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

Module: lookup/query#

Type Aliases#

QueryByExample#

Ƭ QueryByExample: Object

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

Type declaration#

Name

Type

credentialQuery

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

type

"QueryByExample"

Defined in#

src/lookup/query.ts:34


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

Functions#

query#

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

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

Example

The following shows how to query for credentials of a certain type. Adding 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 }
 );

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?

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

Options object, including an authenticated fetch.

Returns#

Promise<VerifiablePresentation>

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

Defined in#

src/lookup/query.ts:97