From e78905ad6d1a64b6f31f22028e90f21178f18121 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Thu, 4 Aug 2022 00:27:30 +0200 Subject: [PATCH 01/15] VDX-88 WIP --- packages/domain-linkage-verifier/CHANGELOG.md | 1 + packages/domain-linkage-verifier/LICENSE | 201 +++++++++++++++++ packages/domain-linkage-verifier/README.md | 53 +++++ .../__tests__/localAgent.test.ts | 35 +++ .../__tests__/restAgent.test.ts | 71 ++++++ .../shared/domainLinkageVerifierAgentLogic.ts | 204 ++++++++++++++++++ packages/domain-linkage-verifier/agent.yml | 76 +++++++ .../api-extractor.json | 3 + packages/domain-linkage-verifier/package.json | 44 ++++ .../src/agent/DomainLinkageVerifier.ts | 47 ++++ packages/domain-linkage-verifier/src/index.ts | 7 + .../src/types/IDomainLinkageVerifier.ts | 24 +++ .../domain-linkage-verifier/tsconfig.json | 10 + packages/tsconfig.json | 3 +- 14 files changed, 778 insertions(+), 1 deletion(-) create mode 100644 packages/domain-linkage-verifier/CHANGELOG.md create mode 100644 packages/domain-linkage-verifier/LICENSE create mode 100644 packages/domain-linkage-verifier/README.md create mode 100644 packages/domain-linkage-verifier/__tests__/localAgent.test.ts create mode 100644 packages/domain-linkage-verifier/__tests__/restAgent.test.ts create mode 100644 packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts create mode 100644 packages/domain-linkage-verifier/agent.yml create mode 100644 packages/domain-linkage-verifier/api-extractor.json create mode 100644 packages/domain-linkage-verifier/package.json create mode 100644 packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts create mode 100644 packages/domain-linkage-verifier/src/index.ts create mode 100644 packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts create mode 100644 packages/domain-linkage-verifier/tsconfig.json diff --git a/packages/domain-linkage-verifier/CHANGELOG.md b/packages/domain-linkage-verifier/CHANGELOG.md new file mode 100644 index 000000000..420e6f23d --- /dev/null +++ b/packages/domain-linkage-verifier/CHANGELOG.md @@ -0,0 +1 @@ +# Change Log diff --git a/packages/domain-linkage-verifier/LICENSE b/packages/domain-linkage-verifier/LICENSE new file mode 100644 index 000000000..a51495fe7 --- /dev/null +++ b/packages/domain-linkage-verifier/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2022] [Sphereon BV, info@sphereon.com] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/domain-linkage-verifier/README.md b/packages/domain-linkage-verifier/README.md new file mode 100644 index 000000000..5765ad77a --- /dev/null +++ b/packages/domain-linkage-verifier/README.md @@ -0,0 +1,53 @@ + +

+
+ Sphereon +
Domain Linkage Verifier (Typescript) +
+

+ +--- + +**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!** + +--- + +A Veramo connection manager plugin. This plugin manages connection configurations to third parties and persists them. These configurations can then be used to establish the connection. + +## Supported connection types + + +## Available functions + +## Usage + +### Adding the plugin to an agent: + +```typescript +const agent = createAgent({ + plugins: [ + new ConnectionManager(), + ], +}) +``` + +### Get a party: + +```typescript +const partyId = '8efb937f-4e90-4056-9a4d-7185ce8dc173' +const result = await agent.cmGetConnection({ + partyId, +}) +``` + +## Installation + +```shell +yarn add @sphereon/ssi-sdk-domain-linkage-verifier +``` + +## Build + +```shell +yarn build +``` diff --git a/packages/domain-linkage-verifier/__tests__/localAgent.test.ts b/packages/domain-linkage-verifier/__tests__/localAgent.test.ts new file mode 100644 index 000000000..099e417f7 --- /dev/null +++ b/packages/domain-linkage-verifier/__tests__/localAgent.test.ts @@ -0,0 +1,35 @@ +import { getConfig } from '@veramo/cli/build/setup' +import { createObjects } from '@veramo/cli/build/lib/objectCreator' +import { Connection } from 'typeorm' + +jest.setTimeout(30000) + +import domainLinkageVerifierAgentLogic from './shared/domainLinkageVerifierAgentLogic' + +let dbConnection: Promise +let agent: any + +const setup = async (): Promise => { + const config = getConfig('packages/connection-manager/agent.yml') + const { localAgent, db } = createObjects(config, { localAgent: '/agent', db: '/dbConnection' }) + agent = localAgent + dbConnection = db + + return true +} + +const tearDown = async (): Promise => { + await (await dbConnection).close() + return true +} + +const getAgent = () => agent +const testContext = { + getAgent, + setup, + tearDown, +} + +describe('Local integration tests', () => { + domainLinkageVerifierAgentLogic(testContext) +}) diff --git a/packages/domain-linkage-verifier/__tests__/restAgent.test.ts b/packages/domain-linkage-verifier/__tests__/restAgent.test.ts new file mode 100644 index 000000000..203096beb --- /dev/null +++ b/packages/domain-linkage-verifier/__tests__/restAgent.test.ts @@ -0,0 +1,71 @@ +import 'cross-fetch/polyfill' +import express from 'express' +import { Server } from 'http' +import { Connection } from 'typeorm' +import { IAgent, createAgent, IAgentOptions } from '@veramo/core' +import { AgentRestClient } from '@veramo/remote-client' +import { AgentRouter, RequestWithAgentRouter } from '@veramo/remote-server' +import { getConfig } from '@veramo/cli/build/setup' +import { createObjects } from '@veramo/cli/build/lib/objectCreator' +import domainLinkageVerifierAgentLogic from './shared/domainLinkageVerifierAgentLogic' +import {IDomainLinkageVerifier} from '../src'; + +jest.setTimeout(30000) + +const port = 3002 +const basePath = '/agent' + +let serverAgent: IAgent +let restServer: Server +let dbConnection: Promise + +const getAgent = (options?: IAgentOptions) => + createAgent({ + ...options, + plugins: [ + new AgentRestClient({ + url: 'http://localhost:' + port + basePath, + enabledMethods: serverAgent.availableMethods(), + schema: serverAgent.getSchema(), + }), + ], + }) + +const setup = async (): Promise => { + const config = getConfig('packages/domain-linkage-verifier/agent.yml') + const { agent, db } = createObjects(config, { agent: '/agent', db: '/dbConnection' }) + serverAgent = agent + dbConnection = db + + const agentRouter = AgentRouter({ + exposedMethods: serverAgent.availableMethods(), + }) + + const requestWithAgent = RequestWithAgentRouter({ + agent: serverAgent, + }) + + return new Promise((resolve) => { + const app = express() + app.use(basePath, requestWithAgent, agentRouter) + restServer = app.listen(port, () => { + resolve(true) + }) + }) +} + +const tearDown = async (): Promise => { + restServer.close() + await (await dbConnection).close() + return true +} + +const testContext = { + getAgent, + setup, + tearDown, +} + +describe('REST integration tests', () => { + domainLinkageVerifierAgentLogic(testContext) +}) diff --git a/packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts b/packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts new file mode 100644 index 000000000..e70509ad8 --- /dev/null +++ b/packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts @@ -0,0 +1,204 @@ +import { TAgent } from '@veramo/core' +import { IConnectionManager } from '../../src/types/IConnectionManager' +import { ConnectionIdentifierEnum, ConnectionTypeEnum, IConnection, IConnectionParty, IOpenIdConfig } from '@sphereon/ssi-sdk-core' + +type ConfiguredAgent = TAgent + +export default (testContext: { getAgent: () => ConfiguredAgent; setup: () => Promise; tearDown: () => Promise }) => { + describe('Connection Manager Agent Plugin', () => { + let agent: ConfiguredAgent + let defaultParty: IConnectionParty + let defaultPartyConnection: IConnection + + const connection = { + type: ConnectionTypeEnum.OPENID, + identifier: { + type: ConnectionIdentifierEnum.URL, + correlationId: 'https://example.com', + }, + config: { + clientId: '138d7bf8-c930-4c6e-b928-97d3a4928b01', + clientSecret: '03b3955f-d020-4f2a-8a27-4e452d4e27a0', + scopes: ['auth'], + issuer: 'https://example.com/app-test', + redirectUrl: 'app:/callback', + dangerouslyAllowInsecureHttpRequests: true, + clientAuthMethod: 'post' as const, + }, + metadata: [ + { + label: 'Authorization URL', + value: 'https://example.com', + }, + { + label: 'Scope', + value: 'Authorization', + }, + ], + } + + beforeAll(async () => { + await testContext.setup() + agent = testContext.getAgent() + + defaultParty = await agent.cmAddParty({ name: 'default_party' }) + defaultPartyConnection = await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) + defaultParty = await agent.cmGetParty({ partyId: defaultParty.id! }) + + await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) + }) + + afterAll(testContext.tearDown) + + it('should get party by id', async () => { + const result = await agent.cmGetParty({ partyId: defaultParty.id! }) + + expect(result.id).toEqual(defaultParty.id) + }) + + it('should throw error when getting party and party is not found', async () => { + const partyId = 'unknownPartyId' + + await expect(agent.cmGetParty({ partyId })).rejects.toThrow(`No party found for id: ${partyId}`) + }) + + it('should get all parties', async () => { + const result = await agent.cmGetParties() + + expect(result.length).toBeGreaterThan(0) + }) + + it('should add party', async () => { + const partyName = 'new_party' + + const result = await agent.cmAddParty({ name: partyName }) + + expect(result.name).toEqual(partyName) + }) + + it('should throw error when adding party with duplicate name', async () => { + const partyName = 'default_party' + await expect(agent.cmAddParty({ name: 'default_party' })).rejects.toThrow(`Duplicate names are not allowed. Name: ${partyName}`) + }) + + it('should update party by id', async () => { + const partyName = 'updated_party' + const party = { + ...defaultParty, + name: partyName, + } + + const result = await agent.cmUpdateParty({ party }) + + expect(result.name).toEqual(partyName) + }) + + it('should throw error when updating party and party is not found', async () => { + const partyId = 'unknownPartyId' + const party = { + ...defaultParty, + id: partyId, + name: 'new_name', + } + await expect(agent.cmUpdateParty({ party })).rejects.toThrow(`No party found for id: ${partyId}`) + }) + + it('should remove party by id and its relations', async () => { + const removeParty = await agent.cmAddParty({ name: 'remove_party' }) + const removePartyConnection = await agent.cmAddConnection({ partyId: removeParty.id!, connection }) + + const result = await agent.cmRemoveParty({ partyId: removeParty.id! }) + + expect(result).toEqual(true) + await expect(agent.cmGetParty({ partyId: removeParty.id! })).rejects.toThrow(`No party found for id: ${removeParty.id!}`) + await expect(agent.cmGetConnection({ connectionId: removePartyConnection.id! })).rejects.toThrow( + `No connection found for id: ${removePartyConnection.id!}` + ) + }) + + it('should get connection by id', async () => { + const result = await agent.cmGetConnection({ connectionId: defaultPartyConnection.id! }) + + expect(result.id).toEqual(defaultPartyConnection.id) + }) + + it('should throw error when getting connection and connection is not found', async () => { + const connectionId = 'b0b5b2f9-7d78-4533-8bc1-386e4f08dce1' + + await expect( + agent.cmGetConnection({ + connectionId, + }) + ).rejects.toThrow(`No connection found for id: ${connectionId}`) + }) + + it('should get all connections', async () => { + const result = await agent.cmGetConnections({ partyId: defaultParty.id! }) + + expect(result.length).toBeGreaterThan(0) + }) + + it('should add connection', async () => { + const result = await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) + + expect(result).not.toBeNull() + }) + + it('should update connection config by id', async () => { + const clientSecret = '423af84c-bfb5-4605-bf6f-3b088d2ff0da' + const connection = { + ...defaultPartyConnection, + config: { + id: '25a619ee-d93e-44ae-8355-ab50d18af8bd', + clientSecret, + clientId: '138d7bf8-c930-4c6e-b928-97d3a4928b01', + scopes: ['auth'], + issuer: 'https://example.com/app-test', + redirectUrl: 'app:/callback', + dangerouslyAllowInsecureHttpRequests: true, + clientAuthMethod: 'post' as const, + }, + } + + const result = await agent.cmUpdateConnection({ connection }) + + expect((result.config as IOpenIdConfig).clientSecret).toEqual(clientSecret) + }) + + it('should throw error when updating connection and connection is not found', async () => { + const connectionId = 'unknownConnectionId' + const connection = { + ...defaultPartyConnection, + id: connectionId, + config: { + id: '25a619ee-d93e-44ae-8355-ab50d18af8bd', + clientSecret: '03b3955f-d020-4f2a-8a27-4e452d4e27a0', + clientId: '138d7bf8-c930-4c6e-b928-97d3a4928b01', + scopes: ['auth'], + issuer: 'https://example.com/app-test', + redirectUrl: 'app:/callback', + dangerouslyAllowInsecureHttpRequests: true, + clientAuthMethod: 'post' as const, + }, + } + + await expect(agent.cmUpdateConnection({ connection })).rejects.toThrow(`No connection found for id: ${connectionId}`) + }) + + it('should remove connection by id and its relations', async () => { + const addedConnection = await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) + + const result = await agent.cmRemoveConnection({ connectionId: addedConnection.id! }) + + expect(result).toEqual(true) + //TODO add relation checks + await expect(agent.cmGetConnection({ connectionId: addedConnection.id! })).rejects.toThrow(`No connection found for id: ${addedConnection.id!}`) + }) + + it('should throw error when removing connection and connection is not found', async () => { + const connectionId = 'unknownConnectionId' + + await expect(agent.cmRemoveConnection({ connectionId })).rejects.toThrow(`No connection found for id: ${connectionId}`) + }) + }) +} diff --git a/packages/domain-linkage-verifier/agent.yml b/packages/domain-linkage-verifier/agent.yml new file mode 100644 index 000000000..c6aee5433 --- /dev/null +++ b/packages/domain-linkage-verifier/agent.yml @@ -0,0 +1,76 @@ +version: 3.0 + +constants: + baseUrl: http://localhost:3335 + port: 3335 + # please use your own X25519 key, this is only an example + secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c + methods: + - verifyDomainLinkage + - verifyDidConfigurationResource + +server: + baseUrl: + $ref: /constants/baseUrl + port: + $ref: /constants/port + use: + # CORS + - - $require: 'cors' + + # Add agent to the request object + - - $require: '@veramo/remote-server?t=function#RequestWithAgentRouter' + $args: + - agent: + $ref: /agent + + # API base path + - - /agent + - $require: '@veramo/remote-server?t=function#apiKeyAuth' + $args: + # Please configure your own API key. This is used when executing agent methods through ${baseUrl}/agent or ${baseUrl}/api-docs + - apiKey: test123 + - $require: '@veramo/remote-server?t=function#AgentRouter' + $args: + - exposedMethods: + $ref: /constants/methods + + # Open API schema + - - /open-api.json + - $require: '@veramo/remote-server?t=function#ApiSchemaRouter' + $args: + - basePath: :3335/agent + securityScheme: bearer + apiName: Agent + apiVersion: '1.0.0' + exposedMethods: + $ref: /constants/methods + + # Swagger docs + - - /api-docs + - $require: swagger-ui-express?t=object#serve + - $require: swagger-ui-express?t=function#setup + $args: + - null + - swaggerOptions: + url: '/open-api.json' + + # Execute during server initialization + init: + - $require: '@veramo/remote-server?t=function#createDefaultDid' + $args: + - agent: + $ref: /agent + baseUrl: + $ref: /constants/baseUrl + messagingServiceEndpoint: /messaging + +# Agent +agent: + $require: '@veramo/core#Agent' + $args: + - schemaValidation: false + plugins: + - $require: ./packages/connection-manager/dist#DomainLinkageVerifier + +// TODO add resolver diff --git a/packages/domain-linkage-verifier/api-extractor.json b/packages/domain-linkage-verifier/api-extractor.json new file mode 100644 index 000000000..94c2c6a9f --- /dev/null +++ b/packages/domain-linkage-verifier/api-extractor.json @@ -0,0 +1,3 @@ +{ + "extends": "../include/api-extractor-base.json" +} diff --git a/packages/domain-linkage-verifier/package.json b/packages/domain-linkage-verifier/package.json new file mode 100644 index 000000000..7315d03b2 --- /dev/null +++ b/packages/domain-linkage-verifier/package.json @@ -0,0 +1,44 @@ +{ + "name": "@sphereon/ssi-sdk-domain-linkage-verifier", + "version": "0.6.0", + "source": "src/index.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "veramo": { + "pluginInterfaces": { + "IConnectionManager": "./src/types/IDomainLinkageVerifier.ts" + } + }, + "scripts": { + "build": "tsc --build", + "generate-plugin-schema": "yarn veramo dev generate-plugin-schema" + }, + "dependencies": { + "@sphereon/domain-linkage-client": "C:\\Git\\Sphereon-Opensource\\domain-linkage-client\\sphereon-domain-linkage-client-v0.1.0.tgz", + "@veramo/core": "^3.1.2-next.84", + "@veramo/credential-w3c": "^3.1.3" + }, + "devDependencies": { + "@veramo/cli": "^3.1.2-next.84", + "typescript": "^4.5.2" + }, + "files": [ + "dist/**/*", + "src/**/*", + "README.md", + "plugin.schema.json", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "repository": "git@github.com:Sphereon-Opensource/SSI-SDK.git", + "author": "Sphereon ", + "license": "Apache-2.0", + "keywords": [ + "DID", + "Domain Linkage", + "DID Configuration Resource", + "Verifier" + ] +} diff --git a/packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts b/packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts new file mode 100644 index 000000000..8afc53deb --- /dev/null +++ b/packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts @@ -0,0 +1,47 @@ +import { + IAgentPlugin, + DIDResolutionResult +} from '@veramo/core' +import { + DomainLinkageVerifier as DLV, + IDomainLinkageValidation, + IResourceValidation, + IVerifyCallbackArgs +} from '@sphereon/domain-linkage-client' +import { schema } from '../index' +import { + IDomainLinkageVerifier, + IRequiredContext, + IVerifyDidConfigurationResourceArgs, + IVerifyDomainLinkageArgs +} from '../types/IDomainLinkageVerifier' + +/** + * {@inheritDoc IConnectionManager} + */ +export class DomainLinkageVerifier implements IAgentPlugin { + readonly schema = schema.IDomainLinkageVerifier + readonly methods: IDomainLinkageVerifier = { + verifyDomainLinkage: this.verifyDomainLinkage.bind(this), + verifyDidConfigurationResource: this.verifyDidConfigurationResource.bind(this) + } + + // TODO options with resolver? + + /** {@inheritDoc IDomainLinkageVerifier.verifyDomainLinkage} */ + private async verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise { + const verifierConfig = { + issueCallback: (args: IVerifyCallbackArgs) => context.agent.verifyCredential({ credential: args.credential }) + } + + return context.agent.resolveDid(args) + .then((didResolutionResult: DIDResolutionResult) => new DLV(verifierConfig) + .verifyDomainLinkage({ didDocument: didResolutionResult.didDocument })) + } + + /** {@inheritDoc IDomainLinkageVerifier.verifyDidConfigurationResource} */ + private async verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise { + return new DLV().verifyResource(args) + } + +} diff --git a/packages/domain-linkage-verifier/src/index.ts b/packages/domain-linkage-verifier/src/index.ts new file mode 100644 index 000000000..85e06fe25 --- /dev/null +++ b/packages/domain-linkage-verifier/src/index.ts @@ -0,0 +1,7 @@ +/** + * @public + */ +const schema = require('../plugin.schema.json') +export { schema } +export { DomainLinkageVerifier } from './agent/DomainLinkageVerifier' +export * from './types/IDomainLinkageVerifier' diff --git a/packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts b/packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts new file mode 100644 index 000000000..3b8112167 --- /dev/null +++ b/packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts @@ -0,0 +1,24 @@ +import { + IAgentContext, + IPluginMethodMap, + IResolver +} from '@veramo/core' + +import { ICredentialIssuer } from '@veramo/credential-w3c' +import { IDidConfigurationResource } from '@sphereon/domain-linkage-client' + +export interface IDomainLinkageVerifier extends IPluginMethodMap { + verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise, + verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise +} + +export interface IVerifyDomainLinkageArgs { + didUrl: string +} + +export interface IVerifyDidConfigurationResourceArgs { + resource: IDidConfigurationResource | string, + didUrl?: string +} + +export type IRequiredContext = IAgentContext diff --git a/packages/domain-linkage-verifier/tsconfig.json b/packages/domain-linkage-verifier/tsconfig.json new file mode 100644 index 000000000..165b8519e --- /dev/null +++ b/packages/domain-linkage-verifier/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig-base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "declarationDir": "dist", + "strictPropertyInitialization": false + }, + "references": [{ "path": "../ssi-sdk-core" }] +} diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 24400b936..a4a4ecfe9 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -17,6 +17,7 @@ { "path": "bls-key-manager" }, { "path": "connection-manager" }, { "path": "data-store" }, - { "path": "ion-did-provider" } + { "path": "ion-did-provider" }, + { "path": "domain-linkage-verifier" } ] } From 43ff6d7cb9b9078e996aab19ad8dc0563e155f96 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Wed, 10 Aug 2022 15:29:57 +0200 Subject: [PATCH 02/15] VDX-88 added wellknown-did-verifier --- packages/domain-linkage-verifier/README.md | 53 ----- .../__tests__/localAgent.test.ts | 35 --- .../__tests__/restAgent.test.ts | 71 ------ .../shared/domainLinkageVerifierAgentLogic.ts | 204 ------------------ .../src/agent/DomainLinkageVerifier.ts | 47 ---- packages/domain-linkage-verifier/src/index.ts | 7 - .../src/types/IDomainLinkageVerifier.ts | 24 --- packages/tsconfig.json | 2 +- .../CHANGELOG.md | 0 .../LICENSE | 0 packages/wellknown-did-verifier/README.md | 95 ++++++++ .../__tests__/localAgent.test.ts | 76 +++++++ .../__tests__/restAgent.test.ts | 114 ++++++++++ .../shared/wellKnownDidVerifierAgentLogic.ts | 171 +++++++++++++++ .../agent.yml | 37 +++- .../api-extractor.json | 0 .../package.json | 16 +- .../wellknown-did-verifier/plugin.schema.json | 34 +++ .../src/agent/WellKnownDidVerifier.ts | 116 ++++++++++ packages/wellknown-did-verifier/src/index.ts | 7 + .../src/types/IWellKnownDidVerifier.ts | 48 +++++ .../tsconfig.json | 2 +- 22 files changed, 705 insertions(+), 454 deletions(-) delete mode 100644 packages/domain-linkage-verifier/README.md delete mode 100644 packages/domain-linkage-verifier/__tests__/localAgent.test.ts delete mode 100644 packages/domain-linkage-verifier/__tests__/restAgent.test.ts delete mode 100644 packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts delete mode 100644 packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts delete mode 100644 packages/domain-linkage-verifier/src/index.ts delete mode 100644 packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts rename packages/{domain-linkage-verifier => wellknown-did-verifier}/CHANGELOG.md (100%) rename packages/{domain-linkage-verifier => wellknown-did-verifier}/LICENSE (100%) create mode 100644 packages/wellknown-did-verifier/README.md create mode 100644 packages/wellknown-did-verifier/__tests__/localAgent.test.ts create mode 100644 packages/wellknown-did-verifier/__tests__/restAgent.test.ts create mode 100644 packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts rename packages/{domain-linkage-verifier => wellknown-did-verifier}/agent.yml (66%) rename packages/{domain-linkage-verifier => wellknown-did-verifier}/api-extractor.json (100%) rename packages/{domain-linkage-verifier => wellknown-did-verifier}/package.json (63%) create mode 100644 packages/wellknown-did-verifier/plugin.schema.json create mode 100644 packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts create mode 100644 packages/wellknown-did-verifier/src/index.ts create mode 100644 packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts rename packages/{domain-linkage-verifier => wellknown-did-verifier}/tsconfig.json (79%) diff --git a/packages/domain-linkage-verifier/README.md b/packages/domain-linkage-verifier/README.md deleted file mode 100644 index 5765ad77a..000000000 --- a/packages/domain-linkage-verifier/README.md +++ /dev/null @@ -1,53 +0,0 @@ - -

