diff options
author | Sebastian <sebasjm@gmail.com> | 2022-10-21 12:12:35 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-10-21 12:12:35 -0300 |
commit | 805e2c4d7cfbc61ca3b0fe43d23ae139be9daeea (patch) | |
tree | 2c47e2a6fe265a8fb3286bc14531b6e6f089d5b5 /packages/taler-util | |
parent | 5ba7956f49675bf961894ad9e6e9f074c2edca07 (diff) | |
download | wallet-core-805e2c4d7cfbc61ca3b0fe43d23ae139be9daeea.tar.xz |
added name into recovery uri
Diffstat (limited to 'packages/taler-util')
-rw-r--r-- | packages/taler-util/src/backup-types.ts | 1 | ||||
-rw-r--r-- | packages/taler-util/src/taleruri.ts | 33 |
2 files changed, 18 insertions, 16 deletions
diff --git a/packages/taler-util/src/backup-types.ts b/packages/taler-util/src/backup-types.ts index b3eb082ea..f44a8ba3f 100644 --- a/packages/taler-util/src/backup-types.ts +++ b/packages/taler-util/src/backup-types.ts @@ -1281,6 +1281,7 @@ export enum BackupProposalStatus { export interface BackupRecovery { walletRootPriv: string; providers: { + name: string; url: string; }[]; } diff --git a/packages/taler-util/src/taleruri.ts b/packages/taler-util/src/taleruri.ts index 45f9a90f2..fb7175e74 100644 --- a/packages/taler-util/src/taleruri.ts +++ b/packages/taler-util/src/taleruri.ts @@ -373,10 +373,13 @@ export function constructPayPullUri(args: { } export function constructRecoveryUri(args: BackupRecovery): string { - const key = args.walletRootPriv - const urls = args.providers.map(p => `p=${canonicalizeBaseUrl(p.url)}`).join("&") + const key = args.walletRootPriv; + //FIXME: name may contain non valid characters + const urls = args.providers + .map((p) => `${p.name}=${canonicalizeBaseUrl(p.url)}`) + .join("&"); - return `taler://recovery/${key}?${urls}` + return `taler://recovery/${key}?${urls}`; } export function parseRecoveryUri(uri: string): BackupRecovery | undefined { const pi = parseProtoInfo(uri, "recovery"); @@ -385,26 +388,24 @@ export function parseRecoveryUri(uri: string): BackupRecovery | undefined { } const idx = pi.rest.indexOf("?"); if (idx === -1) { - return undefined + return undefined; } - const path = pi.rest.slice(0, idx) - const params = pi.rest.slice(idx + 1) + const path = pi.rest.slice(0, idx); + const params = pi.rest.slice(idx + 1); if (!path || !params) { return undefined; } const parts = path.split("/"); const walletRootPriv = parts[0]; - if (!walletRootPriv) return undefined - const providers = new Array<{ url: string }>(); - const args = params.split("&") + if (!walletRootPriv) return undefined; + const providers = new Array<{ name: string; url: string }>(); + const args = params.split("&"); for (const param in args) { - const eq = args[param].indexOf("=") + const eq = args[param].indexOf("="); if (eq === -1) return undefined; - const name = args[param].slice(0, eq) - const value = args[param].slice(eq + 1) - if (name !== "p" || !value) return undefined; - providers.push({ url: value }) + const name = args[param].slice(0, eq); + const url = args[param].slice(eq + 1); + providers.push({ name, url }); } - return { walletRootPriv, providers } + return { walletRootPriv, providers }; } - |