commit 4a09a67df3721b27bbbb659032eb441c84836d44
parent 8e29a3c33119293808a7611c9dc7dcf9b98eb4ca
Author: Sebastian <sebasjm@gmail.com>
Date: Fri, 14 Jun 2024 11:15:04 -0300
hash payto
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git 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