-
- Sphereon -
Domain Linkage Verifier (Typescript) -
-

- ---- - -**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!** - ---- - -A Veramo connection manager plugin. This plugin manages connection configurations to third parties and persists them. These configurations can then be used to establish the connection. - -## Supported connection types - - -## Available functions - -## Usage - -### Adding the plugin to an agent: - -```typescript -const agent = createAgent({ - plugins: [ - new ConnectionManager(), - ], -}) -``` - -### Get a party: - -```typescript -const partyId = '8efb937f-4e90-4056-9a4d-7185ce8dc173' -const result = await agent.cmGetConnection({ - partyId, -}) -``` - -## Installation - -```shell -yarn add @sphereon/ssi-sdk-domain-linkage-verifier -``` - -## Build - -```shell -yarn build -``` diff --git a/packages/domain-linkage-verifier/__tests__/localAgent.test.ts b/packages/domain-linkage-verifier/__tests__/localAgent.test.ts deleted file mode 100644 index 099e417f7..000000000 --- a/packages/domain-linkage-verifier/__tests__/localAgent.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { getConfig } from '@veramo/cli/build/setup' -import { createObjects } from '@veramo/cli/build/lib/objectCreator' -import { Connection } from 'typeorm' - -jest.setTimeout(30000) - -import domainLinkageVerifierAgentLogic from './shared/domainLinkageVerifierAgentLogic' - -let dbConnection: Promise -let agent: any - -const setup = async (): Promise => { - const config = getConfig('packages/connection-manager/agent.yml') - const { localAgent, db } = createObjects(config, { localAgent: '/agent', db: '/dbConnection' }) - agent = localAgent - dbConnection = db - - return true -} - -const tearDown = async (): Promise => { - await (await dbConnection).close() - return true -} - -const getAgent = () => agent -const testContext = { - getAgent, - setup, - tearDown, -} - -describe('Local integration tests', () => { - domainLinkageVerifierAgentLogic(testContext) -}) diff --git a/packages/domain-linkage-verifier/__tests__/restAgent.test.ts b/packages/domain-linkage-verifier/__tests__/restAgent.test.ts deleted file mode 100644 index 203096beb..000000000 --- a/packages/domain-linkage-verifier/__tests__/restAgent.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import 'cross-fetch/polyfill' -import express from 'express' -import { Server } from 'http' -import { Connection } from 'typeorm' -import { IAgent, createAgent, IAgentOptions } from '@veramo/core' -import { AgentRestClient } from '@veramo/remote-client' -import { AgentRouter, RequestWithAgentRouter } from '@veramo/remote-server' -import { getConfig } from '@veramo/cli/build/setup' -import { createObjects } from '@veramo/cli/build/lib/objectCreator' -import domainLinkageVerifierAgentLogic from './shared/domainLinkageVerifierAgentLogic' -import {IDomainLinkageVerifier} from '../src'; - -jest.setTimeout(30000) - -const port = 3002 -const basePath = '/agent' - -let serverAgent: IAgent -let restServer: Server -let dbConnection: Promise - -const getAgent = (options?: IAgentOptions) => - createAgent({ - ...options, - plugins: [ - new AgentRestClient({ - url: 'http://localhost:' + port + basePath, - enabledMethods: serverAgent.availableMethods(), - schema: serverAgent.getSchema(), - }), - ], - }) - -const setup = async (): Promise => { - const config = getConfig('packages/domain-linkage-verifier/agent.yml') - const { agent, db } = createObjects(config, { agent: '/agent', db: '/dbConnection' }) - serverAgent = agent - dbConnection = db - - const agentRouter = AgentRouter({ - exposedMethods: serverAgent.availableMethods(), - }) - - const requestWithAgent = RequestWithAgentRouter({ - agent: serverAgent, - }) - - return new Promise((resolve) => { - const app = express() - app.use(basePath, requestWithAgent, agentRouter) - restServer = app.listen(port, () => { - resolve(true) - }) - }) -} - -const tearDown = async (): Promise => { - restServer.close() - await (await dbConnection).close() - return true -} - -const testContext = { - getAgent, - setup, - tearDown, -} - -describe('REST integration tests', () => { - domainLinkageVerifierAgentLogic(testContext) -}) diff --git a/packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts b/packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts deleted file mode 100644 index e70509ad8..000000000 --- a/packages/domain-linkage-verifier/__tests__/shared/domainLinkageVerifierAgentLogic.ts +++ /dev/null @@ -1,204 +0,0 @@ -import { TAgent } from '@veramo/core' -import { IConnectionManager } from '../../src/types/IConnectionManager' -import { ConnectionIdentifierEnum, ConnectionTypeEnum, IConnection, IConnectionParty, IOpenIdConfig } from '@sphereon/ssi-sdk-core' - -type ConfiguredAgent = TAgent - -export default (testContext: { getAgent: () => ConfiguredAgent; setup: () => Promise; tearDown: () => Promise }) => { - describe('Connection Manager Agent Plugin', () => { - let agent: ConfiguredAgent - let defaultParty: IConnectionParty - let defaultPartyConnection: IConnection - - const connection = { - type: ConnectionTypeEnum.OPENID, - identifier: { - type: ConnectionIdentifierEnum.URL, - correlationId: 'https://example.com', - }, - config: { - clientId: '138d7bf8-c930-4c6e-b928-97d3a4928b01', - clientSecret: '03b3955f-d020-4f2a-8a27-4e452d4e27a0', - scopes: ['auth'], - issuer: 'https://example.com/app-test', - redirectUrl: 'app:/callback', - dangerouslyAllowInsecureHttpRequests: true, - clientAuthMethod: 'post' as const, - }, - metadata: [ - { - label: 'Authorization URL', - value: 'https://example.com', - }, - { - label: 'Scope', - value: 'Authorization', - }, - ], - } - - beforeAll(async () => { - await testContext.setup() - agent = testContext.getAgent() - - defaultParty = await agent.cmAddParty({ name: 'default_party' }) - defaultPartyConnection = await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) - defaultParty = await agent.cmGetParty({ partyId: defaultParty.id! }) - - await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) - }) - - afterAll(testContext.tearDown) - - it('should get party by id', async () => { - const result = await agent.cmGetParty({ partyId: defaultParty.id! }) - - expect(result.id).toEqual(defaultParty.id) - }) - - it('should throw error when getting party and party is not found', async () => { - const partyId = 'unknownPartyId' - - await expect(agent.cmGetParty({ partyId })).rejects.toThrow(`No party found for id: ${partyId}`) - }) - - it('should get all parties', async () => { - const result = await agent.cmGetParties() - - expect(result.length).toBeGreaterThan(0) - }) - - it('should add party', async () => { - const partyName = 'new_party' - - const result = await agent.cmAddParty({ name: partyName }) - - expect(result.name).toEqual(partyName) - }) - - it('should throw error when adding party with duplicate name', async () => { - const partyName = 'default_party' - await expect(agent.cmAddParty({ name: 'default_party' })).rejects.toThrow(`Duplicate names are not allowed. Name: ${partyName}`) - }) - - it('should update party by id', async () => { - const partyName = 'updated_party' - const party = { - ...defaultParty, - name: partyName, - } - - const result = await agent.cmUpdateParty({ party }) - - expect(result.name).toEqual(partyName) - }) - - it('should throw error when updating party and party is not found', async () => { - const partyId = 'unknownPartyId' - const party = { - ...defaultParty, - id: partyId, - name: 'new_name', - } - await expect(agent.cmUpdateParty({ party })).rejects.toThrow(`No party found for id: ${partyId}`) - }) - - it('should remove party by id and its relations', async () => { - const removeParty = await agent.cmAddParty({ name: 'remove_party' }) - const removePartyConnection = await agent.cmAddConnection({ partyId: removeParty.id!, connection }) - - const result = await agent.cmRemoveParty({ partyId: removeParty.id! }) - - expect(result).toEqual(true) - await expect(agent.cmGetParty({ partyId: removeParty.id! })).rejects.toThrow(`No party found for id: ${removeParty.id!}`) - await expect(agent.cmGetConnection({ connectionId: removePartyConnection.id! })).rejects.toThrow( - `No connection found for id: ${removePartyConnection.id!}` - ) - }) - - it('should get connection by id', async () => { - const result = await agent.cmGetConnection({ connectionId: defaultPartyConnection.id! }) - - expect(result.id).toEqual(defaultPartyConnection.id) - }) - - it('should throw error when getting connection and connection is not found', async () => { - const connectionId = 'b0b5b2f9-7d78-4533-8bc1-386e4f08dce1' - - await expect( - agent.cmGetConnection({ - connectionId, - }) - ).rejects.toThrow(`No connection found for id: ${connectionId}`) - }) - - it('should get all connections', async () => { - const result = await agent.cmGetConnections({ partyId: defaultParty.id! }) - - expect(result.length).toBeGreaterThan(0) - }) - - it('should add connection', async () => { - const result = await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) - - expect(result).not.toBeNull() - }) - - it('should update connection config by id', async () => { - const clientSecret = '423af84c-bfb5-4605-bf6f-3b088d2ff0da' - const connection = { - ...defaultPartyConnection, - config: { - id: '25a619ee-d93e-44ae-8355-ab50d18af8bd', - clientSecret, - clientId: '138d7bf8-c930-4c6e-b928-97d3a4928b01', - scopes: ['auth'], - issuer: 'https://example.com/app-test', - redirectUrl: 'app:/callback', - dangerouslyAllowInsecureHttpRequests: true, - clientAuthMethod: 'post' as const, - }, - } - - const result = await agent.cmUpdateConnection({ connection }) - - expect((result.config as IOpenIdConfig).clientSecret).toEqual(clientSecret) - }) - - it('should throw error when updating connection and connection is not found', async () => { - const connectionId = 'unknownConnectionId' - const connection = { - ...defaultPartyConnection, - id: connectionId, - config: { - id: '25a619ee-d93e-44ae-8355-ab50d18af8bd', - clientSecret: '03b3955f-d020-4f2a-8a27-4e452d4e27a0', - clientId: '138d7bf8-c930-4c6e-b928-97d3a4928b01', - scopes: ['auth'], - issuer: 'https://example.com/app-test', - redirectUrl: 'app:/callback', - dangerouslyAllowInsecureHttpRequests: true, - clientAuthMethod: 'post' as const, - }, - } - - await expect(agent.cmUpdateConnection({ connection })).rejects.toThrow(`No connection found for id: ${connectionId}`) - }) - - it('should remove connection by id and its relations', async () => { - const addedConnection = await agent.cmAddConnection({ partyId: defaultParty.id!, connection }) - - const result = await agent.cmRemoveConnection({ connectionId: addedConnection.id! }) - - expect(result).toEqual(true) - //TODO add relation checks - await expect(agent.cmGetConnection({ connectionId: addedConnection.id! })).rejects.toThrow(`No connection found for id: ${addedConnection.id!}`) - }) - - it('should throw error when removing connection and connection is not found', async () => { - const connectionId = 'unknownConnectionId' - - await expect(agent.cmRemoveConnection({ connectionId })).rejects.toThrow(`No connection found for id: ${connectionId}`) - }) - }) -} diff --git a/packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts b/packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts deleted file mode 100644 index 8afc53deb..000000000 --- a/packages/domain-linkage-verifier/src/agent/DomainLinkageVerifier.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - IAgentPlugin, - DIDResolutionResult -} from '@veramo/core' -import { - DomainLinkageVerifier as DLV, - IDomainLinkageValidation, - IResourceValidation, - IVerifyCallbackArgs -} from '@sphereon/domain-linkage-client' -import { schema } from '../index' -import { - IDomainLinkageVerifier, - IRequiredContext, - IVerifyDidConfigurationResourceArgs, - IVerifyDomainLinkageArgs -} from '../types/IDomainLinkageVerifier' - -/** - * {@inheritDoc IConnectionManager} - */ -export class DomainLinkageVerifier implements IAgentPlugin { - readonly schema = schema.IDomainLinkageVerifier - readonly methods: IDomainLinkageVerifier = { - verifyDomainLinkage: this.verifyDomainLinkage.bind(this), - verifyDidConfigurationResource: this.verifyDidConfigurationResource.bind(this) - } - - // TODO options with resolver? - - /** {@inheritDoc IDomainLinkageVerifier.verifyDomainLinkage} */ - private async verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise { - const verifierConfig = { - issueCallback: (args: IVerifyCallbackArgs) => context.agent.verifyCredential({ credential: args.credential }) - } - - return context.agent.resolveDid(args) - .then((didResolutionResult: DIDResolutionResult) => new DLV(verifierConfig) - .verifyDomainLinkage({ didDocument: didResolutionResult.didDocument })) - } - - /** {@inheritDoc IDomainLinkageVerifier.verifyDidConfigurationResource} */ - private async verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise { - return new DLV().verifyResource(args) - } - -} diff --git a/packages/domain-linkage-verifier/src/index.ts b/packages/domain-linkage-verifier/src/index.ts deleted file mode 100644 index 85e06fe25..000000000 --- a/packages/domain-linkage-verifier/src/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * @public - */ -const schema = require('../plugin.schema.json') -export { schema } -export { DomainLinkageVerifier } from './agent/DomainLinkageVerifier' -export * from './types/IDomainLinkageVerifier' diff --git a/packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts b/packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts deleted file mode 100644 index 3b8112167..000000000 --- a/packages/domain-linkage-verifier/src/types/IDomainLinkageVerifier.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { - IAgentContext, - IPluginMethodMap, - IResolver -} from '@veramo/core' - -import { ICredentialIssuer } from '@veramo/credential-w3c' -import { IDidConfigurationResource } from '@sphereon/domain-linkage-client' - -export interface IDomainLinkageVerifier extends IPluginMethodMap { - verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise, - verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise -} - -export interface IVerifyDomainLinkageArgs { - didUrl: string -} - -export interface IVerifyDidConfigurationResourceArgs { - resource: IDidConfigurationResource | string, - didUrl?: string -} - -export type IRequiredContext = IAgentContext diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 97cbc0698..87d1ed881 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -19,6 +19,6 @@ { "path": "connection-manager" }, { "path": "data-store" }, { "path": "ion-did-provider" }, - { "path": "domain-linkage-verifier" } + { "path": "wellknown-did-verifier" }, ] } diff --git a/packages/domain-linkage-verifier/CHANGELOG.md b/packages/wellknown-did-verifier/CHANGELOG.md similarity index 100% rename from packages/domain-linkage-verifier/CHANGELOG.md rename to packages/wellknown-did-verifier/CHANGELOG.md diff --git a/packages/domain-linkage-verifier/LICENSE b/packages/wellknown-did-verifier/LICENSE similarity index 100% rename from packages/domain-linkage-verifier/LICENSE rename to packages/wellknown-did-verifier/LICENSE diff --git a/packages/wellknown-did-verifier/README.md b/packages/wellknown-did-verifier/README.md new file mode 100644 index 000000000..68885e1fe --- /dev/null +++ b/packages/wellknown-did-verifier/README.md @@ -0,0 +1,95 @@ + +

