UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

81 lines (80 loc) 2.91 kB
import { AuthenticationReference, ServiceReference, IdentifierDocumentPublicKey } from './types'; import UserAgentOptions from './UserAgentOptions'; import PublicKey from './crypto/keys/PublicKey'; /** * Class for creating and managing identifiers, * retrieving identifier documents. */ export default class IdentifierDocument { /** * The identifier the document represents. */ id: string; /** * The date the document was created. */ created: Date | undefined; /** * Array of service entries added to the document. */ publicKeys: IdentifierDocumentPublicKey[]; /** * Array of authentication entries added to the document. */ authenticationReferences: AuthenticationReference[]; /** * Array of service entries added to the document. */ serviceReferences: ServiceReference[]; /** * Constructs an instance of the identifier * document. * @param document from which to create the identifier document. * @param options for configuring how to register and resolve identifiers. */ constructor(document: any); /** * Creates a new instance of an identifier document using the * provided public keys. * @param publicKeys to include in the document. */ static create(id: string, publicKeys: IdentifierDocumentPublicKey[]): IdentifierDocument; /** * Creates a new instance of an identifier document using the * provided public keys. * The id is generated. * @param idBase The base id in format did:{method}:{id}. {id} will be filled in by this method * @param publicKeys to include in the document. * @param options User agent options containing the crypto Api */ static createAndGenerateId(idBase: string, publicKeys: IdentifierDocumentPublicKey[], options: UserAgentOptions): Promise<IdentifierDocument>; /** * Adds an authentication reference to the document. * @param authenticationReference to add to the document. */ addAuthenticationReference(authenticationReference: AuthenticationReference): void; /** * Adds a service reference to the document. * @param serviceReference to add to the document. */ addServiceReference(serviceReference: ServiceReference): void; /** * Get Hub Instances from Identity Service Reference. */ getHubInstances(): string[]; /** * Get Hub Locations from Identity Service Reference. */ getHubLocations(): string[]; getPublicKeysFromDocument(): PublicKey[]; /** * Used to control the the properties that are * output by JSON.parse. */ static fromJSON(obj: any): IdentifierDocument; /** * Used to control the the properties that are * output by JSON.stringify. */ toJSON(): any; }