@kya-os/checkpoint-shared 1.6.0 → 1.7.0

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 (83) hide show
  1. package/dist/{browser-posture-DIaVLuW3.d.ts → browser-posture-B8YiPa5c.d.ts} +5 -5
  2. package/dist/{browser-posture-DIaVLuW3.d.ts.map → browser-posture-B8YiPa5c.d.ts.map} +1 -1
  3. package/dist/{browser-posture-BuChqmH5.d.mts → browser-posture-BLhw-MON.d.mts} +5 -5
  4. package/dist/{browser-posture-BuChqmH5.d.mts.map → browser-posture-BLhw-MON.d.mts.map} +1 -1
  5. package/dist/browser-posture-cookie.js +1 -1
  6. package/dist/browser-posture-cookie.mjs +1 -1
  7. package/dist/browser-posture-cookie.mjs.map +1 -1
  8. package/dist/browser-posture-proof.d.mts +1 -1
  9. package/dist/browser-posture-proof.d.mts.map +1 -1
  10. package/dist/browser-posture-proof.d.ts +1 -1
  11. package/dist/browser-posture-proof.d.ts.map +1 -1
  12. package/dist/browser-posture-proof.js +42 -1
  13. package/dist/browser-posture-proof.mjs +42 -1
  14. package/dist/browser-posture-proof.mjs.map +1 -1
  15. package/dist/browser-posture.d.mts +1 -1
  16. package/dist/browser-posture.d.ts +1 -1
  17. package/dist/browser-posture.js +1 -1
  18. package/dist/browser-posture.mjs +1 -1
  19. package/dist/canonical-signer/index.d.mts.map +1 -1
  20. package/dist/canonical-signer/index.d.ts.map +1 -1
  21. package/dist/canonical-signer/index.js +86 -51
  22. package/dist/canonical-signer/index.mjs +86 -51
  23. package/dist/canonical-signer/index.mjs.map +1 -1
  24. package/dist/client-ip-DFamiNoz.d.mts +34 -0
  25. package/dist/client-ip-DFamiNoz.d.mts.map +1 -0
  26. package/dist/client-ip-DFamiNoz.d.ts +34 -0
  27. package/dist/client-ip-DFamiNoz.d.ts.map +1 -0
  28. package/dist/client-ip.d.mts +2 -0
  29. package/dist/client-ip.d.ts +2 -0
  30. package/dist/client-ip.js +7 -0
  31. package/dist/client-ip.mjs +3 -0
  32. package/dist/host-adapter/index.d.mts +2 -0
  33. package/dist/host-adapter/index.d.ts +2 -0
  34. package/dist/host-adapter/index.js +23 -0
  35. package/dist/host-adapter/index.mjs +3 -0
  36. package/dist/host-adapter-C-4IxmqM.mjs +540 -0
  37. package/dist/host-adapter-C-4IxmqM.mjs.map +1 -0
  38. package/dist/host-adapter-CwW9YB0U.js +694 -0
  39. package/dist/index-B7rTovHa.d.mts +707 -0
  40. package/dist/index-B7rTovHa.d.mts.map +1 -0
  41. package/dist/index-HaqfPtaL.d.ts +707 -0
  42. package/dist/index-HaqfPtaL.d.ts.map +1 -0
  43. package/dist/index.d.mts +107 -981
  44. package/dist/index.d.mts.map +1 -1
  45. package/dist/index.d.ts +107 -981
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +73 -2308
  48. package/dist/index.mjs +5 -2240
  49. package/dist/index.mjs.map +1 -1
  50. package/dist/kya-http-error-codes-7ewV5RuK.d.mts +29 -0
  51. package/dist/kya-http-error-codes-7ewV5RuK.d.mts.map +1 -0
  52. package/dist/kya-http-error-codes-7ewV5RuK.d.ts +29 -0
  53. package/dist/kya-http-error-codes-7ewV5RuK.d.ts.map +1 -0
  54. package/dist/kya-http-error-codes-C2JiWPsi.mjs +73 -0
  55. package/dist/kya-http-error-codes-C2JiWPsi.mjs.map +1 -0
  56. package/dist/kya-http-error-codes-UYb1zpGM.js +83 -0
  57. package/dist/kya-http.d.mts +3 -0
  58. package/dist/kya-http.d.ts +3 -0
  59. package/dist/kya-http.js +11 -0
  60. package/dist/kya-http.mjs +4 -0
  61. package/dist/policy/enforcement.d.mts +2 -0
  62. package/dist/policy/enforcement.d.ts +2 -0
  63. package/dist/policy/enforcement.js +15 -0
  64. package/dist/policy/enforcement.mjs +3 -0
  65. package/dist/{posture-origins-Pn-ii-Pp.mjs → posture-origins-Ba83O0cD.mjs} +2 -2
  66. package/dist/posture-origins-Ba83O0cD.mjs.map +1 -0
  67. package/dist/{posture-origins-LFkX80oF.js → posture-origins-CdVOdiMT.js} +1 -1
  68. package/dist/registered-sid-D3g-gZQF.d.mts +11 -0
  69. package/dist/registered-sid-D3g-gZQF.d.mts.map +1 -0
  70. package/dist/registered-sid-D3g-gZQF.d.ts +11 -0
  71. package/dist/registered-sid-D3g-gZQF.d.ts.map +1 -0
  72. package/dist/registered-sid-eLCNZvIF.js +170 -0
  73. package/dist/registered-sid-hUl-bvM5.mjs +142 -0
  74. package/dist/registered-sid-hUl-bvM5.mjs.map +1 -0
  75. package/dist/step-up-BjP--hG-.d.mts +114 -0
  76. package/dist/step-up-BjP--hG-.d.mts.map +1 -0
  77. package/dist/step-up-BjP--hG-.d.ts +114 -0
  78. package/dist/step-up-BjP--hG-.d.ts.map +1 -0
  79. package/dist/step-up-C2d8C20x.js +1697 -0
  80. package/dist/step-up-COlmWJN8.mjs +1513 -0
  81. package/dist/step-up-COlmWJN8.mjs.map +1 -0
  82. package/package.json +23 -1
  83. package/dist/posture-origins-Pn-ii-Pp.mjs.map +0 -1
