/** * @module common */ import type { UrlString } from "@inrupt/solid-client"; import type { DatasetCore } from "@rdfjs/types"; import type { ParseOptions } from "../parser/jsonld"; export type DatasetWithId = DatasetCore & { id: string; }; export type Iri = string; /** * A JSON-LD document is a JSON document including an @context entry. The other * fields may contain any value. * @deprecated Use RDFJS API instead */ export type JsonLd = { "@context": unknown; [property: string]: unknown; }; /** * @deprecated Use RDFJS API instead */ type Proof = { /** * @deprecated Use RDFJS API instead */ type: string; /** * ISO-8601 formatted date */ created: string; /** * @deprecated Use RDFJS API instead */ verificationMethod: string; /** * @deprecated Use RDFJS API instead */ proofPurpose: string; /** * @deprecated Use RDFJS API instead */ proofValue: string; }; /** * A Verifiable Credential JSON-LD document, as specified by the W3C VC HTTP API. * @deprecated Use RDFJS API instead */ export type VerifiableCredentialBase = JsonLd & { id: Iri; /** * @deprecated Use RDFJS API instead */ type: Iri[]; /** * @deprecated Use RDFJS API instead */ issuer: Iri; /** * ISO-8601 formatted date * @deprecated Use RDFJS API instead */ issuanceDate: string; /** * Entity the credential makes claim about. * @deprecated Use RDFJS API instead */ credentialSubject: { /** * @deprecated Use RDFJS API instead */ id: Iri; /** * The claim set is open, as any RDF graph is suitable for a set of claims. * @deprecated Use RDFJS API instead */ [property: string]: unknown; }; /** * @deprecated Use RDFJS API instead */ proof: Proof; }; export type VerifiableCredential = VerifiableCredentialBase & DatasetCore; export type VerifiablePresentation = JsonLd & { id?: string; type: string | string[]; verifiableCredential?: VerifiableCredentialBase[]; holder?: string; proof?: Proof; }; /** * 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. * * @param vcJson A JSON-LD VC. * @returns an equivalent JSON-LD VC, fitted to a specific frame. */ export declare function normalizeVc(vcJson: T): T; /** * Normalizes all VCs wrapped in a VP. * * @param vpJson A JSON-LD VP. * @returns An equivalent JSON-LD VP, with its contained VCs fitted to a specific frame. */ export declare function normalizeVp(vpJson: T): T; /** * Verifies that a given JSON-LD payload conforms to the Verifiable Credential * schema we expect. * @param data The JSON-LD payload * @returns true is the payload matches our expectation. * @deprecated Use isRdfjsVerifiableCredential instead */ export declare function isVerifiableCredential(data: unknown | VerifiableCredentialBase): data is VerifiableCredentialBase; export declare function isUrl(url: string): boolean; /** * @deprecated Use isRdfjsVerifiableCredential instead */ export declare function isVerifiablePresentation(vp: unknown | VerifiablePresentation): vp is VerifiablePresentation; export declare function concatenateContexts(...contexts: unknown[]): unknown; /** * This context contains the required elements to build a valid VC issuance request. */ export declare const defaultContext: string[]; export declare const defaultCredentialTypes: string[]; type LegacyEndpoints = Partial<{ derivationService: UrlString; issuerService: UrlString; statusService: UrlString; verifierService: UrlString; queryService: UrlString; }>; /** * A Verifiable Credential API configuration details. */ export type VerifiableCredentialApiConfiguration = LegacyEndpoints & { specCompliant: Partial<{ derivationService: UrlString; issuerService: UrlString; issuerCredentialAll: UrlString; holderPresentationAll: UrlString; statusService: UrlString; credentialVerifierService: UrlString; presentationVerifierService: UrlString; queryService: UrlString; exchangeService: UrlString; proveService: UrlString; }>; } & { legacy: LegacyEndpoints; }; /** * Discover the available services for a given VC service provider. The detail of * some of these services are given by the [W3C VC API](https://github.com/w3c-ccg/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; *``` * @param vcServiceUrl The URL of the VC services provider. Only the domain is relevant, any provided path will be ignored. * @returns A map of the services available and their URLs. * @since 0.2.0 */ export declare function getVerifiableCredentialApiConfiguration(vcServiceUrl: URL | UrlString): Promise; export declare function internal_applyDataset(vc: T, store: DatasetCore, options?: ParseOptions & { includeVcProperties?: boolean; additionalProperties?: Record; requireId?: boolean; }): DatasetCore; /** * @hidden */ export declare function verifiableCredentialToDataset(vc: T, options?: ParseOptions & { includeVcProperties: true; additionalProperties?: Record; requireId?: true; }): Promise; export declare function verifiableCredentialToDataset(vc: T, options?: ParseOptions & { includeVcProperties?: boolean; additionalProperties?: Record; requireId?: true; }): Promise; export declare function verifiableCredentialToDataset(vc: T, options: ParseOptions & { includeVcProperties: true; additionalProperties?: Record; requireId: false; }): Promise; export declare function verifiableCredentialToDataset(vc: T, options?: ParseOptions & { includeVcProperties?: boolean; additionalProperties?: Record; requireId?: boolean; }): Promise; export declare function hasId(vc: unknown): vc is { id: string; }; /** * @hidden */ export declare function internal_getVerifiableCredentialFromResponse(vcUrl: UrlString | undefined, response: Response, options: ParseOptions & { returnLegacyJsonld: false; skipValidation?: boolean; }): Promise; /** * @deprecated Deprecated in favour of setting returnLegacyJsonld: false. This will be the default value in future * versions of this library. */ export declare function internal_getVerifiableCredentialFromResponse(vcUrl: UrlString | undefined, response: Response, options?: ParseOptions & { returnLegacyJsonld?: true; skipValidation?: boolean; normalize?: (object: VerifiableCredentialBase) => VerifiableCredentialBase; }): Promise; /** * @deprecated Deprecated in favour of setting returnLegacyJsonld: false. This will be the default value in future * versions of this library. */ export declare function internal_getVerifiableCredentialFromResponse(vcUrl: UrlString | undefined, response: Response, options?: ParseOptions & { returnLegacyJsonld?: boolean; skipValidation?: boolean; noVerify?: boolean; }): Promise; /** * Dereference a VC URL, and verify that the resulting content is valid. * * @param vcUrl The URL of the VC. * @param options 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 The dereferenced VC if valid. Throws otherwise. * @since 0.4.0 */ export declare function getVerifiableCredential(vcUrl: UrlString, options: ParseOptions & { fetch?: typeof fetch; skipValidation?: boolean; returnLegacyJsonld: false; normalize?: (object: VerifiableCredentialBase) => VerifiableCredentialBase; }): Promise; /** * Dereference a VC URL, and verify that the resulting content is valid. * * @param vcUrl The URL of the VC. * @param options 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 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. */ export declare function getVerifiableCredential(vcUrl: UrlString, options?: ParseOptions & { fetch?: typeof fetch; skipValidation?: boolean; returnLegacyJsonld?: true; normalize?: (object: VerifiableCredentialBase) => VerifiableCredentialBase; }): Promise; /** * Dereference a VC URL, and verify that the resulting content is valid. * * @param vcUrl The URL of the VC. * @param options 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 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. */ export declare function getVerifiableCredential(vcUrl: UrlString, options?: ParseOptions & { fetch?: typeof fetch; skipValidation?: boolean; returnLegacyJsonld?: boolean; normalize?: (object: VerifiableCredentialBase) => VerifiableCredentialBase; }): Promise; export {};