import type { LinkedDataProof, ProofPurpose } from '@interop/jsonld-signatures'; import type { IVerifiableCredential, IVerifiablePresentation } from '@interop/data-integrity-core'; import type { IDocumentLoader } from '@interop/data-integrity-core/loader'; import { CredentialIssuancePurpose } from './CredentialIssuancePurpose.js'; export { dateRegex } from './helpers.js'; export declare const defaultDocumentLoader: IDocumentLoader; export { CredentialIssuancePurpose }; /** A verifiable credential. */ export type VerifiableCredential = IVerifiableCredential; /** A verifiable presentation. */ export type VerifiablePresentation = IVerifiablePresentation; /** A verifiable presentation (signed or unsigned). */ export type Presentation = IVerifiablePresentation; /** A single entry in a fine-grained verification result `log`. */ export interface LogEntry { /** Check identifier (for example `valid_signature`). */ id: string; /** Whether the check passed. */ valid: boolean; } /** The result of verifying a single credential. */ export interface VerifyCredentialResult { /** True if verified, false if not. */ verified: boolean; /** Credential status check result. */ statusResult?: any; /** Per-proof verification results. */ results?: any[]; /** Fine-grained check log. */ log?: LogEntry[]; /** The source credential, present when `includeCredentials` is `true`. */ credential?: VerifiableCredential; /** The verified credential's id. */ credentialId?: string; /** Set if verification failed. */ error?: Error; } /** The result of verifying a presentation. */ export interface VerifyPresentationResult { /** True if verified, false if not. */ verified: boolean; /** Presentation proof result. */ presentationResult?: any; /** Per-credential verification results. */ credentialResults?: VerifyCredentialResult[]; /** Present on the error and unsigned-presentation return paths. */ results?: any[]; /** Set if verification failed. */ error?: Error; } /** A function for checking credential status. */ export type CheckStatus = (options: any) => Promise; /** Options for {@link issue}. */ export interface IssueCredentialOptions { credential?: VerifiableCredential; suite?: LinkedDataProof; purpose?: ProofPurpose; documentLoader?: IDocumentLoader; now?: string | Date; maxClockSkew?: number; } /** Options for {@link derive}. */ export interface DeriveOptions { verifiableCredential?: VerifiableCredential; suite?: LinkedDataProof; documentLoader?: IDocumentLoader; } /** Options for {@link verifyCredential}. */ export interface VerifyCredentialOptions { credential?: VerifiableCredential; suite?: LinkedDataProof | LinkedDataProof[]; purpose?: ProofPurpose; controller?: object; documentLoader?: IDocumentLoader; checkStatus?: CheckStatus; now?: string | Date; maxClockSkew?: number; } /** Options for {@link verify}. */ export interface VerifyPresentationOptions { presentation?: VerifiablePresentation; suite?: LinkedDataProof | LinkedDataProof[]; unsignedPresentation?: boolean; presentationPurpose?: ProofPurpose; challenge?: string; controller?: object; domain?: string; documentLoader?: IDocumentLoader; checkStatus?: CheckStatus; now?: string | Date; maxClockSkew?: number; includeCredentials?: boolean; } /** Options for {@link createPresentation}. */ export interface CreatePresentationOptions { verifiableCredential?: VerifiableCredential | VerifiableCredential[]; id?: string; holder?: string; now?: string | Date; version?: number; verify?: boolean; maxClockSkew?: number; } /** Options for {@link signPresentation}. */ export interface SignPresentationOptions { presentation?: Presentation; suite?: LinkedDataProof; purpose?: ProofPurpose; domain?: string; challenge?: string; documentLoader?: IDocumentLoader; } /** Options for {@link _checkCredential}. */ export interface CheckCredentialOptions { credential: VerifiableCredential; log?: LogEntry[]; now?: string | Date; mode?: string; maxClockSkew?: number; } /** * Issues a verifiable credential (by taking a base credential document, * and adding a digital signature to it). * * @param options - The options to use. * @param options.credential - Base credential document. * @param options.suite - Signature suite (with private key material or an API * to use it), passed in to `sign()`. * @param options.purpose - A ProofPurpose. If not specified, a default purpose * will be created. * @param options.documentLoader - A document loader. * @param options.now - A string representing date time in ISO 8601 format or an * instance of Date. Defaults to current date time. * @param options.maxClockSkew - A maximum number of seconds that clocks may be * skewed when checking date-times against `now`. * * @throws {Error} If missing required properties. * * @returns Resolves on completion. */ export declare function issue({ credential, suite, purpose, documentLoader, now, maxClockSkew }?: IssueCredentialOptions): Promise; /** * Derives a proof from the given verifiable credential, resulting in a new * verifiable credential. This method is usually used to generate selective * disclosure and / or unlinkable proofs. * * @param options - The options to use. * @param options.verifiableCredential - The verifiable credential containing a * base proof to derive another proof from. * @param options.suite - Derived proof signature suite. * @param options.documentLoader - A document loader. * * @throws {Error} If missing required properties. * * @returns Resolves on completion. */ export declare function derive({ verifiableCredential, suite, documentLoader }?: DeriveOptions): Promise; /** * Verifies a verifiable presentation: * - Checks that the presentation is well-formed * - Checks the proofs (for example, checks digital signatures against the * provided public keys). * * @param options - The options to use. * @param options.presentation - Verifiable presentation, signed or unsigned, * that may contain within it a verifiable credential. * @param options.suite - One or more signature suites that are supported by the * caller's use case. This is an explicit design decision -- the calling code * must specify which signature types (ed25519, RSA, etc) are allowed. * Although it is expected that the secure resolution/fetching of the public * key material (to verify against) is to be handled by the documentLoader, * the suite param can optionally include the key directly. * @param options.unsignedPresentation - By default, this function assumes that * a presentation is signed (and will return an error if a `proof` section is * missing). Set this to `true` if you're using an unsigned presentation. * @param options.presentationPurpose - Optional proof purpose (a default one * will be created if not passed in). * @param options.challenge - Required if purpose is not passed in. * @param options.controller - A controller. * @param options.domain - A domain. * @param options.documentLoader - A document loader. * @param options.checkStatus - Optional function for checking credential status * if `credentialStatus` is present on the credential. * @param options.now - A string representing date time in ISO 8601 format or an * instance of Date. Defaults to current date time. * @param options.maxClockSkew - A maximum number of seconds that clocks may be * skewed when checking date-times against `now`. * @param options.includeCredentials - Set to `true` to include each verified * `credential` in its entry in `credentialResults`. Defaults to `true` to * preserve backwards compatibility; set to `false` to omit them. * * @returns The verification result. */ export declare function verify(options?: VerifyPresentationOptions): Promise; /** * Verifies a verifiable credential: * - Checks that the credential is well-formed * - Checks the proofs (for example, checks digital signatures against the * provided public keys). * * @param options - The options. * @param options.credential - Verifiable credential. * @param options.suite - One or more signature suites that are supported by the * caller's use case. This is an explicit design decision -- the calling code * must specify which signature types (ed25519, RSA, etc) are allowed. * Although it is expected that the secure resolution/fetching of the public * key material (to verify against) is to be handled by the documentLoader, * the suite param can optionally include the key directly. * @param options.purpose - Optional proof purpose (a default one will be * created if not passed in). * @param options.documentLoader - A document loader. * @param options.checkStatus - Optional function for checking credential status * if `credentialStatus` is present on the credential. * @param options.now - A string representing date time in ISO 8601 format or an * instance of Date. Defaults to current date time. * @param options.maxClockSkew - A maximum number of seconds that clocks may be * skewed when checking date-times against `now`. * * @returns The verification result. */ export declare function verifyCredential(options?: VerifyCredentialOptions): Promise; /** * Creates an unsigned presentation from a given verifiable credential. * * @param options - Options to use. * @param options.verifiableCredential - One or more verifiable credential. * @param options.id - Optional VP id. * @param options.holder - Optional presentation holder url. * @param options.now - A string representing date time in ISO 8601 format or an * instance of Date. Defaults to current date time. * @param options.version - The VC context version to use. * @param options.verify - If set to true, throw verification errors for * individual VCs (such as when the VC is expired, etc). * @param options.maxClockSkew - A maximum number of seconds that clocks may be * skewed when checking date-times against `now`. * * @throws {TypeError} If verifiableCredential param is missing. * @throws {Error} If the credential (or the presentation params) are missing * required properties. * * @returns The credential wrapped inside of a VerifiablePresentation. */ export declare function createPresentation({ verifiableCredential, id, holder, now, version, verify, maxClockSkew }?: CreatePresentationOptions): Presentation; /** * Signs a given presentation. * * @param options - Options to use. * @param options.presentation - A presentation. * @param options.suite - Passed in to `sign()`. * @param options.purpose - A ProofPurpose. If not specified, a default purpose * will be created with the domain and challenge options. * @param options.domain - A domain. * @param options.challenge - A required challenge. * @param options.documentLoader - A document loader. * * @returns A VerifiablePresentation with a proof. */ export declare function signPresentation(options?: SignPresentationOptions): Promise; /** * @param presentation - An object that could be a presentation. * * @throws {Error} */ export declare function _checkPresentation(presentation: Presentation): void; /** * @param options - The options. * @param options.credential - An object that could be a VerifiableCredential. * @param options.log - Optional events log, for fine-grained verification * result reporting. * @param options.now - A string representing date time in ISO 8601 format or an * instance of Date. Defaults to current date time. * @param options.mode - The mode of operation for this validation function, * either `issue` or `verify`. * @param options.maxClockSkew - A maximum number of seconds that clocks may be * skewed when checking date-times against `now`. * * @throws {Error} */ export declare function _checkCredential({ credential, log, now, mode, maxClockSkew }: CheckCredentialOptions): void; //# sourceMappingURL=index.d.ts.map