@growth-labs/cms 0.5.30 → 0.5.31
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/dist/engine/foundry-dispatch.d.ts +7 -2
- package/dist/engine/foundry-dispatch.d.ts.map +1 -1
- package/dist/engine/foundry-dispatch.js +24 -6
- package/dist/engine/foundry-dispatch.js.map +1 -1
- package/dist/engine/fronts-publish-intent.d.ts +174 -0
- package/dist/engine/fronts-publish-intent.d.ts.map +1 -0
- package/dist/engine/fronts-publish-intent.js +352 -0
- package/dist/engine/fronts-publish-intent.js.map +1 -0
- package/dist/engine/fronts-publish.d.ts +80 -0
- package/dist/engine/fronts-publish.d.ts.map +1 -0
- package/dist/engine/fronts-publish.js +286 -0
- package/dist/engine/fronts-publish.js.map +1 -0
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +5 -0
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/publisher.d.ts.map +1 -1
- package/dist/engine/publisher.js +21 -1
- package/dist/engine/publisher.js.map +1 -1
- package/dist/integration/index.d.ts.map +1 -1
- package/dist/integration/index.js +10 -0
- package/dist/integration/index.js.map +1 -1
- package/dist/routes/fronts-publish.d.ts +10 -0
- package/dist/routes/fronts-publish.d.ts.map +1 -0
- package/dist/routes/fronts-publish.js +250 -0
- package/dist/routes/fronts-publish.js.map +1 -0
- package/dist/routes/index.d.ts +3 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +4 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/schema/layout.d.ts +2 -2
- package/dist/schema/migrations.d.ts.map +1 -1
- package/dist/schema/migrations.js +36 -0
- package/dist/schema/migrations.js.map +1 -1
- package/dist/schema/portable-text.d.ts +2 -2
- package/dist/schema/tables.d.ts +1 -1
- package/dist/schema/tables.d.ts.map +1 -1
- package/dist/schema/tables.js +2 -0
- package/dist/schema/tables.js.map +1 -1
- package/dist/schema/types.d.ts +59 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js.map +1 -1
- package/dist/surveys/schema.d.ts +54 -54
- package/dist/ui/api/fronts/publish-callback.d.ts +3 -0
- package/dist/ui/api/fronts/publish-callback.d.ts.map +1 -0
- package/dist/ui/api/fronts/publish-callback.js +8 -0
- package/dist/ui/api/fronts/publish-callback.js.map +1 -0
- package/dist/ui/api/fronts/schedule.d.ts +3 -0
- package/dist/ui/api/fronts/schedule.d.ts.map +1 -0
- package/dist/ui/api/fronts/schedule.js +8 -0
- package/dist/ui/api/fronts/schedule.js.map +1 -0
- package/migrations/0026_fronts_publish.sql +31 -0
- package/migrations/0027_fronts_publish_intent.sql +44 -0
- package/package.json +1 -1
- package/src/engine/foundry-dispatch.ts +22 -6
- package/src/engine/fronts-publish-intent.ts +676 -0
- package/src/engine/fronts-publish.ts +417 -0
- package/src/engine/index.ts +27 -0
- package/src/engine/publisher.ts +21 -1
- package/src/integration/index.ts +10 -0
- package/src/routes/fronts-publish.ts +292 -0
- package/src/routes/index.ts +8 -0
- package/src/schema/migrations.ts +36 -0
- package/src/schema/tables.ts +2 -0
- package/src/schema/types.ts +61 -0
- package/src/ui/api/fronts/publish-callback.ts +18 -0
- package/src/ui/api/fronts/schedule.ts +18 -0
|
@@ -400,8 +400,13 @@ export async function applyFoundryCallback(db: D1Database, input: CallbackInput)
|
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
402
|
* Verify a HMAC-SHA256 signature over `rawBody` using `secret`.
|
|
403
|
-
*
|
|
404
|
-
*
|
|
403
|
+
*
|
|
404
|
+
* The `signature` is a hex string, with or without a `sha256=` scheme prefix.
|
|
405
|
+
* Foundry (and the GitHub-webhook convention it mirrors) sends
|
|
406
|
+
* `X-Foundry-Signature: sha256=<hex>`; the prefix MUST be stripped before the
|
|
407
|
+
* hex parse or every prefixed signature fails to decode and the callback 401s.
|
|
408
|
+
* Comparison is case-insensitive on the hex and constant-time on the bytes.
|
|
409
|
+
* Uses Web Crypto `crypto.subtle`.
|
|
405
410
|
*/
|
|
406
411
|
export async function verifyHmac(
|
|
407
412
|
secret: string,
|
|
@@ -410,13 +415,24 @@ export async function verifyHmac(
|
|
|
410
415
|
): Promise<boolean> {
|
|
411
416
|
if (!signature) return false
|
|
412
417
|
|
|
418
|
+
// Strip the optional `sha256=` scheme prefix (case-insensitive) and any
|
|
419
|
+
// surrounding whitespace before decoding the hex digest.
|
|
420
|
+
let hex = signature.trim()
|
|
421
|
+
if (/^sha256=/i.test(hex)) hex = hex.slice('sha256='.length).trim()
|
|
422
|
+
if (!hex) return false
|
|
423
|
+
// Reject non-hex up front: `Number.parseInt('1z', 16)` returns 1 (parses the
|
|
424
|
+
// leading nibble and stops), so malformed hex would otherwise decode to a
|
|
425
|
+
// truncated-but-valid byte string. The constant-time compare still guards
|
|
426
|
+
// forgery, but a strict charset check keeps the decode honest.
|
|
427
|
+
if (!/^[0-9a-f]+$/i.test(hex)) return false
|
|
428
|
+
|
|
413
429
|
let sigBytes: Uint8Array
|
|
414
430
|
try {
|
|
415
431
|
// Parse the hex signature
|
|
416
|
-
if (
|
|
417
|
-
sigBytes = new Uint8Array(
|
|
418
|
-
for (let i = 0; i <
|
|
419
|
-
const byte = Number.parseInt(
|
|
432
|
+
if (hex.length % 2 !== 0) return false
|
|
433
|
+
sigBytes = new Uint8Array(hex.length / 2)
|
|
434
|
+
for (let i = 0; i < hex.length; i += 2) {
|
|
435
|
+
const byte = Number.parseInt(hex.slice(i, i + 2), 16)
|
|
420
436
|
if (Number.isNaN(byte)) return false
|
|
421
437
|
sigBytes[i / 2] = byte
|
|
422
438
|
}
|