From c0df4ef35a636a3fcc986ddce78a2abd260477b0 Mon Sep 17 00:00:00 2001 From: Sai Ranjit Tummalapalli Date: Wed, 29 Nov 2023 16:45:49 +0530 Subject: [PATCH] refactor: merge tag 0.4.2 into develop (#5) * fix: listen to incoming messages on agent initialize not constructor (#1542) Signed-off-by: Niall Shaw * fix(cheqd): make cosmos payer seed optional (#1547) Signed-off-by: Timo Glastra * fix: create message subscription first (#1549) Signed-off-by: Timo Glastra * fix(transport): Use connection in WebSocket ID (#1551) * fix: priority sorting for didcomm services (#1555) Signed-off-by: Timo Glastra * fix: bump missing dependencies version (#1557) Signed-off-by: Eric Vergnaud * chore(release): v0.4.1 (#1548) Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: do not send package via outdated session (#1559) Signed-off-by: Niall Shaw * build(deps): bump @types/indy-sdk from 1.16.26 to 1.16.27 (#1564) Signed-off-by: dependabot[bot] * fix(cheqd): changed the name formatting to a encoded hex value (#1574) Signed-off-by: Tom Lanser * build(deps): bump @cheqd/ts-proto from 2.2.0 to 2.2.2 (#1568) Signed-off-by: dependabot[bot] * build(deps): bump @cosmjs/proto-signing from 0.31.0 to 0.31.1 (#1566) Signed-off-by: dependabot[bot] * fix(core): remove node-fetch dependency (#1578) Signed-off-by: Ariel Gentile * fix: log and throw on WebSocket sending errors (#1573) Signed-off-by: Eric Vergnaud * fix(oob): support oob with connection and messages (#1558) Signed-off-by: Timo Glastra * feat: allow connection invitation encoded in oob url param (#1583) Signed-off-by: Ariel Gentile * fix: duplicate service ids in connections protocol (#1589) * fix: implicit invitation to specific service (#1592) Signed-off-by: Ariel Gentile * fix(askar): throw error if imported wallet exists (#1593) Signed-off-by: Ariel Gentile * fix: service validation in OOB invitation objects (#1575) Signed-off-by: Ariel Gentile * fix: update tsyringe for ts 5 support (#1588) Signed-off-by: Timo Glastra * chore(release): v0.4.2 (#1591) Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: update yarn.lock Signed-off-by: Sai Ranjit Tummalapalli --------- Signed-off-by: Niall Shaw Signed-off-by: Timo Glastra Signed-off-by: Eric Vergnaud Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Signed-off-by: dependabot[bot] Signed-off-by: Tom Lanser Signed-off-by: Ariel Gentile Signed-off-by: Sai Ranjit Tummalapalli Co-authored-by: Niall Shaw <100220424+niall-shaw@users.noreply.github.com> Co-authored-by: Timo Glastra Co-authored-by: Alexander Shenshin <93187809+AlexanderShenshin@users.noreply.github.com> Co-authored-by: ericvergnaud Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Lanser Co-authored-by: Ariel Gentile --- CHANGELOG.md | 44 +++++ Dockerfile | 4 +- lerna.json | 2 +- package.json | 2 +- packages/action-menu/CHANGELOG.md | 10 + packages/action-menu/package.json | 4 +- packages/anoncreds-rs/CHANGELOG.md | 12 ++ packages/anoncreds-rs/package.json | 8 +- packages/anoncreds/CHANGELOG.md | 17 ++ packages/anoncreds/package.json | 6 +- .../credentials/v1/V1CredentialProtocol.ts | 28 ++- .../V1CredentialProtocolCred.test.ts | 2 - .../protocols/proofs/v1/V1ProofProtocol.ts | 25 ++- .../__tests__/__snapshots__/0.3.test.ts.snap | 4 + packages/askar/CHANGELOG.md | 17 ++ packages/askar/package.json | 6 +- packages/askar/src/wallet/AskarWallet.ts | 47 +++-- packages/askar/tests/askar-sqlite.e2e.test.ts | 65 +++++++ packages/bbs-signatures/CHANGELOG.md | 8 + packages/bbs-signatures/package.json | 6 +- packages/cheqd/CHANGELOG.md | 14 ++ packages/cheqd/package.json | 10 +- packages/cheqd/src/CheqdModule.ts | 7 +- packages/cheqd/src/CheqdModuleConfig.ts | 2 +- .../services/CheqdAnonCredsRegistry.ts | 11 +- .../cheqd/src/ledger/CheqdLedgerService.ts | 6 +- packages/core/CHANGELOG.md | 36 ++++ packages/core/package.json | 7 +- packages/core/src/agent/Agent.ts | 43 ++--- packages/core/src/agent/MessageSender.ts | 3 +- packages/core/src/agent/TransportService.ts | 14 ++ .../src/agent/getOutboundMessageContext.ts | 9 +- .../connections/ConnectionsModuleConfig.ts | 3 + .../__tests__/ConnectionService.test.ts | 4 +- .../connections/__tests__/helpers.test.ts | 4 +- .../modules/connections/models/did/DidDoc.ts | 2 +- .../models/did/__tests__/DidDoc.test.ts | 2 +- .../connections/services/ConnectionService.ts | 86 ++++++++- .../modules/connections/services/helpers.ts | 6 +- .../src/modules/credentials/CredentialsApi.ts | 1 + .../v2/CredentialFormatCoordinator.ts | 12 +- .../protocol/v2/V2CredentialProtocol.ts | 22 ++- .../V2CredentialProtocolCred.test.ts | 17 +- .../repository/CredentialExchangeRecord.ts | 5 + .../services/DidCommDocumentService.ts | 17 +- .../__tests__/DidCommDocumentService.test.ts | 84 +++++++++ .../src/modules/dids/domain/DidDocument.ts | 2 +- .../dids/domain/__tests__/DidDocument.test.ts | 2 +- .../MessagePickupApi.ts" | 9 +- packages/core/src/modules/oob/OutOfBandApi.ts | 84 +++++++-- .../oob/__tests__/OutOfBandInvitation.test.ts | 51 +++++ .../oob/__tests__/implicit.e2e.test.ts | 60 ++++-- packages/core/src/modules/oob/helpers.ts | 6 +- .../oob/messages/OutOfBandInvitation.ts | 19 +- .../outOfBandRecordMetadataTypes.ts | 9 + .../protocol/v2/ProofFormatCoordinator.ts | 2 +- .../proofs/protocol/v2/V2ProofProtocol.ts | 20 +- .../__tests__/__snapshots__/0.1.test.ts.snap | 8 + .../core/src/transport/WsOutboundTransport.ts | 5 +- packages/core/src/types.ts | 4 + .../src/utils/__tests__/shortenedUrl.test.ts | 35 +++- packages/core/src/utils/parseInvitation.ts | 70 ++++--- .../error/WalletImportPathExistsError.ts | 7 + packages/core/src/wallet/error/index.ts | 1 + packages/core/tests/logger.ts | 6 +- packages/core/tests/oob.test.ts | 88 +++++++++ .../indy-sdk-to-askar-migration/CHANGELOG.md | 8 + .../indy-sdk-to-askar-migration/package.json | 12 +- packages/indy-sdk/CHANGELOG.md | 17 ++ packages/indy-sdk/package.json | 10 +- packages/indy-vdr/CHANGELOG.md | 10 + packages/indy-vdr/package.json | 6 +- packages/node/CHANGELOG.md | 12 ++ packages/node/package.json | 4 +- .../node/src/transport/WsInboundTransport.ts | 19 +- packages/openid4vc-client/CHANGELOG.md | 8 + packages/openid4vc-client/package.json | 6 +- packages/question-answer/CHANGELOG.md | 10 + packages/question-answer/package.json | 6 +- packages/react-native/CHANGELOG.md | 11 ++ packages/react-native/package.json | 4 +- packages/tenants/CHANGELOG.md | 10 + packages/tenants/package.json | 6 +- yarn.lock | 177 ++++++++++++------ 84 files changed, 1273 insertions(+), 295 deletions(-) create mode 100644 packages/core/src/wallet/error/WalletImportPathExistsError.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index a1f116ebc0..8a8b807b26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,50 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- **askar:** throw error if imported wallet exists ([#1593](https://github.com/hyperledger/aries-framework-javascript/issues/1593)) ([c2bb2a5](https://github.com/hyperledger/aries-framework-javascript/commit/c2bb2a52f10add35de883c9a27716db01b9028df)) +- **cheqd:** changed the name formatting to a encoded hex value ([#1574](https://github.com/hyperledger/aries-framework-javascript/issues/1574)) ([d299f55](https://github.com/hyperledger/aries-framework-javascript/commit/d299f55113cb4c59273ae9fbbb8773b6f0009192)) +- **core:** remove node-fetch dependency ([#1578](https://github.com/hyperledger/aries-framework-javascript/issues/1578)) ([9ee2ce7](https://github.com/hyperledger/aries-framework-javascript/commit/9ee2ce7f0913510fc5b36aef1b7eeffb259b4aed)) +- do not send package via outdated session ([#1559](https://github.com/hyperledger/aries-framework-javascript/issues/1559)) ([de6a735](https://github.com/hyperledger/aries-framework-javascript/commit/de6a735a900b6d7444b17d79e63acaca19cb812a)) +- duplicate service ids in connections protocol ([#1589](https://github.com/hyperledger/aries-framework-javascript/issues/1589)) ([dd75be8](https://github.com/hyperledger/aries-framework-javascript/commit/dd75be88c4e257b6ca76868ceaeb3a8b7d67c185)) +- implicit invitation to specific service ([#1592](https://github.com/hyperledger/aries-framework-javascript/issues/1592)) ([4071dc9](https://github.com/hyperledger/aries-framework-javascript/commit/4071dc97b8ca779e6def3711a538ae821e1e513c)) +- log and throw on WebSocket sending errors ([#1573](https://github.com/hyperledger/aries-framework-javascript/issues/1573)) ([11050af](https://github.com/hyperledger/aries-framework-javascript/commit/11050afc7965adfa9b00107ba34abfbe3afaf874)) +- **oob:** support oob with connection and messages ([#1558](https://github.com/hyperledger/aries-framework-javascript/issues/1558)) ([9732ce4](https://github.com/hyperledger/aries-framework-javascript/commit/9732ce436a0ddee8760b02ac5182e216a75176c2)) +- service validation in OOB invitation objects ([#1575](https://github.com/hyperledger/aries-framework-javascript/issues/1575)) ([91a9434](https://github.com/hyperledger/aries-framework-javascript/commit/91a9434efd53ccbaf80f5613cd908913ad3b806b)) +- update tsyringe for ts 5 support ([#1588](https://github.com/hyperledger/aries-framework-javascript/issues/1588)) ([296955b](https://github.com/hyperledger/aries-framework-javascript/commit/296955b3a648416ac6b502da05a10001920af222)) + +### Features + +- allow connection invitation encoded in oob url param ([#1583](https://github.com/hyperledger/aries-framework-javascript/issues/1583)) ([9d789fa](https://github.com/hyperledger/aries-framework-javascript/commit/9d789fa4e9d159312872f45089d73609eb3d6835)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **anoncreds:** wrong key name for predicates in proof object ([#1517](https://github.com/hyperledger/aries-framework-javascript/issues/1517)) ([d895c78](https://github.com/hyperledger/aries-framework-javascript/commit/d895c78e0e02954a95ad1fd7e2251ee9a02445dc)) +- **askar:** in memory wallet creation ([#1498](https://github.com/hyperledger/aries-framework-javascript/issues/1498)) ([4a158e6](https://github.com/hyperledger/aries-framework-javascript/commit/4a158e64b97595be0733d4277c28c462bd47c908)) +- check if URL already encoded ([#1485](https://github.com/hyperledger/aries-framework-javascript/issues/1485)) ([38a0578](https://github.com/hyperledger/aries-framework-javascript/commit/38a0578011896cfcf217713d34f285cd381ad72c)) +- **cheqd:** make cosmos payer seed optional ([#1547](https://github.com/hyperledger/aries-framework-javascript/issues/1547)) ([9377378](https://github.com/hyperledger/aries-framework-javascript/commit/9377378b0124bf2f593342dba95a13ea5d8944c8)) +- create message subscription first ([#1549](https://github.com/hyperledger/aries-framework-javascript/issues/1549)) ([93276de](https://github.com/hyperledger/aries-framework-javascript/commit/93276debeff1e56c9803e7700875c4254a48236b)) +- encode tails url ([#1479](https://github.com/hyperledger/aries-framework-javascript/issues/1479)) ([fd190b9](https://github.com/hyperledger/aries-framework-javascript/commit/fd190b96106ca4916539d96ff6c4ecef7833f148)) +- force did:key resolver/registrar presence ([#1535](https://github.com/hyperledger/aries-framework-javascript/issues/1535)) ([aaa13dc](https://github.com/hyperledger/aries-framework-javascript/commit/aaa13dc77d6d5133cd02e768e4173462fa65064a)) +- **indy-vdr:** role property not included in nym request ([#1488](https://github.com/hyperledger/aries-framework-javascript/issues/1488)) ([002be4f](https://github.com/hyperledger/aries-framework-javascript/commit/002be4f578729aed1c8ae337f3d2eeecce9e3725)) +- listen to incoming messages on agent initialize not constructor ([#1542](https://github.com/hyperledger/aries-framework-javascript/issues/1542)) ([8f2d593](https://github.com/hyperledger/aries-framework-javascript/commit/8f2d593bcda0bb2d7bea25ad06b9e37784961997)) +- priority sorting for didcomm services ([#1555](https://github.com/hyperledger/aries-framework-javascript/issues/1555)) ([80c37b3](https://github.com/hyperledger/aries-framework-javascript/commit/80c37b30eb9ac3b438288e14c252f79f619dd12f)) +- race condition singleton records ([#1495](https://github.com/hyperledger/aries-framework-javascript/issues/1495)) ([6c2dda5](https://github.com/hyperledger/aries-framework-javascript/commit/6c2dda544bf5f5d3a972a778c389340da6df97c4)) +- **samples:** mediator wallet and http transport ([#1508](https://github.com/hyperledger/aries-framework-javascript/issues/1508)) ([04a8058](https://github.com/hyperledger/aries-framework-javascript/commit/04a80589b19725fb493e51e52a7345915b2c7341)) +- **transport:** Use connection in WebSocket ID ([#1551](https://github.com/hyperledger/aries-framework-javascript/issues/1551)) ([8d2057f](https://github.com/hyperledger/aries-framework-javascript/commit/8d2057f3fe6f3ba236ba5a811b57a7256eae92bf)) + +### Features + +- **anoncreds:** auto create link secret ([#1521](https://github.com/hyperledger/aries-framework-javascript/issues/1521)) ([c6f03e4](https://github.com/hyperledger/aries-framework-javascript/commit/c6f03e49d79a33b1c4b459cef11add93dee051d0)) +- oob without handhsake improvements and routing ([#1511](https://github.com/hyperledger/aries-framework-javascript/issues/1511)) ([9e69cf4](https://github.com/hyperledger/aries-framework-javascript/commit/9e69cf441a75bf7a3c5556cf59e730ee3fce8c28)) +- support askar profiles for multi-tenancy ([#1538](https://github.com/hyperledger/aries-framework-javascript/issues/1538)) ([e448a2a](https://github.com/hyperledger/aries-framework-javascript/commit/e448a2a58dddff2cdf80c4549ea2d842a54b43d1)) +- **w3c:** add convenience methods to vc and vp ([#1477](https://github.com/hyperledger/aries-framework-javascript/issues/1477)) ([83cbfe3](https://github.com/hyperledger/aries-framework-javascript/commit/83cbfe38e788366b616dc244fe34cc49a5a4d331)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/Dockerfile b/Dockerfile index 9514936098..e5490c3880 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,10 +14,10 @@ ENV PACKAGES software-properties-common ca-certificates \ RUN apt-get update -y \ && apt-get install -y $PACKAGES -RUN curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.21_amd64.deb -o libssl1.1.deb \ +RUN curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1-1ubuntu2.1~18.04.23_amd64.deb -o libssl1.1.deb \ # libssl1.1 (required by libindy) && dpkg -i libssl1.1.deb \ - && curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1-1ubuntu2.1~18.04.21_amd64.deb -o libssl-dev1.1.deb \ + && curl http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl-dev_1.1.1-1ubuntu2.1~18.04.23_amd64.deb -o libssl-dev1.1.deb \ # libssl-dev1.1 (required to compile libindy with posgres plugin) && dpkg -i libssl-dev1.1.deb diff --git a/lerna.json b/lerna.json index fc5df5f158..e872504c29 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "packages": ["packages/*"], - "version": "0.4.0", + "version": "0.4.2", "useWorkspaces": true, "npmClient": "yarn", "command": { diff --git a/package.json b/package.json index 222fb1d497..a9b4a23326 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "ts-jest": "^29.0.5", "ts-node": "^10.0.0", "tsconfig-paths": "^4.1.2", - "tsyringe": "^4.7.0", + "tsyringe": "^4.8.0", "typescript": "~4.9.5", "ws": "^8.13.0" }, diff --git a/packages/action-menu/CHANGELOG.md b/packages/action-menu/CHANGELOG.md index 8a9b0d0cda..ffe4bbf8b1 100644 --- a/packages/action-menu/CHANGELOG.md +++ b/packages/action-menu/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/action-menu + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Features + +- oob without handhsake improvements and routing ([#1511](https://github.com/hyperledger/aries-framework-javascript/issues/1511)) ([9e69cf4](https://github.com/hyperledger/aries-framework-javascript/commit/9e69cf441a75bf7a3c5556cf59e730ee3fce8c28)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/action-menu/package.json b/packages/action-menu/package.json index ea2480bcb7..c9e76740ba 100644 --- a/packages/action-menu/package.json +++ b/packages/action-menu/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/action-menu", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,7 +24,7 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "class-transformer": "0.5.1", "class-validator": "0.14.0", "rxjs": "^7.2.0" diff --git a/packages/anoncreds-rs/CHANGELOG.md b/packages/anoncreds-rs/CHANGELOG.md index 550da05b2a..1edc25bd41 100644 --- a/packages/anoncreds-rs/CHANGELOG.md +++ b/packages/anoncreds-rs/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- update tsyringe for ts 5 support ([#1588](https://github.com/hyperledger/aries-framework-javascript/issues/1588)) ([296955b](https://github.com/hyperledger/aries-framework-javascript/commit/296955b3a648416ac6b502da05a10001920af222)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Features + +- **anoncreds:** auto create link secret ([#1521](https://github.com/hyperledger/aries-framework-javascript/issues/1521)) ([c6f03e4](https://github.com/hyperledger/aries-framework-javascript/commit/c6f03e49d79a33b1c4b459cef11add93dee051d0)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/anoncreds-rs/package.json b/packages/anoncreds-rs/package.json index a9719b5668..fd3cdb9868 100644 --- a/packages/anoncreds-rs/package.json +++ b/packages/anoncreds-rs/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/anoncreds-rs", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,12 +24,12 @@ "test": "jest" }, "dependencies": { - "@aries-framework/anoncreds": "0.4.0", - "@aries-framework/core": "0.4.0", + "@aries-framework/anoncreds": "0.4.2", + "@aries-framework/core": "0.4.2", "class-transformer": "^0.5.1", "class-validator": "0.14.0", "rxjs": "^7.2.0", - "tsyringe": "^4.7.0" + "tsyringe": "^4.8.0" }, "devDependencies": { "@hyperledger/anoncreds-nodejs": "^0.1.0", diff --git a/packages/anoncreds/CHANGELOG.md b/packages/anoncreds/CHANGELOG.md index ddd0fcf56f..ca47950fbe 100644 --- a/packages/anoncreds/CHANGELOG.md +++ b/packages/anoncreds/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- **oob:** support oob with connection and messages ([#1558](https://github.com/hyperledger/aries-framework-javascript/issues/1558)) ([9732ce4](https://github.com/hyperledger/aries-framework-javascript/commit/9732ce436a0ddee8760b02ac5182e216a75176c2)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **anoncreds:** wrong key name for predicates in proof object ([#1517](https://github.com/hyperledger/aries-framework-javascript/issues/1517)) ([d895c78](https://github.com/hyperledger/aries-framework-javascript/commit/d895c78e0e02954a95ad1fd7e2251ee9a02445dc)) + +### Features + +- **anoncreds:** auto create link secret ([#1521](https://github.com/hyperledger/aries-framework-javascript/issues/1521)) ([c6f03e4](https://github.com/hyperledger/aries-framework-javascript/commit/c6f03e49d79a33b1c4b459cef11add93dee051d0)) +- oob without handhsake improvements and routing ([#1511](https://github.com/hyperledger/aries-framework-javascript/issues/1511)) ([9e69cf4](https://github.com/hyperledger/aries-framework-javascript/commit/9e69cf441a75bf7a3c5556cf59e730ee3fce8c28)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/anoncreds/package.json b/packages/anoncreds/package.json index 623b93eaaf..2a232a35c3 100644 --- a/packages/anoncreds/package.json +++ b/packages/anoncreds/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/anoncreds", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,14 +24,14 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "bn.js": "^5.2.1", "class-transformer": "0.5.1", "class-validator": "0.14.0", "reflect-metadata": "^0.1.13" }, "devDependencies": { - "@aries-framework/node": "0.4.0", + "@aries-framework/node": "0.4.2", "indy-sdk": "^1.16.0-dev-1636", "rimraf": "^4.4.0", "rxjs": "^7.8.0", diff --git a/packages/anoncreds/src/protocols/credentials/v1/V1CredentialProtocol.ts b/packages/anoncreds/src/protocols/credentials/v1/V1CredentialProtocol.ts index 775c47aff5..67d7b3886e 100644 --- a/packages/anoncreds/src/protocols/credentials/v1/V1CredentialProtocol.ts +++ b/packages/anoncreds/src/protocols/credentials/v1/V1CredentialProtocol.ts @@ -327,7 +327,7 @@ export class V1CredentialProtocol attachments: credentialRecord.linkedAttachments, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) credentialRecord.credentialAttributes = message.credentialPreview.attributes credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential @@ -384,7 +384,7 @@ export class V1CredentialProtocol }), attachments: credentialRecord.linkedAttachments, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) credentialRecord.credentialAttributes = message.credentialPreview.attributes credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential @@ -541,6 +541,7 @@ export class V1CredentialProtocol credentialRecord = new CredentialExchangeRecord({ connectionId: connection?.id, threadId: offerMessage.threadId, + parentThreadId: offerMessage.thread?.parentThreadId, state: CredentialState.OfferReceived, protocolVersion: 'v1', }) @@ -612,7 +613,7 @@ export class V1CredentialProtocol requestAttachments: [attachment], attachments: offerMessage.appendedAttachments?.filter((attachment) => isLinkedAttachment(attachment)), }) - requestMessage.setThread({ threadId: credentialRecord.threadId }) + requestMessage.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) credentialRecord.credentialAttributes = offerMessage.credentialPreview.attributes credentialRecord.autoAcceptCredential = autoAcceptCredential ?? credentialRecord.autoAcceptCredential @@ -691,7 +692,7 @@ export class V1CredentialProtocol comment, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -731,11 +732,7 @@ export class V1CredentialProtocol agentContext.config.logger.debug(`Processing credential request with id ${requestMessage.id}`) - const credentialRecord = await this.getByThreadAndConnectionId( - messageContext.agentContext, - requestMessage.threadId, - connection?.id - ) + const credentialRecord = await this.getByThreadAndConnectionId(messageContext.agentContext, requestMessage.threadId) agentContext.config.logger.trace('Credential record found when processing credential request', credentialRecord) const proposalMessage = await didCommMessageRepository.findAgentMessage(messageContext.agentContext, { @@ -755,6 +752,15 @@ export class V1CredentialProtocol lastSentMessage: offerMessage ?? undefined, }) + // This makes sure that the sender of the incoming message is authorized to do so. + if (!credentialRecord.connectionId) { + await connectionService.matchIncomingMessageToRequestMessageInOutOfBandExchange(messageContext, { + expectedConnectionId: credentialRecord.connectionId, + }) + + credentialRecord.connectionId = connection?.id + } + const requestAttachment = requestMessage.getRequestAttachmentById(INDY_CREDENTIAL_REQUEST_ATTACHMENT_ID) if (!requestAttachment) { @@ -833,7 +839,7 @@ export class V1CredentialProtocol attachments: credentialRecord.linkedAttachments, }) - issueMessage.setThread({ threadId: credentialRecord.threadId }) + issueMessage.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) issueMessage.setPleaseAck() await didCommMessageRepository.saveAgentMessage(agentContext, { @@ -938,6 +944,8 @@ export class V1CredentialProtocol threadId: credentialRecord.threadId, }) + ackMessage.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) + await this.updateState(agentContext, credentialRecord, CredentialState.Done) return { message: ackMessage, credentialRecord } diff --git a/packages/anoncreds/src/protocols/credentials/v1/__tests__/V1CredentialProtocolCred.test.ts b/packages/anoncreds/src/protocols/credentials/v1/__tests__/V1CredentialProtocolCred.test.ts index 0abcbba515..d745c55a22 100644 --- a/packages/anoncreds/src/protocols/credentials/v1/__tests__/V1CredentialProtocolCred.test.ts +++ b/packages/anoncreds/src/protocols/credentials/v1/__tests__/V1CredentialProtocolCred.test.ts @@ -343,7 +343,6 @@ describe('V1CredentialProtocol', () => { // then expect(credentialRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, { threadId: 'somethreadid', - connectionId: connection.id, }) expect(repositoryUpdateSpy).toHaveBeenCalledTimes(1) expect(returnedCredentialRecord.state).toEqual(CredentialState.RequestReceived) @@ -360,7 +359,6 @@ describe('V1CredentialProtocol', () => { // then expect(credentialRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, { threadId: 'somethreadid', - connectionId: connection.id, }) expect(returnedCredentialRecord.state).toEqual(CredentialState.RequestReceived) }) diff --git a/packages/anoncreds/src/protocols/proofs/v1/V1ProofProtocol.ts b/packages/anoncreds/src/protocols/proofs/v1/V1ProofProtocol.ts index 606dc6e7ce..4a8df7c6e0 100644 --- a/packages/anoncreds/src/protocols/proofs/v1/V1ProofProtocol.ts +++ b/packages/anoncreds/src/protocols/proofs/v1/V1ProofProtocol.ts @@ -326,6 +326,7 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol< }) requestPresentationMessage.setThread({ threadId: proofRecord.threadId, + parentThreadId: proofRecord.parentThreadId, }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { @@ -523,7 +524,7 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol< comment, presentationProposal, }) - message.setThread({ threadId: proofRecord.threadId }) + message.setThread({ threadId: proofRecord.threadId, parentThreadId: proofRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -600,7 +601,7 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol< comment, presentationAttachments: [attachment], }) - message.setThread({ threadId: proofRecord.threadId }) + message.setThread({ threadId: proofRecord.threadId, parentThreadId: proofRecord.parentThreadId }) await didCommMessageRepository.saveAgentMessage(agentContext, { agentMessage: message, @@ -745,11 +746,7 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol< // only depends on the public api, rather than the internal API (this helps with breaking changes) const connectionService = agentContext.dependencyManager.resolve(ConnectionService) - const proofRecord = await this.getByThreadAndConnectionId( - agentContext, - presentationMessage.threadId, - connection?.id - ) + const proofRecord = await this.getByThreadAndConnectionId(agentContext, presentationMessage.threadId) const proposalMessage = await didCommMessageRepository.findAgentMessage(agentContext, { associatedRecordId: proofRecord.id, @@ -769,6 +766,15 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol< lastSentMessage: requestMessage, }) + // This makes sure that the sender of the incoming message is authorized to do so. + if (!proofRecord.connectionId) { + await connectionService.matchIncomingMessageToRequestMessageInOutOfBandExchange(messageContext, { + expectedConnectionId: proofRecord.connectionId, + }) + + proofRecord.connectionId = connection?.id + } + const presentationAttachment = presentationMessage.getPresentationAttachmentById(INDY_PROOF_ATTACHMENT_ID) if (!presentationAttachment) { throw new AriesFrameworkError('Missing indy proof attachment in processPresentation') @@ -814,6 +820,11 @@ export class V1ProofProtocol extends BaseProofProtocol implements ProofProtocol< threadId: proofRecord.threadId, }) + ackMessage.setThread({ + threadId: proofRecord.threadId, + parentThreadId: proofRecord.parentThreadId, + }) + // Update record await this.updateState(agentContext, proofRecord, ProofState.Done) diff --git a/packages/anoncreds/src/updates/__tests__/__snapshots__/0.3.test.ts.snap b/packages/anoncreds/src/updates/__tests__/__snapshots__/0.3.test.ts.snap index 1aacd46acc..d6061e5889 100644 --- a/packages/anoncreds/src/updates/__tests__/__snapshots__/0.3.test.ts.snap +++ b/packages/anoncreds/src/updates/__tests__/__snapshots__/0.3.test.ts.snap @@ -27,6 +27,7 @@ exports[`UpdateAssistant | AnonCreds | v0.3.1 - v0.4 should correctly update the "credentialIds": [ "f54d231b-ef4f-4da5-adad-b10a1edaeb18", ], + "parentThreadId": undefined, "state": "done", "threadId": "c5fc78be-b355-4411-86f3-3d97482b9841", }, @@ -209,6 +210,7 @@ exports[`UpdateAssistant | AnonCreds | v0.3.1 - v0.4 should correctly update the "tags": { "connectionId": undefined, "credentialIds": [], + "parentThreadId": undefined, "state": "offer-received", "threadId": "f9f79a46-a4d8-4ee7-9745-1b9cdf03676b", }, @@ -511,6 +513,7 @@ exports[`UpdateAssistant | AnonCreds | v0.3.1 - v0.4 should correctly update the "tags": { "connectionId": undefined, "credentialIds": [], + "parentThreadId": undefined, "state": "offer-sent", "threadId": "f9f79a46-a4d8-4ee7-9745-1b9cdf03676b", }, @@ -604,6 +607,7 @@ exports[`UpdateAssistant | AnonCreds | v0.3.1 - v0.4 should correctly update the "tags": { "connectionId": undefined, "credentialIds": [], + "parentThreadId": undefined, "state": "done", "threadId": "c5fc78be-b355-4411-86f3-3d97482b9841", }, diff --git a/packages/askar/CHANGELOG.md b/packages/askar/CHANGELOG.md index 4e6473e429..26a507de52 100644 --- a/packages/askar/CHANGELOG.md +++ b/packages/askar/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- **askar:** throw error if imported wallet exists ([#1593](https://github.com/hyperledger/aries-framework-javascript/issues/1593)) ([c2bb2a5](https://github.com/hyperledger/aries-framework-javascript/commit/c2bb2a52f10add35de883c9a27716db01b9028df)) +- update tsyringe for ts 5 support ([#1588](https://github.com/hyperledger/aries-framework-javascript/issues/1588)) ([296955b](https://github.com/hyperledger/aries-framework-javascript/commit/296955b3a648416ac6b502da05a10001920af222)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **askar:** in memory wallet creation ([#1498](https://github.com/hyperledger/aries-framework-javascript/issues/1498)) ([4a158e6](https://github.com/hyperledger/aries-framework-javascript/commit/4a158e64b97595be0733d4277c28c462bd47c908)) + +### Features + +- support askar profiles for multi-tenancy ([#1538](https://github.com/hyperledger/aries-framework-javascript/issues/1538)) ([e448a2a](https://github.com/hyperledger/aries-framework-javascript/commit/e448a2a58dddff2cdf80c4549ea2d842a54b43d1)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/askar/package.json b/packages/askar/package.json index a2065acfe4..760e942d73 100644 --- a/packages/askar/package.json +++ b/packages/askar/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/askar", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,12 +24,12 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "bn.js": "^5.2.1", "class-transformer": "0.5.1", "class-validator": "0.14.0", "rxjs": "^7.2.0", - "tsyringe": "^4.7.0" + "tsyringe": "^4.8.0" }, "devDependencies": { "@hyperledger/aries-askar-nodejs": "^0.1.0", diff --git a/packages/askar/src/wallet/AskarWallet.ts b/packages/askar/src/wallet/AskarWallet.ts index 7a46016027..e69a318fd0 100644 --- a/packages/askar/src/wallet/AskarWallet.ts +++ b/packages/askar/src/wallet/AskarWallet.ts @@ -12,6 +12,7 @@ import { FileSystem, WalletNotFoundError, KeyDerivationMethod, + WalletImportPathExistsError, } from '@aries-framework/core' // eslint-disable-next-line import/order import { Store } from '@hyperledger/aries-askar-shared' @@ -111,6 +112,11 @@ export class AskarWallet extends AskarBaseWallet { }) } try { + // Make sure path exists before creating the wallet + if (filePath) { + await this.fileSystem.createDirectory(filePath) + } + this._store = await Store.provision({ recreate: false, uri: askarWalletConfig.uri, @@ -280,7 +286,12 @@ export class AskarWallet extends AskarBaseWallet { } try { - // This method ensures that destination directory is created + // Export path already exists + if (await this.fileSystem.exists(destinationPath)) { + throw new WalletExportPathExistsError( + `Unable to create export, wallet export at path '${exportConfig.path}' already exists` + ) + } const exportedWalletConfig = await this.getAskarWalletConfig({ ...this.walletConfig, storage: { type: 'sqlite', path: destinationPath }, @@ -289,12 +300,8 @@ export class AskarWallet extends AskarBaseWallet { // Close this wallet before copying await this.close() - // Export path already exists - if (await this.fileSystem.exists(destinationPath)) { - throw new WalletExportPathExistsError( - `Unable to create export, wallet export at path '${exportConfig.path}' already exists` - ) - } + // Make sure destination path exists + await this.fileSystem.createDirectory(destinationPath) // Copy wallet to the destination path await this.fileSystem.copyFile(sourcePath, destinationPath) @@ -311,14 +318,14 @@ export class AskarWallet extends AskarBaseWallet { await this._open(this.walletConfig) } catch (error) { - if (error instanceof WalletExportPathExistsError) throw error - const errorMessage = `Error exporting wallet '${this.walletConfig.id}': ${error.message}` this.logger.error(errorMessage, { error, errorMessage: error.message, }) + if (error instanceof WalletExportPathExistsError) throw error + throw new WalletError(errorMessage, { cause: error }) } } @@ -332,9 +339,16 @@ export class AskarWallet extends AskarBaseWallet { } try { - // This method ensures that destination directory is created const importWalletConfig = await this.getAskarWalletConfig(walletConfig) + // Import path already exists + if (await this.fileSystem.exists(destinationPath)) { + throw new WalletExportPathExistsError(`Unable to import wallet. Path '${importConfig.path}' already exists`) + } + + // Make sure destination path exists + await this.fileSystem.createDirectory(destinationPath) + // Copy wallet to the destination path await this.fileSystem.copyFile(sourcePath, destinationPath) @@ -355,6 +369,13 @@ export class AskarWallet extends AskarBaseWallet { errorMessage: error.message, }) + if (error instanceof WalletImportPathExistsError) throw error + + // Cleanup any wallet file we could have created + if (await this.fileSystem.exists(destinationPath)) { + await this.fileSystem.delete(destinationPath) + } + throw new WalletError(errorMessage, { cause: error }) } } @@ -387,13 +408,9 @@ export class AskarWallet extends AskarBaseWallet { private async getAskarWalletConfig(walletConfig: WalletConfig) { const { uri, path } = uriFromWalletConfig(walletConfig, this.fileSystem.dataPath) - // Make sure path exists before creating the wallet - if (path) { - await this.fileSystem.createDirectory(path) - } - return { uri, + path, profile: walletConfig.id, // FIXME: Default derivation method should be set somewhere in either agent config or some constants keyMethod: keyDerivationMethodToStoreKeyMethod( diff --git a/packages/askar/tests/askar-sqlite.e2e.test.ts b/packages/askar/tests/askar-sqlite.e2e.test.ts index 41280f0684..e52b07fcce 100644 --- a/packages/askar/tests/askar-sqlite.e2e.test.ts +++ b/packages/askar/tests/askar-sqlite.e2e.test.ts @@ -147,6 +147,71 @@ describeRunInNodeVersion([18], 'Askar SQLite agents', () => { }) }) + test('throws error when attempting to export and import to existing paths', async () => { + await bobAgent.initialize() + + if (!bobAgent.config.walletConfig) { + throw new Error('No wallet config on bobAgent') + } + + const backupKey = 'someBackupKey' + const backupWalletName = `backup-${utils.uuid()}` + const backupPath = path.join(tmpdir(), backupWalletName) + + // Create backup and try to export it again to the same path + await bobAgent.wallet.export({ path: backupPath, key: backupKey }) + await expect(async () => await bobAgent.wallet.export({ path: backupPath, key: backupKey })).rejects.toThrowError( + /Unable to create export/ + ) + + await bobAgent.wallet.delete() + + // Import backup with different wallet id and initialize + await bobAgent.wallet.import({ id: backupWalletName, key: backupWalletName }, { path: backupPath, key: backupKey }) + await bobAgent.wallet.initialize({ id: backupWalletName, key: backupWalletName }) + await bobAgent.wallet.close() + + // Try to import again an existing wallet + await expect( + async () => + await bobAgent.wallet.import( + { id: backupWalletName, key: backupWalletName }, + { path: backupPath, key: backupKey } + ) + ).rejects.toThrowError(/Unable to import wallet/) + }) + + test('throws error when attempting to import using wrong key', async () => { + await bobAgent.initialize() + + if (!bobAgent.config.walletConfig) { + throw new Error('No wallet config on bobAgent') + } + + const backupKey = 'someBackupKey' + const wrongBackupKey = 'wrongBackupKey' + const backupWalletName = `backup-${utils.uuid()}` + const backupPath = path.join(tmpdir(), backupWalletName) + + // Create backup and try to export it again to the same path + await bobAgent.wallet.export({ path: backupPath, key: backupKey }) + await bobAgent.wallet.delete() + + // Try to import backup with wrong key + await expect( + async () => + await bobAgent.wallet.import( + { id: backupWalletName, key: backupWalletName }, + { path: backupPath, key: wrongBackupKey } + ) + ).rejects.toThrow() + + // Try to import again using the correct key + await bobAgent.wallet.import({ id: backupWalletName, key: backupWalletName }, { path: backupPath, key: backupKey }) + await bobAgent.wallet.initialize({ id: backupWalletName, key: backupWalletName }) + await bobAgent.wallet.close() + }) + test('changing wallet key', async () => { const walletConfig = { id: 'mywallet', diff --git a/packages/bbs-signatures/CHANGELOG.md b/packages/bbs-signatures/CHANGELOG.md index 04a0c23967..bf7bdabc78 100644 --- a/packages/bbs-signatures/CHANGELOG.md +++ b/packages/bbs-signatures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/bbs-signatures + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +**Note:** Version bump only for package @aries-framework/bbs-signatures + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/bbs-signatures/package.json b/packages/bbs-signatures/package.json index 33e08adfcd..ed01ad35fd 100644 --- a/packages/bbs-signatures/package.json +++ b/packages/bbs-signatures/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/bbs-signatures", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,7 +24,7 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "@mattrglobal/bbs-signatures": "^1.0.0", "@mattrglobal/bls12381-key-pair": "^1.0.0", "@stablelib/random": "^1.0.2" @@ -33,7 +33,7 @@ "@animo-id/react-native-bbs-signatures": "^0.1.0" }, "devDependencies": { - "@aries-framework/node": "0.4.0", + "@aries-framework/node": "0.4.2", "reflect-metadata": "^0.1.13", "rimraf": "^4.4.0", "typescript": "~4.9.5" diff --git a/packages/cheqd/CHANGELOG.md b/packages/cheqd/CHANGELOG.md index de6291ebfd..8c91f7a371 100644 --- a/packages/cheqd/CHANGELOG.md +++ b/packages/cheqd/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- **cheqd:** changed the name formatting to a encoded hex value ([#1574](https://github.com/hyperledger/aries-framework-javascript/issues/1574)) ([d299f55](https://github.com/hyperledger/aries-framework-javascript/commit/d299f55113cb4c59273ae9fbbb8773b6f0009192)) +- update tsyringe for ts 5 support ([#1588](https://github.com/hyperledger/aries-framework-javascript/issues/1588)) ([296955b](https://github.com/hyperledger/aries-framework-javascript/commit/296955b3a648416ac6b502da05a10001920af222)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **cheqd:** make cosmos payer seed optional ([#1547](https://github.com/hyperledger/aries-framework-javascript/issues/1547)) ([9377378](https://github.com/hyperledger/aries-framework-javascript/commit/9377378b0124bf2f593342dba95a13ea5d8944c8)) +- force did:key resolver/registrar presence ([#1535](https://github.com/hyperledger/aries-framework-javascript/issues/1535)) ([aaa13dc](https://github.com/hyperledger/aries-framework-javascript/commit/aaa13dc77d6d5133cd02e768e4173462fa65064a)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/cheqd/package.json b/packages/cheqd/package.json index ca62091a93..bb396fe211 100644 --- a/packages/cheqd/package.json +++ b/packages/cheqd/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/cheqd", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,8 +24,8 @@ "test": "jest" }, "dependencies": { - "@aries-framework/anoncreds": "0.4.0", - "@aries-framework/core": "0.4.0", + "@aries-framework/anoncreds": "0.4.2", + "@aries-framework/core": "0.4.2", "@cheqd/sdk": "cjs", "@cheqd/ts-proto": "cjs", "@cosmjs/crypto": "^0.29.5", @@ -34,10 +34,10 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "rxjs": "^7.2.0", - "tsyringe": "^4.7.0" + "tsyringe": "^4.8.0" }, "devDependencies": { - "@aries-framework/indy-sdk": "0.4.0", + "@aries-framework/indy-sdk": "0.4.2", "@types/indy-sdk": "*", "rimraf": "^4.0.7", "typescript": "~4.9.4" diff --git a/packages/cheqd/src/CheqdModule.ts b/packages/cheqd/src/CheqdModule.ts index dbd01f64f9..7ec15ed2ad 100644 --- a/packages/cheqd/src/CheqdModule.ts +++ b/packages/cheqd/src/CheqdModule.ts @@ -1,7 +1,7 @@ import type { CheqdModuleConfigOptions } from './CheqdModuleConfig' import type { AgentContext, DependencyManager, Module } from '@aries-framework/core' -import { AgentConfig } from '@aries-framework/core' +import { AgentConfig, Buffer } from '@aries-framework/core' import { CheqdModuleConfig } from './CheqdModuleConfig' import { CheqdLedgerService } from './ledger' @@ -25,6 +25,11 @@ export class CheqdModule implements Module { dependencyManager.registerInstance(CheqdModuleConfig, this.config) dependencyManager.registerSingleton(CheqdLedgerService) + + // Cheqd module needs Buffer to be available globally + // If it is not available yet, we overwrite it with the + // Buffer implementation from AFJ + global.Buffer = global.Buffer || Buffer } public async initialize(agentContext: AgentContext): Promise { diff --git a/packages/cheqd/src/CheqdModuleConfig.ts b/packages/cheqd/src/CheqdModuleConfig.ts index 3d0077883c..0dcfd31f20 100644 --- a/packages/cheqd/src/CheqdModuleConfig.ts +++ b/packages/cheqd/src/CheqdModuleConfig.ts @@ -7,7 +7,7 @@ export interface CheqdModuleConfigOptions { export interface NetworkConfig { rpcUrl?: string - cosmosPayerSeed: string + cosmosPayerSeed?: string network: string } diff --git a/packages/cheqd/src/anoncreds/services/CheqdAnonCredsRegistry.ts b/packages/cheqd/src/anoncreds/services/CheqdAnonCredsRegistry.ts index 4b3d5db18c..d9e27c18e2 100644 --- a/packages/cheqd/src/anoncreds/services/CheqdAnonCredsRegistry.ts +++ b/packages/cheqd/src/anoncreds/services/CheqdAnonCredsRegistry.ts @@ -12,7 +12,7 @@ import type { } from '@aries-framework/anoncreds' import type { AgentContext } from '@aries-framework/core' -import { AriesFrameworkError, JsonTransformer, utils } from '@aries-framework/core' +import { AriesFrameworkError, Buffer, Hasher, JsonTransformer, TypedArrayEncoder, utils } from '@aries-framework/core' import { CheqdDidResolver, CheqdDidRegistrar } from '../../dids' import { cheqdSdkAnonCredsRegistryIdentifierRegex, parseCheqdDid } from '../utils/identifiers' @@ -135,9 +135,16 @@ export class CheqdAnonCredsRegistry implements AnonCredsRegistry { const cheqdDidRegistrar = agentContext.dependencyManager.resolve(CheqdDidRegistrar) const { credentialDefinition } = options const schema = await this.getSchema(agentContext, credentialDefinition.schemaId) + if (!schema.schema) { + throw new Error(`Schema not found for schemaId: ${credentialDefinition.schemaId}`) + } + + const credDefName = `${schema.schema.name}-${credentialDefinition.tag}` + const credDefNameHashBuffer = Hasher.hash(Buffer.from(credDefName), 'sha2-256') + const credDefResource = { id: utils.uuid(), - name: `${schema.schema?.name}-${credentialDefinition.tag}-CredDef`, + name: TypedArrayEncoder.toHex(credDefNameHashBuffer), resourceType: 'anonCredsCredDef', data: { type: credentialDefinition.type, diff --git a/packages/cheqd/src/ledger/CheqdLedgerService.ts b/packages/cheqd/src/ledger/CheqdLedgerService.ts index 36adf6eb2a..cc460b2e60 100644 --- a/packages/cheqd/src/ledger/CheqdLedgerService.ts +++ b/packages/cheqd/src/ledger/CheqdLedgerService.ts @@ -3,7 +3,7 @@ import type { SignInfo } from '@cheqd/ts-proto/cheqd/did/v2' import type { MsgCreateResourcePayload } from '@cheqd/ts-proto/cheqd/resource/v2' import type { DirectSecp256k1HdWallet, DirectSecp256k1Wallet } from '@cosmjs/proto-signing' -import { injectable } from '@aries-framework/core' +import { AriesFrameworkError, injectable } from '@aries-framework/core' import { createCheqdSDK, DIDModule, ResourceModule, CheqdNetwork } from '@cheqd/sdk' import { CheqdModuleConfig } from '../CheqdModuleConfig' @@ -42,8 +42,8 @@ export class CheqdLedgerService { network.sdk = await createCheqdSDK({ modules: [DIDModule as unknown as AbstractCheqdSDKModule, ResourceModule as unknown as AbstractCheqdSDKModule], rpcUrl: network.rpcUrl, - wallet: await network.cosmosPayerWallet.catch(() => { - throw new Error(`[did-provider-cheqd]: valid cosmosPayerSeed is required`) + wallet: await network.cosmosPayerWallet.catch((error) => { + throw new AriesFrameworkError(`Error initializing cosmos payer wallet: ${error.message}`, { cause: error }) }), }) } diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 8f0e8886fd..325cc6aaab 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -3,6 +3,42 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- **askar:** throw error if imported wallet exists ([#1593](https://github.com/hyperledger/aries-framework-javascript/issues/1593)) ([c2bb2a5](https://github.com/hyperledger/aries-framework-javascript/commit/c2bb2a52f10add35de883c9a27716db01b9028df)) +- **core:** remove node-fetch dependency ([#1578](https://github.com/hyperledger/aries-framework-javascript/issues/1578)) ([9ee2ce7](https://github.com/hyperledger/aries-framework-javascript/commit/9ee2ce7f0913510fc5b36aef1b7eeffb259b4aed)) +- do not send package via outdated session ([#1559](https://github.com/hyperledger/aries-framework-javascript/issues/1559)) ([de6a735](https://github.com/hyperledger/aries-framework-javascript/commit/de6a735a900b6d7444b17d79e63acaca19cb812a)) +- duplicate service ids in connections protocol ([#1589](https://github.com/hyperledger/aries-framework-javascript/issues/1589)) ([dd75be8](https://github.com/hyperledger/aries-framework-javascript/commit/dd75be88c4e257b6ca76868ceaeb3a8b7d67c185)) +- implicit invitation to specific service ([#1592](https://github.com/hyperledger/aries-framework-javascript/issues/1592)) ([4071dc9](https://github.com/hyperledger/aries-framework-javascript/commit/4071dc97b8ca779e6def3711a538ae821e1e513c)) +- log and throw on WebSocket sending errors ([#1573](https://github.com/hyperledger/aries-framework-javascript/issues/1573)) ([11050af](https://github.com/hyperledger/aries-framework-javascript/commit/11050afc7965adfa9b00107ba34abfbe3afaf874)) +- **oob:** support oob with connection and messages ([#1558](https://github.com/hyperledger/aries-framework-javascript/issues/1558)) ([9732ce4](https://github.com/hyperledger/aries-framework-javascript/commit/9732ce436a0ddee8760b02ac5182e216a75176c2)) +- service validation in OOB invitation objects ([#1575](https://github.com/hyperledger/aries-framework-javascript/issues/1575)) ([91a9434](https://github.com/hyperledger/aries-framework-javascript/commit/91a9434efd53ccbaf80f5613cd908913ad3b806b)) +- update tsyringe for ts 5 support ([#1588](https://github.com/hyperledger/aries-framework-javascript/issues/1588)) ([296955b](https://github.com/hyperledger/aries-framework-javascript/commit/296955b3a648416ac6b502da05a10001920af222)) + +### Features + +- allow connection invitation encoded in oob url param ([#1583](https://github.com/hyperledger/aries-framework-javascript/issues/1583)) ([9d789fa](https://github.com/hyperledger/aries-framework-javascript/commit/9d789fa4e9d159312872f45089d73609eb3d6835)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- create message subscription first ([#1549](https://github.com/hyperledger/aries-framework-javascript/issues/1549)) ([93276de](https://github.com/hyperledger/aries-framework-javascript/commit/93276debeff1e56c9803e7700875c4254a48236b)) +- force did:key resolver/registrar presence ([#1535](https://github.com/hyperledger/aries-framework-javascript/issues/1535)) ([aaa13dc](https://github.com/hyperledger/aries-framework-javascript/commit/aaa13dc77d6d5133cd02e768e4173462fa65064a)) +- listen to incoming messages on agent initialize not constructor ([#1542](https://github.com/hyperledger/aries-framework-javascript/issues/1542)) ([8f2d593](https://github.com/hyperledger/aries-framework-javascript/commit/8f2d593bcda0bb2d7bea25ad06b9e37784961997)) +- priority sorting for didcomm services ([#1555](https://github.com/hyperledger/aries-framework-javascript/issues/1555)) ([80c37b3](https://github.com/hyperledger/aries-framework-javascript/commit/80c37b30eb9ac3b438288e14c252f79f619dd12f)) +- race condition singleton records ([#1495](https://github.com/hyperledger/aries-framework-javascript/issues/1495)) ([6c2dda5](https://github.com/hyperledger/aries-framework-javascript/commit/6c2dda544bf5f5d3a972a778c389340da6df97c4)) +- **transport:** Use connection in WebSocket ID ([#1551](https://github.com/hyperledger/aries-framework-javascript/issues/1551)) ([8d2057f](https://github.com/hyperledger/aries-framework-javascript/commit/8d2057f3fe6f3ba236ba5a811b57a7256eae92bf)) + +### Features + +- **anoncreds:** auto create link secret ([#1521](https://github.com/hyperledger/aries-framework-javascript/issues/1521)) ([c6f03e4](https://github.com/hyperledger/aries-framework-javascript/commit/c6f03e49d79a33b1c4b459cef11add93dee051d0)) +- oob without handhsake improvements and routing ([#1511](https://github.com/hyperledger/aries-framework-javascript/issues/1511)) ([9e69cf4](https://github.com/hyperledger/aries-framework-javascript/commit/9e69cf441a75bf7a3c5556cf59e730ee3fce8c28)) +- support askar profiles for multi-tenancy ([#1538](https://github.com/hyperledger/aries-framework-javascript/issues/1538)) ([e448a2a](https://github.com/hyperledger/aries-framework-javascript/commit/e448a2a58dddff2cdf80c4549ea2d842a54b43d1)) +- **w3c:** add convenience methods to vc and vp ([#1477](https://github.com/hyperledger/aries-framework-javascript/issues/1477)) ([83cbfe3](https://github.com/hyperledger/aries-framework-javascript/commit/83cbfe38e788366b616dc244fe34cc49a5a4d331)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/core/package.json b/packages/core/package.json index 45d7569921..207913feeb 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/core", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -30,6 +30,7 @@ "@stablelib/ed25519": "^1.0.2", "@stablelib/random": "^1.0.1", "@stablelib/sha256": "^1.0.1", + "@types/node-fetch": "2.6.2", "@types/ws": "^8.5.4", "abort-controller": "^3.0.0", "big-integer": "^1.6.51", @@ -41,12 +42,11 @@ "lru_map": "^0.4.1", "luxon": "^3.3.0", "make-error": "^1.3.6", - "node-fetch": "^2.6.1", "object-inspect": "^1.10.3", "query-string": "^7.0.1", "reflect-metadata": "^0.1.13", "rxjs": "^7.2.0", - "tsyringe": "^4.7.0", + "tsyringe": "^4.8.0", "uuid": "^9.0.0", "varint": "^6.0.0", "web-did-resolver": "^2.0.21" @@ -54,7 +54,6 @@ "devDependencies": { "@types/events": "^3.0.0", "@types/luxon": "^3.2.0", - "@types/node-fetch": "2.6.2", "@types/object-inspect": "^1.8.0", "@types/uuid": "^9.0.1", "@types/varint": "^6.0.0", diff --git a/packages/core/src/agent/Agent.ts b/packages/core/src/agent/Agent.ts index bb124992cd..952e610c82 100644 --- a/packages/core/src/agent/Agent.ts +++ b/packages/core/src/agent/Agent.ts @@ -41,7 +41,7 @@ interface AgentOptions { // Any makes sure you can use Agent as a type without always needing to specify the exact generics for the agent // eslint-disable-next-line @typescript-eslint/no-explicit-any export class Agent extends BaseAgent { - public messageSubscription: Subscription + private messageSubscription?: Subscription public constructor(options: AgentOptions, dependencyManager = new DependencyManager()) { const agentConfig = new AgentConfig(options.config, options.dependencies) @@ -110,26 +110,6 @@ export class Agent extends BaseAge } super(agentConfig, dependencyManager) - - const stop$ = this.dependencyManager.resolve>(InjectionSymbols.Stop$) - - // Listen for new messages (either from transports or somewhere else in the framework / extensions) - this.messageSubscription = this.eventEmitter - .observable(AgentEventTypes.AgentMessageReceived) - .pipe( - takeUntil(stop$), - concatMap((e) => - this.messageReceiver - .receiveMessage(e.payload.message, { - connection: e.payload.connection, - contextCorrelationId: e.payload.contextCorrelationId, - }) - .catch((error) => { - this.logger.error('Failed to process message', { error }) - }) - ) - ) - .subscribe() } public registerInboundTransport(inboundTransport: InboundTransport) { @@ -168,6 +148,27 @@ export class Agent extends BaseAge } public async initialize() { + const stop$ = this.dependencyManager.resolve>(InjectionSymbols.Stop$) + + // Listen for new messages (either from transports or somewhere else in the framework / extensions) + // We create this before doing any other initialization, so the initialization could already receive messages + this.messageSubscription = this.eventEmitter + .observable(AgentEventTypes.AgentMessageReceived) + .pipe( + takeUntil(stop$), + concatMap((e) => + this.messageReceiver + .receiveMessage(e.payload.message, { + connection: e.payload.connection, + contextCorrelationId: e.payload.contextCorrelationId, + }) + .catch((error) => { + this.logger.error('Failed to process message', { error }) + }) + ) + ) + .subscribe() + await super.initialize() for (const [, module] of Object.entries(this.dependencyManager.registeredModules) as [string, Module][]) { diff --git a/packages/core/src/agent/MessageSender.ts b/packages/core/src/agent/MessageSender.ts index 5a1893f5ef..0faf514b83 100644 --- a/packages/core/src/agent/MessageSender.ts +++ b/packages/core/src/agent/MessageSender.ts @@ -99,11 +99,12 @@ export class MessageSender { } private async sendMessageToSession(agentContext: AgentContext, session: TransportSession, message: AgentMessage) { - this.logger.debug(`Existing ${session.type} transport session has been found.`) + this.logger.debug(`Packing message and sending it via existing session ${session.type}...`) if (!session.keys) { throw new AriesFrameworkError(`There are no keys for the given ${session.type} transport session.`) } const encryptedMessage = await this.envelopeService.packMessage(agentContext, message, session.keys) + this.logger.debug('Sending message') await session.send(agentContext, encryptedMessage) } diff --git a/packages/core/src/agent/TransportService.ts b/packages/core/src/agent/TransportService.ts index a8c61e2af1..4095cb7e9b 100644 --- a/packages/core/src/agent/TransportService.ts +++ b/packages/core/src/agent/TransportService.ts @@ -13,6 +13,14 @@ export class TransportService { public transportSessionTable: TransportSessionTable = {} public saveSession(session: TransportSession) { + if (session.connectionId) { + const oldSessions = this.getExistingSessionsForConnectionIdAndType(session.connectionId, session.type) + oldSessions.forEach((oldSession) => { + if (oldSession) { + this.removeSession(oldSession) + } + }) + } this.transportSessionTable[session.id] = session } @@ -40,6 +48,12 @@ export class TransportService { public removeSession(session: TransportSession) { delete this.transportSessionTable[session.id] } + + private getExistingSessionsForConnectionIdAndType(connectionId: string, type: string) { + return Object.values(this.transportSessionTable).filter( + (session) => session?.connectionId === connectionId && session.type === type + ) + } } interface TransportSessionTable { diff --git a/packages/core/src/agent/getOutboundMessageContext.ts b/packages/core/src/agent/getOutboundMessageContext.ts index 068ce8aafb..ee39cbf43c 100644 --- a/packages/core/src/agent/getOutboundMessageContext.ts +++ b/packages/core/src/agent/getOutboundMessageContext.ts @@ -5,12 +5,10 @@ import type { ResolvedDidCommService } from '../modules/didcomm' import type { OutOfBandRecord } from '../modules/oob' import type { BaseRecordAny } from '../storage/BaseRecord' -import { Agent } from 'http' - import { Key } from '../crypto' import { ServiceDecorator } from '../decorators/service/ServiceDecorator' import { AriesFrameworkError } from '../error' -import { OutOfBandService, OutOfBandRole, OutOfBandRepository } from '../modules/oob' +import { InvitationType, OutOfBandRepository, OutOfBandRole, OutOfBandService } from '../modules/oob' import { OutOfBandRecordMetadataKeys } from '../modules/oob/repository/outOfBandRecordMetadataTypes' import { RoutingService } from '../modules/routing' import { DidCommMessageRepository, DidCommMessageRole } from '../storage' @@ -297,8 +295,11 @@ async function addExchangeDataToMessage( associatedRecord: BaseRecordAny } ) { + const legacyInvitationMetadata = outOfBandRecord?.metadata.get(OutOfBandRecordMetadataKeys.LegacyInvitation) + // Set the parentThreadId on the message from the oob invitation - if (outOfBandRecord) { + // If connectionless is used, we should not add the parentThreadId + if (outOfBandRecord && legacyInvitationMetadata?.legacyInvitationType !== InvitationType.Connectionless) { if (!message.thread) { message.setThread({ parentThreadId: outOfBandRecord.outOfBandInvitation.id, diff --git a/packages/core/src/modules/connections/ConnectionsModuleConfig.ts b/packages/core/src/modules/connections/ConnectionsModuleConfig.ts index 59aaf8cb5b..e3bd0c0408 100644 --- a/packages/core/src/modules/connections/ConnectionsModuleConfig.ts +++ b/packages/core/src/modules/connections/ConnectionsModuleConfig.ts @@ -7,6 +7,9 @@ export interface ConnectionsModuleConfigOptions { * Whether to automatically accept connection messages. Applies to both the connection protocol (RFC 0160) * and the DID exchange protocol (RFC 0023). * + * Note: this setting does not apply to implicit invitation flows, which always need to be manually accepted + * using ConnectionStateChangedEvent + * * @default false */ autoAcceptConnections?: boolean diff --git a/packages/core/src/modules/connections/__tests__/ConnectionService.test.ts b/packages/core/src/modules/connections/__tests__/ConnectionService.test.ts index 00e46a001d..378596a888 100644 --- a/packages/core/src/modules/connections/__tests__/ConnectionService.test.ts +++ b/packages/core/src/modules/connections/__tests__/ConnectionService.test.ts @@ -155,7 +155,7 @@ describe('ConnectionService', () => { service: [ new IndyAgentService({ - id: `XpwgBjsC2wh3eHcMW6ZRJT#IndyAgentService`, + id: `XpwgBjsC2wh3eHcMW6ZRJT#IndyAgentService-1`, serviceEndpoint: agentConfig.endpoints[0], recipientKeys: ['HoVPnpfUjrDECoMZy8vu4U6dwEcLhbzjNwyS3gwLDCG8'], routingKeys: [], @@ -426,7 +426,7 @@ describe('ConnectionService', () => { authentication: [new ReferencedAuthentication(publicKey, authenticationTypes.Ed25519VerificationKey2018)], service: [ new IndyAgentService({ - id: `${did}#IndyAgentService`, + id: `${did}#IndyAgentService-1`, serviceEndpoint: 'http://example.com', recipientKeys: recipientKeys.map((did) => did.key.publicKeyBase58), routingKeys: [], diff --git a/packages/core/src/modules/connections/__tests__/helpers.test.ts b/packages/core/src/modules/connections/__tests__/helpers.test.ts index 5abf26eef9..ae144cc34d 100644 --- a/packages/core/src/modules/connections/__tests__/helpers.test.ts +++ b/packages/core/src/modules/connections/__tests__/helpers.test.ts @@ -140,7 +140,7 @@ describe('convertToNewDidDocument', () => { serviceEndpoint: 'did:sov:SKJVx2kn373FNgvff1SbJo', recipientKeys: ['EoGusetSxDJktp493VCyh981nUnzMamTRjvBaHZAy68d'], routingKeys: ['EoGusetSxDJktp493VCyh981nUnzMamTRjvBaHZAy68d'], - priority: 5, + priority: 6, }), new IndyAgentService({ id: 'did:sov:SKJVx2kn373FNgvff1SbJo#service-2#something-extra', @@ -159,7 +159,7 @@ describe('convertToNewDidDocument', () => { serviceEndpoint: 'did:sov:SKJVx2kn373FNgvff1SbJo', recipientKeys: ['EoGusetSxDJktp493VCyh981nUnzMamTRjvBaHZAy68d'], routingKeys: ['EoGusetSxDJktp493VCyh981nUnzMamTRjvBaHZAy68d'], - priority: 5, + priority: 6, }), new IndyAgentService({ id: '#service-2#something-extra', diff --git a/packages/core/src/modules/connections/models/did/DidDoc.ts b/packages/core/src/modules/connections/models/did/DidDoc.ts index 4d86fa7e19..d40a4aaeca 100644 --- a/packages/core/src/modules/connections/models/did/DidDoc.ts +++ b/packages/core/src/modules/connections/models/did/DidDoc.ts @@ -84,6 +84,6 @@ export class DidDoc { > // Sort services based on indicated priority - return services.sort((a, b) => b.priority - a.priority) + return services.sort((a, b) => a.priority - b.priority) } } diff --git a/packages/core/src/modules/connections/models/did/__tests__/DidDoc.test.ts b/packages/core/src/modules/connections/models/did/__tests__/DidDoc.test.ts index 17023d6060..59e301acaa 100644 --- a/packages/core/src/modules/connections/models/did/__tests__/DidDoc.test.ts +++ b/packages/core/src/modules/connections/models/did/__tests__/DidDoc.test.ts @@ -192,7 +192,7 @@ describe('Did | DidDoc', () => { }) it('returns all IndyAgentService and DidCommService instances sorted by priority', async () => { - expect(didDoc.didCommServices).toEqual([didDoc.service[2], didDoc.service[1]]) + expect(didDoc.didCommServices).toEqual([didDoc.service[1], didDoc.service[2]]) }) }) }) diff --git a/packages/core/src/modules/connections/services/ConnectionService.ts b/packages/core/src/modules/connections/services/ConnectionService.ts index 059c785452..05ec71bc77 100644 --- a/packages/core/src/modules/connections/services/ConnectionService.ts +++ b/packages/core/src/modules/connections/services/ConnectionService.ts @@ -32,7 +32,9 @@ import { DidRecordMetadataKeys } from '../../dids/repository/didRecordMetadataTy import { OutOfBandService } from '../../oob/OutOfBandService' import { OutOfBandRole } from '../../oob/domain/OutOfBandRole' import { OutOfBandState } from '../../oob/domain/OutOfBandState' +import { InvitationType } from '../../oob/messages' import { OutOfBandRepository } from '../../oob/repository' +import { OutOfBandRecordMetadataKeys } from '../../oob/repository/outOfBandRecordMetadataTypes' import { ConnectionEventTypes } from '../ConnectionEvents' import { ConnectionProblemReportError, ConnectionProblemReportReason } from '../errors' import { ConnectionRequestMessage, ConnectionResponseMessage, TrustPingMessage } from '../messages' @@ -538,6 +540,86 @@ export class ConnectionService { } } + /** + * If knownConnectionId is passed, it will compare the incoming connection id with the knownConnectionId, and skip the other validation. + * + * If no known connection id is passed, it asserts that the incoming message is in response to an attached request message to an out of band invitation. + * If is the case, and the state of the out of band record is still await response, the state will be updated to done + * + */ + public async matchIncomingMessageToRequestMessageInOutOfBandExchange( + messageContext: InboundMessageContext, + { expectedConnectionId }: { expectedConnectionId?: string } + ) { + if (expectedConnectionId && messageContext.connection?.id === expectedConnectionId) { + throw new AriesFrameworkError( + `Expecting incoming message to have connection ${expectedConnectionId}, but incoming connection is ${ + messageContext.connection?.id ?? 'undefined' + }` + ) + } + + const outOfBandRepository = messageContext.agentContext.dependencyManager.resolve(OutOfBandRepository) + const outOfBandInvitationId = messageContext.message.thread?.parentThreadId + + // Find the out of band record that is associated with this request + const outOfBandRecord = await outOfBandRepository.findSingleByQuery(messageContext.agentContext, { + invitationId: outOfBandInvitationId, + role: OutOfBandRole.Sender, + invitationRequestsThreadIds: [messageContext.message.threadId], + }) + + // There is no out of band record + if (!outOfBandRecord) { + throw new AriesFrameworkError( + `No out of band record found for credential request message with thread ${messageContext.message.threadId}, out of band invitation id ${outOfBandInvitationId} and role ${OutOfBandRole.Sender}` + ) + } + + const legacyInvitationMetadata = outOfBandRecord.metadata.get(OutOfBandRecordMetadataKeys.LegacyInvitation) + + // If the original invitation was a legacy connectionless invitation, it's okay if the message does not have a pthid. + if ( + legacyInvitationMetadata?.legacyInvitationType !== InvitationType.Connectionless && + outOfBandRecord.outOfBandInvitation.id !== outOfBandInvitationId + ) { + throw new AriesFrameworkError( + 'Response messages to out of band invitation requests MUST have a parent thread id that matches the out of band invitation id.' + ) + } + + // This should not happen, as it is not allowed to create reusable out of band invitations with attached messages + // But should that implementation change, we at least cover it here. + if (outOfBandRecord.reusable) { + throw new AriesFrameworkError( + 'Receiving messages in response to reusable out of band invitations is not supported.' + ) + } + + if (outOfBandRecord.state === OutOfBandState.Done) { + if (!messageContext.connection) { + throw new AriesFrameworkError( + "Can't find connection associated with incoming message, while out of band state is done. State must be await response if no connection has been created" + ) + } + if (messageContext.connection.outOfBandId !== outOfBandRecord.id) { + throw new AriesFrameworkError( + 'Connection associated with incoming message is not associated with the out of band invitation containing the attached message.' + ) + } + + // We're good to go. Connection was created and points to the correct out of band record. And the message is in response to an attached request message from the oob invitation. + } else if (outOfBandRecord.state === OutOfBandState.AwaitResponse) { + // We're good to go. Waiting for a response. And the message is in response to an attached request message from the oob invitation. + + // Now that we have received the first response message to our out of band invitation, we mark the out of band record as done + outOfBandRecord.state = OutOfBandState.Done + await outOfBandRepository.update(messageContext.agentContext, outOfBandRecord) + } else { + throw new AriesFrameworkError(`Out of band record is in incorrect state ${outOfBandRecord.state}`) + } + } + public async updateState(agentContext: AgentContext, connectionRecord: ConnectionRecord, newState: DidExchangeState) { const previousState = connectionRecord.state connectionRecord.state = newState @@ -746,7 +828,7 @@ export class ConnectionService { const services = routing.endpoints.map( (endpoint, index) => new IndyAgentService({ - id: `${indyDid}#IndyAgentService`, + id: `${indyDid}#IndyAgentService-${index + 1}`, serviceEndpoint: endpoint, recipientKeys: [routing.recipientKey.publicKeyBase58], routingKeys: routing.routingKeys.map((key) => key.publicKeyBase58), @@ -781,7 +863,7 @@ export class ConnectionService { const service = services.map( (service, index) => new IndyAgentService({ - id: `${did}#IndyAgentService`, + id: `${did}#IndyAgentService-${index + 1}`, serviceEndpoint: service.serviceEndpoint, recipientKeys: [recipientKey.publicKeyBase58], routingKeys: service.routingKeys?.map(didKeyToVerkey), diff --git a/packages/core/src/modules/connections/services/helpers.ts b/packages/core/src/modules/connections/services/helpers.ts index 3864bbde34..3dbcc9c837 100644 --- a/packages/core/src/modules/connections/services/helpers.ts +++ b/packages/core/src/modules/connections/services/helpers.ts @@ -41,7 +41,11 @@ export function convertToNewDidDocument(didDoc: DidDoc): DidDocument { } }) - didDoc.didCommServices.forEach((service) => { + // FIXME: we reverse the didCommServices here, as the previous implementation was wrong + // and we need to keep the same order to not break the did creation process. + // When we implement the migration to did:peer:2 and did:peer:3 according to the + // RFCs we can change it. + didDoc.didCommServices.reverse().forEach((service) => { const serviceId = normalizeId(service.id) // For didcommv1, we need to replace the old id with the new ones diff --git a/packages/core/src/modules/credentials/CredentialsApi.ts b/packages/core/src/modules/credentials/CredentialsApi.ts index c8eba61ae9..4a0a6ac349 100644 --- a/packages/core/src/modules/credentials/CredentialsApi.ts +++ b/packages/core/src/modules/credentials/CredentialsApi.ts @@ -505,6 +505,7 @@ export class CredentialsApi implements Credent }) message.setThread({ threadId: credentialRecord.threadId, + parentThreadId: credentialRecord.parentThreadId, }) const outboundMessageContext = await getOutboundMessageContext(this.agentContext, { message, diff --git a/packages/core/src/modules/credentials/protocol/v2/CredentialFormatCoordinator.ts b/packages/core/src/modules/credentials/protocol/v2/CredentialFormatCoordinator.ts index 1def0ac9f4..c8fe64e86d 100644 --- a/packages/core/src/modules/credentials/protocol/v2/CredentialFormatCoordinator.ts +++ b/packages/core/src/modules/credentials/protocol/v2/CredentialFormatCoordinator.ts @@ -70,7 +70,7 @@ export class CredentialFormatCoordinator credentialPreview, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -182,7 +182,7 @@ export class CredentialFormatCoordinator comment, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -254,7 +254,7 @@ export class CredentialFormatCoordinator credentialPreview, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -345,7 +345,7 @@ export class CredentialFormatCoordinator comment, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -399,7 +399,7 @@ export class CredentialFormatCoordinator requestAttachments: requestAttachments, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { agentMessage: message, @@ -498,7 +498,7 @@ export class CredentialFormatCoordinator comment, }) - message.setThread({ threadId: credentialRecord.threadId }) + message.setThread({ threadId: credentialRecord.threadId, parentThreadId: credentialRecord.parentThreadId }) message.setPleaseAck() await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { diff --git a/packages/core/src/modules/credentials/protocol/v2/V2CredentialProtocol.ts b/packages/core/src/modules/credentials/protocol/v2/V2CredentialProtocol.ts index 2ab8eddc4a..5d764fb5aa 100644 --- a/packages/core/src/modules/credentials/protocol/v2/V2CredentialProtocol.ts +++ b/packages/core/src/modules/credentials/protocol/v2/V2CredentialProtocol.ts @@ -211,6 +211,7 @@ export class V2CredentialProtocol { // then expect(credentialRepository.findSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, { threadId: 'somethreadid', - connectionId: connection.id, }) expect(credentialRepository.update).toHaveBeenCalledTimes(1) expect(returnedCredentialRecord.state).toEqual(CredentialState.RequestReceived) @@ -368,15 +367,9 @@ describe('credentialProtocol', () => { const returnedCredentialRecord = await credentialProtocol.processRequest(messageContext) // then - expect(credentialRepository.findSingleByQuery).toHaveBeenNthCalledWith( - 1, - agentContext, - - { - threadId: 'somethreadid', - connectionId: connection.id, - } - ) + expect(credentialRepository.findSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, { + threadId: 'somethreadid', + }) expect(eventListenerMock).toHaveBeenCalled() expect(returnedCredentialRecord.state).toEqual(CredentialState.RequestReceived) }) @@ -617,7 +610,7 @@ describe('credentialProtocol', () => { expect(credentialRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, { threadId: 'somethreadid', - connectionId: connection.id, + connectionId: '123', }) expect(returnedCredentialRecord.state).toBe(CredentialState.Done) @@ -685,7 +678,7 @@ describe('credentialProtocol', () => { expect(credentialRepository.getSingleByQuery).toHaveBeenNthCalledWith(1, agentContext, { threadId: 'somethreadid', - connectionId: connection.id, + connectionId: '123', }) expect(credentialRepository.update).toHaveBeenCalled() expect(returnedCredentialRecord.errorMessage).toBe('issuance-abandoned: Indy error') diff --git a/packages/core/src/modules/credentials/repository/CredentialExchangeRecord.ts b/packages/core/src/modules/credentials/repository/CredentialExchangeRecord.ts index c9af8da909..bb1a41c079 100644 --- a/packages/core/src/modules/credentials/repository/CredentialExchangeRecord.ts +++ b/packages/core/src/modules/credentials/repository/CredentialExchangeRecord.ts @@ -17,6 +17,7 @@ export interface CredentialExchangeRecordProps { state: CredentialState connectionId?: string threadId: string + parentThreadId?: string protocolVersion: string tags?: CustomCredentialTags @@ -31,6 +32,7 @@ export interface CredentialExchangeRecordProps { export type CustomCredentialTags = TagsBase export type DefaultCredentialTags = { threadId: string + parentThreadId?: string connectionId?: string state: CredentialState credentialIds: string[] @@ -44,6 +46,7 @@ export interface CredentialRecordBinding { export class CredentialExchangeRecord extends BaseRecord { public connectionId?: string public threadId!: string + public parentThreadId?: string public state!: CredentialState public autoAcceptCredential?: AutoAcceptCredential public revocationNotification?: RevocationNotification @@ -69,6 +72,7 @@ export class CredentialExchangeRecord extends BaseRecord { const didDocument = await this.didResolverService.resolveDidDocument(agentContext, did) - const didCommServices: ResolvedDidCommService[] = [] + const resolvedServices: ResolvedDidCommService[] = [] + + // If did specifies a particular service, filter by its id + const didCommServices = parseDid(did).fragment + ? didDocument.didCommServices.filter((service) => service.id === did) + : didDocument.didCommServices // FIXME: we currently retrieve did documents for all didcomm services in the did document, and we don't have caching // yet so this will re-trigger ledger resolves for each one. Should we only resolve the first service, then the second service, etc...? - for (const didCommService of didDocument.didCommServices) { + for (const didCommService of didCommServices) { if (didCommService instanceof IndyAgentService) { // IndyAgentService (DidComm v0) has keys encoded as raw publicKeyBase58 (verkeys) - didCommServices.push({ + resolvedServices.push({ id: didCommService.id, recipientKeys: didCommService.recipientKeys.map(verkeyToInstanceOfKey), routingKeys: didCommService.routingKeys?.map(verkeyToInstanceOfKey) || [], @@ -54,7 +59,7 @@ export class DidCommDocumentService { return key }) - didCommServices.push({ + resolvedServices.push({ id: didCommService.id, recipientKeys, routingKeys, @@ -63,6 +68,6 @@ export class DidCommDocumentService { } } - return didCommServices + return resolvedServices } } diff --git a/packages/core/src/modules/didcomm/services/__tests__/DidCommDocumentService.test.ts b/packages/core/src/modules/didcomm/services/__tests__/DidCommDocumentService.test.ts index 8019274c46..422db7f2a5 100644 --- a/packages/core/src/modules/didcomm/services/__tests__/DidCommDocumentService.test.ts +++ b/packages/core/src/modules/didcomm/services/__tests__/DidCommDocumentService.test.ts @@ -117,5 +117,89 @@ describe('DidCommDocumentService', () => { routingKeys: [ed25519Key], }) }) + + test('resolves specific DidCommV1Service', async () => { + const publicKeyBase58Ed25519 = 'GyYtYWU1vjwd5PFJM4VSX5aUiSV3TyZMuLBJBTQvfdF8' + const publicKeyBase58X25519 = 'S3AQEEKkGYrrszT9D55ozVVX2XixYp8uynqVm4okbud' + + const Ed25519VerificationMethod: VerificationMethod = { + type: 'Ed25519VerificationKey2018', + controller: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h', + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#key-1', + publicKeyBase58: publicKeyBase58Ed25519, + } + const X25519VerificationMethod: VerificationMethod = { + type: 'X25519KeyAgreementKey2019', + controller: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h', + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#key-agreement-1', + publicKeyBase58: publicKeyBase58X25519, + } + + mockFunction(didResolverService.resolveDidDocument).mockResolvedValue( + new DidDocument({ + context: [ + 'https://w3id.org/did/v1', + 'https://w3id.org/security/suites/ed25519-2018/v1', + 'https://w3id.org/security/suites/x25519-2019/v1', + ], + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h', + verificationMethod: [Ed25519VerificationMethod, X25519VerificationMethod], + authentication: [Ed25519VerificationMethod.id], + keyAgreement: [X25519VerificationMethod.id], + service: [ + new DidCommV1Service({ + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id', + serviceEndpoint: 'https://test.com', + recipientKeys: [X25519VerificationMethod.id], + routingKeys: [Ed25519VerificationMethod.id], + priority: 5, + }), + new DidCommV1Service({ + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id-2', + serviceEndpoint: 'wss://test.com', + recipientKeys: [X25519VerificationMethod.id], + routingKeys: [Ed25519VerificationMethod.id], + priority: 6, + }), + ], + }) + ) + + let resolved = await didCommDocumentService.resolveServicesFromDid( + agentContext, + 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id' + ) + expect(didResolverService.resolveDidDocument).toHaveBeenCalledWith( + agentContext, + 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id' + ) + + let ed25519Key = Key.fromPublicKeyBase58(publicKeyBase58Ed25519, KeyType.Ed25519) + expect(resolved).toHaveLength(1) + expect(resolved[0]).toMatchObject({ + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id', + serviceEndpoint: 'https://test.com', + recipientKeys: [ed25519Key], + routingKeys: [ed25519Key], + }) + + resolved = await didCommDocumentService.resolveServicesFromDid( + agentContext, + 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id-2' + ) + expect(didResolverService.resolveDidDocument).toHaveBeenCalledWith( + agentContext, + 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id-2' + ) + + ed25519Key = Key.fromPublicKeyBase58(publicKeyBase58Ed25519, KeyType.Ed25519) + expect(resolved).toHaveLength(1) + expect(resolved[0]).toMatchObject({ + id: 'did:sov:Q4zqM7aXqm7gDQkUVLng9h#test-id-2', + serviceEndpoint: 'wss://test.com', + recipientKeys: [ed25519Key], + routingKeys: [ed25519Key], + }) + }) }) }) diff --git a/packages/core/src/modules/dids/domain/DidDocument.ts b/packages/core/src/modules/dids/domain/DidDocument.ts index 5b8e32da82..2080d7dfb4 100644 --- a/packages/core/src/modules/dids/domain/DidDocument.ts +++ b/packages/core/src/modules/dids/domain/DidDocument.ts @@ -178,7 +178,7 @@ export class DidDocument { > // Sort services based on indicated priority - return services.sort((a, b) => b.priority - a.priority) + return services.sort((a, b) => a.priority - b.priority) } // TODO: it would probably be easier if we add a utility to each service so we don't have to handle logic for all service types here diff --git a/packages/core/src/modules/dids/domain/__tests__/DidDocument.test.ts b/packages/core/src/modules/dids/domain/__tests__/DidDocument.test.ts index a99b012082..f8b607a619 100644 --- a/packages/core/src/modules/dids/domain/__tests__/DidDocument.test.ts +++ b/packages/core/src/modules/dids/domain/__tests__/DidDocument.test.ts @@ -208,7 +208,7 @@ describe('Did | DidDocument', () => { it('returns all IndyAgentService and DidCommService instances sorted by priority', async () => { const services = didDocumentInstance.service ?? [] - expect(didDocumentInstance.didCommServices).toEqual([services[2], services[1]]) + expect(didDocumentInstance.didCommServices).toEqual([services[1], services[2]]) }) }) diff --git "a/packages/core/src/modules/message-p\303\254ckup/MessagePickupApi.ts" "b/packages/core/src/modules/message-p\303\254ckup/MessagePickupApi.ts" index 653fafd7d7..d47521dc44 100644 --- "a/packages/core/src/modules/message-p\303\254ckup/MessagePickupApi.ts" +++ "b/packages/core/src/modules/message-p\303\254ckup/MessagePickupApi.ts" @@ -13,7 +13,8 @@ import { MessageSender } from '../../agent/MessageSender' import { OutboundMessageContext } from '../../agent/models' import { InjectionSymbols } from '../../constants' import { AriesFrameworkError } from '../../error' -import { injectable } from '../../plugins' +import { Logger } from '../../logger/Logger' +import { inject, injectable } from '../../plugins' import { ConnectionService } from '../connections/services' import { MessagePickupModuleConfig } from './MessagePickupModuleConfig' @@ -32,17 +33,20 @@ export class MessagePickupApi + config: MessagePickupModuleConfig, + @inject(InjectionSymbols.Logger) logger: Logger ) { this.messageSender = messageSender this.connectionService = connectionService this.agentContext = agentContext this.config = config + this.logger = logger } private getProtocol(protocolVersion: MPP): MessagePickupProtocol { @@ -61,6 +65,7 @@ export class MessagePickupApi { + this.logger.debug('Queuing message...') const connectionRecord = await this.connectionService.getById(this.agentContext, options.connectionId) const messageRepository = this.agentContext.dependencyManager.resolve( diff --git a/packages/core/src/modules/oob/OutOfBandApi.ts b/packages/core/src/modules/oob/OutOfBandApi.ts index 0d6449d97c..b6f48b97e2 100644 --- a/packages/core/src/modules/oob/OutOfBandApi.ts +++ b/packages/core/src/modules/oob/OutOfBandApi.ts @@ -20,7 +20,6 @@ import { ServiceDecorator } from '../../decorators/service/ServiceDecorator' import { AriesFrameworkError } from '../../error' import { Logger } from '../../logger' import { inject, injectable } from '../../plugins' -import { DidCommMessageRepository } from '../../storage' import { JsonEncoder, JsonTransformer } from '../../utils' import { parseMessageType, supportsIncomingMessageType } from '../../utils/messageType' import { parseInvitationShortUrl } from '../../utils/parseInvitation' @@ -37,7 +36,8 @@ import { OutOfBandState } from './domain/OutOfBandState' import { HandshakeReuseHandler } from './handlers' import { HandshakeReuseAcceptedHandler } from './handlers/HandshakeReuseAcceptedHandler' import { convertToNewInvitation, convertToOldInvitation } from './helpers' -import { OutOfBandInvitation } from './messages' +import { InvitationType, OutOfBandInvitation } from './messages' +import { OutOfBandRepository } from './repository' import { OutOfBandRecord } from './repository/OutOfBandRecord' import { OutOfBandRecordMetadataKeys } from './repository/outOfBandRecordMetadataTypes' @@ -92,7 +92,6 @@ export class OutOfBandApi { private outOfBandService: OutOfBandService private routingService: RoutingService private connectionsApi: ConnectionsApi - private didCommMessageRepository: DidCommMessageRepository private messageHandlerRegistry: MessageHandlerRegistry private didCommDocumentService: DidCommDocumentService private messageSender: MessageSender @@ -106,7 +105,6 @@ export class OutOfBandApi { outOfBandService: OutOfBandService, routingService: RoutingService, connectionsApi: ConnectionsApi, - didCommMessageRepository: DidCommMessageRepository, messageSender: MessageSender, eventEmitter: EventEmitter, @inject(InjectionSymbols.Logger) logger: Logger, @@ -119,7 +117,6 @@ export class OutOfBandApi { this.outOfBandService = outOfBandService this.routingService = routingService this.connectionsApi = connectionsApi - this.didCommMessageRepository = didCommMessageRepository this.messageSender = messageSender this.eventEmitter = eventEmitter this.registerMessageHandlers(messageHandlerRegistry) @@ -249,6 +246,14 @@ export class OutOfBandApi { ...config, handshakeProtocols: [HandshakeProtocol.Connections], }) + + // Set legacy invitation type + outOfBandRecord.metadata.set(OutOfBandRecordMetadataKeys.LegacyInvitation, { + legacyInvitationType: InvitationType.Connection, + }) + const outOfBandRepository = this.agentContext.dependencyManager.resolve(OutOfBandRepository) + await outOfBandRepository.update(this.agentContext, outOfBandRecord) + return { outOfBandRecord, invitation: convertToOldInvitation(outOfBandRecord.outOfBandInvitation) } } @@ -268,6 +273,13 @@ export class OutOfBandApi { routing: config.routing, }) + // Set legacy invitation type + outOfBandRecord.metadata.set(OutOfBandRecordMetadataKeys.LegacyInvitation, { + legacyInvitationType: InvitationType.Connectionless, + }) + const outOfBandRepository = this.agentContext.dependencyManager.resolve(OutOfBandRepository) + await outOfBandRepository.update(this.agentContext, outOfBandRecord) + // Resolve the service and set it on the message const resolvedService = await this.outOfBandService.getResolvedServiceForOutOfBandServices( this.agentContext, @@ -448,6 +460,13 @@ export class OutOfBandApi { }) } + // If the invitation was converted from another legacy format, we store this, as its needed for some flows + if (outOfBandInvitation.invitationType && outOfBandInvitation.invitationType !== InvitationType.OutOfBand) { + outOfBandRecord.metadata.set(OutOfBandRecordMetadataKeys.LegacyInvitation, { + legacyInvitationType: outOfBandInvitation.invitationType, + }) + } + await this.outOfBandService.save(this.agentContext, outOfBandRecord) this.outOfBandService.emitStateChangedEvent(this.agentContext, outOfBandRecord, null) @@ -572,12 +591,12 @@ export class OutOfBandApi { if (messages) { this.logger.debug('Out of band message contains request messages.') if (connectionRecord.isReady) { - await this.emitWithConnection(connectionRecord, messages) + await this.emitWithConnection(outOfBandRecord, connectionRecord, messages) } else { // Wait until the connection is ready and then pass the messages to the agent for further processing this.connectionsApi .returnWhenIsConnected(connectionRecord.id, { timeoutMs }) - .then((connectionRecord) => this.emitWithConnection(connectionRecord, messages)) + .then((connectionRecord) => this.emitWithConnection(outOfBandRecord, connectionRecord, messages)) .catch((error) => { if (error instanceof EmptyError) { this.logger.warn( @@ -595,9 +614,9 @@ export class OutOfBandApi { this.logger.debug('Out of band message contains only request messages.') if (existingConnection) { this.logger.debug('Connection already exists.', { connectionId: existingConnection.id }) - await this.emitWithConnection(existingConnection, messages) + await this.emitWithConnection(outOfBandRecord, existingConnection, messages) } else { - await this.emitWithServices(services, messages) + await this.emitWithServices(outOfBandRecord, services, messages) } } return { outOfBandRecord } @@ -740,7 +759,11 @@ export class OutOfBandApi { } } - private async emitWithConnection(connectionRecord: ConnectionRecord, messages: PlaintextMessage[]) { + private async emitWithConnection( + outOfBandRecord: OutOfBandRecord, + connectionRecord: ConnectionRecord, + messages: PlaintextMessage[] + ) { const supportedMessageTypes = this.messageHandlerRegistry.supportedMessageTypes const plaintextMessage = messages.find((message) => { const parsedMessageType = parseMessageType(message['@type']) @@ -751,6 +774,9 @@ export class OutOfBandApi { throw new AriesFrameworkError('There is no message in requests~attach supported by agent.') } + // Make sure message has correct parent thread id + this.ensureParentThreadId(outOfBandRecord, plaintextMessage) + this.logger.debug(`Message with type ${plaintextMessage['@type']} can be processed.`) this.eventEmitter.emit(this.agentContext, { @@ -763,7 +789,11 @@ export class OutOfBandApi { }) } - private async emitWithServices(services: Array, messages: PlaintextMessage[]) { + private async emitWithServices( + outOfBandRecord: OutOfBandRecord, + services: Array, + messages: PlaintextMessage[] + ) { if (!services || services.length === 0) { throw new AriesFrameworkError(`There are no services. We can not emit messages`) } @@ -778,6 +808,9 @@ export class OutOfBandApi { throw new AriesFrameworkError('There is no message in requests~attach supported by agent.') } + // Make sure message has correct parent thread id + this.ensureParentThreadId(outOfBandRecord, plaintextMessage) + this.logger.debug(`Message with type ${plaintextMessage['@type']} can be processed.`) this.eventEmitter.emit(this.agentContext, { @@ -789,6 +822,35 @@ export class OutOfBandApi { }) } + private ensureParentThreadId(outOfBandRecord: OutOfBandRecord, plaintextMessage: PlaintextMessage) { + const legacyInvitationMetadata = outOfBandRecord.metadata.get(OutOfBandRecordMetadataKeys.LegacyInvitation) + + // We need to set the parent thread id to the invitation id, according to RFC 0434. + // So if it already has a pthid and it is not the same as the invitation id, we throw an error + if ( + plaintextMessage['~thread']?.pthid && + plaintextMessage['~thread'].pthid !== outOfBandRecord.outOfBandInvitation.id + ) { + throw new AriesFrameworkError( + `Out of band invitation requests~attach message contains parent thread id ${plaintextMessage['~thread'].pthid} that does not match the invitation id ${outOfBandRecord.outOfBandInvitation.id}` + ) + } + + // If the invitation is created from a legacy connectionless invitation, we don't need to set the pthid + // as that's not expected, and it's generated on our side only + if (legacyInvitationMetadata?.legacyInvitationType === InvitationType.Connectionless) { + return + } + + if (!plaintextMessage['~thread']) { + plaintextMessage['~thread'] = {} + } + + // The response to an out-of-band message MUST set its ~thread.pthid equal to the @id property of the out-of-band message. + // By adding the pthid to the message, we ensure that the response will take over this pthid + plaintextMessage['~thread'].pthid = outOfBandRecord.outOfBandInvitation.id + } + private async handleHandshakeReuse(outOfBandRecord: OutOfBandRecord, connectionRecord: ConnectionRecord) { const reuseMessage = await this.outOfBandService.createHandShakeReuse( this.agentContext, diff --git a/packages/core/src/modules/oob/__tests__/OutOfBandInvitation.test.ts b/packages/core/src/modules/oob/__tests__/OutOfBandInvitation.test.ts index c663265a9a..a30fe2331e 100644 --- a/packages/core/src/modules/oob/__tests__/OutOfBandInvitation.test.ts +++ b/packages/core/src/modules/oob/__tests__/OutOfBandInvitation.test.ts @@ -1,8 +1,11 @@ import type { ClassValidationError } from '../../../error/ClassValidationError' import { Attachment } from '../../../decorators/attachment/Attachment' +import { MessageValidator } from '../../../utils' import { JsonEncoder } from '../../../utils/JsonEncoder' import { JsonTransformer } from '../../../utils/JsonTransformer' +import { HandshakeProtocol } from '../../connections' +import { OutOfBandDidCommService } from '../domain' import { OutOfBandInvitation } from '../messages/OutOfBandInvitation' describe('toUrl', () => { @@ -26,6 +29,54 @@ describe('toUrl', () => { }) }) +describe('validation', () => { + test('Out-of-Band Invitation instance with did as service', async () => { + const invitation = new OutOfBandInvitation({ + id: '69212a3a-d068-4f9d-a2dd-4741bca89af3', + label: 'Faber College', + services: ['did:sov:LjgpST2rjsoxYegQDRm7EL'], + handshakeProtocols: [HandshakeProtocol.DidExchange], + }) + + expect(() => MessageValidator.validateSync(invitation)).not.toThrow() + }) + + test('Out-of-Band Invitation instance with object as service', async () => { + const invitation = new OutOfBandInvitation({ + id: '69212a3a-d068-4f9d-a2dd-4741bca89af3', + label: 'Faber College', + services: [ + new OutOfBandDidCommService({ + id: 'didcomm', + serviceEndpoint: 'http://endpoint', + recipientKeys: ['did:key:z6MkqgkLrRyLg6bqk27djwbbaQWgaSYgFVCKq9YKxZbNkpVv'], + }), + ], + handshakeProtocols: [HandshakeProtocol.DidExchange], + }) + + expect(() => MessageValidator.validateSync(invitation)).not.toThrow() + }) + + test('Out-of-Band Invitation instance with string and object as services', async () => { + const invitation = new OutOfBandInvitation({ + id: '69212a3a-d068-4f9d-a2dd-4741bca89af3', + label: 'Faber College', + services: [ + 'did:sov:LjgpST2rjsoxYegQDRm7EL', + new OutOfBandDidCommService({ + id: 'didcomm', + serviceEndpoint: 'http://endpoint', + recipientKeys: ['did:key:z6MkqgkLrRyLg6bqk27djwbbaQWgaSYgFVCKq9YKxZbNkpVv'], + }), + ], + handshakeProtocols: [HandshakeProtocol.DidExchange], + }) + + expect(() => MessageValidator.validateSync(invitation)).not.toThrow() + }) +}) + describe('fromUrl', () => { test('decode the URL containing the base64 encoded invitation as the oob parameter into an `OutOfBandInvitation`', () => { const invitationUrl = diff --git a/packages/core/src/modules/oob/__tests__/implicit.e2e.test.ts b/packages/core/src/modules/oob/__tests__/implicit.e2e.test.ts index 846a139a87..2453b55e6c 100644 --- a/packages/core/src/modules/oob/__tests__/implicit.e2e.test.ts +++ b/packages/core/src/modules/oob/__tests__/implicit.e2e.test.ts @@ -66,10 +66,42 @@ describe('out of band implicit', () => { test(`make a connection with ${HandshakeProtocol.DidExchange} based on implicit OOB invitation`, async () => { const publicDid = await createPublicDid(faberAgent, unqualifiedSubmitterDid, 'rxjs:faber') - expect(publicDid).toBeDefined() + expect(publicDid.did).toBeDefined() + + let { connectionRecord: aliceFaberConnection } = await aliceAgent.oob.receiveImplicitInvitation({ + did: publicDid.did!, + alias: 'Faber public', + label: 'Alice', + handshakeProtocols: [HandshakeProtocol.DidExchange], + }) + + // Wait for a connection event in faber agent and accept the request + let faberAliceConnection = await waitForConnectionRecord(faberAgent, { state: DidExchangeState.RequestReceived }) + await faberAgent.connections.acceptRequest(faberAliceConnection.id) + faberAliceConnection = await faberAgent.connections.returnWhenIsConnected(faberAliceConnection!.id) + expect(faberAliceConnection.state).toBe(DidExchangeState.Completed) + + // Alice should now be connected + aliceFaberConnection = await aliceAgent.connections.returnWhenIsConnected(aliceFaberConnection!.id) + expect(aliceFaberConnection.state).toBe(DidExchangeState.Completed) + + expect(aliceFaberConnection).toBeConnectedWith(faberAliceConnection) + expect(faberAliceConnection).toBeConnectedWith(aliceFaberConnection) + expect(faberAliceConnection.theirLabel).toBe('Alice') + expect(aliceFaberConnection.alias).toBe('Faber public') + expect(aliceFaberConnection.invitationDid).toBe(publicDid.did!) + + // It is possible for an agent to check if it has already a connection to a certain public entity + expect(await aliceAgent.connections.findByInvitationDid(publicDid.did!)).toEqual([aliceFaberConnection]) + }) + test(`make a connection with ${HandshakeProtocol.DidExchange} based on implicit OOB invitation pointing to specific service`, async () => { + const publicDid = await createPublicDid(faberAgent, unqualifiedSubmitterDid, 'rxjs:faber') + expect(publicDid.did).toBeDefined() + + const serviceDidUrl = publicDid.didDocument?.didCommServices[0].id let { connectionRecord: aliceFaberConnection } = await aliceAgent.oob.receiveImplicitInvitation({ - did: publicDid!, + did: serviceDidUrl!, alias: 'Faber public', label: 'Alice', handshakeProtocols: [HandshakeProtocol.DidExchange], @@ -89,18 +121,18 @@ describe('out of band implicit', () => { expect(faberAliceConnection).toBeConnectedWith(aliceFaberConnection) expect(faberAliceConnection.theirLabel).toBe('Alice') expect(aliceFaberConnection.alias).toBe('Faber public') - expect(aliceFaberConnection.invitationDid).toBe(publicDid) + expect(aliceFaberConnection.invitationDid).toBe(serviceDidUrl) // It is possible for an agent to check if it has already a connection to a certain public entity - expect(await aliceAgent.connections.findByInvitationDid(publicDid!)).toEqual([aliceFaberConnection]) + expect(await aliceAgent.connections.findByInvitationDid(serviceDidUrl!)).toEqual([aliceFaberConnection]) }) test(`make a connection with ${HandshakeProtocol.Connections} based on implicit OOB invitation`, async () => { const publicDid = await createPublicDid(faberAgent, unqualifiedSubmitterDid, 'rxjs:faber') - expect(publicDid).toBeDefined() + expect(publicDid.did).toBeDefined() let { connectionRecord: aliceFaberConnection } = await aliceAgent.oob.receiveImplicitInvitation({ - did: publicDid!, + did: publicDid.did!, alias: 'Faber public', label: 'Alice', handshakeProtocols: [HandshakeProtocol.Connections], @@ -120,10 +152,10 @@ describe('out of band implicit', () => { expect(faberAliceConnection).toBeConnectedWith(aliceFaberConnection) expect(faberAliceConnection.theirLabel).toBe('Alice') expect(aliceFaberConnection.alias).toBe('Faber public') - expect(aliceFaberConnection.invitationDid).toBe(publicDid) + expect(aliceFaberConnection.invitationDid).toBe(publicDid.did!) // It is possible for an agent to check if it has already a connection to a certain public entity - expect(await aliceAgent.connections.findByInvitationDid(publicDid!)).toEqual([aliceFaberConnection]) + expect(await aliceAgent.connections.findByInvitationDid(publicDid.did!)).toEqual([aliceFaberConnection]) }) test(`receive an implicit invitation using an unresolvable did`, async () => { @@ -142,7 +174,7 @@ describe('out of band implicit', () => { expect(publicDid).toBeDefined() let { connectionRecord: aliceFaberConnection } = await aliceAgent.oob.receiveImplicitInvitation({ - did: publicDid!, + did: publicDid.did!, alias: 'Faber public', label: 'Alice', handshakeProtocols: [HandshakeProtocol.Connections], @@ -162,11 +194,11 @@ describe('out of band implicit', () => { expect(faberAliceConnection).toBeConnectedWith(aliceFaberConnection) expect(faberAliceConnection.theirLabel).toBe('Alice') expect(aliceFaberConnection.alias).toBe('Faber public') - expect(aliceFaberConnection.invitationDid).toBe(publicDid) + expect(aliceFaberConnection.invitationDid).toBe(publicDid.did) // Repeat implicit invitation procedure let { connectionRecord: aliceFaberNewConnection } = await aliceAgent.oob.receiveImplicitInvitation({ - did: publicDid!, + did: publicDid.did!, alias: 'Faber public New', label: 'Alice New', handshakeProtocols: [HandshakeProtocol.Connections], @@ -186,10 +218,10 @@ describe('out of band implicit', () => { expect(faberAliceNewConnection).toBeConnectedWith(aliceFaberNewConnection) expect(faberAliceNewConnection.theirLabel).toBe('Alice New') expect(aliceFaberNewConnection.alias).toBe('Faber public New') - expect(aliceFaberNewConnection.invitationDid).toBe(publicDid) + expect(aliceFaberNewConnection.invitationDid).toBe(publicDid.did) // Both connections will be associated to the same invitation did - const connectionsFromFaberPublicDid = await aliceAgent.connections.findByInvitationDid(publicDid!) + const connectionsFromFaberPublicDid = await aliceAgent.connections.findByInvitationDid(publicDid.did!) expect(connectionsFromFaberPublicDid).toHaveLength(2) expect(connectionsFromFaberPublicDid).toEqual( expect.arrayContaining([aliceFaberConnection, aliceFaberNewConnection]) @@ -212,5 +244,5 @@ async function createPublicDid(agent: Agent, unqualifiedSubmitterDid: string, en await sleep(1000) - return createResult.didState.did + return createResult.didState } diff --git a/packages/core/src/modules/oob/helpers.ts b/packages/core/src/modules/oob/helpers.ts index be2fdc1b6e..ccd35e7a31 100644 --- a/packages/core/src/modules/oob/helpers.ts +++ b/packages/core/src/modules/oob/helpers.ts @@ -4,7 +4,7 @@ import { ConnectionInvitationMessage, HandshakeProtocol } from '../connections' import { didKeyToVerkey, verkeyToDidKey } from '../dids/helpers' import { OutOfBandDidCommService } from './domain/OutOfBandDidCommService' -import { OutOfBandInvitation } from './messages' +import { InvitationType, OutOfBandInvitation } from './messages' export function convertToNewInvitation(oldInvitation: ConnectionInvitationMessage) { let service @@ -32,7 +32,9 @@ export function convertToNewInvitation(oldInvitation: ConnectionInvitationMessag handshakeProtocols: [HandshakeProtocol.Connections], } - return new OutOfBandInvitation(options) + const outOfBandInvitation = new OutOfBandInvitation(options) + outOfBandInvitation.invitationType = InvitationType.Connection + return outOfBandInvitation } export function convertToOldInvitation(newInvitation: OutOfBandInvitation) { diff --git a/packages/core/src/modules/oob/messages/OutOfBandInvitation.ts b/packages/core/src/modules/oob/messages/OutOfBandInvitation.ts index 39aec65941..80118119a0 100644 --- a/packages/core/src/modules/oob/messages/OutOfBandInvitation.ts +++ b/packages/core/src/modules/oob/messages/OutOfBandInvitation.ts @@ -1,7 +1,7 @@ import type { PlaintextMessage } from '../../../types' import type { HandshakeProtocol } from '../../connections' -import { Expose, Transform, TransformationType, Type } from 'class-transformer' +import { Exclude, Expose, Transform, TransformationType, Type } from 'class-transformer' import { ArrayNotEmpty, IsArray, IsInstance, IsOptional, IsUrl, ValidateNested } from 'class-validator' import { parseUrl } from 'query-string' @@ -44,6 +44,13 @@ export class OutOfBandInvitation extends AgentMessage { } } + /** + * The original type of the invitation. This is not part of the RFC, but allows to identify + * from what the oob invitation was originally created (e.g. legacy connectionless invitation). + */ + @Exclude() + public invitationType?: InvitationType + public addRequest(message: AgentMessage) { if (!this.requests) this.requests = [] const requestAttachment = new Attachment({ @@ -143,7 +150,6 @@ export class OutOfBandInvitation extends AgentMessage { @ArrayNotEmpty() @OutOfBandServiceTransformer() @IsStringOrInstance(OutOfBandDidCommService, { each: true }) - @ValidateNested({ each: true }) // eslint-disable-next-line @typescript-eslint/ban-types private services!: Array @@ -179,3 +185,12 @@ function OutOfBandServiceTransformer() { return value }) } + +/** + * The original invitation an out of band invitation was derived from. + */ +export enum InvitationType { + OutOfBand = 'out-of-band/1.x', + Connection = 'connections/1.x', + Connectionless = 'connectionless', +} diff --git a/packages/core/src/modules/oob/repository/outOfBandRecordMetadataTypes.ts b/packages/core/src/modules/oob/repository/outOfBandRecordMetadataTypes.ts index f092807324..079339a9bf 100644 --- a/packages/core/src/modules/oob/repository/outOfBandRecordMetadataTypes.ts +++ b/packages/core/src/modules/oob/repository/outOfBandRecordMetadataTypes.ts @@ -1,5 +1,8 @@ +import type { InvitationType } from '../messages' + export enum OutOfBandRecordMetadataKeys { RecipientRouting = '_internal/recipientRouting', + LegacyInvitation = '_internal/legacyInvitation', } export type OutOfBandRecordMetadata = { @@ -9,4 +12,10 @@ export type OutOfBandRecordMetadata = { endpoints: string[] mediatorId?: string } + [OutOfBandRecordMetadataKeys.LegacyInvitation]: { + /** + * Indicates the type of the legacy invitation that was used for this out of band exchange. + */ + legacyInvitationType?: Exclude + } } diff --git a/packages/core/src/modules/proofs/protocol/v2/ProofFormatCoordinator.ts b/packages/core/src/modules/proofs/protocol/v2/ProofFormatCoordinator.ts index 54615d7034..29186ec16f 100644 --- a/packages/core/src/modules/proofs/protocol/v2/ProofFormatCoordinator.ts +++ b/packages/core/src/modules/proofs/protocol/v2/ProofFormatCoordinator.ts @@ -328,7 +328,7 @@ export class ProofFormatCoordinator { goalCode, }) - message.setThread({ threadId: proofRecord.threadId }) + message.setThread({ threadId: proofRecord.threadId, parentThreadId: proofRecord.parentThreadId }) message.setPleaseAck() await didCommMessageRepository.saveOrUpdateAgentMessage(agentContext, { diff --git a/packages/core/src/modules/proofs/protocol/v2/V2ProofProtocol.ts b/packages/core/src/modules/proofs/protocol/v2/V2ProofProtocol.ts index 733fbc9f5c..7a9292e0e8 100644 --- a/packages/core/src/modules/proofs/protocol/v2/V2ProofProtocol.ts +++ b/packages/core/src/modules/proofs/protocol/v2/V2ProofProtocol.ts @@ -642,11 +642,7 @@ export class V2ProofProtocol { - outOfBandInvitationMock = await JsonTransformer.fromJSON(mockOobInvite, OutOfBandInvitation) + outOfBandInvitationMock = JsonTransformer.fromJSON(mockOobInvite, OutOfBandInvitation) + outOfBandInvitationMock.invitationType = InvitationType.OutOfBand MessageValidator.validateSync(outOfBandInvitationMock) - connectionInvitationMock = await JsonTransformer.fromJSON(mockConnectionInvite, ConnectionInvitationMessage) + connectionInvitationMock = JsonTransformer.fromJSON(mockConnectionInvite, ConnectionInvitationMessage) MessageValidator.validateSync(connectionInvitationMock) connectionInvitationToNew = convertToNewInvitation(connectionInvitationMock) }) @@ -113,8 +114,34 @@ describe('shortened urls resolving to connection invitations', () => { const short = await oobInvitationFromShortUrl(mockedResponseConnectionJson) expect(short).toEqual(connectionInvitationToNew) }) - test('Resolve a mocked Response in the form of a connection invitation encoded in an url', async () => { + test('Resolve a mocked Response in the form of a connection invitation encoded in an url c_i query parameter', async () => { const short = await oobInvitationFromShortUrl(mockedResponseConnectionUrl) expect(short).toEqual(connectionInvitationToNew) }) + test('Resolve a mocked Response in the form of a connection invitation encoded in an url oob query parameter', async () => { + const mockedResponseConnectionInOobUrl = { + status: 200, + ok: true, + headers: dummyHeader, + url: 'https://oob.lissi.io/ssi?oob=eyJAdHlwZSI6ImRpZDpzb3Y6QnpDYnNOWWhNcmpIaXFaRFRVQVNIZztzcGVjL2Nvbm5lY3Rpb25zLzEuMC9pbnZpdGF0aW9uIiwiQGlkIjoiMGU0NmEzYWEtMzUyOC00OTIxLWJmYjItN2JjYjk0NjVjNjZjIiwibGFiZWwiOiJTdGFkdCB8IExpc3NpLURlbW8iLCJzZXJ2aWNlRW5kcG9pbnQiOiJodHRwczovL2RlbW8tYWdlbnQuaW5zdGl0dXRpb25hbC1hZ2VudC5saXNzaS5pZC9kaWRjb21tLyIsImltYWdlVXJsIjoiaHR0cHM6Ly9yb3V0aW5nLmxpc3NpLmlvL2FwaS9JbWFnZS9kZW1vTXVzdGVyaGF1c2VuIiwicmVjaXBpZW50S2V5cyI6WyJEZlcxbzM2ekxuczlVdGlDUGQyalIyS2pvcnRvZkNhcFNTWTdWR2N2WEF6aCJdfQ', + } as Response + + mockedResponseConnectionInOobUrl.headers = dummyHeader + + const expectedOobMessage = convertToNewInvitation( + JsonTransformer.fromJSON( + { + '@type': 'did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation', + '@id': '0e46a3aa-3528-4921-bfb2-7bcb9465c66c', + label: 'Stadt | Lissi-Demo', + serviceEndpoint: 'https://demo-agent.institutional-agent.lissi.id/didcomm/', + imageUrl: 'https://routing.lissi.io/api/Image/demoMusterhausen', + recipientKeys: ['DfW1o36zLns9UtiCPd2jR2KjortofCapSSY7VGcvXAzh'], + }, + ConnectionInvitationMessage + ) + ) + const short = await oobInvitationFromShortUrl(mockedResponseConnectionInOobUrl) + expect(short).toEqual(expectedOobMessage) + }) }) diff --git a/packages/core/src/utils/parseInvitation.ts b/packages/core/src/utils/parseInvitation.ts index 68db977e62..e9ba61e4c5 100644 --- a/packages/core/src/utils/parseInvitation.ts +++ b/packages/core/src/utils/parseInvitation.ts @@ -9,7 +9,7 @@ import { AriesFrameworkError } from '../error' import { ConnectionInvitationMessage } from '../modules/connections' import { OutOfBandDidCommService } from '../modules/oob/domain/OutOfBandDidCommService' import { convertToNewInvitation } from '../modules/oob/helpers' -import { OutOfBandInvitation } from '../modules/oob/messages' +import { InvitationType, OutOfBandInvitation } from '../modules/oob/messages' import { JsonEncoder } from './JsonEncoder' import { JsonTransformer } from './JsonTransformer' @@ -35,6 +35,36 @@ const fetchShortUrl = async (invitationUrl: string, dependencies: AgentDependenc return response } +/** + * Parses a JSON containing an invitation message and returns an OutOfBandInvitation instance + * + * @param invitationJson JSON object containing message + * @returns OutOfBandInvitation + */ +export const parseInvitationJson = (invitationJson: Record): OutOfBandInvitation => { + const messageType = invitationJson['@type'] as string + + if (!messageType) { + throw new AriesFrameworkError('Invitation is not a valid DIDComm message') + } + + const parsedMessageType = parseMessageType(messageType) + if (supportsIncomingMessageType(parsedMessageType, OutOfBandInvitation.type)) { + const invitation = JsonTransformer.fromJSON(invitationJson, OutOfBandInvitation) + MessageValidator.validateSync(invitation) + invitation.invitationType = InvitationType.OutOfBand + return invitation + } else if (supportsIncomingMessageType(parsedMessageType, ConnectionInvitationMessage.type)) { + const invitation = JsonTransformer.fromJSON(invitationJson, ConnectionInvitationMessage) + MessageValidator.validateSync(invitation) + const outOfBandInvitation = convertToNewInvitation(invitation) + outOfBandInvitation.invitationType = InvitationType.Connection + return outOfBandInvitation + } else { + throw new AriesFrameworkError(`Invitation with '@type' ${parsedMessageType.messageTypeUri} not supported.`) + } +} + /** * Parses URL containing encoded invitation and returns invitation message. * @@ -44,12 +74,12 @@ const fetchShortUrl = async (invitationUrl: string, dependencies: AgentDependenc */ export const parseInvitationUrl = (invitationUrl: string): OutOfBandInvitation => { const parsedUrl = parseUrl(invitationUrl).query - if (parsedUrl['oob']) { - const outOfBandInvitation = OutOfBandInvitation.fromUrl(invitationUrl) - return outOfBandInvitation - } else if (parsedUrl['c_i'] || parsedUrl['d_m']) { - const invitation = ConnectionInvitationMessage.fromUrl(invitationUrl) - return convertToNewInvitation(invitation) + + const encodedInvitation = parsedUrl['oob'] ?? parsedUrl['c_i'] ?? parsedUrl['d_m'] + + if (typeof encodedInvitation === 'string') { + const invitationJson = JsonEncoder.fromBase64(encodedInvitation) as Record + return parseInvitationJson(invitationJson) } throw new AriesFrameworkError( 'InvitationUrl is invalid. It needs to contain one, and only one, of the following parameters: `oob`, `c_i` or `d_m`.' @@ -61,18 +91,7 @@ export const oobInvitationFromShortUrl = async (response: Response): Promise => { const parsedUrl = parseUrl(invitationUrl).query - if (parsedUrl['oob']) { - const outOfBandInvitation = OutOfBandInvitation.fromUrl(invitationUrl) - return outOfBandInvitation - } else if (parsedUrl['c_i']) { - const invitation = ConnectionInvitationMessage.fromUrl(invitationUrl) - return convertToNewInvitation(invitation) + if (parsedUrl['oob'] || parsedUrl['c_i']) { + return parseInvitationUrl(invitationUrl) } // Legacy connectionless invitation else if (parsedUrl['d_m']) { @@ -132,12 +147,15 @@ export const parseInvitationShortUrl = async ( services: [OutOfBandDidCommService.fromResolvedDidCommService(agentMessage.service.resolvedDidCommService)], }) + invitation.invitationType = InvitationType.Connectionless invitation.addRequest(JsonTransformer.fromJSON(messageWithoutService, AgentMessage)) return invitation } else { try { - return oobInvitationFromShortUrl(await fetchShortUrl(invitationUrl, dependencies)) + const outOfBandInvitation = await oobInvitationFromShortUrl(await fetchShortUrl(invitationUrl, dependencies)) + outOfBandInvitation.invitationType = InvitationType.OutOfBand + return outOfBandInvitation } catch (error) { throw new AriesFrameworkError( 'InvitationUrl is invalid. It needs to contain one, and only one, of the following parameters: `oob`, `c_i` or `d_m`, or be valid shortened URL' diff --git a/packages/core/src/wallet/error/WalletImportPathExistsError.ts b/packages/core/src/wallet/error/WalletImportPathExistsError.ts new file mode 100644 index 0000000000..32d9b46d67 --- /dev/null +++ b/packages/core/src/wallet/error/WalletImportPathExistsError.ts @@ -0,0 +1,7 @@ +import { WalletError } from './WalletError' + +export class WalletImportPathExistsError extends WalletError { + public constructor(message: string, { cause }: { cause?: Error } = {}) { + super(message, { cause }) + } +} diff --git a/packages/core/src/wallet/error/index.ts b/packages/core/src/wallet/error/index.ts index 92040216f4..0f9c04b4dd 100644 --- a/packages/core/src/wallet/error/index.ts +++ b/packages/core/src/wallet/error/index.ts @@ -3,4 +3,5 @@ export { WalletNotFoundError } from './WalletNotFoundError' export { WalletInvalidKeyError } from './WalletInvalidKeyError' export { WalletError } from './WalletError' export { WalletKeyExistsError } from './WalletKeyExistsError' +export { WalletImportPathExistsError } from './WalletImportPathExistsError' export { WalletExportPathExistsError } from './WalletExportPathExistsError' diff --git a/packages/core/tests/logger.ts b/packages/core/tests/logger.ts index 769143e938..a04f57ad57 100644 --- a/packages/core/tests/logger.ts +++ b/packages/core/tests/logger.ts @@ -28,7 +28,7 @@ export class TestLogger extends BaseLogger { } as const // Map our log levels to tslog levels - private tsLogLevelNumgerMap = { + private tsLogLevelNumberMap = { [LogLevel.test]: 0, [LogLevel.trace]: 1, [LogLevel.debug]: 2, @@ -48,12 +48,12 @@ export class TestLogger extends BaseLogger { if (logger) { this.logger = logger.getSubLogger({ name, - minLevel: this.logLevel == LogLevel.off ? undefined : this.tsLogLevelNumgerMap[this.logLevel], + minLevel: this.logLevel == LogLevel.off ? undefined : this.tsLogLevelNumberMap[this.logLevel], }) } else { this.logger = new Logger({ name, - minLevel: this.logLevel == LogLevel.off ? undefined : this.tsLogLevelNumgerMap[this.logLevel], + minLevel: this.logLevel == LogLevel.off ? undefined : this.tsLogLevelNumberMap[this.logLevel], attachedTransports: [logToTransport], }) } diff --git a/packages/core/tests/oob.test.ts b/packages/core/tests/oob.test.ts index fece27bda0..2911d9d406 100644 --- a/packages/core/tests/oob.test.ts +++ b/packages/core/tests/oob.test.ts @@ -721,6 +721,94 @@ describe('out of band', () => { }) }) + describe('messages and connection exchange', () => { + test('oob exchange with handshake where response is received to invitation', async () => { + const { message } = await faberAgent.credentials.createOffer(credentialTemplate) + const outOfBandRecord = await faberAgent.oob.createInvitation({ + handshake: true, + messages: [message], + }) + const { outOfBandInvitation } = outOfBandRecord + + await aliceAgent.oob.receiveInvitation(outOfBandInvitation) + + const aliceCredentialRecordPromise = waitForCredentialRecord(aliceAgent, { + state: CredentialState.OfferReceived, + threadId: message.threadId, + timeoutMs: 10000, + }) + + const aliceCredentialRecord = await aliceCredentialRecordPromise + expect(aliceCredentialRecord.state).toBe(CredentialState.OfferReceived) + + // If we receive the event, we know the processing went well + const faberCredentialRecordPromise = waitForCredentialRecord(faberAgent, { + state: CredentialState.RequestReceived, + threadId: message.threadId, + timeoutMs: 10000, + }) + + await aliceAgent.credentials.acceptOffer({ + credentialRecordId: aliceCredentialRecord.id, + }) + + await faberCredentialRecordPromise + }) + + test('oob exchange with reuse where response is received to invitation', async () => { + const { message } = await faberAgent.credentials.createOffer(credentialTemplate) + + const routing = await faberAgent.mediationRecipient.getRouting({}) + const connectionOutOfBandRecord = await faberAgent.oob.createInvitation({ + routing, + }) + + // Create connection + const { connectionRecord } = await aliceAgent.oob.receiveInvitation(connectionOutOfBandRecord.outOfBandInvitation) + if (!connectionRecord) throw new Error('Connection record is undefined') + await aliceAgent.connections.returnWhenIsConnected(connectionRecord.id) + + // Create offer and reuse + const outOfBandRecord = await faberAgent.oob.createInvitation({ + routing, + messages: [message], + }) + // Create connection + const { connectionRecord: offerConnectionRecord } = await aliceAgent.oob.receiveInvitation( + outOfBandRecord.outOfBandInvitation, + { + reuseConnection: true, + } + ) + if (!offerConnectionRecord) throw new Error('Connection record is undefined') + + // Should be the same, as connection is reused. + expect(offerConnectionRecord.id).toEqual(connectionRecord.id) + + const aliceCredentialRecordPromise = waitForCredentialRecord(aliceAgent, { + state: CredentialState.OfferReceived, + threadId: message.threadId, + timeoutMs: 10000, + }) + + const aliceCredentialRecord = await aliceCredentialRecordPromise + expect(aliceCredentialRecord.state).toBe(CredentialState.OfferReceived) + + // If we receive the event, we know the processing went well + const faberCredentialRecordPromise = waitForCredentialRecord(faberAgent, { + state: CredentialState.RequestReceived, + threadId: message.threadId, + timeoutMs: 10000, + }) + + await aliceAgent.credentials.acceptOffer({ + credentialRecordId: aliceCredentialRecord.id, + }) + + await faberCredentialRecordPromise + }) + }) + describe('connection-less exchange', () => { test('oob exchange without handshake where response is received to invitation', async () => { const { message } = await faberAgent.credentials.createOffer(credentialTemplate) diff --git a/packages/indy-sdk-to-askar-migration/CHANGELOG.md b/packages/indy-sdk-to-askar-migration/CHANGELOG.md index 7c76b927af..4a589f8d98 100644 --- a/packages/indy-sdk-to-askar-migration/CHANGELOG.md +++ b/packages/indy-sdk-to-askar-migration/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/indy-sdk-to-askar-migration + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +**Note:** Version bump only for package @aries-framework/indy-sdk-to-askar-migration + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/indy-sdk-to-askar-migration/package.json b/packages/indy-sdk-to-askar-migration/package.json index e761faefc3..f91b8d22ce 100644 --- a/packages/indy-sdk-to-askar-migration/package.json +++ b/packages/indy-sdk-to-askar-migration/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/indy-sdk-to-askar-migration", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,13 +24,13 @@ "test": "jest" }, "dependencies": { - "@aries-framework/anoncreds": "0.4.0", - "@aries-framework/askar": "0.4.0", - "@aries-framework/core": "0.4.0", - "@aries-framework/node": "0.4.0" + "@aries-framework/anoncreds": "0.4.2", + "@aries-framework/askar": "0.4.2", + "@aries-framework/core": "0.4.2", + "@aries-framework/node": "0.4.2" }, "devDependencies": { - "@aries-framework/indy-sdk": "0.4.0", + "@aries-framework/indy-sdk": "0.4.2", "@hyperledger/aries-askar-nodejs": "^0.1.0", "@hyperledger/aries-askar-shared": "^0.1.0", "indy-sdk": "^1.16.0-dev-1655", diff --git a/packages/indy-sdk/CHANGELOG.md b/packages/indy-sdk/CHANGELOG.md index 138d320176..162267c246 100644 --- a/packages/indy-sdk/CHANGELOG.md +++ b/packages/indy-sdk/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- update tsyringe for ts 5 support ([#1588](https://github.com/hyperledger/aries-framework-javascript/issues/1588)) ([296955b](https://github.com/hyperledger/aries-framework-javascript/commit/296955b3a648416ac6b502da05a10001920af222)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **anoncreds:** wrong key name for predicates in proof object ([#1517](https://github.com/hyperledger/aries-framework-javascript/issues/1517)) ([d895c78](https://github.com/hyperledger/aries-framework-javascript/commit/d895c78e0e02954a95ad1fd7e2251ee9a02445dc)) +- force did:key resolver/registrar presence ([#1535](https://github.com/hyperledger/aries-framework-javascript/issues/1535)) ([aaa13dc](https://github.com/hyperledger/aries-framework-javascript/commit/aaa13dc77d6d5133cd02e768e4173462fa65064a)) + +### Features + +- **anoncreds:** auto create link secret ([#1521](https://github.com/hyperledger/aries-framework-javascript/issues/1521)) ([c6f03e4](https://github.com/hyperledger/aries-framework-javascript/commit/c6f03e49d79a33b1c4b459cef11add93dee051d0)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/indy-sdk/package.json b/packages/indy-sdk/package.json index 6d12b17ac6..2192662ac8 100644 --- a/packages/indy-sdk/package.json +++ b/packages/indy-sdk/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/indy-sdk", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,14 +24,14 @@ "test": "jest" }, "dependencies": { - "@aries-framework/anoncreds": "0.4.0", - "@aries-framework/core": "0.4.0", + "@aries-framework/anoncreds": "0.4.2", + "@aries-framework/core": "0.4.2", "@stablelib/ed25519": "^1.0.3", - "@types/indy-sdk": "1.16.26", + "@types/indy-sdk": "1.16.27", "class-transformer": "0.5.1", "class-validator": "0.14.0", "rxjs": "^7.2.0", - "tsyringe": "^4.7.0" + "tsyringe": "^4.8.0" }, "devDependencies": { "rimraf": "^4.4.0", diff --git a/packages/indy-vdr/CHANGELOG.md b/packages/indy-vdr/CHANGELOG.md index 2c5c023417..7f5af7b488 100644 --- a/packages/indy-vdr/CHANGELOG.md +++ b/packages/indy-vdr/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/indy-vdr + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **indy-vdr:** role property not included in nym request ([#1488](https://github.com/hyperledger/aries-framework-javascript/issues/1488)) ([002be4f](https://github.com/hyperledger/aries-framework-javascript/commit/002be4f578729aed1c8ae337f3d2eeecce9e3725)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/indy-vdr/package.json b/packages/indy-vdr/package.json index ecdfffdc76..01bfa13598 100644 --- a/packages/indy-vdr/package.json +++ b/packages/indy-vdr/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/indy-vdr", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,8 +24,8 @@ "test": "jest" }, "dependencies": { - "@aries-framework/anoncreds": "0.4.0", - "@aries-framework/core": "0.4.0" + "@aries-framework/anoncreds": "0.4.2", + "@aries-framework/core": "0.4.2" }, "devDependencies": { "@hyperledger/indy-vdr-nodejs": "^0.1.0", diff --git a/packages/node/CHANGELOG.md b/packages/node/CHANGELOG.md index 9baa91ecbe..bc626c940d 100644 --- a/packages/node/CHANGELOG.md +++ b/packages/node/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +### Bug Fixes + +- log and throw on WebSocket sending errors ([#1573](https://github.com/hyperledger/aries-framework-javascript/issues/1573)) ([11050af](https://github.com/hyperledger/aries-framework-javascript/commit/11050afc7965adfa9b00107ba34abfbe3afaf874)) + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- **samples:** mediator wallet and http transport ([#1508](https://github.com/hyperledger/aries-framework-javascript/issues/1508)) ([04a8058](https://github.com/hyperledger/aries-framework-javascript/commit/04a80589b19725fb493e51e52a7345915b2c7341)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/node/package.json b/packages/node/package.json index f4d3c8e598..69d43e5018 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/node", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,7 +24,7 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "@types/express": "^4.17.15", "express": "^4.17.1", "ffi-napi": "^4.0.3", diff --git a/packages/node/src/transport/WsInboundTransport.ts b/packages/node/src/transport/WsInboundTransport.ts index 4b44675426..423b44e474 100644 --- a/packages/node/src/transport/WsInboundTransport.ts +++ b/packages/node/src/transport/WsInboundTransport.ts @@ -38,7 +38,7 @@ export class WsInboundTransport implements InboundTransport { if (!this.socketIds[socketId]) { this.logger.debug(`Saving new socket with id ${socketId}.`) this.socketIds[socketId] = socket - const session = new WebSocketTransportSession(socketId, socket) + const session = new WebSocketTransportSession(socketId, socket, this.logger) this.listenOnWebSocketMessages(agent, socket, session) socket.on('close', () => { this.logger.debug('Socket closed.') @@ -58,7 +58,6 @@ export class WsInboundTransport implements InboundTransport { if (error) { reject(error) } - resolve() }) }) @@ -73,7 +72,7 @@ export class WsInboundTransport implements InboundTransport { try { await messageReceiver.receiveMessage(JSON.parse(event.data), { session }) } catch (error) { - this.logger.error('Error processing message') + this.logger.error(`Error processing message: ${error}`) } }) } @@ -83,18 +82,26 @@ export class WebSocketTransportSession implements TransportSession { public id: string public readonly type = 'WebSocket' public socket: WebSocket + private logger: Logger - public constructor(id: string, socket: WebSocket) { + public constructor(id: string, socket: WebSocket, logger: Logger) { this.id = id this.socket = socket + this.logger = logger } public async send(agentContext: AgentContext, encryptedMessage: EncryptedMessage): Promise { if (this.socket.readyState !== WebSocket.OPEN) { throw new AriesFrameworkError(`${this.type} transport session has been closed.`) } - - this.socket.send(JSON.stringify(encryptedMessage)) + this.socket.send(JSON.stringify(encryptedMessage), (error?) => { + if (error != undefined) { + this.logger.debug(`Error sending message: ${error}`) + throw new AriesFrameworkError(`${this.type} send message failed.`, { cause: error }) + } else { + this.logger.debug(`${this.type} sent message successfully.`) + } + }) } public async close(): Promise { diff --git a/packages/openid4vc-client/CHANGELOG.md b/packages/openid4vc-client/CHANGELOG.md index 6243dddbad..0c03004490 100644 --- a/packages/openid4vc-client/CHANGELOG.md +++ b/packages/openid4vc-client/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/openid4vc-client + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +**Note:** Version bump only for package @aries-framework/openid4vc-client + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/openid4vc-client/package.json b/packages/openid4vc-client/package.json index be5ada7960..a0bcdf214f 100644 --- a/packages/openid4vc-client/package.json +++ b/packages/openid4vc-client/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/openid4vc-client", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,12 +24,12 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "@sphereon/openid4vci-client": "^0.4.0", "@stablelib/random": "^1.0.2" }, "devDependencies": { - "@aries-framework/node": "0.4.0", + "@aries-framework/node": "0.4.2", "nock": "^13.3.0", "rimraf": "^4.4.0", "typescript": "~4.9.5" diff --git a/packages/question-answer/CHANGELOG.md b/packages/question-answer/CHANGELOG.md index adb6da1b2f..4e21fbab94 100644 --- a/packages/question-answer/CHANGELOG.md +++ b/packages/question-answer/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/question-answer + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Features + +- oob without handhsake improvements and routing ([#1511](https://github.com/hyperledger/aries-framework-javascript/issues/1511)) ([9e69cf4](https://github.com/hyperledger/aries-framework-javascript/commit/9e69cf441a75bf7a3c5556cf59e730ee3fce8c28)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/question-answer/package.json b/packages/question-answer/package.json index 6b05d2b57c..f42cd0cbd5 100644 --- a/packages/question-answer/package.json +++ b/packages/question-answer/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/question-answer", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,13 +24,13 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "class-transformer": "0.5.1", "class-validator": "0.14.0", "rxjs": "^7.2.0" }, "devDependencies": { - "@aries-framework/node": "0.4.0", + "@aries-framework/node": "0.4.2", "reflect-metadata": "^0.1.13", "rimraf": "^4.4.0", "typescript": "~4.9.5" diff --git a/packages/react-native/CHANGELOG.md b/packages/react-native/CHANGELOG.md index 2d5749518e..843d6e8f2b 100644 --- a/packages/react-native/CHANGELOG.md +++ b/packages/react-native/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/react-native + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Bug Fixes + +- check if URL already encoded ([#1485](https://github.com/hyperledger/aries-framework-javascript/issues/1485)) ([38a0578](https://github.com/hyperledger/aries-framework-javascript/commit/38a0578011896cfcf217713d34f285cd381ad72c)) +- encode tails url ([#1479](https://github.com/hyperledger/aries-framework-javascript/issues/1479)) ([fd190b9](https://github.com/hyperledger/aries-framework-javascript/commit/fd190b96106ca4916539d96ff6c4ecef7833f148)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) - feat!: add data, cache and temp dirs to FileSystem (#1306) ([ff5596d](https://github.com/hyperledger/aries-framework-javascript/commit/ff5596d0631e93746494c017797d0191b6bdb0b1)), closes [#1306](https://github.com/hyperledger/aries-framework-javascript/issues/1306) diff --git a/packages/react-native/package.json b/packages/react-native/package.json index c96be09521..7de95a6377 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/react-native", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,7 +24,7 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "@azure/core-asynciterator-polyfill": "^1.0.2", "events": "^3.3.0" }, diff --git a/packages/tenants/CHANGELOG.md b/packages/tenants/CHANGELOG.md index 75b37cfb0b..b31092f57b 100644 --- a/packages/tenants/CHANGELOG.md +++ b/packages/tenants/CHANGELOG.md @@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.2](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.1...v0.4.2) (2023-10-05) + +**Note:** Version bump only for package @aries-framework/tenants + +## [0.4.1](https://github.com/hyperledger/aries-framework-javascript/compare/v0.4.0...v0.4.1) (2023-08-28) + +### Features + +- support askar profiles for multi-tenancy ([#1538](https://github.com/hyperledger/aries-framework-javascript/issues/1538)) ([e448a2a](https://github.com/hyperledger/aries-framework-javascript/commit/e448a2a58dddff2cdf80c4549ea2d842a54b43d1)) + # [0.4.0](https://github.com/hyperledger/aries-framework-javascript/compare/v0.3.3...v0.4.0) (2023-06-03) ### Bug Fixes diff --git a/packages/tenants/package.json b/packages/tenants/package.json index b5d84d761d..3d8dde6a7b 100644 --- a/packages/tenants/package.json +++ b/packages/tenants/package.json @@ -2,7 +2,7 @@ "name": "@aries-framework/tenants", "main": "build/index", "types": "build/index", - "version": "0.4.0", + "version": "0.4.2", "files": [ "build" ], @@ -24,11 +24,11 @@ "test": "jest" }, "dependencies": { - "@aries-framework/core": "0.4.0", + "@aries-framework/core": "0.4.2", "async-mutex": "^0.4.0" }, "devDependencies": { - "@aries-framework/node": "0.4.0", + "@aries-framework/node": "0.4.2", "reflect-metadata": "^0.1.13", "rimraf": "^4.4.0", "typescript": "~4.9.5" diff --git a/yarn.lock b/yarn.lock index 96627bb1a4..3d32a01551 100644 --- a/yarn.lock +++ b/yarn.lock @@ -123,6 +123,75 @@ dependencies: xss "^1.0.8" +"@aries-framework/anoncreds@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@aries-framework/anoncreds/-/anoncreds-0.4.0.tgz#abf0dd6b316d607fbee9fc5ef5d5709dfa2ded36" + integrity sha512-jzZVMXJoTutF5jrATYXHiavUi2APEUbvGiOA8EelP7cabVxCijoWh0DdTEBoGSUv9xuK26iSWVY0MmnAxD7l9g== + dependencies: + "@aries-framework/core" "0.4.0" + bn.js "^5.2.1" + class-transformer "0.5.1" + class-validator "0.14.0" + reflect-metadata "^0.1.13" + +"@aries-framework/askar@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@aries-framework/askar/-/askar-0.4.0.tgz#c9c044497e466aab9bd5e5d77b2fb1bd01fdac1c" + integrity sha512-FQxT+NVUv/CSnlXY13Idilg7qA7xABEKOO2YGi5xUGiyruJDtqzQ6dWqGsa2odX3KE1baFFrNHgCC9I7N+++Jg== + dependencies: + "@aries-framework/core" "0.4.0" + bn.js "^5.2.1" + class-transformer "0.5.1" + class-validator "0.14.0" + rxjs "^7.2.0" + tsyringe "^4.7.0" + +"@aries-framework/core@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@aries-framework/core/-/core-0.4.0.tgz#6af11446174d8f690aa1bf4abf6f61ad47a05b52" + integrity sha512-Z/rTgpJMKTl9iQQd8GnNEV5wCZKdV+kkd+Y4e/KS+j+6yMOxrgaVGcAKlcFIPcHUc6l1iOetJFeVLSwftXW2Kg== + dependencies: + "@digitalcredentials/jsonld" "^5.2.1" + "@digitalcredentials/jsonld-signatures" "^9.3.1" + "@digitalcredentials/vc" "^1.1.2" + "@multiformats/base-x" "^4.0.1" + "@stablelib/ed25519" "^1.0.2" + "@stablelib/random" "^1.0.1" + "@stablelib/sha256" "^1.0.1" + "@types/ws" "^8.5.4" + abort-controller "^3.0.0" + big-integer "^1.6.51" + borc "^3.0.0" + buffer "^6.0.3" + class-transformer "0.5.1" + class-validator "0.14.0" + did-resolver "^4.1.0" + lru_map "^0.4.1" + luxon "^3.3.0" + make-error "^1.3.6" + node-fetch "^2.6.1" + object-inspect "^1.10.3" + query-string "^7.0.1" + reflect-metadata "^0.1.13" + rxjs "^7.2.0" + tsyringe "^4.7.0" + uuid "^9.0.0" + varint "^6.0.0" + web-did-resolver "^2.0.21" + +"@aries-framework/node@0.4.0": + version "0.4.0" + resolved "https://registry.yarnpkg.com/@aries-framework/node/-/node-0.4.0.tgz#2d9f0f58f433c8ef61a5f275e3a1d7a75ecc4dbd" + integrity sha512-ydxkD+Hb8XLLUeX2G27baNUtC3BBB3LG2NfZgy2128q6mAg2mqhLnjWocncE7kWFVneZ5copBIoF2MIPQvwYhg== + dependencies: + "@aries-framework/core" "0.4.0" + "@types/express" "^4.17.15" + express "^4.17.1" + ffi-napi "^4.0.3" + node-fetch "^2.6.1" + ref-napi "^3.0.3" + ws "^8.13.0" + "@ayanworks/polygon-did-registry-contract@2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@ayanworks/polygon-did-registry-contract/-/polygon-did-registry-contract-2.0.0.tgz#bddd72c04b4cc270d226ded4b85760944b03915e" @@ -993,12 +1062,12 @@ uuid "^9.0.0" "@cheqd/ts-proto@^2.2.0", "@cheqd/ts-proto@cjs": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@cheqd/ts-proto/-/ts-proto-2.2.0.tgz#c296a9fff23f47fba84f9c3354439b8fc91129f4" - integrity sha512-COTDndE/haSUPndVYaJGAVT4OMIrVSibGfLrKol9CXZBasmUUJx5rVFOpL34wYq6VcOrfF2TN+63TRePRUBWpA== + version "2.2.2" + resolved "https://registry.yarnpkg.com/@cheqd/ts-proto/-/ts-proto-2.2.2.tgz#c0e808c6d438da7098a225ea24ee94db9822fa06" + integrity sha512-32XCz1tD/T8r9Pw6IWH+XDttnGEguN0/1dWoUnTZ6uIPAA65YYSz2Ba9ZJ69a7YipYzX9C1CRddVZ3u229dfYg== dependencies: - long "^5.2.1" - protobufjs "^7.2.3" + long "^5.2.3" + protobufjs "^7.2.4" "@confio/ics23@^0.6.8": version "0.6.8" @@ -1018,15 +1087,15 @@ "@cosmjs/math" "^0.29.5" "@cosmjs/utils" "^0.29.5" -"@cosmjs/amino@^0.31.0": - version "0.31.0" - resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.31.0.tgz#49b33047295002804ad51bdf7ec0c2c97f1b553d" - integrity sha512-xJ5CCEK7H79FTpOuEmlpSzVI+ZeYESTVvO3wHDgbnceIyAne3C68SvyaKqLUR4uJB0Z4q4+DZHbqW6itUiv4lA== +"@cosmjs/amino@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.31.1.tgz#e6b4adc3ebe19ddfd953c67ee04b1eae488238af" + integrity sha512-kkB9IAkNEUFtjp/uwHv95TgM8VGJ4VWfZwrTyLNqBDD1EpSX2dsNrmUe7k8OMPzKlZUFcKmD4iA0qGvIwzjbGA== dependencies: - "@cosmjs/crypto" "^0.31.0" - "@cosmjs/encoding" "^0.31.0" - "@cosmjs/math" "^0.31.0" - "@cosmjs/utils" "^0.31.0" + "@cosmjs/crypto" "^0.31.1" + "@cosmjs/encoding" "^0.31.1" + "@cosmjs/math" "^0.31.1" + "@cosmjs/utils" "^0.31.1" "@cosmjs/crypto@^0.29.5": version "0.29.5" @@ -1041,14 +1110,14 @@ elliptic "^6.5.4" libsodium-wrappers "^0.7.6" -"@cosmjs/crypto@^0.31.0": - version "0.31.0" - resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.31.0.tgz#0be3867ada0155da19c45a51f5fde08e84f9ec4b" - integrity sha512-UaqCe6Tgh0pe1QlZ66E13t6FlIF86QrnBXXq+EN7Xe1Rouza3fJ1ojGlPleJZkBoq3tAyYVIOOqdZIxtVj/sIQ== +"@cosmjs/crypto@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.31.1.tgz#ce4917df0f7b38f0909a32020907ccff04acefe6" + integrity sha512-4R/SqdzdVzd4E5dpyEh1IKm5GbTqwDogutyIyyb1bcOXiX/x3CrvPI9Tb4WSIMDLvlb5TVzu2YnUV51Q1+6mMA== dependencies: - "@cosmjs/encoding" "^0.31.0" - "@cosmjs/math" "^0.31.0" - "@cosmjs/utils" "^0.31.0" + "@cosmjs/encoding" "^0.31.1" + "@cosmjs/math" "^0.31.1" + "@cosmjs/utils" "^0.31.1" "@noble/hashes" "^1" bn.js "^5.2.0" elliptic "^6.5.4" @@ -1063,10 +1132,10 @@ bech32 "^1.1.4" readonly-date "^1.0.0" -"@cosmjs/encoding@^0.31.0": - version "0.31.0" - resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.31.0.tgz#9a6fd80b59c35fc20638a6436128ad0be681eafc" - integrity sha512-NYGQDRxT7MIRSlcbAezwxK0FqnaSPKCH7O32cmfpHNWorFxhy9lwmBoCvoe59Kd0HmArI4h+NGzLEfX3OLnA4Q== +"@cosmjs/encoding@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.31.1.tgz#0041b2650c443d883e22f27c7d3cd7b844c6d0ec" + integrity sha512-IuxP6ewwX6vg9sUJ8ocJD92pkerI4lyG8J5ynAM3NaX3q+n+uMoPRSQXNeL9bnlrv01FF1kIm8if/f5F7ZPtkA== dependencies: base64-js "^1.3.0" bech32 "^1.1.4" @@ -1087,10 +1156,10 @@ dependencies: bn.js "^5.2.0" -"@cosmjs/math@^0.31.0": - version "0.31.0" - resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.31.0.tgz#c9fc5f8191df7c2375945d2eacce327dfbf26414" - integrity sha512-Sb/8Ry/+gKJaYiV6X8q45kxXC9FoV98XCY1WXtu0JQwOi61VCG2VXsURQnVvZ/EhR/CuT/swOlNKrqEs3da0fw== +"@cosmjs/math@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.31.1.tgz#74c02cf237c2996b77661b636b014168b18d95e6" + integrity sha512-kiuHV6m6DSB8/4UV1qpFhlc4ul8SgLXTGRlYkYiIIP4l0YNeJ+OpPYaOlEgx4Unk2mW3/O2FWYj7Jc93+BWXng== dependencies: bn.js "^5.2.0" @@ -1108,15 +1177,15 @@ long "^4.0.0" "@cosmjs/proto-signing@^0.31.0": - version "0.31.0" - resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.31.0.tgz#7056963457cd967f53f56c2ab4491638e5ade2c0" - integrity sha512-JNlyOJRkn8EKB9mCthkjr6lVX6eyVQ09PFdmB4/DR874E62dFTvQ+YvyKMAgN7K7Dcjj26dVlAD3f6Xs7YOGDg== - dependencies: - "@cosmjs/amino" "^0.31.0" - "@cosmjs/crypto" "^0.31.0" - "@cosmjs/encoding" "^0.31.0" - "@cosmjs/math" "^0.31.0" - "@cosmjs/utils" "^0.31.0" + version "0.31.1" + resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.31.1.tgz#3929d5bee3c88c42b3bc3c4b9db4ab3bddb684c4" + integrity sha512-hipbBVrssPu+jnmRzQRP5hhS/mbz2nU7RvxG/B1ZcdNhr1AtZC5DN09OTUoEpMSRgyQvScXmk/NTbyf+xmCgYg== + dependencies: + "@cosmjs/amino" "^0.31.1" + "@cosmjs/crypto" "^0.31.1" + "@cosmjs/encoding" "^0.31.1" + "@cosmjs/math" "^0.31.1" + "@cosmjs/utils" "^0.31.1" cosmjs-types "^0.8.0" long "^4.0.0" @@ -1176,10 +1245,10 @@ resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.29.5.tgz#3fed1b3528ae8c5f1eb5d29b68755bebfd3294ee" integrity sha512-m7h+RXDUxOzEOGt4P+3OVPX7PuakZT3GBmaM/Y2u+abN3xZkziykD/NvedYFvvCCdQo714XcGl33bwifS9FZPQ== -"@cosmjs/utils@^0.31.0": - version "0.31.0" - resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.31.0.tgz#3a7ac16856dcff63bbf1bb11e31f975f71ef4f21" - integrity sha512-nNcycZWUYLNJlrIXgpcgVRqdl6BXjF4YlXdxobQWpW9Tikk61bEGeAFhDYtC0PwHlokCNw0KxWiHGJL4nL7Q5A== +"@cosmjs/utils@^0.31.1": + version "0.31.1" + resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.31.1.tgz#e6055cd7d722fa72df9cbd0d39cd1f7a9ac80483" + integrity sha512-n4Se1wu4GnKwztQHNFfJvUeWcpvx3o8cWhSbNs9JQShEuB3nv3R5lqFBtDCgHZF/emFQAP+ZjF8bTfCs9UBGhA== "@cspotcode/source-map-support@^0.8.0": version "0.8.1" @@ -3957,14 +4026,14 @@ "@types/node" "*" "@types/http-cache-semantics@*": - version "4.0.1" - resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" - integrity sha512-SZs7ekbP8CN0txVG2xVRH6EgKmEm31BOxA07vkFaETzZz1xh+cbt8BcI0slpymvwhx5dlFnQG2rTlPVQn+iRPQ== + version "4.0.4" + resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz#b979ebad3919799c979b17c72621c0bc0a31c6c4" + integrity sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA== -"@types/indy-sdk@*", "@types/indy-sdk@1.16.26", "@types/indy-sdk@^1.16.26": - version "1.16.26" - resolved "https://registry.yarnpkg.com/@types/indy-sdk/-/indy-sdk-1.16.26.tgz#871f82c3f7d241d649aff5eb6800048890efb8f8" - integrity sha512-KlnjsVsX/7yTmyyIlHWcytlBHoQ1vPGeiLnLv5y1vDftL6OQ5V+hebfAr7d3roMEsjCTH3qKkklwGcj1qS90YA== +"@types/indy-sdk@*", "@types/indy-sdk@1.16.27", "@types/indy-sdk@^1.16.26": + version "1.16.27" + resolved "https://registry.yarnpkg.com/@types/indy-sdk/-/indy-sdk-1.16.27.tgz#f5f01fe2cd39b74cacf91ea84d46a2e351cefa3b" + integrity sha512-ASEGYOuz8Acbybz4W2CYTG/fF7H9UQmJIG5wz8PSAvme07QU04Yzj4RJ5Nzzjej0X/AApEHS/5Jpk3iXTOs9HQ== dependencies: buffer "^6.0.0" @@ -11540,7 +11609,7 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== -long@^5.0.0, long@^5.2.1: +long@^5.0.0, long@^5.2.3: version "5.2.3" resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== @@ -14296,10 +14365,10 @@ protobufjs@^6.8.8, protobufjs@~6.11.2, protobufjs@~6.11.3: "@types/node" ">=13.7.0" long "^4.0.0" -protobufjs@^7.2.3: - version "7.2.4" - resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.4.tgz#3fc1ec0cdc89dd91aef9ba6037ba07408485c3ae" - integrity sha512-AT+RJgD2sH8phPmCf7OUZR8xGdcJRga4+1cOaXJ64hvcSkVhNcRHOwIxUatPH15+nj59WAGTDv3LSGZPEQbJaQ== +protobufjs@^7.2.4: + version "7.2.5" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.5.tgz#45d5c57387a6d29a17aab6846dcc283f9b8e7f2d" + integrity sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A== dependencies: "@protobufjs/aspromise" "^1.1.2" "@protobufjs/base64" "^1.1.2" @@ -16489,7 +16558,7 @@ tsutils@^3.21.0: dependencies: tslib "^1.8.1" -tsyringe@^4.7.0: +tsyringe@^4.7.0, tsyringe@^4.8.0: version "4.8.0" resolved "https://registry.yarnpkg.com/tsyringe/-/tsyringe-4.8.0.tgz#d599651b36793ba872870fee4f845bd484a5cac1" integrity sha512-YB1FG+axdxADa3ncEtRnQCFq/M0lALGLxSZeVNbTU8NqhOVc51nnv2CISTcvc1kyv6EGPtXVr0v6lWeDxiijOA==