UNPKG

@ew-did-registry/claims

Version:

The package exposes functionality needed to create, inspect, approve, and verify Private and Public claims

70 lines (69 loc) 2.99 kB
import { IDIDDocumentFull } from '@ew-did-registry/did-document'; import { IJWT } from '@ew-did-registry/jwt'; import { IDidStore } from '@ew-did-registry/did-store-interface'; import { IDIDDocument } from '@ew-did-registry/did-resolver-interface'; import { EwSigner } from '@ew-did-registry/did-ethr-resolver'; import { IClaims, IPublicClaim, IPrivateClaim, VerificationPurpose } from '../models'; /** * @class * Base class for extending by other claims classes */ export declare class Claims implements IClaims { protected document: IDIDDocumentFull; protected store: IDidStore; jwt: IJWT; keys: { privateKey?: string; publicKey: string; }; did: string; /** * @constructor * * @param { IKeys } keys * @param document * @param store */ constructor(owner: EwSigner, document: IDIDDocumentFull, store: IDidStore); /** * Verifies issuance and publishing of claim at `claimUrl`. * On success returns claim. * Verification takes into account purpose on which claim was issued. * * @param claimUrl: Url of claim to be verified. This method will retrieve * the claim using the didStore configured for the class * @param params.hashFns: The function used to determine the of hash of the claim * token used in the DID document. Used to verify that the DID document service endpoint * matches the retrieved claim. * @param params.issuerDoc: Document with verification methods to verify claim issuance with * @param params.holderDoc: Document with service endpoints to verify claim publishing with * @param params.verificationPurpose: Specifies which verification methods to use. * `VerificationPurpose.Authenticate` is used to verify claim issued to authenticate identity * `VerificationPurpose.Assertion` is used to assert issuer approval. * By default verification asserts claim approval. * */ verify(claimUrl: string, { hashFns, issuerDoc, holderDoc, verificationPurpose, }?: { hashFns?: { [alg: string]: (data: string) => string; }; issuerDoc?: IDIDDocument; holderDoc?: IDIDDocument; verificationPurpose?: VerificationPurpose; }): Promise<IPublicClaim | IPrivateClaim>; /** * @description Verifies that token stored at `claimUrl` is one of the services of `holderDoc`. * * @param claimUrl: url of the published claim * @param params.hashFns: The function used to determine the of hash of the claim * token used in the DID document. Used to verify that the DID document service endpoint * matches the retrieved claim. * @param params.holderDoc: Document in which to search for service endpoint. */ validateServiceEndpointToken(claimUrl: string, { hashFns, holderDoc, }: { hashFns?: { [alg: string]: (data: string) => string; }; holderDoc: IDIDDocument; }): Promise<void>; }