Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oob): support fetching shortened invitation urls #840

Merged
merged 50 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
bd89bc2
Created messages for pickup-v2
TheTreek Apr 7, 2022
b7be29c
Formatting
TheTreek Apr 7, 2022
6d50301
Added handlers for pickup-v2 messages
KolbyRKunz Apr 8, 2022
924c30a
Formatting
KolbyRKunz Apr 8, 2022
6e9f655
send delivery-request through websockets
TheTreek Apr 12, 2022
7f21fd3
Added todo to fix forcing of websockets
TheTreek Apr 12, 2022
2e490cd
Force return_route for pickup-v2, fix delivery handler, general cleanup
TheTreek Apr 13, 2022
5573dcd
Added a limit on how many messages we can request from mediator
TheTreek Apr 13, 2022
fc3e380
Updated reciepnt modules to check for pickupV2
KolbyRKunz Apr 14, 2022
8af3669
put try/catch around message delivery, send status-request on websock…
TheTreek Apr 14, 2022
c611880
Created unit testing for MediatorRecipientService for pickupv2
KolbyRKunz Apr 15, 2022
9195ec5
merge conflicts
KolbyRKunz Apr 15, 2022
01452f6
Updated to PR requests
KolbyRKunz Apr 19, 2022
6cd31c2
Made the message receiver a property of message recipient module
KolbyRKunz Apr 20, 2022
d48dd60
Moved requestStatus into a service to make it internal for now
KolbyRKunz Apr 22, 2022
a51aa81
changed initiateImplicitPickup to openWebSocketAndPickup
KolbyRKunz Apr 27, 2022
85d4c96
initial commit for testing url shortening
KolbyRKunz Apr 28, 2022
5181d7d
updated fromURL for shortened URL
KolbyRKunz May 5, 2022
08d4106
added additional logic to handle shorten URL's that have been redirected
KolbyRKunz May 5, 2022
bb107e1
Improved url shortening
KolbyRKunz May 6, 2022
a359176
Url shortening working, RFC discussion needed
KolbyRKunz May 6, 2022
fb8e808
Merge branch 'main' into feature/shortUrl
KolbyRKunz May 20, 2022
56ca498
cloned url shortening into oob
KolbyRKunz May 20, 2022
d5be405
comments about not being able to follow RFC
KolbyRKunz May 20, 2022
c708a3c
updated query param for oob portion
KolbyRKunz May 20, 2022
f1c2ce1
Merge branch 'main' into feature/shortUrl
KolbyRKunz May 26, 2022
6dcb8f7
tested against oob and added version transformers
KolbyRKunz May 27, 2022
6731c78
formatting
KolbyRKunz May 27, 2022
3cc003e
merge conflicts
KolbyRKunz Jun 8, 2022
142d278
formatting
KolbyRKunz Jun 8, 2022
fd70c1a
initial easy fixes
KolbyRKunz Jun 9, 2022
35da251
refactor done, need to test and create unit tests
KolbyRKunz Jun 15, 2022
6007927
Json results can determine message type
KolbyRKunz Jun 16, 2022
06ed262
tests for out of band shorten invitations written
KolbyRKunz Jun 17, 2022
fb06a24
created tests for short URL
KolbyRKunz Jun 22, 2022
2316bb5
unit tests for shortenedUrls created and passing
KolbyRKunz Jun 24, 2022
6e63951
merged main
KolbyRKunz Jun 24, 2022
fe98b9a
added awaits that were removed to restore failing tests
KolbyRKunz Jun 27, 2022
2a1f496
Merge branch 'main' into feature/shortUrl
KolbyRKunz Jun 29, 2022
b62bf77
Created tests for the transform function
KolbyRKunz Jun 29, 2022
d7e3522
Merge branch 'main' into feature/shortUrl
KolbyRKunz Jul 5, 2022
6fb3672
added support for proper 302 redirects
KolbyRKunz Jul 7, 2022
9a051ec
created new method head to avoid breaking change and reverted awaits
KolbyRKunz Jul 8, 2022
4150f70
Merge branch 'main' into feature/shortUrl
KolbyRKunz Jul 8, 2022
048073c
Url shortening requested chagnes
KolbyRKunz Jul 11, 2022
54e6a80
update for check types
KolbyRKunz Jul 11, 2022
692ebdf
added access to short url parsing in the out of band module, also upd…
KolbyRKunz Jul 13, 2022
3489e11
spelling
KolbyRKunz Jul 13, 2022
26d38c8
updated connectionInvitationMessage throw tag
KolbyRKunz Jul 14, 2022
c9dcac8
Merge branch 'main' into feature/shortUrl
KolbyRKunz Jul 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"web-did-resolver": "^2.0.8"
},
"devDependencies": {
"node-fetch": "^2.0",
"@types/bn.js": "^5.1.0",
"@types/events": "^3.0.0",
"@types/luxon": "^1.27.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,18 @@ export class ConnectionInvitationMessage extends AgentMessage {
*
* @param invitationUrl invitation url containing c_i or d_m parameter
*
* @throws Error when url can not be decoded to JSON, or decoded message is not a valid `ConnectionInvitationMessage`
* @throws Error when the url does not contain c_i or d_m as parameter
* @throws Error when the url is invalid encoded url or shortened url is invalid
KolbyRKunz marked this conversation as resolved.
Show resolved Hide resolved
KolbyRKunz marked this conversation as resolved.
Show resolved Hide resolved
*/
public static fromUrl(invitationUrl: string) {
const parsedUrl = parseUrl(invitationUrl).query
const encodedInvitation = parsedUrl['c_i'] ?? parsedUrl['d_m']

if (typeof encodedInvitation === 'string') {
const invitationJson = JsonEncoder.fromBase64(encodedInvitation)
const invitation = JsonTransformer.fromJSON(invitationJson, ConnectionInvitationMessage)

return invitation
} else {
throw new AriesFrameworkError(
'InvitationUrl is invalid. It needs to contain one, and only one, of the following parameters; `c_i` or `d_m`'
)
throw new AriesFrameworkError('InvitationUrl is invalid. Needs to be encoded with either c_i, d_m, or oob')
}
}
}
Expand Down
18 changes: 15 additions & 3 deletions packages/core/src/modules/oob/OutOfBandModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { injectable, module } from '../../plugins'
import { DidCommMessageRepository, DidCommMessageRole } from '../../storage'
import { JsonEncoder, JsonTransformer } from '../../utils'
import { parseMessageType, supportsIncomingMessageType } from '../../utils/messageType'
import { parseInvitationUrl } from '../../utils/parseInvitation'
import { parseInvitationUrl, parseInvitationShortUrl } from '../../utils/parseInvitation'
import { DidKey } from '../dids'
import { didKeyToVerkey } from '../dids/helpers'
import { outOfBandServiceToNumAlgo2Did } from '../dids/methods/peer/peerDidNumAlgo2'
Expand Down Expand Up @@ -271,8 +271,8 @@ export class OutOfBandModule {
* @param config configuration of how out-of-band invitation should be processed
* @returns out-of-band record and connection record if one has been created
*/
public receiveInvitationFromUrl(invitationUrl: string, config: ReceiveOutOfBandInvitationConfig = {}) {
const message = this.parseInvitation(invitationUrl)
public async receiveInvitationFromUrl(invitationUrl: string, config: ReceiveOutOfBandInvitationConfig = {}) {
const message = await this.parseInvitationShortUrl(invitationUrl)
return this.receiveInvitation(message, config)
}

Expand All @@ -287,6 +287,18 @@ export class OutOfBandModule {
return parseInvitationUrl(invitationUrl)
}

/**
* Parses URL containing encoded invitation and returns invitation message. Compatible with
* parsing shortened URLs
*
* @param invitationUrl URL containing encoded invitation
*
* @returns OutOfBandInvitation
*/
public async parseInvitationShortUrl(invitation: string): Promise<OutOfBandInvitation> {
return await parseInvitationShortUrl(invitation, this.agentConfig.agentDependencies)
}

/**
* Creates inbound out-of-band record and assigns out-of-band invitation message to it if the
* message is valid. It automatically passes out-of-band invitation for further processing to
Expand Down
Loading