diff options
author | Sebastian <sebasjm@gmail.com> | 2024-06-14 11:15:04 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-06-14 11:15:04 -0300 |
commit | 4a09a67df3721b27bbbb659032eb441c84836d44 (patch) | |
tree | 96468c50727d30648ea17b443fa4d8472bd5d0a9 /packages/taler-util/src | |
parent | 8e29a3c33119293808a7611c9dc7dcf9b98eb4ca (diff) | |
download | wallet-core-4a09a67df3721b27bbbb659032eb441c84836d44.tar.xz |
hash payto
Diffstat (limited to 'packages/taler-util/src')
-rw-r--r-- | packages/taler-util/src/payto.ts | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/taler-util/src/payto.ts b/packages/taler-util/src/payto.ts index ff33519c5..1d13fb502 100644 --- a/packages/taler-util/src/payto.ts +++ b/packages/taler-util/src/payto.ts @@ -23,7 +23,7 @@ import { codecForStringURL, renderContext, } from "./codec.js"; -import { AccessToken, codecForAccessToken, codecOptional } from "./index.js"; +import { AccessToken, bytesToString, codecForAccessToken, codecOptional, hashTruncate32, stringToBytes } from "./index.js"; import { URLSearchParams } from "./url.js"; export type PaytoUri = @@ -201,6 +201,11 @@ export function stringifyPaytoUri(p: PaytoUri): PaytoString { return url.href as PaytoString; } +export function hashPaytoUri(p: PaytoUri): string { + const paytoUri = stringifyPaytoUri(p) + return bytesToString(hashTruncate32(stringToBytes(paytoUri + "\0"))); +} + /** * Parse a valid payto:// uri into a PaytoUri object * RFC 8905 |