UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

37 lines 2.32 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); const HubCommitWriteRequest_1 = require("../../../src/hubSession/requests/HubCommitWriteRequest"); const JoseToken_1 = require("../../../src/crypto/protocols/jose/JoseToken"); const ProtectionFormat_1 = require("../../../src/crypto/keyStore/ProtectionFormat"); const JoseConstants_1 = require("../../../src/crypto/protocols/jose/JoseConstants"); const ProtocolTest_1 = require("../../crypto/protocols/jose/ProtocolTest"); const typescript_map_1 = require("typescript-map"); const JoseProtocol_1 = require("../../../src/crypto/protocols/jose/JoseProtocol"); describe('HubWriteRequest', () => { describe('getRequestJson()', () => { it('should return a complete request body', async () => { const options = { payloadProtection: new JoseProtocol_1.default() }; const protectedHeader = new typescript_map_1.TSMap(); const flattenedCommitJson = new JoseToken_1.default(options, new ProtocolTest_1.default(), [ [JoseConstants_1.default.tokenFormat, ProtectionFormat_1.ProtectionFormat.JwsFlatJson], [JoseConstants_1.default.tokenPayload, 'test'], [JoseConstants_1.default.tokenProtected, 'test'], [JoseConstants_1.default.tokenSignatures, [{ signature: 'test', protected: protectedHeader }]] ]); const req = new HubCommitWriteRequest_1.default(flattenedCommitJson); const json = await req.getRequestJson(); expect(json).toEqual({ '@context': 'https://schema.identity.foundation/0.1', '@type': 'WriteRequest', commit: '{"format":"JwsFlatJson","payload":"test","protected":"test","signatures":[{"signature":"test","protected":{}}]}', }); }); }); }); //# sourceMappingURL=HubCommitWriteRequest.spec.js.map