Skip to content

Commit

Permalink
feat: Added support for url query inside the didcomm deeplink (#76)
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Lanser <[email protected]>
  • Loading branch information
Tommylans authored Nov 3, 2023
1 parent 6bb4fee commit 39c63b8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@internal/openid4vc-client": "*",
"@internal/utils": "*",
"@tanstack/react-query": "^4.33.0",
"query-string": "^8.1.0",
"rxjs": "^7.8.1"
},
"peerDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion packages/agent/src/parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { W3cCredentialRepository } from '@aries-framework/core/build/modules/vc/
import { supportsIncomingMessageType } from '@aries-framework/core/build/utils/messageType'
import { OpenId4VpClientService, OpenIdCredentialFormatProfile } from '@internal/openid4vc-client'
import { getHostNameFromUrl } from '@internal/utils'
import queryString from 'query-string'
import { filter, firstValueFrom, merge, first, timeout } from 'rxjs'

export enum QrTypes {
Expand Down Expand Up @@ -346,12 +347,15 @@ export async function tryParseDidCommInvitation(
invitationUrl: string
): Promise<OutOfBandInvitation | null> {
try {
const parsedUrl = queryString.parseUrl(invitationUrl)
const updatedInvitationUrl = (parsedUrl['oobUrl'] as string | undefined) ?? invitationUrl

// Try to parse the invitation as an DIDComm invitation.
// We can't know for sure, as it could be a shortened URL to a DIDComm invitation.
// So we use the parseMessage from AFJ and see if this returns a valid message.
// Parse invitation supports legacy connection invitations, oob invitations, and
// legacy connectionless invitations, and will all transform them into an OOB invitation.
const invitation = await agent.oob.parseInvitation(invitationUrl)
const invitation = await agent.oob.parseInvitation(updatedInvitationUrl)

agent.config.logger.debug(`Parsed didcomm invitation with id ${invitation.id}`)
return invitation
Expand Down
33 changes: 33 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3281,6 +3281,7 @@ __metadata:
"@internal/openid4vc-client": "*"
"@internal/utils": "*"
"@tanstack/react-query": ^4.33.0
query-string: ^8.1.0
rxjs: ^7.8.1
peerDependencies:
"@hyperledger/anoncreds-react-native": ^0.1.0
Expand Down Expand Up @@ -8610,6 +8611,13 @@ __metadata:
languageName: node
linkType: hard

"decode-uri-component@npm:^0.4.1":
version: 0.4.1
resolution: "decode-uri-component@npm:0.4.1"
checksum: 0473924860986fb6ca19ee65a2af13e08801b4f3660475b058500ea8479ed715c919884a026b6bf4296dbb640d3cea74fadf45490b2439152fc548271d0201ec
languageName: node
linkType: hard

"decompress-response@npm:^3.3.0":
version: 3.3.0
resolution: "decompress-response@npm:3.3.0"
Expand Down Expand Up @@ -10409,6 +10417,13 @@ __metadata:
languageName: node
linkType: hard

"filter-obj@npm:^5.1.0":
version: 5.1.0
resolution: "filter-obj@npm:5.1.0"
checksum: ba7c24d9b2c0552ee87d268e07eca74483af61fb740545ffa809f7e9e5294de38cf163ecc55af0e8a40020af9a49512c32f4022de2a858b110420fc8bffa7c9c
languageName: node
linkType: hard

"finalhandler@npm:1.1.2":
version: 1.1.2
resolution: "finalhandler@npm:1.1.2"
Expand Down Expand Up @@ -15236,6 +15251,17 @@ __metadata:
languageName: node
linkType: hard

"query-string@npm:^8.1.0":
version: 8.1.0
resolution: "query-string@npm:8.1.0"
dependencies:
decode-uri-component: ^0.4.1
filter-obj: ^5.1.0
split-on-first: ^3.0.0
checksum: 16fe49ab714f2b802bd31bc417876a38a82cd49bea01c0d6c37ca3439604c774752c8c66f9eda5ee33c268de2fc2a65e0e0e27aa97d8d98159af5c1fc838a017
languageName: node
linkType: hard

"querystring@npm:0.2.0":
version: 0.2.0
resolution: "querystring@npm:0.2.0"
Expand Down Expand Up @@ -16681,6 +16707,13 @@ __metadata:
languageName: node
linkType: hard

"split-on-first@npm:^3.0.0":
version: 3.0.0
resolution: "split-on-first@npm:3.0.0"
checksum: 75dc27ecbac65cfbeab9a3b90cf046307220192d3d7a30e46aa0f19571cc9b4802aac813f3de2cc9b16f2e46aae72f275659b5d2614bb5369c77724d739e5f73
languageName: node
linkType: hard

"split@npm:^1.0.1":
version: 1.0.1
resolution: "split@npm:1.0.1"
Expand Down

0 comments on commit 39c63b8

Please sign in to comment.