From 70f265954a71c6c77745ef55f2d2bff7fcc695df Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Wed, 2 Nov 2022 15:06:17 -0400 Subject: [PATCH 01/28] First draft of did-pkh method. - Create new pkh-did-provider - Add resolve did-pkh tests - Add create did-pkh identidfier test - Add VC creation/verification using did-pkh identifier Currently not using pkh-did-resolver package (error import). Code momentarily copied to did-provider-pkh resolver. --- .gitignore | 2 + __tests__/localAgent.test.ts | 5 + __tests__/localJsonStoreAgent.test.ts | 5 + __tests__/localMemoryStoreAgent.test.ts | 5 + __tests__/restAgent.test.ts | 5 + __tests__/shared/didManager.ts | 13 ++ __tests__/shared/resolveDid.ts | 17 ++ __tests__/shared/verifiableDataLD.ts | 46 ++++ package.json | 1 + packages/credential-ld/src/action-handler.ts | 1 + .../did-provider-ion/dist/tsdoc-metadata.json | 11 + packages/did-provider-pkh/CHANGELOG.md | 82 +++++++ packages/did-provider-pkh/LICENSE | 201 ++++++++++++++++++ packages/did-provider-pkh/README.md | 4 + packages/did-provider-pkh/api-extractor.json | 18 ++ packages/did-provider-pkh/package.json | 42 ++++ packages/did-provider-pkh/src/index.ts | 8 + .../did-provider-pkh/src/pkh-did-provider.ts | 184 ++++++++++++++++ packages/did-provider-pkh/src/resolver.ts | 93 ++++++++ packages/did-provider-pkh/tsconfig.json | 10 + packages/tsconfig.json | 1 + yarn.lock | 12 ++ 22 files changed, 766 insertions(+) create mode 100644 packages/did-provider-ion/dist/tsdoc-metadata.json create mode 100644 packages/did-provider-pkh/CHANGELOG.md create mode 100644 packages/did-provider-pkh/LICENSE create mode 100644 packages/did-provider-pkh/README.md create mode 100644 packages/did-provider-pkh/api-extractor.json create mode 100644 packages/did-provider-pkh/package.json create mode 100644 packages/did-provider-pkh/src/index.ts create mode 100644 packages/did-provider-pkh/src/pkh-did-provider.ts create mode 100644 packages/did-provider-pkh/src/resolver.ts create mode 100644 packages/did-provider-pkh/tsconfig.json diff --git a/.gitignore b/.gitignore index 367d1cf99a..496fa1d75e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ temp agent.yml data .vscode-upload.json + +local-database*.json \ No newline at end of file diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 77d9638fdb..8a2184c763 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -36,6 +36,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -190,6 +191,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -207,6 +211,7 @@ const setup = async (options?: IAgentOptions): Promise => { }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), new DataStore(dbConnection), diff --git a/__tests__/localJsonStoreAgent.test.ts b/__tests__/localJsonStoreAgent.test.ts index 03d63d398b..f6c979ee3a 100644 --- a/__tests__/localJsonStoreAgent.test.ts +++ b/__tests__/localJsonStoreAgent.test.ts @@ -34,6 +34,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -157,6 +158,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -165,6 +169,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), }), diff --git a/__tests__/localMemoryStoreAgent.test.ts b/__tests__/localMemoryStoreAgent.test.ts index 9a7bdf0754..6d4a451495 100644 --- a/__tests__/localMemoryStoreAgent.test.ts +++ b/__tests__/localMemoryStoreAgent.test.ts @@ -35,6 +35,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -155,6 +156,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -163,6 +167,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), }), diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index 9347ad9278..f7f5849675 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -44,6 +44,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -183,6 +184,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -192,6 +196,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...webDidResolver(), // key: getUniversalResolver(), // resolve using remote resolver... when uniresolver becomes more stable, ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => serverAgent as TAgent).getDidFakeResolver(), }), }), diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts index 1c3da7c4d3..1c5a712cb7 100644 --- a/__tests__/shared/didManager.ts +++ b/__tests__/shared/didManager.ts @@ -33,6 +33,19 @@ export default (testContext: { expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) }) + it('should create pkh identifier using did:pkh provider', async () => { + identifier = await agent.didManagerCreate({ + // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier + provider: 'did:pkh', + options: { network: "mainnet"} + }) + expect(identifier.provider).toEqual('did:pkh') + //expect(identifier.did).toMatch(/^did:pkh:eip155:*$/) + expect(identifier.keys.length).toEqual(1) + expect(identifier.services.length).toEqual(0) + expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) + }) + it('should create identifier using did:ethr:arbitrum:goerli provider', async () => { identifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index d25fa34eff..1af7662982 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -1,5 +1,6 @@ // noinspection ES6PreferShortImport +import { IIdentifier } from '@veramo/core' import { IAgentOptions, IDIDManager, IResolver, TAgent } from '../../packages/core/src' type ConfiguredAgent = TAgent @@ -34,6 +35,22 @@ export default (testContext: { expect(result).toHaveProperty('didResolutionMetadata') }) + it('should resolve did:pkh', async () => { + let identifier: IIdentifier = await agent.didManagerCreate({ + // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier + provider: 'did:pkh', + options: { network: "mainnet"} + }); + + const result = await agent.resolveDid({ didUrl: identifier.did}); + const didDoc = result.didDocument + expect(didDoc?.id).toEqual(identifier.did) + expect(result).toHaveProperty('didDocumentMetadata') + expect(result).toHaveProperty('didResolutionMetadata') + + //let cred = await agent.createVerifiableCredential() + }); + it('should resolve imported fake did', async () => { const did = 'did:fake:myfakedid' await agent.didManagerImport({ diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index 5c457925ed..90916dcc9e 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -26,7 +26,9 @@ export default (testContext: { let agent: ConfiguredAgent let didEthrIdentifier: IIdentifier let didKeyIdentifier: IIdentifier + let pkhIdentifier: IIdentifier let storedCredentialHash: string + let storedPkhCredentialHash: string let challenge: string beforeAll(async () => { @@ -35,6 +37,7 @@ export default (testContext: { challenge = 'TEST_CHALLENGE_STRING' didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' }) didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' }) + pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { network: "mainnet"} }) }) afterAll(testContext.tearDown) @@ -257,6 +260,49 @@ export default (testContext: { expect(result.verified).toEqual(true) }) + it('should create verifiable credential in LD with did:pkh', async () => { + + + + + const verifiableCredential = await agent.createVerifiableCredential({ + credential: { + issuer: { id: pkhIdentifier.did }, + '@context': ['https://www.w3.org/2018/credentials/v1', 'https://veramo.io/contexts/profile/v1'], + type: ['VerifiableCredential', 'Profile'], + issuanceDate: new Date().toISOString(), + credentialSubject: { + id: pkhIdentifier.did, + name: 'Martin, the great', + }, + }, + proofFormat: 'lds', + }) + + // Check credential: + expect(verifiableCredential).toHaveProperty('proof') + expect(verifiableCredential).toHaveProperty('proof.jws') + // expect(verifiableCredential.proof.verificationMethod).toEqual( + // `${didKeyIdentifier.did}#${didKeyIdentifier.did.substring( + // didKeyIdentifier.did.lastIndexOf(':') + 1, + // )}`, + // ) + + expect(verifiableCredential['@context']).toEqual([ + 'https://www.w3.org/2018/credentials/v1', + 'https://veramo.io/contexts/profile/v1', + ]) + expect(verifiableCredential['type']).toEqual(['VerifiableCredential', 'Profile']) + + storedPkhCredentialHash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) + expect(typeof storedPkhCredentialHash).toEqual('string') + + const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ + hash: storedCredentialHash, + }) + expect(verifiableCredential).toEqual(verifiableCredential2) + }) + describe('credential verification policies', () => { it('can verify credential at a particular time', async () => { const issuanceDate = '2019-08-19T09:15:20.000Z' // 1566206120 diff --git a/package.json b/package.json index d27fcb7fff..ff518798b9 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "lerna-changelog": "2.2.0", "oas-resolver": "2.5.6", "openapi-types": "12.0.0", + "pkh-did-resolver": "^1.0.10", "prettier": "2.6.2", "pretty-quick": "3.1.3", "rimraf": "3.0.2", diff --git a/packages/credential-ld/src/action-handler.ts b/packages/credential-ld/src/action-handler.ts index c3f8549ae1..31b7d9dd44 100644 --- a/packages/credential-ld/src/action-handler.ts +++ b/packages/credential-ld/src/action-handler.ts @@ -251,6 +251,7 @@ export class CredentialIssuerLD implements IAgentPlugin { signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type)) } + if (!signingKey) throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`) verificationMethodId = signingKey.meta.verificationMethod.id return { signingKey, verificationMethodId } diff --git a/packages/did-provider-ion/dist/tsdoc-metadata.json b/packages/did-provider-ion/dist/tsdoc-metadata.json new file mode 100644 index 0000000000..1d96152afd --- /dev/null +++ b/packages/did-provider-ion/dist/tsdoc-metadata.json @@ -0,0 +1,11 @@ +// This file is read by tools that parse documentation comments conforming to the TSDoc standard. +// It should be published with your NPM package. It should not be tracked by Git. +{ + "tsdocVersion": "0.12", + "toolPackages": [ + { + "packageName": "@microsoft/api-extractor", + "packageVersion": "7.25.0" + } + ] +} diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md new file mode 100644 index 0000000000..375ed49dfa --- /dev/null +++ b/packages/did-provider-pkh/CHANGELOG.md @@ -0,0 +1,82 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) + + +### Bug Fixes + +* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) +* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) +* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) + + +### Features + +* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) +* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) + + + + + +## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) + + +### Features + +* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) +* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) + + + + + +# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) +* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) +* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) + + +### Features + +* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) +* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) diff --git a/packages/did-provider-pkh/LICENSE b/packages/did-provider-pkh/LICENSE new file mode 100644 index 0000000000..fd815d7f8f --- /dev/null +++ b/packages/did-provider-pkh/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 2019 Consensys AG + + 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/did-provider-pkh/README.md b/packages/did-provider-pkh/README.md new file mode 100644 index 0000000000..34de2dbc99 --- /dev/null +++ b/packages/did-provider-pkh/README.md @@ -0,0 +1,4 @@ +# Veramo did:web provider + +This package contains an implementation of `AbstractIdentifierProvider` for the `did:pkh` method. +This enables creation and control of `did:pkh` entities. diff --git a/packages/did-provider-pkh/api-extractor.json b/packages/did-provider-pkh/api-extractor.json new file mode 100644 index 0000000000..409d7f16c8 --- /dev/null +++ b/packages/did-provider-pkh/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "apiReport": { + "enabled": true, + "reportFolder": "./api", + "reportTempFolder": "./api" + }, + + "docModel": { + "enabled": true, + "apiJsonFilePath": "./api/.api.json" + }, + + "dtsRollup": { + "enabled": false + }, + "mainEntryPointFilePath": "/build/index.d.ts" +} diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json new file mode 100644 index 0000000000..6c05e70c72 --- /dev/null +++ b/packages/did-provider-pkh/package.json @@ -0,0 +1,42 @@ +{ + "name": "@veramo/did-provider-pkh", + "description": "Veramo plugin that can enable creation and control of did:pkh identifiers.", + "version": "4.0.0", + "main": "build/index.js", + "types": "build/index.d.ts", + "scripts": { + "build": "tsc", + "extract-api": "yarn veramo dev extract-api" + }, + "dependencies": { + "@transmute/did-key-ed25519": "^0.3.0-unstable.8", + "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", + "@transmute/did-key-x25519": "^0.3.0-unstable.8", + "@veramo/core": "^4.0.0", + "@veramo/did-manager": "^4.0.0", + "debug": "^4.3.3", + "multibase": "^4.0.6", + "multicodec": "^3.2.1" + }, + "devDependencies": { + "@types/debug": "4.1.7", + "typescript": "4.7.3" + }, + "resolutions": { + "*/**/jsonld": "npm:@digitalcredentials/jsonld@^5.2.1" + }, + "files": [ + "build/**/*", + "src/**/*", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "repository": "git@github.com:uport-project/veramo.git", + "author": "Diego Chagastelles ", + "contributors": [], + "license": "Apache-2.0", + "keywords": [] +} diff --git a/packages/did-provider-pkh/src/index.ts b/packages/did-provider-pkh/src/index.ts new file mode 100644 index 0000000000..c7cbbd8f1f --- /dev/null +++ b/packages/did-provider-pkh/src/index.ts @@ -0,0 +1,8 @@ +/** + * Provides `did:pkh` {@link @veramo/did-provider-pkh#PkhDIDProvider | identifier provider } for the + * {@link @veramo/did-manager#DIDManager} + * + * @packageDocumentation + */ +export { PkhDIDProvider } from './pkh-did-provider' +export { getResolver as getDidPkhResolver } from './resolver' diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts new file mode 100644 index 0000000000..5921c79c2d --- /dev/null +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -0,0 +1,184 @@ +import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core' +import { Provider } from '@ethersproject/abstract-provider' + +import { AbstractIdentifierProvider } from '@veramo/did-manager' +import { computePublicKey } from '@ethersproject/signing-key' +import { BigNumber } from '@ethersproject/bignumber' + +import Debug from 'debug' +const debug = Debug('veramo:did-pkh:identifier-provider') + +type IContext = IAgentContext + +/** + * Options for creating a did:ethr + * @beta + */ + export interface CreateDidPkhEthrOptions { + /** + * This can be a network name or hex encoded chain ID (string) or a chainId number + * + * If this is not specified, `mainnet` is assumed. + */ + network?: string | number + + /** + * This is usually a did prefix, like `did:ethr` or `did:ethr:goerli` and can be used to determine the desired + * network, if no `network` option is specified. + */ + providerName?: string +} + +export interface EthrNetworkConfiguration { + /** + * The name of the network, for example 'mainnet', 'goerli', 'polygon'. + * If this is present, then DIDs anchored on this network will have a human-readable prefix, like + * `did:ethr:goerli:0x...`. See the + * {@link https://github.com/uport-project/ethr-did-registry#contract-deployments | official deployments} for a table + * of reusable names. + * If this parameter is not present, `chainId` MUST be specified. + */ + name?: string + + /** + * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. + * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the + * `did:pkh` spec. + * + * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` + */ + chainId?: string | number + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [index: string]: any +} + +/** + * {@link @veramo/did-manager#DIDManager} identifier provider for `did:pkh` identifiers + * + * @beta This API may change without a BREAKING CHANGE notice. + */ +export class PkhDIDProvider extends AbstractIdentifierProvider { + private defaultKms: string + private networks: EthrNetworkConfiguration[] | undefined + + constructor(options: { + defaultKms: string + networks?: EthrNetworkConfiguration[] + }) + { + super() + this.defaultKms = options.defaultKms + if (options.networks) { + this.networks = options.networks + } else { + + // if (typeof options.network === 'string') { + // if (options.network.startsWith('0x')) { + // singleNetwork.chainId = parseInt(options.network.substring(2), 16) + // } else { + // singleNetwork.name = options.network + // } + // } else if (typeof options.network === 'number') { + // singleNetwork.chainId = options.network + // singleNetwork.name = options.name + // } + // this.networks = [singleNetwork] + // } + + } + + } + + + + async createIdentifier( + { kms, options }: { kms?: string; options?: CreateDidPkhEthrOptions }, + context: IContext, + ): Promise> { + + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) + const compressedPublicKey = computePublicKey(`0x${key.publicKeyHex}`, true) + let networkSpecifier = + options?.network || + (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + + + const network = options?.network; // this.getNetworkFor(networkSpecifier) + if (!network) { + throw new Error( + `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${networkSpecifier}'`, + ) + } + // if (typeof networkSpecifier === 'number') { + // networkSpecifier = + // network.name && network.name.length > 0 + // ? network.name + // : BigNumber.from(options?.network || 1).toHexString() + // } + //const networkString = networkSpecifier && networkSpecifier !== 'mainnet' ? `${networkSpecifier}:` : '' + const identifier: Omit = { + did: 'did:pkh:eip155:' + network + ':' + compressedPublicKey, + controllerKeyId: key.kid, + keys: [key], + services: [], + } + debug('Created', identifier.did) + return identifier + } + async updateIdentifier(args: { did: string; kms?: string | undefined; alias?: string | undefined; options?: any }, context: IAgentContext): Promise { + throw new Error('PkhDIDProvider updateIdentifier not supported yet.') + } + + async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise { + for (const { kid } of identifier.keys) { + await context.agent.keyManagerDelete({ kid }) + } + return true + } + + async addKey( + { identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider addKey not supported') + } + + async addService( + { identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider addService not supported') + } + + async removeKey( + args: { identifier: IIdentifier; kid: string; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider removeKey not supported') + } + + async removeService( + args: { identifier: IIdentifier; id: string; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider removeService not supported') + } + + private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { + let networkNameOrId: string | number = networkSpecifier || 'mainnet' + if ( + typeof networkNameOrId === 'string' && + (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) + ) { + networkNameOrId = BigNumber.from(networkNameOrId).toNumber() + } + let network = this.networks?.find( + (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, + ) + if (!network && !networkSpecifier && this.networks?.length === 1) { + network = this.networks[0] + } + return network + } +} diff --git a/packages/did-provider-pkh/src/resolver.ts b/packages/did-provider-pkh/src/resolver.ts new file mode 100644 index 0000000000..ab0508988e --- /dev/null +++ b/packages/did-provider-pkh/src/resolver.ts @@ -0,0 +1,93 @@ +import { AccountId, ChainIdParams } from 'caip' +import type { + DIDResolutionResult, + DIDResolutionOptions, + ResolverRegistry, + ParsedDID, + Resolver, + Resolvable +} from 'did-resolver' + +const DID_LD_JSON = 'application/did+ld+json' +const DID_JSON = 'application/did+json' +const SECPK1_NAMESPACES = ['eip155', 'bip122'] +const TZ_NAMESPACE = 'tezos' + + +function toDidDoc(did: string, accountId: string): any { + const { namespace } = AccountId.parse(accountId).chainId as ChainIdParams + const vmId = did + '#blockchainAccountId' + const doc = { + '@context': [ + 'https://www.w3.org/ns/did/v1', + { + blockchainAccountId: 'https://w3id.org/security#blockchainAccountId', + EcdsaSecp256k1RecoveryMethod2020: + 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#EcdsaSecp256k1RecoveryMethod2020', + Ed25519VerificationKey2018: 'https://w3id.org/security#Ed25519VerificationKey2018', + }, + ], + id: did, + verificationMethod: [ + { + id: vmId, + type: 'EcdsaSecp256k1RecoveryMethod2020', + controller: did, + blockchainAccountId: accountId, + }, + ], + authentication: [vmId], + assertionMethod: [vmId], + } + if (SECPK1_NAMESPACES.includes(namespace)) { + // nothing to do here + } else if (namespace === TZ_NAMESPACE) { + (doc['@context'][1] as any).TezosMethod2021 = 'https://w3id.org/security#TezosMethod2021' + const tzId = did + '#TezosMethod2021' + doc.verificationMethod.push({ + id: tzId, + type: 'TezosMethod2021', + controller: did, + blockchainAccountId: accountId, + }) + doc.authentication.push(tzId) + doc.assertionMethod.push(tzId) + } else { + throw new Error(`chain namespace not supported ${namespace}`) + } + return doc +} + +export function getResolver(): ResolverRegistry { + return { + pkh: async ( + did: string, + parsed: ParsedDID, + r: Resolvable, + options: DIDResolutionOptions + ): Promise => { + const contentType = options.accept || DID_JSON + const response: DIDResolutionResult = { + didResolutionMetadata: { contentType }, + didDocument: null, + didDocumentMetadata: {}, + } + try { + const doc = toDidDoc(did, parsed.id) + if (contentType === DID_LD_JSON) { + response.didDocument = doc + } else if (contentType === DID_JSON) { + delete doc['@context'] + response.didDocument = doc + } else { + delete response.didResolutionMetadata.contentType + response.didResolutionMetadata.error = 'representationNotSupported' + } + } catch (e) { + response.didResolutionMetadata.error = 'invalidDid' + response.didResolutionMetadata.message = e.toString() + } + return response + }, + } +} \ No newline at end of file diff --git a/packages/did-provider-pkh/tsconfig.json b/packages/did-provider-pkh/tsconfig.json new file mode 100644 index 0000000000..21035981a7 --- /dev/null +++ b/packages/did-provider-pkh/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.settings.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build", + "declarationDir": "build", + "skipLibCheck": true + }, + "references": [{ "path": "../core" }, { "path": "../did-manager" }] +} diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 9ca3043803..7453d01a9c 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -14,6 +14,7 @@ { "path": "did-manager" }, { "path": "did-provider-ethr" }, { "path": "did-provider-ion" }, + { "path": "did-provider-pkh" }, { "path": "did-provider-key" }, { "path": "did-provider-web" }, { "path": "did-resolver" }, diff --git a/yarn.lock b/yarn.lock index 96a1d311a9..2d6964926d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6747,6 +6747,11 @@ cacache@^16.0.0, cacache@^16.0.6, cacache@^16.1.0: tar "^6.1.11" unique-filename "^1.1.1" +caip@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/caip/-/caip-1.1.0.tgz#0ccd5bf1bff822459389ccec0a8555712a30c374" + integrity sha512-yOO3Fu4ygyKYAdznuoaqschMKIZzcdgyMpBNtrIfrUhnOeaOWG+dh0c13wcOS6B/46IGGbncoyzJlio79jU7rw== + call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -14575,6 +14580,13 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" +pkh-did-resolver@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/pkh-did-resolver/-/pkh-did-resolver-1.0.10.tgz#f0144aaaf88af4d573ac23b050d77d8edaa879e8" + integrity sha512-GYfZxFQXFfuVUcztZJuf73tjr3L9nRvzvnoAtKIGREHkpEzj801WQ41OJ7PmsTyIDakaHfXyI3WyX33DUsenTw== + dependencies: + caip "~1.1.0" + postcss-attribute-case-insensitive@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.1.tgz#86d323c77ab8896ed90500071c2c8329fba64fda" From e389e2f61da30c92ff682fcd7be508981e2fa715 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:51:09 -0500 Subject: [PATCH 02/28] -Fix did:pkh identifier (use address intead of public key hex) -Use chainId only and not network name -clean up params -fix tests --- __tests__/shared/didManager.ts | 2 +- __tests__/shared/resolveDid.ts | 2 +- __tests__/shared/verifiableDataLD.ts | 18 +-- .../did-provider-pkh/src/pkh-did-provider.ts | 141 ++++++++--------- yarn.lock | 145 +++++++++++++++++- 5 files changed, 207 insertions(+), 101 deletions(-) diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts index 1c5a712cb7..4229c19a5e 100644 --- a/__tests__/shared/didManager.ts +++ b/__tests__/shared/didManager.ts @@ -37,7 +37,7 @@ export default (testContext: { identifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier provider: 'did:pkh', - options: { network: "mainnet"} + options: { chainId: "1"} }) expect(identifier.provider).toEqual('did:pkh') //expect(identifier.did).toMatch(/^did:pkh:eip155:*$/) diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index 1af7662982..514e0c56f2 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -39,7 +39,7 @@ export default (testContext: { let identifier: IIdentifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier provider: 'did:pkh', - options: { network: "mainnet"} + options: { chainId: "1"} }); const result = await agent.resolveDid({ didUrl: identifier.did}); diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index 90916dcc9e..dbc0ca06de 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -37,7 +37,7 @@ export default (testContext: { challenge = 'TEST_CHALLENGE_STRING' didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' }) didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' }) - pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { network: "mainnet"} }) + pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { chainId: "1"} }) }) afterAll(testContext.tearDown) @@ -261,10 +261,6 @@ export default (testContext: { }) it('should create verifiable credential in LD with did:pkh', async () => { - - - - const verifiableCredential = await agent.createVerifiableCredential({ credential: { issuer: { id: pkhIdentifier.did }, @@ -282,23 +278,13 @@ export default (testContext: { // Check credential: expect(verifiableCredential).toHaveProperty('proof') expect(verifiableCredential).toHaveProperty('proof.jws') - // expect(verifiableCredential.proof.verificationMethod).toEqual( - // `${didKeyIdentifier.did}#${didKeyIdentifier.did.substring( - // didKeyIdentifier.did.lastIndexOf(':') + 1, - // )}`, - // ) - - expect(verifiableCredential['@context']).toEqual([ - 'https://www.w3.org/2018/credentials/v1', - 'https://veramo.io/contexts/profile/v1', - ]) expect(verifiableCredential['type']).toEqual(['VerifiableCredential', 'Profile']) storedPkhCredentialHash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) expect(typeof storedPkhCredentialHash).toEqual('string') const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ - hash: storedCredentialHash, + hash: storedPkhCredentialHash, }) expect(verifiableCredential).toEqual(verifiableCredential2) }) diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index 5921c79c2d..7e630eab87 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -1,5 +1,6 @@ import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core' import { Provider } from '@ethersproject/abstract-provider' +import { computeAddress } from '@ethersproject/transactions' import { AbstractIdentifierProvider } from '@veramo/did-manager' import { computePublicKey } from '@ethersproject/signing-key' @@ -16,42 +17,40 @@ type IContext = IAgentContext */ export interface CreateDidPkhEthrOptions { /** - * This can be a network name or hex encoded chain ID (string) or a chainId number + * This can be hex encoded chain ID (string) or a chainId number * - * If this is not specified, `mainnet` is assumed. + * If this is not specified, `1` is assumed. */ - network?: string | number + chainId?: string | number + - /** - * This is usually a did prefix, like `did:ethr` or `did:ethr:goerli` and can be used to determine the desired - * network, if no `network` option is specified. - */ - providerName?: string } -export interface EthrNetworkConfiguration { - /** - * The name of the network, for example 'mainnet', 'goerli', 'polygon'. - * If this is present, then DIDs anchored on this network will have a human-readable prefix, like - * `did:ethr:goerli:0x...`. See the - * {@link https://github.com/uport-project/ethr-did-registry#contract-deployments | official deployments} for a table - * of reusable names. - * If this parameter is not present, `chainId` MUST be specified. - */ - name?: string +// export interface EthrNetworkConfiguration { +// /** +// * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. +// * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the +// * `did:pkh` spec. +// * +// * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` +// */ +// chainId?: string | number + +// // eslint-disable-next-line @typescript-eslint/no-explicit-any +// [index: string]: any +// } + + /** - * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. - * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the - * `did:pkh` spec. - * - * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` - */ - chainId?: string | number + * Helper method that can computes the ethereumAddress corresponding to a Secp256k1 public key. + * @param hexPublicKey A hex encoded public key, optionally prefixed with `0x` + */ + export function toEthereumAddress(hexPublicKey: string): string { + const publicKey = hexPublicKey.startsWith('0x') ? hexPublicKey : '0x' + hexPublicKey + return computeAddress(publicKey) + } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [index: string]: any -} /** * {@link @veramo/did-manager#DIDManager} identifier provider for `did:pkh` identifiers @@ -60,34 +59,18 @@ export interface EthrNetworkConfiguration { */ export class PkhDIDProvider extends AbstractIdentifierProvider { private defaultKms: string - private networks: EthrNetworkConfiguration[] | undefined - + //private networks: EthrNetworkConfiguration[] | undefined + constructor(options: { defaultKms: string - networks?: EthrNetworkConfiguration[] + //networks?: EthrNetworkConfiguration[] }) { super() this.defaultKms = options.defaultKms - if (options.networks) { - this.networks = options.networks - } else { - - // if (typeof options.network === 'string') { - // if (options.network.startsWith('0x')) { - // singleNetwork.chainId = parseInt(options.network.substring(2), 16) - // } else { - // singleNetwork.name = options.network - // } - // } else if (typeof options.network === 'number') { - // singleNetwork.chainId = options.network - // singleNetwork.name = options.name - // } - // this.networks = [singleNetwork] + // if (options.networks) { + // this.networks = options.networks // } - - } - } @@ -96,29 +79,23 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { { kms, options }: { kms?: string; options?: CreateDidPkhEthrOptions }, context: IContext, ): Promise> { - + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) - const compressedPublicKey = computePublicKey(`0x${key.publicKeyHex}`, true) - let networkSpecifier = - options?.network || - (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + const publicAddress = toEthereumAddress(key.publicKeyHex); + // let networkSpecifier = + // options?.network || + // (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + - - const network = options?.network; // this.getNetworkFor(networkSpecifier) + const network = options?.chainId; // this.getNetworkFor(networkSpecifier) if (!network) { throw new Error( - `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${networkSpecifier}'`, + `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${network}'`, ) } - // if (typeof networkSpecifier === 'number') { - // networkSpecifier = - // network.name && network.name.length > 0 - // ? network.name - // : BigNumber.from(options?.network || 1).toHexString() - // } - //const networkString = networkSpecifier && networkSpecifier !== 'mainnet' ? `${networkSpecifier}:` : '' + const identifier: Omit = { - did: 'did:pkh:eip155:' + network + ':' + compressedPublicKey, + did: 'did:pkh:eip155:' + network + ':' + publicAddress, controllerKeyId: key.kid, keys: [key], services: [], @@ -165,20 +142,22 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { throw Error('PkhDIDProvider removeService not supported') } - private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { - let networkNameOrId: string | number = networkSpecifier || 'mainnet' - if ( - typeof networkNameOrId === 'string' && - (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) - ) { - networkNameOrId = BigNumber.from(networkNameOrId).toNumber() - } - let network = this.networks?.find( - (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, - ) - if (!network && !networkSpecifier && this.networks?.length === 1) { - network = this.networks[0] - } - return network - } + // private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { + // let networkNameOrId: string | number = networkSpecifier || 'mainnet' + // if ( + // typeof networkNameOrId === 'string' && + // (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) + // ) { + // networkNameOrId = BigNumber.from(networkNameOrId).toNumber() + // } + // let network = this.networks?.find( + // (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, + // ) + // if (!network && !networkSpecifier && this.networks?.length === 1) { + // network = this.networks[0] + // } + // return network + // } + + } diff --git a/yarn.lock b/yarn.lock index 2d6964926d..2d0a79201e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5869,6 +5869,11 @@ array-differ@^3.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -6371,7 +6376,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.1: +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0, bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -6778,6 +6783,15 @@ camelcase-css@^2.0.1: resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== +camelcase-keys@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" + integrity sha512-Ej37YKYbFUI8QiYlvj9YHb6/Z60dZyPJW0Cs8sFilMbd2lP0bw3ylAq9yJkK4lcTA2dID5fG8LjmJYbO7kWb7Q== + dependencies: + camelcase "^4.1.0" + map-obj "^2.0.0" + quick-lru "^1.0.0" + camelcase-keys@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" @@ -6787,6 +6801,11 @@ camelcase-keys@^6.2.2: map-obj "^4.0.0" quick-lru "^4.0.1" +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + integrity sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw== + camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -7801,6 +7820,13 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2" integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA== +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== + dependencies: + array-find-index "^1.0.1" + cwd@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/cwd/-/cwd-0.10.0.tgz#172400694057c22a13b0cf16162c7e4b7a7fe567" @@ -7899,6 +7925,14 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +decamelize-keys@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" + integrity sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg== + dependencies: + decamelize "^1.1.0" + map-obj "^1.0.0" + decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" @@ -8854,6 +8888,14 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= +ethereum-checksum-address@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/ethereum-checksum-address/-/ethereum-checksum-address-0.0.2.tgz#46fcb2d962dacd1ed49d7b464408ec26fd183209" + integrity sha512-GAb7mPvGgcfi1j+Bsnwm9af9Z7dLUKp+5cFm88+kMrKACfh9gLatGLVVK5pSGEG2pOGfrmqCRcuh3RtMjIg8GQ== + dependencies: + keccak256 "^1.0.0" + meow "^5.0.0" + ethereum-cryptography@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz#74f2ac0f0f5fe79f012c889b3b8446a9a6264e6d" @@ -8864,6 +8906,16 @@ ethereum-cryptography@^1.1.2: "@scure/bip32" "1.1.0" "@scure/bip39" "1.1.0" +ethereum-public-key-to-address@^0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/ethereum-public-key-to-address/-/ethereum-public-key-to-address-0.0.5.tgz#0d8f7ffbbe0fcd379864afbc46790a273029f691" + integrity sha512-j7k9dP49JuK50PtygiTfqjrZLsk0Hc3Vh5jjqCH8pl4mPfwcQwA9Ds+ie7BXr2JdpFDB3cYR8H/1Rwp0jU5Nxg== + dependencies: + ethereum-checksum-address "0.0.2" + keccak "^3.0.1" + meow "^5.0.0" + secp256k1 "^4.0.2" + ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" @@ -10423,6 +10475,11 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= +indent-string@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" + integrity sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ== + indent-string@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" @@ -12212,6 +12269,15 @@ just-diff@^5.0.1: resolved "https://registry.yarnpkg.com/just-diff/-/just-diff-5.0.1.tgz#db8fe1cfeea1156f2374bfb289826dca28e7e390" integrity sha512-X00TokkRIDotUIf3EV4xUm6ELc/IkqhS/vPSHdWnsM5y0HoNMfEqrazizI7g78lpHvnRSRt/PFfKtRqJCOGIuQ== +keccak256@^1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58" + integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw== + dependencies: + bn.js "^5.2.0" + buffer "^6.0.3" + keccak "^3.0.2" + keccak@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" @@ -12220,6 +12286,15 @@ keccak@3.0.1: node-addon-api "^2.0.0" node-gyp-build "^4.2.0" +keccak@^3.0.1, keccak@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" + integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + kind-of@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-2.0.1.tgz#018ec7a4ce7e3a86cb9141be519d24c8faa981b5" @@ -12679,6 +12754,14 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + integrity sha512-RPNliZOFkqFumDhvYqOaNY4Uz9oJM2K9tC6JWsJJsNdhuONW4LQHRBpb0qf4pJApVffI5N39SwzWZJuEhfd7eQ== + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + lower-case@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" @@ -12860,6 +12943,11 @@ map-obj@^1.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= +map-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" + integrity sha512-TzQSV2DiMYgoF5RycneKVUzIa9bQsj/B3tTgsE3dOGqlzHnGIDaC7XBE7grnA+8kZPnfqSGFe95VHc2oc0VFUQ== + map-obj@^4.0.0: version "4.2.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7" @@ -12913,6 +13001,21 @@ memfs@^3.1.2, memfs@^3.4.3: dependencies: fs-monkey "1.0.3" +meow@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" + integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== + dependencies: + camelcase-keys "^4.0.0" + decamelize-keys "^1.0.0" + loud-rejection "^1.0.0" + minimist-options "^3.0.1" + normalize-package-data "^2.3.4" + read-pkg-up "^3.0.0" + redent "^2.0.0" + trim-newlines "^2.0.0" + yargs-parser "^10.0.0" + meow@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/meow/-/meow-7.1.1.tgz#7c01595e3d337fcb0ec4e8eed1666ea95903d306" @@ -13095,6 +13198,14 @@ minimist-options@4.1.0: is-plain-obj "^1.1.0" kind-of "^6.0.3" +minimist-options@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" + integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -13489,7 +13600,7 @@ nopt@^5.0.0: dependencies: abbrev "1" -normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -15466,6 +15577,11 @@ queue-microtask@^1.2.2, queue-microtask@^1.2.3: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +quick-lru@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" + integrity sha512-tRS7sTgyxMXtLum8L65daJnHUhfDUgboRdcWW2bR9vBfrj2+O5HSMbQOJfJJjIVSPFqbBCF37FpwWXGitDc5tA== + quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -15825,6 +15941,14 @@ recursive-readdir@^2.2.2: dependencies: minimatch "3.0.4" +redent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" + integrity sha512-XNwrTx77JQCEMXTeb8movBKuK75MgH0RZkujNuDKCezemx/voapl9i2gCSi8WWm8+ox5ycJi1gxF22fR7c0Ciw== + dependencies: + indent-string "^3.0.0" + strip-indent "^2.0.0" + redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -17074,6 +17198,11 @@ strip-hex-prefix@1.0.0: dependencies: is-hex-prefixed "1.0.0" +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + integrity sha512-RsSNPLpq6YUL7QYy44RnPVTn/lcVZtb48Uof3X5JLbF4zD/Gs7ZFDv2HWol+leoQN2mT86LAzSshGfkTlSOpsA== + strip-indent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" @@ -17529,6 +17658,11 @@ treeverse@^2.0.0: resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" integrity sha512-N5gJCkLu1aXccpOTtqV6ddSEi6ZmGkh3hjmbu1IjcavJK4qyOVQmi0myQKM7z5jVGmD68SJoliaVrMmVObhj6A== +trim-newlines@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" + integrity sha512-MTBWv3jhVjTU7XR3IQHllbiJs8sc75a80OEhB6or/q7pLTWgQ0bMGQXXYQSrSuXe6WiKWDZ5txXY5P59a/coVA== + trim-newlines@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" @@ -18778,6 +18912,13 @@ yargs-parser@20.2.4: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== +yargs-parser@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" + integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== + dependencies: + camelcase "^4.1.0" + yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" From 333d4d0b1f98df683907c30b13055157bd48a491 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:58:43 -0500 Subject: [PATCH 03/28] Changelog.md file removed --- packages/did-provider-pkh/CHANGELOG.md | 82 -------------------------- 1 file changed, 82 deletions(-) delete mode 100644 packages/did-provider-pkh/CHANGELOG.md diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md deleted file mode 100644 index 375ed49dfa..0000000000 --- a/packages/did-provider-pkh/CHANGELOG.md +++ /dev/null @@ -1,82 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) - - -### Bug Fixes - -* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) -* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) -* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) - - -### Features - -* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) -* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) - - - - - -## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) - - -### Features - -* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) -* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) - - - - - -# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) -* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) -* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) - - -### Features - -* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) -* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) From f84f1bd291313fa2914a51355b7eddc3381d7ee9 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Wed, 2 Nov 2022 15:06:17 -0400 Subject: [PATCH 04/28] First draft of did-pkh method. - Create new pkh-did-provider - Add resolve did-pkh tests - Add create did-pkh identidfier test - Add VC creation/verification using did-pkh identifier Currently not using pkh-did-resolver package (error import). Code momentarily copied to did-provider-pkh resolver. --- .gitignore | 2 + __tests__/localAgent.test.ts | 5 + __tests__/localJsonStoreAgent.test.ts | 5 + __tests__/localMemoryStoreAgent.test.ts | 5 + __tests__/restAgent.test.ts | 5 + __tests__/shared/didManager.ts | 13 ++ __tests__/shared/resolveDid.ts | 17 ++ __tests__/shared/verifiableDataLD.ts | 46 ++++ packages/credential-ld/src/action-handler.ts | 1 + .../did-provider-ion/dist/tsdoc-metadata.json | 11 + packages/did-provider-pkh/CHANGELOG.md | 82 +++++++ packages/did-provider-pkh/LICENSE | 201 ++++++++++++++++++ packages/did-provider-pkh/README.md | 4 + packages/did-provider-pkh/api-extractor.json | 18 ++ packages/did-provider-pkh/package.json | 42 ++++ packages/did-provider-pkh/src/index.ts | 8 + .../did-provider-pkh/src/pkh-did-provider.ts | 184 ++++++++++++++++ packages/did-provider-pkh/src/resolver.ts | 93 ++++++++ packages/did-provider-pkh/tsconfig.json | 10 + packages/tsconfig.json | 1 + yarn.lock | 12 ++ 21 files changed, 765 insertions(+) create mode 100644 packages/did-provider-ion/dist/tsdoc-metadata.json create mode 100644 packages/did-provider-pkh/CHANGELOG.md create mode 100644 packages/did-provider-pkh/LICENSE create mode 100644 packages/did-provider-pkh/README.md create mode 100644 packages/did-provider-pkh/api-extractor.json create mode 100644 packages/did-provider-pkh/package.json create mode 100644 packages/did-provider-pkh/src/index.ts create mode 100644 packages/did-provider-pkh/src/pkh-did-provider.ts create mode 100644 packages/did-provider-pkh/src/resolver.ts create mode 100644 packages/did-provider-pkh/tsconfig.json diff --git a/.gitignore b/.gitignore index 367d1cf99a..496fa1d75e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ temp agent.yml data .vscode-upload.json + +local-database*.json \ No newline at end of file diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 39503df2ec..5c02e81d9b 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -36,6 +36,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -193,6 +194,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -210,6 +214,7 @@ const setup = async (options?: IAgentOptions): Promise => { }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), new DataStore(dbConnection), diff --git a/__tests__/localJsonStoreAgent.test.ts b/__tests__/localJsonStoreAgent.test.ts index 03d63d398b..f6c979ee3a 100644 --- a/__tests__/localJsonStoreAgent.test.ts +++ b/__tests__/localJsonStoreAgent.test.ts @@ -34,6 +34,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -157,6 +158,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -165,6 +169,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), }), diff --git a/__tests__/localMemoryStoreAgent.test.ts b/__tests__/localMemoryStoreAgent.test.ts index 9a7bdf0754..6d4a451495 100644 --- a/__tests__/localMemoryStoreAgent.test.ts +++ b/__tests__/localMemoryStoreAgent.test.ts @@ -35,6 +35,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -155,6 +156,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -163,6 +167,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), }), diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index 3ea1f5b450..f7a6012423 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -44,6 +44,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -184,6 +185,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -193,6 +197,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...webDidResolver(), // key: getUniversalResolver(), // resolve using remote resolver... when uniresolver becomes more stable, ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => serverAgent as TAgent).getDidFakeResolver(), }), }), diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts index 7398ab1b62..91ba3b0b43 100644 --- a/__tests__/shared/didManager.ts +++ b/__tests__/shared/didManager.ts @@ -33,6 +33,19 @@ export default (testContext: { expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) }) + it('should create pkh identifier using did:pkh provider', async () => { + identifier = await agent.didManagerCreate({ + // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier + provider: 'did:pkh', + options: { network: "mainnet"} + }) + expect(identifier.provider).toEqual('did:pkh') + //expect(identifier.did).toMatch(/^did:pkh:eip155:*$/) + expect(identifier.keys.length).toEqual(1) + expect(identifier.services.length).toEqual(0) + expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) + }) + it('should create identifier using did:ethr:arbitrum:goerli provider', async () => { identifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index d25fa34eff..1af7662982 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -1,5 +1,6 @@ // noinspection ES6PreferShortImport +import { IIdentifier } from '@veramo/core' import { IAgentOptions, IDIDManager, IResolver, TAgent } from '../../packages/core/src' type ConfiguredAgent = TAgent @@ -34,6 +35,22 @@ export default (testContext: { expect(result).toHaveProperty('didResolutionMetadata') }) + it('should resolve did:pkh', async () => { + let identifier: IIdentifier = await agent.didManagerCreate({ + // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier + provider: 'did:pkh', + options: { network: "mainnet"} + }); + + const result = await agent.resolveDid({ didUrl: identifier.did}); + const didDoc = result.didDocument + expect(didDoc?.id).toEqual(identifier.did) + expect(result).toHaveProperty('didDocumentMetadata') + expect(result).toHaveProperty('didResolutionMetadata') + + //let cred = await agent.createVerifiableCredential() + }); + it('should resolve imported fake did', async () => { const did = 'did:fake:myfakedid' await agent.didManagerImport({ diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index 5c457925ed..90916dcc9e 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -26,7 +26,9 @@ export default (testContext: { let agent: ConfiguredAgent let didEthrIdentifier: IIdentifier let didKeyIdentifier: IIdentifier + let pkhIdentifier: IIdentifier let storedCredentialHash: string + let storedPkhCredentialHash: string let challenge: string beforeAll(async () => { @@ -35,6 +37,7 @@ export default (testContext: { challenge = 'TEST_CHALLENGE_STRING' didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' }) didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' }) + pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { network: "mainnet"} }) }) afterAll(testContext.tearDown) @@ -257,6 +260,49 @@ export default (testContext: { expect(result.verified).toEqual(true) }) + it('should create verifiable credential in LD with did:pkh', async () => { + + + + + const verifiableCredential = await agent.createVerifiableCredential({ + credential: { + issuer: { id: pkhIdentifier.did }, + '@context': ['https://www.w3.org/2018/credentials/v1', 'https://veramo.io/contexts/profile/v1'], + type: ['VerifiableCredential', 'Profile'], + issuanceDate: new Date().toISOString(), + credentialSubject: { + id: pkhIdentifier.did, + name: 'Martin, the great', + }, + }, + proofFormat: 'lds', + }) + + // Check credential: + expect(verifiableCredential).toHaveProperty('proof') + expect(verifiableCredential).toHaveProperty('proof.jws') + // expect(verifiableCredential.proof.verificationMethod).toEqual( + // `${didKeyIdentifier.did}#${didKeyIdentifier.did.substring( + // didKeyIdentifier.did.lastIndexOf(':') + 1, + // )}`, + // ) + + expect(verifiableCredential['@context']).toEqual([ + 'https://www.w3.org/2018/credentials/v1', + 'https://veramo.io/contexts/profile/v1', + ]) + expect(verifiableCredential['type']).toEqual(['VerifiableCredential', 'Profile']) + + storedPkhCredentialHash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) + expect(typeof storedPkhCredentialHash).toEqual('string') + + const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ + hash: storedCredentialHash, + }) + expect(verifiableCredential).toEqual(verifiableCredential2) + }) + describe('credential verification policies', () => { it('can verify credential at a particular time', async () => { const issuanceDate = '2019-08-19T09:15:20.000Z' // 1566206120 diff --git a/packages/credential-ld/src/action-handler.ts b/packages/credential-ld/src/action-handler.ts index c3f8549ae1..31b7d9dd44 100644 --- a/packages/credential-ld/src/action-handler.ts +++ b/packages/credential-ld/src/action-handler.ts @@ -251,6 +251,7 @@ export class CredentialIssuerLD implements IAgentPlugin { signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type)) } + if (!signingKey) throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`) verificationMethodId = signingKey.meta.verificationMethod.id return { signingKey, verificationMethodId } diff --git a/packages/did-provider-ion/dist/tsdoc-metadata.json b/packages/did-provider-ion/dist/tsdoc-metadata.json new file mode 100644 index 0000000000..1d96152afd --- /dev/null +++ b/packages/did-provider-ion/dist/tsdoc-metadata.json @@ -0,0 +1,11 @@ +// This file is read by tools that parse documentation comments conforming to the TSDoc standard. +// It should be published with your NPM package. It should not be tracked by Git. +{ + "tsdocVersion": "0.12", + "toolPackages": [ + { + "packageName": "@microsoft/api-extractor", + "packageVersion": "7.25.0" + } + ] +} diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md new file mode 100644 index 0000000000..375ed49dfa --- /dev/null +++ b/packages/did-provider-pkh/CHANGELOG.md @@ -0,0 +1,82 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) + + +### Bug Fixes + +* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) +* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) +* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) + + +### Features + +* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) +* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) + + + + + +## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) + + +### Features + +* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) +* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) + + + + + +# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) +* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) +* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) + + +### Features + +* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) +* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) diff --git a/packages/did-provider-pkh/LICENSE b/packages/did-provider-pkh/LICENSE new file mode 100644 index 0000000000..fd815d7f8f --- /dev/null +++ b/packages/did-provider-pkh/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 2019 Consensys AG + + 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/did-provider-pkh/README.md b/packages/did-provider-pkh/README.md new file mode 100644 index 0000000000..34de2dbc99 --- /dev/null +++ b/packages/did-provider-pkh/README.md @@ -0,0 +1,4 @@ +# Veramo did:web provider + +This package contains an implementation of `AbstractIdentifierProvider` for the `did:pkh` method. +This enables creation and control of `did:pkh` entities. diff --git a/packages/did-provider-pkh/api-extractor.json b/packages/did-provider-pkh/api-extractor.json new file mode 100644 index 0000000000..409d7f16c8 --- /dev/null +++ b/packages/did-provider-pkh/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "apiReport": { + "enabled": true, + "reportFolder": "./api", + "reportTempFolder": "./api" + }, + + "docModel": { + "enabled": true, + "apiJsonFilePath": "./api/.api.json" + }, + + "dtsRollup": { + "enabled": false + }, + "mainEntryPointFilePath": "/build/index.d.ts" +} diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json new file mode 100644 index 0000000000..6c05e70c72 --- /dev/null +++ b/packages/did-provider-pkh/package.json @@ -0,0 +1,42 @@ +{ + "name": "@veramo/did-provider-pkh", + "description": "Veramo plugin that can enable creation and control of did:pkh identifiers.", + "version": "4.0.0", + "main": "build/index.js", + "types": "build/index.d.ts", + "scripts": { + "build": "tsc", + "extract-api": "yarn veramo dev extract-api" + }, + "dependencies": { + "@transmute/did-key-ed25519": "^0.3.0-unstable.8", + "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", + "@transmute/did-key-x25519": "^0.3.0-unstable.8", + "@veramo/core": "^4.0.0", + "@veramo/did-manager": "^4.0.0", + "debug": "^4.3.3", + "multibase": "^4.0.6", + "multicodec": "^3.2.1" + }, + "devDependencies": { + "@types/debug": "4.1.7", + "typescript": "4.7.3" + }, + "resolutions": { + "*/**/jsonld": "npm:@digitalcredentials/jsonld@^5.2.1" + }, + "files": [ + "build/**/*", + "src/**/*", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "repository": "git@github.com:uport-project/veramo.git", + "author": "Diego Chagastelles ", + "contributors": [], + "license": "Apache-2.0", + "keywords": [] +} diff --git a/packages/did-provider-pkh/src/index.ts b/packages/did-provider-pkh/src/index.ts new file mode 100644 index 0000000000..c7cbbd8f1f --- /dev/null +++ b/packages/did-provider-pkh/src/index.ts @@ -0,0 +1,8 @@ +/** + * Provides `did:pkh` {@link @veramo/did-provider-pkh#PkhDIDProvider | identifier provider } for the + * {@link @veramo/did-manager#DIDManager} + * + * @packageDocumentation + */ +export { PkhDIDProvider } from './pkh-did-provider' +export { getResolver as getDidPkhResolver } from './resolver' diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts new file mode 100644 index 0000000000..5921c79c2d --- /dev/null +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -0,0 +1,184 @@ +import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core' +import { Provider } from '@ethersproject/abstract-provider' + +import { AbstractIdentifierProvider } from '@veramo/did-manager' +import { computePublicKey } from '@ethersproject/signing-key' +import { BigNumber } from '@ethersproject/bignumber' + +import Debug from 'debug' +const debug = Debug('veramo:did-pkh:identifier-provider') + +type IContext = IAgentContext + +/** + * Options for creating a did:ethr + * @beta + */ + export interface CreateDidPkhEthrOptions { + /** + * This can be a network name or hex encoded chain ID (string) or a chainId number + * + * If this is not specified, `mainnet` is assumed. + */ + network?: string | number + + /** + * This is usually a did prefix, like `did:ethr` or `did:ethr:goerli` and can be used to determine the desired + * network, if no `network` option is specified. + */ + providerName?: string +} + +export interface EthrNetworkConfiguration { + /** + * The name of the network, for example 'mainnet', 'goerli', 'polygon'. + * If this is present, then DIDs anchored on this network will have a human-readable prefix, like + * `did:ethr:goerli:0x...`. See the + * {@link https://github.com/uport-project/ethr-did-registry#contract-deployments | official deployments} for a table + * of reusable names. + * If this parameter is not present, `chainId` MUST be specified. + */ + name?: string + + /** + * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. + * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the + * `did:pkh` spec. + * + * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` + */ + chainId?: string | number + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [index: string]: any +} + +/** + * {@link @veramo/did-manager#DIDManager} identifier provider for `did:pkh` identifiers + * + * @beta This API may change without a BREAKING CHANGE notice. + */ +export class PkhDIDProvider extends AbstractIdentifierProvider { + private defaultKms: string + private networks: EthrNetworkConfiguration[] | undefined + + constructor(options: { + defaultKms: string + networks?: EthrNetworkConfiguration[] + }) + { + super() + this.defaultKms = options.defaultKms + if (options.networks) { + this.networks = options.networks + } else { + + // if (typeof options.network === 'string') { + // if (options.network.startsWith('0x')) { + // singleNetwork.chainId = parseInt(options.network.substring(2), 16) + // } else { + // singleNetwork.name = options.network + // } + // } else if (typeof options.network === 'number') { + // singleNetwork.chainId = options.network + // singleNetwork.name = options.name + // } + // this.networks = [singleNetwork] + // } + + } + + } + + + + async createIdentifier( + { kms, options }: { kms?: string; options?: CreateDidPkhEthrOptions }, + context: IContext, + ): Promise> { + + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) + const compressedPublicKey = computePublicKey(`0x${key.publicKeyHex}`, true) + let networkSpecifier = + options?.network || + (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + + + const network = options?.network; // this.getNetworkFor(networkSpecifier) + if (!network) { + throw new Error( + `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${networkSpecifier}'`, + ) + } + // if (typeof networkSpecifier === 'number') { + // networkSpecifier = + // network.name && network.name.length > 0 + // ? network.name + // : BigNumber.from(options?.network || 1).toHexString() + // } + //const networkString = networkSpecifier && networkSpecifier !== 'mainnet' ? `${networkSpecifier}:` : '' + const identifier: Omit = { + did: 'did:pkh:eip155:' + network + ':' + compressedPublicKey, + controllerKeyId: key.kid, + keys: [key], + services: [], + } + debug('Created', identifier.did) + return identifier + } + async updateIdentifier(args: { did: string; kms?: string | undefined; alias?: string | undefined; options?: any }, context: IAgentContext): Promise { + throw new Error('PkhDIDProvider updateIdentifier not supported yet.') + } + + async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise { + for (const { kid } of identifier.keys) { + await context.agent.keyManagerDelete({ kid }) + } + return true + } + + async addKey( + { identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider addKey not supported') + } + + async addService( + { identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider addService not supported') + } + + async removeKey( + args: { identifier: IIdentifier; kid: string; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider removeKey not supported') + } + + async removeService( + args: { identifier: IIdentifier; id: string; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider removeService not supported') + } + + private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { + let networkNameOrId: string | number = networkSpecifier || 'mainnet' + if ( + typeof networkNameOrId === 'string' && + (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) + ) { + networkNameOrId = BigNumber.from(networkNameOrId).toNumber() + } + let network = this.networks?.find( + (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, + ) + if (!network && !networkSpecifier && this.networks?.length === 1) { + network = this.networks[0] + } + return network + } +} diff --git a/packages/did-provider-pkh/src/resolver.ts b/packages/did-provider-pkh/src/resolver.ts new file mode 100644 index 0000000000..ab0508988e --- /dev/null +++ b/packages/did-provider-pkh/src/resolver.ts @@ -0,0 +1,93 @@ +import { AccountId, ChainIdParams } from 'caip' +import type { + DIDResolutionResult, + DIDResolutionOptions, + ResolverRegistry, + ParsedDID, + Resolver, + Resolvable +} from 'did-resolver' + +const DID_LD_JSON = 'application/did+ld+json' +const DID_JSON = 'application/did+json' +const SECPK1_NAMESPACES = ['eip155', 'bip122'] +const TZ_NAMESPACE = 'tezos' + + +function toDidDoc(did: string, accountId: string): any { + const { namespace } = AccountId.parse(accountId).chainId as ChainIdParams + const vmId = did + '#blockchainAccountId' + const doc = { + '@context': [ + 'https://www.w3.org/ns/did/v1', + { + blockchainAccountId: 'https://w3id.org/security#blockchainAccountId', + EcdsaSecp256k1RecoveryMethod2020: + 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#EcdsaSecp256k1RecoveryMethod2020', + Ed25519VerificationKey2018: 'https://w3id.org/security#Ed25519VerificationKey2018', + }, + ], + id: did, + verificationMethod: [ + { + id: vmId, + type: 'EcdsaSecp256k1RecoveryMethod2020', + controller: did, + blockchainAccountId: accountId, + }, + ], + authentication: [vmId], + assertionMethod: [vmId], + } + if (SECPK1_NAMESPACES.includes(namespace)) { + // nothing to do here + } else if (namespace === TZ_NAMESPACE) { + (doc['@context'][1] as any).TezosMethod2021 = 'https://w3id.org/security#TezosMethod2021' + const tzId = did + '#TezosMethod2021' + doc.verificationMethod.push({ + id: tzId, + type: 'TezosMethod2021', + controller: did, + blockchainAccountId: accountId, + }) + doc.authentication.push(tzId) + doc.assertionMethod.push(tzId) + } else { + throw new Error(`chain namespace not supported ${namespace}`) + } + return doc +} + +export function getResolver(): ResolverRegistry { + return { + pkh: async ( + did: string, + parsed: ParsedDID, + r: Resolvable, + options: DIDResolutionOptions + ): Promise => { + const contentType = options.accept || DID_JSON + const response: DIDResolutionResult = { + didResolutionMetadata: { contentType }, + didDocument: null, + didDocumentMetadata: {}, + } + try { + const doc = toDidDoc(did, parsed.id) + if (contentType === DID_LD_JSON) { + response.didDocument = doc + } else if (contentType === DID_JSON) { + delete doc['@context'] + response.didDocument = doc + } else { + delete response.didResolutionMetadata.contentType + response.didResolutionMetadata.error = 'representationNotSupported' + } + } catch (e) { + response.didResolutionMetadata.error = 'invalidDid' + response.didResolutionMetadata.message = e.toString() + } + return response + }, + } +} \ No newline at end of file diff --git a/packages/did-provider-pkh/tsconfig.json b/packages/did-provider-pkh/tsconfig.json new file mode 100644 index 0000000000..21035981a7 --- /dev/null +++ b/packages/did-provider-pkh/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.settings.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build", + "declarationDir": "build", + "skipLibCheck": true + }, + "references": [{ "path": "../core" }, { "path": "../did-manager" }] +} diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 9ca3043803..7453d01a9c 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -14,6 +14,7 @@ { "path": "did-manager" }, { "path": "did-provider-ethr" }, { "path": "did-provider-ion" }, + { "path": "did-provider-pkh" }, { "path": "did-provider-key" }, { "path": "did-provider-web" }, { "path": "did-resolver" }, diff --git a/yarn.lock b/yarn.lock index 83b1209e95..ca468b578c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6985,6 +6985,11 @@ cacache@^16.0.0, cacache@^16.0.6, cacache@^16.1.0: tar "^6.1.11" unique-filename "^1.1.1" +caip@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/caip/-/caip-1.1.0.tgz#0ccd5bf1bff822459389ccec0a8555712a30c374" + integrity sha512-yOO3Fu4ygyKYAdznuoaqschMKIZzcdgyMpBNtrIfrUhnOeaOWG+dh0c13wcOS6B/46IGGbncoyzJlio79jU7rw== + call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -14901,6 +14906,13 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" +pkh-did-resolver@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/pkh-did-resolver/-/pkh-did-resolver-1.0.10.tgz#f0144aaaf88af4d573ac23b050d77d8edaa879e8" + integrity sha512-GYfZxFQXFfuVUcztZJuf73tjr3L9nRvzvnoAtKIGREHkpEzj801WQ41OJ7PmsTyIDakaHfXyI3WyX33DUsenTw== + dependencies: + caip "~1.1.0" + postcss-attribute-case-insensitive@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.1.tgz#86d323c77ab8896ed90500071c2c8329fba64fda" From 5e80be2d46c9baa6aebd440f4e8e5e1a26edaf67 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:51:09 -0500 Subject: [PATCH 05/28] -Fix did:pkh identifier (use address intead of public key hex) -Use chainId only and not network name -clean up params -fix tests --- __tests__/shared/didManager.ts | 2 +- __tests__/shared/resolveDid.ts | 2 +- __tests__/shared/verifiableDataLD.ts | 18 +-- .../did-provider-pkh/src/pkh-did-provider.ts | 141 ++++++++---------- yarn.lock | 136 ++++++++++++++++- 5 files changed, 198 insertions(+), 101 deletions(-) diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts index 91ba3b0b43..e1b2acb1a7 100644 --- a/__tests__/shared/didManager.ts +++ b/__tests__/shared/didManager.ts @@ -37,7 +37,7 @@ export default (testContext: { identifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier provider: 'did:pkh', - options: { network: "mainnet"} + options: { chainId: "1"} }) expect(identifier.provider).toEqual('did:pkh') //expect(identifier.did).toMatch(/^did:pkh:eip155:*$/) diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index 1af7662982..514e0c56f2 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -39,7 +39,7 @@ export default (testContext: { let identifier: IIdentifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier provider: 'did:pkh', - options: { network: "mainnet"} + options: { chainId: "1"} }); const result = await agent.resolveDid({ didUrl: identifier.did}); diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index 90916dcc9e..dbc0ca06de 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -37,7 +37,7 @@ export default (testContext: { challenge = 'TEST_CHALLENGE_STRING' didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' }) didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' }) - pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { network: "mainnet"} }) + pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { chainId: "1"} }) }) afterAll(testContext.tearDown) @@ -261,10 +261,6 @@ export default (testContext: { }) it('should create verifiable credential in LD with did:pkh', async () => { - - - - const verifiableCredential = await agent.createVerifiableCredential({ credential: { issuer: { id: pkhIdentifier.did }, @@ -282,23 +278,13 @@ export default (testContext: { // Check credential: expect(verifiableCredential).toHaveProperty('proof') expect(verifiableCredential).toHaveProperty('proof.jws') - // expect(verifiableCredential.proof.verificationMethod).toEqual( - // `${didKeyIdentifier.did}#${didKeyIdentifier.did.substring( - // didKeyIdentifier.did.lastIndexOf(':') + 1, - // )}`, - // ) - - expect(verifiableCredential['@context']).toEqual([ - 'https://www.w3.org/2018/credentials/v1', - 'https://veramo.io/contexts/profile/v1', - ]) expect(verifiableCredential['type']).toEqual(['VerifiableCredential', 'Profile']) storedPkhCredentialHash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) expect(typeof storedPkhCredentialHash).toEqual('string') const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ - hash: storedCredentialHash, + hash: storedPkhCredentialHash, }) expect(verifiableCredential).toEqual(verifiableCredential2) }) diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index 5921c79c2d..7e630eab87 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -1,5 +1,6 @@ import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core' import { Provider } from '@ethersproject/abstract-provider' +import { computeAddress } from '@ethersproject/transactions' import { AbstractIdentifierProvider } from '@veramo/did-manager' import { computePublicKey } from '@ethersproject/signing-key' @@ -16,42 +17,40 @@ type IContext = IAgentContext */ export interface CreateDidPkhEthrOptions { /** - * This can be a network name or hex encoded chain ID (string) or a chainId number + * This can be hex encoded chain ID (string) or a chainId number * - * If this is not specified, `mainnet` is assumed. + * If this is not specified, `1` is assumed. */ - network?: string | number + chainId?: string | number + - /** - * This is usually a did prefix, like `did:ethr` or `did:ethr:goerli` and can be used to determine the desired - * network, if no `network` option is specified. - */ - providerName?: string } -export interface EthrNetworkConfiguration { - /** - * The name of the network, for example 'mainnet', 'goerli', 'polygon'. - * If this is present, then DIDs anchored on this network will have a human-readable prefix, like - * `did:ethr:goerli:0x...`. See the - * {@link https://github.com/uport-project/ethr-did-registry#contract-deployments | official deployments} for a table - * of reusable names. - * If this parameter is not present, `chainId` MUST be specified. - */ - name?: string +// export interface EthrNetworkConfiguration { +// /** +// * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. +// * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the +// * `did:pkh` spec. +// * +// * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` +// */ +// chainId?: string | number + +// // eslint-disable-next-line @typescript-eslint/no-explicit-any +// [index: string]: any +// } + + /** - * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. - * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the - * `did:pkh` spec. - * - * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` - */ - chainId?: string | number + * Helper method that can computes the ethereumAddress corresponding to a Secp256k1 public key. + * @param hexPublicKey A hex encoded public key, optionally prefixed with `0x` + */ + export function toEthereumAddress(hexPublicKey: string): string { + const publicKey = hexPublicKey.startsWith('0x') ? hexPublicKey : '0x' + hexPublicKey + return computeAddress(publicKey) + } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [index: string]: any -} /** * {@link @veramo/did-manager#DIDManager} identifier provider for `did:pkh` identifiers @@ -60,34 +59,18 @@ export interface EthrNetworkConfiguration { */ export class PkhDIDProvider extends AbstractIdentifierProvider { private defaultKms: string - private networks: EthrNetworkConfiguration[] | undefined - + //private networks: EthrNetworkConfiguration[] | undefined + constructor(options: { defaultKms: string - networks?: EthrNetworkConfiguration[] + //networks?: EthrNetworkConfiguration[] }) { super() this.defaultKms = options.defaultKms - if (options.networks) { - this.networks = options.networks - } else { - - // if (typeof options.network === 'string') { - // if (options.network.startsWith('0x')) { - // singleNetwork.chainId = parseInt(options.network.substring(2), 16) - // } else { - // singleNetwork.name = options.network - // } - // } else if (typeof options.network === 'number') { - // singleNetwork.chainId = options.network - // singleNetwork.name = options.name - // } - // this.networks = [singleNetwork] + // if (options.networks) { + // this.networks = options.networks // } - - } - } @@ -96,29 +79,23 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { { kms, options }: { kms?: string; options?: CreateDidPkhEthrOptions }, context: IContext, ): Promise> { - + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) - const compressedPublicKey = computePublicKey(`0x${key.publicKeyHex}`, true) - let networkSpecifier = - options?.network || - (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + const publicAddress = toEthereumAddress(key.publicKeyHex); + // let networkSpecifier = + // options?.network || + // (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + - - const network = options?.network; // this.getNetworkFor(networkSpecifier) + const network = options?.chainId; // this.getNetworkFor(networkSpecifier) if (!network) { throw new Error( - `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${networkSpecifier}'`, + `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${network}'`, ) } - // if (typeof networkSpecifier === 'number') { - // networkSpecifier = - // network.name && network.name.length > 0 - // ? network.name - // : BigNumber.from(options?.network || 1).toHexString() - // } - //const networkString = networkSpecifier && networkSpecifier !== 'mainnet' ? `${networkSpecifier}:` : '' + const identifier: Omit = { - did: 'did:pkh:eip155:' + network + ':' + compressedPublicKey, + did: 'did:pkh:eip155:' + network + ':' + publicAddress, controllerKeyId: key.kid, keys: [key], services: [], @@ -165,20 +142,22 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { throw Error('PkhDIDProvider removeService not supported') } - private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { - let networkNameOrId: string | number = networkSpecifier || 'mainnet' - if ( - typeof networkNameOrId === 'string' && - (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) - ) { - networkNameOrId = BigNumber.from(networkNameOrId).toNumber() - } - let network = this.networks?.find( - (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, - ) - if (!network && !networkSpecifier && this.networks?.length === 1) { - network = this.networks[0] - } - return network - } + // private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { + // let networkNameOrId: string | number = networkSpecifier || 'mainnet' + // if ( + // typeof networkNameOrId === 'string' && + // (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) + // ) { + // networkNameOrId = BigNumber.from(networkNameOrId).toNumber() + // } + // let network = this.networks?.find( + // (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, + // ) + // if (!network && !networkSpecifier && this.networks?.length === 1) { + // network = this.networks[0] + // } + // return network + // } + + } diff --git a/yarn.lock b/yarn.lock index ca468b578c..2da348f5e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6093,6 +6093,11 @@ array-differ@^3.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -6612,7 +6617,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.1: +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0, bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -7016,6 +7021,15 @@ camelcase-css@^2.0.1: resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== +camelcase-keys@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" + integrity sha512-Ej37YKYbFUI8QiYlvj9YHb6/Z60dZyPJW0Cs8sFilMbd2lP0bw3ylAq9yJkK4lcTA2dID5fG8LjmJYbO7kWb7Q== + dependencies: + camelcase "^4.1.0" + map-obj "^2.0.0" + quick-lru "^1.0.0" + camelcase-keys@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" @@ -7025,6 +7039,11 @@ camelcase-keys@^6.2.2: map-obj "^4.0.0" quick-lru "^4.0.1" +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + integrity sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw== + camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -8039,6 +8058,13 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2" integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA== +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== + dependencies: + array-find-index "^1.0.1" + cwd@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/cwd/-/cwd-0.10.0.tgz#172400694057c22a13b0cf16162c7e4b7a7fe567" @@ -8137,6 +8163,14 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +decamelize-keys@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" + integrity sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg== + dependencies: + decamelize "^1.1.0" + map-obj "^1.0.0" + decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" @@ -9150,6 +9184,14 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= +ethereum-checksum-address@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/ethereum-checksum-address/-/ethereum-checksum-address-0.0.2.tgz#46fcb2d962dacd1ed49d7b464408ec26fd183209" + integrity sha512-GAb7mPvGgcfi1j+Bsnwm9af9Z7dLUKp+5cFm88+kMrKACfh9gLatGLVVK5pSGEG2pOGfrmqCRcuh3RtMjIg8GQ== + dependencies: + keccak256 "^1.0.0" + meow "^5.0.0" + ethereum-cryptography@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz#74f2ac0f0f5fe79f012c889b3b8446a9a6264e6d" @@ -9160,6 +9202,16 @@ ethereum-cryptography@^1.1.2: "@scure/bip32" "1.1.0" "@scure/bip39" "1.1.0" +ethereum-public-key-to-address@^0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/ethereum-public-key-to-address/-/ethereum-public-key-to-address-0.0.5.tgz#0d8f7ffbbe0fcd379864afbc46790a273029f691" + integrity sha512-j7k9dP49JuK50PtygiTfqjrZLsk0Hc3Vh5jjqCH8pl4mPfwcQwA9Ds+ie7BXr2JdpFDB3cYR8H/1Rwp0jU5Nxg== + dependencies: + ethereum-checksum-address "0.0.2" + keccak "^3.0.1" + meow "^5.0.0" + secp256k1 "^4.0.2" + ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" @@ -10709,6 +10761,11 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= +indent-string@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" + integrity sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ== + indent-string@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" @@ -12538,6 +12595,15 @@ keccak@3.0.2: node-gyp-build "^4.2.0" readable-stream "^3.6.0" +keccak@^3.0.1, keccak@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" + integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + kind-of@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-2.0.1.tgz#018ec7a4ce7e3a86cb9141be519d24c8faa981b5" @@ -12997,6 +13063,14 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + integrity sha512-RPNliZOFkqFumDhvYqOaNY4Uz9oJM2K9tC6JWsJJsNdhuONW4LQHRBpb0qf4pJApVffI5N39SwzWZJuEhfd7eQ== + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + lower-case@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" @@ -13178,6 +13252,11 @@ map-obj@^1.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= +map-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" + integrity sha512-TzQSV2DiMYgoF5RycneKVUzIa9bQsj/B3tTgsE3dOGqlzHnGIDaC7XBE7grnA+8kZPnfqSGFe95VHc2oc0VFUQ== + map-obj@^4.0.0: version "4.2.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7" @@ -13231,6 +13310,21 @@ memfs@^3.1.2, memfs@^3.4.3: dependencies: fs-monkey "1.0.3" +meow@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" + integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== + dependencies: + camelcase-keys "^4.0.0" + decamelize-keys "^1.0.0" + loud-rejection "^1.0.0" + minimist-options "^3.0.1" + normalize-package-data "^2.3.4" + read-pkg-up "^3.0.0" + redent "^2.0.0" + trim-newlines "^2.0.0" + yargs-parser "^10.0.0" + meow@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/meow/-/meow-7.1.1.tgz#7c01595e3d337fcb0ec4e8eed1666ea95903d306" @@ -13413,6 +13507,14 @@ minimist-options@4.1.0: is-plain-obj "^1.1.0" kind-of "^6.0.3" +minimist-options@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" + integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -13807,7 +13909,7 @@ nopt@^5.0.0: dependencies: abbrev "1" -normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -15804,6 +15906,11 @@ queue-microtask@^1.2.2, queue-microtask@^1.2.3: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +quick-lru@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" + integrity sha512-tRS7sTgyxMXtLum8L65daJnHUhfDUgboRdcWW2bR9vBfrj2+O5HSMbQOJfJJjIVSPFqbBCF37FpwWXGitDc5tA== + quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -16153,6 +16260,14 @@ recursive-readdir@^2.2.2: dependencies: minimatch "3.0.4" +redent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" + integrity sha512-XNwrTx77JQCEMXTeb8movBKuK75MgH0RZkujNuDKCezemx/voapl9i2gCSi8WWm8+ox5ycJi1gxF22fR7c0Ciw== + dependencies: + indent-string "^3.0.0" + strip-indent "^2.0.0" + redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -17393,6 +17508,11 @@ strip-hex-prefix@1.0.0: dependencies: is-hex-prefixed "1.0.0" +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + integrity sha512-RsSNPLpq6YUL7QYy44RnPVTn/lcVZtb48Uof3X5JLbF4zD/Gs7ZFDv2HWol+leoQN2mT86LAzSshGfkTlSOpsA== + strip-indent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" @@ -17848,6 +17968,11 @@ treeverse@^2.0.0: resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" integrity sha512-N5gJCkLu1aXccpOTtqV6ddSEi6ZmGkh3hjmbu1IjcavJK4qyOVQmi0myQKM7z5jVGmD68SJoliaVrMmVObhj6A== +trim-newlines@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" + integrity sha512-MTBWv3jhVjTU7XR3IQHllbiJs8sc75a80OEhB6or/q7pLTWgQ0bMGQXXYQSrSuXe6WiKWDZ5txXY5P59a/coVA== + trim-newlines@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" @@ -19115,6 +19240,13 @@ yargs-parser@20.2.4: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== +yargs-parser@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" + integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== + dependencies: + camelcase "^4.1.0" + yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" From 8139780439b07630b8856982b1e9176807ba655b Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:58:43 -0500 Subject: [PATCH 06/28] Changelog.md file removed --- packages/did-provider-pkh/CHANGELOG.md | 82 -------------------------- 1 file changed, 82 deletions(-) delete mode 100644 packages/did-provider-pkh/CHANGELOG.md diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md deleted file mode 100644 index 375ed49dfa..0000000000 --- a/packages/did-provider-pkh/CHANGELOG.md +++ /dev/null @@ -1,82 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) - - -### Bug Fixes - -* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) -* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) -* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) - - -### Features - -* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) -* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) - - - - - -## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) - - -### Features - -* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) -* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) - - - - - -# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) -* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) -* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) - - -### Features - -* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) -* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) From 50af2cb22b9f9ea8215a9fcb9323e394122a321f Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:32:45 -0500 Subject: [PATCH 07/28] Update packages/did-provider-pkh/package.json Co-authored-by: Mircea Nistor --- packages/did-provider-pkh/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index 6c05e70c72..71bd70b72f 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -9,9 +9,9 @@ "extract-api": "yarn veramo dev extract-api" }, "dependencies": { - "@transmute/did-key-ed25519": "^0.3.0-unstable.8", - "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", - "@transmute/did-key-x25519": "^0.3.0-unstable.8", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", "@veramo/core": "^4.0.0", "@veramo/did-manager": "^4.0.0", "debug": "^4.3.3", From 6bd24b581a7d68d0e48f9fe56071b9d81f59a8ae Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:33:11 -0500 Subject: [PATCH 08/28] Update packages/did-provider-pkh/package.json Co-authored-by: Mircea Nistor --- packages/did-provider-pkh/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index 71bd70b72f..d084d3680e 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -22,9 +22,6 @@ "@types/debug": "4.1.7", "typescript": "4.7.3" }, - "resolutions": { - "*/**/jsonld": "npm:@digitalcredentials/jsonld@^5.2.1" - }, "files": [ "build/**/*", "src/**/*", From b75aed7aa9682348b51f7e7f5196f4ffc21cece5 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:34:20 -0500 Subject: [PATCH 09/28] Update packages/did-provider-pkh/package.json Co-authored-by: Mircea Nistor --- packages/did-provider-pkh/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index d084d3680e..096e4664dd 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -14,9 +14,7 @@ "@ethersproject/transactions": "^5.7.0", "@veramo/core": "^4.0.0", "@veramo/did-manager": "^4.0.0", - "debug": "^4.3.3", - "multibase": "^4.0.6", - "multicodec": "^3.2.1" + "debug": "^4.3.3" }, "devDependencies": { "@types/debug": "4.1.7", From 53a270bdc0ee1b39891583ad24555adfebdbada7 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:35:39 -0500 Subject: [PATCH 10/28] cleanup unused code --- .../did-provider-pkh/src/pkh-did-provider.ts | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index 7e630eab87..fb32870bf1 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -26,30 +26,14 @@ type IContext = IAgentContext } -// export interface EthrNetworkConfiguration { -// /** -// * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. -// * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the -// * `did:pkh` spec. -// * -// * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` -// */ -// chainId?: string | number - -// // eslint-disable-next-line @typescript-eslint/no-explicit-any -// [index: string]: any -// } - - - - /** + /** * Helper method that can computes the ethereumAddress corresponding to a Secp256k1 public key. * @param hexPublicKey A hex encoded public key, optionally prefixed with `0x` */ - export function toEthereumAddress(hexPublicKey: string): string { + export function toEthereumAddress(hexPublicKey: string): string { const publicKey = hexPublicKey.startsWith('0x') ? hexPublicKey : '0x' + hexPublicKey return computeAddress(publicKey) - } + } /** From 8c597a1cb8bcfe13169b2b31efdc0360776e118f Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 15:29:13 -0500 Subject: [PATCH 11/28] Cleanup did:pkh provider --- package.json | 3 +- .../did-provider-pkh/src/pkh-did-provider.ts | 13 +- yarn.lock | 178 +----------------- 3 files changed, 12 insertions(+), 182 deletions(-) diff --git a/package.json b/package.json index 90fa097e21..b34e21f811 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "ts-jest": "28.0.4", "ts-json-schema-generator": "1.0.0", "ts-node": "10.8.1", - "typescript": "4.8.4" + "typescript": "4.8.4", + "caip": "^1.1.0" }, "repository": { "type": "git", diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index fb32870bf1..6deda53451 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -22,8 +22,6 @@ type IContext = IAgentContext * If this is not specified, `1` is assumed. */ chainId?: string | number - - } /** @@ -43,18 +41,13 @@ type IContext = IAgentContext */ export class PkhDIDProvider extends AbstractIdentifierProvider { private defaultKms: string - //private networks: EthrNetworkConfiguration[] | undefined constructor(options: { defaultKms: string - //networks?: EthrNetworkConfiguration[] }) { super() this.defaultKms = options.defaultKms - // if (options.networks) { - // this.networks = options.networks - // } } @@ -66,12 +59,8 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) const publicAddress = toEthereumAddress(key.publicKeyHex); - // let networkSpecifier = - // options?.network || - // (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) - - const network = options?.chainId; // this.getNetworkFor(networkSpecifier) + const network = options?.chainId; if (!network) { throw new Error( `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${network}'`, diff --git a/yarn.lock b/yarn.lock index d5ad6e3586..6679130d11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4700,18 +4700,6 @@ jose "^4.3.8" web-streams-polyfill "^3.0.3" -"@transmute/jose-ld@^0.7.0-unstable.67": - version "0.7.0-unstable.67" - resolved "https://registry.yarnpkg.com/@transmute/jose-ld/-/jose-ld-0.7.0-unstable.67.tgz#c202775f23fc2ab1aeae1e5ee0e71983f541f6ad" - integrity sha512-9xGZpdNEzhBeeZfNnM1y83rN6SQ6tuXgx+WrQF9GoPtyxwcvZlqEqn9DBEiMzleaAC5kmXBbVPXbXv6QxkPyDg== - dependencies: - "@peculiar/webcrypto" "^1.1.6" - "@stablelib/aes-kw" "^1.0.0" - "@stablelib/xchacha20poly1305" "^1.0.0" - base64url "^3.0.1" - jose "^4.3.8" - web-streams-polyfill "^3.0.3" - "@transmute/json-web-signature@^0.7.0-unstable.67": version "0.7.0-unstable.67" resolved "https://registry.yarnpkg.com/@transmute/json-web-signature/-/json-web-signature-0.7.0-unstable.67.tgz#79387d7f2b88e27e13dcf55015a68893ee434431" @@ -4772,11 +4760,6 @@ resolved "https://registry.yarnpkg.com/@transmute/security-context/-/security-context-0.7.0-unstable.67.tgz#51a6a7b34e49f37b512fc61404529579e7806895" integrity sha512-BRfFAcXTBHbBDbnXWofAZSV7bktDMiv0UuJjUiEqt+PkSWFx74UtIYrLxw4HfYPoGWJ6m6I5XBiRZ3L5LVX0XQ== -"@transmute/security-context@^0.7.0-unstable.67": - version "0.7.0-unstable.67" - resolved "https://registry.yarnpkg.com/@transmute/security-context/-/security-context-0.7.0-unstable.67.tgz#51a6a7b34e49f37b512fc61404529579e7806895" - integrity sha512-BRfFAcXTBHbBDbnXWofAZSV7bktDMiv0UuJjUiEqt+PkSWFx74UtIYrLxw4HfYPoGWJ6m6I5XBiRZ3L5LVX0XQ== - "@transmute/web-crypto-key-pair@^0.7.0-unstable.67": version "0.7.0-unstable.67" resolved "https://registry.yarnpkg.com/@transmute/web-crypto-key-pair/-/web-crypto-key-pair-0.7.0-unstable.67.tgz#e3313c2664b2baf097f1c3ba9827ee05259609cb" @@ -6093,11 +6076,6 @@ array-differ@^3.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== -array-find-index@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" - integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== - array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -6617,7 +6595,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0, bn.js@^5.2.1: +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -6990,7 +6968,7 @@ cacache@^16.0.0, cacache@^16.0.6, cacache@^16.1.0: tar "^6.1.11" unique-filename "^1.1.1" -caip@~1.1.0: +caip@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/caip/-/caip-1.1.0.tgz#0ccd5bf1bff822459389ccec0a8555712a30c374" integrity sha512-yOO3Fu4ygyKYAdznuoaqschMKIZzcdgyMpBNtrIfrUhnOeaOWG+dh0c13wcOS6B/46IGGbncoyzJlio79jU7rw== @@ -7021,15 +6999,6 @@ camelcase-css@^2.0.1: resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== -camelcase-keys@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" - integrity sha512-Ej37YKYbFUI8QiYlvj9YHb6/Z60dZyPJW0Cs8sFilMbd2lP0bw3ylAq9yJkK4lcTA2dID5fG8LjmJYbO7kWb7Q== - dependencies: - camelcase "^4.1.0" - map-obj "^2.0.0" - quick-lru "^1.0.0" - camelcase-keys@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" @@ -7039,11 +7008,6 @@ camelcase-keys@^6.2.2: map-obj "^4.0.0" quick-lru "^4.0.1" -camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw== - camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -8058,13 +8022,6 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2" integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA== -currently-unhandled@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" - integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== - dependencies: - array-find-index "^1.0.1" - cwd@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/cwd/-/cwd-0.10.0.tgz#172400694057c22a13b0cf16162c7e4b7a7fe567" @@ -8163,14 +8120,6 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= -decamelize-keys@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" - integrity sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg== - dependencies: - decamelize "^1.1.0" - map-obj "^1.0.0" - decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" @@ -9184,14 +9133,6 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= -ethereum-checksum-address@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/ethereum-checksum-address/-/ethereum-checksum-address-0.0.2.tgz#46fcb2d962dacd1ed49d7b464408ec26fd183209" - integrity sha512-GAb7mPvGgcfi1j+Bsnwm9af9Z7dLUKp+5cFm88+kMrKACfh9gLatGLVVK5pSGEG2pOGfrmqCRcuh3RtMjIg8GQ== - dependencies: - keccak256 "^1.0.0" - meow "^5.0.0" - ethereum-cryptography@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz#74f2ac0f0f5fe79f012c889b3b8446a9a6264e6d" @@ -9202,16 +9143,6 @@ ethereum-cryptography@^1.1.2: "@scure/bip32" "1.1.0" "@scure/bip39" "1.1.0" -ethereum-public-key-to-address@^0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/ethereum-public-key-to-address/-/ethereum-public-key-to-address-0.0.5.tgz#0d8f7ffbbe0fcd379864afbc46790a273029f691" - integrity sha512-j7k9dP49JuK50PtygiTfqjrZLsk0Hc3Vh5jjqCH8pl4mPfwcQwA9Ds+ie7BXr2JdpFDB3cYR8H/1Rwp0jU5Nxg== - dependencies: - ethereum-checksum-address "0.0.2" - keccak "^3.0.1" - meow "^5.0.0" - secp256k1 "^4.0.2" - ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" @@ -10761,11 +10692,6 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= -indent-string@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" - integrity sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ== - indent-string@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" @@ -12586,25 +12512,7 @@ just-diff@^5.0.1: resolved "https://registry.yarnpkg.com/just-diff/-/just-diff-5.0.1.tgz#db8fe1cfeea1156f2374bfb289826dca28e7e390" integrity sha512-X00TokkRIDotUIf3EV4xUm6ELc/IkqhS/vPSHdWnsM5y0HoNMfEqrazizI7g78lpHvnRSRt/PFfKtRqJCOGIuQ== -keccak256@^1.0.0: - version "1.0.6" - resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58" - integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw== - dependencies: - bn.js "^5.2.0" - buffer "^6.0.3" - keccak "^3.0.2" - -keccak@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" - integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== - dependencies: - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - readable-stream "^3.6.0" - -keccak@^3.0.1, keccak@^3.0.2: +keccak@3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== @@ -13072,14 +12980,6 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" -loud-rejection@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" - integrity sha512-RPNliZOFkqFumDhvYqOaNY4Uz9oJM2K9tC6JWsJJsNdhuONW4LQHRBpb0qf4pJApVffI5N39SwzWZJuEhfd7eQ== - dependencies: - currently-unhandled "^0.4.1" - signal-exit "^3.0.0" - lower-case@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" @@ -13261,11 +13161,6 @@ map-obj@^1.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= -map-obj@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" - integrity sha512-TzQSV2DiMYgoF5RycneKVUzIa9bQsj/B3tTgsE3dOGqlzHnGIDaC7XBE7grnA+8kZPnfqSGFe95VHc2oc0VFUQ== - map-obj@^4.0.0: version "4.2.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7" @@ -13319,21 +13214,6 @@ memfs@^3.1.2, memfs@^3.4.3: dependencies: fs-monkey "1.0.3" -meow@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" - integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== - dependencies: - camelcase-keys "^4.0.0" - decamelize-keys "^1.0.0" - loud-rejection "^1.0.0" - minimist-options "^3.0.1" - normalize-package-data "^2.3.4" - read-pkg-up "^3.0.0" - redent "^2.0.0" - trim-newlines "^2.0.0" - yargs-parser "^10.0.0" - meow@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/meow/-/meow-7.1.1.tgz#7c01595e3d337fcb0ec4e8eed1666ea95903d306" @@ -13516,14 +13396,6 @@ minimist-options@4.1.0: is-plain-obj "^1.1.0" kind-of "^6.0.3" -minimist-options@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" - integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== - dependencies: - arrify "^1.0.1" - is-plain-obj "^1.1.0" - minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -13918,7 +13790,7 @@ nopt@^5.0.0: dependencies: abbrev "1" -normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: +normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -15017,13 +14889,6 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" -pkh-did-resolver@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/pkh-did-resolver/-/pkh-did-resolver-1.0.10.tgz#f0144aaaf88af4d573ac23b050d77d8edaa879e8" - integrity sha512-GYfZxFQXFfuVUcztZJuf73tjr3L9nRvzvnoAtKIGREHkpEzj801WQ41OJ7PmsTyIDakaHfXyI3WyX33DUsenTw== - dependencies: - caip "~1.1.0" - postcss-attribute-case-insensitive@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.1.tgz#86d323c77ab8896ed90500071c2c8329fba64fda" @@ -15915,11 +15780,6 @@ queue-microtask@^1.2.2, queue-microtask@^1.2.3: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== -quick-lru@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" - integrity sha512-tRS7sTgyxMXtLum8L65daJnHUhfDUgboRdcWW2bR9vBfrj2+O5HSMbQOJfJJjIVSPFqbBCF37FpwWXGitDc5tA== - quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -16269,14 +16129,6 @@ recursive-readdir@^2.2.2: dependencies: minimatch "3.0.4" -redent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" - integrity sha512-XNwrTx77JQCEMXTeb8movBKuK75MgH0RZkujNuDKCezemx/voapl9i2gCSi8WWm8+ox5ycJi1gxF22fR7c0Ciw== - dependencies: - indent-string "^3.0.0" - strip-indent "^2.0.0" - redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -17517,11 +17369,6 @@ strip-hex-prefix@1.0.0: dependencies: is-hex-prefixed "1.0.0" -strip-indent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" - integrity sha512-RsSNPLpq6YUL7QYy44RnPVTn/lcVZtb48Uof3X5JLbF4zD/Gs7ZFDv2HWol+leoQN2mT86LAzSshGfkTlSOpsA== - strip-indent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" @@ -17977,11 +17824,6 @@ treeverse@^2.0.0: resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" integrity sha512-N5gJCkLu1aXccpOTtqV6ddSEi6ZmGkh3hjmbu1IjcavJK4qyOVQmi0myQKM7z5jVGmD68SJoliaVrMmVObhj6A== -trim-newlines@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" - integrity sha512-MTBWv3jhVjTU7XR3IQHllbiJs8sc75a80OEhB6or/q7pLTWgQ0bMGQXXYQSrSuXe6WiKWDZ5txXY5P59a/coVA== - trim-newlines@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" @@ -18213,6 +18055,11 @@ typeorm@^0.3.10: xml2js "^0.4.23" yargs "^17.3.1" +typescript@4.7.3: + version "4.7.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d" + integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA== + typescript@4.8.4: version "4.8.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" @@ -19249,13 +19096,6 @@ yargs-parser@20.2.4: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== -yargs-parser@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" - integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== - dependencies: - camelcase "^4.1.0" - yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" From 339d9df7493c0d1cd5456f15058cb9d631710d0d Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 15:32:19 -0500 Subject: [PATCH 12/28] remove tsdoc-metadata.json --- packages/did-provider-ion/dist/tsdoc-metadata.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/did-provider-ion/dist/tsdoc-metadata.json diff --git a/packages/did-provider-ion/dist/tsdoc-metadata.json b/packages/did-provider-ion/dist/tsdoc-metadata.json deleted file mode 100644 index 1d96152afd..0000000000 --- a/packages/did-provider-ion/dist/tsdoc-metadata.json +++ /dev/null @@ -1,11 +0,0 @@ -// This file is read by tools that parse documentation comments conforming to the TSDoc standard. -// It should be published with your NPM package. It should not be tracked by Git. -{ - "tsdocVersion": "0.12", - "toolPackages": [ - { - "packageName": "@microsoft/api-extractor", - "packageVersion": "7.25.0" - } - ] -} From 87dea7371f029a0807c8dfe28fe572ca11553064 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Tue, 22 Nov 2022 16:52:16 -0500 Subject: [PATCH 13/28] fix browser tests --- packages/test-react-app/src/veramo/setup.ts | 5 +++++ scripts/prepare-react-test.sh | 1 + 2 files changed, 6 insertions(+) diff --git a/packages/test-react-app/src/veramo/setup.ts b/packages/test-react-app/src/veramo/setup.ts index 32f7bfc93b..e1b06dad02 100644 --- a/packages/test-react-app/src/veramo/setup.ts +++ b/packages/test-react-app/src/veramo/setup.ts @@ -28,6 +28,7 @@ import { VeramoEd25519Signature2018, } from '@veramo/credential-ld' import { getDidKeyResolver, KeyDIDProvider } from '@veramo/did-provider-key' +import { getDidPkhResolver, PkhDIDProvider } from '@veramo/did-provider-pkh' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '@veramo/did-comm' import { ISelectiveDisclosure, SdrMessageHandler, SelectiveDisclosure } from '@veramo/selective-disclosure' import { KeyManagementSystem, SecretBox } from '@veramo/kms-local' @@ -64,6 +65,7 @@ export function getAgent(options?: IAgentOptions): TAgent { ...ethrDidResolver({ infuraProjectId: INFURA_PROJECT_ID }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent as TAgent).getDidFakeResolver(), }), }), @@ -106,6 +108,9 @@ export function getAgent(options?: IAgentOptions): TAgent { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), diff --git a/scripts/prepare-react-test.sh b/scripts/prepare-react-test.sh index 36268181ec..387f7e8f5b 100644 --- a/scripts/prepare-react-test.sh +++ b/scripts/prepare-react-test.sh @@ -15,6 +15,7 @@ packages=( "did-manager" "did-provider-ethr" "did-provider-key" +"did-provider-pkh" "did-provider-web" "did-resolver" "key-manager" From dc765978110452b1cae654ff177dec97e40ae3a0 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Wed, 2 Nov 2022 15:06:17 -0400 Subject: [PATCH 14/28] First draft of did-pkh method. - Create new pkh-did-provider - Add resolve did-pkh tests - Add create did-pkh identidfier test - Add VC creation/verification using did-pkh identifier Currently not using pkh-did-resolver package (error import). Code momentarily copied to did-provider-pkh resolver. --- .gitignore | 2 + __tests__/localAgent.test.ts | 5 + __tests__/localJsonStoreAgent.test.ts | 5 + __tests__/localMemoryStoreAgent.test.ts | 5 + __tests__/restAgent.test.ts | 5 + __tests__/shared/didManager.ts | 13 ++ __tests__/shared/resolveDid.ts | 17 ++ __tests__/shared/verifiableDataLD.ts | 46 ++++ packages/credential-ld/src/action-handler.ts | 1 + .../did-provider-ion/dist/tsdoc-metadata.json | 11 + packages/did-provider-pkh/CHANGELOG.md | 82 +++++++ packages/did-provider-pkh/LICENSE | 201 ++++++++++++++++++ packages/did-provider-pkh/README.md | 4 + packages/did-provider-pkh/api-extractor.json | 18 ++ packages/did-provider-pkh/package.json | 42 ++++ packages/did-provider-pkh/src/index.ts | 8 + .../did-provider-pkh/src/pkh-did-provider.ts | 184 ++++++++++++++++ packages/did-provider-pkh/src/resolver.ts | 93 ++++++++ packages/did-provider-pkh/tsconfig.json | 10 + packages/tsconfig.json | 1 + yarn.lock | 12 ++ 21 files changed, 765 insertions(+) create mode 100644 packages/did-provider-ion/dist/tsdoc-metadata.json create mode 100644 packages/did-provider-pkh/CHANGELOG.md create mode 100644 packages/did-provider-pkh/LICENSE create mode 100644 packages/did-provider-pkh/README.md create mode 100644 packages/did-provider-pkh/api-extractor.json create mode 100644 packages/did-provider-pkh/package.json create mode 100644 packages/did-provider-pkh/src/index.ts create mode 100644 packages/did-provider-pkh/src/pkh-did-provider.ts create mode 100644 packages/did-provider-pkh/src/resolver.ts create mode 100644 packages/did-provider-pkh/tsconfig.json diff --git a/.gitignore b/.gitignore index 367d1cf99a..496fa1d75e 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,5 @@ temp agent.yml data .vscode-upload.json + +local-database*.json \ No newline at end of file diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 39503df2ec..5c02e81d9b 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -36,6 +36,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -193,6 +194,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -210,6 +214,7 @@ const setup = async (options?: IAgentOptions): Promise => { }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), new DataStore(dbConnection), diff --git a/__tests__/localJsonStoreAgent.test.ts b/__tests__/localJsonStoreAgent.test.ts index 03d63d398b..f6c979ee3a 100644 --- a/__tests__/localJsonStoreAgent.test.ts +++ b/__tests__/localJsonStoreAgent.test.ts @@ -34,6 +34,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -157,6 +158,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -165,6 +169,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), }), diff --git a/__tests__/localMemoryStoreAgent.test.ts b/__tests__/localMemoryStoreAgent.test.ts index 9a7bdf0754..6d4a451495 100644 --- a/__tests__/localMemoryStoreAgent.test.ts +++ b/__tests__/localMemoryStoreAgent.test.ts @@ -35,6 +35,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -155,6 +156,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -163,6 +167,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent).getDidFakeResolver(), }), }), diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index 3ea1f5b450..f7a6012423 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -44,6 +44,7 @@ import { import { EthrDIDProvider } from '../packages/did-provider-ethr/src' import { WebDIDProvider } from '../packages/did-provider-web/src' import { getDidKeyResolver, KeyDIDProvider } from '../packages/did-provider-key/src' +import { getDidPkhResolver, PkhDIDProvider } from '../packages/did-provider-pkh/src' import { DIDComm, DIDCommHttpTransport, DIDCommMessageHandler, IDIDComm } from '../packages/did-comm/src' import { ISelectiveDisclosure, @@ -184,6 +185,9 @@ const setup = async (options?: IAgentOptions): Promise => { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), @@ -193,6 +197,7 @@ const setup = async (options?: IAgentOptions): Promise => { ...webDidResolver(), // key: getUniversalResolver(), // resolve using remote resolver... when uniresolver becomes more stable, ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => serverAgent as TAgent).getDidFakeResolver(), }), }), diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts index 7398ab1b62..91ba3b0b43 100644 --- a/__tests__/shared/didManager.ts +++ b/__tests__/shared/didManager.ts @@ -33,6 +33,19 @@ export default (testContext: { expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) }) + it('should create pkh identifier using did:pkh provider', async () => { + identifier = await agent.didManagerCreate({ + // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier + provider: 'did:pkh', + options: { network: "mainnet"} + }) + expect(identifier.provider).toEqual('did:pkh') + //expect(identifier.did).toMatch(/^did:pkh:eip155:*$/) + expect(identifier.keys.length).toEqual(1) + expect(identifier.services.length).toEqual(0) + expect(identifier.controllerKeyId).toEqual(identifier.keys[0].kid) + }) + it('should create identifier using did:ethr:arbitrum:goerli provider', async () => { identifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index d25fa34eff..1af7662982 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -1,5 +1,6 @@ // noinspection ES6PreferShortImport +import { IIdentifier } from '@veramo/core' import { IAgentOptions, IDIDManager, IResolver, TAgent } from '../../packages/core/src' type ConfiguredAgent = TAgent @@ -34,6 +35,22 @@ export default (testContext: { expect(result).toHaveProperty('didResolutionMetadata') }) + it('should resolve did:pkh', async () => { + let identifier: IIdentifier = await agent.didManagerCreate({ + // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier + provider: 'did:pkh', + options: { network: "mainnet"} + }); + + const result = await agent.resolveDid({ didUrl: identifier.did}); + const didDoc = result.didDocument + expect(didDoc?.id).toEqual(identifier.did) + expect(result).toHaveProperty('didDocumentMetadata') + expect(result).toHaveProperty('didResolutionMetadata') + + //let cred = await agent.createVerifiableCredential() + }); + it('should resolve imported fake did', async () => { const did = 'did:fake:myfakedid' await agent.didManagerImport({ diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index 5c457925ed..90916dcc9e 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -26,7 +26,9 @@ export default (testContext: { let agent: ConfiguredAgent let didEthrIdentifier: IIdentifier let didKeyIdentifier: IIdentifier + let pkhIdentifier: IIdentifier let storedCredentialHash: string + let storedPkhCredentialHash: string let challenge: string beforeAll(async () => { @@ -35,6 +37,7 @@ export default (testContext: { challenge = 'TEST_CHALLENGE_STRING' didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' }) didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' }) + pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { network: "mainnet"} }) }) afterAll(testContext.tearDown) @@ -257,6 +260,49 @@ export default (testContext: { expect(result.verified).toEqual(true) }) + it('should create verifiable credential in LD with did:pkh', async () => { + + + + + const verifiableCredential = await agent.createVerifiableCredential({ + credential: { + issuer: { id: pkhIdentifier.did }, + '@context': ['https://www.w3.org/2018/credentials/v1', 'https://veramo.io/contexts/profile/v1'], + type: ['VerifiableCredential', 'Profile'], + issuanceDate: new Date().toISOString(), + credentialSubject: { + id: pkhIdentifier.did, + name: 'Martin, the great', + }, + }, + proofFormat: 'lds', + }) + + // Check credential: + expect(verifiableCredential).toHaveProperty('proof') + expect(verifiableCredential).toHaveProperty('proof.jws') + // expect(verifiableCredential.proof.verificationMethod).toEqual( + // `${didKeyIdentifier.did}#${didKeyIdentifier.did.substring( + // didKeyIdentifier.did.lastIndexOf(':') + 1, + // )}`, + // ) + + expect(verifiableCredential['@context']).toEqual([ + 'https://www.w3.org/2018/credentials/v1', + 'https://veramo.io/contexts/profile/v1', + ]) + expect(verifiableCredential['type']).toEqual(['VerifiableCredential', 'Profile']) + + storedPkhCredentialHash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) + expect(typeof storedPkhCredentialHash).toEqual('string') + + const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ + hash: storedCredentialHash, + }) + expect(verifiableCredential).toEqual(verifiableCredential2) + }) + describe('credential verification policies', () => { it('can verify credential at a particular time', async () => { const issuanceDate = '2019-08-19T09:15:20.000Z' // 1566206120 diff --git a/packages/credential-ld/src/action-handler.ts b/packages/credential-ld/src/action-handler.ts index c3f8549ae1..31b7d9dd44 100644 --- a/packages/credential-ld/src/action-handler.ts +++ b/packages/credential-ld/src/action-handler.ts @@ -251,6 +251,7 @@ export class CredentialIssuerLD implements IAgentPlugin { signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type)) } + if (!signingKey) throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`) verificationMethodId = signingKey.meta.verificationMethod.id return { signingKey, verificationMethodId } diff --git a/packages/did-provider-ion/dist/tsdoc-metadata.json b/packages/did-provider-ion/dist/tsdoc-metadata.json new file mode 100644 index 0000000000..1d96152afd --- /dev/null +++ b/packages/did-provider-ion/dist/tsdoc-metadata.json @@ -0,0 +1,11 @@ +// This file is read by tools that parse documentation comments conforming to the TSDoc standard. +// It should be published with your NPM package. It should not be tracked by Git. +{ + "tsdocVersion": "0.12", + "toolPackages": [ + { + "packageName": "@microsoft/api-extractor", + "packageVersion": "7.25.0" + } + ] +} diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md new file mode 100644 index 0000000000..375ed49dfa --- /dev/null +++ b/packages/did-provider-pkh/CHANGELOG.md @@ -0,0 +1,82 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) + + +### Bug Fixes + +* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) +* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) +* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) + + +### Features + +* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) +* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) + + + + + +## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) + + +### Features + +* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) +* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) + + + + + +# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) +* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) +* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) + + +### Features + +* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) +* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) diff --git a/packages/did-provider-pkh/LICENSE b/packages/did-provider-pkh/LICENSE new file mode 100644 index 0000000000..fd815d7f8f --- /dev/null +++ b/packages/did-provider-pkh/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 2019 Consensys AG + + 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/did-provider-pkh/README.md b/packages/did-provider-pkh/README.md new file mode 100644 index 0000000000..34de2dbc99 --- /dev/null +++ b/packages/did-provider-pkh/README.md @@ -0,0 +1,4 @@ +# Veramo did:web provider + +This package contains an implementation of `AbstractIdentifierProvider` for the `did:pkh` method. +This enables creation and control of `did:pkh` entities. diff --git a/packages/did-provider-pkh/api-extractor.json b/packages/did-provider-pkh/api-extractor.json new file mode 100644 index 0000000000..409d7f16c8 --- /dev/null +++ b/packages/did-provider-pkh/api-extractor.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", + "apiReport": { + "enabled": true, + "reportFolder": "./api", + "reportTempFolder": "./api" + }, + + "docModel": { + "enabled": true, + "apiJsonFilePath": "./api/.api.json" + }, + + "dtsRollup": { + "enabled": false + }, + "mainEntryPointFilePath": "/build/index.d.ts" +} diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json new file mode 100644 index 0000000000..6c05e70c72 --- /dev/null +++ b/packages/did-provider-pkh/package.json @@ -0,0 +1,42 @@ +{ + "name": "@veramo/did-provider-pkh", + "description": "Veramo plugin that can enable creation and control of did:pkh identifiers.", + "version": "4.0.0", + "main": "build/index.js", + "types": "build/index.d.ts", + "scripts": { + "build": "tsc", + "extract-api": "yarn veramo dev extract-api" + }, + "dependencies": { + "@transmute/did-key-ed25519": "^0.3.0-unstable.8", + "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", + "@transmute/did-key-x25519": "^0.3.0-unstable.8", + "@veramo/core": "^4.0.0", + "@veramo/did-manager": "^4.0.0", + "debug": "^4.3.3", + "multibase": "^4.0.6", + "multicodec": "^3.2.1" + }, + "devDependencies": { + "@types/debug": "4.1.7", + "typescript": "4.7.3" + }, + "resolutions": { + "*/**/jsonld": "npm:@digitalcredentials/jsonld@^5.2.1" + }, + "files": [ + "build/**/*", + "src/**/*", + "README.md", + "LICENSE" + ], + "publishConfig": { + "access": "public" + }, + "repository": "git@github.com:uport-project/veramo.git", + "author": "Diego Chagastelles ", + "contributors": [], + "license": "Apache-2.0", + "keywords": [] +} diff --git a/packages/did-provider-pkh/src/index.ts b/packages/did-provider-pkh/src/index.ts new file mode 100644 index 0000000000..c7cbbd8f1f --- /dev/null +++ b/packages/did-provider-pkh/src/index.ts @@ -0,0 +1,8 @@ +/** + * Provides `did:pkh` {@link @veramo/did-provider-pkh#PkhDIDProvider | identifier provider } for the + * {@link @veramo/did-manager#DIDManager} + * + * @packageDocumentation + */ +export { PkhDIDProvider } from './pkh-did-provider' +export { getResolver as getDidPkhResolver } from './resolver' diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts new file mode 100644 index 0000000000..5921c79c2d --- /dev/null +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -0,0 +1,184 @@ +import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core' +import { Provider } from '@ethersproject/abstract-provider' + +import { AbstractIdentifierProvider } from '@veramo/did-manager' +import { computePublicKey } from '@ethersproject/signing-key' +import { BigNumber } from '@ethersproject/bignumber' + +import Debug from 'debug' +const debug = Debug('veramo:did-pkh:identifier-provider') + +type IContext = IAgentContext + +/** + * Options for creating a did:ethr + * @beta + */ + export interface CreateDidPkhEthrOptions { + /** + * This can be a network name or hex encoded chain ID (string) or a chainId number + * + * If this is not specified, `mainnet` is assumed. + */ + network?: string | number + + /** + * This is usually a did prefix, like `did:ethr` or `did:ethr:goerli` and can be used to determine the desired + * network, if no `network` option is specified. + */ + providerName?: string +} + +export interface EthrNetworkConfiguration { + /** + * The name of the network, for example 'mainnet', 'goerli', 'polygon'. + * If this is present, then DIDs anchored on this network will have a human-readable prefix, like + * `did:ethr:goerli:0x...`. See the + * {@link https://github.com/uport-project/ethr-did-registry#contract-deployments | official deployments} for a table + * of reusable names. + * If this parameter is not present, `chainId` MUST be specified. + */ + name?: string + + /** + * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. + * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the + * `did:pkh` spec. + * + * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` + */ + chainId?: string | number + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [index: string]: any +} + +/** + * {@link @veramo/did-manager#DIDManager} identifier provider for `did:pkh` identifiers + * + * @beta This API may change without a BREAKING CHANGE notice. + */ +export class PkhDIDProvider extends AbstractIdentifierProvider { + private defaultKms: string + private networks: EthrNetworkConfiguration[] | undefined + + constructor(options: { + defaultKms: string + networks?: EthrNetworkConfiguration[] + }) + { + super() + this.defaultKms = options.defaultKms + if (options.networks) { + this.networks = options.networks + } else { + + // if (typeof options.network === 'string') { + // if (options.network.startsWith('0x')) { + // singleNetwork.chainId = parseInt(options.network.substring(2), 16) + // } else { + // singleNetwork.name = options.network + // } + // } else if (typeof options.network === 'number') { + // singleNetwork.chainId = options.network + // singleNetwork.name = options.name + // } + // this.networks = [singleNetwork] + // } + + } + + } + + + + async createIdentifier( + { kms, options }: { kms?: string; options?: CreateDidPkhEthrOptions }, + context: IContext, + ): Promise> { + + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) + const compressedPublicKey = computePublicKey(`0x${key.publicKeyHex}`, true) + let networkSpecifier = + options?.network || + (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + + + const network = options?.network; // this.getNetworkFor(networkSpecifier) + if (!network) { + throw new Error( + `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${networkSpecifier}'`, + ) + } + // if (typeof networkSpecifier === 'number') { + // networkSpecifier = + // network.name && network.name.length > 0 + // ? network.name + // : BigNumber.from(options?.network || 1).toHexString() + // } + //const networkString = networkSpecifier && networkSpecifier !== 'mainnet' ? `${networkSpecifier}:` : '' + const identifier: Omit = { + did: 'did:pkh:eip155:' + network + ':' + compressedPublicKey, + controllerKeyId: key.kid, + keys: [key], + services: [], + } + debug('Created', identifier.did) + return identifier + } + async updateIdentifier(args: { did: string; kms?: string | undefined; alias?: string | undefined; options?: any }, context: IAgentContext): Promise { + throw new Error('PkhDIDProvider updateIdentifier not supported yet.') + } + + async deleteIdentifier(identifier: IIdentifier, context: IContext): Promise { + for (const { kid } of identifier.keys) { + await context.agent.keyManagerDelete({ kid }) + } + return true + } + + async addKey( + { identifier, key, options }: { identifier: IIdentifier; key: IKey; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider addKey not supported') + } + + async addService( + { identifier, service, options }: { identifier: IIdentifier; service: IService; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider addService not supported') + } + + async removeKey( + args: { identifier: IIdentifier; kid: string; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider removeKey not supported') + } + + async removeService( + args: { identifier: IIdentifier; id: string; options?: any }, + context: IContext, + ): Promise { + throw Error('PkhDIDProvider removeService not supported') + } + + private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { + let networkNameOrId: string | number = networkSpecifier || 'mainnet' + if ( + typeof networkNameOrId === 'string' && + (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) + ) { + networkNameOrId = BigNumber.from(networkNameOrId).toNumber() + } + let network = this.networks?.find( + (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, + ) + if (!network && !networkSpecifier && this.networks?.length === 1) { + network = this.networks[0] + } + return network + } +} diff --git a/packages/did-provider-pkh/src/resolver.ts b/packages/did-provider-pkh/src/resolver.ts new file mode 100644 index 0000000000..ab0508988e --- /dev/null +++ b/packages/did-provider-pkh/src/resolver.ts @@ -0,0 +1,93 @@ +import { AccountId, ChainIdParams } from 'caip' +import type { + DIDResolutionResult, + DIDResolutionOptions, + ResolverRegistry, + ParsedDID, + Resolver, + Resolvable +} from 'did-resolver' + +const DID_LD_JSON = 'application/did+ld+json' +const DID_JSON = 'application/did+json' +const SECPK1_NAMESPACES = ['eip155', 'bip122'] +const TZ_NAMESPACE = 'tezos' + + +function toDidDoc(did: string, accountId: string): any { + const { namespace } = AccountId.parse(accountId).chainId as ChainIdParams + const vmId = did + '#blockchainAccountId' + const doc = { + '@context': [ + 'https://www.w3.org/ns/did/v1', + { + blockchainAccountId: 'https://w3id.org/security#blockchainAccountId', + EcdsaSecp256k1RecoveryMethod2020: + 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020#EcdsaSecp256k1RecoveryMethod2020', + Ed25519VerificationKey2018: 'https://w3id.org/security#Ed25519VerificationKey2018', + }, + ], + id: did, + verificationMethod: [ + { + id: vmId, + type: 'EcdsaSecp256k1RecoveryMethod2020', + controller: did, + blockchainAccountId: accountId, + }, + ], + authentication: [vmId], + assertionMethod: [vmId], + } + if (SECPK1_NAMESPACES.includes(namespace)) { + // nothing to do here + } else if (namespace === TZ_NAMESPACE) { + (doc['@context'][1] as any).TezosMethod2021 = 'https://w3id.org/security#TezosMethod2021' + const tzId = did + '#TezosMethod2021' + doc.verificationMethod.push({ + id: tzId, + type: 'TezosMethod2021', + controller: did, + blockchainAccountId: accountId, + }) + doc.authentication.push(tzId) + doc.assertionMethod.push(tzId) + } else { + throw new Error(`chain namespace not supported ${namespace}`) + } + return doc +} + +export function getResolver(): ResolverRegistry { + return { + pkh: async ( + did: string, + parsed: ParsedDID, + r: Resolvable, + options: DIDResolutionOptions + ): Promise => { + const contentType = options.accept || DID_JSON + const response: DIDResolutionResult = { + didResolutionMetadata: { contentType }, + didDocument: null, + didDocumentMetadata: {}, + } + try { + const doc = toDidDoc(did, parsed.id) + if (contentType === DID_LD_JSON) { + response.didDocument = doc + } else if (contentType === DID_JSON) { + delete doc['@context'] + response.didDocument = doc + } else { + delete response.didResolutionMetadata.contentType + response.didResolutionMetadata.error = 'representationNotSupported' + } + } catch (e) { + response.didResolutionMetadata.error = 'invalidDid' + response.didResolutionMetadata.message = e.toString() + } + return response + }, + } +} \ No newline at end of file diff --git a/packages/did-provider-pkh/tsconfig.json b/packages/did-provider-pkh/tsconfig.json new file mode 100644 index 0000000000..21035981a7 --- /dev/null +++ b/packages/did-provider-pkh/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.settings.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build", + "declarationDir": "build", + "skipLibCheck": true + }, + "references": [{ "path": "../core" }, { "path": "../did-manager" }] +} diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 9ca3043803..7453d01a9c 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -14,6 +14,7 @@ { "path": "did-manager" }, { "path": "did-provider-ethr" }, { "path": "did-provider-ion" }, + { "path": "did-provider-pkh" }, { "path": "did-provider-key" }, { "path": "did-provider-web" }, { "path": "did-resolver" }, diff --git a/yarn.lock b/yarn.lock index 83b1209e95..ca468b578c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6985,6 +6985,11 @@ cacache@^16.0.0, cacache@^16.0.6, cacache@^16.1.0: tar "^6.1.11" unique-filename "^1.1.1" +caip@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/caip/-/caip-1.1.0.tgz#0ccd5bf1bff822459389ccec0a8555712a30c374" + integrity sha512-yOO3Fu4ygyKYAdznuoaqschMKIZzcdgyMpBNtrIfrUhnOeaOWG+dh0c13wcOS6B/46IGGbncoyzJlio79jU7rw== + call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -14901,6 +14906,13 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" +pkh-did-resolver@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/pkh-did-resolver/-/pkh-did-resolver-1.0.10.tgz#f0144aaaf88af4d573ac23b050d77d8edaa879e8" + integrity sha512-GYfZxFQXFfuVUcztZJuf73tjr3L9nRvzvnoAtKIGREHkpEzj801WQ41OJ7PmsTyIDakaHfXyI3WyX33DUsenTw== + dependencies: + caip "~1.1.0" + postcss-attribute-case-insensitive@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.1.tgz#86d323c77ab8896ed90500071c2c8329fba64fda" From 9c21fcbc2c8a96fcbdc8e538993c2f31c8f76e0b Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:51:09 -0500 Subject: [PATCH 15/28] -Fix did:pkh identifier (use address intead of public key hex) -Use chainId only and not network name -clean up params -fix tests --- __tests__/shared/didManager.ts | 2 +- __tests__/shared/resolveDid.ts | 2 +- __tests__/shared/verifiableDataLD.ts | 18 +-- .../did-provider-pkh/src/pkh-did-provider.ts | 141 +++++++---------- yarn.lock | 147 +++++++++++++++++- 5 files changed, 208 insertions(+), 102 deletions(-) diff --git a/__tests__/shared/didManager.ts b/__tests__/shared/didManager.ts index 91ba3b0b43..e1b2acb1a7 100644 --- a/__tests__/shared/didManager.ts +++ b/__tests__/shared/didManager.ts @@ -37,7 +37,7 @@ export default (testContext: { identifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier provider: 'did:pkh', - options: { network: "mainnet"} + options: { chainId: "1"} }) expect(identifier.provider).toEqual('did:pkh') //expect(identifier.did).toMatch(/^did:pkh:eip155:*$/) diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index 1af7662982..514e0c56f2 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -39,7 +39,7 @@ export default (testContext: { let identifier: IIdentifier = await agent.didManagerCreate({ // this expects the `did:ethr` provider to matchPrefix and use the `arbitrum:goerli` network specifier provider: 'did:pkh', - options: { network: "mainnet"} + options: { chainId: "1"} }); const result = await agent.resolveDid({ didUrl: identifier.did}); diff --git a/__tests__/shared/verifiableDataLD.ts b/__tests__/shared/verifiableDataLD.ts index 90916dcc9e..dbc0ca06de 100644 --- a/__tests__/shared/verifiableDataLD.ts +++ b/__tests__/shared/verifiableDataLD.ts @@ -37,7 +37,7 @@ export default (testContext: { challenge = 'TEST_CHALLENGE_STRING' didEthrIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:ethr' }) didKeyIdentifier = await agent.didManagerCreate({ kms: 'local', provider: 'did:key' }) - pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { network: "mainnet"} }) + pkhIdentifier = await agent.didManagerCreate({ kms: 'local', provider: "did:pkh", options: { chainId: "1"} }) }) afterAll(testContext.tearDown) @@ -261,10 +261,6 @@ export default (testContext: { }) it('should create verifiable credential in LD with did:pkh', async () => { - - - - const verifiableCredential = await agent.createVerifiableCredential({ credential: { issuer: { id: pkhIdentifier.did }, @@ -282,23 +278,13 @@ export default (testContext: { // Check credential: expect(verifiableCredential).toHaveProperty('proof') expect(verifiableCredential).toHaveProperty('proof.jws') - // expect(verifiableCredential.proof.verificationMethod).toEqual( - // `${didKeyIdentifier.did}#${didKeyIdentifier.did.substring( - // didKeyIdentifier.did.lastIndexOf(':') + 1, - // )}`, - // ) - - expect(verifiableCredential['@context']).toEqual([ - 'https://www.w3.org/2018/credentials/v1', - 'https://veramo.io/contexts/profile/v1', - ]) expect(verifiableCredential['type']).toEqual(['VerifiableCredential', 'Profile']) storedPkhCredentialHash = await agent.dataStoreSaveVerifiableCredential({ verifiableCredential }) expect(typeof storedPkhCredentialHash).toEqual('string') const verifiableCredential2 = await agent.dataStoreGetVerifiableCredential({ - hash: storedCredentialHash, + hash: storedPkhCredentialHash, }) expect(verifiableCredential).toEqual(verifiableCredential2) }) diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index 5921c79c2d..7e630eab87 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -1,5 +1,6 @@ import { IIdentifier, IKey, IService, IAgentContext, IKeyManager } from '@veramo/core' import { Provider } from '@ethersproject/abstract-provider' +import { computeAddress } from '@ethersproject/transactions' import { AbstractIdentifierProvider } from '@veramo/did-manager' import { computePublicKey } from '@ethersproject/signing-key' @@ -16,42 +17,40 @@ type IContext = IAgentContext */ export interface CreateDidPkhEthrOptions { /** - * This can be a network name or hex encoded chain ID (string) or a chainId number + * This can be hex encoded chain ID (string) or a chainId number * - * If this is not specified, `mainnet` is assumed. + * If this is not specified, `1` is assumed. */ - network?: string | number + chainId?: string | number + - /** - * This is usually a did prefix, like `did:ethr` or `did:ethr:goerli` and can be used to determine the desired - * network, if no `network` option is specified. - */ - providerName?: string } -export interface EthrNetworkConfiguration { - /** - * The name of the network, for example 'mainnet', 'goerli', 'polygon'. - * If this is present, then DIDs anchored on this network will have a human-readable prefix, like - * `did:ethr:goerli:0x...`. See the - * {@link https://github.com/uport-project/ethr-did-registry#contract-deployments | official deployments} for a table - * of reusable names. - * If this parameter is not present, `chainId` MUST be specified. - */ - name?: string +// export interface EthrNetworkConfiguration { +// /** +// * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. +// * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the +// * `did:pkh` spec. +// * +// * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` +// */ +// chainId?: string | number + +// // eslint-disable-next-line @typescript-eslint/no-explicit-any +// [index: string]: any +// } + + /** - * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. - * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the - * `did:pkh` spec. - * - * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` - */ - chainId?: string | number + * Helper method that can computes the ethereumAddress corresponding to a Secp256k1 public key. + * @param hexPublicKey A hex encoded public key, optionally prefixed with `0x` + */ + export function toEthereumAddress(hexPublicKey: string): string { + const publicKey = hexPublicKey.startsWith('0x') ? hexPublicKey : '0x' + hexPublicKey + return computeAddress(publicKey) + } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [index: string]: any -} /** * {@link @veramo/did-manager#DIDManager} identifier provider for `did:pkh` identifiers @@ -60,34 +59,18 @@ export interface EthrNetworkConfiguration { */ export class PkhDIDProvider extends AbstractIdentifierProvider { private defaultKms: string - private networks: EthrNetworkConfiguration[] | undefined - + //private networks: EthrNetworkConfiguration[] | undefined + constructor(options: { defaultKms: string - networks?: EthrNetworkConfiguration[] + //networks?: EthrNetworkConfiguration[] }) { super() this.defaultKms = options.defaultKms - if (options.networks) { - this.networks = options.networks - } else { - - // if (typeof options.network === 'string') { - // if (options.network.startsWith('0x')) { - // singleNetwork.chainId = parseInt(options.network.substring(2), 16) - // } else { - // singleNetwork.name = options.network - // } - // } else if (typeof options.network === 'number') { - // singleNetwork.chainId = options.network - // singleNetwork.name = options.name - // } - // this.networks = [singleNetwork] + // if (options.networks) { + // this.networks = options.networks // } - - } - } @@ -96,29 +79,23 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { { kms, options }: { kms?: string; options?: CreateDidPkhEthrOptions }, context: IContext, ): Promise> { - + const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) - const compressedPublicKey = computePublicKey(`0x${key.publicKeyHex}`, true) - let networkSpecifier = - options?.network || - (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + const publicAddress = toEthereumAddress(key.publicKeyHex); + // let networkSpecifier = + // options?.network || + // (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) + - - const network = options?.network; // this.getNetworkFor(networkSpecifier) + const network = options?.chainId; // this.getNetworkFor(networkSpecifier) if (!network) { throw new Error( - `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${networkSpecifier}'`, + `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${network}'`, ) } - // if (typeof networkSpecifier === 'number') { - // networkSpecifier = - // network.name && network.name.length > 0 - // ? network.name - // : BigNumber.from(options?.network || 1).toHexString() - // } - //const networkString = networkSpecifier && networkSpecifier !== 'mainnet' ? `${networkSpecifier}:` : '' + const identifier: Omit = { - did: 'did:pkh:eip155:' + network + ':' + compressedPublicKey, + did: 'did:pkh:eip155:' + network + ':' + publicAddress, controllerKeyId: key.kid, keys: [key], services: [], @@ -165,20 +142,22 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { throw Error('PkhDIDProvider removeService not supported') } - private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { - let networkNameOrId: string | number = networkSpecifier || 'mainnet' - if ( - typeof networkNameOrId === 'string' && - (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) - ) { - networkNameOrId = BigNumber.from(networkNameOrId).toNumber() - } - let network = this.networks?.find( - (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, - ) - if (!network && !networkSpecifier && this.networks?.length === 1) { - network = this.networks[0] - } - return network - } + // private getNetworkFor(networkSpecifier: string | number | undefined): EthrNetworkConfiguration | undefined { + // let networkNameOrId: string | number = networkSpecifier || 'mainnet' + // if ( + // typeof networkNameOrId === 'string' && + // (networkNameOrId.startsWith('0x') || parseInt(networkNameOrId) > 0) + // ) { + // networkNameOrId = BigNumber.from(networkNameOrId).toNumber() + // } + // let network = this.networks?.find( + // (n) => n.chainId === networkNameOrId || n.name === networkNameOrId || n.description === networkNameOrId, + // ) + // if (!network && !networkSpecifier && this.networks?.length === 1) { + // network = this.networks[0] + // } + // return network + // } + + } diff --git a/yarn.lock b/yarn.lock index ca468b578c..d5ad6e3586 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6093,6 +6093,11 @@ array-differ@^3.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== + array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -6612,7 +6617,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.1: +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0, bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -7016,6 +7021,15 @@ camelcase-css@^2.0.1: resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== +camelcase-keys@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" + integrity sha512-Ej37YKYbFUI8QiYlvj9YHb6/Z60dZyPJW0Cs8sFilMbd2lP0bw3ylAq9yJkK4lcTA2dID5fG8LjmJYbO7kWb7Q== + dependencies: + camelcase "^4.1.0" + map-obj "^2.0.0" + quick-lru "^1.0.0" + camelcase-keys@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" @@ -7025,6 +7039,11 @@ camelcase-keys@^6.2.2: map-obj "^4.0.0" quick-lru "^4.0.1" +camelcase@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" + integrity sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw== + camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -8039,6 +8058,13 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2" integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA== +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== + dependencies: + array-find-index "^1.0.1" + cwd@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/cwd/-/cwd-0.10.0.tgz#172400694057c22a13b0cf16162c7e4b7a7fe567" @@ -8137,6 +8163,14 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= +decamelize-keys@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" + integrity sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg== + dependencies: + decamelize "^1.1.0" + map-obj "^1.0.0" + decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" @@ -9150,6 +9184,14 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= +ethereum-checksum-address@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/ethereum-checksum-address/-/ethereum-checksum-address-0.0.2.tgz#46fcb2d962dacd1ed49d7b464408ec26fd183209" + integrity sha512-GAb7mPvGgcfi1j+Bsnwm9af9Z7dLUKp+5cFm88+kMrKACfh9gLatGLVVK5pSGEG2pOGfrmqCRcuh3RtMjIg8GQ== + dependencies: + keccak256 "^1.0.0" + meow "^5.0.0" + ethereum-cryptography@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz#74f2ac0f0f5fe79f012c889b3b8446a9a6264e6d" @@ -9160,6 +9202,16 @@ ethereum-cryptography@^1.1.2: "@scure/bip32" "1.1.0" "@scure/bip39" "1.1.0" +ethereum-public-key-to-address@^0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/ethereum-public-key-to-address/-/ethereum-public-key-to-address-0.0.5.tgz#0d8f7ffbbe0fcd379864afbc46790a273029f691" + integrity sha512-j7k9dP49JuK50PtygiTfqjrZLsk0Hc3Vh5jjqCH8pl4mPfwcQwA9Ds+ie7BXr2JdpFDB3cYR8H/1Rwp0jU5Nxg== + dependencies: + ethereum-checksum-address "0.0.2" + keccak "^3.0.1" + meow "^5.0.0" + secp256k1 "^4.0.2" + ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" @@ -10709,6 +10761,11 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= +indent-string@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" + integrity sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ== + indent-string@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" @@ -12529,7 +12586,25 @@ just-diff@^5.0.1: resolved "https://registry.yarnpkg.com/just-diff/-/just-diff-5.0.1.tgz#db8fe1cfeea1156f2374bfb289826dca28e7e390" integrity sha512-X00TokkRIDotUIf3EV4xUm6ELc/IkqhS/vPSHdWnsM5y0HoNMfEqrazizI7g78lpHvnRSRt/PFfKtRqJCOGIuQ== -keccak@3.0.2: +keccak256@^1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58" + integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw== + dependencies: + bn.js "^5.2.0" + buffer "^6.0.3" + keccak "^3.0.2" + +keccak@3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" + integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + +keccak@^3.0.1, keccak@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== @@ -12997,6 +13072,14 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + integrity sha512-RPNliZOFkqFumDhvYqOaNY4Uz9oJM2K9tC6JWsJJsNdhuONW4LQHRBpb0qf4pJApVffI5N39SwzWZJuEhfd7eQ== + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + lower-case@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" @@ -13178,6 +13261,11 @@ map-obj@^1.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= +map-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" + integrity sha512-TzQSV2DiMYgoF5RycneKVUzIa9bQsj/B3tTgsE3dOGqlzHnGIDaC7XBE7grnA+8kZPnfqSGFe95VHc2oc0VFUQ== + map-obj@^4.0.0: version "4.2.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7" @@ -13231,6 +13319,21 @@ memfs@^3.1.2, memfs@^3.4.3: dependencies: fs-monkey "1.0.3" +meow@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" + integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== + dependencies: + camelcase-keys "^4.0.0" + decamelize-keys "^1.0.0" + loud-rejection "^1.0.0" + minimist-options "^3.0.1" + normalize-package-data "^2.3.4" + read-pkg-up "^3.0.0" + redent "^2.0.0" + trim-newlines "^2.0.0" + yargs-parser "^10.0.0" + meow@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/meow/-/meow-7.1.1.tgz#7c01595e3d337fcb0ec4e8eed1666ea95903d306" @@ -13413,6 +13516,14 @@ minimist-options@4.1.0: is-plain-obj "^1.1.0" kind-of "^6.0.3" +minimist-options@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" + integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -13807,7 +13918,7 @@ nopt@^5.0.0: dependencies: abbrev "1" -normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -15804,6 +15915,11 @@ queue-microtask@^1.2.2, queue-microtask@^1.2.3: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== +quick-lru@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" + integrity sha512-tRS7sTgyxMXtLum8L65daJnHUhfDUgboRdcWW2bR9vBfrj2+O5HSMbQOJfJJjIVSPFqbBCF37FpwWXGitDc5tA== + quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -16153,6 +16269,14 @@ recursive-readdir@^2.2.2: dependencies: minimatch "3.0.4" +redent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" + integrity sha512-XNwrTx77JQCEMXTeb8movBKuK75MgH0RZkujNuDKCezemx/voapl9i2gCSi8WWm8+ox5ycJi1gxF22fR7c0Ciw== + dependencies: + indent-string "^3.0.0" + strip-indent "^2.0.0" + redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -17393,6 +17517,11 @@ strip-hex-prefix@1.0.0: dependencies: is-hex-prefixed "1.0.0" +strip-indent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" + integrity sha512-RsSNPLpq6YUL7QYy44RnPVTn/lcVZtb48Uof3X5JLbF4zD/Gs7ZFDv2HWol+leoQN2mT86LAzSshGfkTlSOpsA== + strip-indent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" @@ -17848,6 +17977,11 @@ treeverse@^2.0.0: resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" integrity sha512-N5gJCkLu1aXccpOTtqV6ddSEi6ZmGkh3hjmbu1IjcavJK4qyOVQmi0myQKM7z5jVGmD68SJoliaVrMmVObhj6A== +trim-newlines@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" + integrity sha512-MTBWv3jhVjTU7XR3IQHllbiJs8sc75a80OEhB6or/q7pLTWgQ0bMGQXXYQSrSuXe6WiKWDZ5txXY5P59a/coVA== + trim-newlines@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" @@ -19115,6 +19249,13 @@ yargs-parser@20.2.4: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== +yargs-parser@^10.0.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" + integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== + dependencies: + camelcase "^4.1.0" + yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" From 1babf3578bb3dd133c53e7beca6ad6fa426d870a Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:58:43 -0500 Subject: [PATCH 16/28] Changelog.md file removed --- packages/did-provider-pkh/CHANGELOG.md | 82 -------------------------- 1 file changed, 82 deletions(-) delete mode 100644 packages/did-provider-pkh/CHANGELOG.md diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md deleted file mode 100644 index 375ed49dfa..0000000000 --- a/packages/did-provider-pkh/CHANGELOG.md +++ /dev/null @@ -1,82 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) - - -### Bug Fixes - -* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) -* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) -* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) - - -### Features - -* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) -* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) - - - - - -## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) - - -### Features - -* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) -* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) - - - - - -# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) -* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) -* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) - - -### Features - -* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) -* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) From 12e41eb790ddab095c34bc1b6da03375a7da0d38 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Wed, 2 Nov 2022 15:06:17 -0400 Subject: [PATCH 17/28] First draft of did-pkh method. - Create new pkh-did-provider - Add resolve did-pkh tests - Add create did-pkh identidfier test - Add VC creation/verification using did-pkh identifier Currently not using pkh-did-resolver package (error import). Code momentarily copied to did-provider-pkh resolver. --- packages/did-provider-pkh/CHANGELOG.md | 82 ++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 packages/did-provider-pkh/CHANGELOG.md diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md new file mode 100644 index 0000000000..375ed49dfa --- /dev/null +++ b/packages/did-provider-pkh/CHANGELOG.md @@ -0,0 +1,82 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) + + +### Bug Fixes + +* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) +* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) +* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) + + +### Features + +* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) +* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) + + + + + +## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) + +**Note:** Version bump only for package @veramo/did-provider-key + + + + + +# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) + + +### Features + +* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) +* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) + + + + + +# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) + + +### Bug Fixes + +* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) +* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) +* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) + + +### Features + +* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) +* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) From 83bdea8447e2c887ce61c2b63ab39b4c3c026632 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:51:09 -0500 Subject: [PATCH 18/28] -Fix did:pkh identifier (use address intead of public key hex) -Use chainId only and not network name -clean up params -fix tests --- yarn.lock | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/yarn.lock b/yarn.lock index d5ad6e3586..52c3859ade 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12613,6 +12613,15 @@ keccak@^3.0.1, keccak@^3.0.2: node-gyp-build "^4.2.0" readable-stream "^3.6.0" +keccak@^3.0.1, keccak@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" + integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== + dependencies: + node-addon-api "^2.0.0" + node-gyp-build "^4.2.0" + readable-stream "^3.6.0" + kind-of@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-2.0.1.tgz#018ec7a4ce7e3a86cb9141be519d24c8faa981b5" From aa0a722dc55eef213680cec695fa8f4b8c8cbc90 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 13:58:43 -0500 Subject: [PATCH 19/28] Changelog.md file removed --- packages/did-provider-pkh/CHANGELOG.md | 82 -------------------------- 1 file changed, 82 deletions(-) delete mode 100644 packages/did-provider-pkh/CHANGELOG.md diff --git a/packages/did-provider-pkh/CHANGELOG.md b/packages/did-provider-pkh/CHANGELOG.md deleted file mode 100644 index 375ed49dfa..0000000000 --- a/packages/did-provider-pkh/CHANGELOG.md +++ /dev/null @@ -1,82 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [4.0.0](https://github.com/uport-project/veramo/compare/v3.1.5...v4.0.0) (2022-09-22) - - -### Bug Fixes - -* **deps:** replace @transmute/lds-ecdsa-secp256k1-recovery2020 with fork ([#953](https://github.com/uport-project/veramo/issues/953)) ([573a0ef](https://github.com/uport-project/veramo/commit/573a0efe8d28653bd0389e401c25a2dd9c361a96)), closes [#952](https://github.com/uport-project/veramo/issues/952) -* **did-resolver:** use interface `Resolvable` instead of the `Resolver` class ([9c2e59f](https://github.com/uport-project/veramo/commit/9c2e59f3f23f808511c6c0e8e440b4d53ba5cb00)) -* update and fix inline documentation of all exported types ([#921](https://github.com/uport-project/veramo/issues/921)) ([63e64e0](https://github.com/uport-project/veramo/commit/63e64e0e2693808c4704dca8cc511dc0bab3f3b1)) - - -### Features - -* **credential-ld:** add support for browser environments ([#916](https://github.com/uport-project/veramo/issues/916)) ([435e4d2](https://github.com/uport-project/veramo/commit/435e4d260b1774f96b182c1a75ab2f1c993f2291)) -* **did-manager:** add`didManagerUpdate` method for full DID document updates ([#974](https://github.com/uport-project/veramo/issues/974)) ([5682b25](https://github.com/uport-project/veramo/commit/5682b2566b7c4f8f9bfda10e8d06a8d2624c2a1b)), closes [#971](https://github.com/uport-project/veramo/issues/971) [#960](https://github.com/uport-project/veramo/issues/960) [#948](https://github.com/uport-project/veramo/issues/948) - - - - - -## [3.1.3](https://github.com/uport-project/veramo/compare/v3.1.2...v3.1.3) (2022-06-01) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.1.0](https://github.com/uport-project/veramo/compare/v3.0.0...v3.1.0) (2021-11-12) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [3.0.0](https://github.com/uport-project/veramo/compare/v2.1.3...v3.0.0) (2021-09-20) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.1.0](https://github.com/uport-project/veramo/compare/v2.0.1...v2.1.0) (2021-08-11) - -**Note:** Version bump only for package @veramo/did-provider-key - - - - - -# [2.0.0](https://github.com/uport-project/veramo/compare/v1.2.2...v2.0.0) (2021-07-14) - - -### Features - -* add fake did method usable in tests ([4fc587c](https://github.com/uport-project/veramo/commit/4fc587cf07a56b2065c7c6beec2345001f5a5f40)) -* **cli:** export new agent methods and request LD DIDDocument by default ([#617](https://github.com/uport-project/veramo/issues/617)) ([26d088b](https://github.com/uport-project/veramo/commit/26d088b86ecfd66a00cdef7c7bb926148f46fbc9)) - - - - - -# [1.2.0](https://github.com/uport-project/veramo/compare/v1.1.2...v1.2.0) (2021-04-27) - - -### Bug Fixes - -* **deps:** update all non-major dependencies ([#462](https://github.com/uport-project/veramo/issues/462)) ([4a2b206](https://github.com/uport-project/veramo/commit/4a2b20633810b45a155bf2149cbff57d157bda3c)) -* **deps:** update dependency multibase to v4 ([#396](https://github.com/uport-project/veramo/issues/396)) ([7ea7a8d](https://github.com/uport-project/veramo/commit/7ea7a8d38b36be82f8eb9f025783fd95e9b51508)) -* **deps:** update dependency multicodec to v3 ([#398](https://github.com/uport-project/veramo/issues/398)) ([9e23a10](https://github.com/uport-project/veramo/commit/9e23a102506792d199fed5820a01290de2474392)) - - -### Features - -* add native resolver for did:key ([#458](https://github.com/uport-project/veramo/issues/458)) ([a026f24](https://github.com/uport-project/veramo/commit/a026f247ad91dcb3a996e0e95b0fe253cf538f8b)), closes [#352](https://github.com/uport-project/veramo/issues/352) -* **did-provider-key:** add did:key provider; fixes [#335](https://github.com/uport-project/veramo/issues/335) ([#351](https://github.com/uport-project/veramo/issues/351)) ([42cd2b0](https://github.com/uport-project/veramo/commit/42cd2b08a2fd21b5b5d7bdfa57dd00ccc7184dc7)), closes [decentralized-identity/did-jwt#78](https://github.com/decentralized-identity/did-jwt/issues/78) From 839562438b220bc60b782a8973e383e0720556b5 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:32:45 -0500 Subject: [PATCH 20/28] Update packages/did-provider-pkh/package.json Co-authored-by: Mircea Nistor --- packages/did-provider-pkh/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index 6c05e70c72..71bd70b72f 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -9,9 +9,9 @@ "extract-api": "yarn veramo dev extract-api" }, "dependencies": { - "@transmute/did-key-ed25519": "^0.3.0-unstable.8", - "@transmute/did-key-secp256k1": "^0.3.0-unstable.8", - "@transmute/did-key-x25519": "^0.3.0-unstable.8", + "@ethersproject/signing-key": "^5.7.0", + "@ethersproject/bignumber": "^5.7.0", + "@ethersproject/transactions": "^5.7.0", "@veramo/core": "^4.0.0", "@veramo/did-manager": "^4.0.0", "debug": "^4.3.3", From c3603c1b511590df8207e2fb177fabbb84c58762 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:33:11 -0500 Subject: [PATCH 21/28] Update packages/did-provider-pkh/package.json Co-authored-by: Mircea Nistor --- packages/did-provider-pkh/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index 71bd70b72f..d084d3680e 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -22,9 +22,6 @@ "@types/debug": "4.1.7", "typescript": "4.7.3" }, - "resolutions": { - "*/**/jsonld": "npm:@digitalcredentials/jsonld@^5.2.1" - }, "files": [ "build/**/*", "src/**/*", From 8a157e8e694db20011bd4b3e7f9ac0c1dfbf7fc5 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:34:20 -0500 Subject: [PATCH 22/28] Update packages/did-provider-pkh/package.json Co-authored-by: Mircea Nistor --- packages/did-provider-pkh/package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index d084d3680e..096e4664dd 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -14,9 +14,7 @@ "@ethersproject/transactions": "^5.7.0", "@veramo/core": "^4.0.0", "@veramo/did-manager": "^4.0.0", - "debug": "^4.3.3", - "multibase": "^4.0.6", - "multicodec": "^3.2.1" + "debug": "^4.3.3" }, "devDependencies": { "@types/debug": "4.1.7", From 62db30e6f7cdadbbf2651f8306e1cb67439e70c9 Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 14:35:39 -0500 Subject: [PATCH 23/28] cleanup unused code --- .../did-provider-pkh/src/pkh-did-provider.ts | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index 7e630eab87..fb32870bf1 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -26,30 +26,14 @@ type IContext = IAgentContext } -// export interface EthrNetworkConfiguration { -// /** -// * The chain ID for the ethereum network being configured. This can be a hex-encoded string starting with `0x`. -// * If `name` is not specified, then the hex encoded `chainId` will be used when creating DIDs, according to the -// * `did:pkh` spec. -// * -// * Example, chainId==42 and name==undefined => DIDs are prefixed with `did:ethr:0x2a:` -// */ -// chainId?: string | number - -// // eslint-disable-next-line @typescript-eslint/no-explicit-any -// [index: string]: any -// } - - - - /** + /** * Helper method that can computes the ethereumAddress corresponding to a Secp256k1 public key. * @param hexPublicKey A hex encoded public key, optionally prefixed with `0x` */ - export function toEthereumAddress(hexPublicKey: string): string { + export function toEthereumAddress(hexPublicKey: string): string { const publicKey = hexPublicKey.startsWith('0x') ? hexPublicKey : '0x' + hexPublicKey return computeAddress(publicKey) - } + } /** From 5a766c4cfbc2e2c945d849eab12d779282d1c00b Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 15:29:13 -0500 Subject: [PATCH 24/28] Cleanup did:pkh provider --- package.json | 3 +- .../did-provider-pkh/src/pkh-did-provider.ts | 13 +- yarn.lock | 178 +----------------- 3 files changed, 12 insertions(+), 182 deletions(-) diff --git a/package.json b/package.json index 90fa097e21..b34e21f811 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "ts-jest": "28.0.4", "ts-json-schema-generator": "1.0.0", "ts-node": "10.8.1", - "typescript": "4.8.4" + "typescript": "4.8.4", + "caip": "^1.1.0" }, "repository": { "type": "git", diff --git a/packages/did-provider-pkh/src/pkh-did-provider.ts b/packages/did-provider-pkh/src/pkh-did-provider.ts index fb32870bf1..6deda53451 100644 --- a/packages/did-provider-pkh/src/pkh-did-provider.ts +++ b/packages/did-provider-pkh/src/pkh-did-provider.ts @@ -22,8 +22,6 @@ type IContext = IAgentContext * If this is not specified, `1` is assumed. */ chainId?: string | number - - } /** @@ -43,18 +41,13 @@ type IContext = IAgentContext */ export class PkhDIDProvider extends AbstractIdentifierProvider { private defaultKms: string - //private networks: EthrNetworkConfiguration[] | undefined constructor(options: { defaultKms: string - //networks?: EthrNetworkConfiguration[] }) { super() this.defaultKms = options.defaultKms - // if (options.networks) { - // this.networks = options.networks - // } } @@ -66,12 +59,8 @@ export class PkhDIDProvider extends AbstractIdentifierProvider { const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' }) const publicAddress = toEthereumAddress(key.publicKeyHex); - // let networkSpecifier = - // options?.network || - // (options?.providerName?.match(/^did:pkh:eip155.+$/) ? options?.providerName?.substring(9) : undefined) - - const network = options?.chainId; // this.getNetworkFor(networkSpecifier) + const network = options?.chainId; if (!network) { throw new Error( `invalid_setup: Cannot create did:pkh. There is no known configuration for network=${network}'`, diff --git a/yarn.lock b/yarn.lock index 52c3859ade..3093ed079e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4700,18 +4700,6 @@ jose "^4.3.8" web-streams-polyfill "^3.0.3" -"@transmute/jose-ld@^0.7.0-unstable.67": - version "0.7.0-unstable.67" - resolved "https://registry.yarnpkg.com/@transmute/jose-ld/-/jose-ld-0.7.0-unstable.67.tgz#c202775f23fc2ab1aeae1e5ee0e71983f541f6ad" - integrity sha512-9xGZpdNEzhBeeZfNnM1y83rN6SQ6tuXgx+WrQF9GoPtyxwcvZlqEqn9DBEiMzleaAC5kmXBbVPXbXv6QxkPyDg== - dependencies: - "@peculiar/webcrypto" "^1.1.6" - "@stablelib/aes-kw" "^1.0.0" - "@stablelib/xchacha20poly1305" "^1.0.0" - base64url "^3.0.1" - jose "^4.3.8" - web-streams-polyfill "^3.0.3" - "@transmute/json-web-signature@^0.7.0-unstable.67": version "0.7.0-unstable.67" resolved "https://registry.yarnpkg.com/@transmute/json-web-signature/-/json-web-signature-0.7.0-unstable.67.tgz#79387d7f2b88e27e13dcf55015a68893ee434431" @@ -4772,11 +4760,6 @@ resolved "https://registry.yarnpkg.com/@transmute/security-context/-/security-context-0.7.0-unstable.67.tgz#51a6a7b34e49f37b512fc61404529579e7806895" integrity sha512-BRfFAcXTBHbBDbnXWofAZSV7bktDMiv0UuJjUiEqt+PkSWFx74UtIYrLxw4HfYPoGWJ6m6I5XBiRZ3L5LVX0XQ== -"@transmute/security-context@^0.7.0-unstable.67": - version "0.7.0-unstable.67" - resolved "https://registry.yarnpkg.com/@transmute/security-context/-/security-context-0.7.0-unstable.67.tgz#51a6a7b34e49f37b512fc61404529579e7806895" - integrity sha512-BRfFAcXTBHbBDbnXWofAZSV7bktDMiv0UuJjUiEqt+PkSWFx74UtIYrLxw4HfYPoGWJ6m6I5XBiRZ3L5LVX0XQ== - "@transmute/web-crypto-key-pair@^0.7.0-unstable.67": version "0.7.0-unstable.67" resolved "https://registry.yarnpkg.com/@transmute/web-crypto-key-pair/-/web-crypto-key-pair-0.7.0-unstable.67.tgz#e3313c2664b2baf097f1c3ba9827ee05259609cb" @@ -6093,11 +6076,6 @@ array-differ@^3.0.0: resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== -array-find-index@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" - integrity sha512-M1HQyIXcBGtVywBt8WVdim+lrNaK7VHp99Qt5pSNziXznKHViIBbXWtfRTpEFpF/c4FdfxNAsCCwPp5phBYJtw== - array-flatten@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" @@ -6617,7 +6595,7 @@ bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== -bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.0, bn.js@^5.2.1: +bn.js@^5.0.0, bn.js@^5.1.1, bn.js@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== @@ -6990,7 +6968,7 @@ cacache@^16.0.0, cacache@^16.0.6, cacache@^16.1.0: tar "^6.1.11" unique-filename "^1.1.1" -caip@~1.1.0: +caip@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/caip/-/caip-1.1.0.tgz#0ccd5bf1bff822459389ccec0a8555712a30c374" integrity sha512-yOO3Fu4ygyKYAdznuoaqschMKIZzcdgyMpBNtrIfrUhnOeaOWG+dh0c13wcOS6B/46IGGbncoyzJlio79jU7rw== @@ -7021,15 +6999,6 @@ camelcase-css@^2.0.1: resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== -camelcase-keys@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-4.2.0.tgz#a2aa5fb1af688758259c32c141426d78923b9b77" - integrity sha512-Ej37YKYbFUI8QiYlvj9YHb6/Z60dZyPJW0Cs8sFilMbd2lP0bw3ylAq9yJkK4lcTA2dID5fG8LjmJYbO7kWb7Q== - dependencies: - camelcase "^4.1.0" - map-obj "^2.0.0" - quick-lru "^1.0.0" - camelcase-keys@^6.2.2: version "6.2.2" resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" @@ -7039,11 +7008,6 @@ camelcase-keys@^6.2.2: map-obj "^4.0.0" quick-lru "^4.0.1" -camelcase@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" - integrity sha512-FxAv7HpHrXbh3aPo4o2qxHay2lkLY3x5Mw3KeE4KQE8ysVfziWeRZDwcjauvwBSGEC/nXUPzZy8zeh4HokqOnw== - camelcase@^5.0.0, camelcase@^5.3.1: version "5.3.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" @@ -8058,13 +8022,6 @@ csstype@^3.0.2: resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2" integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA== -currently-unhandled@^0.4.1: - version "0.4.1" - resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" - integrity sha512-/fITjgjGU50vjQ4FH6eUoYu+iUoUKIXws2hL15JJpIR+BbTxaXQsMuuyjtNh2WqsSBS5nsaZHFsFecyw5CCAng== - dependencies: - array-find-index "^1.0.1" - cwd@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/cwd/-/cwd-0.10.0.tgz#172400694057c22a13b0cf16162c7e4b7a7fe567" @@ -8163,14 +8120,6 @@ debuglog@^1.0.1: resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= -decamelize-keys@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" - integrity sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg== - dependencies: - decamelize "^1.1.0" - map-obj "^1.0.0" - decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" @@ -9184,14 +9133,6 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc= -ethereum-checksum-address@0.0.2: - version "0.0.2" - resolved "https://registry.yarnpkg.com/ethereum-checksum-address/-/ethereum-checksum-address-0.0.2.tgz#46fcb2d962dacd1ed49d7b464408ec26fd183209" - integrity sha512-GAb7mPvGgcfi1j+Bsnwm9af9Z7dLUKp+5cFm88+kMrKACfh9gLatGLVVK5pSGEG2pOGfrmqCRcuh3RtMjIg8GQ== - dependencies: - keccak256 "^1.0.0" - meow "^5.0.0" - ethereum-cryptography@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz#74f2ac0f0f5fe79f012c889b3b8446a9a6264e6d" @@ -9202,16 +9143,6 @@ ethereum-cryptography@^1.1.2: "@scure/bip32" "1.1.0" "@scure/bip39" "1.1.0" -ethereum-public-key-to-address@^0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/ethereum-public-key-to-address/-/ethereum-public-key-to-address-0.0.5.tgz#0d8f7ffbbe0fcd379864afbc46790a273029f691" - integrity sha512-j7k9dP49JuK50PtygiTfqjrZLsk0Hc3Vh5jjqCH8pl4mPfwcQwA9Ds+ie7BXr2JdpFDB3cYR8H/1Rwp0jU5Nxg== - dependencies: - ethereum-checksum-address "0.0.2" - keccak "^3.0.1" - meow "^5.0.0" - secp256k1 "^4.0.2" - ethjs-util@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-util/-/ethjs-util-0.1.6.tgz#f308b62f185f9fe6237132fb2a9818866a5cd536" @@ -10761,11 +10692,6 @@ imurmurhash@^0.1.4: resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= -indent-string@^3.0.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" - integrity sha512-BYqTHXTGUIvg7t1r4sJNKcbDZkL92nkXA8YtRpbjFHRHGDL/NtUeiBJMeE60kIFN/Mg8ESaWQvftaYMGJzQZCQ== - indent-string@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251" @@ -12586,25 +12512,7 @@ just-diff@^5.0.1: resolved "https://registry.yarnpkg.com/just-diff/-/just-diff-5.0.1.tgz#db8fe1cfeea1156f2374bfb289826dca28e7e390" integrity sha512-X00TokkRIDotUIf3EV4xUm6ELc/IkqhS/vPSHdWnsM5y0HoNMfEqrazizI7g78lpHvnRSRt/PFfKtRqJCOGIuQ== -keccak256@^1.0.0: - version "1.0.6" - resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.6.tgz#dd32fb771558fed51ce4e45a035ae7515573da58" - integrity sha512-8GLiM01PkdJVGUhR1e6M/AvWnSqYS0HaERI+K/QtStGDGlSTx2B1zTqZk4Zlqu5TxHJNTxWAdP9Y+WI50OApUw== - dependencies: - bn.js "^5.2.0" - buffer "^6.0.3" - keccak "^3.0.2" - -keccak@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.1.tgz#ae30a0e94dbe43414f741375cff6d64c8bea0bff" - integrity sha512-epq90L9jlFWCW7+pQa6JOnKn2Xgl2mtI664seYR6MHskvI9agt7AnDqmAlp9TqU4/caMYbA08Hi5DMZAl5zdkA== - dependencies: - node-addon-api "^2.0.0" - node-gyp-build "^4.2.0" - readable-stream "^3.6.0" - -keccak@^3.0.1, keccak@^3.0.2: +keccak@3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.2.tgz#4c2c6e8c54e04f2670ee49fa734eb9da152206e0" integrity sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ== @@ -13081,14 +12989,6 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" -loud-rejection@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" - integrity sha512-RPNliZOFkqFumDhvYqOaNY4Uz9oJM2K9tC6JWsJJsNdhuONW4LQHRBpb0qf4pJApVffI5N39SwzWZJuEhfd7eQ== - dependencies: - currently-unhandled "^0.4.1" - signal-exit "^3.0.0" - lower-case@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" @@ -13270,11 +13170,6 @@ map-obj@^1.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= -map-obj@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" - integrity sha512-TzQSV2DiMYgoF5RycneKVUzIa9bQsj/B3tTgsE3dOGqlzHnGIDaC7XBE7grnA+8kZPnfqSGFe95VHc2oc0VFUQ== - map-obj@^4.0.0: version "4.2.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.2.1.tgz#e4ea399dbc979ae735c83c863dd31bdf364277b7" @@ -13328,21 +13223,6 @@ memfs@^3.1.2, memfs@^3.4.3: dependencies: fs-monkey "1.0.3" -meow@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/meow/-/meow-5.0.0.tgz#dfc73d63a9afc714a5e371760eb5c88b91078aa4" - integrity sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig== - dependencies: - camelcase-keys "^4.0.0" - decamelize-keys "^1.0.0" - loud-rejection "^1.0.0" - minimist-options "^3.0.1" - normalize-package-data "^2.3.4" - read-pkg-up "^3.0.0" - redent "^2.0.0" - trim-newlines "^2.0.0" - yargs-parser "^10.0.0" - meow@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/meow/-/meow-7.1.1.tgz#7c01595e3d337fcb0ec4e8eed1666ea95903d306" @@ -13525,14 +13405,6 @@ minimist-options@4.1.0: is-plain-obj "^1.1.0" kind-of "^6.0.3" -minimist-options@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-3.0.2.tgz#fba4c8191339e13ecf4d61beb03f070103f3d954" - integrity sha512-FyBrT/d0d4+uiZRbqznPXqw3IpZZG3gl3wKWiX784FycUKVwBt0uLBFkQrtE4tZOrgo78nZp2jnKz3L65T5LdQ== - dependencies: - arrify "^1.0.1" - is-plain-obj "^1.1.0" - minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -13927,7 +13799,7 @@ nopt@^5.0.0: dependencies: abbrev "1" -normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: +normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -15026,13 +14898,6 @@ pkg-up@^3.1.0: dependencies: find-up "^3.0.0" -pkh-did-resolver@^1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/pkh-did-resolver/-/pkh-did-resolver-1.0.10.tgz#f0144aaaf88af4d573ac23b050d77d8edaa879e8" - integrity sha512-GYfZxFQXFfuVUcztZJuf73tjr3L9nRvzvnoAtKIGREHkpEzj801WQ41OJ7PmsTyIDakaHfXyI3WyX33DUsenTw== - dependencies: - caip "~1.1.0" - postcss-attribute-case-insensitive@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/postcss-attribute-case-insensitive/-/postcss-attribute-case-insensitive-5.0.1.tgz#86d323c77ab8896ed90500071c2c8329fba64fda" @@ -15924,11 +15789,6 @@ queue-microtask@^1.2.2, queue-microtask@^1.2.3: resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== -quick-lru@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" - integrity sha512-tRS7sTgyxMXtLum8L65daJnHUhfDUgboRdcWW2bR9vBfrj2+O5HSMbQOJfJJjIVSPFqbBCF37FpwWXGitDc5tA== - quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -16278,14 +16138,6 @@ recursive-readdir@^2.2.2: dependencies: minimatch "3.0.4" -redent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/redent/-/redent-2.0.0.tgz#c1b2007b42d57eb1389079b3c8333639d5e1ccaa" - integrity sha512-XNwrTx77JQCEMXTeb8movBKuK75MgH0RZkujNuDKCezemx/voapl9i2gCSi8WWm8+ox5ycJi1gxF22fR7c0Ciw== - dependencies: - indent-string "^3.0.0" - strip-indent "^2.0.0" - redent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" @@ -17526,11 +17378,6 @@ strip-hex-prefix@1.0.0: dependencies: is-hex-prefixed "1.0.0" -strip-indent@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" - integrity sha512-RsSNPLpq6YUL7QYy44RnPVTn/lcVZtb48Uof3X5JLbF4zD/Gs7ZFDv2HWol+leoQN2mT86LAzSshGfkTlSOpsA== - strip-indent@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" @@ -17986,11 +17833,6 @@ treeverse@^2.0.0: resolved "https://registry.yarnpkg.com/treeverse/-/treeverse-2.0.0.tgz#036dcef04bc3fd79a9b79a68d4da03e882d8a9ca" integrity sha512-N5gJCkLu1aXccpOTtqV6ddSEi6ZmGkh3hjmbu1IjcavJK4qyOVQmi0myQKM7z5jVGmD68SJoliaVrMmVObhj6A== -trim-newlines@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" - integrity sha512-MTBWv3jhVjTU7XR3IQHllbiJs8sc75a80OEhB6or/q7pLTWgQ0bMGQXXYQSrSuXe6WiKWDZ5txXY5P59a/coVA== - trim-newlines@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.1.tgz#260a5d962d8b752425b32f3a7db0dcacd176c144" @@ -18222,6 +18064,11 @@ typeorm@^0.3.10: xml2js "^0.4.23" yargs "^17.3.1" +typescript@4.7.3: + version "4.7.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.3.tgz#8364b502d5257b540f9de4c40be84c98e23a129d" + integrity sha512-WOkT3XYvrpXx4vMMqlD+8R8R37fZkjyLGlxavMc4iB8lrl8L0DeTcHbYgw/v0N/z9wAFsgBhcsF0ruoySS22mA== + typescript@4.8.4: version "4.8.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" @@ -19258,13 +19105,6 @@ yargs-parser@20.2.4: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== -yargs-parser@^10.0.0: - version "10.1.0" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-10.1.0.tgz#7202265b89f7e9e9f2e5765e0fe735a905edbaa8" - integrity sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ== - dependencies: - camelcase "^4.1.0" - yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" From 6f2ec80183da42d833e9ccdf30cd8f107ea724ca Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Mon, 21 Nov 2022 15:32:19 -0500 Subject: [PATCH 25/28] remove tsdoc-metadata.json --- packages/did-provider-ion/dist/tsdoc-metadata.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 packages/did-provider-ion/dist/tsdoc-metadata.json diff --git a/packages/did-provider-ion/dist/tsdoc-metadata.json b/packages/did-provider-ion/dist/tsdoc-metadata.json deleted file mode 100644 index 1d96152afd..0000000000 --- a/packages/did-provider-ion/dist/tsdoc-metadata.json +++ /dev/null @@ -1,11 +0,0 @@ -// This file is read by tools that parse documentation comments conforming to the TSDoc standard. -// It should be published with your NPM package. It should not be tracked by Git. -{ - "tsdocVersion": "0.12", - "toolPackages": [ - { - "packageName": "@microsoft/api-extractor", - "packageVersion": "7.25.0" - } - ] -} From 54e1c88daa3ca4bb7cf0b42032fe565ed731872c Mon Sep 17 00:00:00 2001 From: dchagastelles Date: Tue, 22 Nov 2022 16:52:16 -0500 Subject: [PATCH 26/28] fix browser tests --- packages/test-react-app/src/veramo/setup.ts | 5 +++++ scripts/prepare-react-test.sh | 1 + 2 files changed, 6 insertions(+) diff --git a/packages/test-react-app/src/veramo/setup.ts b/packages/test-react-app/src/veramo/setup.ts index 32f7bfc93b..e1b06dad02 100644 --- a/packages/test-react-app/src/veramo/setup.ts +++ b/packages/test-react-app/src/veramo/setup.ts @@ -28,6 +28,7 @@ import { VeramoEd25519Signature2018, } from '@veramo/credential-ld' import { getDidKeyResolver, KeyDIDProvider } from '@veramo/did-provider-key' +import { getDidPkhResolver, PkhDIDProvider } from '@veramo/did-provider-pkh' import { DIDComm, DIDCommMessageHandler, IDIDComm } from '@veramo/did-comm' import { ISelectiveDisclosure, SdrMessageHandler, SelectiveDisclosure } from '@veramo/selective-disclosure' import { KeyManagementSystem, SecretBox } from '@veramo/kms-local' @@ -64,6 +65,7 @@ export function getAgent(options?: IAgentOptions): TAgent { ...ethrDidResolver({ infuraProjectId: INFURA_PROJECT_ID }), ...webDidResolver(), ...getDidKeyResolver(), + ...getDidPkhResolver(), ...new FakeDidResolver(() => agent as TAgent).getDidFakeResolver(), }), }), @@ -106,6 +108,9 @@ export function getAgent(options?: IAgentOptions): TAgent { 'did:key': new KeyDIDProvider({ defaultKms: 'local', }), + 'did:pkh': new PkhDIDProvider({ + defaultKms: 'local', + }), 'did:fake': new FakeDidProvider(), }, }), diff --git a/scripts/prepare-react-test.sh b/scripts/prepare-react-test.sh index 36268181ec..387f7e8f5b 100644 --- a/scripts/prepare-react-test.sh +++ b/scripts/prepare-react-test.sh @@ -15,6 +15,7 @@ packages=( "did-manager" "did-provider-ethr" "did-provider-key" +"did-provider-pkh" "did-provider-web" "did-resolver" "key-manager" From 2194a84fa71585c4804b7af6736683a20457a651 Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Mon, 28 Nov 2022 18:48:10 +0100 Subject: [PATCH 27/28] chore(deps): use same typescript package --- packages/did-provider-pkh/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/did-provider-pkh/package.json b/packages/did-provider-pkh/package.json index 096e4664dd..5c5761a427 100644 --- a/packages/did-provider-pkh/package.json +++ b/packages/did-provider-pkh/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@types/debug": "4.1.7", - "typescript": "4.7.3" + "typescript": "4.8.4" }, "files": [ "build/**/*", From f64690cc1c4cfd78c485ec7a991ed69d73b2f85c Mon Sep 17 00:00:00 2001 From: Mircea Nistor Date: Tue, 29 Nov 2022 11:00:49 +0100 Subject: [PATCH 28/28] fix: typo in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 81dcd40d12..a9fc1e416e 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "rimraf": "3.0.2", "semantic-release": "19.0.3", "ts-jest": "28.0.4", - "caip": "^1.1.0" + "caip": "^1.1.0", "ts-json-schema-generator": "1.1.2", "ts-node": "10.9.1", "typescript": "4.9.3"