@tokenoftrust/storefront-runner 2.4.62 → 2.4.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.63",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -424,6 +424,18 @@ async function hmacHex(secret: string, message: string): Promise<string> {
|
|
|
424
424
|
.join("");
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
function constantTimeHexEqual(expected: string, presented: string): boolean {
|
|
428
|
+
const enc = new TextEncoder();
|
|
429
|
+
const left = enc.encode(expected);
|
|
430
|
+
const right = enc.encode(presented);
|
|
431
|
+
const length = Math.max(left.length, right.length);
|
|
432
|
+
let acc = left.length ^ right.length;
|
|
433
|
+
for (let i = 0; i < length; i++) {
|
|
434
|
+
acc |= (left[i] ?? 0) ^ (right[i] ?? 0);
|
|
435
|
+
}
|
|
436
|
+
return acc === 0;
|
|
437
|
+
}
|
|
438
|
+
|
|
427
439
|
/**
|
|
428
440
|
* Sign one field for product `code`. Editable fields hash the sentinel
|
|
429
441
|
* `--OPEN--` and gain the `||open` suffix so checkout accepts a user-entered value.
|
|
@@ -596,7 +608,7 @@ export async function enforceCartSubmission(input: {
|
|
|
596
608
|
if (!field.hash) return false;
|
|
597
609
|
const valueToHash = field.open ? "--OPEN--" : field.value;
|
|
598
610
|
const expected = await hmacHex(secret, codeField.value + field.baseName + valueToHash);
|
|
599
|
-
return expected
|
|
611
|
+
return constantTimeHexEqual(expected, field.hash);
|
|
600
612
|
};
|
|
601
613
|
|
|
602
614
|
if (signed) {
|