@kya-os/checkpoint-shared 1.3.0 → 1.3.1

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 (52) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/beacon-types/index.d.mts +3 -1
  3. package/dist/beacon-types/index.d.ts +3 -1
  4. package/dist/beacon-types/index.js +15 -2
  5. package/dist/beacon-types/index.mjs +15 -2
  6. package/dist/browser-posture-report.d.mts +85 -0
  7. package/dist/browser-posture-report.d.ts +85 -0
  8. package/dist/browser-posture-report.js +1 -0
  9. package/dist/browser-posture-report.mjs +1 -0
  10. package/dist/browser-posture.d.mts +114 -0
  11. package/dist/browser-posture.d.ts +114 -0
  12. package/dist/browser-posture.js +4204 -0
  13. package/dist/browser-posture.mjs +4187 -0
  14. package/dist/browser.d.mts +30 -1
  15. package/dist/browser.d.ts +30 -1
  16. package/dist/browser.js +1 -1
  17. package/dist/browser.mjs +1 -1
  18. package/dist/errors/index.d.mts +104 -0
  19. package/dist/errors/index.d.ts +104 -0
  20. package/dist/errors/index.js +338 -0
  21. package/dist/errors/index.mjs +333 -0
  22. package/dist/gateway/index.d.mts +6 -1
  23. package/dist/gateway/index.d.ts +6 -1
  24. package/dist/gateway/index.js +4 -0
  25. package/dist/gateway/index.mjs +4 -1
  26. package/dist/index.d.mts +769 -146
  27. package/dist/index.d.ts +769 -146
  28. package/dist/index.js +926 -282
  29. package/dist/index.mjs +903 -283
  30. package/dist/signals/index.d.mts +1 -1
  31. package/dist/signals/index.d.ts +1 -1
  32. package/dist/signals/index.js +95 -2
  33. package/dist/signals/index.mjs +95 -2
  34. package/fixtures/client-ip-resolution.json +103 -0
  35. package/fixtures/detection/reason-codes.json +35 -0
  36. package/fixtures/detection/signal-exposure-example.json +62 -0
  37. package/fixtures/kya-http/README.md +112 -0
  38. package/fixtures/kya-http/challenge-proof.canonical.json +25 -0
  39. package/fixtures/kya-http/challenge.approval-quorum.json +37 -0
  40. package/fixtures/kya-http/challenge.delegation.fetcher-200.json +55 -0
  41. package/fixtures/kya-http/challenge.delegation.full.json +81 -0
  42. package/fixtures/kya-http/challenge.delegation.minimal.json +57 -0
  43. package/fixtures/kya-http/error-codes.json +35 -0
  44. package/fixtures/kya-http/fetcher-200-predicate.vectors.json +72 -0
  45. package/fixtures/kya-http/negative.challenges.json +54 -0
  46. package/fixtures/kya-http/pickup.transcript.json +96 -0
  47. package/fixtures/kya-http/pickup.transcript.quorum.json +156 -0
  48. package/fixtures/kya-http/protected-resource-metadata.full.json +30 -0
  49. package/fixtures/kya-http/protected-resource-metadata.global.json +28 -0
  50. package/fixtures/kya-http/registration.request.json +33 -0
  51. package/fixtures/kya-http/registration.response.json +32 -0
  52. package/package.json +20 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @kya-os/checkpoint-shared
2
2
 
3
+ ## Unreleased — error registry single source of truth (#4792)
4
+
5
+ - Extended the shared `ERROR_CODES` registry with every v1 error code emitted
6
+ across apps/web routes: `BILLING_ERRORS`, `RESOURCE_ERRORS`,
7
+ `POLICY_ERRORS`, `BARE_ERRORS`, and `LOWERCASE_ERRORS` are new groups, and
8
+ `VALIDATION_ERRORS`, `PERMISSION_ERRORS`, `INTERNAL_ERRORS`, and
9
+ `PIXEL_ERRORS` gained new codes.
10
+ - Added `pickErrorCodes`, a typed picker that selects a subset of the
11
+ registry by key while preserving each wire string's literal type.
12
+ - Added the `./errors` subpath: a pure entrypoint re-exporting only the
13
+ registry and picker, with no dependency on the rest of the barrel.
14
+
15
+ ## Unreleased — client-IP resolution (#4794)
16
+
17
+ - Added the runtime-agnostic client-IP normalizer and trust resolver.
18
+ - Added shared Vercel, Cloudflare, trusted-proxy, direct, and authenticated
19
+ explicit-address policies with provenance and trust metadata.
20
+ - Added language-neutral resolution fixtures consumed by TypeScript and .NET.
21
+
3
22
  ## 1.2.0 — 2026-05-19
