UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

62 lines (61 loc) 2 kB
/// <reference types="node" /> /// <reference types="pouchdb-core" /> import Identifier from '../../../Identifier'; import IResolver from '../../../resolvers/IResolver'; /** * Named Arguments of Did Protocol */ export interface DidProtocolOptions { /** * Identifier who wants to send requests. */ sender: Identifier; /** * Resolver for resolving identifier documents */ resolver: IResolver; } /** * Hub Protocol for decrypting/verifying and encrypting/signing payloads */ export default class DidProtocol { /** * Client's Identifier to be used for signing and decrypting. */ private sender; /** * Resolver for resolving Identifier Documents */ private resolver; /** * Crypto factory defining the crypto API */ private cryptoFactory; /** * Key store for storing keys */ private keyStore; /** * User agent options */ private options; /** * Authentication constructor * @param options Arguments to a constructor in a named object */ constructor(options: DidProtocolOptions); /** * Unwrapping method for unwrapping requests/responses. * Decrypt a cipher using [PrivateKey] of Client Identifier and then verify payload. * @param encryptionKeyReference key reference of private key in keystore used to decrypt. * @param cipher the cipher to be decrypted and verified by client Identifier. */ decryptAndVerify(encryptionKeyReference: string, cipher: Buffer): Promise<any>; /** * Wrapping method for wrapping requests/responses. * Sign a payload using [PrivateKey] in client's keystore and encrypt payload using [PublicKey] * @param payload the payload to be signed and encrypted by client Identifier. * #param receiverId identifier for the receiver. */ signAndEncrypt(payload: any, receiverId: string): Promise<string>; }