@kya-os/checkpoint-nextjs 1.11.0 → 1.13.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/CHANGELOG.md +38 -0
- package/README.md +16 -8
- package/dist/{adapt-BdQ9R7Iw.mjs → adapt-BGEyLf44.mjs} +13 -3
- package/dist/adapt-BGEyLf44.mjs.map +1 -0
- package/dist/{adapt-CCSKGjVH.js → adapt-D2-OBY9M.js} +17 -1
- package/dist/{api-middleware-BWjokNis.d.mts → api-middleware-BtsYJU5u.d.mts} +2 -2
- package/dist/{api-middleware-BWjokNis.d.mts.map → api-middleware-BtsYJU5u.d.mts.map} +1 -1
- package/dist/{api-middleware-C-ngFX_8.mjs → api-middleware-DcUgTDv5.mjs} +4 -4
- package/dist/{api-middleware-C-ngFX_8.mjs.map → api-middleware-DcUgTDv5.mjs.map} +1 -1
- package/dist/{api-middleware-Bf3xmM9W.js → api-middleware-LhLqOapx.js} +3 -3
- package/dist/api-middleware.d.mts +1 -1
- package/dist/api-middleware.js +1 -1
- package/dist/api-middleware.mjs +1 -1
- package/dist/cedar-wasm.d.mts +1 -1
- package/dist/cedar-wasm.d.ts +1 -1
- package/dist/cedar-wasm.js +1 -1
- package/dist/cedar-wasm.mjs +1 -1
- package/dist/cedar-wasm.mjs.map +1 -1
- package/dist/config-CXS_-rRv.d.ts +95 -0
- package/dist/config-CXS_-rRv.d.ts.map +1 -0
- package/dist/config-DQ-VuHlJ.d.mts +95 -0
- package/dist/config-DQ-VuHlJ.d.mts.map +1 -0
- package/dist/engine-wasm.d.mts +1 -1
- package/dist/engine-wasm.d.ts +1 -1
- package/dist/engine-wasm.js +1 -1
- package/dist/engine-wasm.mjs +1 -1
- package/dist/engine-wasm.mjs.map +1 -1
- package/dist/index-edge.d.mts +4 -4
- package/dist/index-edge.d.ts +3 -3
- package/dist/index-edge.js +2 -2
- package/dist/index-edge.mjs +2 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/dist/middleware-bundler.d.mts +1 -1
- package/dist/middleware-bundler.d.ts +1 -1
- package/dist/middleware-bundler.js +3 -3
- package/dist/middleware-bundler.mjs +3 -3
- package/dist/middleware-bundler.mjs.map +1 -1
- package/dist/middleware-core-0s8y7UNN.js +203 -0
- package/dist/{middleware-core-Bol44X9C.d.ts → middleware-core-Cxb9Jh0a.d.mts} +4 -7
- package/dist/middleware-core-Cxb9Jh0a.d.mts.map +1 -0
- package/dist/middleware-core-DN_FLlaV.mjs +193 -0
- package/dist/middleware-core-DN_FLlaV.mjs.map +1 -0
- package/dist/{middleware-core-DycsbHUd.d.mts → middleware-core-DaNMjsib.d.ts} +4 -7
- package/dist/middleware-core-DaNMjsib.d.ts.map +1 -0
- package/dist/middleware-edge.d.mts +1 -1
- package/dist/middleware-edge.d.mts.map +1 -1
- package/dist/middleware-edge.d.ts +1 -1
- package/dist/middleware-edge.d.ts.map +1 -1
- package/dist/middleware-edge.js +21 -35
- package/dist/middleware-edge.mjs +21 -35
- package/dist/middleware-edge.mjs.map +1 -1
- package/dist/middleware-node-context-BvqrL2Ra.mjs +16 -0
- package/dist/middleware-node-context-BvqrL2Ra.mjs.map +1 -0
- package/dist/middleware-node-context-TRMTgp3y.js +20 -0
- package/dist/middleware-node.d.mts +2 -2
- package/dist/middleware-node.d.ts +2 -2
- package/dist/middleware-node.js +3 -3
- package/dist/middleware-node.mjs +3 -3
- package/dist/middleware-node.mjs.map +1 -1
- package/dist/public-api-BZ5Ahk6X.d.mts +5 -0
- package/dist/{public-api-CYsHrTQI.d.ts → public-api-DnTh8YEz.d.ts} +2 -2
- package/package.json +3 -3
- package/dist/adapt-BdQ9R7Iw.mjs.map +0 -1
- package/dist/config-CPP1RV0f.d.mts +0 -291
- package/dist/config-CPP1RV0f.d.mts.map +0 -1
- package/dist/config-DVgOFxJs.d.ts +0 -291
- package/dist/config-DVgOFxJs.d.ts.map +0 -1
- package/dist/middleware-core-B0jf5_Hm.mjs +0 -264
- package/dist/middleware-core-B0jf5_Hm.mjs.map +0 -1
- package/dist/middleware-core-Bol44X9C.d.ts.map +0 -1
- package/dist/middleware-core-CMc-2QkU.js +0 -274
- package/dist/middleware-core-DycsbHUd.d.mts.map +0 -1
- package/dist/middleware-node-context-591KsiYg.js +0 -39
- package/dist/middleware-node-context-D_ZyUEcA.mjs +0 -35
- package/dist/middleware-node-context-D_ZyUEcA.mjs.map +0 -1
- package/dist/public-api-DkG7pRE0.d.mts +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapt-BdQ9R7Iw.mjs","names":[],"sources":["../src/adapt.ts"],"sourcesContent":["/**\n * D.3 — `RenderedResponse` → `NextResponse` adapter.\n *\n * The host wrapper's *only* job on the outbound path: take the\n * transport-agnostic `RenderedResponse` Phase C's\n * `renderDecisionAsResponse` produces and translate it to a\n * `NextResponse`. Zero verdict decisions, zero engine I/O.\n *\n * Shared between the Node-runtime and Edge-runtime entries. The\n * branching here is identical in both — Next.js `NextResponse` has the\n * same API surface across runtimes; only the underlying response\n * primitive differs (Node http.ServerResponse vs Edge `Response`).\n *\n * Architectural pins per architect § 4.3 / § 4.4:\n *\n * 1. **Verdict-cookie format is contract.** Sites-1's Sonner toast\n * depends on `__checkpoint_verdict=%7B%22verdict%22%3A%22<v>%22...\n * %7D` (single URL-encoded JSON). Byte-format pinned by adapt.test.\n *\n * 2. **HTML-accepting clients → `/blocked` rewrite at status 200**\n * (so the page renders with the verdict cookie set; Sonner picks\n * up the cookie and shows the toast). Non-HTML clients → JSON 4xx.\n *\n * 3. **`X-Checkpoint-Engine` carries `result.engineInfo.name`** —\n * `checkpoint-engine-wasm` after Phase D ships. Brian's Sites-2\n * deviation note confirmed the `X-Checkpoint-*` prefix is canon.\n */\n\nimport { type NextRequest, NextResponse } from 'next/server.js';\n\nimport type { RenderedResponse } from '@kya-os/checkpoint-wasm-runtime/orchestrator';\nimport {\n VERDICT_COOKIE_NAME,\n BLOCKED_PATH,\n encodeVerdictCookie,\n acceptsHtml,\n classifyResponseShape,\n} from '@kya-os/checkpoint-shared/host-adapter';\nimport {\n FAIL_CLOSED_BODY,\n FAIL_CLOSED_HEADERS,\n FAIL_CLOSED_STATUS,\n} from '@kya-os/checkpoint-shared/policy/enforcement';\n\n/**\n * 503 (Retry-After, no-store) for an engine/pipeline fault. Never a 500 and\n * never a pass-through: an unverifiable request is not allowed.\n */\nexport function failClosedResponse(): NextResponse {\n return NextResponse.json(FAIL_CLOSED_BODY, {\n status: FAIL_CLOSED_STATUS,\n headers: FAIL_CLOSED_HEADERS,\n });\n}\n\n/**\n * Convert the engine's transport-agnostic `RenderedResponse` into a\n * `NextResponse`. Sites-1's Playwright suite is the regression gate;\n * any drift here is caught downstream.\n */\nexport function adaptToNextResponse(rendered: RenderedResponse, req: NextRequest): NextResponse {\n const clientAcceptsHtml = acceptsHtml(req.headers);\n const verdictCookie = encodeVerdictCookie(rendered);\n const shape = classifyResponseShape(rendered, clientAcceptsHtml);\n\n switch (shape) {\n case 'pass-through': {\n // Permit OR Observe-mode any-verdict.\n const res = NextResponse.next();\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'redirect': {\n // Decision::Redirect → 302 + Location.\n const target = new URL(rendered.headers.Location!);\n const res = NextResponse.redirect(target);\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'html-block': {\n // Sites-1 contract: HTML clients (browsers) need a renderable page\n // to show the rejection UI. The verdict cookie carries the reason;\n // the /blocked route reads it and renders the toast.\n const blockedUrl = new URL(BLOCKED_PATH, req.url);\n const res = NextResponse.rewrite(blockedUrl, { status: 200 });\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n\n case 'json-block': {\n // The orchestrator's RenderedResponse already supplies the correct\n // status (401/403/422/...); we just need to materialise the body.\n // application/problem+json (Instruct) uses the Content-Type from\n // rendered.headers; defaults to application/json for everything else.\n const body = rendered.body ?? {};\n const res = NextResponse.json(body, { status: rendered.status as number });\n applyHeaders(res, rendered);\n setVerdictCookie(res, verdictCookie);\n return res;\n }\n }\n}\n\n// -----------------------------------------------------------------------------\n// Helpers — Next.js-specific glue. The framework-agnostic primitives\n// (encodeVerdictCookie, acceptsHtml, classifyResponseShape,\n// VERDICT_COOKIE_NAME, BLOCKED_PATH) live in `@kya-os/checkpoint-shared`\n// so checkpoint-express + future host wrappers produce byte-identical\n// cookies and route HTML/JSON branching the same way.\n// -----------------------------------------------------------------------------\n\nfunction setVerdictCookie(res: NextResponse, value: string): void {\n // Path / SameSite / HttpOnly chosen for the Sonner-bridge use case:\n // path=/ so any route can read it, SameSite=Lax so first-party\n // navigations carry it, HttpOnly=false so the client-side toast JS\n // can read it (it's verdict UX, not a session token).\n res.cookies.set({\n name: VERDICT_COOKIE_NAME,\n value,\n path: '/',\n sameSite: 'lax',\n httpOnly: false,\n });\n}\n\nfunction applyHeaders(res: NextResponse, rendered: RenderedResponse): void {\n // NextResponse.next() / rewrite() / json() return responses with\n // some default headers; orchestrator headers (X-Checkpoint-*, Location)\n // override. We don't strip pre-existing headers — only set new ones.\n for (const [key, value] of Object.entries(rendered.headers)) {\n res.headers.set(key, value);\n }\n for (const [key, value] of rendered.headerEntries ?? []) {\n res.headers.append(key, value);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,qBAAmC;CACjD,OAAO,aAAa,KAAK,kBAAkB;EACzC,QAAQ;EACR,SAAS;CACX,CAAC;AACH;;;;;;AAOA,SAAgB,oBAAoB,UAA4B,KAAgC;CAC9F,MAAM,oBAAoB,YAAY,IAAI,OAAO;CACjD,MAAM,gBAAgB,oBAAoB,QAAQ;CAGlD,QAFc,sBAAsB,UAAU,iBAElC,GAAZ;EACE,KAAK,gBAAgB;GAEnB,MAAM,MAAM,aAAa,KAAK;GAC9B,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,YAAY;GAEf,MAAM,SAAS,IAAI,IAAI,SAAS,QAAQ,QAAS;GACjD,MAAM,MAAM,aAAa,SAAS,MAAM;GACxC,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,cAAc;GAIjB,MAAM,aAAa,IAAI,IAAI,cAAc,IAAI,GAAG;GAChD,MAAM,MAAM,aAAa,QAAQ,YAAY,EAAE,QAAQ,IAAI,CAAC;GAC5D,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;EAEA,KAAK,cAAc;GAKjB,MAAM,OAAO,SAAS,QAAQ,CAAC;GAC/B,MAAM,MAAM,aAAa,KAAK,MAAM,EAAE,QAAQ,SAAS,OAAiB,CAAC;GACzE,aAAa,KAAK,QAAQ;GAC1B,iBAAiB,KAAK,aAAa;GACnC,OAAO;EACT;CACF;AACF;AAUA,SAAS,iBAAiB,KAAmB,OAAqB;CAKhE,IAAI,QAAQ,IAAI;EACd,MAAM;EACN;EACA,MAAM;EACN,UAAU;EACV,UAAU;CACZ,CAAC;AACH;AAEA,SAAS,aAAa,KAAmB,UAAkC;CAIzE,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,OAAO,GACxD,IAAI,QAAQ,IAAI,KAAK,KAAK;CAE5B,KAAK,MAAM,CAAC,KAAK,UAAU,SAAS,iBAAiB,CAAC,GACpD,IAAI,QAAQ,OAAO,KAAK,KAAK;AAEjC"}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { BrowserPostureConfig } from "@kya-os/checkpoint-shared/browser-posture";
|
|
2
|
-
import { ComposedPolicyContext, RequestClaimStore } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
|
|
3
|
-
import { DidResolverAdapter, PolicyEvaluatorAdapter, ReputationOracleAdapter, StatusListCacheAdapter } from "@kya-os/checkpoint-wasm-runtime/adapters";
|
|
4
|
-
import { NextRequest } from "next/server.js";
|
|
5
|
-
import { ChallengeContextFailureEvent, ChallengeEnvelopeMode, ChallengeWireInput, ClientIpTrustPolicy } from "@kya-os/checkpoint-shared";
|
|
6
|
-
import { EnforcementMode, EngineConfig, VerifyResult } from "@kya-os/checkpoint-wasm-runtime/engine";
|
|
7
|
-
//#region src/config.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Configuration for `withCheckpoint`.
|
|
10
|
-
*/
|
|
11
|
-
interface CheckpointConfig {
|
|
12
|
-
/**
|
|
13
|
-
* Selects the infrastructure allowed to vouch for observed client addresses.
|
|
14
|
-
* Vercel headers are honored only inside its managed runtime (`VERCEL=1`).
|
|
15
|
-
* NextRequest exposes no socket peer, so generic proxy and Cloudflare origin
|
|
16
|
-
* profiles cannot authenticate that boundary and return no address. Use a
|
|
17
|
-
* transport-aware ingress, such as the Express adapter, for those profiles.
|
|
18
|
-
*/
|
|
19
|
-
clientIpPolicy?: ClientIpTrustPolicy;
|
|
20
|
-
/**
|
|
21
|
-
* Tenant identifier — typically the customer's dashboard hostname
|
|
22
|
-
* (e.g. `acme.checkpoint.example`). The PolicyEvaluator uses this
|
|
23
|
-
* to look up tenant policy from the dashboard.
|
|
24
|
-
*/
|
|
25
|
-
tenantHost: string;
|
|
26
|
-
/** Exact org DID used to verify the consent credential's audience. */
|
|
27
|
-
resourceOrgDid?: string;
|
|
28
|
-
/** Explicit trusted delegation issuers; otherwise resolved from project policy. */
|
|
29
|
-
trustedDelegationRoots?: string[];
|
|
30
|
-
/**
|
|
31
|
-
* `'enforce'` (default) blocks; `'observe'` passes everything
|
|
32
|
-
* through with `X-Checkpoint-Would-Have-Been` headers. Per Phase 0.2.
|
|
33
|
-
*
|
|
34
|
-
* @default 'enforce'
|
|
35
|
-
*/
|
|
36
|
-
enforcementMode?: EnforcementMode;
|
|
37
|
-
/**
|
|
38
|
-
* Challenge-emission envelope mode (draft-kya-http-02 §8.1 fetcher-200).
|
|
39
|
-
* `negotiated` serves a body-readable HTTP 200 step-up response to
|
|
40
|
-
* cooperative agents (fetchers that drop 4xx/5xx bodies), keeping the spec
|
|
41
|
-
* 401/422 for everyone else. Defaults to `negotiated` (#3530). A cooperative-UX
|
|
42
|
-
* bridge, NOT an access control.
|
|
43
|
-
*
|
|
44
|
-
* @default 'negotiated'
|
|
45
|
-
*/
|
|
46
|
-
delegationChallengeMode?: ChallengeEnvelopeMode;
|
|
47
|
-
/**
|
|
48
|
-
* Resolve a policy `Challenge`, or a block consent can remedy, into registered wire context.
|
|
49
|
-
* The callback performs any Authorization-Host registration asynchronously;
|
|
50
|
-
* the synchronous engine renderer never fabricates a sid, consent URI, or proof.
|
|
51
|
-
*/
|
|
52
|
-
resolveDelegationChallenge?: (context: {
|
|
53
|
-
result: VerifyResult;
|
|
54
|
-
request: NextRequest;
|
|
55
|
-
}) => ChallengeWireInput | undefined | Promise<ChallengeWireInput | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* Registration/resolution budget in milliseconds.
|
|
58
|
-
*
|
|
59
|
-
* @default 3000
|
|
60
|
-
*/
|
|
61
|
-
delegationChallengeTimeoutMs?: number;
|
|
62
|
-
/** Sanitized registration failure hook for metrics and operator warnings. */
|
|
63
|
-
onDelegationChallengeFailure?: (event: ChallengeContextFailureEvent) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Argus reputation oracle base URL. Omit to use the trust-by-default
|
|
66
|
-
* baseline (reputation defaults to 1.0; orchestrator logs a one-shot
|
|
67
|
-
* warning at first request).
|
|
68
|
-
*/
|
|
69
|
-
argusUrl?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Dashboard base URL for the composed policy fetch
|
|
72
|
-
* (`<dashboardUrl>/api/internal/policies/{projectId}`). Takes precedence over
|
|
73
|
-
* `baseUrl`; omit both to use the hosted dashboard.
|
|
74
|
-
*/
|
|
75
|
-
dashboardUrl?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Returned to the PolicyEvaluator for anonymous requests (no agent
|
|
78
|
-
* DID). Trust-by-default. Engine scale is `0.0` to `1.0`.
|
|
79
|
-
*
|
|
80
|
-
* @default 1.0
|
|
81
|
-
*/
|
|
82
|
-
reputationBaseline?: number;
|
|
83
|
-
/**
|
|
84
|
-
* Pre-built adapter instances. Production deployments use the
|
|
85
|
-
* factory-built defaults from `@kya-os/checkpoint-wasm-runtime/adapters`;
|
|
86
|
-
* tests use stubs. The factory composes any provided overrides over
|
|
87
|
-
* defaults — partial overrides are supported.
|
|
88
|
-
*/
|
|
89
|
-
adapters?: Partial<{
|
|
90
|
-
didResolver: DidResolverAdapter;
|
|
91
|
-
statusListCache: StatusListCacheAdapter;
|
|
92
|
-
reputationOracle: ReputationOracleAdapter;
|
|
93
|
-
policyEvaluator: PolicyEvaluatorAdapter;
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* Optional callback for the post-verdict path — fires after every
|
|
97
|
-
* verification, regardless of permit/block, with the full
|
|
98
|
-
* `VerifyResult`. Use for logging, dashboards, telemetry. Errors
|
|
99
|
-
* thrown here are swallowed so user code can't break the middleware
|
|
100
|
-
* response.
|
|
101
|
-
*/
|
|
102
|
-
onResult?: (result: VerifyResult, req: NextRequest) => void | Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Accept legacy `KYA-Delegation`-header envelope form alongside the
|
|
105
|
-
* canonical `_meta.proof.jws` body form. Default `false`.
|
|
106
|
-
*
|
|
107
|
-
* **When to enable** — customers whose agents pre-date Envelope-1
|
|
108
|
-
* (#2537) and ship KYA-OS proofs as `{protected,payload,signature}`
|
|
109
|
-
* JSON in a `KYA-Delegation` HTTP header. Post-Envelope-1 agents
|
|
110
|
-
* ship compact JWS in the request body's `_meta.proof.jws` field;
|
|
111
|
-
* those don't need this flag.
|
|
112
|
-
*
|
|
113
|
-
* Forwarded to the orchestrator's `VerifyRequestOpts.legacyEnvelopeFallback`.
|
|
114
|
-
* Both transports (header + body) are honored when this is `true`;
|
|
115
|
-
* the orchestrator's detection order is body first, then header
|
|
116
|
-
* (`packages/checkpoint-wasm-runtime/src/engine/orchestrator/build-agent-request.ts`).
|
|
117
|
-
*
|
|
118
|
-
* SDK-Envelope-Plumbing-1 (#2594). Added in `@kya-os/checkpoint-nextjs@1.1.0`.
|
|
119
|
-
*
|
|
120
|
-
* @default false
|
|
121
|
-
*/
|
|
122
|
-
legacyEnvelopeFallback?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Read the request body when `content-type` is `application/json` so
|
|
125
|
-
* the orchestrator can extract a KYA-OS envelope from
|
|
126
|
-
* `_meta.proof.jws`. Default `true`.
|
|
127
|
-
*
|
|
128
|
-
* **When to disable** — streaming middlewares that can't tolerate
|
|
129
|
-
* the `req.clone()` memory overhead (one full-body copy is buffered
|
|
130
|
-
* during the read). For those, set `false` and route KYA-OS
|
|
131
|
-
* envelopes through the `KYA-Delegation` header transport instead
|
|
132
|
-
* (requires `legacyEnvelopeFallback: true`).
|
|
133
|
-
*
|
|
134
|
-
* The clone preserves `req.body` for downstream handlers — disabling
|
|
135
|
-
* is a performance optimization, not a correctness fix.
|
|
136
|
-
*
|
|
137
|
-
* SDK-Envelope-Plumbing-1 (#2594). Added in `@kya-os/checkpoint-nextjs@1.1.0`.
|
|
138
|
-
*
|
|
139
|
-
* @default true
|
|
140
|
-
*/
|
|
141
|
-
drainJsonBody?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Engine-default behaviour knobs forwarded to every composed
|
|
144
|
-
* `ContextSpec`. Defaults to `{ tier3Action: 'monitor' }` —
|
|
145
|
-
* customer-onboarding-safe (tenant policy decides; engine doesn't
|
|
146
|
-
* short-circuit known-agent UAs with an engine-default Block).
|
|
147
|
-
*
|
|
148
|
-
* Opt into `{ tier3Action: 'block' }` when the host wants the
|
|
149
|
-
* calibrated engine-default block for KnownAiAgent / AiCrawler /
|
|
150
|
-
* HeadlessBrowser classifications BEFORE the tenant policy seam.
|
|
151
|
-
*
|
|
152
|
-
* Added in `@kya-os/checkpoint-nextjs@1.2.0` (Engine-Tier3-Monitor-
|
|
153
|
-
* Default, #2653 + this PR's plumbing follow-up).
|
|
154
|
-
*
|
|
155
|
-
* @default { tier3Action: 'monitor' }
|
|
156
|
-
*/
|
|
157
|
-
engineConfig?: EngineConfig;
|
|
158
|
-
/**
|
|
159
|
-
* Project API key. Required for detections to land in the dashboard
|
|
160
|
-
* — the engine verifies in-process via WASM, but the resulting
|
|
161
|
-
* `VerifyResult` only reaches the dashboard's `detections` table
|
|
162
|
-
* when this reporter is configured. Without it the verdict path
|
|
163
|
-
* works locally but the onboarding "Verify connection" check fails
|
|
164
|
-
* forever because no rows are ever written.
|
|
165
|
-
*
|
|
166
|
-
* Resolve from `process.env.CHECKPOINT_API_KEY` in the host app.
|
|
167
|
-
*
|
|
168
|
-
* Added in `@kya-os/checkpoint-nextjs@1.4.0`
|
|
169
|
-
* (SDK-Detection-Reporter-1).
|
|
170
|
-
*/
|
|
171
|
-
apiKey?: string;
|
|
172
|
-
/**
|
|
173
|
-
* Dashboard base URL. Override for staging or self-hosted dashboards.
|
|
174
|
-
*
|
|
175
|
-
* @default 'https://kya.vouched.id'
|
|
176
|
-
*/
|
|
177
|
-
baseUrl?: string;
|
|
178
|
-
/**
|
|
179
|
-
* Surface reporter errors via `console.warn`. Defaults to `false`.
|
|
180
|
-
* The reporter is fire-and-forget; enable during development to
|
|
181
|
-
* confirm `apiKey` / `baseUrl` are routed correctly.
|
|
182
|
-
*
|
|
183
|
-
* Also wires the composed-policy shadow-divergence + evaluation-error
|
|
184
|
-
* telemetry, and pipeline-failure logging (the 503 fail-closed path), to
|
|
185
|
-
* `console.warn`/`console.error` (otherwise silent).
|
|
186
|
-
*
|
|
187
|
-
* @default false
|
|
188
|
-
*/
|
|
189
|
-
debug?: boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Project id whose composed (/policy-compose) policy this middleware
|
|
192
|
-
* enforces. When set, the project's policy is fetched from the dashboard
|
|
193
|
-
* (`<dashboardUrl ?? baseUrl ?? default>/api/internal/policies/${projectId}`)
|
|
194
|
-
* and — if it carries a deployed Cedar bundle with `engineEnforcementEnabled`
|
|
195
|
-
* on — the kya-os-engine decision is enforced IN-PROCESS, byte-for-byte the
|
|
196
|
-
* same as the DNS Gateway. Omit to run detection + the structured policy only
|
|
197
|
-
* (fully back-compatible; purely additive).
|
|
198
|
-
*
|
|
199
|
-
* SHADOW-FIRST: with a deployed bundle but `engineEnforcementEnabled` off, the
|
|
200
|
-
* engine decision is computed + logged on divergence but does NOT act.
|
|
201
|
-
*
|
|
202
|
-
* **Node vs Edge:** composed enforcement is default-on under the Node runtime
|
|
203
|
-
* (`./node`). Under the Edge runtime (`./edge`) it additionally requires
|
|
204
|
-
* `cedarWasmModule` to be wired (see below) — otherwise the seam stays inert.
|
|
205
|
-
*
|
|
206
|
-
* Added in `@kya-os/checkpoint-nextjs@1.5.0` (@Policy middleware-Cedar, #3076).
|
|
207
|
-
*/
|
|
208
|
-
projectId?: string;
|
|
209
|
-
/** Signed browser risk; configure explicit route scopes to enable consent step-up. */
|
|
210
|
-
browserPosture?: BrowserPostureConfig;
|
|
211
|
-
/**
|
|
212
|
-
* Where accepted signed requests are claimed, so each is used once. Defaults
|
|
213
|
-
* to the dashboard's shared ledger when `apiKey` and `projectId` are set,
|
|
214
|
-
* otherwise to a store in this process or isolate (with a one-time warning,
|
|
215
|
-
* since a deployment with several instances needs a shared store). Pass
|
|
216
|
-
* `createLocalRequestClaimStore()` to choose the in-process store explicitly.
|
|
217
|
-
*/
|
|
218
|
-
requestClaimStore?: RequestClaimStore;
|
|
219
|
-
/**
|
|
220
|
-
* Policy-fetch cache TTL in seconds. Defaults to 300 (5 minutes). How long
|
|
221
|
-
* a fetched project policy is reused before the middleware refetches from
|
|
222
|
-
* the dashboard — i.e. the worst-case delay before a dashboard policy
|
|
223
|
-
* change takes effect on this host.
|
|
224
|
-
*
|
|
225
|
-
* `0` disables reuse entirely: every request fetches the policy (one
|
|
226
|
-
* origin round-trip per request). Use for demo/example sites where instant
|
|
227
|
-
* policy propagation matters more than latency; keep the default (or a
|
|
228
|
-
* small positive value like 5) for production and benchmark hosts.
|
|
229
|
-
*
|
|
230
|
-
* @default 300
|
|
231
|
-
*/
|
|
232
|
-
policyCacheTtlSeconds?: number;
|
|
233
|
-
/**
|
|
234
|
-
* Advanced / testing: inject a pre-built composed-policy context instead of
|
|
235
|
-
* letting `withCheckpoint` construct one from `projectId` + `baseUrl` +
|
|
236
|
-
* `apiKey`. Mirrors the `adapters` injection philosophy — production omits
|
|
237
|
-
* this. When set, it takes precedence over `projectId`.
|
|
238
|
-
*/
|
|
239
|
-
composedPolicyEnforcer?: ComposedPolicyContext;
|
|
240
|
-
/**
|
|
241
|
-
* EDGE runtime only. The Cedar build's `WebAssembly.Module`. Prefer passing
|
|
242
|
-
* it as `engineWasmModule` (see there); this field is kept so existing
|
|
243
|
-
* configs work. Passed alone it serves both roles, detection and policy, on
|
|
244
|
-
* one instance. Passed next to the engine-only build it runs as a second
|
|
245
|
-
* instance, and the Edge bundle carries the engine twice (`debug` logs a
|
|
246
|
-
* hint).
|
|
247
|
-
*
|
|
248
|
-
* Without a Cedar module the project's policy is still fetched and never
|
|
249
|
-
* skipped: with no Cedar policy nothing changes, a policy in shadow mode
|
|
250
|
-
* keeps the structured decision, and an enforcing policy answers every
|
|
251
|
-
* request 503 and logs which module is missing. The Node runtime ignores
|
|
252
|
-
* this field (it loads Cedar through `createPolicyEvaluator`).
|
|
253
|
-
*
|
|
254
|
-
* Added in `@kya-os/checkpoint-nextjs@1.5.0` (@Policy middleware-Cedar, #3076).
|
|
255
|
-
*/
|
|
256
|
-
cedarWasmModule?: WebAssembly.Module;
|
|
257
|
-
/**
|
|
258
|
-
* EDGE runtime only, and required there unless `cedarWasmModule` is set.
|
|
259
|
-
* The module the engine runs on, statically imported by the host:
|
|
260
|
-
*
|
|
261
|
-
* ```ts
|
|
262
|
-
* // Detection only:
|
|
263
|
-
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
264
|
-
* // Detection and the project's Cedar policy, on one module:
|
|
265
|
-
* import engineWasmModule from '@kya-os/checkpoint-nextjs/cedar-wasm';
|
|
266
|
-
*
|
|
267
|
-
* export default withCheckpoint({ tenantHost, projectId, engineWasmModule });
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* The Cedar build is the engine plus Cedar, so it replaces the engine-only
|
|
271
|
-
* build rather than adding to it; it is larger, which is why it is opt-in.
|
|
272
|
-
* A project whose Cedar policy is enforcing needs it on the Edge runtime.
|
|
273
|
-
*
|
|
274
|
-
* The Edge runtime does not let code compile WebAssembly from bytes, so the
|
|
275
|
-
* engine cannot fetch and compile its own binary there; the bundler has to
|
|
276
|
-
* hand it over as a compiled module. The Node runtime ignores this field.
|
|
277
|
-
*/
|
|
278
|
-
engineWasmModule?: WebAssembly.Module;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* `withCheckpoint` configuration for the Edge runtime (`./edge`): the engine
|
|
282
|
-
* needs a module, `engineWasmModule` or, on its own, `cedarWasmModule`.
|
|
283
|
-
*/
|
|
284
|
-
type CheckpointEdgeConfig = CheckpointConfig & ({
|
|
285
|
-
engineWasmModule: WebAssembly.Module;
|
|
286
|
-
} | {
|
|
287
|
-
cedarWasmModule: WebAssembly.Module;
|
|
288
|
-
});
|
|
289
|
-
//#endregion
|
|
290
|
-
export { CheckpointEdgeConfig as n, CheckpointConfig as t };
|
|
291
|
-
//# sourceMappingURL=config-CPP1RV0f.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CPP1RV0f.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;;;;UAoCiB;;;;;;;;EAQf,iBAAiB;;;;;;EAMjB;;EAEA;;EAEA;;;;;;;EAQA,kBAAkB;;;;;;;;;;EAWlB,0BAA0B;;;;;;EAO1B,8BAA8B;IAC5B,QAAQ;IACR,SAAS;QACL,iCAAiC,QAAQ;;;;;;EAO/C;;EAGA,gCAAgC,OAAO;;;;;;EAOvC;;;;;;EAOA;;;;;;;EAQA;;;;;;;EAQA,WAAW;IACT,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;;;;;;;;;EAUnB,YAAY,QAAQ,cAAc,KAAK,uBAAuB;;;;;;;;;;;;;;;;;;;;EAqB9D;;;;;;;;;;;;;;;;;;;EAoBA;;;;;;;;;;;;;;;;EAiBA,eAAe;;;;;;;;;;;;;;EAef;;;;;;EAOA;;;;;;;;;;;;EAaA;;;;;;;;;;;;;;;;;;;EAoBA;;EAEA,iBAAiB;;;;;;;;EAQjB,oBAAoB;;;;;;;;;;;;;;EAepB;;;;;;;EAQA,yBAAyB;;;;;;;;;;;;;;;;;EAkBzB,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;EAuB9B,mBAAmB,YAAY;;;;;;KAOrB,uBAAuB;EAC9B,kBAAkB,YAAY;;EAAa,iBAAiB,YAAY"}
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { ChallengeContextFailureEvent, ChallengeEnvelopeMode, ChallengeWireInput, ClientIpTrustPolicy } from "@kya-os/checkpoint-shared";
|
|
2
|
-
import { NextRequest } from "next/server.js";
|
|
3
|
-
import { BrowserPostureConfig } from "@kya-os/checkpoint-shared/browser-posture";
|
|
4
|
-
import { ComposedPolicyContext, RequestClaimStore } from "@kya-os/checkpoint-wasm-runtime/composed-policy";
|
|
5
|
-
import { DidResolverAdapter, PolicyEvaluatorAdapter, ReputationOracleAdapter, StatusListCacheAdapter } from "@kya-os/checkpoint-wasm-runtime/adapters";
|
|
6
|
-
import { EnforcementMode, EngineConfig, VerifyResult } from "@kya-os/checkpoint-wasm-runtime/engine";
|
|
7
|
-
//#region src/config.d.ts
|
|
8
|
-
/**
|
|
9
|
-
* Configuration for `withCheckpoint`.
|
|
10
|
-
*/
|
|
11
|
-
interface CheckpointConfig {
|
|
12
|
-
/**
|
|
13
|
-
* Selects the infrastructure allowed to vouch for observed client addresses.
|
|
14
|
-
* Vercel headers are honored only inside its managed runtime (`VERCEL=1`).
|
|
15
|
-
* NextRequest exposes no socket peer, so generic proxy and Cloudflare origin
|
|
16
|
-
* profiles cannot authenticate that boundary and return no address. Use a
|
|
17
|
-
* transport-aware ingress, such as the Express adapter, for those profiles.
|
|
18
|
-
*/
|
|
19
|
-
clientIpPolicy?: ClientIpTrustPolicy;
|
|
20
|
-
/**
|
|
21
|
-
* Tenant identifier — typically the customer's dashboard hostname
|
|
22
|
-
* (e.g. `acme.checkpoint.example`). The PolicyEvaluator uses this
|
|
23
|
-
* to look up tenant policy from the dashboard.
|
|
24
|
-
*/
|
|
25
|
-
tenantHost: string;
|
|
26
|
-
/** Exact org DID used to verify the consent credential's audience. */
|
|
27
|
-
resourceOrgDid?: string;
|
|
28
|
-
/** Explicit trusted delegation issuers; otherwise resolved from project policy. */
|
|
29
|
-
trustedDelegationRoots?: string[];
|
|
30
|
-
/**
|
|
31
|
-
* `'enforce'` (default) blocks; `'observe'` passes everything
|
|
32
|
-
* through with `X-Checkpoint-Would-Have-Been` headers. Per Phase 0.2.
|
|
33
|
-
*
|
|
34
|
-
* @default 'enforce'
|
|
35
|
-
*/
|
|
36
|
-
enforcementMode?: EnforcementMode;
|
|
37
|
-
/**
|
|
38
|
-
* Challenge-emission envelope mode (draft-kya-http-02 §8.1 fetcher-200).
|
|
39
|
-
* `negotiated` serves a body-readable HTTP 200 step-up response to
|
|
40
|
-
* cooperative agents (fetchers that drop 4xx/5xx bodies), keeping the spec
|
|
41
|
-
* 401/422 for everyone else. Defaults to `negotiated` (#3530). A cooperative-UX
|
|
42
|
-
* bridge, NOT an access control.
|
|
43
|
-
*
|
|
44
|
-
* @default 'negotiated'
|
|
45
|
-
*/
|
|
46
|
-
delegationChallengeMode?: ChallengeEnvelopeMode;
|
|
47
|
-
/**
|
|
48
|
-
* Resolve a policy `Challenge`, or a block consent can remedy, into registered wire context.
|
|
49
|
-
* The callback performs any Authorization-Host registration asynchronously;
|
|
50
|
-
* the synchronous engine renderer never fabricates a sid, consent URI, or proof.
|
|
51
|
-
*/
|
|
52
|
-
resolveDelegationChallenge?: (context: {
|
|
53
|
-
result: VerifyResult;
|
|
54
|
-
request: NextRequest;
|
|
55
|
-
}) => ChallengeWireInput | undefined | Promise<ChallengeWireInput | undefined>;
|
|
56
|
-
/**
|
|
57
|
-
* Registration/resolution budget in milliseconds.
|
|
58
|
-
*
|
|
59
|
-
* @default 3000
|
|
60
|
-
*/
|
|
61
|
-
delegationChallengeTimeoutMs?: number;
|
|
62
|
-
/** Sanitized registration failure hook for metrics and operator warnings. */
|
|
63
|
-
onDelegationChallengeFailure?: (event: ChallengeContextFailureEvent) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Argus reputation oracle base URL. Omit to use the trust-by-default
|
|
66
|
-
* baseline (reputation defaults to 1.0; orchestrator logs a one-shot
|
|
67
|
-
* warning at first request).
|
|
68
|
-
*/
|
|
69
|
-
argusUrl?: string;
|
|
70
|
-
/**
|
|
71
|
-
* Dashboard base URL for the composed policy fetch
|
|
72
|
-
* (`<dashboardUrl>/api/internal/policies/{projectId}`). Takes precedence over
|
|
73
|
-
* `baseUrl`; omit both to use the hosted dashboard.
|
|
74
|
-
*/
|
|
75
|
-
dashboardUrl?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Returned to the PolicyEvaluator for anonymous requests (no agent
|
|
78
|
-
* DID). Trust-by-default. Engine scale is `0.0` to `1.0`.
|
|
79
|
-
*
|
|
80
|
-
* @default 1.0
|
|
81
|
-
*/
|
|
82
|
-
reputationBaseline?: number;
|
|
83
|
-
/**
|
|
84
|
-
* Pre-built adapter instances. Production deployments use the
|
|
85
|
-
* factory-built defaults from `@kya-os/checkpoint-wasm-runtime/adapters`;
|
|
86
|
-
* tests use stubs. The factory composes any provided overrides over
|
|
87
|
-
* defaults — partial overrides are supported.
|
|
88
|
-
*/
|
|
89
|
-
adapters?: Partial<{
|
|
90
|
-
didResolver: DidResolverAdapter;
|
|
91
|
-
statusListCache: StatusListCacheAdapter;
|
|
92
|
-
reputationOracle: ReputationOracleAdapter;
|
|
93
|
-
policyEvaluator: PolicyEvaluatorAdapter;
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* Optional callback for the post-verdict path — fires after every
|
|
97
|
-
* verification, regardless of permit/block, with the full
|
|
98
|
-
* `VerifyResult`. Use for logging, dashboards, telemetry. Errors
|
|
99
|
-
* thrown here are swallowed so user code can't break the middleware
|
|
100
|
-
* response.
|
|
101
|
-
*/
|
|
102
|
-
onResult?: (result: VerifyResult, req: NextRequest) => void | Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Accept legacy `KYA-Delegation`-header envelope form alongside the
|
|
105
|
-
* canonical `_meta.proof.jws` body form. Default `false`.
|
|
106
|
-
*
|
|
107
|
-
* **When to enable** — customers whose agents pre-date Envelope-1
|
|
108
|
-
* (#2537) and ship KYA-OS proofs as `{protected,payload,signature}`
|
|
109
|
-
* JSON in a `KYA-Delegation` HTTP header. Post-Envelope-1 agents
|
|
110
|
-
* ship compact JWS in the request body's `_meta.proof.jws` field;
|
|
111
|
-
* those don't need this flag.
|
|
112
|
-
*
|
|
113
|
-
* Forwarded to the orchestrator's `VerifyRequestOpts.legacyEnvelopeFallback`.
|
|
114
|
-
* Both transports (header + body) are honored when this is `true`;
|
|
115
|
-
* the orchestrator's detection order is body first, then header
|
|
116
|
-
* (`packages/checkpoint-wasm-runtime/src/engine/orchestrator/build-agent-request.ts`).
|
|
117
|
-
*
|
|
118
|
-
* SDK-Envelope-Plumbing-1 (#2594). Added in `@kya-os/checkpoint-nextjs@1.1.0`.
|
|
119
|
-
*
|
|
120
|
-
* @default false
|
|
121
|
-
*/
|
|
122
|
-
legacyEnvelopeFallback?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Read the request body when `content-type` is `application/json` so
|
|
125
|
-
* the orchestrator can extract a KYA-OS envelope from
|
|
126
|
-
* `_meta.proof.jws`. Default `true`.
|
|
127
|
-
*
|
|
128
|
-
* **When to disable** — streaming middlewares that can't tolerate
|
|
129
|
-
* the `req.clone()` memory overhead (one full-body copy is buffered
|
|
130
|
-
* during the read). For those, set `false` and route KYA-OS
|
|
131
|
-
* envelopes through the `KYA-Delegation` header transport instead
|
|
132
|
-
* (requires `legacyEnvelopeFallback: true`).
|
|
133
|
-
*
|
|
134
|
-
* The clone preserves `req.body` for downstream handlers — disabling
|
|
135
|
-
* is a performance optimization, not a correctness fix.
|
|
136
|
-
*
|
|
137
|
-
* SDK-Envelope-Plumbing-1 (#2594). Added in `@kya-os/checkpoint-nextjs@1.1.0`.
|
|
138
|
-
*
|
|
139
|
-
* @default true
|
|
140
|
-
*/
|
|
141
|
-
drainJsonBody?: boolean;
|
|
142
|
-
/**
|
|
143
|
-
* Engine-default behaviour knobs forwarded to every composed
|
|
144
|
-
* `ContextSpec`. Defaults to `{ tier3Action: 'monitor' }` —
|
|
145
|
-
* customer-onboarding-safe (tenant policy decides; engine doesn't
|
|
146
|
-
* short-circuit known-agent UAs with an engine-default Block).
|
|
147
|
-
*
|
|
148
|
-
* Opt into `{ tier3Action: 'block' }` when the host wants the
|
|
149
|
-
* calibrated engine-default block for KnownAiAgent / AiCrawler /
|
|
150
|
-
* HeadlessBrowser classifications BEFORE the tenant policy seam.
|
|
151
|
-
*
|
|
152
|
-
* Added in `@kya-os/checkpoint-nextjs@1.2.0` (Engine-Tier3-Monitor-
|
|
153
|
-
* Default, #2653 + this PR's plumbing follow-up).
|
|
154
|
-
*
|
|
155
|
-
* @default { tier3Action: 'monitor' }
|
|
156
|
-
*/
|
|
157
|
-
engineConfig?: EngineConfig;
|
|
158
|
-
/**
|
|
159
|
-
* Project API key. Required for detections to land in the dashboard
|
|
160
|
-
* — the engine verifies in-process via WASM, but the resulting
|
|
161
|
-
* `VerifyResult` only reaches the dashboard's `detections` table
|
|
162
|
-
* when this reporter is configured. Without it the verdict path
|
|
163
|
-
* works locally but the onboarding "Verify connection" check fails
|
|
164
|
-
* forever because no rows are ever written.
|
|
165
|
-
*
|
|
166
|
-
* Resolve from `process.env.CHECKPOINT_API_KEY` in the host app.
|
|
167
|
-
*
|
|
168
|
-
* Added in `@kya-os/checkpoint-nextjs@1.4.0`
|
|
169
|
-
* (SDK-Detection-Reporter-1).
|
|
170
|
-
*/
|
|
171
|
-
apiKey?: string;
|
|
172
|
-
/**
|
|
173
|
-
* Dashboard base URL. Override for staging or self-hosted dashboards.
|
|
174
|
-
*
|
|
175
|
-
* @default 'https://kya.vouched.id'
|
|
176
|
-
*/
|
|
177
|
-
baseUrl?: string;
|
|
178
|
-
/**
|
|
179
|
-
* Surface reporter errors via `console.warn`. Defaults to `false`.
|
|
180
|
-
* The reporter is fire-and-forget; enable during development to
|
|
181
|
-
* confirm `apiKey` / `baseUrl` are routed correctly.
|
|
182
|
-
*
|
|
183
|
-
* Also wires the composed-policy shadow-divergence + evaluation-error
|
|
184
|
-
* telemetry, and pipeline-failure logging (the 503 fail-closed path), to
|
|
185
|
-
* `console.warn`/`console.error` (otherwise silent).
|
|
186
|
-
*
|
|
187
|
-
* @default false
|
|
188
|
-
*/
|
|
189
|
-
debug?: boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Project id whose composed (/policy-compose) policy this middleware
|
|
192
|
-
* enforces. When set, the project's policy is fetched from the dashboard
|
|
193
|
-
* (`<dashboardUrl ?? baseUrl ?? default>/api/internal/policies/${projectId}`)
|
|
194
|
-
* and — if it carries a deployed Cedar bundle with `engineEnforcementEnabled`
|
|
195
|
-
* on — the kya-os-engine decision is enforced IN-PROCESS, byte-for-byte the
|
|
196
|
-
* same as the DNS Gateway. Omit to run detection + the structured policy only
|
|
197
|
-
* (fully back-compatible; purely additive).
|
|
198
|
-
*
|
|
199
|
-
* SHADOW-FIRST: with a deployed bundle but `engineEnforcementEnabled` off, the
|
|
200
|
-
* engine decision is computed + logged on divergence but does NOT act.
|
|
201
|
-
*
|
|
202
|
-
* **Node vs Edge:** composed enforcement is default-on under the Node runtime
|
|
203
|
-
* (`./node`). Under the Edge runtime (`./edge`) it additionally requires
|
|
204
|
-
* `cedarWasmModule` to be wired (see below) — otherwise the seam stays inert.
|
|
205
|
-
*
|
|
206
|
-
* Added in `@kya-os/checkpoint-nextjs@1.5.0` (@Policy middleware-Cedar, #3076).
|
|
207
|
-
*/
|
|
208
|
-
projectId?: string;
|
|
209
|
-
/** Signed browser risk; configure explicit route scopes to enable consent step-up. */
|
|
210
|
-
browserPosture?: BrowserPostureConfig;
|
|
211
|
-
/**
|
|
212
|
-
* Where accepted signed requests are claimed, so each is used once. Defaults
|
|
213
|
-
* to the dashboard's shared ledger when `apiKey` and `projectId` are set,
|
|
214
|
-
* otherwise to a store in this process or isolate (with a one-time warning,
|
|
215
|
-
* since a deployment with several instances needs a shared store). Pass
|
|
216
|
-
* `createLocalRequestClaimStore()` to choose the in-process store explicitly.
|
|
217
|
-
*/
|
|
218
|
-
requestClaimStore?: RequestClaimStore;
|
|
219
|
-
/**
|
|
220
|
-
* Policy-fetch cache TTL in seconds. Defaults to 300 (5 minutes). How long
|
|
221
|
-
* a fetched project policy is reused before the middleware refetches from
|
|
222
|
-
* the dashboard — i.e. the worst-case delay before a dashboard policy
|
|
223
|
-
* change takes effect on this host.
|
|
224
|
-
*
|
|
225
|
-
* `0` disables reuse entirely: every request fetches the policy (one
|
|
226
|
-
* origin round-trip per request). Use for demo/example sites where instant
|
|
227
|
-
* policy propagation matters more than latency; keep the default (or a
|
|
228
|
-
* small positive value like 5) for production and benchmark hosts.
|
|
229
|
-
*
|
|
230
|
-
* @default 300
|
|
231
|
-
*/
|
|
232
|
-
policyCacheTtlSeconds?: number;
|
|
233
|
-
/**
|
|
234
|
-
* Advanced / testing: inject a pre-built composed-policy context instead of
|
|
235
|
-
* letting `withCheckpoint` construct one from `projectId` + `baseUrl` +
|
|
236
|
-
* `apiKey`. Mirrors the `adapters` injection philosophy — production omits
|
|
237
|
-
* this. When set, it takes precedence over `projectId`.
|
|
238
|
-
*/
|
|
239
|
-
composedPolicyEnforcer?: ComposedPolicyContext;
|
|
240
|
-
/**
|
|
241
|
-
* EDGE runtime only. The Cedar build's `WebAssembly.Module`. Prefer passing
|
|
242
|
-
* it as `engineWasmModule` (see there); this field is kept so existing
|
|
243
|
-
* configs work. Passed alone it serves both roles, detection and policy, on
|
|
244
|
-
* one instance. Passed next to the engine-only build it runs as a second
|
|
245
|
-
* instance, and the Edge bundle carries the engine twice (`debug` logs a
|
|
246
|
-
* hint).
|
|
247
|
-
*
|
|
248
|
-
* Without a Cedar module the project's policy is still fetched and never
|
|
249
|
-
* skipped: with no Cedar policy nothing changes, a policy in shadow mode
|
|
250
|
-
* keeps the structured decision, and an enforcing policy answers every
|
|
251
|
-
* request 503 and logs which module is missing. The Node runtime ignores
|
|
252
|
-
* this field (it loads Cedar through `createPolicyEvaluator`).
|
|
253
|
-
*
|
|
254
|
-
* Added in `@kya-os/checkpoint-nextjs@1.5.0` (@Policy middleware-Cedar, #3076).
|
|
255
|
-
*/
|
|
256
|
-
cedarWasmModule?: WebAssembly.Module;
|
|
257
|
-
/**
|
|
258
|
-
* EDGE runtime only, and required there unless `cedarWasmModule` is set.
|
|
259
|
-
* The module the engine runs on, statically imported by the host:
|
|
260
|
-
*
|
|
261
|
-
* ```ts
|
|
262
|
-
* // Detection only:
|
|
263
|
-
* import engineWasmModule from '@kya-os/checkpoint-nextjs/engine-wasm';
|
|
264
|
-
* // Detection and the project's Cedar policy, on one module:
|
|
265
|
-
* import engineWasmModule from '@kya-os/checkpoint-nextjs/cedar-wasm';
|
|
266
|
-
*
|
|
267
|
-
* export default withCheckpoint({ tenantHost, projectId, engineWasmModule });
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* The Cedar build is the engine plus Cedar, so it replaces the engine-only
|
|
271
|
-
* build rather than adding to it; it is larger, which is why it is opt-in.
|
|
272
|
-
* A project whose Cedar policy is enforcing needs it on the Edge runtime.
|
|
273
|
-
*
|
|
274
|
-
* The Edge runtime does not let code compile WebAssembly from bytes, so the
|
|
275
|
-
* engine cannot fetch and compile its own binary there; the bundler has to
|
|
276
|
-
* hand it over as a compiled module. The Node runtime ignores this field.
|
|
277
|
-
*/
|
|
278
|
-
engineWasmModule?: WebAssembly.Module;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* `withCheckpoint` configuration for the Edge runtime (`./edge`): the engine
|
|
282
|
-
* needs a module, `engineWasmModule` or, on its own, `cedarWasmModule`.
|
|
283
|
-
*/
|
|
284
|
-
type CheckpointEdgeConfig = CheckpointConfig & ({
|
|
285
|
-
engineWasmModule: WebAssembly.Module;
|
|
286
|
-
} | {
|
|
287
|
-
cedarWasmModule: WebAssembly.Module;
|
|
288
|
-
});
|
|
289
|
-
//#endregion
|
|
290
|
-
export { CheckpointEdgeConfig as n, CheckpointConfig as t };
|
|
291
|
-
//# sourceMappingURL=config-DVgOFxJs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-DVgOFxJs.d.ts","names":[],"sources":["../src/config.ts"],"mappings":";;;;;;;;;;UAoCiB;;;;;;;;EAQf,iBAAiB;;;;;;EAMjB;;EAEA;;EAEA;;;;;;;EAQA,kBAAkB;;;;;;;;;;EAWlB,0BAA0B;;;;;;EAO1B,8BAA8B;IAC5B,QAAQ;IACR,SAAS;QACL,iCAAiC,QAAQ;;;;;;EAO/C;;EAGA,gCAAgC,OAAO;;;;;;EAOvC;;;;;;EAOA;;;;;;;EAQA;;;;;;;EAQA,WAAW;IACT,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,iBAAiB;;;;;;;;;EAUnB,YAAY,QAAQ,cAAc,KAAK,uBAAuB;;;;;;;;;;;;;;;;;;;;EAqB9D;;;;;;;;;;;;;;;;;;;EAoBA;;;;;;;;;;;;;;;;EAiBA,eAAe;;;;;;;;;;;;;;EAef;;;;;;EAOA;;;;;;;;;;;;EAaA;;;;;;;;;;;;;;;;;;;EAoBA;;EAEA,iBAAiB;;;;;;;;EAQjB,oBAAoB;;;;;;;;;;;;;;EAepB;;;;;;;EAQA,yBAAyB;;;;;;;;;;;;;;;;;EAkBzB,kBAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;EAuB9B,mBAAmB,YAAY;;;;;;KAOrB,uBAAuB;EAC9B,kBAAkB,YAAY;;EAAa,iBAAiB,YAAY"}
|