4
23
 
5
24
  F-19 vocabulary rename (additive, dual-label deprecation window).
@@ -78,6 +78,7 @@ interface BeaconConfig {
78
78
  retryAttempts?: number;
79
79
  retryDelay?: number;
80
80
  useWorker?: boolean;
81
+ enableWebWorker?: boolean;
81
82
  workerUrl?: string;
82
83
  workerConfig?: WorkerConfig;
83
84
  lazySignalsUrl?: string;
@@ -328,7 +329,7 @@ interface WorkerPoolConfig {
328
329
  scaleUpThreshold?: number;
329
330
  scaleDownThreshold?: number;
330
331
  }
331
- type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error';
332
+ type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error' | 'response';
332
333
  type ProtocolVersion = '1.0' | '1.1' | '2.0';
333
334
  interface BeaconWorkerMessage {
334
335
  type: BeaconWorkerMessageType;
@@ -355,6 +356,7 @@ interface WorkerConfig {
355
356
  taskTimeout?: number;
356
357
  fallbackDelay?: number;
357
358
  enableFallback?: boolean;
359
+ initTimeoutMs?: number;
358
360
  }
359
361
  interface CircuitBreakerConfig {
360
362
  threshold: number;
@@ -78,6 +78,7 @@ interface BeaconConfig {
78
78
  retryAttempts?: number;
79
79
  retryDelay?: number;
80
80
  useWorker?: boolean;
81
+ enableWebWorker?: boolean;
81
82
  workerUrl?: string;
82
83
  workerConfig?: WorkerConfig;
83
84
  lazySignalsUrl?: string;
@@ -328,7 +329,7 @@ interface WorkerPoolConfig {
328
329
  scaleUpThreshold?: number;
329
330
  scaleDownThreshold?: number;
330
331
  }
331
- type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error';
332
+ type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error' | 'response';
332
333
  type ProtocolVersion = '1.0' | '1.1' | '2.0';
333
334
  interface BeaconWorkerMessage {
334
335
  type: BeaconWorkerMessageType;
@@ -355,6 +356,7 @@ interface WorkerConfig {
355
356
  taskTimeout?: number;
356
357
  fallbackDelay?: number;
357
358
  enableFallback?: boolean;
359
+ initTimeoutMs?: number;
358
360
  }
359
361
  interface CircuitBreakerConfig {
360
362
  threshold: number;
@@ -25,7 +25,20 @@ function isLogLevel(value) {
25
25
  return value === "error" || value === "warn" || value === "info" || value === "debug";
26
26
  }
27
27
  function isBeaconWorkerMessageType(value) {
28
- return value === "init" || value === "collect" || value === "flush" || value === "config" || value === "status" || value === "error";
28
+ return value === "init" || value === "collect" || value === "flush" || value === "config" || value === "status" || value === "error" || // `beacon.worker.ts`'s `respond()` has always sent this on every
29
+ // successful request (init/collect/flush/config/status) — the allowlist
30
+ // just never named it, so `parseBeaconWorkerMessage` silently coerced
31
+ // every success response to `'init'` (see that function's fallback).
32
+ value === "response";
33
+ }
34
+ function resolveUseWorker(config) {
35
+ if (typeof config.useWorker === "boolean") {
36
+ return config.useWorker;
37
+ }
38
+ if (typeof config.enableWebWorker === "boolean") {
39
+ return config.enableWebWorker;
40
+ }
41
+ return true;
29
42
  }
30
43
  function parseRetryStrategy(input) {
31
44
  const strategy = toRecord(input);
@@ -201,7 +214,7 @@ function parseBeaconConfig(input) {
201
214
  maxQueueSize: numberOr(config.maxQueueSize, 100),
202
215
  retryAttempts: numberOr(config.retryAttempts, 3),
203
216
  retryDelay: numberOr(config.retryDelay, 2e3),
204
- useWorker: config.useWorker !== false,
217
+ useWorker: resolveUseWorker(config),
205
218
  workerUrl: stringOr(config.workerUrl),
206
219
  workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0,
207
220
  lazySignalsUrl: stringOr(config.lazySignalsUrl)
@@ -23,7 +23,20 @@ function isLogLevel(value) {
23
23
  return value === "error" || value === "warn" || value === "info" || value === "debug";
24
24
  }
25
25
  function isBeaconWorkerMessageType(value) {
26
- return value === "init" || value === "collect" || value === "flush" || value === "config" || value === "status" || value === "error";
26
+ return value === "init" || value === "collect" || value === "flush" || value === "config" || value === "status" || value === "error" || // `beacon.worker.ts`'s `respond()` has always sent this on every
27
+ // successful request (init/collect/flush/config/status) — the allowlist
28
+ // just never named it, so `parseBeaconWorkerMessage` silently coerced
29
+ // every success response to `'init'` (see that function's fallback).
30
+ value === "response";
31
+ }
32
+ function resolveUseWorker(config) {
33
+ if (typeof config.useWorker === "boolean") {
34
+ return config.useWorker;
35
+ }
36
+ if (typeof config.enableWebWorker === "boolean") {
37
+ return config.enableWebWorker;
38
+ }
39
+ return true;
27
40
  }
28
41
  function parseRetryStrategy(input) {
29
42
  const strategy = toRecord(input);
@@ -199,7 +212,7 @@ function parseBeaconConfig(input) {
199
212
  maxQueueSize: numberOr(config.maxQueueSize, 100),
200
213
  retryAttempts: numberOr(config.retryAttempts, 3),
201
214
  retryDelay: numberOr(config.retryDelay, 2e3),
202
- useWorker: config.useWorker !== false,
215
+ useWorker: resolveUseWorker(config),
203
216
  workerUrl: stringOr(config.workerUrl),
204
217
  workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0,
205
218
  lazySignalsUrl: stringOr(config.lazySignalsUrl)
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const BrowserPostureSchema: z.ZodObject<{
4
+ v: z.ZodLiteral<1>;
5
+ project_id: z.ZodString;
6
+ origin: z.ZodString;
7
+ session_id: z.ZodString;
8
+ binding: z.ZodString;
9
+ verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
10
+ score: z.ZodNullable<z.ZodNumber>;
11
+ scorer_version: z.ZodNumber;
12
+ reasons: z.ZodArray<z.ZodString, "many">;
13
+ iat: z.ZodNumber;
14
+ exp: z.ZodNumber;
15
+ }, "strip", z.ZodTypeAny, {
16
+ verdict: "human" | "agent-driven" | "insufficient";
17
+ score: number | null;
18
+ reasons: string[];
19
+ v: 1;
20
+ project_id: string;
21
+ origin: string;
22
+ session_id: string;
23
+ binding: string;
24
+ scorer_version: number;
25
+ iat: number;
26
+ exp: number;
27
+ }, {
28
+ verdict: "human" | "agent-driven" | "insufficient";
29
+ score: number | null;
30
+ reasons: string[];
31
+ v: 1;
32
+ project_id: string;
33
+ origin: string;
34
+ session_id: string;
35
+ binding: string;
36
+ scorer_version: number;
37
+ iat: number;
38
+ exp: number;
39
+ }>;
40
+ type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
41
+
42
+ declare const BrowserPostureReportSchema: z.ZodObject<{
43
+ projectId: z.ZodString;
44
+ sessionId: z.ZodString;
45
+ verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
46
+ score: z.ZodNullable<z.ZodNumber>;
47
+ scorerVersion: z.ZodNumber;
48
+ reasons: z.ZodArray<z.ZodString, "many">;
49
+ issuedAt: z.ZodNumber;
50
+ expiresAt: z.ZodNumber;
51
+ source: z.ZodLiteral<"verified-posture">;
52
+ }, "strip", z.ZodTypeAny, {
53
+ projectId: string;
54
+ sessionId: string;
55
+ verdict: "human" | "agent-driven" | "insufficient";
56
+ score: number | null;
57
+ scorerVersion: number;
58
+ reasons: string[];
59
+ issuedAt: number;
60
+ expiresAt: number;
61
+ source: "verified-posture";
62
+ }, {
63
+ projectId: string;
64
+ sessionId: string;
65
+ verdict: "human" | "agent-driven" | "insufficient";
66
+ score: number | null;
67
+ scorerVersion: number;
68
+ reasons: string[];
69
+ issuedAt: number;
70
+ expiresAt: number;
71
+ source: "verified-posture";
72
+ }>;
73
+ declare function browserPostureReport(posture: BrowserPosture): {
74
+ projectId: string;
75
+ sessionId: string;
76
+ verdict: "human" | "agent-driven" | "insufficient";
77
+ score: number | null;
78
+ scorerVersion: number;
79
+ reasons: string[];
80
+ issuedAt: number;
81
+ expiresAt: number;
82
+ source: "verified-posture";
83
+ };
84
+
85
+ export { BrowserPostureReportSchema, browserPostureReport };
@@ -0,0 +1,85 @@
1
+ import { z } from 'zod';
2
+
3
+ declare const BrowserPostureSchema: z.ZodObject<{
4
+ v: z.ZodLiteral<1>;
5
+ project_id: z.ZodString;
6
+ origin: z.ZodString;
7
+ session_id: z.ZodString;
8
+ binding: z.ZodString;
9
+ verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
10
+ score: z.ZodNullable<z.ZodNumber>;
11
+ scorer_version: z.ZodNumber;
12
+ reasons: z.ZodArray<z.ZodString, "many">;
13
+ iat: z.ZodNumber;
14
+ exp: z.ZodNumber;
15
+ }, "strip", z.ZodTypeAny, {
16
+ verdict: "human" | "agent-driven" | "insufficient";
17
+ score: number | null;
18
+ reasons: string[];
19
+ v: 1;
20
+ project_id: string;
21
+ origin: string;
22
+ session_id: string;
23
+ binding: string;
24
+ scorer_version: number;
25
+ iat: number;
26
+ exp: number;
27
+ }, {
28
+ verdict: "human" | "agent-driven" | "insufficient";
29
+ score: number | null;
30
+ reasons: string[];
31
+ v: 1;
32
+ project_id: string;
33
+ origin: string;
34
+ session_id: string;
35
+ binding: string;
36
+ scorer_version: number;
37
+ iat: number;
38
+ exp: number;
39
+ }>;
40
+ type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
41
+
42
+ declare const BrowserPostureReportSchema: z.ZodObject<{
43
+ projectId: z.ZodString;
44
+ sessionId: z.ZodString;
45
+ verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
46
+ score: z.ZodNullable<z.ZodNumber>;
47
+ scorerVersion: z.ZodNumber;
48
+ reasons: z.ZodArray<z.ZodString, "many">;
49
+ issuedAt: z.ZodNumber;
50
+ expiresAt: z.ZodNumber;
51
+ source: z.ZodLiteral<"verified-posture">;
52
+ }, "strip", z.ZodTypeAny, {
53
+ projectId: string;
54
+ sessionId: string;
55
+ verdict: "human" | "agent-driven" | "insufficient";
56
+ score: number | null;
57
+ scorerVersion: number;
58
+ reasons: string[];
59
+ issuedAt: number;
60
+ expiresAt: number;
61
+ source: "verified-posture";
62
+ }, {
63
+ projectId: string;
64
+ sessionId: string;
65
+ verdict: "human" | "agent-driven" | "insufficient";
66
+ score: number | null;
67
+ scorerVersion: number;
68
+ reasons: string[];
69
+ issuedAt: number;
70
+ expiresAt: number;
71
+ source: "verified-posture";
72
+ }>;
73
+ declare function browserPostureReport(posture: BrowserPosture): {
74
+ projectId: string;
75
+ sessionId: string;
76
+ verdict: "human" | "agent-driven" | "insufficient";
77
+ score: number | null;
78
+ scorerVersion: number;
79
+ reasons: string[];
80
+ issuedAt: number;
81
+ expiresAt: number;
82
+ source: "verified-posture";
83
+ };
84
+
85
+ export { BrowserPostureReportSchema, browserPostureReport };
@@ -0,0 +1 @@
1
+ 'use strict';var zod=require('zod');var i=zod.z.object({projectId:zod.z.string().min(1).max(128),sessionId:zod.z.string().uuid(),verdict:zod.z.enum(["human","agent-driven","insufficient"]),score:zod.z.number().min(0).max(1).nullable(),scorerVersion:zod.z.number().int().positive(),reasons:zod.z.array(zod.z.string().max(160)).max(8),issuedAt:zod.z.number().int().nonnegative(),expiresAt:zod.z.number().int().positive(),source:zod.z.literal("verified-posture")});function o(r){return {projectId:r.project_id,sessionId:r.session_id,verdict:r.verdict,score:r.score,scorerVersion:r.scorer_version,reasons:r.reasons,issuedAt:r.iat,expiresAt:r.exp,source:"verified-posture"}}exports.BrowserPostureReportSchema=i;exports.browserPostureReport=o;
@@ -0,0 +1 @@
1
+ import {z}from'zod';var i=z.object({projectId:z.string().min(1).max(128),sessionId:z.string().uuid(),verdict:z.enum(["human","agent-driven","insufficient"]),score:z.number().min(0).max(1).nullable(),scorerVersion:z.number().int().positive(),reasons:z.array(z.string().max(160)).max(8),issuedAt:z.number().int().nonnegative(),expiresAt:z.number().int().positive(),source:z.literal("verified-posture")});function o(r){return {projectId:r.project_id,sessionId:r.session_id,verdict:r.verdict,score:r.score,scorerVersion:r.scorer_version,reasons:r.reasons,issuedAt:r.iat,expiresAt:r.exp,source:"verified-posture"}}export{i as BrowserPostureReportSchema,o as browserPostureReport};
@@ -0,0 +1,114 @@
1
+ import { JWK } from 'jose';
2
+ export { JWK } from 'jose';
3
+ import { z } from 'zod';
4
+
5
+ declare const BrowserPostureReportSchema: z.ZodObject<{
6
+ projectId: z.ZodString;
7
+ sessionId: z.ZodString;
8
+ verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
9
+ score: z.ZodNullable<z.ZodNumber>;
10
+ scorerVersion: z.ZodNumber;
11
+ reasons: z.ZodArray<z.ZodString, "many">;
12
+ issuedAt: z.ZodNumber;
13
+ expiresAt: z.ZodNumber;
14
+ source: z.ZodLiteral<"verified-posture">;
15
+ }, "strip", z.ZodTypeAny, {
16
+ verdict: "agent-driven" | "human" | "insufficient";
17
+ score: number | null;
18
+ reasons: string[];
19
+ projectId: string;
20
+ sessionId: string;
21
+ scorerVersion: number;
22
+ issuedAt: number;
23
+ expiresAt: number;
24
+ source: "verified-posture";
25
+ }, {
26
+ verdict: "agent-driven" | "human" | "insufficient";
27
+ score: number | null;
28
+ reasons: string[];
29
+ projectId: string;
30
+ sessionId: string;
31
+ scorerVersion: number;
32
+ issuedAt: number;
33
+ expiresAt: number;
34
+ source: "verified-posture";
35
+ }>;
36
+ declare function browserPostureReport(posture: BrowserPosture): {
37
+ projectId: string;
38
+ sessionId: string;
39
+ verdict: "agent-driven" | "human" | "insufficient";
40
+ score: number | null;
41
+ scorerVersion: number;
42
+ reasons: string[];
43
+ issuedAt: number;
44
+ expiresAt: number;
45
+ source: "verified-posture";
46
+ };
47
+
48
+ declare const UNSIGNED_BROWSER_AGENT: {
49
+ readonly agentType: "Browser agent (unsigned)";
50
+ readonly detectionClass: "ai_agent";
51
+ readonly verificationMethod: "behavioral";
52
+ };
53
+ declare const behavioralConfidence: (score: number | null) => number;
54
+ declare const POSTURE_TTL_SECONDS = 120;
55
+ declare const POSTURE_ISSUER = "checkpoint:browser-posture:v1";
56
+ declare const POSTURE_TYPE = "checkpoint-posture+jwt";
57
+ declare const BrowserPostureSchema: z.ZodObject<{
58
+ v: z.ZodLiteral<1>;
59
+ project_id: z.ZodString;
60
+ origin: z.ZodString;
61
+ session_id: z.ZodString;
62
+ binding: z.ZodString;
63
+ verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
64
+ score: z.ZodNullable<z.ZodNumber>;
65
+ scorer_version: z.ZodNumber;
66
+ reasons: z.ZodArray<z.ZodString, "many">;
67
+ iat: z.ZodNumber;
68
+ exp: z.ZodNumber;
69
+ }, "strip", z.ZodTypeAny, {
70
+ v: 1;
71
+ project_id: string;
72
+ origin: string;
73
+ session_id: string;
74
+ binding: string;
75
+ verdict: "agent-driven" | "human" | "insufficient";
76
+ score: number | null;
77
+ scorer_version: number;
78
+ reasons: string[];
79
+ iat: number;
80
+ exp: number;
81
+ }, {
82
+ v: 1;
83
+ project_id: string;
84
+ origin: string;
85
+ session_id: string;
86
+ binding: string;
87
+ verdict: "agent-driven" | "human" | "insufficient";
88
+ score: number | null;
89
+ scorer_version: number;
90
+ reasons: string[];
91
+ iat: number;
92
+ exp: number;
93
+ }>;
94
+ type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
95
+ interface BrowserPostureConfig {
96
+ publicKey: JWK;
97
+ keyId: string;
98
+ origin: string;
99
+ sessionCookieName?: string;
100
+ protectedRoutes?: Array<{
101
+ path: string;
102
+ scopes: string[];
103
+ }>;
104
+ }
105
+ declare function postureCookieName(projectId: string): string;
106
+ declare function readPostureCookie(header: string | null | undefined, name: string): string | undefined;
107
+ declare function postureSessionBinding(sessionId: string): Promise<string>;
108
+ declare function signBrowserPosture(posture: BrowserPosture, privateKey: JWK, keyId: string): Promise<string>;
109
+ declare function verifyBrowserPosture(token: string | undefined, config: BrowserPostureConfig, projectId: string, browserSessionId: string | undefined, now?: number): Promise<BrowserPosture | undefined>;
110
+ declare function postureFromCookies(header: string | null | undefined, config: BrowserPostureConfig, projectId: string): Promise<BrowserPosture | undefined>;
111
+ declare function postureRequiredScopes(config: BrowserPostureConfig, path: string): string[] | undefined;
112
+ declare function validateBrowserPostureConfig(config: BrowserPostureConfig, projectId: string | undefined): void;
113
+
114
+ export { type BrowserPosture, type BrowserPostureConfig, BrowserPostureReportSchema, BrowserPostureSchema, POSTURE_ISSUER, POSTURE_TTL_SECONDS, POSTURE_TYPE, UNSIGNED_BROWSER_AGENT, behavioralConfidence, browserPostureReport, postureCookieName, postureFromCookies, postureRequiredScopes, postureSessionBinding, readPostureCookie, signBrowserPosture, validateBrowserPostureConfig, verifyBrowserPosture };
@@ -0,0 +1,114 @@
1
+ import { JWK } from 'jose';
2
+ export { JWK } from 'jose';
3
+ import { z } from 'zod';
4
+
5
+ declare const BrowserPostureReportSchema: z.ZodObject<{
6
+ projectId: z.ZodString;
7
+ sessionId: z.ZodString;
8
+ verdict: z.ZodEnum<["human", "agent-driven", "insufficient"]>;
9
+ score: z.ZodNullable<z.ZodNumber>;
10
+ scorerVersion: z.ZodNumber;
11
+ reasons: z.ZodArray<z.ZodString, "many">;
12
+ issuedAt: z.ZodNumber;
13
+ expiresAt: z.ZodNumber;
14
+ source: z.ZodLiteral<"verified-posture">;
15
+ }, "strip", z.ZodTypeAny, {
16
+ verdict: "agent-driven" | "human" | "insufficient";
17
+ score: number | null;
18
+ reasons: string[];
19
+ projectId: string;
20
+ sessionId: string;
21
+ scorerVersion: number;
22
+ issuedAt: number;
23
+ expiresAt: number;
24
+ source: "verified-posture";
25
+ }, {
26
+ verdict: "agent-driven" | "human" | "insufficient";
27
+ score: number | null;
28
+ reasons: string[];
29
+ projectId: string;
30
+ sessionId: string;
31
+ scorerVersion: number;
32
+ issuedAt: number;
33
+ expiresAt: number;
34
+ source: "verified-posture";
35
+ }>;
36
+ declare function browserPostureReport(posture: BrowserPosture): {
37
+ projectId: string;
38
+ sessionId: string;
39
+ verdict: "agent-driven" | "human" | "insufficient";
40
+ score: number | null;
41
+ scorerVersion: number;
42
+ reasons: string[];
43
+ issuedAt: number;
44
+ expiresAt: number;
45
+ source: "verified-posture";
46
+ };
47
+
48
+ declare const UNSIGNED_BROWSER_AGENT: {
49
+ readonly agentType: "Browser agent (unsigned)";
50
+ readonly detectionClass: "ai_agent";
51
+ readonly verificationMethod: "behavioral";
52
+ };
53
+ declare const behavioralConfidence: (score: number | null) => number;
54
+ declare const POSTURE_TTL_SECONDS = 120;
55
+ declare const POSTURE_ISSUER = "checkpoint:browser-posture:v1";
56
+ declare const POSTURE_TYPE = "checkpoint-posture+jwt";
57
+ declare const BrowserPostureSchema: z.ZodObject<{
58
+ v: z.ZodLiteral<1>;
59
+ project_id: z.ZodString;
60
+ origin: z.ZodString;
61
+ session_id: z.ZodString;
62
+ binding: z.ZodString;
63
+ verdict: z.ZodEnum<["agent-driven", "human", "insufficient"]>;
64
+ score: z.ZodNullable<z.ZodNumber>;
65
+ scorer_version: z.ZodNumber;
66
+ reasons: z.ZodArray<z.ZodString, "many">;
67
+ iat: z.ZodNumber;
68
+ exp: z.ZodNumber;
69
+ }, "strip", z.ZodTypeAny, {
70
+ v: 1;
71
+ project_id: string;
72
+ origin: string;
73
+ session_id: string;
74
+ binding: string;
75
+ verdict: "agent-driven" | "human" | "insufficient";
76
+ score: number | null;
77
+ scorer_version: number;
78
+ reasons: string[];
79
+ iat: number;
80
+ exp: number;
81
+ }, {
82
+ v: 1;
83
+ project_id: string;
84
+ origin: string;
85
+ session_id: string;
86
+ binding: string;
87
+ verdict: "agent-driven" | "human" | "insufficient";
88
+ score: number | null;
89
+ scorer_version: number;
90
+ reasons: string[];
91
+ iat: number;
92
+ exp: number;
93
+ }>;
94
+ type BrowserPosture = z.infer<typeof BrowserPostureSchema>;
95
+ interface BrowserPostureConfig {
96
+ publicKey: JWK;
97
+ keyId: string;
98
+ origin: string;
99
+ sessionCookieName?: string;
100
+ protectedRoutes?: Array<{
101
+ path: string;
102
+ scopes: string[];
103
+ }>;
104
+ }
105
+ declare function postureCookieName(projectId: string): string;
106
+ declare function readPostureCookie(header: string | null | undefined, name: string): string | undefined;
107
+ declare function postureSessionBinding(sessionId: string): Promise<string>;
108
+ declare function signBrowserPosture(posture: BrowserPosture, privateKey: JWK, keyId: string): Promise<string>;
109
+ declare function verifyBrowserPosture(token: string | undefined, config: BrowserPostureConfig, projectId: string, browserSessionId: string | undefined, now?: number): Promise<BrowserPosture | undefined>;
110
+ declare function postureFromCookies(header: string | null | undefined, config: BrowserPostureConfig, projectId: string): Promise<BrowserPosture | undefined>;
111
+ declare function postureRequiredScopes(config: BrowserPostureConfig, path: string): string[] | undefined;
112
+ declare function validateBrowserPostureConfig(config: BrowserPostureConfig, projectId: string | undefined): void;
113
+
114
+ export { type BrowserPosture, type BrowserPostureConfig, BrowserPostureReportSchema, BrowserPostureSchema, POSTURE_ISSUER, POSTURE_TTL_SECONDS, POSTURE_TYPE, UNSIGNED_BROWSER_AGENT, behavioralConfidence, browserPostureReport, postureCookieName, postureFromCookies, postureRequiredScopes, postureSessionBinding, readPostureCookie, signBrowserPosture, validateBrowserPostureConfig, verifyBrowserPosture };