+
+ Sphereon +
Well-Known DID Verifier (Typescript) +
+

+ +--- + +**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!** + +--- + +A `Sphereon SSI-SDK` plugin to verify relationships between the controller of an origin and a DID and to verify DID configuration resources. + +## Available functions +* registerSignatureValidation +* removeSignatureValidation +* verifyDomainLinkage +* verifyDidConfigurationResource + +## Usage + +### Adding the plugin to an agent: + +```typescript +import { + IWellKnownDidVerifier, + WellKnownDidVerifier +} from '@sphereon/ssi-sdk-wellknown-did-verifier'; + +const agent = createAgent({ + plugins: [ + new WellKnownDidVerifier({ + signatureVerifications: {'verified': () => Promise.resolve({ verified: true })}, + onlyVerifyServiceDids: true + }), + ], +}) +``` + +### Register signature verification callback: + +```typescript +agent.registerSignatureVerification({ + key: 'example_key', + signatureVerification: () => Promise.resolve({ verified: true }) +}) + .then(() => console.log('success')) + .catch(() => console.log('failed')) +``` + +### Remove signature verification callback: + +```typescript +agent.removeSignatureVerification({ key: 'example_key' }) + .then(() => console.log('success')) + .catch(() => console.log('failed')) +``` + +### Verify domain linkage: + +```typescript +agent.verifyDomainLinkage({ + didUrl: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo', + signatureVerification: 'verified', + onlyVerifyServiceDids: false +}) +.then((result: IDomainLinkageValidation) => console.log(result.status)) +``` + +### Verify DID configuration resource: + +You can either pass in a DID configuration resource or fetch it remotely by setting a secure well-known location (origin). + +```typescript +agent.verifyDidConfigurationResource({ + signatureVerification: () => Promise.resolve({ verified: true }), + origin: 'https://example.com' +}) +.then((result: IResourceValidation) => console.log(result.status)) +``` + +## Installation + +```shell +yarn add @sphereon/ssi-sdk-wellknown-did-verifier +``` + +## Build + +```shell +yarn build +``` diff --git a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts new file mode 100644 index 000000000..8d0a1236b --- /dev/null +++ b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts @@ -0,0 +1,76 @@ +import { getConfig } from '@veramo/cli/build/setup' +import { createObjects } from '@veramo/cli/build/lib/objectCreator' +import { ServiceTypesEnum } from '@sphereon/wellknown-dids-client/dist/types' +import wellKnownDidVerifierAgentLogic from './shared/wellKnownDidVerifierAgentLogic' + +jest.setTimeout(30000) + +let agent: any + +const setup = async (): Promise => { + const config = getConfig('packages/wellknown-did-verifier/agent.yml') + const { localAgent } = createObjects(config, { localAgent: '/agent' }) + + await localAgent.registerSignatureVerification({ + key: 'verified', + signatureVerification: () => Promise.resolve({ verified: true }) + }, null) + + const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM'; + const ORIGIN = 'https://example.com'; + const DOCUMENT = { + '@context': [ + 'https://www.w3.org/ns/did/v1', + 'https://identity.foundation/.well-known/did-configuration/v1' + ], + id: DID, + verificationMethod: [ + { + id: `${DID}#_Qq0UL2Fq651Q0Fjd6TvnYE-faHiOpRlPVQcY_-tA4A`, + type: 'JsonWebKey2020', + controller: DID, + publicKeyJwk: { + kty: 'OKP', + crv: 'Ed25519', + x: 'VCpo2LMLhn6iWku8MKvSLg2ZAoC-nlOyPVQaO3FxVeQ', + }, + }, + ], + service: [ + { + id: `${DID}#foo`, + type: ServiceTypesEnum.LINKED_DOMAINS, + serviceEndpoint: { + origins: [ORIGIN, ORIGIN], + }, + }, + { + id: `${DID}#bar`, + type: ServiceTypesEnum.LINKED_DOMAINS, + serviceEndpoint: ORIGIN, + }, + ], + }; + + localAgent.resolveDid = jest.fn().mockReturnValue(Promise.resolve({ didDocument: DOCUMENT })) + + agent = localAgent + + return true +} + +const tearDown = async (): Promise => { + return true +} + +const getAgent = () => agent +const testContext = { + getAgent, + setup, + tearDown, + isRestTest: false, +} + +describe('Local integration tests', () => { + wellKnownDidVerifierAgentLogic(testContext) +}) diff --git a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts new file mode 100644 index 000000000..6e856814c --- /dev/null +++ b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts @@ -0,0 +1,114 @@ +import 'cross-fetch/polyfill' +// @ts-ignore +import express from 'express' +import { Server } from 'http' +import { IAgent, createAgent, IAgentOptions } from '@veramo/core' +import { AgentRestClient } from '@veramo/remote-client' +import { AgentRouter, RequestWithAgentRouter } from '@veramo/remote-server' +import { getConfig } from '@veramo/cli/build/setup' +import { createObjects } from '@veramo/cli/build/lib/objectCreator' +import { IWellKnownDidVerifier } from '../src/types/IWellKnownDidVerifier'; +import { ServiceTypesEnum } from '@sphereon/wellknown-dids-client/dist/types' +import wellKnownDidVerifierAgentLogic from './shared/wellKnownDidVerifierAgentLogic' + +jest.setTimeout(30000) + +const port = 3002 +const basePath = '/agent' + +let serverAgent: IAgent +let restServer: Server + +const getAgent = (options?: IAgentOptions) => + createAgent({ + ...options, + plugins: [ + new AgentRestClient({ + url: 'http://localhost:' + port + basePath, + enabledMethods: serverAgent.availableMethods(), + schema: serverAgent.getSchema(), + }), + ], + }) + +const setup = async (): Promise => { + const config = getConfig('packages/wellknown-did-verifier/agent.yml') + const { agent } = createObjects(config, { agent: '/agent' }) + + await agent.registerSignatureVerification({ + key: 'verified', + signatureVerification: () => Promise.resolve({ verified: true }) + }, null) + + const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM'; + const ORIGIN = 'https://example.com'; + const DOCUMENT = { + '@context': [ + 'https://www.w3.org/ns/did/v1', + 'https://identity.foundation/.well-known/did-configuration/v1' + ], + id: DID, + verificationMethod: [ + { + id: `${DID}#_Qq0UL2Fq651Q0Fjd6TvnYE-faHiOpRlPVQcY_-tA4A`, + type: 'JsonWebKey2020', + controller: DID, + publicKeyJwk: { + kty: 'OKP', + crv: 'Ed25519', + x: 'VCpo2LMLhn6iWku8MKvSLg2ZAoC-nlOyPVQaO3FxVeQ', + }, + }, + ], + service: [ + { + id: `${DID}#foo`, + type: ServiceTypesEnum.LINKED_DOMAINS, + serviceEndpoint: { + origins: [ORIGIN, ORIGIN], + }, + }, + { + id: `${DID}#bar`, + type: ServiceTypesEnum.LINKED_DOMAINS, + serviceEndpoint: ORIGIN, + }, + ], + }; + + agent.resolveDid = jest.fn().mockReturnValue(Promise.resolve({ didDocument: DOCUMENT })) + + serverAgent = agent + + const agentRouter = AgentRouter({ + exposedMethods: serverAgent.availableMethods(), + }) + + const requestWithAgent = RequestWithAgentRouter({ + agent: serverAgent, + }) + + return new Promise((resolve) => { + const app = express() + app.use(basePath, requestWithAgent, agentRouter) + restServer = app.listen(port, () => { + resolve(true) + }) + }) +} + +const tearDown = async (): Promise => { + restServer.close() + return true +} + +const testContext = { + getAgent, + setup, + tearDown, + isRestTest: true, +} + +describe('REST integration tests', () => { + wellKnownDidVerifierAgentLogic(testContext) +}) diff --git a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts new file mode 100644 index 000000000..81d889cfc --- /dev/null +++ b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts @@ -0,0 +1,171 @@ +import { ValidationStatusEnum } from '@sphereon/wellknown-dids-client/dist/types'; +import { TAgent, IResolver } from '@veramo/core' +import { IWellKnownDidVerifier } from '../../src/types/IWellKnownDidVerifier' + +const nock = require('nock') + +type ConfiguredAgent = TAgent + +export default (testContext: { + getAgent: () => ConfiguredAgent + setup: () => Promise + tearDown: () => Promise + isRestTest: boolean +}) => { + describe('Well-Known DID Verifier Agent Plugin', () => { + const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM'; + const DID_CONFIGURATION = { + '@context': 'https://identity.foundation/.well-known/did-configuration/v1', + linked_dids: [ + 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNI3o2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSJ9.eyJleHAiOjE3NjQ4NzkxMzksImlzcyI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNIiwibmJmIjoxNjA3MTEyNzM5LCJzdWIiOiJkaWQ6a2V5Ono2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSIsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwiaHR0cHM6Ly9pZGVudGl0eS5mb3VuZGF0aW9uLy53ZWxsLWtub3duL2RpZC1jb25maWd1cmF0aW9uL3YxIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7ImlkIjoiZGlkOmtleTp6Nk1rb1RIc2dOTnJieThKekNOUTFpUkx5VzVRUTZSOFh1dTZBQThpZ0dyTVZQVU0iLCJvcmlnaW4iOiJodHRwczovL2lkZW50aXR5LmZvdW5kYXRpb24ifSwiZXhwaXJhdGlvbkRhdGUiOiIyMDI1LTEyLTA0VDE0OjEyOjE5LTA2OjAwIiwiaXNzdWFuY2VEYXRlIjoiMjAyMC0xMi0wNFQxNDoxMjoxOS0wNjowMCIsImlzc3VlciI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNIiwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIkRvbWFpbkxpbmthZ2VDcmVkZW50aWFsIl19fQ.YZnpPMAW3GdaPXC2YKoJ7Igt1OaVZKq09XZBkptyhxTAyHTkX2Ewtew-JKHKQjyDyabY3HAy1LUPoIQX0jrU0J82pIYT3k2o7nNTdLbxlgb49FcDn4czntt5SbY0m1XwrMaKEvV0bHQsYPxNTqjYsyySccgPfmvN9IT8gRS-M9a6MZQxuB3oEMrVOQ5Vco0bvTODXAdCTHibAk1FlvKz0r1vO5QMhtW4OlRrVTI7ibquf9Nim_ch0KeMMThFjsBDKetuDF71nUcL5sf7PCFErvl8ZVw3UK4NkZ6iM-XIRsLL6rXP2SnDUVovcldhxd_pyKEYviMHBOgBdoNP6fOgRQ', + 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNI3o2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSJ9.eyJleHAiOjE3NjQ4NzkxMzksImlzcyI6ImRpZDprZXk6b3RoZXIiLCJuYmYiOjE2MDcxMTI3MzksInN1YiI6ImRpZDprZXk6b3RoZXIiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vaWRlbnRpdHkuZm91bmRhdGlvbi8ud2VsbC1rbm93bi9kaWQtY29uZmlndXJhdGlvbi92MSJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJpZCI6ImRpZDprZXk6b3RoZXIiLCJvcmlnaW4iOiJodHRwczovL2lkZW50aXR5LmZvdW5kYXRpb24ifSwiZXhwaXJhdGlvbkRhdGUiOiIyMDI1LTEyLTA0VDE0OjEyOjE5LTA2OjAwIiwiaXNzdWFuY2VEYXRlIjoiMjAyMC0xMi0wNFQxNDoxMjoxOS0wNjowMCIsImlzc3VlciI6ImRpZDprZXk6b3RoZXIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRG9tYWluTGlua2FnZUNyZWRlbnRpYWwiXX19.rRuc-ojuEgyq8p_tBYK7BayuiNTBeXNyAnC14Rnjs-jsnhae4_E1Q12W99K2NGCGBi5KjNsBcZmdNJPxejiKPrjjcB99poFCgTY8tuRzDjVo0lIeBwfx9qqjKHTRTUR8FGM_imlOpVfBF4AHYxjkHvZn6c9lYvatYcDpB2UfH4BNXkdSVrUXy_kYjpMpAdRtyCAnD_isN1YpEHBqBmnfuVUbYcQK5kk6eiokRFDtWruL1OEeJMYPqjuBSd2m-H54tSM84Oic_pg2zXDjjBlXNelat6MPNT2QxmkwJg7oyewQWX2Ot2yyhSp9WyAQWMlQIe2x84R0lADUmZ1TPQchNw', + ], + }; + + let agent: ConfiguredAgent + + beforeAll(async () => { + await testContext.setup() + agent = testContext.getAgent() + }) + + afterAll(testContext.tearDown) + + it('should verify domain linkage with signature verification key', async () => { + nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION); + + const result = await agent.verifyDomainLinkage({ + didUrl: DID, + signatureVerification: 'verified' + }) + + expect(result.status).toEqual(ValidationStatusEnum.VALID) + }) + + it('should only verify service DIDs when onlyVerifyServiceDids set to true', async () => { + nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION); + + const result = await agent.verifyDomainLinkage({ + didUrl: DID, + signatureVerification: 'verified', + onlyVerifyServiceDids: true + }) + + expect(result.endpointDescriptors[0].resources[0].credentials.length).toEqual(1); + }) + + it('should throw error if signature verification key is not found when verifying a domain linkage', async () => { + const signatureVerificationKey = 'unknown' + await expect( + agent.verifyDomainLinkage({ + didUrl: DID, + signatureVerification: signatureVerificationKey, + }) + ).rejects.toThrow(`Signature validation not found for key: ${signatureVerificationKey}`) + }) + + it('should throw error if signature verification key is not found when verifying a DID configuration resource', async () => { + const signatureVerificationKey = 'unknown' + + await expect( + agent.verifyDidConfigurationResource({ + signatureVerification: signatureVerificationKey, + origin: 'https://example.com' + }) + ).rejects.toThrow(`Signature validation not found for key: ${signatureVerificationKey}`) + }) + + it('should throw error if no configuration or origin is supplied', async () => { + await expect( + agent.verifyDidConfigurationResource({ + signatureVerification: 'verified' + }) + ).rejects.toThrow('No DID configuration resource or origin supplied.') + }) + + it('should throw error if both configuration and origin are supplied', async () => { + await expect( + agent.verifyDidConfigurationResource({ + signatureVerification: 'verified', + configuration: DID_CONFIGURATION, + origin: 'https://example.com' + }) + ).rejects.toThrow('Cannot supply both a DID configuration resource and an origin.') + }) + + it('should verify DID configuration resource with signature verification key', async () => { + nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION); + + const result = await agent.verifyDidConfigurationResource({ + signatureVerification: 'verified', + origin: 'https://example.com' + }) + + expect(result.status).toEqual(ValidationStatusEnum.VALID) + }) + + it('should only verify specific DID when given', async () => { + nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION); + + const result = await agent.verifyDidConfigurationResource({ + did: DID, + signatureVerification: 'verified', + origin: 'https://example.com' + }) + + expect(result.credentials.length).toEqual(1); + }) + + if (!testContext.isRestTest) { + it('should verify domain linkage with signature verification callback', async () => { + nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION); + + const result = await agent.verifyDomainLinkage({ + didUrl: DID, + signatureVerification: () => Promise.resolve({ verified: true }) + }) + + expect(result.status).toEqual(ValidationStatusEnum.VALID) + }) + + it('should register signature verification', async () => { + const signatureVerificationKey = 'new' + await agent.registerSignatureVerification({ + key: signatureVerificationKey, + signatureVerification: () => Promise.resolve({ verified: true }) + }) + + await expect( + agent.registerSignatureVerification({ + key: signatureVerificationKey, + signatureVerification: () => Promise.resolve({ verified: true }) + }) + ).rejects.toThrow(`Signature validation with key: ${signatureVerificationKey} already present`) + }) + + it('should remove signature verification', async () => { + const signatureVerificationKey = 'remove' + await agent.registerSignatureVerification({ + key: signatureVerificationKey, + signatureVerification: () => Promise.resolve({ verified: true }) + }) + + const result = await agent.removeSignatureVerification({ key: signatureVerificationKey }) + + expect(result).toEqual(true) + }) + + it('should verify DID configuration resource with signature verification callback', async () => { + nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION); + + const result = await agent.verifyDidConfigurationResource({ + signatureVerification: () => Promise.resolve({ verified: true }), + origin: 'https://example.com' + }) + + expect(result.status).toEqual(ValidationStatusEnum.VALID) + }) + } + }) + +} diff --git a/packages/domain-linkage-verifier/agent.yml b/packages/wellknown-did-verifier/agent.yml similarity index 66% rename from packages/domain-linkage-verifier/agent.yml rename to packages/wellknown-did-verifier/agent.yml index c6aee5433..4f4405789 100644 --- a/packages/domain-linkage-verifier/agent.yml +++ b/packages/wellknown-did-verifier/agent.yml @@ -6,6 +6,8 @@ constants: # please use your own X25519 key, this is only an example secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c methods: + - registerSignatureValidation + - removeSignatureValidation - verifyDomainLinkage - verifyDidConfigurationResource @@ -65,12 +67,41 @@ server: $ref: /constants/baseUrl messagingServiceEndpoint: /messaging +didResolver: + $require: '@veramo/did-resolver#DIDResolverPlugin' + $args: + - resolver: + $require: did-resolver#Resolver + $args: + - web: + $ref: /web-did-resolver + key: + $ref: /did-key-resolver + elem: + $ref: /universal-resolver + io: + $ref: /universal-resolver + ion: + $ref: /universal-resolver + sov: + $ref: /universal-resolver + +universal-resolver: + $require: '@veramo/did-resolver#UniversalResolver' + $args: + - url: https://dev.uniresolver.io/1.0/identifiers/ + +did-key-resolver: + $require: '@veramo/did-provider-key?t=function&p=/key#getDidKeyResolver' + +web-did-resolver: + $require: web-did-resolver?t=function&p=/web#getResolver + # Agent agent: $require: '@veramo/core#Agent' $args: - schemaValidation: false plugins: - - $require: ./packages/connection-manager/dist#DomainLinkageVerifier - -// TODO add resolver + - $ref: /didResolver + - $require: ./packages/wellknown-did-verifier/dist#WellKnownDidVerifier diff --git a/packages/domain-linkage-verifier/api-extractor.json b/packages/wellknown-did-verifier/api-extractor.json similarity index 100% rename from packages/domain-linkage-verifier/api-extractor.json rename to packages/wellknown-did-verifier/api-extractor.json diff --git a/packages/domain-linkage-verifier/package.json b/packages/wellknown-did-verifier/package.json similarity index 63% rename from packages/domain-linkage-verifier/package.json rename to packages/wellknown-did-verifier/package.json index 7315d03b2..2e9e5886d 100644 --- a/packages/domain-linkage-verifier/package.json +++ b/packages/wellknown-did-verifier/package.json @@ -1,12 +1,12 @@ { - "name": "@sphereon/ssi-sdk-domain-linkage-verifier", + "name": "@sphereon/ssi-sdk-wellknown-did-verifier", "version": "0.6.0", "source": "src/index.ts", "main": "dist/index.js", "types": "dist/index.d.ts", "veramo": { "pluginInterfaces": { - "IConnectionManager": "./src/types/IDomainLinkageVerifier.ts" + "IWellknownDidVerifier": "./src/types/IWellKnownDidVerifier.ts" } }, "scripts": { @@ -14,13 +14,12 @@ "generate-plugin-schema": "yarn veramo dev generate-plugin-schema" }, "dependencies": { - "@sphereon/domain-linkage-client": "C:\\Git\\Sphereon-Opensource\\domain-linkage-client\\sphereon-domain-linkage-client-v0.1.0.tgz", - "@veramo/core": "^3.1.2-next.84", - "@veramo/credential-w3c": "^3.1.3" + "@sphereon/wellknown-dids-client": "^0.1.0" }, "devDependencies": { - "@veramo/cli": "^3.1.2-next.84", - "typescript": "^4.5.2" + "@veramo/cli": "3.1.2-next.84", + "nock": "^13.2.9", + "typescript": "4.6.4" }, "files": [ "dist/**/*", @@ -39,6 +38,7 @@ "DID", "Domain Linkage", "DID Configuration Resource", - "Verifier" + "Verifier", + "Well-Known DIDs" ] } diff --git a/packages/wellknown-did-verifier/plugin.schema.json b/packages/wellknown-did-verifier/plugin.schema.json new file mode 100644 index 000000000..8050db33d --- /dev/null +++ b/packages/wellknown-did-verifier/plugin.schema.json @@ -0,0 +1,34 @@ +{ + "IWellKnownDidVerifier": { + "components": { + "schemas": { + "IVerifyDomainLinkageArgs": { + "type": "object", + "properties": { + "didUrl": { + "type": "string" + }, + "signatureVerification": { + "type": "string" + }, + "onlyVerifyServiceDids": { + "type": "boolean" + }, + "additionalProperties": false + }, + "required": ["didUrl", "signatureVerification"], + "description": "Arguments needed for {@link IWellKnownDidVerifier.verifyDomainLinkage } " + } + }, + "methods": { + "verifyDomainLinkage": { + "description": "Verifies the relationship between the controller of an origin and a DID", + "arguments": { + "$ref": "#/components/schemas/IVerifyDomainLinkageArgs" + }, + "returnType": "object" + } + } + } + } +} diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts new file mode 100644 index 000000000..0ba954840 --- /dev/null +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -0,0 +1,116 @@ +import { + IAgentPlugin, + DIDResolutionResult +} from '@veramo/core' +import { WellKnownDidVerifier as Verifier } from '@sphereon/wellknown-dids-client' +import { + IDomainLinkageValidation, + IResourceValidation, + IVerifyCallbackArgs, + IVerifyCredentialResult, +} from '@sphereon/wellknown-dids-client/dist/types' +import { schema } from '../index' +import { + IWellKnownDidVerifier, + IWellKnownDidVerifierOptionsArgs, + IRegisterSignatureVerificationArgs, + IRemoveSignatureVerificationArgs, + IRequiredContext, + IVerifyDidConfigurationResourceArgs, + IVerifyDomainLinkageArgs, +} from '../types/IWellKnownDidVerifier' + +/** + * {@inheritDoc IWellKnownDidVerifier} + */ +export class WellKnownDidVerifier implements IAgentPlugin { + readonly schema = schema.IWellKnownDidVerifier + readonly methods: IWellKnownDidVerifier = { + registerSignatureVerification: this.registerSignatureVerification.bind(this), + removeSignatureVerification: this.removeSignatureVerification.bind(this), + verifyDomainLinkage: this.verifyDomainLinkage.bind(this), + verifyDidConfigurationResource: this.verifyDidConfigurationResource.bind(this) + } + + private readonly signatureVerifications: Record Promise> + private readonly onlyVerifyServiceDids: boolean + + constructor(args: IWellKnownDidVerifierOptionsArgs) { + this.signatureVerifications = args.signatureVerifications || {} + this.onlyVerifyServiceDids = args.onlyVerifyServiceDids || false + } + + // constructor( + // signatureVerifications?: Record Promise>, + // onlyVerifyServiceDids?: boolean + // ) { + // this.signatureVerifications = signatureVerifications || {} + // this.onlyVerifyServiceDids = onlyVerifyServiceDids || false + // } + + /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ + private async registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise { + if (this.signatureVerifications[args.key] !== undefined) { + return Promise.reject(new Error(`Signature validation with key: ${args.key} already present`)) + } + + this.signatureVerifications[args.key] = args.signatureVerification + } + + /** {@inheritDoc IWellKnownDidVerifier.removeSignatureVerification} */ + private async removeSignatureVerification(args: IRemoveSignatureVerificationArgs, context: IRequiredContext): Promise { + return delete this.signatureVerifications[args.key] + } + + /** {@inheritDoc IWellKnownDidVerifier.verifyDomainLinkage} */ + private async verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise { + const signatureVerification: (args: IVerifyCallbackArgs) => Promise = + (typeof args.signatureVerification === 'string') + ? await this.getSignatureVerification(args.signatureVerification) + : args.signatureVerification as (args: IVerifyCallbackArgs) => Promise + + return context.agent.resolveDid({ didUrl: args.didUrl }) + .then((didResolutionResult: DIDResolutionResult) => { + if (!didResolutionResult.didDocument) { + return Promise.reject(Error(`Unable to resolve did: ${args.didUrl}`)) + } + + return new Verifier().verifyDomainLinkage({ + didDocument: didResolutionResult.didDocument, + verifySignatureCallback: signatureVerification, + onlyVerifyServiceDid: args.onlyVerifyServiceDids || this.onlyVerifyServiceDids + }) + }) + } + + /** {@inheritDoc IWellKnownDidVerifier.verifyDidConfigurationResource} */ + private async verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise { + if (args.configuration && args.origin) { + return Promise.reject(Error('Cannot supply both a DID configuration resource and an origin.')) + } + + if (!args.configuration && !args.origin) { + return Promise.reject(Error('No DID configuration resource or origin supplied.')) + } + + const signatureVerification: (args: IVerifyCallbackArgs) => Promise = + (typeof args.signatureVerification === 'string') + ? await this.getSignatureVerification(args.signatureVerification) + : args.signatureVerification as (args: IVerifyCallbackArgs) => Promise + + return new Verifier().verifyResource({ + verifySignatureCallback: signatureVerification, + configuration: args.configuration, + origin: args.origin, + did: args.did + }) + } + + private async getSignatureVerification(key: string): Promise<(args: IVerifyCallbackArgs) => Promise> { + if (this.signatureVerifications[key] === undefined) { + return Promise.reject(new Error(`Signature validation not found for key: ${key}`)) + } + + return this.signatureVerifications[key] + } +} diff --git a/packages/wellknown-did-verifier/src/index.ts b/packages/wellknown-did-verifier/src/index.ts new file mode 100644 index 000000000..c4d83f300 --- /dev/null +++ b/packages/wellknown-did-verifier/src/index.ts @@ -0,0 +1,7 @@ +/** + * @public + */ +const schema = require('../plugin.schema.json') +export { schema } +export { WellKnownDidVerifier } from './agent/WellKnownDidVerifier' +export * from './types/IWellKnownDidVerifier' diff --git a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts new file mode 100644 index 000000000..c1647497d --- /dev/null +++ b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts @@ -0,0 +1,48 @@ +import { + IDidConfigurationResource, + IDomainLinkageValidation, + IVerifyCallbackArgs, + IVerifyCredentialResult, + IResourceValidation +} from '@sphereon/wellknown-dids-client/dist/types' +import { + IAgentContext, + IPluginMethodMap, + IResolver +} from '@veramo/core' + +export interface IWellKnownDidVerifier extends IPluginMethodMap { + registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise, + removeSignatureVerification(args: IRemoveSignatureVerificationArgs, context: IRequiredContext): Promise, + verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise, + verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise +} + +export interface IWellKnownDidVerifierOptionsArgs { + signatureVerifications?: Record Promise> + onlyVerifyServiceDids?: boolean +} + +export interface IRegisterSignatureVerificationArgs { + key: string + signatureVerification: (args: IVerifyCallbackArgs) => Promise +} + +export interface IRemoveSignatureVerificationArgs { + key: string +} + +export interface IVerifyDomainLinkageArgs { + didUrl: string + signatureVerification: ((args: IVerifyCallbackArgs) => Promise) | string + onlyVerifyServiceDids?: boolean +} + +export interface IVerifyDidConfigurationResourceArgs { + signatureVerification: ((args: IVerifyCallbackArgs) => Promise) | string + configuration?: IDidConfigurationResource; + origin?: string; + did?: string +} + +export type IRequiredContext = IAgentContext diff --git a/packages/domain-linkage-verifier/tsconfig.json b/packages/wellknown-did-verifier/tsconfig.json similarity index 79% rename from packages/domain-linkage-verifier/tsconfig.json rename to packages/wellknown-did-verifier/tsconfig.json index 165b8519e..d3e5c24d2 100644 --- a/packages/domain-linkage-verifier/tsconfig.json +++ b/packages/wellknown-did-verifier/tsconfig.json @@ -6,5 +6,5 @@ "declarationDir": "dist", "strictPropertyInitialization": false }, - "references": [{ "path": "../ssi-sdk-core" }] + "references": [] } From a76779aa6c461f941e3b074e4cace71daee0908d Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Wed, 10 Aug 2022 15:32:55 +0200 Subject: [PATCH 03/15] VDX-88 removed unused code --- .../src/agent/WellKnownDidVerifier.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index 0ba954840..a28f9a4ad 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -40,14 +40,6 @@ export class WellKnownDidVerifier implements IAgentPlugin { this.onlyVerifyServiceDids = args.onlyVerifyServiceDids || false } - // constructor( - // signatureVerifications?: Record Promise>, - // onlyVerifyServiceDids?: boolean - // ) { - // this.signatureVerifications = signatureVerifications || {} - // this.onlyVerifyServiceDids = onlyVerifyServiceDids || false - // } - /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ private async registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise { if (this.signatureVerifications[args.key] !== undefined) { From 4179fdae07a0ccd86b26d5d55c2651dbcc7c94d9 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Wed, 10 Aug 2022 15:36:38 +0200 Subject: [PATCH 04/15] VDX-88 removed plugin generation script --- packages/wellknown-did-verifier/package.json | 3 +-- yarn.lock | 21 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/wellknown-did-verifier/package.json b/packages/wellknown-did-verifier/package.json index 2e9e5886d..51e684483 100644 --- a/packages/wellknown-did-verifier/package.json +++ b/packages/wellknown-did-verifier/package.json @@ -10,8 +10,7 @@ } }, "scripts": { - "build": "tsc --build", - "generate-plugin-schema": "yarn veramo dev generate-plugin-schema" + "build": "tsc --build" }, "dependencies": { "@sphereon/wellknown-dids-client": "^0.1.0" diff --git a/yarn.lock b/yarn.lock index 37dd52f87..8c1ee4567 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3306,6 +3306,15 @@ resolved "https://registry.yarnpkg.com/@sphereon/react-native-argon2/-/react-native-argon2-2.0.6.tgz#602abb96d6d41a7f0778a3323940fca0b4fa13ed" integrity sha512-5RkIzhfeDw12p1t2BcQQJyYmgtPE3CQDPLwPfwpnVGamG5R8tY4FhJRNScGzRzttHw6tbBWC1acZ2IM0swEmUQ== +"@sphereon/wellknown-dids-client@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@sphereon/wellknown-dids-client/-/wellknown-dids-client-0.1.0.tgz#b682cfad2086513564dbde3df1388a2fd865f3be" + integrity sha512-JpXTVCZQCGvKPhJ4KJ2bkklo/MnAoUrsfMN6C65FgLu9VznLM3pEMB/IbqHk4yJ8OWIg8zeOc5s2G2YiGxaQ1A== + dependencies: + "@sphereon/ssi-sdk-core" "^0.7.0" + cross-fetch "^3.1.5" + jwt-decode "^3.1.2" + "@sqltools/formatter@^1.2.2": version "1.2.3" resolved "https://registry.yarnpkg.com/@sqltools/formatter/-/formatter-1.2.3.tgz#1185726610acc37317ddab11c3c7f9066966bd20" @@ -11459,7 +11468,7 @@ nerf-dart@^1.0.0: resolved "https://registry.yarnpkg.com/nerf-dart/-/nerf-dart-1.0.0.tgz#e6dab7febf5ad816ea81cf5c629c5a0ebde72c1a" integrity sha512-EZSPZB70jiVsivaBLYDCyntd5eH8NTSMOn3rB+HxwdmKThGELLdYv8qVIMWvZEFy9w8ZZpW9h9OB32l1rGtj7g== -nock@*, nock@^13.2.1: +nock@*, nock@^13.2.1, nock@^13.2.9: version "13.2.9" resolved "https://registry.yarnpkg.com/nock/-/nock-13.2.9.tgz#4faf6c28175d36044da4cfa68e33e5a15086ad4c" integrity sha512-1+XfJNYF1cjGB+TKMWi29eZ0b82QOvQs2YoLNzbpWGqFMtRQHTa57osqdGj4FrFPgkO4D4AZinzUJR9VvW3QUA== @@ -14705,6 +14714,11 @@ typescript@4.4.3: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA== +typescript@4.6.4, typescript@~4.6.2, typescript@~4.6.3: + version "4.6.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" + integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== + typescript@^4.4.3, typescript@^4.5.2, typescript@^4.5.4, typescript@^4.7.4: version "4.7.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" @@ -14715,11 +14729,6 @@ typescript@~4.4.3: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.4.tgz#2cd01a1a1f160704d3101fd5a58ff0f9fcb8030c" integrity sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA== -typescript@~4.6.2, typescript@~4.6.3: - version "4.6.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" - integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== - typical@^2.6.0, typical@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d" From 7e98ba6ab9c6d4f51f351c2ea3c9ea403b354b6b Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Wed, 10 Aug 2022 16:18:00 +0200 Subject: [PATCH 05/15] VDX-88 constructor fix --- .../src/agent/WellKnownDidVerifier.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index a28f9a4ad..a394825e0 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -35,9 +35,9 @@ export class WellKnownDidVerifier implements IAgentPlugin { private readonly signatureVerifications: Record Promise> private readonly onlyVerifyServiceDids: boolean - constructor(args: IWellKnownDidVerifierOptionsArgs) { - this.signatureVerifications = args.signatureVerifications || {} - this.onlyVerifyServiceDids = args.onlyVerifyServiceDids || false + constructor(args?: IWellKnownDidVerifierOptionsArgs) { + this.signatureVerifications = args && args.signatureVerifications || {} + this.onlyVerifyServiceDids = args && args.onlyVerifyServiceDids || false } /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ From fe35f9e60cf398ac2dd62cb7acfb48f0c4d6f70f Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Wed, 10 Aug 2022 16:27:54 +0200 Subject: [PATCH 06/15] VDX-88 set fixed version for ts --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 820b0b8d0..e72e5c373 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "ts-jest": "^27.1.3", "ts-json-schema-generator": "^0.97.0", "ts-node": "^10.4.0", - "typescript": "^4.5.4", + "typescript": "4.6.4", "eslint": "^8.7.0", "eslint-plugin-eslint-comments": "^3.2.0", "@typescript-eslint/eslint-plugin": "^5.9.1", From 0c7784973ed273b2600595ca04e97faeaaebcb5b Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 00:27:04 +0200 Subject: [PATCH 07/15] VDX-88 version to 0.7.0 --- packages/wellknown-did-verifier/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wellknown-did-verifier/package.json b/packages/wellknown-did-verifier/package.json index 51e684483..049dc579d 100644 --- a/packages/wellknown-did-verifier/package.json +++ b/packages/wellknown-did-verifier/package.json @@ -1,6 +1,6 @@ { "name": "@sphereon/ssi-sdk-wellknown-did-verifier", - "version": "0.6.0", + "version": "0.7.0", "source": "src/index.ts", "main": "dist/index.js", "types": "dist/index.d.ts", From b9fb4ecc6d18fd4eafd8c59c1591e53a002019e1 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 00:29:07 +0200 Subject: [PATCH 08/15] VDX-88 interface field renamed --- .../wellknown-did-verifier/__tests__/localAgent.test.ts | 2 +- .../wellknown-did-verifier/__tests__/restAgent.test.ts | 2 +- .../src/agent/WellKnownDidVerifier.ts | 8 ++++---- .../src/types/IWellKnownDidVerifier.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts index 8d0a1236b..0445570d8 100644 --- a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts +++ b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts @@ -12,7 +12,7 @@ const setup = async (): Promise => { const { localAgent } = createObjects(config, { localAgent: '/agent' }) await localAgent.registerSignatureVerification({ - key: 'verified', + signatureVerificationKey: 'verified', signatureVerification: () => Promise.resolve({ verified: true }) }, null) diff --git a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts index 6e856814c..faa555bd5 100644 --- a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts +++ b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts @@ -36,7 +36,7 @@ const setup = async (): Promise => { const { agent } = createObjects(config, { agent: '/agent' }) await agent.registerSignatureVerification({ - key: 'verified', + signatureVerificationKey: 'verified', signatureVerification: () => Promise.resolve({ verified: true }) }, null) diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index a394825e0..3e07ac25e 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -42,16 +42,16 @@ export class WellKnownDidVerifier implements IAgentPlugin { /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ private async registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise { - if (this.signatureVerifications[args.key] !== undefined) { - return Promise.reject(new Error(`Signature validation with key: ${args.key} already present`)) + if (this.signatureVerifications[args.signatureVerificationKey] !== undefined) { + return Promise.reject(new Error(`Signature validation with key: ${args.signatureVerificationKey} already present`)) } - this.signatureVerifications[args.key] = args.signatureVerification + this.signatureVerifications[args.signatureVerificationKey] = args.signatureVerification } /** {@inheritDoc IWellKnownDidVerifier.removeSignatureVerification} */ private async removeSignatureVerification(args: IRemoveSignatureVerificationArgs, context: IRequiredContext): Promise { - return delete this.signatureVerifications[args.key] + return delete this.signatureVerifications[args.signatureVerificationKey] } /** {@inheritDoc IWellKnownDidVerifier.verifyDomainLinkage} */ diff --git a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts index c1647497d..c7ebcebca 100644 --- a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts @@ -24,12 +24,12 @@ export interface IWellKnownDidVerifierOptionsArgs { } export interface IRegisterSignatureVerificationArgs { - key: string + signatureVerificationKey: string signatureVerification: (args: IVerifyCallbackArgs) => Promise } export interface IRemoveSignatureVerificationArgs { - key: string + signatureVerificationKey: string } export interface IVerifyDomainLinkageArgs { From df0cc1e2ec362b15e2aa3c629608ae10c7c85f33 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 00:30:09 +0200 Subject: [PATCH 09/15] VDX-88 removed secret key from agent.yml --- packages/wellknown-did-verifier/agent.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/wellknown-did-verifier/agent.yml b/packages/wellknown-did-verifier/agent.yml index 4f4405789..92424989f 100644 --- a/packages/wellknown-did-verifier/agent.yml +++ b/packages/wellknown-did-verifier/agent.yml @@ -3,8 +3,6 @@ version: 3.0 constants: baseUrl: http://localhost:3335 port: 3335 - # please use your own X25519 key, this is only an example - secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c methods: - registerSignatureValidation - removeSignatureValidation From f3bdc4442d66fe5e6743394691f3480087da6fbc Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 00:33:19 +0200 Subject: [PATCH 10/15] VDX-88 test cleanup --- .../shared/wellKnownDidVerifierAgentLogic.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts index 81d889cfc..ced9ffdaf 100644 --- a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts +++ b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts @@ -94,7 +94,9 @@ export default (testContext: { }) it('should verify DID configuration resource with signature verification key', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json') + .times(1) + .reply(200, DID_CONFIGURATION); const result = await agent.verifyDidConfigurationResource({ signatureVerification: 'verified', @@ -105,7 +107,9 @@ export default (testContext: { }) it('should only verify specific DID when given', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json') + .times(1) + .reply(200, DID_CONFIGURATION); const result = await agent.verifyDidConfigurationResource({ did: DID, @@ -118,7 +122,9 @@ export default (testContext: { if (!testContext.isRestTest) { it('should verify domain linkage with signature verification callback', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json') + .times(1) + .reply(200, DID_CONFIGURATION); const result = await agent.verifyDomainLinkage({ didUrl: DID, @@ -131,13 +137,13 @@ export default (testContext: { it('should register signature verification', async () => { const signatureVerificationKey = 'new' await agent.registerSignatureVerification({ - key: signatureVerificationKey, + signatureVerificationKey, signatureVerification: () => Promise.resolve({ verified: true }) }) await expect( agent.registerSignatureVerification({ - key: signatureVerificationKey, + signatureVerificationKey, signatureVerification: () => Promise.resolve({ verified: true }) }) ).rejects.toThrow(`Signature validation with key: ${signatureVerificationKey} already present`) @@ -146,11 +152,11 @@ export default (testContext: { it('should remove signature verification', async () => { const signatureVerificationKey = 'remove' await agent.registerSignatureVerification({ - key: signatureVerificationKey, + signatureVerificationKey, signatureVerification: () => Promise.resolve({ verified: true }) }) - const result = await agent.removeSignatureVerification({ key: signatureVerificationKey }) + const result = await agent.removeSignatureVerification({ signatureVerificationKey }) expect(result).toEqual(true) }) From 6bbbb2c8b7455e221e7c0ee3c56498465bf841f9 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 00:58:04 +0200 Subject: [PATCH 11/15] VDX-88 readme update --- packages/wellknown-did-verifier/README.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/wellknown-did-verifier/README.md b/packages/wellknown-did-verifier/README.md index 68885e1fe..927013d22 100644 --- a/packages/wellknown-did-verifier/README.md +++ b/packages/wellknown-did-verifier/README.md @@ -12,7 +12,7 @@ --- -A `Sphereon SSI-SDK` plugin to verify relationships between the controller of an origin and a DID and to verify DID configuration resources. +A `Sphereon SSI-SDK` plugin to verify relationships between the controller of an origin and a DID conforming to the DIF [spec for well-known DID Configurations](https://identity.foundation/.well-known/resources/did-configuration/) It is written in Typescript and can be compiled to any target JavaScript version. ## Available functions * registerSignatureValidation @@ -42,9 +42,11 @@ const agent = createAgent({ ### Register signature verification callback: +Registers a callback function to be called within the verification process, to verify the signature of the credentials within the DID configuration resource. + ```typescript agent.registerSignatureVerification({ - key: 'example_key', + signatureVerificationKey: 'example_key', signatureVerification: () => Promise.resolve({ verified: true }) }) .then(() => console.log('success')) @@ -53,14 +55,19 @@ agent.registerSignatureVerification({ ### Remove signature verification callback: +Removes a registered callback function. + ```typescript -agent.removeSignatureVerification({ key: 'example_key' }) +agent.removeSignatureVerification({ signatureVerificationKey: 'example_key' }) .then(() => console.log('success')) .catch(() => console.log('failed')) ``` ### Verify domain linkage: +Verifies the relationship between the controller of an origin and a given DID. +Option available to only verify the service DID. + ```typescript agent.verifyDomainLinkage({ didUrl: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo', @@ -72,12 +79,16 @@ agent.verifyDomainLinkage({ ### Verify DID configuration resource: -You can either pass in a DID configuration resource or fetch it remotely by setting a secure well-known location (origin). +Verifies a DID configuration resource and domain linkage credentials it holds. + +You can either pass in a DID configuration resource or fetch it remotely by setting a secure well-known location (origin). +Option available to only verify a given DID. ```typescript agent.verifyDidConfigurationResource({ signatureVerification: () => Promise.resolve({ verified: true }), - origin: 'https://example.com' + origin: 'https://example.com', + did: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo' }) .then((result: IResourceValidation) => console.log(result.status)) ``` From a245b1497a45b6a89cbd8f0eea59a2ff4e195ab2 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 01:08:23 +0200 Subject: [PATCH 12/15] VDX-88 test cleanup --- .../shared/wellKnownDidVerifierAgentLogic.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts index ced9ffdaf..51b9a267c 100644 --- a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts +++ b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts @@ -32,7 +32,9 @@ export default (testContext: { afterAll(testContext.tearDown) it('should verify domain linkage with signature verification key', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json') + .times(3) + .reply(200, DID_CONFIGURATION); const result = await agent.verifyDomainLinkage({ didUrl: DID, @@ -43,7 +45,9 @@ export default (testContext: { }) it('should only verify service DIDs when onlyVerifyServiceDids set to true', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json') + .times(3) + .reply(200, DID_CONFIGURATION); const result = await agent.verifyDomainLinkage({ didUrl: DID, @@ -123,7 +127,7 @@ export default (testContext: { if (!testContext.isRestTest) { it('should verify domain linkage with signature verification callback', async () => { nock('https://example.com').get('/.well-known/did-configuration.json') - .times(1) + .times(3) .reply(200, DID_CONFIGURATION); const result = await agent.verifyDomainLinkage({ @@ -162,7 +166,9 @@ export default (testContext: { }) it('should verify DID configuration resource with signature verification callback', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json') + .times(1) + .reply(200, DID_CONFIGURATION); const result = await agent.verifyDidConfigurationResource({ signatureVerification: () => Promise.resolve({ verified: true }), From 7f845055df7cb338d87e148f6f98e54d37d22a83 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 01:10:39 +0200 Subject: [PATCH 13/15] VDX-88 prettier --- packages/wellknown-did-verifier/README.md | 60 ++++++------ .../__tests__/localAgent.test.ts | 22 ++--- .../__tests__/restAgent.test.ts | 24 ++--- .../shared/wellKnownDidVerifierAgentLogic.ts | 91 ++++++++----------- .../src/agent/WellKnownDidVerifier.ts | 44 ++++----- .../src/types/IWellKnownDidVerifier.ts | 18 ++-- 6 files changed, 120 insertions(+), 139 deletions(-) diff --git a/packages/wellknown-did-verifier/README.md b/packages/wellknown-did-verifier/README.md index 927013d22..ad9081d75 100644 --- a/packages/wellknown-did-verifier/README.md +++ b/packages/wellknown-did-verifier/README.md @@ -12,29 +12,27 @@ --- -A `Sphereon SSI-SDK` plugin to verify relationships between the controller of an origin and a DID conforming to the DIF [spec for well-known DID Configurations](https://identity.foundation/.well-known/resources/did-configuration/) It is written in Typescript and can be compiled to any target JavaScript version. +A `Sphereon SSI-SDK` plugin to verify relationships between the controller of an origin and a DID conforming to the DIF [spec for well-known DID Configurations](https://identity.foundation/.well-known/resources/did-configuration/) It is written in Typescript and can be compiled to any target JavaScript version. ## Available functions -* registerSignatureValidation -* removeSignatureValidation -* verifyDomainLinkage -* verifyDidConfigurationResource + +- registerSignatureValidation +- removeSignatureValidation +- verifyDomainLinkage +- verifyDidConfigurationResource ## Usage ### Adding the plugin to an agent: ```typescript -import { - IWellKnownDidVerifier, - WellKnownDidVerifier -} from '@sphereon/ssi-sdk-wellknown-did-verifier'; +import { IWellKnownDidVerifier, WellKnownDidVerifier } from '@sphereon/ssi-sdk-wellknown-did-verifier' const agent = createAgent({ plugins: [ new WellKnownDidVerifier({ - signatureVerifications: {'verified': () => Promise.resolve({ verified: true })}, - onlyVerifyServiceDids: true + signatureVerifications: { verified: () => Promise.resolve({ verified: true }) }, + onlyVerifyServiceDids: true, }), ], }) @@ -45,10 +43,11 @@ const agent = createAgent({ Registers a callback function to be called within the verification process, to verify the signature of the credentials within the DID configuration resource. ```typescript -agent.registerSignatureVerification({ - signatureVerificationKey: 'example_key', - signatureVerification: () => Promise.resolve({ verified: true }) -}) +agent + .registerSignatureVerification({ + signatureVerificationKey: 'example_key', + signatureVerification: () => Promise.resolve({ verified: true }), + }) .then(() => console.log('success')) .catch(() => console.log('failed')) ``` @@ -58,23 +57,25 @@ agent.registerSignatureVerification({ Removes a registered callback function. ```typescript -agent.removeSignatureVerification({ signatureVerificationKey: 'example_key' }) +agent + .removeSignatureVerification({ signatureVerificationKey: 'example_key' }) .then(() => console.log('success')) .catch(() => console.log('failed')) ``` ### Verify domain linkage: -Verifies the relationship between the controller of an origin and a given DID. +Verifies the relationship between the controller of an origin and a given DID. Option available to only verify the service DID. ```typescript -agent.verifyDomainLinkage({ - didUrl: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo', - signatureVerification: 'verified', - onlyVerifyServiceDids: false -}) -.then((result: IDomainLinkageValidation) => console.log(result.status)) +agent + .verifyDomainLinkage({ + didUrl: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo', + signatureVerification: 'verified', + onlyVerifyServiceDids: false, + }) + .then((result: IDomainLinkageValidation) => console.log(result.status)) ``` ### Verify DID configuration resource: @@ -85,12 +86,13 @@ You can either pass in a DID configuration resource or fetch it remotely by sett Option available to only verify a given DID. ```typescript -agent.verifyDidConfigurationResource({ - signatureVerification: () => Promise.resolve({ verified: true }), - origin: 'https://example.com', - did: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo' -}) -.then((result: IResourceValidation) => console.log(result.status)) +agent + .verifyDidConfigurationResource({ + signatureVerification: () => Promise.resolve({ verified: true }), + origin: 'https://example.com', + did: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo', + }) + .then((result: IResourceValidation) => console.log(result.status)) ``` ## Installation diff --git a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts index 0445570d8..be34f632a 100644 --- a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts +++ b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts @@ -11,18 +11,18 @@ const setup = async (): Promise => { const config = getConfig('packages/wellknown-did-verifier/agent.yml') const { localAgent } = createObjects(config, { localAgent: '/agent' }) - await localAgent.registerSignatureVerification({ - signatureVerificationKey: 'verified', - signatureVerification: () => Promise.resolve({ verified: true }) - }, null) + await localAgent.registerSignatureVerification( + { + signatureVerificationKey: 'verified', + signatureVerification: () => Promise.resolve({ verified: true }), + }, + null + ) - const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM'; - const ORIGIN = 'https://example.com'; + const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM' + const ORIGIN = 'https://example.com' const DOCUMENT = { - '@context': [ - 'https://www.w3.org/ns/did/v1', - 'https://identity.foundation/.well-known/did-configuration/v1' - ], + '@context': ['https://www.w3.org/ns/did/v1', 'https://identity.foundation/.well-known/did-configuration/v1'], id: DID, verificationMethod: [ { @@ -50,7 +50,7 @@ const setup = async (): Promise => { serviceEndpoint: ORIGIN, }, ], - }; + } localAgent.resolveDid = jest.fn().mockReturnValue(Promise.resolve({ didDocument: DOCUMENT })) diff --git a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts index faa555bd5..aef75163d 100644 --- a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts +++ b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts @@ -7,7 +7,7 @@ import { AgentRestClient } from '@veramo/remote-client' import { AgentRouter, RequestWithAgentRouter } from '@veramo/remote-server' import { getConfig } from '@veramo/cli/build/setup' import { createObjects } from '@veramo/cli/build/lib/objectCreator' -import { IWellKnownDidVerifier } from '../src/types/IWellKnownDidVerifier'; +import { IWellKnownDidVerifier } from '../src/types/IWellKnownDidVerifier' import { ServiceTypesEnum } from '@sphereon/wellknown-dids-client/dist/types' import wellKnownDidVerifierAgentLogic from './shared/wellKnownDidVerifierAgentLogic' @@ -35,18 +35,18 @@ const setup = async (): Promise => { const config = getConfig('packages/wellknown-did-verifier/agent.yml') const { agent } = createObjects(config, { agent: '/agent' }) - await agent.registerSignatureVerification({ - signatureVerificationKey: 'verified', - signatureVerification: () => Promise.resolve({ verified: true }) - }, null) + await agent.registerSignatureVerification( + { + signatureVerificationKey: 'verified', + signatureVerification: () => Promise.resolve({ verified: true }), + }, + null + ) - const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM'; - const ORIGIN = 'https://example.com'; + const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM' + const ORIGIN = 'https://example.com' const DOCUMENT = { - '@context': [ - 'https://www.w3.org/ns/did/v1', - 'https://identity.foundation/.well-known/did-configuration/v1' - ], + '@context': ['https://www.w3.org/ns/did/v1', 'https://identity.foundation/.well-known/did-configuration/v1'], id: DID, verificationMethod: [ { @@ -74,7 +74,7 @@ const setup = async (): Promise => { serviceEndpoint: ORIGIN, }, ], - }; + } agent.resolveDid = jest.fn().mockReturnValue(Promise.resolve({ didDocument: DOCUMENT })) diff --git a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts index 51b9a267c..c2c0af42f 100644 --- a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts +++ b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts @@ -1,4 +1,4 @@ -import { ValidationStatusEnum } from '@sphereon/wellknown-dids-client/dist/types'; +import { ValidationStatusEnum } from '@sphereon/wellknown-dids-client/dist/types' import { TAgent, IResolver } from '@veramo/core' import { IWellKnownDidVerifier } from '../../src/types/IWellKnownDidVerifier' @@ -13,14 +13,14 @@ export default (testContext: { isRestTest: boolean }) => { describe('Well-Known DID Verifier Agent Plugin', () => { - const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM'; + const DID = 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM' const DID_CONFIGURATION = { '@context': 'https://identity.foundation/.well-known/did-configuration/v1', linked_dids: [ 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNI3o2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSJ9.eyJleHAiOjE3NjQ4NzkxMzksImlzcyI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNIiwibmJmIjoxNjA3MTEyNzM5LCJzdWIiOiJkaWQ6a2V5Ono2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSIsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwiaHR0cHM6Ly9pZGVudGl0eS5mb3VuZGF0aW9uLy53ZWxsLWtub3duL2RpZC1jb25maWd1cmF0aW9uL3YxIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7ImlkIjoiZGlkOmtleTp6Nk1rb1RIc2dOTnJieThKekNOUTFpUkx5VzVRUTZSOFh1dTZBQThpZ0dyTVZQVU0iLCJvcmlnaW4iOiJodHRwczovL2lkZW50aXR5LmZvdW5kYXRpb24ifSwiZXhwaXJhdGlvbkRhdGUiOiIyMDI1LTEyLTA0VDE0OjEyOjE5LTA2OjAwIiwiaXNzdWFuY2VEYXRlIjoiMjAyMC0xMi0wNFQxNDoxMjoxOS0wNjowMCIsImlzc3VlciI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNIiwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIkRvbWFpbkxpbmthZ2VDcmVkZW50aWFsIl19fQ.YZnpPMAW3GdaPXC2YKoJ7Igt1OaVZKq09XZBkptyhxTAyHTkX2Ewtew-JKHKQjyDyabY3HAy1LUPoIQX0jrU0J82pIYT3k2o7nNTdLbxlgb49FcDn4czntt5SbY0m1XwrMaKEvV0bHQsYPxNTqjYsyySccgPfmvN9IT8gRS-M9a6MZQxuB3oEMrVOQ5Vco0bvTODXAdCTHibAk1FlvKz0r1vO5QMhtW4OlRrVTI7ibquf9Nim_ch0KeMMThFjsBDKetuDF71nUcL5sf7PCFErvl8ZVw3UK4NkZ6iM-XIRsLL6rXP2SnDUVovcldhxd_pyKEYviMHBOgBdoNP6fOgRQ', 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImRpZDprZXk6ejZNa29USHNnTk5yYnk4SnpDTlExaVJMeVc1UVE2UjhYdXU2QUE4aWdHck1WUFVNI3o2TWtvVEhzZ05OcmJ5OEp6Q05RMWlSTHlXNVFRNlI4WHV1NkFBOGlnR3JNVlBVTSJ9.eyJleHAiOjE3NjQ4NzkxMzksImlzcyI6ImRpZDprZXk6b3RoZXIiLCJuYmYiOjE2MDcxMTI3MzksInN1YiI6ImRpZDprZXk6b3RoZXIiLCJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vaWRlbnRpdHkuZm91bmRhdGlvbi8ud2VsbC1rbm93bi9kaWQtY29uZmlndXJhdGlvbi92MSJdLCJjcmVkZW50aWFsU3ViamVjdCI6eyJpZCI6ImRpZDprZXk6b3RoZXIiLCJvcmlnaW4iOiJodHRwczovL2lkZW50aXR5LmZvdW5kYXRpb24ifSwiZXhwaXJhdGlvbkRhdGUiOiIyMDI1LTEyLTA0VDE0OjEyOjE5LTA2OjAwIiwiaXNzdWFuY2VEYXRlIjoiMjAyMC0xMi0wNFQxNDoxMjoxOS0wNjowMCIsImlzc3VlciI6ImRpZDprZXk6b3RoZXIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRG9tYWluTGlua2FnZUNyZWRlbnRpYWwiXX19.rRuc-ojuEgyq8p_tBYK7BayuiNTBeXNyAnC14Rnjs-jsnhae4_E1Q12W99K2NGCGBi5KjNsBcZmdNJPxejiKPrjjcB99poFCgTY8tuRzDjVo0lIeBwfx9qqjKHTRTUR8FGM_imlOpVfBF4AHYxjkHvZn6c9lYvatYcDpB2UfH4BNXkdSVrUXy_kYjpMpAdRtyCAnD_isN1YpEHBqBmnfuVUbYcQK5kk6eiokRFDtWruL1OEeJMYPqjuBSd2m-H54tSM84Oic_pg2zXDjjBlXNelat6MPNT2QxmkwJg7oyewQWX2Ot2yyhSp9WyAQWMlQIe2x84R0lADUmZ1TPQchNw', ], - }; + } let agent: ConfiguredAgent @@ -32,39 +32,35 @@ export default (testContext: { afterAll(testContext.tearDown) it('should verify domain linkage with signature verification key', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json') - .times(3) - .reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION) const result = await agent.verifyDomainLinkage({ didUrl: DID, - signatureVerification: 'verified' + signatureVerification: 'verified', }) expect(result.status).toEqual(ValidationStatusEnum.VALID) }) it('should only verify service DIDs when onlyVerifyServiceDids set to true', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json') - .times(3) - .reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION) const result = await agent.verifyDomainLinkage({ didUrl: DID, signatureVerification: 'verified', - onlyVerifyServiceDids: true + onlyVerifyServiceDids: true, }) - expect(result.endpointDescriptors[0].resources[0].credentials.length).toEqual(1); + expect(result.endpointDescriptors[0].resources[0].credentials.length).toEqual(1) }) it('should throw error if signature verification key is not found when verifying a domain linkage', async () => { const signatureVerificationKey = 'unknown' await expect( - agent.verifyDomainLinkage({ - didUrl: DID, - signatureVerification: signatureVerificationKey, - }) + agent.verifyDomainLinkage({ + didUrl: DID, + signatureVerification: signatureVerificationKey, + }) ).rejects.toThrow(`Signature validation not found for key: ${signatureVerificationKey}`) }) @@ -72,67 +68,61 @@ export default (testContext: { const signatureVerificationKey = 'unknown' await expect( - agent.verifyDidConfigurationResource({ - signatureVerification: signatureVerificationKey, - origin: 'https://example.com' - }) + agent.verifyDidConfigurationResource({ + signatureVerification: signatureVerificationKey, + origin: 'https://example.com', + }) ).rejects.toThrow(`Signature validation not found for key: ${signatureVerificationKey}`) }) it('should throw error if no configuration or origin is supplied', async () => { await expect( - agent.verifyDidConfigurationResource({ - signatureVerification: 'verified' - }) + agent.verifyDidConfigurationResource({ + signatureVerification: 'verified', + }) ).rejects.toThrow('No DID configuration resource or origin supplied.') }) it('should throw error if both configuration and origin are supplied', async () => { await expect( - agent.verifyDidConfigurationResource({ - signatureVerification: 'verified', - configuration: DID_CONFIGURATION, - origin: 'https://example.com' - }) + agent.verifyDidConfigurationResource({ + signatureVerification: 'verified', + configuration: DID_CONFIGURATION, + origin: 'https://example.com', + }) ).rejects.toThrow('Cannot supply both a DID configuration resource and an origin.') }) it('should verify DID configuration resource with signature verification key', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json') - .times(1) - .reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION) const result = await agent.verifyDidConfigurationResource({ signatureVerification: 'verified', - origin: 'https://example.com' + origin: 'https://example.com', }) expect(result.status).toEqual(ValidationStatusEnum.VALID) }) it('should only verify specific DID when given', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json') - .times(1) - .reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION) const result = await agent.verifyDidConfigurationResource({ did: DID, signatureVerification: 'verified', - origin: 'https://example.com' + origin: 'https://example.com', }) - expect(result.credentials.length).toEqual(1); + expect(result.credentials.length).toEqual(1) }) if (!testContext.isRestTest) { it('should verify domain linkage with signature verification callback', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json') - .times(3) - .reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION) const result = await agent.verifyDomainLinkage({ didUrl: DID, - signatureVerification: () => Promise.resolve({ verified: true }) + signatureVerification: () => Promise.resolve({ verified: true }), }) expect(result.status).toEqual(ValidationStatusEnum.VALID) @@ -142,14 +132,14 @@ export default (testContext: { const signatureVerificationKey = 'new' await agent.registerSignatureVerification({ signatureVerificationKey, - signatureVerification: () => Promise.resolve({ verified: true }) + signatureVerification: () => Promise.resolve({ verified: true }), }) await expect( - agent.registerSignatureVerification({ - signatureVerificationKey, - signatureVerification: () => Promise.resolve({ verified: true }) - }) + agent.registerSignatureVerification({ + signatureVerificationKey, + signatureVerification: () => Promise.resolve({ verified: true }), + }) ).rejects.toThrow(`Signature validation with key: ${signatureVerificationKey} already present`) }) @@ -157,7 +147,7 @@ export default (testContext: { const signatureVerificationKey = 'remove' await agent.registerSignatureVerification({ signatureVerificationKey, - signatureVerification: () => Promise.resolve({ verified: true }) + signatureVerification: () => Promise.resolve({ verified: true }), }) const result = await agent.removeSignatureVerification({ signatureVerificationKey }) @@ -166,18 +156,15 @@ export default (testContext: { }) it('should verify DID configuration resource with signature verification callback', async () => { - nock('https://example.com').get('/.well-known/did-configuration.json') - .times(1) - .reply(200, DID_CONFIGURATION); + nock('https://example.com').get('/.well-known/did-configuration.json').times(1).reply(200, DID_CONFIGURATION) const result = await agent.verifyDidConfigurationResource({ signatureVerification: () => Promise.resolve({ verified: true }), - origin: 'https://example.com' + origin: 'https://example.com', }) expect(result.status).toEqual(ValidationStatusEnum.VALID) }) } }) - } diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index 3e07ac25e..7388b13d6 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -1,7 +1,4 @@ -import { - IAgentPlugin, - DIDResolutionResult -} from '@veramo/core' +import { IAgentPlugin, DIDResolutionResult } from '@veramo/core' import { WellKnownDidVerifier as Verifier } from '@sphereon/wellknown-dids-client' import { IDomainLinkageValidation, @@ -29,15 +26,15 @@ export class WellKnownDidVerifier implements IAgentPlugin { registerSignatureVerification: this.registerSignatureVerification.bind(this), removeSignatureVerification: this.removeSignatureVerification.bind(this), verifyDomainLinkage: this.verifyDomainLinkage.bind(this), - verifyDidConfigurationResource: this.verifyDidConfigurationResource.bind(this) + verifyDidConfigurationResource: this.verifyDidConfigurationResource.bind(this), } private readonly signatureVerifications: Record Promise> private readonly onlyVerifyServiceDids: boolean constructor(args?: IWellKnownDidVerifierOptionsArgs) { - this.signatureVerifications = args && args.signatureVerifications || {} - this.onlyVerifyServiceDids = args && args.onlyVerifyServiceDids || false + this.signatureVerifications = (args && args.signatureVerifications) || {} + this.onlyVerifyServiceDids = (args && args.onlyVerifyServiceDids) || false } /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ @@ -57,22 +54,21 @@ export class WellKnownDidVerifier implements IAgentPlugin { /** {@inheritDoc IWellKnownDidVerifier.verifyDomainLinkage} */ private async verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise { const signatureVerification: (args: IVerifyCallbackArgs) => Promise = - (typeof args.signatureVerification === 'string') - ? await this.getSignatureVerification(args.signatureVerification) - : args.signatureVerification as (args: IVerifyCallbackArgs) => Promise + typeof args.signatureVerification === 'string' + ? await this.getSignatureVerification(args.signatureVerification) + : (args.signatureVerification as (args: IVerifyCallbackArgs) => Promise) - return context.agent.resolveDid({ didUrl: args.didUrl }) - .then((didResolutionResult: DIDResolutionResult) => { - if (!didResolutionResult.didDocument) { - return Promise.reject(Error(`Unable to resolve did: ${args.didUrl}`)) - } + return context.agent.resolveDid({ didUrl: args.didUrl }).then((didResolutionResult: DIDResolutionResult) => { + if (!didResolutionResult.didDocument) { + return Promise.reject(Error(`Unable to resolve did: ${args.didUrl}`)) + } - return new Verifier().verifyDomainLinkage({ - didDocument: didResolutionResult.didDocument, - verifySignatureCallback: signatureVerification, - onlyVerifyServiceDid: args.onlyVerifyServiceDids || this.onlyVerifyServiceDids - }) + return new Verifier().verifyDomainLinkage({ + didDocument: didResolutionResult.didDocument, + verifySignatureCallback: signatureVerification, + onlyVerifyServiceDid: args.onlyVerifyServiceDids || this.onlyVerifyServiceDids, }) + }) } /** {@inheritDoc IWellKnownDidVerifier.verifyDidConfigurationResource} */ @@ -86,15 +82,15 @@ export class WellKnownDidVerifier implements IAgentPlugin { } const signatureVerification: (args: IVerifyCallbackArgs) => Promise = - (typeof args.signatureVerification === 'string') - ? await this.getSignatureVerification(args.signatureVerification) - : args.signatureVerification as (args: IVerifyCallbackArgs) => Promise + typeof args.signatureVerification === 'string' + ? await this.getSignatureVerification(args.signatureVerification) + : (args.signatureVerification as (args: IVerifyCallbackArgs) => Promise) return new Verifier().verifyResource({ verifySignatureCallback: signatureVerification, configuration: args.configuration, origin: args.origin, - did: args.did + did: args.did, }) } diff --git a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts index c7ebcebca..0f09b9ad8 100644 --- a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts @@ -3,18 +3,14 @@ import { IDomainLinkageValidation, IVerifyCallbackArgs, IVerifyCredentialResult, - IResourceValidation + IResourceValidation, } from '@sphereon/wellknown-dids-client/dist/types' -import { - IAgentContext, - IPluginMethodMap, - IResolver -} from '@veramo/core' +import { IAgentContext, IPluginMethodMap, IResolver } from '@veramo/core' export interface IWellKnownDidVerifier extends IPluginMethodMap { - registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise, - removeSignatureVerification(args: IRemoveSignatureVerificationArgs, context: IRequiredContext): Promise, - verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise, + registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise + removeSignatureVerification(args: IRemoveSignatureVerificationArgs, context: IRequiredContext): Promise + verifyDomainLinkage(args: IVerifyDomainLinkageArgs, context: IRequiredContext): Promise verifyDidConfigurationResource(args: IVerifyDidConfigurationResourceArgs, context: IRequiredContext): Promise } @@ -40,8 +36,8 @@ export interface IVerifyDomainLinkageArgs { export interface IVerifyDidConfigurationResourceArgs { signatureVerification: ((args: IVerifyCallbackArgs) => Promise) | string - configuration?: IDidConfigurationResource; - origin?: string; + configuration?: IDidConfigurationResource + origin?: string did?: string } From 8c9f6daf4ba192affe277800c5f4180ee06b8d85 Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 10:15:18 +0200 Subject: [PATCH 14/15] VDX-88 var renamed --- packages/wellknown-did-verifier/README.md | 2 +- .../wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts | 4 ++-- .../wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/wellknown-did-verifier/README.md b/packages/wellknown-did-verifier/README.md index ad9081d75..40edbeef6 100644 --- a/packages/wellknown-did-verifier/README.md +++ b/packages/wellknown-did-verifier/README.md @@ -71,7 +71,7 @@ Option available to only verify the service DID. ```typescript agent .verifyDomainLinkage({ - didUrl: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo', + did: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', signatureVerification: 'verified', onlyVerifyServiceDids: false, }) diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index 7388b13d6..68854a4e0 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -58,9 +58,9 @@ export class WellKnownDidVerifier implements IAgentPlugin { ? await this.getSignatureVerification(args.signatureVerification) : (args.signatureVerification as (args: IVerifyCallbackArgs) => Promise) - return context.agent.resolveDid({ didUrl: args.didUrl }).then((didResolutionResult: DIDResolutionResult) => { + return context.agent.resolveDid({ didUrl: args.did }).then((didResolutionResult: DIDResolutionResult) => { if (!didResolutionResult.didDocument) { - return Promise.reject(Error(`Unable to resolve did: ${args.didUrl}`)) + return Promise.reject(Error(`Unable to resolve did: ${args.did}`)) } return new Verifier().verifyDomainLinkage({ diff --git a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts index 0f09b9ad8..371b57c9b 100644 --- a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts @@ -29,7 +29,7 @@ export interface IRemoveSignatureVerificationArgs { } export interface IVerifyDomainLinkageArgs { - didUrl: string + did: string signatureVerification: ((args: IVerifyCallbackArgs) => Promise) | string onlyVerifyServiceDids?: boolean } From 6c29dd4edff85a2d3ad659a55c691437c8ac6bbb Mon Sep 17 00:00:00 2001 From: "A.G.J. Cate" Date: Fri, 12 Aug 2022 10:18:47 +0200 Subject: [PATCH 15/15] VDX-88 var renamed --- packages/wellknown-did-verifier/README.md | 4 ++-- .../__tests__/localAgent.test.ts | 2 +- .../__tests__/restAgent.test.ts | 2 +- .../shared/wellKnownDidVerifierAgentLogic.ts | 22 +++++++++---------- .../src/agent/WellKnownDidVerifier.ts | 8 +++---- .../src/types/IWellKnownDidVerifier.ts | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/wellknown-did-verifier/README.md b/packages/wellknown-did-verifier/README.md index 40edbeef6..ec455f867 100644 --- a/packages/wellknown-did-verifier/README.md +++ b/packages/wellknown-did-verifier/README.md @@ -45,7 +45,7 @@ Registers a callback function to be called within the verification process, to v ```typescript agent .registerSignatureVerification({ - signatureVerificationKey: 'example_key', + callbackName: 'example_key', signatureVerification: () => Promise.resolve({ verified: true }), }) .then(() => console.log('success')) @@ -58,7 +58,7 @@ Removes a registered callback function. ```typescript agent - .removeSignatureVerification({ signatureVerificationKey: 'example_key' }) + .removeSignatureVerification({ callbackName: 'example_key' }) .then(() => console.log('success')) .catch(() => console.log('failed')) ``` diff --git a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts index be34f632a..77411b25b 100644 --- a/packages/wellknown-did-verifier/__tests__/localAgent.test.ts +++ b/packages/wellknown-did-verifier/__tests__/localAgent.test.ts @@ -13,7 +13,7 @@ const setup = async (): Promise => { await localAgent.registerSignatureVerification( { - signatureVerificationKey: 'verified', + callbackName: 'verified', signatureVerification: () => Promise.resolve({ verified: true }), }, null diff --git a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts index aef75163d..fe54fd482 100644 --- a/packages/wellknown-did-verifier/__tests__/restAgent.test.ts +++ b/packages/wellknown-did-verifier/__tests__/restAgent.test.ts @@ -37,7 +37,7 @@ const setup = async (): Promise => { await agent.registerSignatureVerification( { - signatureVerificationKey: 'verified', + callbackName: 'verified', signatureVerification: () => Promise.resolve({ verified: true }), }, null diff --git a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts index c2c0af42f..a57133bbb 100644 --- a/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts +++ b/packages/wellknown-did-verifier/__tests__/shared/wellKnownDidVerifierAgentLogic.ts @@ -35,7 +35,7 @@ export default (testContext: { nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION) const result = await agent.verifyDomainLinkage({ - didUrl: DID, + did: DID, signatureVerification: 'verified', }) @@ -46,7 +46,7 @@ export default (testContext: { nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION) const result = await agent.verifyDomainLinkage({ - didUrl: DID, + did: DID, signatureVerification: 'verified', onlyVerifyServiceDids: true, }) @@ -58,7 +58,7 @@ export default (testContext: { const signatureVerificationKey = 'unknown' await expect( agent.verifyDomainLinkage({ - didUrl: DID, + did: DID, signatureVerification: signatureVerificationKey, }) ).rejects.toThrow(`Signature validation not found for key: ${signatureVerificationKey}`) @@ -121,7 +121,7 @@ export default (testContext: { nock('https://example.com').get('/.well-known/did-configuration.json').times(3).reply(200, DID_CONFIGURATION) const result = await agent.verifyDomainLinkage({ - didUrl: DID, + did: DID, signatureVerification: () => Promise.resolve({ verified: true }), }) @@ -129,28 +129,28 @@ export default (testContext: { }) it('should register signature verification', async () => { - const signatureVerificationKey = 'new' + const callbackName = 'new' await agent.registerSignatureVerification({ - signatureVerificationKey, + callbackName, signatureVerification: () => Promise.resolve({ verified: true }), }) await expect( agent.registerSignatureVerification({ - signatureVerificationKey, + callbackName, signatureVerification: () => Promise.resolve({ verified: true }), }) - ).rejects.toThrow(`Signature validation with key: ${signatureVerificationKey} already present`) + ).rejects.toThrow(`Signature validation with key: ${callbackName} already present`) }) it('should remove signature verification', async () => { - const signatureVerificationKey = 'remove' + const callbackName = 'remove' await agent.registerSignatureVerification({ - signatureVerificationKey, + callbackName, signatureVerification: () => Promise.resolve({ verified: true }), }) - const result = await agent.removeSignatureVerification({ signatureVerificationKey }) + const result = await agent.removeSignatureVerification({ callbackName }) expect(result).toEqual(true) }) diff --git a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts index 68854a4e0..61a35715d 100644 --- a/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/agent/WellKnownDidVerifier.ts @@ -39,16 +39,16 @@ export class WellKnownDidVerifier implements IAgentPlugin { /** {@inheritDoc IWellKnownDidVerifier.registerSignatureVerification} */ private async registerSignatureVerification(args: IRegisterSignatureVerificationArgs, context: IRequiredContext): Promise { - if (this.signatureVerifications[args.signatureVerificationKey] !== undefined) { - return Promise.reject(new Error(`Signature validation with key: ${args.signatureVerificationKey} already present`)) + if (this.signatureVerifications[args.callbackName] !== undefined) { + return Promise.reject(new Error(`Signature validation with key: ${args.callbackName} already present`)) } - this.signatureVerifications[args.signatureVerificationKey] = args.signatureVerification + this.signatureVerifications[args.callbackName] = args.signatureVerification } /** {@inheritDoc IWellKnownDidVerifier.removeSignatureVerification} */ private async removeSignatureVerification(args: IRemoveSignatureVerificationArgs, context: IRequiredContext): Promise { - return delete this.signatureVerifications[args.signatureVerificationKey] + return delete this.signatureVerifications[args.callbackName] } /** {@inheritDoc IWellKnownDidVerifier.verifyDomainLinkage} */ diff --git a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts index 371b57c9b..26bf17d40 100644 --- a/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts +++ b/packages/wellknown-did-verifier/src/types/IWellKnownDidVerifier.ts @@ -20,12 +20,12 @@ export interface IWellKnownDidVerifierOptionsArgs { } export interface IRegisterSignatureVerificationArgs { - signatureVerificationKey: string + callbackName: string signatureVerification: (args: IVerifyCallbackArgs) => Promise } export interface IRemoveSignatureVerificationArgs { - signatureVerificationKey: string + callbackName: string } export interface IVerifyDomainLinkageArgs {