Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
refactor: support ?d_m invitations
Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
  • Loading branch information
sairanjit committed Sep 13, 2021
commit a2055f2180e5fd9c1dcfc87be7978e4f2fd08f1e
6 changes: 2 additions & 4 deletions src/network/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ export const NetworkServices: Function = async (url: string, apiType: string, ap
export const OutboundAgentMessage: Function = async (url: string, apiType: string, apiBody: string) => {
try {
console.log("url", url)
console.log("apiBody", apiBody)
const abortController = new AbortController()
const id = setTimeout(() => abortController.abort(), 15000)
const id = setTimeout(() => abortController.abort(), 4000)
const response = await fetch(url, {
method: 'POST',
body: apiBody,
Expand All @@ -40,10 +39,9 @@ export const OutboundAgentMessage: Function = async (url: string, apiType: strin
clearTimeout(id)
const responseMessage = await response.text()
if (responseMessage) {
console.log(`Response received`, { responseMessage, status: response.status })
console.log(`Response received`)
try {
const wireMessage = JSON.parse(responseMessage)
console.log(`Response received`, wireMessage)
if (wireMessage.hasOwnProperty('tag')) {
await InboundMessageService.addMessages(wireMessage)
}
Expand Down
1 change: 0 additions & 1 deletion src/transports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ class InboundMessageHandler {
}

const connection = await WalletStorageService.getWalletRecordFromQuery(JSON.parse(this.wallet.walletConfig), JSON.parse(this.wallet.walletCredentials), RecordType.Connection, JSON.stringify(query));
console.log('connection', typeof connection)
if (connection.length === 0 || connection.verkey === '') {
console.log('Connection not found')
await WalletStorageService.deleteWalletRecord(JSON.parse(this.wallet.walletConfig), JSON.parse(this.wallet.walletCredentials), RecordType.SSIMessage, unprocessedMessages[i].id);
Expand Down
9 changes: 7 additions & 2 deletions src/utils/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ export function getServiceEndpoint() {
}

export function decodeInvitationFromUrl(invitationUrl: string) {
const [, encodedInvitation] = invitationUrl.split('c_i=');
return JSON.parse(Buffer.from(encodedInvitation, 'base64').toString());
if (invitationUrl.includes("?c_i=")) {
const [, encodedInvitation] = invitationUrl.split('c_i=');
return JSON.parse(Buffer.from(encodedInvitation, 'base64').toString());
} else if (invitationUrl.includes("?d_m=")) {
const [encodedInvitation] = invitationUrl.split('=')[1].split('%');
return JSON.parse(Buffer.from(encodedInvitation, 'base64').toString());
}
}

export function encodeInvitationToUrl(invitation: InvitationDetails): string {
Expand Down