diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-12-06 12:47:28 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-12-06 12:47:28 +0100 |
commit | ee1fc03ae82f2f4662041af3d4243113e92ffeaf (patch) | |
tree | b01ab0adf1b2d551db3a4f4ee89b41379d945a54 /src/wallet-impl | |
parent | b4d36fca180602d6d90440f9ba257b92fc626e6c (diff) |
case-insensitive URIs
Diffstat (limited to 'src/wallet-impl')
-rw-r--r-- | src/wallet-impl/pay.ts | 23 | ||||
-rw-r--r-- | src/wallet-impl/pending.ts | 3 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/wallet-impl/pay.ts b/src/wallet-impl/pay.ts index 4933098cd..7076f905d 100644 --- a/src/wallet-impl/pay.ts +++ b/src/wallet-impl/pay.ts @@ -65,7 +65,7 @@ import { } from "../util/helpers"; import { Logger } from "../util/logging"; import { InternalWalletState } from "./state"; -import { parsePayUri, parseRefundUri } from "../util/taleruri"; +import { parsePayUri, parseRefundUri, getOrderDownloadUrl } from "../util/taleruri"; import { getTotalRefreshCost, refresh } from "./refresh"; import { encodeCrock, getRandomBytes } from "../crypto/talerCrypto"; import { guardOperationException } from "./errors"; @@ -557,9 +557,10 @@ async function processDownloadProposalImpl( if (proposal.proposalStatus != ProposalStatus.DOWNLOADING) { return; } - const parsed_url = new URL(proposal.url); - parsed_url.searchParams.set("nonce", proposal.noncePub); - const urlWithNonce = parsed_url.href; + + const parsedUrl = new URL(getOrderDownloadUrl(proposal.merchantBaseUrl, proposal.orderId)); + parsedUrl.searchParams.set("nonce", proposal.noncePub); + const urlWithNonce = parsedUrl.href; console.log("downloading contract from '" + urlWithNonce + "'"); let resp; try { @@ -629,13 +630,14 @@ async function processDownloadProposalImpl( */ async function startDownloadProposal( ws: InternalWalletState, - url: string, + merchantBaseUrl: string, + orderId: string, sessionId?: string, ): Promise<string> { const oldProposal = await oneShotGetIndexed( ws.db, - Stores.proposals.urlIndex, - url, + Stores.proposals.urlAndOrderIdIndex, + [merchantBaseUrl, orderId], ); if (oldProposal) { await processDownloadProposal(ws, oldProposal.proposalId); @@ -650,8 +652,8 @@ async function startDownloadProposal( noncePriv: priv, noncePub: pub, timestamp: getTimestampNow(), - url, - downloadSessionId: sessionId, + merchantBaseUrl, + orderId, proposalId: proposalId, proposalStatus: ProposalStatus.DOWNLOADING, repurchaseProposalId: undefined, @@ -763,7 +765,8 @@ export async function preparePay( let proposalId = await startDownloadProposal( ws, - uriResult.downloadUrl, + uriResult.merchantBaseUrl, + uriResult.orderId, uriResult.sessionId, ); diff --git a/src/wallet-impl/pending.ts b/src/wallet-impl/pending.ts index 02f8d9ef9..5fb9ef5ce 100644 --- a/src/wallet-impl/pending.ts +++ b/src/wallet-impl/pending.ts @@ -312,7 +312,8 @@ async function gatherProposalPending( resp.pendingOperations.push({ type: "proposal-download", givesLifeness: true, - merchantBaseUrl: proposal.download?.contractTerms.merchant_base_url || "", + merchantBaseUrl: proposal.merchantBaseUrl, + orderId: proposal.orderId, proposalId: proposal.proposalId, proposalTimestamp: proposal.timestamp, lastError: proposal.lastError, |