diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-20 03:09:25 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-24 16:14:29 +0200 |
commit | 82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch) | |
tree | 965f6eb89b84d65a62b49008fd972c004832ccd1 /src/content_scripts/notify.ts | |
parent | e6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff) | |
download | wallet-core-82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8.tar.xz |
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules
into one file (plus commons chunks) for every entry point. This results
in a much smaller extension size (almost half). Furthermore we use
yarn/npm even for extension run-time dependencies. This relieves us
from manually vendoring and building dependencies. It's also easier to
understand for new developers familiar with node.
Diffstat (limited to 'src/content_scripts/notify.ts')
-rw-r--r-- | src/content_scripts/notify.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/content_scripts/notify.ts b/src/content_scripts/notify.ts index bf91b79c9..8a25dd500 100644 --- a/src/content_scripts/notify.ts +++ b/src/content_scripts/notify.ts @@ -25,6 +25,8 @@ "use strict"; +import URI = require("urijs"); + declare var cloneInto: any; // Make sure we don't pollute the namespace too much. @@ -65,7 +67,7 @@ namespace TalerNotify { type: "hash-contract", detail: {contract} }; - return new Promise((resolve, reject) => { + return new Promise<string>((resolve, reject) => { chrome.runtime.sendMessage(walletHashContractMsg, (resp: any) => { if (!resp.hash) { console.log("error", resp); @@ -95,7 +97,7 @@ namespace TalerNotify { historyEntry, }, }; - return new Promise((resolve, reject) => { + return new Promise<void>((resolve, reject) => { chrome.runtime.sendMessage(walletMsg, (resp: any) => { resolve(); }); @@ -114,7 +116,7 @@ namespace TalerNotify { }, }, }; - return new Promise((resolve, reject) => { + return new Promise<number>((resolve, reject) => { chrome.runtime.sendMessage(walletMsg, (resp: any) => { if (resp && resp.error) { reject(resp); @@ -162,7 +164,7 @@ namespace TalerNotify { const walletMsg = { type: "generate-nonce", }; - return new Promise((resolve, reject) => { + return new Promise<string>((resolve, reject) => { chrome.runtime.sendMessage(walletMsg, (resp: any) => { resolve(resp); }); @@ -170,7 +172,7 @@ namespace TalerNotify { } function downloadContract(url: string, nonce: string): Promise<any> { - let parsed_url = URI(url); + let parsed_url = new URI(url); url = parsed_url.setQuery({nonce}).href(); // FIXME: include and check nonce! return new Promise((resolve, reject) => { @@ -243,7 +245,7 @@ namespace TalerNotify { await putHistory(historyEntry); let offerId = await saveOffer(proposal); - const uri = URI(chrome.extension.getURL( + const uri = new URI(chrome.extension.getURL( "/src/pages/confirm-contract.html")); const params = { offerId: offerId.toString(), @@ -294,13 +296,13 @@ namespace TalerNotify { addHandler("taler-create-reserve", (msg: any) => { let params = { amount: JSON.stringify(msg.amount), - callback_url: URI(msg.callback_url) + callback_url: new URI(msg.callback_url) .absoluteTo(document.location.href), bank_url: document.location.href, wt_types: JSON.stringify(msg.wt_types), suggested_exchange_url: msg.suggested_exchange_url, }; - let uri = URI(chrome.extension.getURL("/src/pages/confirm-create-reserve.html")); + let uri = new URI(chrome.extension.getURL("/src/pages/confirm-create-reserve.html")); let redirectUrl = uri.query(params).href(); window.location.href = redirectUrl; }); @@ -309,7 +311,7 @@ namespace TalerNotify { let params = { req: JSON.stringify(msg), }; - let uri = URI(chrome.extension.getURL("/src/pages/add-auditor.html")); + let uri = new URI(chrome.extension.getURL("/src/pages/add-auditor.html")); let redirectUrl = uri.query(params).href(); window.location.href = redirectUrl; }); @@ -340,7 +342,7 @@ namespace TalerNotify { addHandler("taler-pay", async(msg: any, sendResponse: any) => { // current URL without fragment - let url = URI(document.location.href).fragment("").href(); + let url = new URI(document.location.href).fragment("").href(); let res = await queryPayment(url); logVerbose && console.log("taler-pay: got response", res); if (res && res.payReq) { |