diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-03-16 18:23:35 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-03-16 18:23:35 +0100 |
commit | d7e013594d15388b1a7342a44a0e9c8d4ecca82d (patch) | |
tree | 499bcf433ad800f1da959adbd5b4722039832568 | |
parent | 6dd8ca1675817cc0ca65f0819489234eeafaa2ed (diff) | |
download | web-common-d7e013594d15388b1a7342a44a0e9c8d4ecca82d.tar.gz web-common-d7e013594d15388b1a7342a44a0e9c8d4ecca82d.tar.bz2 web-common-d7e013594d15388b1a7342a44a0e9c8d4ecca82d.zip |
auditor calls
-rw-r--r-- | taler-wallet-lib.js | 40 | ||||
-rw-r--r-- | taler-wallet-lib.ts | 51 | ||||
-rw-r--r-- | tsconfig.json | 3 |
3 files changed, 93 insertions, 1 deletions
diff --git a/taler-wallet-lib.js b/taler-wallet-lib.js index b7d1262..b160918 100644 --- a/taler-wallet-lib.js +++ b/taler-wallet-lib.js @@ -226,6 +226,46 @@ var taler; internalPay(p); } taler.pay = pay; + function internalAddAuditor(d) { + // either the callback gets called, + // or the wallet will redirect the browser + callWallet("taler-add-auditor", d); + } + taler.internalAddAuditor = internalAddAuditor; + function addAuditor(d) { + if (!installed) { + logVerbose && console.log("delaying call to 'addAuditor' until GNU Taler wallet is present"); + taler.onPresent(function () { + addAuditor(d); + }); + return; + } + internalAddAuditor(d); + } + taler.addAuditor = addAuditor; + function internalCheckAuditor(url) { + return new Promise(function (resolve, reject) { + callWallet("taler-check-auditor", url, function (x) { return resolve(x); }); + }); + } + taler.internalCheckAuditor = internalCheckAuditor; + /** + * Check if an auditor is already added to the wallet. + * + * Same-origin restrictions apply. + */ + function checkAuditor(url) { + if (!installed) { + logVerbose && console.log("delaying call to 'checkAuditor' until GNU Taler wallet is present"); + return new Promise(function (resolve, reject) { + taler.onPresent(function () { + resolve(checkAuditor(url)); + }); + }); + } + return internalCheckAuditor(url); + } + taler.checkAuditor = checkAuditor; function initTaler() { function handleUninstall() { installed = false; diff --git a/taler-wallet-lib.ts b/taler-wallet-lib.ts index 6fe3c28..aca5395 100644 --- a/taler-wallet-lib.ts +++ b/taler-wallet-lib.ts @@ -261,6 +261,57 @@ namespace taler { internalPay(p); } + export interface AuditorDetail { + currency: string; + url: string; + auditorPub: string; + expirationStamp: number; + } + + + export function internalAddAuditor(d: AuditorDetail) { + // either the callback gets called, + // or the wallet will redirect the browser + callWallet("taler-add-auditor", d); + } + + + export function addAuditor(d: AuditorDetail) { + if (!installed) { + logVerbose && console.log("delaying call to 'addAuditor' until GNU Taler wallet is present"); + taler.onPresent(() => { + addAuditor(d); + }); + return; + } + internalAddAuditor(d); + } + + + export function internalCheckAuditor(url: string): Promise<AuditorDetail|undefined> { + return new Promise<AuditorDetail|undefined>((resolve, reject) => { + callWallet("taler-check-auditor", url, (x: any) => resolve(x as AuditorDetail)); + }); + } + + + /** + * Check if an auditor is already added to the wallet. + * + * Same-origin restrictions apply. + */ + export function checkAuditor(url: string): Promise<AuditorDetail|undefined> { + if (!installed) { + logVerbose && console.log("delaying call to 'checkAuditor' until GNU Taler wallet is present"); + return new Promise<AuditorDetail|undefined>((resolve, reject) => { + taler.onPresent(() => { + resolve(checkAuditor(url)); + }); + }); + } + return internalCheckAuditor(url); + } + function initTaler() { diff --git a/tsconfig.json b/tsconfig.json index 30712d1..1a14563 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,8 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "strictNullChecks": true, - "noImplicitAny": true + "noImplicitAny": true, + "lib": ["ES6", "DOM"] }, "files": [ "taler-wallet-lib.ts", |