diff --git a/examples/node/.gitignore b/examples/node/.gitignore index 5baa59d6..45e8d404 100644 --- a/examples/node/.gitignore +++ b/examples/node/.gitignore @@ -1 +1,2 @@ -db \ No newline at end of file +db +.env diff --git a/examples/node/README.md b/examples/node/README.md new file mode 100644 index 00000000..2e5542b0 --- /dev/null +++ b/examples/node/README.md @@ -0,0 +1,38 @@ +# Node Examples + +## Prerequisites + +- You will need a working mediatorDID, we are currently running a v1 mediator. + +## Installation + +In this directory, you'll need to run + +```bash +npm install +``` + +## Environment Variables + +Set up a `.env` file in this folder, see `.env.example` + +```bash +MEDIATOR_DID= +``` + +## Running the tests + +For the +``` +npm run start:inmemory +``` + +TODO +``` +npm run start:leveldb +``` + +TODO: +``` +npm run start:indexdb +``` diff --git a/examples/node/package-lock.json b/examples/node/package-lock.json index 8322f070..8592efe7 100644 --- a/examples/node/package-lock.json +++ b/examples/node/package-lock.json @@ -9,11 +9,12 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@atala/prism-wallet-sdk": "^4.0.0-rc.1", + "@atala/prism-wallet-sdk": "^5.1.0", "@pluto-encrypted/database": "^1.15.1", "@pluto-encrypted/iagon": "^0.0.0-beta.18", - "@pluto-encrypted/inmemory": "^1.12.1", + "@pluto-encrypted/inmemory": "^1.12.2", "@pluto-encrypted/leveldb": "^1.12.1", + "@pluto-encrypted/schemas": "^1.3.5", "fake-indexeddb": "^5.0.1", "prettier": "^3.0.2" }, @@ -26,9 +27,9 @@ } }, "node_modules/@atala/apollo": { - "version": "1.2.10", - "resolved": "https://registry.npmjs.org/@atala/apollo/-/apollo-1.2.10.tgz", - "integrity": "sha512-0uoA76e3eE0gl9h7/77GtgoYsX2OvM+rWdDkA5mOR2WB6XU4lGrVdXv954WNjpNQaNcMwkeh2INje51d7RuAIw==", + "version": "1.2.16", + "resolved": "https://registry.npmjs.org/@atala/apollo/-/apollo-1.2.16.tgz", + "integrity": "sha512-va/u0p/dNcV5tl/pzYxiCw/f+MGW3per/TR3Z6YiPggRFLqH61CetGWXy3W5dHzp5CFVpuwOqaDFFS5vVfD+Eg==", "dependencies": { "@noble/curves": "1.2.0", "@noble/hashes": "1.3.1", @@ -42,9 +43,9 @@ } }, "node_modules/@atala/prism-wallet-sdk": { - "version": "4.0.0-rc.1", - "resolved": "https://registry.npmjs.org/@atala/prism-wallet-sdk/-/prism-wallet-sdk-4.0.0-rc.1.tgz", - "integrity": "sha512-LGrgPra85+3ZBnEYV7ip0Z0ys/9Z8BnZMwzE78rQf4J9cOPFX9nFOUN7V1eb0OlEfaHGrAyuWH9pbbNRGL5FNA==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@atala/prism-wallet-sdk/-/prism-wallet-sdk-5.1.0.tgz", + "integrity": "sha512-Mqb4AiCaMt+NEJp+5ZX9R21Dvj/+5fkbFdNBM3QEg0c4QIyI7V6bA56jJpDjMer887eNvzFt7SU0Nq/he4L6hg==", "dependencies": { "@atala/apollo": "^1.2.10", "@scure/bip32": "^1.3.0", @@ -64,9 +65,11 @@ "elliptic": "^6.5.4", "google-protobuf": "^3.21.2", "hash.js": "1.1.7", - "jose": "^4.12.2", + "isows": "^1.0.3", + "jose": "^4.15.5", "jsonwebtoken": "^9.0.0", "multiformats": "^9.9.0", + "rxdb": "^14.17.1", "text-encoding": "^0.7.0", "util": "^0.12.5", "uuid": "^9.0.0" @@ -969,13 +972,13 @@ } }, "node_modules/@grpc/grpc-js/node_modules/@grpc/proto-loader": { - "version": "0.7.10", - "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.10.tgz", - "integrity": "sha512-CAqDfoaQ8ykFd9zqBDn4k6iWT9loLAlc2ETmDFS9JCD70gDcnA4L3AFEo2iV7KyAtAAHFW9ftq1Fz+Vsgq80RQ==", + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.7.13.tgz", + "integrity": "sha512-AiXO/bfe9bmxBjxxtYxFAXGZvMaN5s8kO+jBHAJCON8rJoB5YS/D6X7ZNc6XQkuHNmyl4CYaMI1fJ/Gn27RGGw==", "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", - "protobufjs": "^7.2.4", + "protobufjs": "^7.2.5", "yargs": "^17.7.2" }, "bin": { @@ -1004,9 +1007,9 @@ "integrity": "sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==" }, "node_modules/@grpc/grpc-js/node_modules/protobufjs": { - "version": "7.2.6", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.2.6.tgz", - "integrity": "sha512-dgJaEDDL6x8ASUZ1YqWciTRrdOuYNzoOf27oHNfdyvKqHr5i0FV7FSLU+aIeFjyFgVxrpTOtQUi0BLLBymZaBw==", + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.3.2.tgz", + "integrity": "sha512-RXyHaACeqXeqAKGLDl68rQKbmObRsTIn4TYVUUug1KfS47YWCo5MacGITEryugIgZqORCvJWEk4l449POg5Txg==", "hasInstallScript": true, "dependencies": { "@protobufjs/aspromise": "^1.1.2", @@ -1095,9 +1098,9 @@ } }, "node_modules/@mongodb-js/saslprep": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.4.tgz", - "integrity": "sha512-8zJ8N1x51xo9hwPh6AWnKdLGEC5N3lDa6kms1YHmFBoRhTpJR6HG8wWk0td1MVCu9cD4YBrvjZEtd5Obw0Fbnw==", + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.8.tgz", + "integrity": "sha512-qKwC/M/nNNaKUBMQ0nuzm47b7ZYWQHN3pcXq4IIcoSBc2hOIrflAxJduIvvqmhoz3gR2TacTAs8vlsCVPkiEdQ==", "dependencies": { "sparse-bitfield": "^3.0.3" } @@ -1165,12 +1168,51 @@ "@atala/prism-wallet-sdk": "^4.0.0-rc.1" } }, - "node_modules/@pluto-encrypted/database/node_modules/@pluto-encrypted/shared": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/shared/-/shared-1.11.3.tgz", - "integrity": "sha512-/Ud10UeA7l+E9dM5rrfo5ED0U7kKwVgatsI+vL1EGs8/4W7OZXECP3DsDl/JnjH8GC/gH3ddql8U9PviWFi2ig==", + "node_modules/@pluto-encrypted/database/node_modules/@atala/prism-wallet-sdk": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@atala/prism-wallet-sdk/-/prism-wallet-sdk-4.0.2.tgz", + "integrity": "sha512-dAQTvFeg8oZsO022ICOWZ/8mfowwXwz26J70VQrFT5drqhIvTER4d7T2CLEgBytchHIk6ueowCGcBlL+JIe9tA==", + "dependencies": { + "@atala/apollo": "^1.2.10", + "@scure/bip32": "^1.3.0", + "@scure/bip39": "^1.1.1", + "@stablelib/base64": "^1.0.1", + "@stablelib/sha256": "^1.0.1", + "@stablelib/uuid": "^1.0.2", + "@stablelib/wipe": "^1.0.1", + "@stablelib/x25519": "^1.0.3", + "antlr4ts": "^0.5.0-alpha.4", + "assert": "^2.0.0", + "axios": "^1.6.1", + "bn.js": "^5.2.1", + "buffer": "^6.0.3", + "did-jwt": "^6.11.5", + "did-resolver": "^4.1.0", + "elliptic": "^6.5.4", + "google-protobuf": "^3.21.2", + "hash.js": "1.1.7", + "jose": "^4.12.2", + "jsonwebtoken": "^9.0.0", + "multiformats": "^9.9.0", + "text-encoding": "^0.7.0", + "util": "^0.12.5", + "uuid": "^9.0.0" + }, + "peerDependenciesMeta": { + "react-native-sqlite-storage": { + "optional": true + } + } + }, + "node_modules/@pluto-encrypted/database/node_modules/@pluto-encrypted/inmemory": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@pluto-encrypted/inmemory/-/inmemory-1.12.1.tgz", + "integrity": "sha512-Zdb2iWIh04Jb0U+RvLBvNKkfKGzX7EEvOoTYXGhpN8g9aI8E5THYbSwqrklnTDDvztnzzmGlfUrqxY4eGzEVug==", + "optional": true, "dependencies": { "@pluto-encrypted/encryption": "1.11.0", + "@pluto-encrypted/shared": "1.11.3", + "array-push-at-sort-position": "^4.0.1", "rxdb": "^14.17.0", "uuid": "^9.0.1" } @@ -1248,21 +1290,10 @@ "uuid": "^9.0.1" } }, - "node_modules/@pluto-encrypted/indexdb/node_modules/@pluto-encrypted/shared": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/shared/-/shared-1.11.3.tgz", - "integrity": "sha512-/Ud10UeA7l+E9dM5rrfo5ED0U7kKwVgatsI+vL1EGs8/4W7OZXECP3DsDl/JnjH8GC/gH3ddql8U9PviWFi2ig==", - "optional": true, - "dependencies": { - "@pluto-encrypted/encryption": "1.11.0", - "rxdb": "^14.17.0", - "uuid": "^9.0.1" - } - }, "node_modules/@pluto-encrypted/inmemory": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/inmemory/-/inmemory-1.12.1.tgz", - "integrity": "sha512-Zdb2iWIh04Jb0U+RvLBvNKkfKGzX7EEvOoTYXGhpN8g9aI8E5THYbSwqrklnTDDvztnzzmGlfUrqxY4eGzEVug==", + "version": "1.12.3", + "resolved": "https://registry.npmjs.org/@pluto-encrypted/inmemory/-/inmemory-1.12.3.tgz", + "integrity": "sha512-OBilhIBKrqZkxKx7F98UmVU2rxXbyLwv3R7R8/uz0+7n+QmJ1tR6WEaCQN/WkxG95Vx07lLxCIt35l4Iw/681A==", "dependencies": { "@pluto-encrypted/encryption": "1.11.0", "@pluto-encrypted/shared": "1.11.3", @@ -1271,16 +1302,6 @@ "uuid": "^9.0.1" } }, - "node_modules/@pluto-encrypted/inmemory/node_modules/@pluto-encrypted/shared": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/shared/-/shared-1.11.3.tgz", - "integrity": "sha512-/Ud10UeA7l+E9dM5rrfo5ED0U7kKwVgatsI+vL1EGs8/4W7OZXECP3DsDl/JnjH8GC/gH3ddql8U9PviWFi2ig==", - "dependencies": { - "@pluto-encrypted/encryption": "1.11.0", - "rxdb": "^14.17.0", - "uuid": "^9.0.1" - } - }, "node_modules/@pluto-encrypted/leveldb": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@pluto-encrypted/leveldb/-/leveldb-1.12.1.tgz", @@ -1297,36 +1318,62 @@ "uuid": "^9.0.1" } }, - "node_modules/@pluto-encrypted/leveldb/node_modules/@pluto-encrypted/shared": { - "version": "1.11.3", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/shared/-/shared-1.11.3.tgz", - "integrity": "sha512-/Ud10UeA7l+E9dM5rrfo5ED0U7kKwVgatsI+vL1EGs8/4W7OZXECP3DsDl/JnjH8GC/gH3ddql8U9PviWFi2ig==", - "dependencies": { - "@pluto-encrypted/encryption": "1.11.0", - "rxdb": "^14.17.0", - "uuid": "^9.0.1" - } - }, "node_modules/@pluto-encrypted/schemas": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/schemas/-/schemas-1.2.1.tgz", - "integrity": "sha512-nInW9rsVdXQ1zbAJ0+p/3y62Vug/dxXjH9QOYW71apzBxl0NUlCe32RzoCAwnv+6mLOrAo30+bJbE5paD00v0Q==", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@pluto-encrypted/schemas/-/schemas-1.3.5.tgz", + "integrity": "sha512-ePr6AKFIuCv1KjBWCJEd2UeQVZdXR1jL9iYL38w5z5OezFFWEV9i4Be8QHmxa6UuTGBLKrAtUDdlS8PHL+aeMA==", "dependencies": { - "@atala/prism-wallet-sdk": "^4.0.0-rc.1", + "@atala/prism-wallet-sdk": "^4.0.2", "@pluto-encrypted/encryption": "1.11.0", - "@pluto-encrypted/shared": "1.11.2", + "@pluto-encrypted/shared": "1.11.3", "rxdb": "^14.17.0", "rxjs": "7.8.1", "uuid": "^9.0.1" }, "peerDependencies": { - "@atala/prism-wallet-sdk": "^4.0.0-rc.1" + "@atala/prism-wallet-sdk": "^4.0.2" + } + }, + "node_modules/@pluto-encrypted/schemas/node_modules/@atala/prism-wallet-sdk": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@atala/prism-wallet-sdk/-/prism-wallet-sdk-4.0.2.tgz", + "integrity": "sha512-dAQTvFeg8oZsO022ICOWZ/8mfowwXwz26J70VQrFT5drqhIvTER4d7T2CLEgBytchHIk6ueowCGcBlL+JIe9tA==", + "dependencies": { + "@atala/apollo": "^1.2.10", + "@scure/bip32": "^1.3.0", + "@scure/bip39": "^1.1.1", + "@stablelib/base64": "^1.0.1", + "@stablelib/sha256": "^1.0.1", + "@stablelib/uuid": "^1.0.2", + "@stablelib/wipe": "^1.0.1", + "@stablelib/x25519": "^1.0.3", + "antlr4ts": "^0.5.0-alpha.4", + "assert": "^2.0.0", + "axios": "^1.6.1", + "bn.js": "^5.2.1", + "buffer": "^6.0.3", + "did-jwt": "^6.11.5", + "did-resolver": "^4.1.0", + "elliptic": "^6.5.4", + "google-protobuf": "^3.21.2", + "hash.js": "1.1.7", + "jose": "^4.12.2", + "jsonwebtoken": "^9.0.0", + "multiformats": "^9.9.0", + "text-encoding": "^0.7.0", + "util": "^0.12.5", + "uuid": "^9.0.0" + }, + "peerDependenciesMeta": { + "react-native-sqlite-storage": { + "optional": true + } } }, "node_modules/@pluto-encrypted/shared": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/@pluto-encrypted/shared/-/shared-1.11.2.tgz", - "integrity": "sha512-2wVSQXRQMm5roqsDtiFHeHuEFCP3FOSonSxxkFAiV7VXp0UAtLvbAW5bpwb2or46y5edUvsycfxQBEgEhfNXlQ==", + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@pluto-encrypted/shared/-/shared-1.11.3.tgz", + "integrity": "sha512-/Ud10UeA7l+E9dM5rrfo5ED0U7kKwVgatsI+vL1EGs8/4W7OZXECP3DsDl/JnjH8GC/gH3ddql8U9PviWFi2ig==", "dependencies": { "@pluto-encrypted/encryption": "1.11.0", "rxdb": "^14.17.0", @@ -1454,9 +1501,9 @@ } }, "node_modules/@socket.io/component-emitter": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", - "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg==" + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz", + "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==" }, "node_modules/@stablelib/aead": { "version": "1.0.1", @@ -1923,9 +1970,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.17.41", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.41.tgz", - "integrity": "sha512-OaJ7XLaelTgrvlZD8/aa0vvvxZdUmlCn6MtWeB7TkiKW70BQLc9XEPpDLPdbo52ZhXUCrznlWdCHWxJWtdyajA==", + "version": "4.19.5", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.5.tgz", + "integrity": "sha512-y6W03tvrACO72aijJ5uF02FRq5cgDR9lUxddQ8vyF+GvmjJQqbzDcJngEjURc+ZsG31VI3hODNZJ2URj86pzmg==", "dependencies": { "@types/node": "*", "@types/qs": "*", @@ -1967,9 +2014,9 @@ } }, "node_modules/@types/qs": { - "version": "6.9.11", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.11.tgz", - "integrity": "sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==" + "version": "6.9.15", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", + "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==" }, "node_modules/@types/range-parser": { "version": "1.2.7", @@ -1986,13 +2033,13 @@ } }, "node_modules/@types/serve-static": { - "version": "1.15.5", - "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.5.tgz", - "integrity": "sha512-PDRk21MnK70hja/YF8AHfC7yIsiQHn1rcXx7ijCFBX/k+XQJhQT/gw3xekXKJvx+5SXaMMS8oqQy09Mzvz2TuQ==", + "version": "1.15.7", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", + "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", "dependencies": { "@types/http-errors": "*", - "@types/mime": "*", - "@types/node": "*" + "@types/node": "*", + "@types/send": "*" } }, "node_modules/@types/simple-peer": { @@ -2287,9 +2334,9 @@ "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==" }, "node_modules/bson": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz", - "integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.8.0.tgz", + "integrity": "sha512-iOJg8pr7wq2tg/zSlCCHMi3hMm5JTOxLTagf3zxhcenHsFp+c6uOs6K7W5UE7A4QIJGtqh/ZovFNMP4mOPJynQ==", "engines": { "node": ">=16.20.1" } @@ -2323,13 +2370,18 @@ "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==" }, "node_modules/call-bind": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz", - "integrity": "sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.1", - "set-function-length": "^1.1.1" + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2513,16 +2565,19 @@ } }, "node_modules/define-data-property": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.1.tgz", - "integrity": "sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", "dependencies": { - "get-intrinsic": "^1.2.1", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.0" + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/define-properties": { @@ -2646,27 +2701,27 @@ } }, "node_modules/engine.io-client": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.3.tgz", - "integrity": "sha512-9Z0qLB0NIisTRt1DZ/8U2k12RJn8yls/nXMZLn+/N8hANT3TcYjKFKcwbw5zFQiN4NTde3TSY9zb79e1ij6j9Q==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz", + "integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==", "dependencies": { "@socket.io/component-emitter": "~3.1.0", "debug": "~4.3.1", "engine.io-parser": "~5.2.1", - "ws": "~8.11.0", + "ws": "~8.17.1", "xmlhttprequest-ssl": "~2.0.0" } }, "node_modules/engine.io-client/node_modules/ws": { - "version": "8.11.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", - "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "engines": { "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -2678,9 +2733,9 @@ } }, "node_modules/engine.io-parser": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.1.tgz", - "integrity": "sha512-9JktcM3u18nU9N2Lz3bWeBgxVgOKpw7yhRaoxQA3FUDZzzw+9WlA6p4G4u0RixNkg14fH7EfEc/RhpurtiROTQ==", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz", + "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==", "engines": { "node": ">=10.0.0" } @@ -2701,6 +2756,25 @@ "errno": "cli.js" } }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.19.11", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.11.tgz", @@ -2740,9 +2814,9 @@ } }, "node_modules/escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", + "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "engines": { "node": ">=6" } @@ -2965,15 +3039,19 @@ } }, "node_modules/get-intrinsic": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz", - "integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", "dependencies": { + "es-errors": "^1.3.0", "function-bind": "^1.1.2", "has-proto": "^1.0.1", "has-symbols": "^1.0.3", "hasown": "^2.0.0" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -3026,6 +3104,9 @@ "version": "5.14.0", "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.14.0.tgz", "integrity": "sha512-itrUTQZP/TgswR4GSSYuwWUzrE/w5GhbwM2GX3ic2U7aw33jgEsayfIlvaj7/GcIvZgNMzsPTrE5hqPuFUiE5g==", + "workspaces": [ + "website" + ], "engines": { "node": ">=10" }, @@ -3055,11 +3136,11 @@ } }, "node_modules/has-property-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", - "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", "dependencies": { - "get-intrinsic": "^1.2.2" + "es-define-property": "^1.0.0" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -3325,15 +3406,29 @@ "ws": "*" } }, + "node_modules/isows": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.4.tgz", + "integrity": "sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wagmi-dev" + } + ], + "peerDependencies": { + "ws": "*" + } + }, "node_modules/isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" }, "node_modules/jose": { - "version": "4.15.4", - "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.4.tgz", - "integrity": "sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==", + "version": "4.15.9", + "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.9.tgz", + "integrity": "sha512-1vUQX+IdDMVPj4k8kOxgUqlcK518yluMuGZwqlr44FS1ppZB/5GWh4rZG89erpOBOJjU/OBsnCVFfapsRz6nEA==", "funding": { "url": "https://github.com/sponsors/panva" } @@ -4163,13 +4258,14 @@ "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" }, "node_modules/regexp.prototype.flags": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.1.tgz", - "integrity": "sha512-sy6TXMN+hnP/wMy+ISxg3krXx7BAtWVO4UouuCN/ziM9UEne0euamVNafDfvC83bRNr95y0V5iijeDQFUNpvrg==", + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz", + "integrity": "sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==", "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.2.0", - "set-function-name": "^2.0.0" + "call-bind": "^1.0.6", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "set-function-name": "^2.0.1" }, "engines": { "node": ">= 0.4" @@ -4377,28 +4473,30 @@ } }, "node_modules/set-function-length": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.0.tgz", - "integrity": "sha512-4DBHDoyHlM1IRPGYcoxexgh67y4ueR53FKV1yyxwFMY7aCqcN/38M1+SwZ/qJQ8iLv7+ck385ot4CcisOAPT9w==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", "dependencies": { - "define-data-property": "^1.1.1", + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.1" + "has-property-descriptors": "^1.0.2" }, "engines": { "node": ">= 0.4" } }, "node_modules/set-function-name": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz", - "integrity": "sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", "dependencies": { - "define-data-property": "^1.0.1", + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", "functions-have-names": "^1.2.3", - "has-property-descriptors": "^1.0.0" + "has-property-descriptors": "^1.0.2" }, "engines": { "node": ">= 0.4" diff --git a/examples/node/package.json b/examples/node/package.json index cbf15116..08bce2f8 100644 --- a/examples/node/package.json +++ b/examples/node/package.json @@ -12,11 +12,12 @@ "license": "ISC", "type": "module", "dependencies": { - "@atala/prism-wallet-sdk": "^4.0.0-rc.1", + "@atala/prism-wallet-sdk": "^5.1.0", "@pluto-encrypted/database": "^1.15.1", "@pluto-encrypted/iagon": "^0.0.0-beta.18", - "@pluto-encrypted/inmemory": "^1.12.1", + "@pluto-encrypted/inmemory": "^1.12.2", "@pluto-encrypted/leveldb": "^1.12.1", + "@pluto-encrypted/schemas": "^1.3.5", "fake-indexeddb": "^5.0.1", "prettier": "^3.0.2" }, @@ -27,4 +28,4 @@ "tsx": "^4.6.2", "typescript": "^5.2.2" } -} \ No newline at end of file +} diff --git a/examples/node/src/inmemory.js b/examples/node/src/inmemory.js index e1921581..0424c567 100644 --- a/examples/node/src/inmemory.js +++ b/examples/node/src/inmemory.js @@ -1,69 +1,73 @@ -import { getDefaultCollections } from '@pluto-encrypted/schemas'; - -async function createTestScenario() { - - const PlutoEncrypted = await import('@pluto-encrypted/database') - const { default: InMemory } = await import("@pluto-encrypted/inmemory") - const { default: SDK } = await import("@atala/prism-wallet-sdk"); - - const { Database } = PlutoEncrypted; - const defaultPassword = new Uint8Array(32).fill(1); - const mediatorDID = SDK.Domain.DID.fromString( - "did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjoiaHR0cHM6Ly9iZXRhLW1lZGlhdG9yLmF0YWxhcHJpc20uaW8iLCJyIjpbXSwiYSI6WyJkaWRjb21tL3YyIl19" - ); - const apollo = new SDK.Apollo(); - const api = new SDK.ApiImpl(); - const castor = new SDK.Castor(apollo); - const pluto = await Database.createEncrypted( - { - name: `my-db`, - encryptionKey: defaultPassword, - storage: InMemory, - collections: getDefaultCollections() - } - ); - const didcomm = new SDK.DIDCommWrapper(apollo, castor, pluto); - const mercury = new SDK.Mercury(castor, didcomm, api); - const store = new SDK.PublicMediatorStore(pluto); - const handler = new SDK.BasicMediatorHandler(mediatorDID, mercury, store); - const manager = new SDK.ConnectionsManager(castor, mercury, pluto, handler); +import InMemory from "@pluto-encrypted/inmemory"; +import SDK from "@atala/prism-wallet-sdk"; + + +// TODO: move DID to env +// https://sit-prism-mediator.atalaprism.io/ - NOTE: currently returning a 504 +// const mediatorDIDString = 'did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHBzOi8vc2l0LXByaXNtLW1lZGlhdG9yLmF0YWxhcHJpc20uaW8iLCJhIjpbImRpZGNvbW0vdjIiXX19.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6IndzczovL3NpdC1wcmlzbS1tZWRpYXRvci5hdGFsYXByaXNtLmlvL3dzIiwiYSI6WyJkaWRjb21tL3YyIl19fQ' + +// local mediator did +const mediatorDIDString = 'did:peer:2.Ez6LSghwSE437wnDE1pt3X6hVDUQzSjsHzinpX3XFvMjRAm7y.Vz6Mkhh1e5CEYYq6JBUcTZ6Cp2ranCWRrv7Yax3Le4N59R6dd.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6Imh0dHBzOi8vc2FuZGJveC1tZWRpYXRvci5hdGFsYXByaXNtLmlvIiwiYSI6WyJkaWRjb21tL3YyIl19fQ.SeyJ0IjoiZG0iLCJzIjp7InVyaSI6IndzczovL3NhbmRib3gtbWVkaWF0b3IuYXRhbGFwcmlzbS5pby93cyIsImEiOlsiZGlkY29tbS92MiJdfX0' + +async function createAgent () { + const mediatorDID = SDK.Domain.DID.fromString(mediatorDIDString) + + const store = new SDK.Store({ + name: 'test', + storage: InMemory, + password: Buffer.from("demoapp").toString("hex") + }) + + const apollo = new SDK.Apollo() const seed = apollo.createRandomSeed(); - const agent = new SDK.Agent( - apollo, - castor, - pluto, - mercury, - handler, - manager, - seed.seed, - ); + + const pluto = new SDK.Pluto( + store, + apollo + ) + return { - SDK, - apollo, - seed, - agent, - mercury, - pluto, - castor, - }; + agent: SDK.Agent.initialize({ mediatorDID, pluto, apollo, seed: seed.seed }), + seed + } } (async () => { + // create the SDK agent + const { + seed, + agent + } = await createAgent() + .catch(err => console.error('Failed to create the agent', err)) + console.log('Agent created') + + // start the SDK agent + await agent.start() + .catch(err => console.error('Failed to start the agent', err)) - const { seed, agent, SDK } = await createTestScenario(); + console.log('Agent started and mediation has been established') - agent.addListener(SDK.ListenerKey.MESSAGE, (message) => { + + // listen for new messages + agent.addListener(SDK.ListenerKey.MESSAGE, async (message) => { console.log("Got new message", message); - }); - await agent.start(); + // await agent.stop() + // .then(() => console.log('Agent stopped')) + }); + + console.log() console.log( `Welcome to PrismEdge Agent, state ${agent.state } with mnemonics ${seed.mnemonics.join(", ")}`, - ); + ) + console.log() + + // Send a message try { + console.log('Creating test message') const secondaryDID = await agent.createNewPeerDID([], true); const message = new SDK.BasicMessage( { content: "Test Message" }, @@ -73,10 +77,19 @@ async function createTestScenario() { await agent.sendMessage(message.makeMessage()); await agent.sendMessage(message.makeMessage()); - console.log("Sent"); + + console.log('Test message sent!') } catch (err) { - console.log( - "Safe to ignore, mediator returns null on successfully receiving the message, unpack fails.", - ); + if (/Malformed: Message is not a valid JWE, JWS or JWM/.test(err.message)) { + // NOTE: Safe to ignore, mediator returns null on successfully receiving the message, unpack fails. + console.log('Test message sent!') + } else { + throw err + } } })(); + + + + +