This is an Alpha release of this package, it is only intended to be used by @inrupt/solid-client-access-grants for now.

@inrupt/solid-client-vc / lookup/query

Module: lookup/query#

Type Aliases#

MinimalPresentation#

Ƭ MinimalPresentation: { verifiableCredential: DatasetWithId[] } & DatasetCore

Defined in#

src/lookup/query.ts:87


QueryByExample#

Ƭ QueryByExample: Object

Based on https://w3c-ccg.github.io/vp-request-spec/#query-by-example.

Type declaration#

Name

Type

credentialQuery

{ example: Partial<VerifiableCredentialBase> & { credentialSchema?: { id: string ; type: string } ; trustedIssuer?: { issuer: string ; required: boolean }[] } ; reason?: string ; required?: boolean }[]

type

"QueryByExample"

Defined in#

src/lookup/query.ts:47


VerifiablePresentationRequest#

Ƭ VerifiablePresentationRequest: Object

A VP request is a standard way of getting a Verifiable Presentation matching the requestor’s needs.

Note: Currently, only the QueryByExample type is implemented, but support for other query types may be added in the future.

Type declaration#

Name

Type

challenge?

string

domain?

string

query

QueryByExample[]

Defined in#

src/lookup/query.ts:72

Functions#

query#

query(queryEndpoint, vpRequest, options): Promise<MinimalPresentation>

Send a Verifiable Presentation Request to a query endpoint in order to retrieve all Verifiable Credentials matching the query, wrapped in a single Presentation.

Parameters#

Name

Type

Description

queryEndpoint

string

URL of the query endpoint.

vpRequest

VerifiablePresentationRequest

VP Request object, compliant with https://w3c-ccg.github.io/vp-request-spec

options

ParseOptions & { fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>(input: string | Request | URL, init?: RequestInit) => Promise<Response> ; normalize?: (vc: VerifiableCredentialBase) => VerifiableCredentialBase ; returnLegacyJsonld: false }

Options object, including an authenticated fetch.

Returns#

Promise<MinimalPresentation>

The resulting Verifiable Presentation wrapping all the Credentials matching the query.

Example

a reason to the request is helpful when interacting with a user. The resulting Verifiable Presentation will wrap zero or more Verifiable Credentials.

const verifiablePresentation = await query(
   "https://example.org/query", { 
     query: [{
       type: "QueryByExample",
       credentialQuery: [
         {
           reason: "Some reason",
           example: {
             type: ["SomeCredentialType"],
           },
         },
       ],
     }]
   },
   { fetch: session.fetch }
 );

Defined in#

src/lookup/query.ts:123

query(queryEndpoint, vpRequest, options?): Promise<ParsedVerifiablePresentation>

Parameters#

Name

Type

queryEndpoint

string

vpRequest

VerifiablePresentationRequest

options?

ParseOptions & { fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>(input: string | Request | URL, init?: RequestInit) => Promise<Response> ; normalize?: (vc: VerifiableCredentialBase) => VerifiableCredentialBase ; returnLegacyJsonld?: true }

Returns#

Promise<ParsedVerifiablePresentation>

Deprecated

Use RDFJS API instead of relying on the JSON structure by setting returnLegacyJsonld to false

Defined in#

src/lookup/query.ts:135

query(queryEndpoint, vpRequest, options?): Promise<ParsedVerifiablePresentation | MinimalPresentation>

Parameters#

Name

Type

queryEndpoint

string

vpRequest

VerifiablePresentationRequest

options?

ParseOptions & { fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>(input: string | Request | URL, init?: RequestInit) => Promise<Response> ; normalize?: (vc: VerifiableCredentialBase) => VerifiableCredentialBase ; returnLegacyJsonld?: boolean }

Returns#

Promise<ParsedVerifiablePresentation | MinimalPresentation>

Deprecated

Use RDFJS API instead of relying on the JSON structure by setting returnLegacyJsonld to false

Defined in#

src/lookup/query.ts:147