UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

60 lines 2.57 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); const Identifier_1 = require("../../src/Identifier"); const IdentifierDocument_1 = require("../../src/IdentifierDocument"); const RegistrarCryptoOptions_1 = require("../../src/registrars/RegistrarCryptoOptions"); const CryptoFactory_1 = require("../../src/crypto/plugin/CryptoFactory"); const src_1 = require("../../src"); const JoseProtocol_1 = require("../../src/crypto/protocols/jose/JoseProtocol"); /** * Implementation of a registrar for testing. */ class TestRegistrar { constructor() { /** * Crypto options for the Registrar */ this.registrarCryptoOptions = new RegistrarCryptoOptions_1.default(new CryptoFactory_1.default(new src_1.KeyStoreInMemory(), src_1.SubtleCryptoNode.getSubtleCrypto()), new JoseProtocol_1.default()); } /** * Prepares the resolver for the test run. * @param identifier to use for the test. * @param identifierDocument to use for the test. */ prepareTest(identifier, identifierDocument) { this.identifier = identifier; this.identifierDocument = identifierDocument; } /** * Registers the identifier document on the ledger * returning the identifier generated by the registrar. * @inheritdoc */ async register(identifierDocument) { // if (this.identifierDocument === identifierDocument) { // return this.identifier; // } // throw new Error('Not found'); console.log(identifierDocument); console.log(this.identifierDocument); return this.identifier; } /** * Uses the specified input for generating * an identifier reference, but does not register * with a ledger. * @inheritdoc */ async generateIdentifier(input) { const document = IdentifierDocument_1.default.create(`${input.id}:12345abcde`, input.publicKeys); this.identifierDocument = document; this.identifier = new Identifier_1.default(document); return this.identifier; } } exports.default = TestRegistrar; //# sourceMappingURL=TestRegistrar.js.map