@@ -0,0 +1,29 @@
1
+ //#region src/mcpi/kya-http-error-codes.d.ts
2
+ declare const KYA_HTTP_ERROR: {
3
+ readonly MISSING_SIGNATURE: "kyaos/missing-signature";
4
+ readonly INVALID_SIGNATURE: "kyaos/invalid-signature";
5
+ readonly EXPIRED: "kyaos/expired";
6
+ readonly REPLAY: "kyaos/replay";
7
+ readonly DID_UNRESOLVABLE: "kyaos/did-unresolvable";
8
+ readonly AUTHORIZATION_REQUIRED: "kyaos/authorization-required";
9
+ readonly PROFILE_VIOLATION: "kyaos/profile-violation";
10
+ readonly DELEGATION_REVOKED: "kyaos/delegation-revoked";
11
+ readonly SCOPE_INSUFFICIENT: "kyaos/scope-insufficient";
12
+ readonly CHAIN_BROKEN: "kyaos/chain-broken";
13
+ readonly HOLDER_MISMATCH: "kyaos/holder-mismatch";
14
+ readonly AUDIENCE_MISMATCH: "kyaos/audience-mismatch";
15
+ readonly SESSION_MISMATCH: "kyaos/session-mismatch";
16
+ readonly PICKUP_PINNED: "kyaos/pickup-pinned";
17
+ readonly ASSURANCE_INSUFFICIENT: "kyaos/assurance-insufficient";
18
+ readonly STATUS_PENDING: "kyaos/status-pending";
19
+ readonly AUTHORIZATION_HOST_UNAVAILABLE: "kyaos/authorization-host-unavailable";
20
+ readonly REPLAY_STATE_UNAVAILABLE: "kyaos/replay-state-unavailable";
21
+ readonly REPLAY_CAPACITY: "kyaos/replay-capacity";
22
+ readonly INVALID_SESSION: "kyaos/invalid-session";
23
+ readonly PICKUP_EXPIRED: "kyaos/pickup-expired";
24
+ };
25
+ type KyaHttpErrorCode = (typeof KYA_HTTP_ERROR)[keyof typeof KYA_HTTP_ERROR];
26
+ declare const KYA_HTTP_ERROR_STATUS: Readonly<Record<KyaHttpErrorCode, number>>;
27
+ //#endregion
28
+ export { KYA_HTTP_ERROR_STATUS as n, KyaHttpErrorCode as r, KYA_HTTP_ERROR as t };
29
+ //# sourceMappingURL=kya-http-error-codes-7ewV5RuK.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kya-http-error-codes-7ewV5RuK.d.mts","names":[],"sources":["../src/mcpi/kya-http-error-codes.ts"],"mappings":";cAiBa;;;;;;;;;;;;;;;;;;;;;;;KA0CD,2BAA2B,6BAA6B;cAOvD,uBAAuB,SAAS,OAAO"}
@@ -0,0 +1,29 @@
1
+ //#region src/mcpi/kya-http-error-codes.d.ts
2
+ declare const KYA_HTTP_ERROR: {
3
+ readonly MISSING_SIGNATURE: "kyaos/missing-signature";
4
+ readonly INVALID_SIGNATURE: "kyaos/invalid-signature";
5
+ readonly EXPIRED: "kyaos/expired";
6
+ readonly REPLAY: "kyaos/replay";
7
+ readonly DID_UNRESOLVABLE: "kyaos/did-unresolvable";
8
+ readonly AUTHORIZATION_REQUIRED: "kyaos/authorization-required";
9
+ readonly PROFILE_VIOLATION: "kyaos/profile-violation";
10
+ readonly DELEGATION_REVOKED: "kyaos/delegation-revoked";
11
+ readonly SCOPE_INSUFFICIENT: "kyaos/scope-insufficient";
12
+ readonly CHAIN_BROKEN: "kyaos/chain-broken";
13
+ readonly HOLDER_MISMATCH: "kyaos/holder-mismatch";
14
+ readonly AUDIENCE_MISMATCH: "kyaos/audience-mismatch";
15
+ readonly SESSION_MISMATCH: "kyaos/session-mismatch";
16
+ readonly PICKUP_PINNED: "kyaos/pickup-pinned";
17
+ readonly ASSURANCE_INSUFFICIENT: "kyaos/assurance-insufficient";
18
+ readonly STATUS_PENDING: "kyaos/status-pending";
19
+ readonly AUTHORIZATION_HOST_UNAVAILABLE: "kyaos/authorization-host-unavailable";
20
+ readonly REPLAY_STATE_UNAVAILABLE: "kyaos/replay-state-unavailable";
21
+ readonly REPLAY_CAPACITY: "kyaos/replay-capacity";
22
+ readonly INVALID_SESSION: "kyaos/invalid-session";
23
+ readonly PICKUP_EXPIRED: "kyaos/pickup-expired";
24
+ };
25
+ type KyaHttpErrorCode = (typeof KYA_HTTP_ERROR)[keyof typeof KYA_HTTP_ERROR];
26
+ declare const KYA_HTTP_ERROR_STATUS: Readonly<Record<KyaHttpErrorCode, number>>;
27
+ //#endregion
28
+ export { KYA_HTTP_ERROR_STATUS as n, KyaHttpErrorCode as r, KYA_HTTP_ERROR as t };
29
+ //# sourceMappingURL=kya-http-error-codes-7ewV5RuK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kya-http-error-codes-7ewV5RuK.d.ts","names":[],"sources":["../src/mcpi/kya-http-error-codes.ts"],"mappings":";cAiBa;;;;;;;;;;;;;;;;;;;;;;;KA0CD,2BAA2B,6BAA6B;cAOvD,uBAAuB,SAAS,OAAO"}
@@ -0,0 +1,73 @@
1
+ //#region src/mcpi/kya-http-error-codes.ts
2
+ /**
3
+ * KYA-HTTP error code registry — draft-kya-http-02 §9 / H1.2 (#3245).
4
+ *
5
+ * The `kyaos/*` strings are wire constants returned in the `error` field of a
6
+ * KYA-HTTP failure response (and mapped to an HTTP status). Emitters MUST use
7
+ * these EXACT bytes; consumers MAY additionally accept the legacy `kya/*`
8
+ * spellings for one transition cycle.
9
+ *
10
+ * The single source of truth is the golden fixture
11
+ * `packages/checkpoint-shared/fixtures/kya-http/error-codes.json`; the parity
12
+ * test in `__tests__/kya-http-error-codes.test.ts` reads that JSON via `fs` and
13
+ * asserts this map is byte-exact against it (no drift, no omissions).
14
+ *
15
+ * `as const satisfies Record<string, \`kyaos/${string}\`>` keeps the narrow
16
+ * literal value types (so consumers get autocomplete and a compile error on a
17
+ * typo'd code) while still proving every value is a well-formed `kyaos/…` string.
18
+ */
19
+ const KYA_HTTP_ERROR = {
20
+ MISSING_SIGNATURE: "kyaos/missing-signature",
21
+ INVALID_SIGNATURE: "kyaos/invalid-signature",
22
+ EXPIRED: "kyaos/expired",
23
+ REPLAY: "kyaos/replay",
24
+ DID_UNRESOLVABLE: "kyaos/did-unresolvable",
25
+ AUTHORIZATION_REQUIRED: "kyaos/authorization-required",
26
+ PROFILE_VIOLATION: "kyaos/profile-violation",
27
+ DELEGATION_REVOKED: "kyaos/delegation-revoked",
28
+ SCOPE_INSUFFICIENT: "kyaos/scope-insufficient",
29
+ CHAIN_BROKEN: "kyaos/chain-broken",
30
+ HOLDER_MISMATCH: "kyaos/holder-mismatch",
31
+ AUDIENCE_MISMATCH: "kyaos/audience-mismatch",
32
+ SESSION_MISMATCH: "kyaos/session-mismatch",
33
+ PICKUP_PINNED: "kyaos/pickup-pinned",
34
+ ASSURANCE_INSUFFICIENT: "kyaos/assurance-insufficient",
35
+ STATUS_PENDING: "kyaos/status-pending",
36
+ AUTHORIZATION_HOST_UNAVAILABLE: "kyaos/authorization-host-unavailable",
37
+ REPLAY_STATE_UNAVAILABLE: "kyaos/replay-state-unavailable",
38
+ REPLAY_CAPACITY: "kyaos/replay-capacity",
39
+ INVALID_SESSION: "kyaos/invalid-session",
40
+ PICKUP_EXPIRED: "kyaos/pickup-expired"
41
+ };
42
+ /**
43
+ * The HTTP status the registry assigns each code (draft-kya-http-02 §9).
44
+ * Mirrors `error-codes.json` exactly, pinned by `__tests__/kya-http-error-codes.test.ts`,
45
+ * and matches the engine's own table (`rust/crates/kya-os-engine/src/render/kya_error.rs`).
46
+ */
47
+ const KYA_HTTP_ERROR_STATUS = {
48
+ [KYA_HTTP_ERROR.MISSING_SIGNATURE]: 401,
49
+ [KYA_HTTP_ERROR.INVALID_SIGNATURE]: 401,
50
+ [KYA_HTTP_ERROR.EXPIRED]: 401,
51
+ [KYA_HTTP_ERROR.REPLAY]: 401,
52
+ [KYA_HTTP_ERROR.DID_UNRESOLVABLE]: 401,
53
+ [KYA_HTTP_ERROR.AUTHORIZATION_REQUIRED]: 401,
54
+ [KYA_HTTP_ERROR.PROFILE_VIOLATION]: 403,
55
+ [KYA_HTTP_ERROR.DELEGATION_REVOKED]: 403,
56
+ [KYA_HTTP_ERROR.SCOPE_INSUFFICIENT]: 403,
57
+ [KYA_HTTP_ERROR.CHAIN_BROKEN]: 403,
58
+ [KYA_HTTP_ERROR.HOLDER_MISMATCH]: 403,
59
+ [KYA_HTTP_ERROR.AUDIENCE_MISMATCH]: 403,
60
+ [KYA_HTTP_ERROR.SESSION_MISMATCH]: 403,
61
+ [KYA_HTTP_ERROR.PICKUP_PINNED]: 403,
62
+ [KYA_HTTP_ERROR.ASSURANCE_INSUFFICIENT]: 403,
63
+ [KYA_HTTP_ERROR.STATUS_PENDING]: 503,
64
+ [KYA_HTTP_ERROR.AUTHORIZATION_HOST_UNAVAILABLE]: 503,
65
+ [KYA_HTTP_ERROR.REPLAY_STATE_UNAVAILABLE]: 503,
66
+ [KYA_HTTP_ERROR.REPLAY_CAPACITY]: 429,
67
+ [KYA_HTTP_ERROR.INVALID_SESSION]: 404,
68
+ [KYA_HTTP_ERROR.PICKUP_EXPIRED]: 410
69
+ };
70
+
71
+ //#endregion
72
+ export { KYA_HTTP_ERROR_STATUS as n, KYA_HTTP_ERROR as t };
73
+ //# sourceMappingURL=kya-http-error-codes-C2JiWPsi.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kya-http-error-codes-C2JiWPsi.mjs","names":[],"sources":["../src/mcpi/kya-http-error-codes.ts"],"sourcesContent":["/**\n * KYA-HTTP error code registry — draft-kya-http-02 §9 / H1.2 (#3245).\n *\n * The `kyaos/*` strings are wire constants returned in the `error` field of a\n * KYA-HTTP failure response (and mapped to an HTTP status). Emitters MUST use\n * these EXACT bytes; consumers MAY additionally accept the legacy `kya/*`\n * spellings for one transition cycle.\n *\n * The single source of truth is the golden fixture\n * `packages/checkpoint-shared/fixtures/kya-http/error-codes.json`; the parity\n * test in `__tests__/kya-http-error-codes.test.ts` reads that JSON via `fs` and\n * asserts this map is byte-exact against it (no drift, no omissions).\n *\n * `as const satisfies Record<string, \\`kyaos/${string}\\`>` keeps the narrow\n * literal value types (so consumers get autocomplete and a compile error on a\n * typo'd code) while still proving every value is a well-formed `kyaos/…` string.\n */\nexport const KYA_HTTP_ERROR = {\n // ── 401 (identity / signature) ──────────────────────────────────────────\n MISSING_SIGNATURE: 'kyaos/missing-signature',\n INVALID_SIGNATURE: 'kyaos/invalid-signature',\n EXPIRED: 'kyaos/expired',\n REPLAY: 'kyaos/replay',\n DID_UNRESOLVABLE: 'kyaos/did-unresolvable',\n AUTHORIZATION_REQUIRED: 'kyaos/authorization-required',\n\n // ── 403 (delegation / profile) ──────────────────────────────────────────\n PROFILE_VIOLATION: 'kyaos/profile-violation',\n DELEGATION_REVOKED: 'kyaos/delegation-revoked',\n SCOPE_INSUFFICIENT: 'kyaos/scope-insufficient',\n CHAIN_BROKEN: 'kyaos/chain-broken',\n HOLDER_MISMATCH: 'kyaos/holder-mismatch',\n AUDIENCE_MISMATCH: 'kyaos/audience-mismatch',\n SESSION_MISMATCH: 'kyaos/session-mismatch',\n PICKUP_PINNED: 'kyaos/pickup-pinned',\n // Credential verified but its achieved assurance tier is below the\n // determining policy's opt-in `@min_assurance` floor (trust-gap G3) — a\n // bearer credential (attested-bearer, no proof-of-possession) cannot satisfy\n // a key-bound+ floor. Recovery: a key-bound signed request, not a new\n // credential.\n ASSURANCE_INSUFFICIENT: 'kyaos/assurance-insufficient',\n\n // ── 503 (revocation status unverifiable — RETRYABLE) ─────────────────────\n // Emitted when a credential DECLARES a `credentialStatus` but its status list\n // was not supplied / could not be fetched (cold cache, past the 300s status\n // cap). Fail-closed but retryable: a warmed list may yet verify (#3345 / #3446).\n STATUS_PENDING: 'kyaos/status-pending',\n AUTHORIZATION_HOST_UNAVAILABLE: 'kyaos/authorization-host-unavailable',\n REPLAY_STATE_UNAVAILABLE: 'kyaos/replay-state-unavailable',\n\n // Live replay entries are retained when admission capacity is exhausted.\n REPLAY_CAPACITY: 'kyaos/replay-capacity',\n\n // ── pickup flow (404 / 410) ─────────────────────────────────────────────\n INVALID_SESSION: 'kyaos/invalid-session',\n PICKUP_EXPIRED: 'kyaos/pickup-expired',\n} as const satisfies Record<string, `kyaos/${string}`>;\n\n/** A `kyaos/*` registry code (the value side of {@link KYA_HTTP_ERROR}). */\nexport type KyaHttpErrorCode = (typeof KYA_HTTP_ERROR)[keyof typeof KYA_HTTP_ERROR];\n\n/**\n * The HTTP status the registry assigns each code (draft-kya-http-02 §9).\n * Mirrors `error-codes.json` exactly, pinned by `__tests__/kya-http-error-codes.test.ts`,\n * and matches the engine's own table (`rust/crates/kya-os-engine/src/render/kya_error.rs`).\n */\nexport const KYA_HTTP_ERROR_STATUS: Readonly<Record<KyaHttpErrorCode, number>> = {\n [KYA_HTTP_ERROR.MISSING_SIGNATURE]: 401,\n [KYA_HTTP_ERROR.INVALID_SIGNATURE]: 401,\n [KYA_HTTP_ERROR.EXPIRED]: 401,\n [KYA_HTTP_ERROR.REPLAY]: 401,\n [KYA_HTTP_ERROR.DID_UNRESOLVABLE]: 401,\n [KYA_HTTP_ERROR.AUTHORIZATION_REQUIRED]: 401,\n [KYA_HTTP_ERROR.PROFILE_VIOLATION]: 403,\n [KYA_HTTP_ERROR.DELEGATION_REVOKED]: 403,\n [KYA_HTTP_ERROR.SCOPE_INSUFFICIENT]: 403,\n [KYA_HTTP_ERROR.CHAIN_BROKEN]: 403,\n [KYA_HTTP_ERROR.HOLDER_MISMATCH]: 403,\n [KYA_HTTP_ERROR.AUDIENCE_MISMATCH]: 403,\n [KYA_HTTP_ERROR.SESSION_MISMATCH]: 403,\n [KYA_HTTP_ERROR.PICKUP_PINNED]: 403,\n [KYA_HTTP_ERROR.ASSURANCE_INSUFFICIENT]: 403,\n [KYA_HTTP_ERROR.STATUS_PENDING]: 503,\n [KYA_HTTP_ERROR.AUTHORIZATION_HOST_UNAVAILABLE]: 503,\n [KYA_HTTP_ERROR.REPLAY_STATE_UNAVAILABLE]: 503,\n [KYA_HTTP_ERROR.REPLAY_CAPACITY]: 429,\n [KYA_HTTP_ERROR.INVALID_SESSION]: 404,\n [KYA_HTTP_ERROR.PICKUP_EXPIRED]: 410,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,iBAAiB;CAE5B,mBAAmB;CACnB,mBAAmB;CACnB,SAAS;CACT,QAAQ;CACR,kBAAkB;CAClB,wBAAwB;CAGxB,mBAAmB;CACnB,oBAAoB;CACpB,oBAAoB;CACpB,cAAc;CACd,iBAAiB;CACjB,mBAAmB;CACnB,kBAAkB;CAClB,eAAe;CAMf,wBAAwB;CAMxB,gBAAgB;CAChB,gCAAgC;CAChC,0BAA0B;CAG1B,iBAAiB;CAGjB,iBAAiB;CACjB,gBAAgB;AAClB;;;;;;AAUA,MAAa,wBAAoE;EAC9E,eAAe,oBAAoB;EACnC,eAAe,oBAAoB;EACnC,eAAe,UAAU;EACzB,eAAe,SAAS;EACxB,eAAe,mBAAmB;EAClC,eAAe,yBAAyB;EACxC,eAAe,oBAAoB;EACnC,eAAe,qBAAqB;EACpC,eAAe,qBAAqB;EACpC,eAAe,eAAe;EAC9B,eAAe,kBAAkB;EACjC,eAAe,oBAAoB;EACnC,eAAe,mBAAmB;EAClC,eAAe,gBAAgB;EAC/B,eAAe,yBAAyB;EACxC,eAAe,iBAAiB;EAChC,eAAe,iCAAiC;EAChD,eAAe,2BAA2B;EAC1C,eAAe,kBAAkB;EACjC,eAAe,kBAAkB;EACjC,eAAe,iBAAiB;AACnC"}
@@ -0,0 +1,83 @@
1
+ //#region src/mcpi/kya-http-error-codes.ts
2
+ /**
3
+ * KYA-HTTP error code registry — draft-kya-http-02 §9 / H1.2 (#3245).
4
+ *
5
+ * The `kyaos/*` strings are wire constants returned in the `error` field of a
6
+ * KYA-HTTP failure response (and mapped to an HTTP status). Emitters MUST use
7
+ * these EXACT bytes; consumers MAY additionally accept the legacy `kya/*`
8
+ * spellings for one transition cycle.
9
+ *
10
+ * The single source of truth is the golden fixture
11
+ * `packages/checkpoint-shared/fixtures/kya-http/error-codes.json`; the parity
12
+ * test in `__tests__/kya-http-error-codes.test.ts` reads that JSON via `fs` and
13
+ * asserts this map is byte-exact against it (no drift, no omissions).
14
+ *
15
+ * `as const satisfies Record<string, \`kyaos/${string}\`>` keeps the narrow
16
+ * literal value types (so consumers get autocomplete and a compile error on a
17
+ * typo'd code) while still proving every value is a well-formed `kyaos/…` string.
18
+ */
19
+ const KYA_HTTP_ERROR = {
20
+ MISSING_SIGNATURE: "kyaos/missing-signature",
21
+ INVALID_SIGNATURE: "kyaos/invalid-signature",
22
+ EXPIRED: "kyaos/expired",
23
+ REPLAY: "kyaos/replay",
24
+ DID_UNRESOLVABLE: "kyaos/did-unresolvable",
25
+ AUTHORIZATION_REQUIRED: "kyaos/authorization-required",
26
+ PROFILE_VIOLATION: "kyaos/profile-violation",
27
+ DELEGATION_REVOKED: "kyaos/delegation-revoked",
28
+ SCOPE_INSUFFICIENT: "kyaos/scope-insufficient",
29
+ CHAIN_BROKEN: "kyaos/chain-broken",
30
+ HOLDER_MISMATCH: "kyaos/holder-mismatch",
31
+ AUDIENCE_MISMATCH: "kyaos/audience-mismatch",
32
+ SESSION_MISMATCH: "kyaos/session-mismatch",
33
+ PICKUP_PINNED: "kyaos/pickup-pinned",
34
+ ASSURANCE_INSUFFICIENT: "kyaos/assurance-insufficient",
35
+ STATUS_PENDING: "kyaos/status-pending",
36
+ AUTHORIZATION_HOST_UNAVAILABLE: "kyaos/authorization-host-unavailable",
37
+ REPLAY_STATE_UNAVAILABLE: "kyaos/replay-state-unavailable",
38
+ REPLAY_CAPACITY: "kyaos/replay-capacity",
39
+ INVALID_SESSION: "kyaos/invalid-session",
40
+ PICKUP_EXPIRED: "kyaos/pickup-expired"
41
+ };
42
+ /**
43
+ * The HTTP status the registry assigns each code (draft-kya-http-02 §9).
44
+ * Mirrors `error-codes.json` exactly, pinned by `__tests__/kya-http-error-codes.test.ts`,
45
+ * and matches the engine's own table (`rust/crates/kya-os-engine/src/render/kya_error.rs`).
46
+ */
47
+ const KYA_HTTP_ERROR_STATUS = {
48
+ [KYA_HTTP_ERROR.MISSING_SIGNATURE]: 401,
49
+ [KYA_HTTP_ERROR.INVALID_SIGNATURE]: 401,
50
+ [KYA_HTTP_ERROR.EXPIRED]: 401,
51
+ [KYA_HTTP_ERROR.REPLAY]: 401,
52
+ [KYA_HTTP_ERROR.DID_UNRESOLVABLE]: 401,
53
+ [KYA_HTTP_ERROR.AUTHORIZATION_REQUIRED]: 401,
54
+ [KYA_HTTP_ERROR.PROFILE_VIOLATION]: 403,
55
+ [KYA_HTTP_ERROR.DELEGATION_REVOKED]: 403,
56
+ [KYA_HTTP_ERROR.SCOPE_INSUFFICIENT]: 403,
57
+ [KYA_HTTP_ERROR.CHAIN_BROKEN]: 403,
58
+ [KYA_HTTP_ERROR.HOLDER_MISMATCH]: 403,
59
+ [KYA_HTTP_ERROR.AUDIENCE_MISMATCH]: 403,
60
+ [KYA_HTTP_ERROR.SESSION_MISMATCH]: 403,
61
+ [KYA_HTTP_ERROR.PICKUP_PINNED]: 403,
62
+ [KYA_HTTP_ERROR.ASSURANCE_INSUFFICIENT]: 403,
63
+ [KYA_HTTP_ERROR.STATUS_PENDING]: 503,
64
+ [KYA_HTTP_ERROR.AUTHORIZATION_HOST_UNAVAILABLE]: 503,
65
+ [KYA_HTTP_ERROR.REPLAY_STATE_UNAVAILABLE]: 503,
66
+ [KYA_HTTP_ERROR.REPLAY_CAPACITY]: 429,
67
+ [KYA_HTTP_ERROR.INVALID_SESSION]: 404,
68
+ [KYA_HTTP_ERROR.PICKUP_EXPIRED]: 410
69
+ };
70
+
71
+ //#endregion
72
+ Object.defineProperty(exports, 'KYA_HTTP_ERROR', {
73
+ enumerable: true,
74
+ get: function () {
75
+ return KYA_HTTP_ERROR;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, 'KYA_HTTP_ERROR_STATUS', {
79
+ enumerable: true,
80
+ get: function () {
81
+ return KYA_HTTP_ERROR_STATUS;
82
+ }
83
+ });
@@ -0,0 +1,3 @@
1
+ import { n as KYA_HTTP_ERROR_STATUS, r as KyaHttpErrorCode, t as KYA_HTTP_ERROR } from "./kya-http-error-codes-7ewV5RuK.mjs";
2
+ import { a as requestPresentedCredential, i as requestCarriesDelegationProof, n as SID_ATTRIBUTABLE_RESULT, r as DELEGATION_PROOF_HEADERS, t as REGISTERED_SID_MAX_LENGTH } from "./registered-sid-D3g-gZQF.mjs";
3
+ export { DELEGATION_PROOF_HEADERS, KYA_HTTP_ERROR, KYA_HTTP_ERROR_STATUS, KyaHttpErrorCode, REGISTERED_SID_MAX_LENGTH, SID_ATTRIBUTABLE_RESULT, requestCarriesDelegationProof, requestPresentedCredential };
@@ -0,0 +1,3 @@
1
+ import { n as KYA_HTTP_ERROR_STATUS, r as KyaHttpErrorCode, t as KYA_HTTP_ERROR } from "./kya-http-error-codes-7ewV5RuK.js";
2
+ import { a as requestPresentedCredential, i as requestCarriesDelegationProof, n as SID_ATTRIBUTABLE_RESULT, r as DELEGATION_PROOF_HEADERS, t as REGISTERED_SID_MAX_LENGTH } from "./registered-sid-D3g-gZQF.js";
3
+ export { DELEGATION_PROOF_HEADERS, KYA_HTTP_ERROR, KYA_HTTP_ERROR_STATUS, KyaHttpErrorCode, REGISTERED_SID_MAX_LENGTH, SID_ATTRIBUTABLE_RESULT, requestCarriesDelegationProof, requestPresentedCredential };
@@ -0,0 +1,11 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_kya_http_error_codes = require('./kya-http-error-codes-UYb1zpGM.js');
3
+ const require_registered_sid = require('./registered-sid-eLCNZvIF.js');
4
+
5
+ exports.DELEGATION_PROOF_HEADERS = require_registered_sid.DELEGATION_PROOF_HEADERS;
6
+ exports.KYA_HTTP_ERROR = require_kya_http_error_codes.KYA_HTTP_ERROR;
7
+ exports.KYA_HTTP_ERROR_STATUS = require_kya_http_error_codes.KYA_HTTP_ERROR_STATUS;
8
+ exports.REGISTERED_SID_MAX_LENGTH = require_registered_sid.REGISTERED_SID_MAX_LENGTH;
9
+ exports.SID_ATTRIBUTABLE_RESULT = require_registered_sid.SID_ATTRIBUTABLE_RESULT;
10
+ exports.requestCarriesDelegationProof = require_registered_sid.requestCarriesDelegationProof;
11
+ exports.requestPresentedCredential = require_registered_sid.requestPresentedCredential;
@@ -0,0 +1,4 @@
1
+ import { n as KYA_HTTP_ERROR_STATUS, t as KYA_HTTP_ERROR } from "./kya-http-error-codes-C2JiWPsi.mjs";
2
+ import { a as requestPresentedCredential, i as requestCarriesDelegationProof, n as SID_ATTRIBUTABLE_RESULT, r as DELEGATION_PROOF_HEADERS, t as REGISTERED_SID_MAX_LENGTH } from "./registered-sid-hUl-bvM5.mjs";
3
+
4
+ export { DELEGATION_PROOF_HEADERS, KYA_HTTP_ERROR, KYA_HTTP_ERROR_STATUS, REGISTERED_SID_MAX_LENGTH, SID_ATTRIBUTABLE_RESULT, requestCarriesDelegationProof, requestPresentedCredential };
@@ -0,0 +1,2 @@
1
+ import { A as FAIL_CLOSED_HEADERS, D as NO_EVIDENCE_EXCLUSION_TERM, E as NO_EVIDENCE_EQUALITY_TERM, M as isEngineEnforcing, O as withNoEvidenceExclusion, T as NO_EVIDENCE_CATEGORY, a as ApprovalQuorum, c as decisionPolicyId, d as RequestFacts, i as validateStepUpQuorum, j as FAIL_CLOSED_STATUS, k as FAIL_CLOSED_BODY, l as requiredScopesForRequest, n as StepUpQuorumCheck, o as approvalQuorumForRequest, r as StepUpQuorumLike, s as DecisionLike, t as InvalidStepUpReason } from "../step-up-BjP--hG-.mjs";
2
+ export { type ApprovalQuorum, type DecisionLike, FAIL_CLOSED_BODY, FAIL_CLOSED_HEADERS, FAIL_CLOSED_STATUS, type InvalidStepUpReason, NO_EVIDENCE_CATEGORY, NO_EVIDENCE_EQUALITY_TERM, NO_EVIDENCE_EXCLUSION_TERM, type RequestFacts, type StepUpQuorumCheck, type StepUpQuorumLike, approvalQuorumForRequest, decisionPolicyId, isEngineEnforcing, requiredScopesForRequest, validateStepUpQuorum, withNoEvidenceExclusion };
@@ -0,0 +1,2 @@
1
+ import { A as FAIL_CLOSED_HEADERS, D as NO_EVIDENCE_EXCLUSION_TERM, E as NO_EVIDENCE_EQUALITY_TERM, M as isEngineEnforcing, O as withNoEvidenceExclusion, T as NO_EVIDENCE_CATEGORY, a as ApprovalQuorum, c as decisionPolicyId, d as RequestFacts, i as validateStepUpQuorum, j as FAIL_CLOSED_STATUS, k as FAIL_CLOSED_BODY, l as requiredScopesForRequest, n as StepUpQuorumCheck, o as approvalQuorumForRequest, r as StepUpQuorumLike, s as DecisionLike, t as InvalidStepUpReason } from "../step-up-BjP--hG-.js";
2
+ export { type ApprovalQuorum, type DecisionLike, FAIL_CLOSED_BODY, FAIL_CLOSED_HEADERS, FAIL_CLOSED_STATUS, type InvalidStepUpReason, NO_EVIDENCE_CATEGORY, NO_EVIDENCE_EQUALITY_TERM, NO_EVIDENCE_EXCLUSION_TERM, type RequestFacts, type StepUpQuorumCheck, type StepUpQuorumLike, approvalQuorumForRequest, decisionPolicyId, isEngineEnforcing, requiredScopesForRequest, validateStepUpQuorum, withNoEvidenceExclusion };
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_step_up = require('../step-up-C2d8C20x.js');
3
+
4
+ exports.FAIL_CLOSED_BODY = require_step_up.FAIL_CLOSED_BODY;
5
+ exports.FAIL_CLOSED_HEADERS = require_step_up.FAIL_CLOSED_HEADERS;
6
+ exports.FAIL_CLOSED_STATUS = require_step_up.FAIL_CLOSED_STATUS;
7
+ exports.NO_EVIDENCE_CATEGORY = require_step_up.NO_EVIDENCE_CATEGORY;
8
+ exports.NO_EVIDENCE_EQUALITY_TERM = require_step_up.NO_EVIDENCE_EQUALITY_TERM;
9
+ exports.NO_EVIDENCE_EXCLUSION_TERM = require_step_up.NO_EVIDENCE_EXCLUSION_TERM;
10
+ exports.approvalQuorumForRequest = require_step_up.approvalQuorumForRequest;
11
+ exports.decisionPolicyId = require_step_up.decisionPolicyId;
12
+ exports.isEngineEnforcing = require_step_up.isEngineEnforcing;
13
+ exports.requiredScopesForRequest = require_step_up.requiredScopesForRequest;
14
+ exports.validateStepUpQuorum = require_step_up.validateStepUpQuorum;
15
+ exports.withNoEvidenceExclusion = require_step_up.withNoEvidenceExclusion;
@@ -0,0 +1,3 @@
1
+ import { A as FAIL_CLOSED_STATUS, C as NO_EVIDENCE_EXCLUSION_TERM, O as FAIL_CLOSED_BODY, S as NO_EVIDENCE_EQUALITY_TERM, i as requiredScopesForRequest, j as isEngineEnforcing, k as FAIL_CLOSED_HEADERS, n as approvalQuorumForRequest, r as decisionPolicyId, t as validateStepUpQuorum, w as withNoEvidenceExclusion, x as NO_EVIDENCE_CATEGORY } from "../step-up-COlmWJN8.mjs";
2
+
3
+ export { FAIL_CLOSED_BODY, FAIL_CLOSED_HEADERS, FAIL_CLOSED_STATUS, NO_EVIDENCE_CATEGORY, NO_EVIDENCE_EQUALITY_TERM, NO_EVIDENCE_EXCLUSION_TERM, approvalQuorumForRequest, decisionPolicyId, isEngineEnforcing, requiredScopesForRequest, validateStepUpQuorum, withNoEvidenceExclusion };
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Validation Patterns
9
9
  */
10
- const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
10
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
11
11
  const VALIDATION_PATTERNS = {
12
12
  UUID: UUID_PATTERN,
13
13
  ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,
@@ -530,4 +530,4 @@ function matchAllowedOrigin(pageOrigin, allowed) {
530
530
 
531
531
  //#endregion
532
532
  export { BROWSER_PATTERNS as a, OS_PATTERNS as c, UUID_PATTERN as d, VALIDATION_PATTERNS as f, testPatterns as g, testPattern as h, validatePostureOrigins as i, SUSPICIOUS_PATTERNS as l, findMatchingPattern as m, matchAllowedOrigin as n, HEADER_PATTERNS as o, extractMatch as p, parseOriginPattern as r, MOBILE_PATTERNS as s, isPublicSuffixLike as t, USER_AGENT_PATTERNS as u };
533
- //# sourceMappingURL=posture-origins-Pn-ii-Pp.mjs.map
533
+ //# sourceMappingURL=posture-origins-Ba83O0cD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posture-origins-Ba83O0cD.mjs","names":[],"sources":["../src/constants/patterns.ts","../src/posture-origins/index.ts"],"sourcesContent":["/**\n * Regular Expression Patterns\n *\n * Common regex patterns used for validation and detection\n */\n\n/**\n * Validation Patterns\n */\n// Hoisted out of the object literal below so bundle-size-critical leaves can\n// import JUST this one pattern. `VALIDATION_PATTERNS` re-exports it, so there\n// is still exactly one definition and no drift.\n//\n// Why it matters: rolldown (via tsdown) does not do property-level DCE on a\n// const object literal the way esbuild did. `browser-posture-cookie.ts` uses\n// only `.UUID`, but importing the whole object dragged every pattern —\n// ULID, SLUG, IPV4, IPV6 — into that leaf, taking it from 272 to 2,870 bytes.\nexport const UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\n\nexport const VALIDATION_PATTERNS = {\n // Identifiers\n UUID: UUID_PATTERN,\n ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,\n SLUG: /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n\n // Network\n IPV4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,\n IPV6: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,\n IP: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$|^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,\n // eslint-disable-next-line no-useless-escape\n // CIDR pattern: uses IPV4 pattern and restricts mask to 0-32\n CIDR: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\/(?:[0-9]|[12][0-9]|3[0-2])$/,\n // eslint-disable-next-line no-useless-escape\n DOMAIN: /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)*[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i,\n HOSTNAME:\n /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/,\n // eslint-disable-next-line no-useless-escape\n URL: /^https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/,\n\n // Contact\n // Email pattern: stricter validation (rejects consecutive dots, requires TLD)\n // Local part: alphanumeric start/end, dots allowed but not consecutive\n EMAIL:\n /^[a-zA-Z0-9](?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]|\\.(?!\\.))*[a-zA-Z0-9]?@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,\n PHONE: /^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$/,\n\n // Security\n // JWT pattern: requires 3 parts (header.payload.signature) - signature cannot be empty\n JWT: /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+$/,\n // eslint-disable-next-line no-useless-escape\n BASE64: /^[A-Za-z0-9+\\/]*={0,2}$/,\n HEX: /^[0-9a-fA-F]+$/,\n MD5: /^[a-f0-9]{32}$/i,\n SHA1: /^[a-f0-9]{40}$/i,\n SHA256: /^[a-f0-9]{64}$/i,\n\n // Versions\n SEMVER:\n /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/,\n\n // Files\n FILENAME: /^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\\.[a-zA-Z0-9_-]+$/,\n PATH: /^(\\/[^/ ]*)+\\/?$/,\n\n // Keys\n API_KEY: /^[A-Za-z0-9_-]{32,}$/,\n SECRET_KEY: /^[A-Za-z0-9_-]{64,}$/,\n PIXEL_ID: /^px_[A-Za-z0-9]{16}$/,\n} as const;\n\n/**\n * User Agent Patterns for Agent Detection\n */\nexport const USER_AGENT_PATTERNS = {\n // AI Agents\n OPENAI: /(?:GPTBot|ChatGPT-User|OpenAI)/i,\n ANTHROPIC: /(?:Claude-Web|Claude-User|anthropic-ai|claude-web|claude-user|ClaudeBot)/i,\n PERPLEXITY: /(?:PerplexityBot|Perplexica)/i,\n GOOGLE_AI: /(?:Bard|Google-InspectionTool)/i,\n MICROSOFT_AI: /(?:BingPreview\\/.*ChatGPT|Copilot)/i,\n\n // Search Bots\n GOOGLEBOT: /Googlebot/i,\n BINGBOT: /(?:bingbot|BingPreview|msnbot)/i,\n DUCKDUCKBOT: /DuckDuckBot/i,\n BAIDUBOT: /Baiduspider/i,\n YANDEXBOT: /YandexBot/i,\n\n // Social Media Bots\n FACEBOOK: /(?:facebookexternalhit|facebookcatalog)/i,\n TWITTER: /(?:Twitterbot|TwitterImageProxy)/i,\n LINKEDIN: /LinkedInBot/i,\n WHATSAPP: /WhatsApp/i,\n TELEGRAM: /TelegramBot/i,\n DISCORD: /Discordbot/i,\n SLACK: /Slackbot/i,\n\n // Crawlers and Scrapers\n GENERIC_BOT: /(?:bot|crawler|spider|scraper|agent)/i,\n SCRAPY: /Scrapy/i,\n PUPPETEER: /(?:HeadlessChrome|Puppeteer)/i,\n PLAYWRIGHT: /Playwright/i,\n SELENIUM: /(?:selenium|webdriver)/i,\n\n // Development Tools\n POSTMAN: /PostmanRuntime/i,\n INSOMNIA: /insomnia/i,\n CURL: /curl/i,\n WGET: /Wget/i,\n HTTPIE: /HTTPie/i,\n\n // Monitoring Services\n UPTIMEROBOT: /UptimeRobot/i,\n PINGDOM: /Pingdom/i,\n NEWRELIC: /NewRelicPinger/i,\n DATADOG: /Datadog/i,\n} as const;\n\n/**\n * Header Patterns for Agent Detection\n */\nexport const HEADER_PATTERNS = {\n // AI-specific headers\n AI_HEADERS: /^(?:X-(?:OpenAI|Anthropic|AI|Bot|Agent|LLM))/i,\n\n // Automation headers\n AUTOMATION_HEADERS: /^(?:X-(?:Automated|Robot|Crawler|Scraper))/i,\n\n // Missing standard headers\n MISSING_ACCEPT: /^$/,\n MISSING_ACCEPT_LANGUAGE: /^$/,\n MISSING_ACCEPT_ENCODING: /^$/,\n\n // Suspicious patterns\n GENERIC_ACCEPT: /^\\*\\/\\*$/,\n NO_COOKIES: /^$/,\n\n // Known proxy headers\n PROXY_HEADERS: /^(?:X-Forwarded-|X-Real-IP|X-Originating-IP|Via|Forwarded)/i,\n\n // Cloud provider headers\n CLOUD_HEADERS: /^(?:X-(?:AWS|Azure|GCP|Cloudflare))/i,\n} as const;\n\n/**\n * Browser Patterns\n */\nexport const BROWSER_PATTERNS = {\n CHROME: /Chrome\\/([0-9.]+)/,\n FIREFOX: /Firefox\\/([0-9.]+)/,\n SAFARI: /Version\\/([0-9.]+).*Safari/,\n EDGE: /Edg\\/([0-9.]+)/,\n OPERA: /OPR\\/([0-9.]+)/,\n IE: /MSIE ([0-9.]+)/,\n} as const;\n\n/**\n * Operating System Patterns\n */\nexport const OS_PATTERNS = {\n WINDOWS: /Windows NT ([0-9.]+)/,\n MACOS: /Mac OS X ([0-9_]+)/,\n LINUX: /Linux/,\n ANDROID: /Android ([0-9.]+)/,\n IOS: /OS ([0-9_]+) like Mac OS X/,\n} as const;\n\n/**\n * Mobile Device Patterns\n */\nexport const MOBILE_PATTERNS = {\n MOBILE: /(?:Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini)/i,\n TABLET: /(?:iPad|Android.*Tablet|Tablet.*Android|Kindle|Silk)/i,\n DESKTOP: /(?:Windows NT|Mac OS X|Linux|CrOS)/i,\n} as const;\n\n/**\n * Suspicious Behavior Patterns\n */\nexport const SUSPICIOUS_PATTERNS = {\n // Rapid requests\n RAPID_REQUESTS: /^[0-9]{1,3}$/,\n\n // Sequential access\n SEQUENTIAL_URLS: /\\?(?:page|offset|id)=[0-9]+/,\n\n // Data extraction\n API_ENDPOINTS: /\\/api\\/|\\.json$|\\.xml$/i,\n\n // Form submission without interaction\n DIRECT_POST: /^POST$/,\n\n // Known attack patterns\n SQL_INJECTION:\n /(?:union|select|insert|update|delete|drop|create|alter|exec|script|javascript|onerror|onload|eval|src=)/i,\n XSS_ATTEMPT: /(?:<script|javascript:|onerror=|onclick=|<iframe|<embed|<object)/i,\n PATH_TRAVERSAL: /(?:\\.\\.\\/|\\.\\.\\\\|%2e%2e%2f|%252e%252e%252f)/i,\n\n // Encoding attempts\n URL_ENCODED: /%[0-9a-f]{2}/i,\n BASE64_DATA: /data:[^;]+;base64,/i,\n} as const;\n\n/**\n * Maximum input length for pattern matching. UAs, header values, and\n * detection payloads are bounded in practice (<4KB even for the most\n * verbose Chrome/Firefox UAs). Caps worst-case complexity for any\n * polynomial-shaped pattern an external caller might supply to\n * `testPattern` / `extractMatch`; CodeQL flagged the unbounded path\n * (js/polynomial-redos) on PR #2576.\n */\nconst MAX_PATTERN_INPUT_LENGTH = 4096;\n\n/**\n * Helper function to test a pattern. Returns `false` on inputs longer\n * than {@link MAX_PATTERN_INPUT_LENGTH} — an abuse signal we'd rather\n * reject than process.\n */\nexport function testPattern(pattern: RegExp, value: string): boolean {\n if (value.length > MAX_PATTERN_INPUT_LENGTH) return false;\n return pattern.test(value);\n}\n\n/**\n * Helper function to extract match from pattern. Returns `null` on\n * over-long inputs (same ReDoS defense as `testPattern`).\n */\nexport function extractMatch(pattern: RegExp, value: string): string | null {\n if (value.length > MAX_PATTERN_INPUT_LENGTH) return null;\n const match = value.match(pattern);\n return match ? match[1] || match[0] : null;\n}\n\n/**\n * Helper function to test multiple patterns\n */\nexport function testPatterns(patterns: RegExp[], value: string): boolean {\n return patterns.some((pattern) => testPattern(pattern, value));\n}\n\n/**\n * Helper function to find matching pattern\n */\nexport function findMatchingPattern(\n patterns: Record<string, RegExp>,\n value: string\n): string | null {\n for (const [name, pattern] of Object.entries(patterns)) {\n if (testPattern(pattern, value)) {\n return name;\n }\n }\n return null;\n}\n","/**\n * Posture origins: which page origins a project's browser posture token may\n * be issued for (and, at the edge gateway, accepted on).\n *\n * The primary origin is derived from `project.domain`. A project can add up\n * to {@link MAX_POSTURE_ORIGINS} more in `settings.postureOrigins`, for the\n * installs a single varchar cannot describe: a Shopify store whose shoppers\n * browse a custom domain while `project.domain` is the myshopify host, `www`\n * next to the apex, a staging host, several storefront domains.\n *\n * One resolver, used by every caller (the beacon issuer, the settings APIs,\n * the dashboard editor, the gateway verifier, the beacon-ingest Worker), so\n * what the dashboard accepts, what the issuer signs and what the gateway\n * verifies can never drift apart.\n *\n * Pure, dependency-free, Web-standard `URL` only: safe in Node, the browser\n * and Cloudflare Workers. `URL` also gives consistent IDN handling: a\n * Unicode host is converted to its punycode (`xn--`) form everywhere, which\n * is exactly how a browser serializes the `Origin` header.\n *\n * Pattern rules (the stored form is always normalized):\n * - `https://host[:port]`: an exact origin. HTTPS only, with no localhost\n * exception, because the posture signer (`signBrowserPosture`) refuses any\n * non-HTTPS audience anyway.\n * - A bare `host` is read as `https://host`. Paths, a trailing slash, query\n * and fragment are stripped; userinfo (`user@host`) is rejected.\n * - `https://*.example.com`: matches any origin ONE OR MORE labels below\n * `example.com` (`a.example.com`, `a.b.example.com`), same scheme and port.\n * It never matches the apex `example.com`; list that separately. The\n * wildcard is allowed only as the whole leftmost label.\n * - A wildcard over a public or multi-tenant suffix is rejected\n * (`*.com`, `*.co.uk`, `*.myshopify.com`, `*.vercel.app`, ...): it would\n * let any tenant of that platform mint posture for this project.\n *\n * @example\n * const allowed = resolveProjectAllowedOrigins({\n * domain: 'checkpoint-rebrand.myshopify.com',\n * settings: { postureOrigins: ['https://www.brand.com', 'https://*.brand.com'] },\n * });\n * matchAllowedOrigin('https://shop.brand.com', allowed); // 'https://shop.brand.com'\n * matchAllowedOrigin('https://brand.com', allowed); // undefined (apex not listed)\n */\n\nexport const MAX_POSTURE_ORIGINS = 20;\n/** Longest accepted entry: `https://` + a 253-char host + `:65535`, with headroom. */\nexport const MAX_POSTURE_ORIGIN_LENGTH = 300;\n\n/**\n * Multi-tenant hosting suffixes a customer does not control the siblings of.\n * A wildcard AT or anywhere BELOW one of these is refused, because platforms\n * nest tenant namespaces (`*.s3.us-east-1.amazonaws.com`, `*.a.run.app`,\n * `*.blob.core.windows.net`). An exact tenant host (`https://brand.myshopify.com`)\n * is still accepted.\n *\n * The public-suffix list is not a dependency of this package (it would ship\n * to the dashboard bundle and both Workers), so this is a curated list plus\n * the structural checks in {@link isPublicSuffixLike}. It is not complete:\n * adopting the PSL private section (e.g. `tldts`) is the full fix.\n */\nexport const MULTI_TENANT_SUFFIXES: ReadonlySet<string> = new Set([\n // Commerce and site builders\n 'myshopify.com',\n 'shopifypreview.com',\n 'myshopline.com',\n 'mybigcommerce.com',\n 'bigcartel.com',\n 'company.site',\n 'square.site',\n 'wixsite.com',\n 'wixstudio.io',\n 'squarespace.com',\n 'webflow.io',\n 'framer.app',\n 'framer.website',\n 'carrd.co',\n 'weebly.com',\n 'godaddysites.com',\n 'mystrikingly.com',\n 'hs-sites.com',\n 'hubspotpagebuilder.com',\n 'myportfolio.com',\n 'notion.site',\n 'ghost.io',\n 'substack.com',\n 'tumblr.com',\n 'blogspot.com',\n 'wordpress.com',\n 'wpengine.com',\n 'wpenginepowered.com',\n 'pantheonsite.io',\n 'kinsta.cloud',\n 'gitbook.io',\n 'bubbleapps.io',\n 'neocities.org',\n // App and AI builders\n 'lovable.app',\n 'lovable.dev',\n 'replit.app',\n 'replit.dev',\n 'repl.co',\n 'glitch.me',\n 'vusercontent.net',\n 'csb.app',\n 'codesandbox.io',\n 'stackblitz.io',\n 'webcontainer.io',\n 'streamlit.app',\n 'hf.space',\n 'gradio.live',\n 'pythonanywhere.com',\n // Hosting platforms\n 'vercel.app',\n 'now.sh',\n 'netlify.app',\n 'netlify.com',\n 'pages.dev',\n 'workers.dev',\n 'r2.dev',\n 'github.io',\n 'github.dev',\n 'gitlab.io',\n 'herokuapp.com',\n 'onrender.com',\n 'fly.dev',\n 'railway.app',\n 'koyeb.app',\n 'deno.dev',\n 'surge.sh',\n 'ondigitalocean.app',\n 'digitaloceanspaces.com',\n 'gitpod.io',\n // Cloud providers and CDNs\n 'amazonaws.com',\n 'amplifyapp.com',\n 'awsapprunner.com',\n 'elasticbeanstalk.com',\n 'cloudfront.net',\n 'azurewebsites.net',\n 'azurestaticapps.net',\n 'azurecontainerapps.io',\n 'azureedge.net',\n 'azurefd.net',\n 'azure-api.net',\n 'cloudapp.net',\n 'cloudapp.azure.com',\n 'windows.net',\n 'run.app',\n 'web.app',\n 'firebaseapp.com',\n 'firebasestorage.app',\n 'appspot.com',\n 'googleapis.com',\n 'googleusercontent.com',\n 'translate.goog',\n 'fastly.net',\n 'akamaized.net',\n 'akamaihd.net',\n 'edgekey.net',\n 'edgesuite.net',\n 'b-cdn.net',\n 'cloudflarestorage.com',\n 'supabase.co',\n // Tunnels\n 'ngrok.io',\n 'ngrok.app',\n 'ngrok.dev',\n 'ngrok-free.app',\n 'ngrok-free.dev',\n 'trycloudflare.com',\n 'loca.lt',\n]);\n\n/** Common second-level labels under a two-letter country TLD (`co.uk`, `com.au`, `ne.jp`). */\nconst CCTLD_SECOND_LEVEL_LABELS: ReadonlySet<string> = new Set([\n 'ac',\n 'biz',\n 'co',\n 'com',\n 'edu',\n 'gen',\n 'go',\n 'gob',\n 'gov',\n 'info',\n 'ltd',\n 'me',\n 'mil',\n 'ne',\n 'net',\n 'nic',\n 'or',\n 'org',\n 'plc',\n 'sch',\n]);\n\nconst WILDCARD_PROBE_LABEL = 'posture-origin-wildcard-probe';\n\nexport interface ParsedOriginPattern {\n /** The normalized stored form, e.g. `https://*.example.com` or `https://a.example.com:8443`. */\n pattern: string;\n wildcard: boolean;\n /** Lowercased, punycoded host WITHOUT the `*.` prefix. */\n host: string;\n /** Explicit port, or '' for the scheme default. */\n port: string;\n}\n\nexport type OriginPatternResult =\n | { ok: true; value: ParsedOriginPattern }\n | { ok: false; error: string };\n\n/**\n * True when a wildcard directly over `host` would cover sites the customer\n * does not control: a single label (`com`), a common ccTLD second level\n * (`co.uk`, `com.au`), or a known multi-tenant platform suffix or any host\n * below one (`myshopify.com`, `s3.us-east-1.amazonaws.com`). A heuristic,\n * not the full PSL.\n */\nexport function isPublicSuffixLike(host: string): boolean {\n const labels = host.split('.');\n if (labels.length < 2) return true;\n for (let index = 0; index < labels.length - 1; index++) {\n if (MULTI_TENANT_SUFFIXES.has(labels.slice(index).join('.'))) return true;\n }\n if (labels.length === 2) {\n const [second, top] = labels;\n if (top.length === 2 && CCTLD_SECOND_LEVEL_LABELS.has(second)) return true;\n }\n return false;\n}\n\nfunction isIpLiteral(host: string): boolean {\n return host.startsWith('[') || /^\\d+(\\.\\d+){3}$/.test(host);\n}\n\n/**\n * Validates and normalizes one allowlist entry. Returns a human-readable\n * error for the settings API's 400 and the dashboard editor.\n */\nexport function parseOriginPattern(input: string): OriginPatternResult {\n const trimmed = typeof input === 'string' ? input.trim() : '';\n if (!trimmed) return { ok: false, error: 'Enter an origin such as https://www.example.com' };\n if (trimmed.length > MAX_POSTURE_ORIGIN_LENGTH) {\n return { ok: false, error: `Must be at most ${MAX_POSTURE_ORIGIN_LENGTH} characters` };\n }\n const schemeMatch = /^([a-z][a-z0-9+.-]*):\\/\\//i.exec(trimmed);\n if (schemeMatch && schemeMatch[1].toLowerCase() !== 'https') {\n return { ok: false, error: 'Only https:// origins are supported' };\n }\n const rest = schemeMatch ? trimmed.slice(schemeMatch[0].length) : trimmed;\n const wildcard = rest.startsWith('*.');\n const withoutWildcard = wildcard ? rest.slice(2) : rest;\n if (withoutWildcard.includes('*')) {\n return {\n ok: false,\n error: 'A wildcard is only allowed as the whole first label, e.g. https://*.example.com',\n };\n }\n let url: URL;\n try {\n url = new URL(`https://${wildcard ? `${WILDCARD_PROBE_LABEL}.` : ''}${withoutWildcard}`);\n } catch {\n return { ok: false, error: 'Not a valid origin' };\n }\n if (url.username || url.password) {\n return { ok: false, error: 'Origins cannot contain a username or password' };\n }\n let host = url.hostname;\n if (wildcard) host = host.slice(WILDCARD_PROBE_LABEL.length + 1);\n if (!host || host.endsWith('.') || host.startsWith('.')) {\n return { ok: false, error: 'Not a valid host name' };\n }\n if (isIpLiteral(host)) {\n return { ok: false, error: 'Use a domain name, not an IP address' };\n }\n if (wildcard && isPublicSuffixLike(host)) {\n return {\n ok: false,\n error: `*.${host} would include sites you do not control; list your own hosts instead`,\n };\n }\n if (!host.includes('.')) {\n return { ok: false, error: 'Use a fully qualified domain, e.g. www.example.com' };\n }\n const port = url.port;\n // Port 0 is not a connectable port, so no page is ever served from it.\n if (port === '0') return { ok: false, error: 'Not a valid port' };\n const pattern = `https://${wildcard ? '*.' : ''}${host}${port ? `:${port}` : ''}`;\n return { ok: true, value: { pattern, wildcard, host, port } };\n}\n\nexport type PostureOriginsValidation =\n | { ok: true; origins: string[] }\n | { ok: false; errors: Array<{ index: number; message: string }> };\n\n/**\n * Validates a full allowlist from an API body or the editor: every entry\n * must parse, the list is capped, and duplicates (after normalization) are\n * removed while keeping first-seen order.\n */\nexport function validatePostureOrigins(input: unknown): PostureOriginsValidation {\n if (!Array.isArray(input)) {\n return { ok: false, errors: [{ index: -1, message: 'Expected a list of origins' }] };\n }\n if (input.length > MAX_POSTURE_ORIGINS) {\n return {\n ok: false,\n errors: [{ index: -1, message: `At most ${MAX_POSTURE_ORIGINS} additional origins` }],\n };\n }\n const errors: Array<{ index: number; message: string }> = [];\n const origins: string[] = [];\n input.forEach((entry, index) => {\n if (typeof entry !== 'string') {\n errors.push({ index, message: 'Each origin must be a string' });\n return;\n }\n const parsed = parseOriginPattern(entry);\n if (!parsed.ok) {\n errors.push({ index, message: parsed.error });\n return;\n }\n if (!origins.includes(parsed.value.pattern)) origins.push(parsed.value.pattern);\n });\n return errors.length > 0 ? { ok: false, errors } : { ok: true, origins };\n}\n\n/**\n * The primary origin from `project.domain`: an exact HTTPS origin, or\n * undefined when the domain is unset or carries a path, query, fragment or\n * userinfo. A bare host is read as `https://host`.\n */\nexport function primaryPostureOrigin(domain: string | null | undefined): string | undefined {\n if (!domain) return undefined;\n try {\n const url = new URL(domain.includes('://') ? domain : `https://${domain}`);\n if (\n url.protocol !== 'https:' ||\n url.username ||\n url.password ||\n url.pathname !== '/' ||\n url.search ||\n url.hash\n )\n return undefined;\n return url.origin;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Reads `settings.postureOrigins` defensively: settings is a jsonb column,\n * so anything written before validation existed (or by hand) is re-parsed\n * and invalid entries are dropped rather than trusted.\n */\nexport function postureKeysUrl(base: string, projectId: string): string {\n return `${base}/api/v1/beacon/keys?projectId=${projectId}`;\n}\n\nexport function readPostureOriginsSetting(settings: unknown): string[] {\n if (!settings || typeof settings !== 'object') return [];\n const raw = (settings as { postureOrigins?: unknown }).postureOrigins;\n if (!Array.isArray(raw)) return [];\n const origins: string[] = [];\n for (const entry of raw.slice(0, MAX_POSTURE_ORIGINS)) {\n if (typeof entry !== 'string') continue;\n const parsed = parseOriginPattern(entry);\n if (parsed.ok && !origins.includes(parsed.value.pattern)) origins.push(parsed.value.pattern);\n }\n return origins;\n}\n\n/**\n * Every origin pattern a project's posture may be issued for: the primary\n * (from `project.domain`) first, then the additional allowlist. Empty when\n * neither exists, which the issuer reports as `domain-unset`.\n */\nexport function resolveProjectAllowedOrigins(project: {\n domain: string | null | undefined;\n settings?: unknown;\n}): string[] {\n const allowed: string[] = [];\n const primary = primaryPostureOrigin(project.domain);\n if (primary) allowed.push(primary);\n for (const pattern of readPostureOriginsSetting(project.settings)) {\n if (!allowed.includes(pattern)) allowed.push(pattern);\n }\n return allowed;\n}\n\n/**\n * Returns the page origin when it matches one of `allowed`, else undefined.\n * The page origin must already be in the browser's serialized form\n * (`https://host[:port]`, lowercase, no path); anything else, including the\n * opaque `null` origin, never matches. The value returned is the page origin\n * itself, never a pattern, so a signed audience is always a concrete origin.\n */\nexport function matchAllowedOrigin(\n pageOrigin: string | null | undefined,\n allowed: readonly string[]\n): string | undefined {\n if (!pageOrigin || allowed.length === 0) return undefined;\n let url: URL;\n try {\n url = new URL(pageOrigin);\n } catch {\n return undefined;\n }\n if (url.protocol !== 'https:' || url.origin !== pageOrigin) return undefined;\n const host = url.hostname;\n if (host.includes('*')) return undefined;\n for (const entry of allowed) {\n const parsed = parseOriginPattern(entry);\n if (!parsed.ok || parsed.value.port !== url.port) continue;\n const { wildcard, host: patternHost } = parsed.value;\n if (!wildcard) {\n if (host === patternHost) return pageOrigin;\n continue;\n }\n if (host.length > patternHost.length + 1 && host.endsWith(`.${patternHost}`)) {\n return pageOrigin;\n }\n }\n return undefined;\n}\n\n/**\n * The page origin for an ingest request: the browser-set `Origin` header,\n * or, ONLY when that header is absent, the origin of `Referer`. Both are\n * set by the browser and equally forgeable by a non-browser client, so the\n * fallback adds no trust; it recovers installs whose proxy or request mode\n * drops `Origin`. A present-but-opaque `Origin: null` is kept as is (and\n * never matches), so a sandboxed frame cannot fall back to its Referer.\n * Never read `X-Forwarded-Host`, `X-Forwarded-Origin` or any custom header\n * here: those are caller-controlled.\n */\nexport function pageOriginFromHeaders(\n origin: string | null | undefined,\n referer: string | null | undefined\n): string | null {\n // Present means present: an empty `Origin:` is kept (and never matches)\n // rather than falling back to Referer.\n if (origin !== null && origin !== undefined) return origin;\n if (!referer) return null;\n try {\n const url = new URL(referer);\n if (url.protocol !== 'https:' || url.username || url.password) return null;\n return url.origin;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAa,eACX;AAEF,MAAa,sBAAsB;CAEjC,MAAM;CACN,MAAM;CACN,MAAM;CAGN,MAAM;CACN,MAAM;CACN,IAAI;CAGJ,MAAM;CAEN,QAAQ;CACR,UACE;CAEF,KAAK;CAKL,OACE;CACF,OAAO;CAIP,KAAK;CAEL,QAAQ;CACR,KAAK;CACL,KAAK;CACL,MAAM;CACN,QAAQ;CAGR,QACE;CAGF,UAAU;CACV,MAAM;CAGN,SAAS;CACT,YAAY;CACZ,UAAU;AACZ;;;;AAKA,MAAa,sBAAsB;CAEjC,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,WAAW;CACX,cAAc;CAGd,WAAW;CACX,SAAS;CACT,aAAa;CACb,UAAU;CACV,WAAW;CAGX,UAAU;CACV,SAAS;CACT,UAAU;CACV,UAAU;CACV,UAAU;CACV,SAAS;CACT,OAAO;CAGP,aAAa;CACb,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,UAAU;CAGV,SAAS;CACT,UAAU;CACV,MAAM;CACN,MAAM;CACN,QAAQ;CAGR,aAAa;CACb,SAAS;CACT,UAAU;CACV,SAAS;AACX;;;;AAKA,MAAa,kBAAkB;CAE7B,YAAY;CAGZ,oBAAoB;CAGpB,gBAAgB;CAChB,yBAAyB;CACzB,yBAAyB;CAGzB,gBAAgB;CAChB,YAAY;CAGZ,eAAe;CAGf,eAAe;AACjB;;;;AAKA,MAAa,mBAAmB;CAC9B,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,MAAM;CACN,OAAO;CACP,IAAI;AACN;;;;AAKA,MAAa,cAAc;CACzB,SAAS;CACT,OAAO;CACP,OAAO;CACP,SAAS;CACT,KAAK;AACP;;;;AAKA,MAAa,kBAAkB;CAC7B,QAAQ;CACR,QAAQ;CACR,SAAS;AACX;;;;AAKA,MAAa,sBAAsB;CAEjC,gBAAgB;CAGhB,iBAAiB;CAGjB,eAAe;CAGf,aAAa;CAGb,eACE;CACF,aAAa;CACb,gBAAgB;CAGhB,aAAa;CACb,aAAa;AACf;;;;;;;;;AAUA,MAAM,2BAA2B;;;;;;AAOjC,SAAgB,YAAY,SAAiB,OAAwB;CACnE,IAAI,MAAM,SAAS,0BAA0B,OAAO;CACpD,OAAO,QAAQ,KAAK,KAAK;AAC3B;;;;;AAMA,SAAgB,aAAa,SAAiB,OAA8B;CAC1E,IAAI,MAAM,SAAS,0BAA0B,OAAO;CACpD,MAAM,QAAQ,MAAM,MAAM,OAAO;CACjC,OAAO,QAAQ,MAAM,MAAM,MAAM,KAAK;AACxC;;;;AAKA,SAAgB,aAAa,UAAoB,OAAwB;CACvE,OAAO,SAAS,MAAM,YAAY,YAAY,SAAS,KAAK,CAAC;AAC/D;;;;AAKA,SAAgB,oBACd,UACA,OACe;CACf,KAAK,MAAM,CAAC,MAAM,YAAY,OAAO,QAAQ,QAAQ,GACnD,IAAI,YAAY,SAAS,KAAK,GAC5B,OAAO;CAGX,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACnNA,MAAa,sBAAsB;;AAEnC,MAAa,4BAA4B;;;;;;;;;;;;;AAczC,MAAa,wCAA6C,IAAI,IAAI;CAEhE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,MAAM,4CAAiD,IAAI,IAAI;CAC7D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,uBAAuB;;;;;;;;AAuB7B,SAA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"}
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Validation Patterns
9
9
  */
10
- const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
10
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
11
11
  const VALIDATION_PATTERNS = {
12
12
  UUID: UUID_PATTERN,
13
13
  ULID: /^[0-9A-HJKMNP-TV-Z]{26}$/,
@@ -0,0 +1,11 @@
1
+ //#region src/mcpi/delegation-headers.d.ts
2
+ declare const DELEGATION_PROOF_HEADERS: readonly ["kya-os-delegation-credential", "kya-delegation"];
3
+ declare function requestCarriesDelegationProof(headers: Headers | Record<string, unknown> | null | undefined): boolean;
4
+ declare function requestPresentedCredential(headers: Headers | Record<string, unknown> | null | undefined): boolean;
5
+ //#endregion
6
+ //#region src/mcpi/registered-sid.d.ts
7
+ declare const REGISTERED_SID_MAX_LENGTH = 100;
8
+ declare const SID_ATTRIBUTABLE_RESULT: "verified";
9
+ //#endregion
10
+ export { requestPresentedCredential as a, requestCarriesDelegationProof as i, SID_ATTRIBUTABLE_RESULT as n, DELEGATION_PROOF_HEADERS as r, REGISTERED_SID_MAX_LENGTH as t };
11
+ //# sourceMappingURL=registered-sid-D3g-gZQF.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registered-sid-D3g-gZQF.d.mts","names":[],"sources":["../src/mcpi/delegation-headers.ts","../src/mcpi/registered-sid.ts"],"mappings":";cAmBa;iBAgBG,8BACd,SAAS,UAAU;iBA4FL,2BACd,SAAS,UAAU;;;cClHR;cAUA"}
@@ -0,0 +1,11 @@
1
+ //#region src/mcpi/delegation-headers.d.ts
2
+ declare const DELEGATION_PROOF_HEADERS: readonly ["kya-os-delegation-credential", "kya-delegation"];
3
+ declare function requestCarriesDelegationProof(headers: Headers | Record<string, unknown> | null | undefined): boolean;
4
+ declare function requestPresentedCredential(headers: Headers | Record<string, unknown> | null | undefined): boolean;
5
+ //#endregion
6
+ //#region src/mcpi/registered-sid.d.ts
7
+ declare const REGISTERED_SID_MAX_LENGTH = 100;
8
+ declare const SID_ATTRIBUTABLE_RESULT: "verified";
9
+ //#endregion
10
+ export { requestPresentedCredential as a, requestCarriesDelegationProof as i, SID_ATTRIBUTABLE_RESULT as n, DELEGATION_PROOF_HEADERS as r, REGISTERED_SID_MAX_LENGTH as t };
11
+ //# sourceMappingURL=registered-sid-D3g-gZQF.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registered-sid-D3g-gZQF.d.ts","names":[],"sources":["../src/mcpi/delegation-headers.ts","../src/mcpi/registered-sid.ts"],"mappings":";cAmBa;iBAgBG,8BACd,SAAS,UAAU;iBA4FL,2BACd,SAAS,UAAU;;;cClHR;cAUA"}
@@ -0,0 +1,170 @@
1
+ //#region src/mcpi/delegation-headers.ts
2
+ /**
3
+ * Delegation-proof request detection (P2 / DR-1).
4
+ *
5
+ * The engine's L2 delegation-root pinning (`ContextSpec.trustedDelegationRoots`)
6
+ * is consulted for every credential the engine verifies: the delegation-proof
7
+ * headers below AND an `Authorization: Bearer` VC-JWT. Consumers gate root
8
+ * resolution on `requestPresentedCredential`, so the human / no-credential hot
9
+ * path stays a precise no-op.
10
+ *
11
+ * Keeping the header set here (rather than re-listing the literals at each site)
12
+ * is the whole point: a new delegation transport header is added in one place
13
+ * and every verifier surface agrees.
14
+ */
15
+ /**
16
+ * Lowercased delegation-proof header names. `kya-os-delegation-credential` is the
17
+ * canonical KYA-OS transport; `kya-delegation` is the legacy envelope form still
18
+ * accepted via `legacyEnvelopeFallback`.
19
+ */
20
+ const DELEGATION_PROOF_HEADERS = ["kya-os-delegation-credential", "kya-delegation"];
21
+ /** A header value is "present" when it is a non-empty string (or non-empty list). */
22
+ function isPresent(value) {
23
+ if (Array.isArray(value)) return value.length > 0;
24
+ return typeof value === "string" && value.length > 0;
25
+ }
26
+ /**
27
+ * Does the request carry a KYA-OS delegation-proof header?
28
+ *
29
+ * Accepts either a `Headers` instance (Next.js / fetch — case-insensitive
30
+ * lookup) or a plain header record (raw Node/Express headers, gateway worker's
31
+ * lowercased map). Record keys are matched case-insensitively, so callers do not
32
+ * need to pre-normalize. Returns `false` for `null`/`undefined`.
33
+ */
34
+ function requestCarriesDelegationProof(headers) {
35
+ if (!headers) return false;
36
+ if (typeof headers.get === "function") {
37
+ const h = headers;
38
+ return DELEGATION_PROOF_HEADERS.some((name) => isPresent(h.get(name)));
39
+ }
40
+ const record = headers;
41
+ const lowerKeyed = /* @__PURE__ */ new Map();
42
+ for (const key of Object.keys(record)) lowerKeyed.set(key.toLowerCase(), record[key]);
43
+ return DELEGATION_PROOF_HEADERS.some((name) => isPresent(lowerKeyed.get(name)));
44
+ }
45
+ const MAX_VC_JWT_PAYLOAD_CHARS = 16384;
46
+ function headerText(headers, name) {
47
+ if (typeof headers.get === "function") return headers.get(name) ?? void 0;
48
+ for (const [key, value] of Object.entries(headers)) {
49
+ if (key.toLowerCase() !== name) continue;
50
+ if (Array.isArray(value)) return value.join(", ");
51
+ return typeof value === "string" ? value : void 0;
52
+ }
53
+ }
54
+ function isMemberDelimiter(c) {
55
+ return c === "=" || c === ";" || c === "," || c === " " || c === " ";
56
+ }
57
+ function hasKyaMember(value) {
58
+ let memberStart = true;
59
+ let quoted = false;
60
+ let escaped = false;
61
+ for (let i = 0; i < value.length; i++) {
62
+ const c = value[i];
63
+ if (quoted) {
64
+ if (escaped) escaped = false;
65
+ else if (c === "\\") escaped = true;
66
+ else if (c === "\"") quoted = false;
67
+ continue;
68
+ }
69
+ if (memberStart) {
70
+ if (c === " " || c === " ") continue;
71
+ if (value.startsWith("kya", i) && (i + 3 === value.length || isMemberDelimiter(value[i + 3]))) return true;
72
+ memberStart = false;
73
+ }
74
+ if (c === "\"") quoted = true;
75
+ else if (c === ",") memberStart = true;
76
+ }
77
+ return false;
78
+ }
79
+ function decodeBase64UrlJson(segment) {
80
+ const padded = segment.replace(/-/g, "+").replace(/_/g, "/");
81
+ const binary = atob(padded + "=".repeat((4 - padded.length % 4) % 4));
82
+ const bytes = Uint8Array.from(binary, (ch) => ch.charCodeAt(0));
83
+ return JSON.parse(new TextDecoder().decode(bytes));
84
+ }
85
+ function isDelegationCredentialPayload(payload) {
86
+ if (typeof payload !== "object" || payload === null) return false;
87
+ if ("vc" in payload) return true;
88
+ const type = payload.type;
89
+ return Array.isArray(type) && type.includes("DelegationCredential");
90
+ }
91
+ function looksLikeVcJwt(token) {
92
+ const parts = token.split(".");
93
+ if (parts.length !== 3 || parts.some((part) => part.length === 0)) return false;
94
+ if (parts[1].length > MAX_VC_JWT_PAYLOAD_CHARS) return true;
95
+ try {
96
+ return isDelegationCredentialPayload(decodeBase64UrlJson(parts[1]));
97
+ } catch {
98
+ return false;
99
+ }
100
+ }
101
+ /** Same definition as the .NET / Java `IsCredentialPresented`. */
102
+ function requestPresentedCredential(headers) {
103
+ if (!headers) return false;
104
+ for (const name of ["signature-input", "signature"]) {
105
+ const value = headerText(headers, name);
106
+ if (value && hasKyaMember(value)) return true;
107
+ }
108
+ if (requestCarriesDelegationProof(headers)) return true;
109
+ const bearer = headerText(headers, "authorization")?.match(/^bearer\s+(\S+)/i);
110
+ return bearer !== null && bearer !== void 0 && looksLikeVcJwt(bearer[1]);
111
+ }
112
+
113
+ //#endregion
114
+ //#region src/mcpi/registered-sid.ts
115
+ /**
116
+ * The registered session anchor (`sid`) contract between a reporter and
117
+ * Checkpoint ingest. Kept apart from `reported-identity.ts`, which builds Zod
118
+ * schemas when it loads, so the runtime and the `./kya-http` entry can read
119
+ * these values without loading Zod.
120
+ */
121
+ /**
122
+ * Max length of a registered session anchor (`sid`) accepted on the wire and
123
+ * enforced again at the customer route. The join partner
124
+ * `bouncer_sessions.id` is `varchar(100)`; `detections.registered_sid` stays
125
+ * `text` (converting a live column to `varchar` would take an ACCESS EXCLUSIVE
126
+ * rewrite of the hottest table), so this constant is the width contract
127
+ * instead of the column type.
128
+ */
129
+ const REGISTERED_SID_MAX_LENGTH = 100;
130
+ /**
131
+ * The one delegation result that may attribute a `sid` to a session timeline.
132
+ * A rejected presentation carries no engine-emitted sid, and a sid on a
133
+ * `failed` / `not_presented` report is attacker-shaped, so ingest stamps
134
+ * `registered_sid` only for this result and nulls it otherwise (D4 / D15).
135
+ * One member on purpose: Section 13 of the plan records how an explicitly
136
+ * unverified-labeled `failed` could join it later.
137
+ */
138
+ const SID_ATTRIBUTABLE_RESULT = "verified";
139
+
140
+ //#endregion
141
+ Object.defineProperty(exports, 'DELEGATION_PROOF_HEADERS', {
142
+ enumerable: true,
143
+ get: function () {
144
+ return DELEGATION_PROOF_HEADERS;
145
+ }
146
+ });
147
+ Object.defineProperty(exports, 'REGISTERED_SID_MAX_LENGTH', {
148
+ enumerable: true,
149
+ get: function () {
150
+ return REGISTERED_SID_MAX_LENGTH;
151
+ }
152
+ });
153
+ Object.defineProperty(exports, 'SID_ATTRIBUTABLE_RESULT', {
154
+ enumerable: true,
155
+ get: function () {
156
+ return SID_ATTRIBUTABLE_RESULT;
157
+ }
158
+ });
159
+ Object.defineProperty(exports, 'requestCarriesDelegationProof', {
160
+ enumerable: true,
161
+ get: function () {
162
+ return requestCarriesDelegationProof;
163
+ }
164
+ });
165
+ Object.defineProperty(exports, 'requestPresentedCredential', {
166
+ enumerable: true,
167
+ get: function () {
168
+ return requestPresentedCredential;
169
+ }
170
+ });