@inrupt/solid-client-vc / common
Module: common#
Type Aliases#
DatasetWithId#
Ƭ DatasetWithId: DatasetCore
& { id
: string
}
Defined in#
src/common/common.ts:41
Iri#
Ƭ Iri: string
Defined in#
src/common/common.ts:43
JsonLd#
Ƭ JsonLd: Object
A JSON-LD document is a JSON document including an
Context
entry. The other fields may contain any value.
Deprecated
Use RDFJS API instead
Index signature#
▪ [property: string
]: unknown
Type declaration#
Name |
Type |
---|---|
|
|
Defined in#
src/common/common.ts:49
VerifiableCredential#
Ƭ VerifiableCredential: VerifiableCredentialBase
& DatasetCore
Defined in#
src/common/common.ts:120
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:310
VerifiableCredentialBase#
Ƭ VerifiableCredentialBase: 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.
Deprecated
Use RDFJS API instead
Defined in#
src/common/common.ts:84
VerifiablePresentation#
Ƭ VerifiablePresentation: JsonLd
& { holder?
: string
; id?
: string
; proof?
: Proof
; type
: string
| string
[] ; verifiableCredential?
: VerifiableCredentialBase
[] }
Defined in#
src/common/common.ts:122
Variables#
defaultContext#
• Const
defaultContext: string
[]
This context contains the required elements to build a valid VC issuance request.
Defined in#
src/common/common.ts:303
defaultCredentialTypes#
• Const
defaultCredentialTypes: string
[]
Defined in#
src/common/common.ts:305
Functions#
concatenateContexts#
▸ concatenateContexts(...contexts
): unknown
Parameters#
Name |
Type |
---|---|
|
|
Returns#
unknown
Defined in#
src/common/common.ts:286
getVerifiableCredential#
▸ getVerifiableCredential(vcUrl
, options
): Promise
<DatasetWithId
>
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. - options.returnLegacyJsonld: Include the normalized JSON-LD in the response |
Returns#
Promise
<DatasetWithId
>
The dereferenced VC if valid. Throws otherwise.
Since
0.4.0
Defined in#
src/common/common.ts:682
▸ 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. - options.returnLegacyJsonld: Include the normalized JSON-LD in the response |
Returns#
Promise
<VerifiableCredential
>
The dereferenced VC if valid. Throws otherwise.
Since
0.4.0
Deprecated
Deprecated in favour of setting returnLegacyJsonld: false. This will be the default value in future versions of this library.
Defined in#
src/common/common.ts:703
▸ getVerifiableCredential(vcUrl
, options?
): Promise
<DatasetWithId
>
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. - options.returnLegacyJsonld: Include the normalized JSON-LD in the response |
Returns#
Promise
<DatasetWithId
>
The dereferenced VC if valid. Throws otherwise.
Since
0.4.0
Deprecated
Deprecated in favour of setting returnLegacyJsonld: false. This will be the default value in future versions of this library.
Defined in#
src/common/common.ts:724
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:434
hasId#
▸ hasId(vc
): vc is Object
Parameters#
Name |
Type |
---|---|
|
|
Returns#
vc is Object
Defined in#
src/common/common.ts:553
internal_applyDataset#
▸ internal_applyDataset<T
>(vc
, store
, options?
): DatasetCore
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
---|---|
|
|
|
|
|
|
Returns#
DatasetCore
Defined in#
src/common/common.ts:449
internal_getVerifiableCredentialFromResponse#
▸ internal_getVerifiableCredentialFromResponse(vcUrl
, response
, options?
): Promise
<VerifiableCredential
>
Parameters#
Name |
Type |
---|---|
|
|
|
|
|
|
Returns#
Promise
<VerifiableCredential
>
Deprecated
Deprecated in favour of setting returnLegacyJsonld: false. This will be the default value in future versions of this library.
Defined in#
src/common/common.ts:577
▸ internal_getVerifiableCredentialFromResponse(vcUrl
, response
, options?
): Promise
<DatasetWithId
>
Parameters#
Name |
Type |
---|---|
|
|
|
|
|
|
Returns#
Promise
<DatasetWithId
>
Deprecated
Deprecated in favour of setting returnLegacyJsonld: false. This will be the default value in future versions of this library.
Defined in#
src/common/common.ts:590
isUrl#
▸ isUrl(url
): boolean
Parameters#
Name |
Type |
---|---|
|
|
Returns#
boolean
Defined in#
src/common/common.ts:243
isVerifiableCredential#
▸ isVerifiableCredential(data
): data is VerifiableCredentialBase
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 VerifiableCredentialBase
true is the payload matches our expectation.
Deprecated
Use isRdfjsVerifiableCredential instead
Defined in#
src/common/common.ts:199
isVerifiablePresentation#
▸ isVerifiablePresentation(vp
): vp is VerifiablePresentation
Parameters#
Name |
Type |
---|---|
|
|
Returns#
vp is VerifiablePresentation
Deprecated
Use isRdfjsVerifiableCredential instead
Defined in#
src/common/common.ts:257
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:150
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:180
verifiableCredentialToDataset#
▸ verifiableCredentialToDataset<T
>(vc
, options?
): Promise
<DatasetWithId
>
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
---|---|
|
|
|
|
Returns#
Promise
<DatasetWithId
>
Defined in#
src/common/common.ts:501
▸ verifiableCredentialToDataset<T
>(vc
, options
): Promise
<T
& DatasetCore
>
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
---|---|
|
|
|
|
Returns#
Promise
<T
& DatasetCore
>
Defined in#
src/common/common.ts:509
▸ verifiableCredentialToDataset<T
>(vc
, options?
): Promise
<DatasetCore
>
Type parameters#
Name |
Type |
---|---|
|
extends |
Parameters#
Name |
Type |
---|---|
|
|
|
|
Returns#
Promise
<DatasetCore
>
Defined in#
src/common/common.ts:517