UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

83 lines (82 loc) 2.65 kB
import Identifier from "../Identifier"; /** * Type to describe a claim description. */ export declare type ClaimDescription = { header: string; body: string; }; /** * Type to describe a claim key-value pair. */ export declare type Claim = { [key: string]: string; }; /** * Class that represents a ClaimObject * @class */ export default class ClaimObject { /** * Pointer to the claimClass that is tied to this claimObject. */ claimClass: string; /** * Context of the specific claim object */ context: string; /** * Type of the Claim Object. */ type: string; /** * Identifier of the entity that issued ClaimObject */ issuer: string; /** * A list of claim descriptions that will define each claim. */ claimDescriptions: ClaimDescription[]; /** * A list of claims that are contained in this claimObject. */ claimDetails: Claim[]; /** * The Claim Details if they have been signed. */ signedClaimDetails?: string; /** * Instantiates a new ClaimObject. * @param claimClass Pointer to the claimClass that is tied to this claimObject. * @param claimDescriptions A list of claim descriptions that will define each claim. * @param claimDetails A list of claims that are contained in this claimObject. */ constructor(claimClass: string, context: string, type: string, issuer: string, claimDescriptions: ClaimDescription[], claimDetails: Claim[], signedClaimDetails?: string); /** * Sign the claim details with signer. * @param signer Identifier that will sign the claim details. */ signClaimDetails(signer: Identifier, keyReference: string): Promise<void>; /** * If details are signed, return signed claim details. * Else return unsigned claim details. */ getClaimDetails(): string | Claim[]; /** * Add a claim to the claim details. * @param {Claim} claim Claim to be added to claimDetails. * @param {ClaimDescription} claimDescription Optional parameter if want to also add a corresponding claim description. */ addClaim(claim: Claim, claimDescription?: ClaimDescription): Promise<void>; /** * Stringify ClaimObject. * @returns A Stringified ClaimObject in the correct format */ serialize(): string; /** * Create new ClaimObject from stringified JSON. * @param object Stringifed JSON object * @returns a ClaimObject */ static deserialize(object: any): Promise<ClaimObject>; }