@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.
- package/dist/{browser-posture-DIaVLuW3.d.ts → browser-posture-B8YiPa5c.d.ts} +5 -5
- package/dist/{browser-posture-DIaVLuW3.d.ts.map → browser-posture-B8YiPa5c.d.ts.map} +1 -1
- package/dist/{browser-posture-BuChqmH5.d.mts → browser-posture-BLhw-MON.d.mts} +5 -5
- package/dist/{browser-posture-BuChqmH5.d.mts.map → browser-posture-BLhw-MON.d.mts.map} +1 -1
- package/dist/browser-posture-cookie.js +1 -1
- package/dist/browser-posture-cookie.mjs +1 -1
- package/dist/browser-posture-cookie.mjs.map +1 -1
- package/dist/browser-posture-proof.d.mts +1 -1
- package/dist/browser-posture-proof.d.mts.map +1 -1
- package/dist/browser-posture-proof.d.ts +1 -1
- package/dist/browser-posture-proof.d.ts.map +1 -1
- package/dist/browser-posture-proof.js +42 -1
- package/dist/browser-posture-proof.mjs +42 -1
- package/dist/browser-posture-proof.mjs.map +1 -1
- package/dist/browser-posture.d.mts +1 -1
- package/dist/browser-posture.d.ts +1 -1
- package/dist/browser-posture.js +1 -1
- package/dist/browser-posture.mjs +1 -1
- package/dist/canonical-signer/index.d.mts.map +1 -1
- package/dist/canonical-signer/index.d.ts.map +1 -1
- package/dist/canonical-signer/index.js +86 -51
- package/dist/canonical-signer/index.mjs +86 -51
- package/dist/canonical-signer/index.mjs.map +1 -1
- package/dist/client-ip-DFamiNoz.d.mts +34 -0
- package/dist/client-ip-DFamiNoz.d.mts.map +1 -0
- package/dist/client-ip-DFamiNoz.d.ts +34 -0
- package/dist/client-ip-DFamiNoz.d.ts.map +1 -0
- package/dist/client-ip.d.mts +2 -0
- package/dist/client-ip.d.ts +2 -0
- package/dist/client-ip.js +7 -0
- package/dist/client-ip.mjs +3 -0
- package/dist/host-adapter/index.d.mts +2 -0
- package/dist/host-adapter/index.d.ts +2 -0
- package/dist/host-adapter/index.js +23 -0
- package/dist/host-adapter/index.mjs +3 -0
- package/dist/host-adapter-C-4IxmqM.mjs +540 -0
- package/dist/host-adapter-C-4IxmqM.mjs.map +1 -0
- package/dist/host-adapter-CwW9YB0U.js +694 -0
- package/dist/index-B7rTovHa.d.mts +707 -0
- package/dist/index-B7rTovHa.d.mts.map +1 -0
- package/dist/index-HaqfPtaL.d.ts +707 -0
- package/dist/index-HaqfPtaL.d.ts.map +1 -0
- package/dist/index.d.mts +107 -981
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +107 -981
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -2308
- package/dist/index.mjs +5 -2240
- package/dist/index.mjs.map +1 -1
- package/dist/kya-http-error-codes-7ewV5RuK.d.mts +29 -0
- package/dist/kya-http-error-codes-7ewV5RuK.d.mts.map +1 -0
- package/dist/kya-http-error-codes-7ewV5RuK.d.ts +29 -0
- package/dist/kya-http-error-codes-7ewV5RuK.d.ts.map +1 -0
- package/dist/kya-http-error-codes-C2JiWPsi.mjs +73 -0
- package/dist/kya-http-error-codes-C2JiWPsi.mjs.map +1 -0
- package/dist/kya-http-error-codes-UYb1zpGM.js +83 -0
- package/dist/kya-http.d.mts +3 -0
- package/dist/kya-http.d.ts +3 -0
- package/dist/kya-http.js +11 -0
- package/dist/kya-http.mjs +4 -0
- package/dist/policy/enforcement.d.mts +2 -0
- package/dist/policy/enforcement.d.ts +2 -0
- package/dist/policy/enforcement.js +15 -0
- package/dist/policy/enforcement.mjs +3 -0
- package/dist/{posture-origins-Pn-ii-Pp.mjs → posture-origins-Ba83O0cD.mjs} +2 -2
- package/dist/posture-origins-Ba83O0cD.mjs.map +1 -0
- package/dist/{posture-origins-LFkX80oF.js → posture-origins-CdVOdiMT.js} +1 -1
- package/dist/registered-sid-D3g-gZQF.d.mts +11 -0
- package/dist/registered-sid-D3g-gZQF.d.mts.map +1 -0
- package/dist/registered-sid-D3g-gZQF.d.ts +11 -0
- package/dist/registered-sid-D3g-gZQF.d.ts.map +1 -0
- package/dist/registered-sid-eLCNZvIF.js +170 -0
- package/dist/registered-sid-hUl-bvM5.mjs +142 -0
- package/dist/registered-sid-hUl-bvM5.mjs.map +1 -0
- package/dist/step-up-BjP--hG-.d.mts +114 -0
- package/dist/step-up-BjP--hG-.d.mts.map +1 -0
- package/dist/step-up-BjP--hG-.d.ts +114 -0
- package/dist/step-up-BjP--hG-.d.ts.map +1 -0
- package/dist/step-up-C2d8C20x.js +1697 -0
- package/dist/step-up-COlmWJN8.mjs +1513 -0
- package/dist/step-up-COlmWJN8.mjs.map +1 -0
- package/package.json +23 -1
- package/dist/posture-origins-Pn-ii-Pp.mjs.map +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
export { requestPresentedCredential as a, requestCarriesDelegationProof as i, SID_ATTRIBUTABLE_RESULT as n, DELEGATION_PROOF_HEADERS as r, REGISTERED_SID_MAX_LENGTH as t };
|
|
142
|
+
//# sourceMappingURL=registered-sid-hUl-bvM5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registered-sid-hUl-bvM5.mjs","names":[],"sources":["../src/mcpi/delegation-headers.ts","../src/mcpi/registered-sid.ts"],"sourcesContent":["/**\n * Delegation-proof request detection (P2 / DR-1).\n *\n * The engine's L2 delegation-root pinning (`ContextSpec.trustedDelegationRoots`)\n * is consulted for every credential the engine verifies: the delegation-proof\n * headers below AND an `Authorization: Bearer` VC-JWT. Consumers gate root\n * resolution on `requestPresentedCredential`, so the human / no-credential hot\n * path stays a precise no-op.\n *\n * Keeping the header set here (rather than re-listing the literals at each site)\n * is the whole point: a new delegation transport header is added in one place\n * and every verifier surface agrees.\n */\n\n/**\n * Lowercased delegation-proof header names. `kya-os-delegation-credential` is the\n * canonical KYA-OS transport; `kya-delegation` is the legacy envelope form still\n * accepted via `legacyEnvelopeFallback`.\n */\nexport const DELEGATION_PROOF_HEADERS = ['kya-os-delegation-credential', 'kya-delegation'] as const;\n\n/** A header value is \"present\" when it is a non-empty string (or non-empty list). */\nfunction isPresent(value: unknown): boolean {\n if (Array.isArray(value)) return value.length > 0;\n return typeof value === 'string' && value.length > 0;\n}\n\n/**\n * Does the request carry a KYA-OS delegation-proof header?\n *\n * Accepts either a `Headers` instance (Next.js / fetch — case-insensitive\n * lookup) or a plain header record (raw Node/Express headers, gateway worker's\n * lowercased map). Record keys are matched case-insensitively, so callers do not\n * need to pre-normalize. Returns `false` for `null`/`undefined`.\n */\nexport function requestCarriesDelegationProof(\n headers: Headers | Record<string, unknown> | null | undefined\n): boolean {\n if (!headers) return false;\n\n if (typeof (headers as Headers).get === 'function') {\n const h = headers as Headers;\n return DELEGATION_PROOF_HEADERS.some((name) => isPresent(h.get(name)));\n }\n\n const record = headers as Record<string, unknown>;\n const lowerKeyed = new Map<string, unknown>();\n for (const key of Object.keys(record)) {\n lowerKeyed.set(key.toLowerCase(), record[key]);\n }\n return DELEGATION_PROOF_HEADERS.some((name) => isPresent(lowerKeyed.get(name)));\n}\n\nconst MAX_VC_JWT_PAYLOAD_CHARS = 16 * 1024;\n\nfunction headerText(headers: Headers | Record<string, unknown>, name: string): string | undefined {\n if (typeof (headers as Headers).get === 'function') {\n return (headers as Headers).get(name) ?? undefined;\n }\n for (const [key, value] of Object.entries(headers as Record<string, unknown>)) {\n if (key.toLowerCase() !== name) continue;\n if (Array.isArray(value)) return value.join(', ');\n return typeof value === 'string' ? value : undefined;\n }\n return undefined;\n}\n\nfunction isMemberDelimiter(c: string): boolean {\n return c === '=' || c === ';' || c === ',' || c === ' ' || c === '\\t';\n}\n\n// Quote-aware member scan; the engine owns the authoritative parse.\nfunction hasKyaMember(value: string): boolean {\n let memberStart = true;\n let quoted = false;\n let escaped = false;\n for (let i = 0; i < value.length; i++) {\n const c = value[i];\n if (quoted) {\n if (escaped) escaped = false;\n else if (c === '\\\\') escaped = true;\n else if (c === '\"') quoted = false;\n continue;\n }\n if (memberStart) {\n if (c === ' ' || c === '\\t') continue;\n if (\n value.startsWith('kya', i) &&\n (i + 3 === value.length || isMemberDelimiter(value[i + 3]))\n ) {\n return true;\n }\n memberStart = false;\n }\n if (c === '\"') quoted = true;\n else if (c === ',') memberStart = true;\n }\n return false;\n}\n\nfunction decodeBase64UrlJson(segment: string): unknown {\n const padded = segment.replace(/-/g, '+').replace(/_/g, '/');\n const binary = atob(padded + '='.repeat((4 - (padded.length % 4)) % 4));\n const bytes = Uint8Array.from(binary, (ch) => ch.charCodeAt(0));\n return JSON.parse(new TextDecoder().decode(bytes));\n}\n\nfunction isDelegationCredentialPayload(payload: unknown): boolean {\n if (typeof payload !== 'object' || payload === null) return false;\n if ('vc' in payload) return true;\n const type = (payload as { type?: unknown }).type;\n return Array.isArray(type) && type.includes('DelegationCredential');\n}\n\n// Must equal the orchestrator's delegation routing (`vc` claim OR flat `type`\n// DelegationCredential); an oversized payload counts as presented.\nfunction looksLikeVcJwt(token: string): boolean {\n const parts = token.split('.');\n if (parts.length !== 3 || parts.some((part) => part.length === 0)) return false;\n if (parts[1].length > MAX_VC_JWT_PAYLOAD_CHARS) return true;\n try {\n return isDelegationCredentialPayload(decodeBase64UrlJson(parts[1]));\n } catch {\n return false;\n }\n}\n\n/** Same definition as the .NET / Java `IsCredentialPresented`. */\nexport function requestPresentedCredential(\n headers: Headers | Record<string, unknown> | null | undefined\n): boolean {\n if (!headers) return false;\n for (const name of ['signature-input', 'signature']) {\n const value = headerText(headers, name);\n if (value && hasKyaMember(value)) return true;\n }\n if (requestCarriesDelegationProof(headers)) return true;\n const authorization = headerText(headers, 'authorization');\n const bearer = authorization?.match(/^bearer\\s+(\\S+)/i);\n return bearer !== null && bearer !== undefined && looksLikeVcJwt(bearer[1]);\n}\n","/**\n * The registered session anchor (`sid`) contract between a reporter and\n * Checkpoint ingest. Kept apart from `reported-identity.ts`, which builds Zod\n * schemas when it loads, so the runtime and the `./kya-http` entry can read\n * these values without loading Zod.\n */\n\n/**\n * Max length of a registered session anchor (`sid`) accepted on the wire and\n * enforced again at the customer route. The join partner\n * `bouncer_sessions.id` is `varchar(100)`; `detections.registered_sid` stays\n * `text` (converting a live column to `varchar` would take an ACCESS EXCLUSIVE\n * rewrite of the hottest table), so this constant is the width contract\n * instead of the column type.\n */\nexport const REGISTERED_SID_MAX_LENGTH = 100;\n\n/**\n * The one delegation result that may attribute a `sid` to a session timeline.\n * A rejected presentation carries no engine-emitted sid, and a sid on a\n * `failed` / `not_presented` report is attacker-shaped, so ingest stamps\n * `registered_sid` only for this result and nulls it otherwise (D4 / D15).\n * One member on purpose: Section 13 of the plan records how an explicitly\n * unverified-labeled `failed` could join it later.\n */\nexport const SID_ATTRIBUTABLE_RESULT = 'verified' as const;\n"],"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AM,QAAQ,CAAC,mBAAmB,WAAW,GAAG;EACnD,MAAM,QAAQ,WAAW,SAAS,IAAI;EACtC,IAAI,SAAS,aAAa,KAAK,GAAG,OAAO;CAC3C;CACA,IAAI,8BAA8B,OAAO,GAAG,OAAO;CAEnD,MAAM,SADgB,WAAW,SAAS,eACf,CAAC,EAAE,MAAM,kBAAkB;CACtD,OAAO,WAAW,QAAQ,WAAW,UAAa,eAAe,OAAO,EAAE;AAC5E;;;;;;;;;;;;;;;;;;AC7HA,MAAa,4BAA4B;;;;;;;;;AAUzC,MAAa,0BAA0B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//#region src/policy/engine-enforcing.d.ts
|
|
2
|
+
declare function isEngineEnforcing(flags: {
|
|
3
|
+
engineEnforcementEnabled?: boolean | null;
|
|
4
|
+
enabled?: boolean | null;
|
|
5
|
+
}): boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/policy/fail-closed-response.d.ts
|
|
8
|
+
declare const FAIL_CLOSED_STATUS = 503;
|
|
9
|
+
declare const FAIL_CLOSED_BODY: {
|
|
10
|
+
readonly error: "Service temporarily unavailable";
|
|
11
|
+
readonly source: "checkpoint-middleware";
|
|
12
|
+
};
|
|
13
|
+
declare const FAIL_CLOSED_HEADERS: Readonly<Record<string, string>>;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/policy/legacy-carve-out.d.ts
|
|
16
|
+
declare const NO_EVIDENCE_CATEGORY = "no_evidence";
|
|
17
|
+
declare const NO_EVIDENCE_EXCLUSION_TERM = "principal.category != \"no_evidence\"";
|
|
18
|
+
declare const NO_EVIDENCE_EQUALITY_TERM = "principal.category == \"no_evidence\"";
|
|
19
|
+
declare function withNoEvidenceExclusion(cedar: string): string;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/policy/cedar-principal-scope.d.ts
|
|
22
|
+
type ProbeClass = 'human' | typeof NO_EVIDENCE_CATEGORY;
|
|
23
|
+
interface CedarCondition {
|
|
24
|
+
kind: 'when' | 'unless';
|
|
25
|
+
body: string;
|
|
26
|
+
}
|
|
27
|
+
interface CedarStatement {
|
|
28
|
+
effect: 'forbid' | 'permit';
|
|
29
|
+
blockStart: number;
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
text: string;
|
|
33
|
+
scope: string;
|
|
34
|
+
conditions: CedarCondition[];
|
|
35
|
+
annotations: string;
|
|
36
|
+
}
|
|
37
|
+
interface Facts {
|
|
38
|
+
category: string;
|
|
39
|
+
path?: string;
|
|
40
|
+
discountNaming?: boolean;
|
|
41
|
+
}
|
|
42
|
+
declare function parseCedarStatements(cedar: string): CedarStatement[];
|
|
43
|
+
declare function statementApplies(statement: CedarStatement, facts: Facts): boolean;
|
|
44
|
+
declare function statementId(statement: CedarStatement): string | undefined;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/policy/cedar-rule-match.d.ts
|
|
47
|
+
interface RequestFacts {
|
|
48
|
+
path?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
category?: string;
|
|
51
|
+
}
|
|
52
|
+
declare function pathLiteralsInBlock(block: string): string[];
|
|
53
|
+
declare function splitCedarBlocks(cedar: string): string[];
|
|
54
|
+
declare function blockEqualityLiterals(block: string, attr: string): string[];
|
|
55
|
+
declare function isForbidBlock(block: string): boolean;
|
|
56
|
+
declare function isUnnarrowedDenyBlock(block: string): boolean;
|
|
57
|
+
interface PolicyHazardAnalysis {
|
|
58
|
+
unnarrowedDenyFor(path: string, probe: ProbeClass): boolean;
|
|
59
|
+
explicitDenyFor(path: string, probe: ProbeClass): boolean;
|
|
60
|
+
humanHazard(path: string): boolean;
|
|
61
|
+
noEvidenceHazard(path: string): boolean;
|
|
62
|
+
noEvidenceNamed(path: string): boolean;
|
|
63
|
+
}
|
|
64
|
+
declare function analyzePolicySource(cedar: string): PolicyHazardAnalysis;
|
|
65
|
+
declare function pathHasUnnarrowedDenyRuleFor(cedar: string, path: string, probe: ProbeClass): boolean;
|
|
66
|
+
declare function pathHasExplicitDenyRuleFor(cedar: string, path: string, probe: ProbeClass): boolean;
|
|
67
|
+
declare function pathHasUnnarrowedDenyRule(cedar: string, path: string): boolean;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/policy/required-scopes.d.ts
|
|
70
|
+
declare function requiredScopesForRequest(policySource: string | null | undefined, request?: RequestFacts): string[];
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/policy/decision-policy-id.d.ts
|
|
73
|
+
interface DecisionLike {
|
|
74
|
+
kind: string;
|
|
75
|
+
policyId?: string;
|
|
76
|
+
reason?: {
|
|
77
|
+
kind: string;
|
|
78
|
+
policyId?: string;
|
|
79
|
+
};
|
|
80
|
+
params?: {
|
|
81
|
+
policyId?: string;
|
|
82
|
+
};
|
|
83
|
+
target?: {
|
|
84
|
+
policyId?: string;
|
|
85
|
+
};
|
|
86
|
+
payload?: {
|
|
87
|
+
policyId?: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
declare function decisionPolicyId(decision: DecisionLike): string | undefined;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/policy/approval-quorum.d.ts
|
|
93
|
+
interface ApprovalQuorum {
|
|
94
|
+
n: number;
|
|
95
|
+
approvers: string[];
|
|
96
|
+
}
|
|
97
|
+
declare function approvalQuorumForRequest(policySource: string | null | undefined, request?: RequestFacts): ApprovalQuorum | null;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/policy/step-up.d.ts
|
|
100
|
+
interface StepUpQuorumLike {
|
|
101
|
+
n: number;
|
|
102
|
+
approvers: string[];
|
|
103
|
+
}
|
|
104
|
+
type InvalidStepUpReason = 'invalid_step_up_quorum' | 'step_up_no_approvers';
|
|
105
|
+
type StepUpQuorumCheck = {
|
|
106
|
+
ok: true;
|
|
107
|
+
} | {
|
|
108
|
+
ok: false;
|
|
109
|
+
reason: InvalidStepUpReason;
|
|
110
|
+
};
|
|
111
|
+
declare function validateStepUpQuorum(quorum: StepUpQuorumLike): StepUpQuorumCheck;
|
|
112
|
+
//#endregion
|
|
113
|
+
export { FAIL_CLOSED_HEADERS as A, statementApplies as C, NO_EVIDENCE_EXCLUSION_TERM as D, NO_EVIDENCE_EQUALITY_TERM as E, isEngineEnforcing as M, withNoEvidenceExclusion as O, parseCedarStatements as S, NO_EVIDENCE_CATEGORY as T, pathHasUnnarrowedDenyRule as _, ApprovalQuorum as a, splitCedarBlocks as b, decisionPolicyId as c, RequestFacts as d, analyzePolicySource as f, pathHasExplicitDenyRuleFor as g, isUnnarrowedDenyBlock as h, validateStepUpQuorum as i, FAIL_CLOSED_STATUS as j, FAIL_CLOSED_BODY as k, requiredScopesForRequest as l, isForbidBlock as m, StepUpQuorumCheck as n, approvalQuorumForRequest as o, blockEqualityLiterals as p, StepUpQuorumLike as r, DecisionLike as s, InvalidStepUpReason as t, PolicyHazardAnalysis as u, pathHasUnnarrowedDenyRuleFor as v, statementId as w, ProbeClass as x, pathLiteralsInBlock as y };
|
|
114
|
+
//# sourceMappingURL=step-up-BjP--hG-.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-up-BjP--hG-.d.mts","names":[],"sources":["../src/policy/engine-enforcing.ts","../src/policy/fail-closed-response.ts","../src/policy/legacy-carve-out.ts","../src/policy/cedar-principal-scope.ts","../src/policy/cedar-rule-match.ts","../src/policy/required-scopes.ts","../src/policy/decision-policy-id.ts","../src/policy/approval-quorum.ts","../src/policy/step-up.ts"],"mappings":";iBAOgB,kBAAkB;EAChC;EACA;;;;cCTW;cAIA;WAAA;WAAA;;cAKA,qBAAqB,SAAS;;;cCL9B;cACA;cACA;iBAiPG,wBAAwB;;;KCvO5B,8BAA8B;UAIzB;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ;;UAGQ;EACR;EACA;EACA;;iBA6Cc,qBAAqB,gBAAgB;iBA0HrC,iBAAiB,WAAW,gBAAgB,OAAO;iBA+BnD,YAAY,WAAW;;;UC/MtB;EACf;EAEA;EAEA;;iBAgDc,oBAAoB;iBAiEpB,iBAAiB;iBAWjB,sBAAsB,eAAe;iBA+CrC,cAAc;iBAKd,sBAAsB;UAIrB;EACf,kBAAkB,cAAc,OAAO;EACvC,gBAAgB,cAAc,OAAO;EACrC,YAAY;EACZ,iBAAiB;EACjB,gBAAgB;;iBAGF,oBAAoB,gBAAgB;iBAcpC,6BACd,eACA,cACA,OAAO;iBAKO,2BACd,eACA,cACA,OAAO;iBAKO,0BAA0B,eAAe;;;iBC/NzC,yBACd,yCACA,UAAU;;;UCXK;EACf;EACA;EACA;IAAW;IAAc;;EACzB;IAAW;;EACX;IAAW;;EACX;IAAY;;;iBAGE,iBAAiB,UAAU;;;UCQ1B;EAEf;EAEA;;iBAGc,yBACd,yCACA,UAAU,eACT;;;UCZc;EACf;EACA;;KAOU;KAGA;EAAsB;;EAAe;EAAW,QAAQ;;iBAWpD,qBAAqB,QAAQ,mBAAmB"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
//#region src/policy/engine-enforcing.d.ts
|
|
2
|
+
declare function isEngineEnforcing(flags: {
|
|
3
|
+
engineEnforcementEnabled?: boolean | null;
|
|
4
|
+
enabled?: boolean | null;
|
|
5
|
+
}): boolean;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/policy/fail-closed-response.d.ts
|
|
8
|
+
declare const FAIL_CLOSED_STATUS = 503;
|
|
9
|
+
declare const FAIL_CLOSED_BODY: {
|
|
10
|
+
readonly error: "Service temporarily unavailable";
|
|
11
|
+
readonly source: "checkpoint-middleware";
|
|
12
|
+
};
|
|
13
|
+
declare const FAIL_CLOSED_HEADERS: Readonly<Record<string, string>>;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/policy/legacy-carve-out.d.ts
|
|
16
|
+
declare const NO_EVIDENCE_CATEGORY = "no_evidence";
|
|
17
|
+
declare const NO_EVIDENCE_EXCLUSION_TERM = "principal.category != \"no_evidence\"";
|
|
18
|
+
declare const NO_EVIDENCE_EQUALITY_TERM = "principal.category == \"no_evidence\"";
|
|
19
|
+
declare function withNoEvidenceExclusion(cedar: string): string;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/policy/cedar-principal-scope.d.ts
|
|
22
|
+
type ProbeClass = 'human' | typeof NO_EVIDENCE_CATEGORY;
|
|
23
|
+
interface CedarCondition {
|
|
24
|
+
kind: 'when' | 'unless';
|
|
25
|
+
body: string;
|
|
26
|
+
}
|
|
27
|
+
interface CedarStatement {
|
|
28
|
+
effect: 'forbid' | 'permit';
|
|
29
|
+
blockStart: number;
|
|
30
|
+
start: number;
|
|
31
|
+
end: number;
|
|
32
|
+
text: string;
|
|
33
|
+
scope: string;
|
|
34
|
+
conditions: CedarCondition[];
|
|
35
|
+
annotations: string;
|
|
36
|
+
}
|
|
37
|
+
interface Facts {
|
|
38
|
+
category: string;
|
|
39
|
+
path?: string;
|
|
40
|
+
discountNaming?: boolean;
|
|
41
|
+
}
|
|
42
|
+
declare function parseCedarStatements(cedar: string): CedarStatement[];
|
|
43
|
+
declare function statementApplies(statement: CedarStatement, facts: Facts): boolean;
|
|
44
|
+
declare function statementId(statement: CedarStatement): string | undefined;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/policy/cedar-rule-match.d.ts
|
|
47
|
+
interface RequestFacts {
|
|
48
|
+
path?: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
category?: string;
|
|
51
|
+
}
|
|
52
|
+
declare function pathLiteralsInBlock(block: string): string[];
|
|
53
|
+
declare function splitCedarBlocks(cedar: string): string[];
|
|
54
|
+
declare function blockEqualityLiterals(block: string, attr: string): string[];
|
|
55
|
+
declare function isForbidBlock(block: string): boolean;
|
|
56
|
+
declare function isUnnarrowedDenyBlock(block: string): boolean;
|
|
57
|
+
interface PolicyHazardAnalysis {
|
|
58
|
+
unnarrowedDenyFor(path: string, probe: ProbeClass): boolean;
|
|
59
|
+
explicitDenyFor(path: string, probe: ProbeClass): boolean;
|
|
60
|
+
humanHazard(path: string): boolean;
|
|
61
|
+
noEvidenceHazard(path: string): boolean;
|
|
62
|
+
noEvidenceNamed(path: string): boolean;
|
|
63
|
+
}
|
|
64
|
+
declare function analyzePolicySource(cedar: string): PolicyHazardAnalysis;
|
|
65
|
+
declare function pathHasUnnarrowedDenyRuleFor(cedar: string, path: string, probe: ProbeClass): boolean;
|
|
66
|
+
declare function pathHasExplicitDenyRuleFor(cedar: string, path: string, probe: ProbeClass): boolean;
|
|
67
|
+
declare function pathHasUnnarrowedDenyRule(cedar: string, path: string): boolean;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/policy/required-scopes.d.ts
|
|
70
|
+
declare function requiredScopesForRequest(policySource: string | null | undefined, request?: RequestFacts): string[];
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/policy/decision-policy-id.d.ts
|
|
73
|
+
interface DecisionLike {
|
|
74
|
+
kind: string;
|
|
75
|
+
policyId?: string;
|
|
76
|
+
reason?: {
|
|
77
|
+
kind: string;
|
|
78
|
+
policyId?: string;
|
|
79
|
+
};
|
|
80
|
+
params?: {
|
|
81
|
+
policyId?: string;
|
|
82
|
+
};
|
|
83
|
+
target?: {
|
|
84
|
+
policyId?: string;
|
|
85
|
+
};
|
|
86
|
+
payload?: {
|
|
87
|
+
policyId?: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
declare function decisionPolicyId(decision: DecisionLike): string | undefined;
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/policy/approval-quorum.d.ts
|
|
93
|
+
interface ApprovalQuorum {
|
|
94
|
+
n: number;
|
|
95
|
+
approvers: string[];
|
|
96
|
+
}
|
|
97
|
+
declare function approvalQuorumForRequest(policySource: string | null | undefined, request?: RequestFacts): ApprovalQuorum | null;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/policy/step-up.d.ts
|
|
100
|
+
interface StepUpQuorumLike {
|
|
101
|
+
n: number;
|
|
102
|
+
approvers: string[];
|
|
103
|
+
}
|
|
104
|
+
type InvalidStepUpReason = 'invalid_step_up_quorum' | 'step_up_no_approvers';
|
|
105
|
+
type StepUpQuorumCheck = {
|
|
106
|
+
ok: true;
|
|
107
|
+
} | {
|
|
108
|
+
ok: false;
|
|
109
|
+
reason: InvalidStepUpReason;
|
|
110
|
+
};
|
|
111
|
+
declare function validateStepUpQuorum(quorum: StepUpQuorumLike): StepUpQuorumCheck;
|
|
112
|
+
//#endregion
|
|
113
|
+
export { FAIL_CLOSED_HEADERS as A, statementApplies as C, NO_EVIDENCE_EXCLUSION_TERM as D, NO_EVIDENCE_EQUALITY_TERM as E, isEngineEnforcing as M, withNoEvidenceExclusion as O, parseCedarStatements as S, NO_EVIDENCE_CATEGORY as T, pathHasUnnarrowedDenyRule as _, ApprovalQuorum as a, splitCedarBlocks as b, decisionPolicyId as c, RequestFacts as d, analyzePolicySource as f, pathHasExplicitDenyRuleFor as g, isUnnarrowedDenyBlock as h, validateStepUpQuorum as i, FAIL_CLOSED_STATUS as j, FAIL_CLOSED_BODY as k, requiredScopesForRequest as l, isForbidBlock as m, StepUpQuorumCheck as n, approvalQuorumForRequest as o, blockEqualityLiterals as p, StepUpQuorumLike as r, DecisionLike as s, InvalidStepUpReason as t, PolicyHazardAnalysis as u, pathHasUnnarrowedDenyRuleFor as v, statementId as w, ProbeClass as x, pathLiteralsInBlock as y };
|
|
114
|
+
//# sourceMappingURL=step-up-BjP--hG-.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-up-BjP--hG-.d.ts","names":[],"sources":["../src/policy/engine-enforcing.ts","../src/policy/fail-closed-response.ts","../src/policy/legacy-carve-out.ts","../src/policy/cedar-principal-scope.ts","../src/policy/cedar-rule-match.ts","../src/policy/required-scopes.ts","../src/policy/decision-policy-id.ts","../src/policy/approval-quorum.ts","../src/policy/step-up.ts"],"mappings":";iBAOgB,kBAAkB;EAChC;EACA;;;;cCTW;cAIA;WAAA;WAAA;;cAKA,qBAAqB,SAAS;;;cCL9B;cACA;cACA;iBAiPG,wBAAwB;;;KCvO5B,8BAA8B;UAIzB;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA,YAAY;EACZ;;UAGQ;EACR;EACA;EACA;;iBA6Cc,qBAAqB,gBAAgB;iBA0HrC,iBAAiB,WAAW,gBAAgB,OAAO;iBA+BnD,YAAY,WAAW;;;UC/MtB;EACf;EAEA;EAEA;;iBAgDc,oBAAoB;iBAiEpB,iBAAiB;iBAWjB,sBAAsB,eAAe;iBA+CrC,cAAc;iBAKd,sBAAsB;UAIrB;EACf,kBAAkB,cAAc,OAAO;EACvC,gBAAgB,cAAc,OAAO;EACrC,YAAY;EACZ,iBAAiB;EACjB,gBAAgB;;iBAGF,oBAAoB,gBAAgB;iBAcpC,6BACd,eACA,cACA,OAAO;iBAKO,2BACd,eACA,cACA,OAAO;iBAKO,0BAA0B,eAAe;;;iBC/NzC,yBACd,yCACA,UAAU;;;UCXK;EACf;EACA;EACA;IAAW;IAAc;;EACzB;IAAW;;EACX;IAAW;;EACX;IAAY;;;iBAGE,iBAAiB,UAAU;;;UCQ1B;EAEf;EAEA;;iBAGc,yBACd,yCACA,UAAU,eACT;;;UCZc;EACf;EACA;;KAOU;KAGA;EAAsB;;EAAe;EAAW,QAAQ;;iBAWpD,qBAAqB,QAAQ,mBAAmB"}
|