@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

@context

unknown

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:262


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:255


defaultCredentialTypes#

Const defaultCredentialTypes: string[]

Defined in#

src/common/common.ts:257

Functions#

concatenateContexts#

concatenateContexts(...contexts): unknown

Parameters#

Name

Type

...contexts

unknown[]

Returns#

unknown

Defined in#

src/common/common.ts:238


getVerifiableCredential#

getVerifiableCredential(vcUrl, options?): Promise<VerifiableCredential>

Dereference a VC URL, and verify that the resulting content is valid.

Since

0.4.0

Parameters#

Name

Type

Description

vcUrl

string

The URL of the VC.

options?

Partial<{ fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response> }>

Options to customize the function behavior. - options.fetch: Specify a WHATWG-compatible authenticated fetch.

Returns#

Promise<VerifiableCredential>

The dereferenced VC if valid. Throws otherwise.

Defined in#

src/common/common.ts:409


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.

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

Parameters#

Name

Type

Description

vcServiceUrl

string | URL

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.

Defined in#

src/common/common.ts:386


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

data

unknown

The JSON-LD payload

Returns#

data is VerifiableCredential

true is the payload matches our expectation.

Defined in#

src/common/common.ts:157


isVerifiablePresentation#

isVerifiablePresentation(vp): vp is VerifiablePresentation

Parameters#

Name

Type

vp

unknown

Returns#

vp is VerifiablePresentation

Defined in#

src/common/common.ts:209


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

T

Parameters#

Name

Type

Description

vcJson

T

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

T

Parameters#

Name

Type

Description

vpJson

T

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:139