@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
101 lines (100 loc) • 4.06 kB
TypeScript
/// <reference types="node" />
/// <reference types="pouchdb-core" />
import IdentifierDocument from './IdentifierDocument';
import UserAgentOptions from './UserAgentOptions';
import { IdentifierDocumentPublicKey } from './types';
/**
* Class for creating and managing identifiers,
* retrieving identifier documents.
*/
export default class Identifier {
identifier: IdentifierDocument | string;
/**
* The string representation of the identier for the persona
* in the format 'did:{method}:{id}'.
*/
id: string;
/**
* The identifier document for the identifier
* if one exists.
*/
document: IdentifierDocument | undefined;
/**
* User Agent Options
*/
options: UserAgentOptions | undefined;
/**
* Constructs an instance of the Identifier
* class using the provided identifier or identifier document.
* @param identifier either the string representation of an identifier or a identifier document.
* @param [options] for configuring how to register and resolve identifiers.
*/
constructor(identifier: IdentifierDocument | string, options?: UserAgentOptions);
/**
* Creates a new decentralized identifier.
* @param [options] for configuring how to register and resolve identifiers.
*/
static create(options: UserAgentOptions): Promise<Identifier>;
/**
* Creates a new decentralized identifier, using the current identifier
* and the specified target. If the registar flag is true, the newly created
* identifier will be registered using the
* @param target entity for which to create the linked identifier
* @param register flag indicating whether the new identifier should be registered
* with a ledger.
*/
createLinkedIdentifier(target: string, register?: boolean): Promise<Identifier>;
/**
* Generate a key and save it into the store
* @param generator interface
* @param algorithm for the key
* @param target id of peer
*/
private generateAndSaveKey;
/**
* Gets the IdentifierDocument for the identifier
* instance, throwing if no identifier has been
* created.
*/
getDocument(): Promise<IdentifierDocument>;
/**
* Performs a public key lookup using the
* specified key identifier, returning the
* key defined in document.
* @param keyIdentifier the identifier of the public key.
*/
getPublicKey(keyIdentifier?: string): Promise<IdentifierDocumentPublicKey>;
/**
* Generate a storage identifier to store a key
* @param personaId The identifier for the persona
* @param target The identifier for the peer. Will be persona for non-pairwise keys
* @param algorithm Key algorithm
* @param keyType Key type
*/
static keyStorageIdentifier(personaId: string, target: string, algorithm: string, keyType: string): string;
private createIdentifierDocument;
private getDidDocumentKeyType;
/**
* Sign payload with key specified by keyStorageIdentifier in options.keyStore
* @param payload object to be signed
* @param keyReference the identifier for the key used to sign payload.
*/
sign(payload: any, keyReference: string): Promise<string>;
/**
* Verify the payload with public key from the Identifier Document.
* @param jws the signed token to be verified.
*/
verify(jws: string): Promise<string>;
/**
* Encrypt payload using Public Key registered on Identifier Document.
* @param payload object that will be encrypted.
* @param encryptionKeys used for the encryption.
*/
encrypt(payload: any): Promise<string>;
/**
* Decrypt cipher using key referenced in keystore.
* @param cipher cipher to be decrypted.
* @param keyReference string that references what key to use from keystore.
*/
decrypt(cipher: Buffer, keyReference: string): Promise<string>;
}