@inrupt/solid-client-vc / common
Module: common#
Type Aliases#
Iri#
Ƭ Iri: string
Defined in#
src/common/common.ts:35
JsonLd#
Ƭ JsonLd: Object
A JSON-LD document is a JSON document including an
Context
entry. The other fields may contain any value.
Index signature#
▪ [property: string
]: unknown
Type declaration#
Name |
Type |
---|---|
|
|
Defined in#
src/common/common.ts:40
VerifiableCredential#
Ƭ VerifiableCredential: JsonLd
& { credentialSubject
: { [property: string]
: unknown
; id
: Iri
} ; id
: Iri
; issuanceDate
: string
; issuer
: Iri
; proof
: Proof
; type
: Iri
[] }
A Verifiable Credential JSON-LD document, as specified by the W3C VC HTTP API.
Defined in#
src/common/common.ts:59
VerifiableCredentialApiConfiguration#
Ƭ VerifiableCredentialApiConfiguration: Partial
<{ derivationService
: UrlString
; issuerService
: UrlString
; statusService
: UrlString
; verifierService
: UrlString
}> & { specCompliant
: Partial
<{ credentialVerifierService
: UrlString
; derivationService
: UrlString
; exchangeService
: UrlString
; holderPresentationAll
: UrlString
; issuerCredentialAll
: UrlString
; issuerService
: UrlString
; presentationVerifierService
: UrlString
; proveService
: UrlString
; queryService
: UrlString
; statusService
: UrlString
}> } & { legacy
: Partial
<{ derivationService
: UrlString
; issuerService
: UrlString
; statusService
: UrlString
; verifierService
: UrlString
}> }
A Verifiable Credential API configuration details.
Defined in#
src/common/common.ts:261
VerifiablePresentation#
Ƭ VerifiablePresentation: JsonLd
& { holder?
: string
; id?
: string
; proof?
: Proof
; type
: string
| string
[] ; verifiableCredential?
: VerifiableCredential
[] }
Defined in#
src/common/common.ts:80
Variables#
defaultContext#
• Const
defaultContext: string
[]
This context contains the required elements to build a valid VC issuance request.
Defined in#
src/common/common.ts:254
defaultCredentialTypes#
• Const
defaultCredentialTypes: string
[]
Defined in#
src/common/common.ts:256
Functions#
concatenateContexts#
▸ concatenateContexts(...contexts
): unknown
Parameters#
Name |
Type |
---|---|
|
|
Returns#
unknown
Defined in#
src/common/common.ts:237
getVerifiableCredential#
▸ getVerifiableCredential(vcUrl
, options?
): Promise
<VerifiableCredential
>
Dereference a VC URL, and verify that the resulting content is valid.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the VC. |
|
|
Options to customize the function behavior. - options.fetch: Specify a WHATWG-compatible authenticated fetch. |
Returns#
Promise
<VerifiableCredential
>
The dereferenced VC if valid. Throws otherwise.
Since
0.4.0
Defined in#
src/common/common.ts:408
getVerifiableCredentialApiConfiguration#
▸ getVerifiableCredentialApiConfiguration(vcServiceUrl
): Promise
<VerifiableCredentialApiConfiguration
>
Discover the available services for a given VC service provider. The detail of some of these services are given by the W3C VC API.
The returned value has two entries at its top-level, legacy
and specCompliant
.
The former reflects the legacy (default) behavior, and relies on an ad-hoc discovery
mechanism. The latter follows what the VC-API specification requires.
Note that since the specification only mandates URL patterns, what the discovery gets you is the URL where the endpoint should be available if it is present. Whether it actually is available or not is something you cannot assume and must explicitly check.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The URL of the VC services provider. Only the domain is relevant, any provided path will be ignored. |
Returns#
Promise
<VerifiableCredentialApiConfiguration
>
A map of the services available and their URLs.
Example
Here is how the spec-compliant endpoints are discovered:
const config = await getVerifiableCredentialApiConfiguration("https://example.org/vc-provider");
const issuer = config.specCompliant.issuerService;
Here is how legacy endpoints are accessed:
const config = await getVerifiableCredentialApiConfiguration("https://example.org/vc-provider");
const legacyIssuer = config.legacy.issuerService;
Since
0.2.0
Defined in#
src/common/common.ts:385
isVerifiableCredential#
▸ isVerifiableCredential(data
): data is VerifiableCredential
Verifies that a given JSON-LD payload conforms to the Verifiable Credential schema we expect.
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
The JSON-LD payload |
Returns#
data is VerifiableCredential
true is the payload matches our expectation.
Defined in#
src/common/common.ts:156
isVerifiablePresentation#
▸ isVerifiablePresentation(vp
): vp is VerifiablePresentation
Parameters#
Name |
Type |
---|---|
|
|
Returns#
vp is VerifiablePresentation
Defined in#
src/common/common.ts:208
normalizeVc#
▸ normalizeVc<T
>(vcJson
): T
This function is a temporary stopgap until we implement proper JSON-LD parsing. It refactors know misalignments between the JSON-LD object we receive and the JSON frame we expect.
Type parameters#
Name |
---|
|
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
A JSON-LD VC. |
Returns#
T
an equivalent JSON-LD VC, fitted to a specific frame.
Defined in#
src/common/common.ts:108
normalizeVp#
▸ normalizeVp<T
>(vpJson
): T
Normalizes all VCs wrapped in a VP.
Type parameters#
Name |
---|
|
Parameters#
Name |
Type |
Description |
---|---|---|
|
|
A JSON-LD VP. |
Returns#
T
An equivalent JSON-LD VP, with its contained VCs fitted to a specific frame.
Defined in#
src/common/common.ts:138