@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.
Files changed (67) hide show
  1. package/dist/engine/foundry-dispatch.d.ts +7 -2
  2. package/dist/engine/foundry-dispatch.d.ts.map +1 -1
  3. package/dist/engine/foundry-dispatch.js +24 -6
  4. package/dist/engine/foundry-dispatch.js.map +1 -1
  5. package/dist/engine/fronts-publish-intent.d.ts +174 -0
  6. package/dist/engine/fronts-publish-intent.d.ts.map +1 -0
  7. package/dist/engine/fronts-publish-intent.js +352 -0
  8. package/dist/engine/fronts-publish-intent.js.map +1 -0
  9. package/dist/engine/fronts-publish.d.ts +80 -0
  10. package/dist/engine/fronts-publish.d.ts.map +1 -0
  11. package/dist/engine/fronts-publish.js +286 -0
  12. package/dist/engine/fronts-publish.js.map +1 -0
  13. package/dist/engine/index.d.ts +2 -0
  14. package/dist/engine/index.d.ts.map +1 -1
  15. package/dist/engine/index.js +5 -0
  16. package/dist/engine/index.js.map +1 -1
  17. package/dist/engine/publisher.d.ts.map +1 -1
  18. package/dist/engine/publisher.js +21 -1
  19. package/dist/engine/publisher.js.map +1 -1
  20. package/dist/integration/index.d.ts.map +1 -1
  21. package/dist/integration/index.js +10 -0
  22. package/dist/integration/index.js.map +1 -1
  23. package/dist/routes/fronts-publish.d.ts +10 -0
  24. package/dist/routes/fronts-publish.d.ts.map +1 -0
  25. package/dist/routes/fronts-publish.js +250 -0
  26. package/dist/routes/fronts-publish.js.map +1 -0
  27. package/dist/routes/index.d.ts +3 -0
  28. package/dist/routes/index.d.ts.map +1 -1
  29. package/dist/routes/index.js +4 -0
  30. package/dist/routes/index.js.map +1 -1
  31. package/dist/schema/layout.d.ts +2 -2
  32. package/dist/schema/migrations.d.ts.map +1 -1
  33. package/dist/schema/migrations.js +36 -0
  34. package/dist/schema/migrations.js.map +1 -1
  35. package/dist/schema/portable-text.d.ts +2 -2
  36. package/dist/schema/tables.d.ts +1 -1
  37. package/dist/schema/tables.d.ts.map +1 -1
  38. package/dist/schema/tables.js +2 -0
  39. package/dist/schema/tables.js.map +1 -1
  40. package/dist/schema/types.d.ts +59 -0
  41. package/dist/schema/types.d.ts.map +1 -1
  42. package/dist/schema/types.js.map +1 -1
  43. package/dist/surveys/schema.d.ts +54 -54
  44. package/dist/ui/api/fronts/publish-callback.d.ts +3 -0
  45. package/dist/ui/api/fronts/publish-callback.d.ts.map +1 -0
  46. package/dist/ui/api/fronts/publish-callback.js +8 -0
  47. package/dist/ui/api/fronts/publish-callback.js.map +1 -0
  48. package/dist/ui/api/fronts/schedule.d.ts +3 -0
  49. package/dist/ui/api/fronts/schedule.d.ts.map +1 -0
  50. package/dist/ui/api/fronts/schedule.js +8 -0
  51. package/dist/ui/api/fronts/schedule.js.map +1 -0
  52. package/migrations/0026_fronts_publish.sql +31 -0
  53. package/migrations/0027_fronts_publish_intent.sql +44 -0
  54. package/package.json +1 -1
  55. package/src/engine/foundry-dispatch.ts +22 -6
  56. package/src/engine/fronts-publish-intent.ts +676 -0
  57. package/src/engine/fronts-publish.ts +417 -0
  58. package/src/engine/index.ts +27 -0
  59. package/src/engine/publisher.ts +21 -1
  60. package/src/integration/index.ts +10 -0
  61. package/src/routes/fronts-publish.ts +292 -0
  62. package/src/routes/index.ts +8 -0
  63. package/src/schema/migrations.ts +36 -0
  64. package/src/schema/tables.ts +2 -0
  65. package/src/schema/types.ts +61 -0
  66. package/src/ui/api/fronts/publish-callback.ts +18 -0
  67. 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
- * The `signature` is expected as a lowercase hex string.
404
- * Uses Web Crypto `crypto.subtle` and a constant-time comparison.
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 (signature.length % 2 !== 0) return false
417
- sigBytes = new Uint8Array(signature.length / 2)
418
- for (let i = 0; i < signature.length; i += 2) {
419
- const byte = Number.parseInt(signature.slice(i, i + 2), 16)
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
  }