diff options
Diffstat (limited to 'src/webex')
-rw-r--r-- | src/webex/messages.ts | 16 | ||||
-rw-r--r-- | src/webex/wxApi.ts | 28 | ||||
-rw-r--r-- | src/webex/wxBackend.ts | 99 |
3 files changed, 0 insertions, 143 deletions
diff --git a/src/webex/messages.ts b/src/webex/messages.ts index f1046d5c7..7b3041ac2 100644 --- a/src/webex/messages.ts +++ b/src/webex/messages.ts @@ -73,10 +73,6 @@ export interface MessageMap { request: { proposalId: number }; response: walletTypes.CheckPayResult; }; - "query-payment": { - request: {}; - response: dbTypes.PurchaseRecord; - }; "exchange-info": { request: { baseUrl: string }; response: dbTypes.ExchangeRecord; @@ -97,10 +93,6 @@ export interface MessageMap { request: {}; response: walletTypes.HistoryRecord[]; }; - "get-proposal": { - request: { proposalId: number }; - response: dbTypes.ProposalDownloadRecord | undefined; - }; "get-coins": { request: { exchangeBaseUrl: string }; response: any; @@ -169,10 +161,6 @@ export interface MessageMap { request: { contractTermsHash: string }; response: dbTypes.PurchaseRecord; }; - "get-full-refund-fees": { - request: { refundPermissions: talerTypes.MerchantRefundPermission[] }; - response: AmountJson; - }; "accept-tip": { request: { talerTipUri: string }; response: void; @@ -185,10 +173,6 @@ export interface MessageMap { request: {}; response: void; }; - "taler-pay": { - request: any; - response: void; - }; "download-proposal": { request: { url: string }; response: number; diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts index fd01aed3f..d2e8c94f1 100644 --- a/src/webex/wxApi.ts +++ b/src/webex/wxApi.ts @@ -216,13 +216,6 @@ export function payback(coinPub: string): Promise<void> { } /** - * Get a proposal stored in the wallet by its proposal id. - */ -export function getProposal(proposalId: number): Promise<ProposalDownloadRecord | undefined> { - return callBackend("get-proposal", { proposalId }); -} - -/** * Check if payment is possible or already done. */ export function checkPay(proposalId: number): Promise<CheckPayResult> { @@ -258,13 +251,6 @@ export function confirmReserve(reservePub: string): Promise<void> { } /** - * Query for a payment by fulfillment URL. - */ -export function queryPaymentByFulfillmentUrl(url: string): Promise<PurchaseRecord> { - return callBackend("query-payment", { url }); -} - -/** * Check upgrade information */ export function checkUpgrade(): Promise<UpgradeResponse> { @@ -336,14 +322,6 @@ export function getPurchase(contractTermsHash: string): Promise<PurchaseRecord> return callBackend("get-purchase", { contractTermsHash }); } -/** - * Get the refund fees for a refund permission, including - * subsequent refresh and unrefreshable coins. - */ -export function getFullRefundFees(args: { refundPermissions: MerchantRefundPermission[] }): Promise<AmountJson> { - return callBackend("get-full-refund-fees", { refundPermissions: args.refundPermissions }); -} - /** * Get the status of processing a tip. @@ -367,12 +345,6 @@ export function clearNotification(): Promise<void> { return callBackend("clear-notification", { }); } -/** - * Trigger taler payment processing (for payment, tipping and refunds). - */ -export function talerPay(msg: any): Promise<void> { - return callBackend("taler-pay", msg); -} /** * Download a contract. diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts index 70a7557e3..570a37586 100644 --- a/src/webex/wxBackend.ts +++ b/src/webex/wxBackend.ts @@ -139,21 +139,6 @@ function handleMessage( } return needsWallet().checkPay(detail.proposalId); } - case "query-payment": { - if (sender.tab && sender.tab.id) { - rateLimitCache[sender.tab.id]++; - if (rateLimitCache[sender.tab.id] > 10) { - console.warn("rate limit for query-payment exceeded"); - const msg = { - error: "rate limit exceeded for query-payment", - hint: "Check for redirect loops", - rateLimitExceeded: true, - }; - return Promise.resolve(msg); - } - } - return needsWallet().queryPaymentByFulfillmentUrl(detail.url); - } case "exchange-info": { if (!detail.baseUrl) { return Promise.resolve({ error: "bad url" }); @@ -187,9 +172,6 @@ function handleMessage( // TODO: limit history length return needsWallet().getHistory(); } - case "get-proposal": { - return needsWallet().getProposal(detail.proposalId); - } case "get-exchanges": { return needsWallet().getExchanges(); } @@ -289,8 +271,6 @@ function handleMessage( } return needsWallet().getPurchase(contractTermsHash); } - case "get-full-refund-fees": - return needsWallet().getFullRefundFees(detail.refundPermissions); case "accept-refund": return needsWallet().applyRefund(detail.refundUrl); case "get-tip-status": { @@ -311,25 +291,6 @@ function handleMessage( } return needsWallet().abortFailedPayment(detail.contractTermsHash); } - case "taler-pay": { - const senderUrl = sender.url; - if (!senderUrl) { - console.log("can't trigger payment, no sender URL"); - return; - } - const tab = sender.tab; - if (!tab) { - console.log("can't trigger payment, no sender tab"); - return; - } - const tabId = tab.id; - if (typeof tabId !== "string") { - console.log("can't trigger payment, no sender tab id"); - return; - } - talerPay(detail, senderUrl, tabId); - return; - } case "benchmark-crypto": { if (!detail.repetitions) { throw Error("repetitions not given"); @@ -418,66 +379,6 @@ class ChromeNotifier implements Notifier { } } -async function talerPay( - fields: any, - url: string, - tabId: number, -): Promise<string | undefined> { - if (!currentWallet) { - console.log("can't handle payment, no wallet"); - return undefined; - } - - const w = currentWallet; - - const goToPayment = (p: PurchaseRecord): string => { - const nextUrl = new URI(p.contractTerms.fulfillment_url); - nextUrl.addSearch("order_id", p.contractTerms.order_id); - if (p.lastSessionSig) { - nextUrl.addSearch("session_sig", p.lastSessionSig); - } - return nextUrl.href(); - }; - - if (fields.resource_url) { - const p = await w.queryPaymentByFulfillmentUrl(fields.resource_url); - console.log("query for resource url", fields.resource_url, "result", p); - if ( - p && - (fields.session_id === undefined || fields.session_id === p.lastSessionId) - ) { - return goToPayment(p); - } - } - if (fields.contract_url) { - const proposalId = await w.downloadProposal(fields.contract_url); - const uri = new URI( - chrome.extension.getURL("/src/webex/pages/confirm-contract.html"), - ); - if (fields.session_id) { - uri.addSearch("sessionId", fields.session_id); - } - uri.addSearch("proposalId", proposalId); - const redirectUrl = uri.href(); - return redirectUrl; - } - if (fields.offer_url) { - return fields.offer_url; - } - if (fields.refund_url) { - console.log("processing refund"); - const uri = new URI( - chrome.extension.getURL("/src/webex/pages/refund.html"), - ); - return uri.query({ refundUrl: fields.refund_url }).href(); - } - if (fields.tip) { - const uri = new URI(chrome.extension.getURL("/src/webex/pages/tip.html")); - return uri.query({ tip_token: fields.tip }).href(); - } - return undefined; -} - function getTab(tabId: number): Promise<chrome.tabs.Tab> { return new Promise((resolve, reject) => { chrome.tabs.get(tabId, (tab: chrome.tabs.Tab) => resolve(tab)); |