diff options
Diffstat (limited to 'packages')
-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 |