From 1f3b5e9359212ef3a94b488a29983a36189eeb60 Mon Sep 17 00:00:00 2001 From: Andrew Nikitin Date: Wed, 31 Jan 2024 17:41:17 +0100 Subject: [PATCH] feat: Allow to switch DID controllers [DEV-3586] (#400) * Allow DID controller switching * Add the same logic for deactivation and resource creation * Accept publicKeyHexs as a parameter deactivate and resource creation interfaces * Making refactorings and changes due to discussion * Change log severity level to debuf * Fix review comments * Bump + removed dead imports --------- Co-authored-by: Tasos Derisiotis <50984242+Eengineer1@users.noreply.github.com> --- package-lock.json | 543 ++++++++++++------------- package.json | 4 +- src/agent/ICheqd.ts | 13 +- src/did-manager/cheqd-did-provider.ts | 550 ++++++++++++++++++++++---- src/utils/helpers.ts | 14 + 5 files changed, 759 insertions(+), 365 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8c7d32b..3509d02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cheqd/did-provider-cheqd", - "version": "3.6.16-develop.1", + "version": "3.6.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cheqd/did-provider-cheqd", - "version": "3.6.16-develop.1", + "version": "3.6.16", "license": "Apache-2.0", "dependencies": { "@cheqd/sdk": "^3.7.9", @@ -40,7 +40,7 @@ "@semantic-release/release-notes-generator": "^12.1.0", "@types/debug": "^4.1.12", "@types/jest": "^29.5.11", - "@types/uuid": "^9.0.7", + "@types/uuid": "^9.0.8", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "conventional-changelog-conventionalcommits": "^7.0.2", @@ -51,7 +51,7 @@ "long": "^4.0.0", "prettier": "^3.2.4", "semantic-release": "^22.0.12", - "ts-jest": "^29.1.1", + "ts-jest": "^29.1.2", "typescript": "^5.3.3" }, "engines": { @@ -184,9 +184,9 @@ } }, "node_modules/@babel/core": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.7.tgz", - "integrity": "sha512-+UpDgowcmqe36d4NwqvKsyPMlOLNGMsfMmQ5WGCu+siCe3t3dfe9njrzGfdN4qq+bcNUt0+Vw6haRxBOycs4dw==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.23.9.tgz", + "integrity": "sha512-5q0175NOjddqpvvzU+kDiSOAk4PfdO6FvwCWoQ6RO7rTzEe8vlo+4HVfcnAREhD4npMs0e9uZypjTwzZPCf/cw==", "dev": true, "dependencies": { "@ampproject/remapping": "^2.2.0", @@ -194,11 +194,11 @@ "@babel/generator": "^7.23.6", "@babel/helper-compilation-targets": "^7.23.6", "@babel/helper-module-transforms": "^7.23.3", - "@babel/helpers": "^7.23.7", - "@babel/parser": "^7.23.6", - "@babel/template": "^7.22.15", - "@babel/traverse": "^7.23.7", - "@babel/types": "^7.23.6", + "@babel/helpers": "^7.23.9", + "@babel/parser": "^7.23.9", + "@babel/template": "^7.23.9", + "@babel/traverse": "^7.23.9", + "@babel/types": "^7.23.9", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -388,14 +388,14 @@ } }, "node_modules/@babel/helpers": { - "version": "7.23.8", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.8.tgz", - "integrity": "sha512-KDqYz4PiOWvDFrdHLPhKtCThtIcKVy6avWD2oG4GEvyQ+XDZwHD4YQd+H2vNMnq2rkdxsDkU82T+Vk8U/WXHRQ==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.23.9.tgz", + "integrity": "sha512-87ICKgU5t5SzOT7sBMfCOZQ2rHjRU+Pcb9BoILMYz600W6DkVRLFBPwQ18gwUVvggqXivaUakpnxWQGbpywbBQ==", "dev": true, "dependencies": { - "@babel/template": "^7.22.15", - "@babel/traverse": "^7.23.7", - "@babel/types": "^7.23.6" + "@babel/template": "^7.23.9", + "@babel/traverse": "^7.23.9", + "@babel/types": "^7.23.9" }, "engines": { "node": ">=6.9.0" @@ -487,9 +487,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.23.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.6.tgz", - "integrity": "sha512-Z2uID7YJ7oNvAI20O9X0bblw7Qqs8Q2hFy0R9tAfnfLkp5MW0UH9eUvnDSnFwKZ0AvgS1ucqR4KzvVHgnke1VQ==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.9.tgz", + "integrity": "sha512-9tcKgqKbs3xGJ+NtKF2ndOBBLVwPjl1SHxPQkd36r3Dlirw3xWUeGaTbqr7uGZcTaxkVNwc+03SVP7aCdWrTlA==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -676,23 +676,23 @@ } }, "node_modules/@babel/template": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", - "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.23.9.tgz", + "integrity": "sha512-+xrD2BWLpvHKNmX2QbpdpsBaWnRxahMwJjO+KZk2JOElj5nSmKezyS1B4u+QbHMTX69t4ukm6hh9lsYQ7GHCKA==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.13", - "@babel/parser": "^7.22.15", - "@babel/types": "^7.22.15" + "@babel/code-frame": "^7.23.5", + "@babel/parser": "^7.23.9", + "@babel/types": "^7.23.9" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.23.7", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.7.tgz", - "integrity": "sha512-tY3mM8rH9jM0YHFGyfC0/xf+SB5eKUu7HPj7/k3fpi9dAlsMc5YbQvDi0Sh2QTPXqMhyaAtzAr807TIyfQrmyg==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.9.tgz", + "integrity": "sha512-I/4UJ9vs90OkBtY6iiiTORVMyIhJ4kAVmsKo9KFc8UOxMeUfi2hvtIBsET5u9GizXE6/GFSuKCTNfgCswuEjRg==", "dev": true, "dependencies": { "@babel/code-frame": "^7.23.5", @@ -701,8 +701,8 @@ "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.23.6", - "@babel/types": "^7.23.6", + "@babel/parser": "^7.23.9", + "@babel/types": "^7.23.9", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -720,9 +720,9 @@ } }, "node_modules/@babel/types": { - "version": "7.23.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.6.tgz", - "integrity": "sha512-+uarb83brBzPKN38NX1MkB6vb6+mwvR6amUulqAE7ccQw1pEl+bCia9TbdG1lsnFP7lZySvUn37CHyXQdfTwzg==", + "version": "7.23.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.9.tgz", + "integrity": "sha512-dQjSq/7HaSjRM43FFGnv5keM2HsxpmyV1PfaSVm0nzzjwwTmjOe6J4bC8e3+pTEIgHaHj+1ZlLThRJ2auc/w1Q==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.23.4", @@ -2352,9 +2352,9 @@ "dev": true }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.21", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.21.tgz", - "integrity": "sha512-SRfKmRe1KvYnxjEMtxEr+J4HIeMX5YBg/qhRHpxEIGjhX1rshcHlnFUE9K0GazhVKWM7B+nARSkV8LuvJdJ5/g==", + "version": "0.3.22", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz", + "integrity": "sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==", "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", @@ -3237,6 +3237,7 @@ "version": "10.16.4", "resolved": "https://registry.npmjs.org/@motionone/vue/-/vue-10.16.4.tgz", "integrity": "sha512-z10PF9JV6SbjFq+/rYabM+8CVlMokgl8RFGvieSGNTmrkQanfHn+15XBrhG3BgUfvmTeSeyShfOHpG0i9zEdcg==", + "deprecated": "Motion One for Vue is deprecated. Use Oku Motion instead https://oku-ui.com/motion", "dependencies": { "@motionone/dom": "^10.16.4", "tslib": "^2.3.1" @@ -3340,9 +3341,9 @@ } }, "node_modules/@octokit/core": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.2.tgz", - "integrity": "sha512-cZUy1gUvd4vttMic7C0lwPed8IYXWYp8kHIMatyhY8t8n3Cpw2ILczkV5pGMPqef7v0bLo0pOHrEHarsau2Ydg==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.1.0.tgz", + "integrity": "sha512-BDa2VAMLSh3otEiaMJ/3Y36GU4qf6GI+VivQ/P41NC6GHcdxpKlqV0ikSZ5gdQsmS3ojXeRx5vasgNTinF0Q4g==", "dev": true, "dependencies": { "@octokit/auth-token": "^4.0.0", @@ -3681,9 +3682,9 @@ } }, "node_modules/@parcel/watcher-wasm": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.3.0.tgz", - "integrity": "sha512-ejBAX8H0ZGsD8lSICDNyMbSEtPMWgDL0WFCt/0z7hyf5v8Imz4rAM8xY379mBsECkq/Wdqa5WEDLqtjZ+6NxfA==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.4.0.tgz", + "integrity": "sha512-MNgQ4WCbBybqQ97KwR/hqJGYTg3+s8qHpgIyFWB2qJOBvoJWbXuJGmm4ZkPLq2bMaANqCZqrXwmKYagZTkMKZA==", "bundleDependencies": [ "napi-wasm" ], @@ -3763,9 +3764,12 @@ } }, "node_modules/@parcel/watcher/node_modules/node-addon-api": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz", - "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA==" + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.0.tgz", + "integrity": "sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==", + "engines": { + "node": "^16 || ^18 || >= 20" + } }, "node_modules/@pnpm/config.env-replace": { "version": "1.1.0", @@ -4314,9 +4318,9 @@ } }, "node_modules/@sinonjs/commons": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.0.tgz", - "integrity": "sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-3.0.1.tgz", + "integrity": "sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==", "dev": true, "dependencies": { "type-detect": "4.0.8" @@ -4779,9 +4783,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.11.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.5.tgz", - "integrity": "sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==", + "version": "20.11.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.13.tgz", + "integrity": "sha512-5G4zQwdiQBSWYTDAH1ctw2eidqdhMJaNsiIDKHFr55ihz5Trl2qqR8fdrT732yPBho5gkNxXm67OxWFBqX9aPg==", "dependencies": { "undici-types": "~5.26.4" } @@ -4818,9 +4822,9 @@ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==" }, "node_modules/@types/uuid": { - "version": "9.0.7", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.7.tgz", - "integrity": "sha512-WUtIVRUZ9i5dYXefDEAI7sh9/O7jGvHg7Df/5O/gtH3Yabe5odI3UWopVR1qbPXQtvOxWu3mM4XxlYeZtMWF4g==", + "version": "9.0.8", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz", + "integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA==", "dev": true }, "node_modules/@types/yargs": { @@ -6050,9 +6054,9 @@ } }, "node_modules/axios": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.5.tgz", - "integrity": "sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz", + "integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==", "dependencies": { "follow-redirects": "^1.15.4", "form-data": "^4.0.0", @@ -6347,9 +6351,9 @@ "integrity": "sha512-+12sHB+Br8HIh6VAMVEG5r3UXCyESIgDW7kzk3BjIXa43DVqVwL7GC5TW3jeh+72dtcH99pPVpw0X8i0jt+/kw==" }, "node_modules/browserslist": { - "version": "4.22.2", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.2.tgz", - "integrity": "sha512-0UgcrvQmBDvZHFGdYUehrCNIazki7/lUP3kkoi/r3YB2amZbFM9J43ZRkJTXBUZK4gmx56+Sqk9+Vs9mwZx9+A==", + "version": "4.22.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.22.3.tgz", + "integrity": "sha512-UAp55yfwNv0klWNapjs/ktHoguxuQNGnOzxYmfnXIS+8AsRDZkSDxg7R1AX3GKzn078SBI5dzwzj/Yx0Or0e3A==", "dev": true, "funding": [ { @@ -6366,8 +6370,8 @@ } ], "dependencies": { - "caniuse-lite": "^1.0.30001565", - "electron-to-chromium": "^1.4.601", + "caniuse-lite": "^1.0.30001580", + "electron-to-chromium": "^1.4.648", "node-releases": "^2.0.14", "update-browserslist-db": "^1.0.13" }, @@ -6458,9 +6462,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001578", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001578.tgz", - "integrity": "sha512-J/jkFgsQ3NEl4w2lCoM9ZPxrD+FoBNJ7uJUpGVjIg/j0OwJosWM36EPDv+Yyi0V4twBk9pPmlFS+PLykgEvUmg==", + "version": "1.0.30001581", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001581.tgz", + "integrity": "sha512-whlTkwhqV2tUmP3oYhtNfaWGYHDdS3JYFQBKXxcUR9qqPWsRhFHhoISO2Xnl/g0xyKzht9mI1LZpiNWfMzHixQ==", "dev": true, "funding": [ { @@ -7089,6 +7093,11 @@ "node": ">= 8" } }, + "node_modules/crossws": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/crossws/-/crossws-0.1.1.tgz", + "integrity": "sha512-c9c/o7bS3OjsdpSkvexpka0JNlesBF2JU9B2V1yNsYGwRbAafxhJQ7VI9b48D5bpONz/oxbPGMzBojy9sXoQIQ==" + }, "node_modules/crypto-random-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-4.0.0.tgz", @@ -7454,9 +7463,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.635", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.635.tgz", - "integrity": "sha512-iu/2D0zolKU3iDGXXxdOzNf72Jnokn+K1IN6Kk4iV6l1Tr2g/qy+mvmtfAiBwZe5S3aB5r92vp+zSZ69scYRrg==", + "version": "1.4.651", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.651.tgz", + "integrity": "sha512-jjks7Xx+4I7dslwsbaFocSwqBbGHQmuXBJUK9QBZTIrzPq3pzn6Uf2szFSP728FtLYE3ldiccmlkOM/zhGKCpA==", "dev": true }, "node_modules/elliptic": { @@ -8126,9 +8135,9 @@ } }, "node_modules/fastq": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", - "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.0.tgz", + "integrity": "sha512-zGygtijUMT7jnk3h26kUms3BkSDp4IfIKjmnqI2tvx6nuBfiF1UqOxbnLfzdv+apBy+53oaImsKtMw/xYbW+1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -8599,18 +8608,19 @@ "dev": true }, "node_modules/h3": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/h3/-/h3-1.10.0.tgz", - "integrity": "sha512-Tw1kcIC+AeimwRmviiObaD5EB430Yt+lTgOxLJxNr96Vd/fGRu04EF7aKfOAcpwKCI+U2JlbxOLhycD86p3Ciw==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/h3/-/h3-1.10.1.tgz", + "integrity": "sha512-UBAUp47hmm4BB5/njB4LrEa9gpuvZj4/Qf/ynSMzO6Ku2RXaouxEfiG2E2IFnv6fxbhAkzjasDxmo6DFdEeXRg==", "dependencies": { "cookie-es": "^1.0.0", - "defu": "^6.1.3", + "defu": "^6.1.4", "destr": "^2.0.2", "iron-webcrypto": "^1.0.0", + "ohash": "^1.1.3", "radix3": "^1.1.0", "ufo": "^1.3.2", "uncrypto": "^0.1.3", - "unenv": "^1.8.0" + "unenv": "^1.9.0" } }, "node_modules/hamt-sharding": { @@ -8771,9 +8781,9 @@ } }, "node_modules/hosted-git-info/node_modules/lru-cache": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", - "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", "dev": true, "engines": { "node": "14 || >=16.14" @@ -9293,17 +9303,13 @@ } }, "node_modules/ipfs-unixfs": { - "version": "11.1.2", - "resolved": "https://registry.npmjs.org/ipfs-unixfs/-/ipfs-unixfs-11.1.2.tgz", - "integrity": "sha512-HVjrACOhU8RgMskcrfydk+FDAE9pFKr8tneKLaVYQ2f81HUKXoiSdgsAJY/jt7Ieyj4tE12TZGduIeWtNpScOw==", + "version": "11.1.3", + "resolved": "https://registry.npmjs.org/ipfs-unixfs/-/ipfs-unixfs-11.1.3.tgz", + "integrity": "sha512-sy6Koojwm/EcM8yvDlycRYA89C8wIcLcGTMMpqnCPUtqTCdl+JxsuPNCBgAu7tmO8Nipm7Tv7f0g/erxTGKKRA==", "dependencies": { "err-code": "^3.0.1", "protons-runtime": "^5.0.0", "uint8arraylist": "^2.4.3" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.0.0" } }, "node_modules/ipfs-unixfs-importer": { @@ -10633,9 +10639,9 @@ } }, "node_modules/jsonc-parser": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.0.tgz", - "integrity": "sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==" + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/jsonc-parser/-/jsonc-parser-3.2.1.tgz", + "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==" }, "node_modules/jsonfile": { "version": "6.1.0", @@ -11016,23 +11022,24 @@ "dev": true }, "node_modules/listhen": { - "version": "1.5.6", - "resolved": "https://registry.npmjs.org/listhen/-/listhen-1.5.6.tgz", - "integrity": "sha512-gTpEJhT5L85L0bFgmu+Boqu5rP4DwDtEb4Exq5gdQUxWRwx4jbzdInZkmyLONo5EwIcQB0k7ZpWlpCDPdL77EQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/listhen/-/listhen-1.6.0.tgz", + "integrity": "sha512-z0RcEXVX5oTpY1bO02SKoTU/kmZSrFSngNNzHRM6KICR17PTq7ANush6AE6ztGJwJD4RLpBrVHd9GnV51J7s3w==", "dependencies": { - "@parcel/watcher": "^2.3.0", - "@parcel/watcher-wasm": "2.3.0", + "@parcel/watcher": "^2.4.0", + "@parcel/watcher-wasm": "2.4.0", "citty": "^0.1.5", "clipboardy": "^4.0.0", "consola": "^3.2.3", + "crossws": "^0.1.0", "defu": "^6.1.4", "get-port-please": "^3.1.2", - "h3": "^1.10.0", + "h3": "^1.10.1", "http-shutdown": "^1.2.2", "jiti": "^1.21.0", - "mlly": "^1.4.2", + "mlly": "^1.5.0", "node-forge": "^1.3.1", - "pathe": "^1.1.1", + "pathe": "^1.1.2", "std-env": "^3.7.0", "ufo": "^1.3.2", "untun": "^0.1.3", @@ -11741,9 +11748,9 @@ } }, "node_modules/npm": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/npm/-/npm-10.3.0.tgz", - "integrity": "sha512-9u5GFc1UqI2DLlGI7QdjkpIaBs3UhTtY8KoCqYJK24gV/j/tByaI4BA4R7RkOc+ASqZMzFPKt4Pj2Z8JcGo//A==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/npm/-/npm-10.4.0.tgz", + "integrity": "sha512-RS7Mx0OVfXlOcQLRePuDIYdFCVBPCNapWHplDK+mh7GDdP/Tvor4ocuybRRPSvfcRb2vjRJt1fHCqw3cr8qACQ==", "bundleDependencies": [ "@isaacs/string-locale-compare", "@npmcli/arborist", @@ -11807,7 +11814,6 @@ "semver", "spdx-expression-parse", "ssri", - "strip-ansi", "supports-color", "tar", "text-table", @@ -11826,8 +11832,8 @@ "@npmcli/map-workspaces": "^3.0.4", "@npmcli/package-json": "^5.0.0", "@npmcli/promise-spawn": "^7.0.1", - "@npmcli/run-script": "^7.0.3", - "@sigstore/tuf": "^2.2.0", + "@npmcli/run-script": "^7.0.4", + "@sigstore/tuf": "^2.3.0", "abbrev": "^2.0.0", "archy": "~1.0.0", "cacache": "^18.0.2", @@ -11873,7 +11879,7 @@ "npm-user-validate": "^2.0.0", "npmlog": "^7.0.1", "p-map": "^4.0.0", - "pacote": "^17.0.5", + "pacote": "^17.0.6", "parse-conflict-json": "^3.0.1", "proc-log": "^3.0.0", "qrcode-terminal": "^0.12.0", @@ -11881,7 +11887,6 @@ "semver": "^7.5.4", "spdx-expression-parse": "^3.0.1", "ssri": "^10.0.5", - "strip-ansi": "^7.1.0", "supports-color": "^9.4.0", "tar": "^6.2.0", "text-table": "~0.2.0", @@ -11938,6 +11943,18 @@ "node": ">=12" } }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.0.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", "dev": true, @@ -11961,6 +11978,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm/node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "dev": true, + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/npm/node_modules/@isaacs/string-locale-compare": { "version": "1.1.0", "dev": true, @@ -11984,7 +12016,7 @@ } }, "node_modules/npm/node_modules/@npmcli/arborist": { - "version": "7.3.0", + "version": "7.3.1", "dev": true, "inBundle": true, "license": "ISC", @@ -12016,7 +12048,7 @@ "parse-conflict-json": "^3.0.0", "proc-log": "^3.0.0", "promise-all-reject-late": "^1.0.0", - "promise-call-limit": "^1.0.2", + "promise-call-limit": "^3.0.1", "read-package-json-fast": "^3.0.2", "semver": "^7.3.7", "ssri": "^10.0.5", @@ -12214,15 +12246,15 @@ } }, "node_modules/npm/node_modules/@npmcli/run-script": { - "version": "7.0.3", + "version": "7.0.4", "dev": true, "inBundle": true, "license": "ISC", "dependencies": { "@npmcli/node-gyp": "^3.0.0", + "@npmcli/package-json": "^5.0.0", "@npmcli/promise-spawn": "^7.0.0", "node-gyp": "^10.0.0", - "read-package-json-fast": "^3.0.0", "which": "^4.0.0" }, "engines": { @@ -12240,7 +12272,7 @@ } }, "node_modules/npm/node_modules/@sigstore/bundle": { - "version": "2.1.0", + "version": "2.1.1", "dev": true, "inBundle": true, "license": "Apache-2.0", @@ -12251,6 +12283,15 @@ "node": "^16.14.0 || >=18.0.0" } }, + "node_modules/npm/node_modules/@sigstore/core": { + "version": "0.2.0", + "dev": true, + "inBundle": true, + "license": "Apache-2.0", + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, "node_modules/npm/node_modules/@sigstore/protobuf-specs": { "version": "0.2.1", "dev": true, @@ -12261,12 +12302,13 @@ } }, "node_modules/npm/node_modules/@sigstore/sign": { - "version": "2.2.0", + "version": "2.2.1", "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@sigstore/bundle": "^2.1.0", + "@sigstore/bundle": "^2.1.1", + "@sigstore/core": "^0.2.0", "@sigstore/protobuf-specs": "^0.2.1", "make-fetch-happen": "^13.0.0" }, @@ -12275,13 +12317,27 @@ } }, "node_modules/npm/node_modules/@sigstore/tuf": { - "version": "2.2.0", + "version": "2.3.0", "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { "@sigstore/protobuf-specs": "^0.2.1", - "tuf-js": "^2.1.0" + "tuf-js": "^2.2.0" + }, + "engines": { + "node": "^16.14.0 || >=18.0.0" + } + }, + "node_modules/npm/node_modules/@sigstore/verify": { + "version": "0.1.0", + "dev": true, + "inBundle": true, + "license": "Apache-2.0", + "dependencies": { + "@sigstore/bundle": "^2.1.1", + "@sigstore/core": "^0.2.0", + "@sigstore/protobuf-specs": "^0.2.1" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -12344,15 +12400,12 @@ } }, "node_modules/npm/node_modules/ansi-regex": { - "version": "6.0.1", + "version": "5.0.1", "dev": true, "inBundle": true, "license": "MIT", "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" + "node": ">=8" } }, "node_modules/npm/node_modules/ansi-styles": { @@ -12529,27 +12582,6 @@ "node": ">= 10" } }, - "node_modules/npm/node_modules/cli-columns/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/cli-columns/node_modules/strip-ansi": { - "version": "6.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/npm/node_modules/cli-table3": { "version": "0.6.3", "dev": true, @@ -12623,27 +12655,6 @@ "node": ">=8.0.0" } }, - "node_modules/npm/node_modules/columnify/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/columnify/node_modules/strip-ansi": { - "version": "6.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/npm/node_modules/common-ancestor-path": { "version": "1.0.1", "dev": true, @@ -12849,27 +12860,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/npm/node_modules/gauge/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/gauge/node_modules/strip-ansi": { - "version": "6.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/npm/node_modules/glob": { "version": "10.3.10", "dev": true, @@ -13164,7 +13154,7 @@ } }, "node_modules/npm/node_modules/libnpmdiff": { - "version": "6.0.5", + "version": "6.0.6", "dev": true, "inBundle": true, "license": "ISC", @@ -13184,7 +13174,7 @@ } }, "node_modules/npm/node_modules/libnpmexec": { - "version": "7.0.6", + "version": "7.0.7", "dev": true, "inBundle": true, "license": "ISC", @@ -13206,7 +13196,7 @@ } }, "node_modules/npm/node_modules/libnpmfund": { - "version": "5.0.3", + "version": "5.0.4", "dev": true, "inBundle": true, "license": "ISC", @@ -13244,7 +13234,7 @@ } }, "node_modules/npm/node_modules/libnpmpack": { - "version": "6.0.5", + "version": "6.0.6", "dev": true, "inBundle": true, "license": "ISC", @@ -13259,7 +13249,7 @@ } }, "node_modules/npm/node_modules/libnpmpublish": { - "version": "9.0.3", + "version": "9.0.4", "dev": true, "inBundle": true, "license": "ISC", @@ -13270,7 +13260,7 @@ "npm-registry-fetch": "^16.0.0", "proc-log": "^3.0.0", "semver": "^7.3.7", - "sigstore": "^2.1.0", + "sigstore": "^2.2.0", "ssri": "^10.0.5" }, "engines": { @@ -13766,7 +13756,7 @@ } }, "node_modules/npm/node_modules/pacote": { - "version": "17.0.5", + "version": "17.0.6", "dev": true, "inBundle": true, "license": "ISC", @@ -13786,7 +13776,7 @@ "promise-retry": "^2.0.1", "read-package-json": "^7.0.0", "read-package-json-fast": "^3.0.0", - "sigstore": "^2.0.0", + "sigstore": "^2.2.0", "ssri": "^10.0.0", "tar": "^6.1.11" }, @@ -13868,7 +13858,7 @@ } }, "node_modules/npm/node_modules/promise-call-limit": { - "version": "1.0.2", + "version": "3.0.1", "dev": true, "inBundle": true, "license": "ISC", @@ -14047,15 +14037,17 @@ } }, "node_modules/npm/node_modules/sigstore": { - "version": "2.1.0", + "version": "2.2.0", "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { - "@sigstore/bundle": "^2.1.0", + "@sigstore/bundle": "^2.1.1", + "@sigstore/core": "^0.2.0", "@sigstore/protobuf-specs": "^0.2.1", - "@sigstore/sign": "^2.1.0", - "@sigstore/tuf": "^2.1.0" + "@sigstore/sign": "^2.2.1", + "@sigstore/tuf": "^2.3.0", + "@sigstore/verify": "^0.1.0" }, "engines": { "node": "^16.14.0 || >=18.0.0" @@ -14172,37 +14164,7 @@ "node": ">=8" } }, - "node_modules/npm/node_modules/string-width-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/string-width-cjs/node_modules/strip-ansi": { - "version": "6.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/string-width/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/npm/node_modules/string-width/node_modules/strip-ansi": { + "node_modules/npm/node_modules/strip-ansi": { "version": "6.0.1", "dev": true, "inBundle": true, @@ -14214,21 +14176,6 @@ "node": ">=8" } }, - "node_modules/npm/node_modules/strip-ansi": { - "version": "7.1.0", - "dev": true, - "inBundle": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/npm/node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", @@ -14242,15 +14189,6 @@ "node": ">=8" } }, - "node_modules/npm/node_modules/strip-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/npm/node_modules/supports-color": { "version": "9.4.0", "dev": true, @@ -14335,7 +14273,7 @@ } }, "node_modules/npm/node_modules/tuf-js": { - "version": "2.1.0", + "version": "2.2.0", "dev": true, "inBundle": true, "license": "MIT", @@ -14483,15 +14421,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/npm/node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { - "version": "5.0.1", - "dev": true, - "inBundle": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/npm/node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { "version": "4.3.0", "dev": true, @@ -14507,16 +14436,16 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/npm/node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "node_modules/npm/node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.0.1", "dev": true, "inBundle": true, "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/npm/node_modules/wrap-ansi/node_modules/emoji-regex": { @@ -14542,6 +14471,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/npm/node_modules/wrap-ansi/node_modules/strip-ansi": { + "version": "7.1.0", + "dev": true, + "inBundle": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, "node_modules/npm/node_modules/write-file-atomic": { "version": "5.0.1", "dev": true, @@ -14579,6 +14523,11 @@ "ufo": "^1.3.0" } }, + "node_modules/ohash": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/ohash/-/ohash-1.1.3.tgz", + "integrity": "sha512-zuHHiGTYTA1sYJ/wZN+t5HKZaH23i4yI1HMwbuXm24Nid7Dv0KcuRlKoNKS9UNfAVSBlnGLcuQrnOKWOZoEGaw==" + }, "node_modules/on-exit-leak-free": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz", @@ -15173,10 +15122,11 @@ "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" }, "node_modules/protons-runtime": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-5.2.2.tgz", - "integrity": "sha512-o97rNPN9pE3cxOxjs/waZNRKlbY/DR11oc20rUvarWZgFzQLLLzJU0RFh5JPi6GJCN67VGVn9/FDIEtFblfB3A==", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/protons-runtime/-/protons-runtime-5.3.0.tgz", + "integrity": "sha512-RySXxx+jvz4mi/rr2VsnvgWvC6dFP2pVyWpVRFYb/jxmwih862ZjXJLUkjd+nOtXBx0Lwk2xeuY2f2fmd3FT9w==", "dependencies": { + "uint8-varint": "^2.0.2", "uint8arraylist": "^2.4.3", "uint8arrays": "^5.0.1" } @@ -15516,9 +15466,9 @@ } }, "node_modules/read-pkg-up/node_modules/type-fest": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.9.0.tgz", - "integrity": "sha512-KS/6lh/ynPGiHD/LnAobrEFq3Ad4pBzOlJ1wAnJx9N4EYoqFhMfLIBjUT2UEx4wg5ZE+cC1ob6DCSpppVo+rtg==", + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.10.2.tgz", + "integrity": "sha512-anpAG63wSpdEbLwOqH8L84urkL6PiVIov3EMmgIhhThevh9aiMQov+6Btx0wldNcvm4wV+e2/Rt1QdDwKHFbHw==", "dev": true, "engines": { "node": ">=16" @@ -15545,9 +15495,9 @@ } }, "node_modules/read-pkg/node_modules/type-fest": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.9.0.tgz", - "integrity": "sha512-KS/6lh/ynPGiHD/LnAobrEFq3Ad4pBzOlJ1wAnJx9N4EYoqFhMfLIBjUT2UEx4wg5ZE+cC1ob6DCSpppVo+rtg==", + "version": "4.10.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.10.2.tgz", + "integrity": "sha512-anpAG63wSpdEbLwOqH8L84urkL6PiVIov3EMmgIhhThevh9aiMQov+6Btx0wldNcvm4wV+e2/Rt1QdDwKHFbHw==", "dev": true, "engines": { "node": ">=16" @@ -16448,9 +16398,9 @@ } }, "node_modules/spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.4.0.tgz", + "integrity": "sha512-hcjppoJ68fhxA/cjbN4T8N6uCUejN8yFw69ttpqtBeCbF3u13n7mb31NB9jKwGTTWWnt9IbRA/mf1FprYS8wfw==", "dev": true }, "node_modules/spdx-expression-parse": { @@ -16533,9 +16483,9 @@ } }, "node_modules/stream-shift": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.2.tgz", - "integrity": "sha512-rV4Bovi9xx0BFzOb/X0B2GqoIjvqPCttZdu0Wgtx2Dxkj7ETyWl9gmqJ4EutWRLvtZWm8dxE+InQZX1IryZn/w==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.3.tgz", + "integrity": "sha512-76ORR0DO1o1hlKwTbi/DM3EXWGf3ZJYO8cXX5RJwnul2DEg2oyoZyjLNoQM8WsvZiFKCRfC1O0J7iCvie3RZmQ==" }, "node_modules/stream-to-it": { "version": "0.2.4", @@ -16875,9 +16825,9 @@ } }, "node_modules/ts-jest": { - "version": "29.1.1", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz", - "integrity": "sha512-D6xjnnbP17cC85nliwGiL+tpoKN0StpgE0TeOjXQTU6MVCfsB4v7aW05CgQ/1OywGb0x/oy9hHFnN+sczTiRaA==", + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz", + "integrity": "sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==", "dev": true, "dependencies": { "bs-logger": "0.x", @@ -16893,7 +16843,7 @@ "ts-jest": "cli.js" }, "engines": { - "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + "node": "^16.10.0 || ^18.0.0 || >=20.0.0" }, "peerDependencies": { "@babel/core": ">=7.0.0-beta.0 <8", @@ -17016,6 +16966,15 @@ "node": ">=0.8.0" } }, + "node_modules/uint8-varint": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/uint8-varint/-/uint8-varint-2.0.4.tgz", + "integrity": "sha512-FwpTa7ZGA/f/EssWAb5/YV6pHgVF1fViKdW8cWaEarjB8t7NyofSWBdOTyFPaGuUG4gx3v1O3PQ8etsiOs3lcw==", + "dependencies": { + "uint8arraylist": "^2.0.0", + "uint8arrays": "^5.0.0" + } + }, "node_modules/uint8arraylist": { "version": "2.4.8", "resolved": "https://registry.npmjs.org/uint8arraylist/-/uint8arraylist-2.4.8.tgz", @@ -17203,9 +17162,9 @@ } }, "node_modules/unstorage/node_modules/lru-cache": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.1.0.tgz", - "integrity": "sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", "engines": { "node": "14 || >=16.14" } @@ -17392,9 +17351,9 @@ } }, "node_modules/web-vitals": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-3.5.1.tgz", - "integrity": "sha512-xQ9lvIpfLxUj0eSmT79ZjRoU5wIRfIr7pNukL7ZE4EcWZSmfZQqOlhuAGfkVa3EFmzPHZhWhXfm2i5ys+THVPg==" + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-3.5.2.tgz", + "integrity": "sha512-c0rhqNcHXRkY/ogGDJQxZ9Im9D19hDihbzSQJrsioex+KnFgmMzBiy57Z1EjkhX/+OjyBpclDCzz2ITtjokFmg==" }, "node_modules/webidl-conversions": { "version": "3.0.1", diff --git a/package.json b/package.json index 90d96fe..cdf254b 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "@semantic-release/release-notes-generator": "^12.1.0", "@types/debug": "^4.1.12", "@types/jest": "^29.5.11", - "@types/uuid": "^9.0.7", + "@types/uuid": "^9.0.8", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "conventional-changelog-conventionalcommits": "^7.0.2", @@ -136,7 +136,7 @@ "long": "^4.0.0", "prettier": "^3.2.4", "semantic-release": "^22.0.12", - "ts-jest": "^29.1.1", + "ts-jest": "^29.1.2", "typescript": "^5.3.3" }, "publishConfig": { diff --git a/src/agent/ICheqd.ts b/src/agent/ICheqd.ts index f6f80d4..53dd2be 100644 --- a/src/agent/ICheqd.ts +++ b/src/agent/ICheqd.ts @@ -16,6 +16,7 @@ import { createKeyPairBase64, createKeyPairHex, createVerificationKeys, + toMultibaseRaw, } from '@cheqd/sdk'; import { Coin, DeliverTxResponse } from '@cosmjs/stargate'; import { @@ -38,6 +39,7 @@ import { IResolver, W3CVerifiableCredential, ICredentialVerifier, + DIDResolutionResult, } from '@veramo/core'; import { CheqdDIDProvider, @@ -52,6 +54,8 @@ import { DefaultStatusList2021Encoding, DefaultStatusList2021ResourceType, DefaultStatusList2021StatusPurposeType, + createMsgCreateDidDocPayloadToSign, + TPublicKeyEd25519, } from '../did-manager/cheqd-did-provider.js'; import { fromString, toString } from 'uint8arrays'; import { decodeJWT } from 'did-jwt'; @@ -345,12 +349,13 @@ export interface ICheqdCreateIdentifierArgs { keys?: TImportableEd25519Key[]; versionId?: string; fee?: DidStdFee; + } export interface ICheqdUpdateIdentifierArgs { kms: string; document: DIDDocument; - keys?: TImportableEd25519Key[]; + keys?: TImportableEd25519Key[] | TPublicKeyEd25519[]; versionId?: string; fee?: DidStdFee; } @@ -358,7 +363,7 @@ export interface ICheqdUpdateIdentifierArgs { export interface ICheqdDeactivateIdentifierArgs { kms: string; document: DIDDocument; - keys?: TImportableEd25519Key[]; + keys?: TImportableEd25519Key[] | TPublicKeyEd25519[]; fee?: DidStdFee; } @@ -367,7 +372,7 @@ export interface ICheqdCreateLinkedResourceArgs { payload: ResourcePayload; network: CheqdNetwork; file?: string; - signInputs?: ISignInputs[]; + signInputs?: ISignInputs[] | TPublicKeyEd25519[]; fee?: DidStdFee; } @@ -1250,7 +1255,7 @@ export class Cheqd implements IAgentPlugin { kms: args.kms, keys: args.keys, versionId: args?.versionId, - fee: args?.fee, + fee: args?.fee }, }); } diff --git a/src/did-manager/cheqd-did-provider.ts b/src/did-manager/cheqd-did-provider.ts index da2a3d8..0e4b3c6 100644 --- a/src/did-manager/cheqd-did-provider.ts +++ b/src/did-manager/cheqd-did-provider.ts @@ -20,7 +20,7 @@ import { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2/inde import { AccountData, Coin, DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing'; import { GasPrice, DeliverTxResponse } from '@cosmjs/stargate'; import { assert } from '@cosmjs/utils'; -import { DIDDocument } from 'did-resolver'; +import { DIDDocument, DIDResolutionResult } from 'did-resolver'; import { IIdentifier, IKey, @@ -45,6 +45,7 @@ import { LitNetworks, } from '../dkg-threshold/lit-protocol.js'; import { IContext } from '../agent/ICheqd.js'; +import { getControllers } from '../utils/helpers.js'; const debug = Debug('veramo:did-provider-cheqd'); @@ -104,16 +105,322 @@ export type TImportableEd25519Key = Required> & { + kid: TImportableEd25519Key['publicKeyHex']; + type: 'Ed25519'; +}; + declare const TImportableEd25519Key: { isTImportableEd25519Key(object: object[]): object is TImportableEd25519Key[]; }; export type TSupportedKeyType = 'Ed25519' | 'Secp256k1'; +export interface IKeyWithController extends IKey { + controller?: string +} + +export interface ICheqdIDentifier extends IIdentifier { + // List of keyRefs which were used for signing the transaction + controllerKeyRefs?: string[] + // List of keys which could be used for signing the transaction + controllerKeys?: IKeyWithController[] +} + export class EnglishMnemonic extends _ { static readonly _mnemonicMatcher = /^[a-z]+( [a-z]+)*$/; } +export class CheqdSignInfoProvider { + readonly context: IContext; + signInfos: SignInfo[]; + publicKeyHexs: string[]; + controllers: string[]; + controllerKeys: IKeyWithController[]; + controllerKeyRefs: string[]; + + constructor (context: IContext) { + this.signInfos = []; + this.publicKeyHexs = []; + this.controllerKeys = []; + this.controllerKeyRefs = []; + this.controllers = []; + this.context = context; + } + + setPublicKeyHexs(publicKeyHexs: string[]): void { + this.publicKeyHexs = publicKeyHexs; + } + + setSignInfos(signInfos: SignInfo[]): void { + this.signInfos = signInfos; + } + + setControllers(controllers: string[]): void { + this.controllers = controllers; + } + + getSignInfos(): SignInfo[] { + return this.signInfos; + } + + getPublicKeyHexs(): string[] { + return this.publicKeyHexs; + } + + getControllerKeys(): IKeyWithController[] { + return this.controllerKeys; + } + + getControllerKeyRefs(): string[] { + return this.controllerKeyRefs; + } + + getControllerKeysForSigning(): IKeyWithController[] { + const keys:IKeyWithController[] = []; + this.controllers.forEach((controller) => { + const key = this.controllerKeys.find((key) => key.controller === controller); + if (key) { + keys.push(key); + } + }) + return keys; + } + + async compilePublicKeyHexs( + controllers: string[], + options: { + publicKeyHexs?: string[]; + } + ): Promise { + + const publicKeyHexs = options.publicKeyHexs || []; + if (publicKeyHexs.length === 0) { + for (const controller of controllers) { + const key = await this.context.agent.didManagerGet({ did: controller }).then((result) => result.keys[0]); + publicKeyHexs.push(key.kid) + } + } + this.setPublicKeyHexs(publicKeyHexs); + } + + async compileSignInfos( + payload: Uint8Array, + controllers: string[], + ): Promise { + // 1. Iterate over the contollers and for each - get DIDDocument and get the verificationMethodId associated with one of publicKeyHexs + // 1.1 Iterate over the list of verificationMethods and make the checks: + // 1.1.1 Iterate over publicKeyHexs and convert each publicKeyHex to the verification Material + // 1.1.2 If it compares with the one in the verificationMethod, then we have a match and can store the pair of verificationMethodId and publicKeyHex + // 2. Iterate over the pair of verificationMethodIds and publicKeys and create SignInfo§ + + // Setup + const signInfos: SignInfo[] = []; + const publicKeyHexs = this.getPublicKeyHexs(); + + // Get verificationMethodIds + const verificationMethodIds: { + verificationMethodId: string, + publicKeyHex: string, + }[] = []; + + // Iterate over list of controllers and tries to get the corresponding verificationMethodId associated with one of publicKeyHexs + for (const controller of controllers) { + // We need to get here current version of DIDDocument associated with the controller and cannot skip it even if document.id === controller + // cause in case of remooving verifcation method we need to sign the payload with the old verification method which is on ledger. + const controllerResolutionResult = await this.context.agent.resolveDid({ didUrl: controller }); + const controllerDidDocument = controllerResolutionResult.didDocument; + // Check if controller DID document is resolved + if (!controllerDidDocument) { + throw new CheqdProviderError( + '[did-provider-cheqd]: compileSignInfos: Error while resolving the DID document for controller DID: ' + controller, + CheqdProviderErrorCodes.UnresolvedDID); + } + // Check that controller's DIDDocument is active + if (controllerResolutionResult.didDocumentMetadata.deactivated) { + throw new CheqdProviderError( + `[did-provider-cheqd]: compileSignInfos: DIDDocument associated with controller ${controller} is deactivated`, + CheqdProviderErrorCodes.DeactivatedController); + } + // Check if controller DID document contains verification methods + if (!controllerDidDocument.verificationMethod) { + throw new CheqdProviderError( + '[did-provider-cheqd]: compileSignInfos: Controller DID document does not contain verification methods', + CheqdProviderErrorCodes.EmptyVerificationMethod); + } + // Iterate over verificationMethods and by comparing publicKeys get the verificationMethod Id + for (const vm of controllerDidDocument.verificationMethod) { + // Try to match verificationMethod with one of publicKeyHexs + for (const publicKeyHex of publicKeyHexs) { + // Get publicKeyHex from verificationMethod + const vmPublicKey = extractPublicKeyHex(vm); + // Compare publicKeys + if (publicKeyHex === vmPublicKey) { + // Create SignInfo object + signInfos.push({ + verificationMethodId: vm.id, + signature: base64ToBytes( + await this.context.agent.keyManagerSign({ + keyRef: publicKeyHex, + data: toString(payload, 'hex'), + encoding: 'hex', + }) + ), + } satisfies SignInfo) + // Setup controllerKeyRefs + this.controllerKeyRefs.push(publicKeyHex); + } + } + // Setup key structure for display + const kid = extractPublicKeyHex(vm); + const key = await this.context.agent.keyManagerGet({ kid }); + this.controllerKeys.push({...key, controller: vm.controller} satisfies IKeyWithController); + } + } + // Setup signInfos + this.setSignInfos(signInfos) + } + + async updateIdentifierCompileSignInfos( + didDocument: DIDDocument, + options: { + versionId?: string + publicKeyHexs?: string[]; + } + ): Promise { + + // Steps to solve the issue: + // 1. Collect list of controllers. The user can remove, append and reqrite the controller. + // But we need to send all the signatures, old and news + // 2. Generate payloads + // 3. Compile list of signInfos + + // Get current version of DIDDocument + const actualDIDDocument: DIDResolutionResult = await this.context.agent.resolveDid({ didUrl: didDocument.id }); + if (!actualDIDDocument.didDocument) { + throw new Error('[did-provider-cheqd]: updateIdentifierSignInfos: Error while resolving the DID document for updating with error: ' + actualDIDDocument.didResolutionMetadata.error); + } + // Compile controllers + const updatedControllers: string[] = getControllers(didDocument); + const actualControllers: string[] = getControllers(actualDIDDocument.didDocument); + const controllers = [...new Set([...updatedControllers, ...actualControllers])]; + + // Generate payload + const versionId = options.versionId || v4(); + const payload = await createMsgCreateDidDocPayloadToSign(didDocument, versionId); + + // Setup publicKeyHexs + await this.compilePublicKeyHexs(controllers, options); + + // Setup controllers. Here it's supposed to be a list of controllers which are associated with the DIDDocument + this.setControllers(updatedControllers); + + // Setup SignInfos + await this.compileSignInfos(payload, controllers); + } + + async deactivateIdentifierCompileSignInfos( + didDocument: DIDDocument, + options: { + publicKeyHexs?: string[]; + versionId?: string + }): Promise { + + // Steps to solve the issue: + // 1. Collect list of controllers. The user can remove, append and reqrite the controller. + // But we need to send all the signatures, old and news + // Generate payload to sign + // 3. Compile list of signInfos + + // Get Controllers + const controllers: string[] = getControllers(didDocument); + + // For did deactivation ledger requires the signature from original DID Document controller + // So we need to add the controller to the list of controllers + if (!controllers.includes(didDocument.id)) { + controllers.push(didDocument.id); + } + + + // Generate payload + const versionId = options.versionId || v4(); + const payload = await createMsgDeactivateDidDocPayloadToSign(didDocument, versionId); + + // Setup publicKeyHexs + await this.compilePublicKeyHexs(controllers, options); + + // Setup SignInfos + await this.compileSignInfos(payload, controllers); + } + + async resourceCreateCompileSignInfos( + did: string, + resourcePayload: ResourcePayload, + options: { + publicKeyHexs?: string[]; + }): Promise { + + // Steps to solve the issue: + // 1. Collect list of controllers. The user can remove, append and reqrite the controller. + // But we need to send all the signatures, old and news + // Generate payload to sign + // 3. Compile list of signInfos + + const didDocument = await this.context.agent.resolveDid({ didUrl: did }).then((result) => result.didDocument); + if (!didDocument) { + throw new Error('[did-provider-cheqd]: resourceCreateCompileSignInfos: Erro while resolving the DID document for controller DID: ' + did); + } + // Get Controllers + const controllers: string[] = getControllers(didDocument); + + // For resource creation ledger requires the signature from original DID Document controller + // So we need to add the controller to the list of controllers + if (!controllers.includes(did)) { + controllers.push(did); + } + + // Generate payload + const payload = await MsgCreateResourcePayload.encode(MsgCreateResourcePayload.fromPartial(resourcePayload)).finish() + + // Setup publicKeyHexs + await this.compilePublicKeyHexs(controllers, options); + + // Setup SignInfos + await this.compileSignInfos(payload, controllers); + } + + async keysAreInKMS(publicKeys: string[]) { + for (const keyRef of publicKeys) { + try { + await this.context.agent.keyManagerGet({ kid: keyRef }); + } catch (e) { + return { + placed: false, + error: `PublicKey: ${keyRef} is not placed in kms` + }; + } + } + return { + placed: true + }; + } + +} + /** * {@link @veramo/did-manager#DIDManager} identifier provider for `did:cheqd` identifiers. * @public @@ -224,10 +531,17 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { assert(tx.code === 0, `cosmos_transaction: Failed to create DID. Reason: ${tx.rawLog}`); + const identifier: ICheqdIDentifier = { + did: options.document.id, + keys: [], + services: options.document.service || [], + provider: options.document.id.split(':').splice(0, 3).join(':'), + }; + //* Currently, only one controller key is supported. //* We assume that the first key in the list is the controller key. //* This is subject to change in the near future. - const keys: ManagedKeyInfo[] = options.keys + identifier.keys= options.keys ? await (async function (that: CheqdDIDProvider) { const scopedKeys: ManagedKeyInfo[] = []; for (const key of options.keys!) { @@ -249,16 +563,21 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { } return scopedKeys; })(this) - : await this.getKeysFromVerificationMethod(context, options.document.verificationMethod); - - const controllerKey: IKey = keys[0]; - const identifier: IIdentifier = { - did: options.document.id, - controllerKeyId: controllerKey.kid, - keys, - services: options.document.service || [], - provider: options.document.id.split(':').splice(0, 3).join(':'), - }; + : await (async function (that: CheqdDIDProvider) { + const vmKeys = await that.getKeysFromVerificationMethod(context, options.document.verificationMethod); + // Setup controllerKeyRefs + identifier.controllerKeyRefs = vmKeys.map((key) => key.kid); + // Setup controllerKeys. It's a list of keys to display + identifier.controllerKeys = vmKeys.map((key) => ({...key, controller: options.document.id} satisfies IKeyWithController)); + // Here we are returning all keys associated with the DIDDocument (including keys for controllers) + // We already compiled it while discovering the verificationMethodIds + return vmKeys; + })(this); + await this.getKeysFromVerificationMethod(context, options.document.verificationMethod); + + + const controllerKey: IKey = identifier.keys[0]; + identifier.controllerKeyId = controllerKey.kid; debug('Created DID', identifier.did); @@ -273,23 +592,60 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { }: { did: string; document: DIDDocument; - options: { kms: string; keys?: TImportableEd25519Key[]; versionId?: string; fee?: DidStdFee }; + options: { + kms: string; + keys?: TImportableEd25519Key[] | TPublicKeyEd25519[]; + versionId?: string; + fee?: DidStdFee; + }; }, context: IContext - ): Promise { + ): Promise { + // Handle input parameters const sdk = await this.getCheqdSDK(options?.fee); const versionId = options.versionId || v4(); - const signInputs: ISignInputs[] | SignInfo[] = options.keys - ? (function () { - return options.keys.map((key) => - createSignInputsFromImportableEd25519Key(key, document.verificationMethod || []) - ); - })() - : await (async function (that: CheqdDIDProvider) { - const data = await createMsgCreateDidDocPayloadToSign(document, versionId); - return await that.signPayload(context, data, document.verificationMethod); - })(this); + const keys = options.keys || []; + const signInfoProvider = new CheqdSignInfoProvider(context); + + // It answers on question what the keys are actually in input + const areKeysImportable = keys.length > 0 && keys.every((key) => { + return Object.keys(key).includes('privateKeyHex') + }); + // options.keys may be list of keys with privateKey ibside or just list of publicKeys + const publicKeyHexs: string[] = areKeysImportable + ? [] + : keys.map((key) => key.publicKeyHex) + + // Check that publicKeyHexs are placed in kms if the user provides the keys + const _r = await signInfoProvider.keysAreInKMS(publicKeyHexs) + if (_r.error) { + throw Error(`[updateIdentifier]: ${_r.error}`) + } + + // Check that verificationMethod on changed DIDDocument list exists and not empty + if (!document.verificationMethod || document.verificationMethod.length === 0) { + throw new CheqdProviderError( + '[updateIdentifier]: VerificationMethod should be placed and not be empty', + CheqdProviderErrorCodes.EmptyVerificationMethod) + } + const signInputs: ISignInputs[] | SignInfo[] = areKeysImportable + ? (function () { + // We are sure here that keys are placed + return options.keys!.map((key) => + createSignInputsFromImportableEd25519Key(key, document.verificationMethod || []) + ); + })() + : await (async function () { + await signInfoProvider.updateIdentifierCompileSignInfos( + document, { + publicKeyHexs, + versionId + }); + return signInfoProvider.getSignInfos(); + })(); + + debug(`[updateIdentifier]: DID: ${did}, VerificationMethodIds for signing: ${signInputs.map((signInput) => signInput.verificationMethodId)}`) const tx = await sdk.updateDidDocTx( signInputs, document satisfies DIDDocument, @@ -301,18 +657,24 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { ); assert(tx.code === 0, `cosmos_transaction: Failed to update DID. Reason: ${tx.rawLog}`); + // Setup return value + const identifier: ICheqdIDentifier = { + did: document.id, + keys: [], + services: document.service || [], + provider: document.id.split(':').splice(0, 3).join(':'), + };; - //* Currently, only one controller key is supported. - //* We assume that the first key in the list is the controller key. - //* This is subject to change in the near future. - const keys: ManagedKeyInfo[] = options.keys + // Get keys for updated DIDDocument + // Here we are importing only the keys which has privateKey field set up + identifier.keys = options.keys && areKeysImportable ? await (async function (that: CheqdDIDProvider) { const scopedKeys: ManagedKeyInfo[] = []; for (const key of options.keys!) { let managedKey: ManagedKeyInfo | undefined; try { managedKey = await context.agent.keyManagerImport({ - ...key, + ...key as TImportableEd25519Key, kms: options.kms || that.defaultKms, } satisfies MinimalImportableKey); } catch (e) { @@ -325,20 +687,22 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { scopedKeys.push(managedKey); } } - + // Setup controllerKeyId + identifier.controllerKeyId = scopedKeys[0].kid; return scopedKeys; - })(this) - : await this.getKeysFromVerificationMethod(context, document.verificationMethod); - - const controllerKey = keys[0]; - - const identifier: IIdentifier = { - did: document.id, - controllerKeyId: controllerKey.kid, - keys, - services: document.service || [], - provider: document.id.split(':').splice(0, 3).join(':'), - }; + })(this) + : await (async function (that: CheqdDIDProvider) { + const vmKeys = await that.getKeysFromVerificationMethod(context, document.verificationMethod); + // Setup controllerKeyId. It should be asocciated with verificationMethod list + identifier.controllerKeyId = vmKeys[0].kid; + // Setup controllerKeyRefs. It's a list of keys which were used for signing the transaction + identifier.controllerKeyRefs = signInfoProvider.getControllerKeyRefs(); + // Setup controllerKeys. It's a list of keys to display + identifier.controllerKeys = signInfoProvider.getControllerKeysForSigning(); + // Here we are returning all keys associated with the DIDDocument (including keys for controllers) + // We already compiled it while discovering the verificationMethodIds + return vmKeys; + })(this); debug('Updated DID', did); @@ -353,23 +717,52 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { }: { did: string; document: DIDDocument; - options: { keys?: TImportableEd25519Key[]; fee?: DidStdFee; versionId?: string }; + options: { + keys?: TImportableEd25519Key[] | TPublicKeyEd25519[]; + fee?: DidStdFee; + versionId?: string + }; }, context: IContext ): Promise { const sdk = await this.getCheqdSDK(options?.fee); const versionId = options.versionId || v4(); - const signInputs: ISignInputs[] | SignInfo[] = options.keys - ? (function () { - return options.keys.map((key) => - createSignInputsFromImportableEd25519Key(key, document.verificationMethod || []) - ); - })() - : await (async function (that: CheqdDIDProvider) { - const data = await createMsgDeactivateDidDocPayloadToSign(document, versionId); - return await that.signPayload(context, data, document.verificationMethod); - })(this); + const keys = options.keys || []; + // Providr for compiling SignInfos + const signInfoProvider = new CheqdSignInfoProvider(context); + // It answers on question what the keys are actually in input + const areKeysImportable = keys.length > 0 && keys.every((key) => { + return Object.keys(key).includes('privateKeyHex') + }); + const publicKeyHexs: string[] = areKeysImportable + ? [] + : keys.map((key) => key.publicKeyHex) + + // Check that publicKeyHexs are placed in kms + const _r = await signInfoProvider.keysAreInKMS(publicKeyHexs) + if (_r.error) { + throw Error(`[deactivateIdentifier]: ${_r.error}`) + } + + const signInputs: ISignInputs[] | SignInfo[] = areKeysImportable + ? (function () { + // We are sure here that keys are placed + return options.keys!.map((key) => + createSignInputsFromImportableEd25519Key(key, document.verificationMethod || []) + ); + })() + : await (async function () { + + await signInfoProvider.deactivateIdentifierCompileSignInfos( + document, { + publicKeyHexs, + versionId + }); + return signInfoProvider.getSignInfos(); + })(); + + debug(`[deactivateIdentifier]: DID: ${did}, VerificationMethodIds for signing: ${signInputs.map((signInput) => signInput.verificationMethodId)}`) const tx = await sdk.deactivateDidDocTx( signInputs, document satisfies DIDDocument, @@ -390,24 +783,46 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { async createResource( { options, - }: { options: { payload: ResourcePayload; signInputs?: ISignInputs[]; kms?: string; fee?: DidStdFee } }, + }: { options: { + payload: ResourcePayload; + signInputs?: ISignInputs[] | TPublicKeyEd25519[]; + kms?: string; + fee?: DidStdFee + } }, context: IContext ): Promise { const sdk = await this.getCheqdSDK(options?.fee); + const signInfoProvider = new CheqdSignInfoProvider(context); + const inputKeys = options.signInputs || []; + + const areSignInputs = inputKeys.length > 0 && inputKeys.every((key) => { + return Object.keys(key).includes('privateKeyHex') + }); + // options.signInputs may be list of keys with privateKey ibside or just list of publicKeys + const publicKeyHexs: string[] = areSignInputs + ? [] + : inputKeys.map((key) => key.publicKeyHex) + + // Check that publicKeyHexs are placed in kms + const _r = await signInfoProvider.keysAreInKMS(publicKeyHexs) + if (_r.error) { + throw Error(`[updateIdentifier]: ${_r.error}`) + } - const signInputs: ISignInputs[] | SignInfo[] = options.signInputs - ? options.signInputs + const signInputs: ISignInputs[] | SignInfo[] = areSignInputs + ? options.signInputs as ISignInputs[] : await (async function (that: CheqdDIDProvider) { const did = `did:cheqd:${that.network}:${options.payload.collectionId}`; - const { didDocument } = await sdk.queryDidDoc(did, { sdk: sdk }); - - return await that.signPayload( - context, - MsgCreateResourcePayload.encode(MsgCreateResourcePayload.fromPartial(options.payload)).finish(), - didDocument?.verificationMethod - ); + await signInfoProvider.resourceCreateCompileSignInfos( + did, + options.payload, + { + publicKeyHexs, + }); + return signInfoProvider.getSignInfos(); })(this); + debug(`[createResource]: DID: did:cheqd:${this.network}:${options.payload.collectionId} , VerificationMethodIds for signing: ${signInputs.map((signInput) => signInput.verificationMethodId)}`) const tx = await sdk.createLinkedResourceTx(signInputs, options.payload, '', this?.fee, undefined, { sdk: sdk, }); @@ -425,8 +840,8 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { } }; - if (options.signInputs) { - const signInput = options.signInputs.filter((input) => mapKeyType(input.keyType) !== undefined); + if (areSignInputs) { + const signInput = (inputKeys as ISignInputs[]).filter((input) => mapKeyType(input.keyType) !== undefined); const keys: ManagedKeyInfo[] = []; for (const input of signInput) { @@ -564,11 +979,12 @@ export class CheqdDIDProvider extends AbstractIdentifierProvider { private async getKeysFromVerificationMethod( context: IAgentContext, verificationMethod: VerificationMethod[] = [] - ): Promise { + ): Promise { return Promise.all( verificationMethod.map(async (method) => { const kid = extractPublicKeyHex(method); - return await context.agent.keyManagerGet({ kid }); + const key = await context.agent.keyManagerGet({ kid }); + return {...key, controller: method.controller} }) ).catch((error) => { throw new Error(`Failed to sign payload: ${error}`); diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 6f9dc3b..ac13f0d 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,3 +1,4 @@ +import { DIDDocument } from '@veramo/core-types'; import { generate as generateSecret, type GenerateOptions } from 'generate-password'; import { toString } from 'uint8arrays/to-string'; @@ -59,3 +60,16 @@ export function unescapeUnicode(str: string): string { return String.fromCharCode(parseInt(cc, 16)); }); } + +export function getControllers(didDocument: DIDDocument): string[] { + const controllers: string[] = []; + if (didDocument.controller) { + if (typeof didDocument.controller === 'string') { + controllers.push(didDocument.controller); + } + if (Array.isArray(didDocument.controller)) { + controllers.push(...didDocument.controller); + } + } + return controllers; +}