@kya-os/checkpoint-shared 1.2.1 → 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 (68) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -1
  3. package/dist/beacon-types/index.d.mts +13 -2
  4. package/dist/beacon-types/index.d.ts +13 -2
  5. package/dist/beacon-types/index.js +35 -3
  6. package/dist/beacon-types/index.mjs +35 -4
  7. package/dist/browser-posture-report.d.mts +85 -0
  8. package/dist/browser-posture-report.d.ts +85 -0
  9. package/dist/browser-posture-report.js +1 -0
  10. package/dist/browser-posture-report.mjs +1 -0
  11. package/dist/browser-posture.d.mts +114 -0
  12. package/dist/browser-posture.d.ts +114 -0
  13. package/dist/browser-posture.js +4204 -0
  14. package/dist/browser-posture.mjs +4187 -0
  15. package/dist/browser.d.mts +35 -1
  16. package/dist/browser.d.ts +35 -1
  17. package/dist/browser.js +1 -1
  18. package/dist/browser.mjs +1 -1
  19. package/dist/canonical-signer/index.js +31 -2
  20. package/dist/canonical-signer/index.mjs +31 -2
  21. package/dist/deploy/index.d.mts +449 -2
  22. package/dist/deploy/index.d.ts +449 -2
  23. package/dist/deploy/index.js +238 -1
  24. package/dist/deploy/index.mjs +228 -2
  25. package/dist/errors/index.d.mts +104 -0
  26. package/dist/errors/index.d.ts +104 -0
  27. package/dist/errors/index.js +338 -0
  28. package/dist/errors/index.mjs +333 -0
  29. package/dist/gateway/index.d.mts +6 -1
  30. package/dist/gateway/index.d.ts +6 -1
  31. package/dist/gateway/index.js +4 -0
  32. package/dist/gateway/index.mjs +4 -1
  33. package/dist/index.d.mts +2388 -851
  34. package/dist/index.d.ts +2388 -851
  35. package/dist/index.js +2684 -686
  36. package/dist/index.mjs +2575 -669
  37. package/dist/mcpi/multibase-ed25519.d.mts +8 -0
  38. package/dist/mcpi/multibase-ed25519.d.ts +8 -0
  39. package/dist/mcpi/multibase-ed25519.js +125 -0
  40. package/dist/mcpi/multibase-ed25519.mjs +119 -0
  41. package/dist/signals/index.d.mts +158 -0
  42. package/dist/signals/index.d.ts +158 -0
  43. package/dist/signals/index.js +1667 -0
  44. package/dist/signals/index.mjs +1637 -0
  45. package/dist/test-fixtures/index.d.mts +37 -1
  46. package/dist/test-fixtures/index.d.ts +37 -1
  47. package/dist/test-fixtures/index.js +92 -1
  48. package/dist/test-fixtures/index.mjs +87 -2
  49. package/fixtures/client-ip-resolution.json +103 -0
  50. package/fixtures/detection/reason-codes.json +35 -0
  51. package/fixtures/detection/signal-exposure-example.json +62 -0
  52. package/fixtures/kya-http/README.md +112 -0
  53. package/fixtures/kya-http/challenge-proof.canonical.json +25 -0
  54. package/fixtures/kya-http/challenge.approval-quorum.json +37 -0
  55. package/fixtures/kya-http/challenge.delegation.fetcher-200.json +55 -0
  56. package/fixtures/kya-http/challenge.delegation.full.json +81 -0
  57. package/fixtures/kya-http/challenge.delegation.minimal.json +57 -0
  58. package/fixtures/kya-http/error-codes.json +35 -0
  59. package/fixtures/kya-http/fetcher-200-predicate.vectors.json +72 -0
  60. package/fixtures/kya-http/negative.challenges.json +54 -0
  61. package/fixtures/kya-http/pickup.transcript.json +96 -0
  62. package/fixtures/kya-http/pickup.transcript.quorum.json +156 -0
  63. package/fixtures/kya-http/protected-resource-metadata.full.json +30 -0
  64. package/fixtures/kya-http/protected-resource-metadata.global.json +28 -0
  65. package/fixtures/kya-http/registration.request.json +33 -0
  66. package/fixtures/kya-http/registration.response.json +32 -0
  67. package/package.json +42 -9
  68. package/src/data/compiled/merged-rules.json +8 -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).
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @kya-os/checkpoint-shared
2
2
 
3
- Shared types, schemas, and constants for AgentShield - the single source of truth for all TypeScript type definitions.
3
+ Shared types, schemas, and constants for Checkpoint - the single source of truth for all TypeScript type definitions.
4
4
 
5
5
  ## Installation
6
6
 
@@ -7,6 +7,7 @@ type BeaconJsonValue = JsonValue;
7
7
  type BeaconCustomData = Record<string, JsonValue | undefined>;
8
8
  type BeaconPayload = BeaconCollectorData | BeaconCustomData | null;
9
9
  type WorkerPayload = unknown;
10
+ declare function isBeaconIdentity(value: unknown): value is BeaconIdentity;
10
11
  interface NetworkInformationLike extends EventTarget {
11
12
  type?: string;
12
13
  effectiveType?: string;
@@ -54,8 +55,13 @@ interface LargestContentfulPaintEntry extends PerformanceEntry {
54
55
  renderTime?: number;
55
56
  loadTime?: number;
56
57
  }
58
+ interface BeaconIdentity {
59
+ userId: string;
60
+ }
57
61
  interface BeaconConfig {
58
62
  projectId: string;
63
+ identity?: BeaconIdentity;
64
+ endpoint?: string;
59
65
  environment?: 'development' | 'staging' | 'production' | string;
60
66
  tags?: Record<string, string | number | boolean>;
61
67
  enabled?: boolean;
@@ -67,12 +73,15 @@ interface BeaconConfig {
67
73
  sessionCookieName?: string;
68
74
  batchSize?: number;
69
75
  flushInterval?: number;
76
+ collectorDeadlineMs?: number;
70
77
  maxQueueSize?: number;
71
78
  retryAttempts?: number;
72
79
  retryDelay?: number;
73
80
  useWorker?: boolean;
81
+ enableWebWorker?: boolean;
74
82
  workerUrl?: string;
75
83
  workerConfig?: WorkerConfig;
84
+ lazySignalsUrl?: string;
76
85
  }
77
86
  interface BeaconEvent {
78
87
  type: BeaconEventType;
@@ -83,6 +92,7 @@ interface BeaconMetadata {
83
92
  sessionId: string;
84
93
  timestamp: number;
85
94
  eventName?: string;
95
+ identity?: BeaconIdentity;
86
96
  [key: string]: unknown;
87
97
  }
88
98
  interface IAgentShieldBeacon {
@@ -319,7 +329,7 @@ interface WorkerPoolConfig {
319
329
  scaleUpThreshold?: number;
320
330
  scaleDownThreshold?: number;
321
331
  }
322
- type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error';
332
+ type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error' | 'response';
323
333
  type ProtocolVersion = '1.0' | '1.1' | '2.0';
324
334
  interface BeaconWorkerMessage {
325
335
  type: BeaconWorkerMessageType;
@@ -346,6 +356,7 @@ interface WorkerConfig {
346
356
  taskTimeout?: number;
347
357
  fallbackDelay?: number;
348
358
  enableFallback?: boolean;
359
+ initTimeoutMs?: number;
349
360
  }
350
361
  interface CircuitBreakerConfig {
351
362
  threshold: number;
@@ -424,4 +435,4 @@ declare class AgentShieldBeacon implements IAgentShieldBeacon {
424
435
  destroy(): Promise<void>;
425
436
  }
426
437
 
427
- export { AgentShieldBeacon, type BatchEvent, type BeaconBatch, type BeaconCollectorData, type BeaconConfig, type BeaconCustomData, type BeaconEvent, type BeaconEventType, type BeaconJsonValue, type BeaconMetadata, type BeaconPayload, type BeaconPrimitive, type BeaconResponse, type BeaconWorkerMessage, type BeaconWorkerMessageType, type BrowserContext, type CircuitBreakerConfig, type CircuitBreakerState, type ConnectionType, type FallbackOptions, type IAgentShieldBeacon, type JsonPrimitive, type JsonValue, type LargestContentfulPaintEntry, type MessagePriority, type NavigatorWithNetworkInformation, type NetworkInfo, type NetworkInformationLike, type OfflineQueueEntry, type PerformanceMemoryInfo, type PerformanceMetrics, type PerformanceWithMemory, type ProtocolVersion, type ResourceUsage, ResourceUsageSchema, type RetryStrategy, type SessionData, type TransportConfig, type TransportMetrics, type TransportOptions, type TransportResponse, type TransportState, type TrustedTypePolicyLike, type WindowWithBeaconMetadata, type WindowWithTrustedTypes, type WorkerAction, type WorkerCapabilities, type WorkerConfig, type WorkerError, type WorkerErrorType, type WorkerHealthStatus, type WorkerMessage, type WorkerMessageType, type WorkerMetrics, type WorkerPayload, type WorkerPoolConfig, WorkerPoolConfigSchema, type WorkerState, type WorkerTask, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
438
+ export { AgentShieldBeacon, type BatchEvent, type BeaconBatch, type BeaconCollectorData, type BeaconConfig, type BeaconCustomData, type BeaconEvent, type BeaconEventType, type BeaconIdentity, type BeaconJsonValue, type BeaconMetadata, type BeaconPayload, type BeaconPrimitive, type BeaconResponse, type BeaconWorkerMessage, type BeaconWorkerMessageType, type BrowserContext, type CircuitBreakerConfig, type CircuitBreakerState, type ConnectionType, type FallbackOptions, type IAgentShieldBeacon, type JsonPrimitive, type JsonValue, type LargestContentfulPaintEntry, type MessagePriority, type NavigatorWithNetworkInformation, type NetworkInfo, type NetworkInformationLike, type OfflineQueueEntry, type PerformanceMemoryInfo, type PerformanceMetrics, type PerformanceWithMemory, type ProtocolVersion, type ResourceUsage, ResourceUsageSchema, type RetryStrategy, type SessionData, type TransportConfig, type TransportMetrics, type TransportOptions, type TransportResponse, type TransportState, type TrustedTypePolicyLike, type WindowWithBeaconMetadata, type WindowWithTrustedTypes, type WorkerAction, type WorkerCapabilities, type WorkerConfig, type WorkerError, type WorkerErrorType, type WorkerHealthStatus, type WorkerMessage, type WorkerMessageType, type WorkerMetrics, type WorkerPayload, type WorkerPoolConfig, WorkerPoolConfigSchema, type WorkerState, type WorkerTask, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
@@ -7,6 +7,7 @@ type BeaconJsonValue = JsonValue;
7
7
  type BeaconCustomData = Record<string, JsonValue | undefined>;
8
8
  type BeaconPayload = BeaconCollectorData | BeaconCustomData | null;
9
9
  type WorkerPayload = unknown;
10
+ declare function isBeaconIdentity(value: unknown): value is BeaconIdentity;
10
11
  interface NetworkInformationLike extends EventTarget {
11
12
  type?: string;
12
13
  effectiveType?: string;
@@ -54,8 +55,13 @@ interface LargestContentfulPaintEntry extends PerformanceEntry {
54
55
  renderTime?: number;
55
56
  loadTime?: number;
56
57
  }
58
+ interface BeaconIdentity {
59
+ userId: string;
60
+ }
57
61
  interface BeaconConfig {
58
62
  projectId: string;
63
+ identity?: BeaconIdentity;
64
+ endpoint?: string;
59
65
  environment?: 'development' | 'staging' | 'production' | string;
60
66
  tags?: Record<string, string | number | boolean>;
61
67
  enabled?: boolean;
@@ -67,12 +73,15 @@ interface BeaconConfig {
67
73
  sessionCookieName?: string;
68
74
  batchSize?: number;
69
75
  flushInterval?: number;
76
+ collectorDeadlineMs?: number;
70
77
  maxQueueSize?: number;
71
78
  retryAttempts?: number;
72
79
  retryDelay?: number;
73
80
  useWorker?: boolean;
81
+ enableWebWorker?: boolean;
74
82
  workerUrl?: string;
75
83
  workerConfig?: WorkerConfig;
84
+ lazySignalsUrl?: string;
76
85
  }
77
86
  interface BeaconEvent {
78
87
  type: BeaconEventType;
@@ -83,6 +92,7 @@ interface BeaconMetadata {
83
92
  sessionId: string;
84
93
  timestamp: number;
85
94
  eventName?: string;
95
+ identity?: BeaconIdentity;
86
96
  [key: string]: unknown;
87
97
  }
88
98
  interface IAgentShieldBeacon {
@@ -319,7 +329,7 @@ interface WorkerPoolConfig {
319
329
  scaleUpThreshold?: number;
320
330
  scaleDownThreshold?: number;
321
331
  }
322
- type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error';
332
+ type BeaconWorkerMessageType = 'init' | 'collect' | 'flush' | 'config' | 'status' | 'error' | 'response';
323
333
  type ProtocolVersion = '1.0' | '1.1' | '2.0';
324
334
  interface BeaconWorkerMessage {
325
335
  type: BeaconWorkerMessageType;
@@ -346,6 +356,7 @@ interface WorkerConfig {
346
356
  taskTimeout?: number;
347
357
  fallbackDelay?: number;
348
358
  enableFallback?: boolean;
359
+ initTimeoutMs?: number;
349
360
  }
350
361
  interface CircuitBreakerConfig {
351
362
  threshold: number;
@@ -424,4 +435,4 @@ declare class AgentShieldBeacon implements IAgentShieldBeacon {
424
435
  destroy(): Promise<void>;
425
436
  }
426
437
 
427
- export { AgentShieldBeacon, type BatchEvent, type BeaconBatch, type BeaconCollectorData, type BeaconConfig, type BeaconCustomData, type BeaconEvent, type BeaconEventType, type BeaconJsonValue, type BeaconMetadata, type BeaconPayload, type BeaconPrimitive, type BeaconResponse, type BeaconWorkerMessage, type BeaconWorkerMessageType, type BrowserContext, type CircuitBreakerConfig, type CircuitBreakerState, type ConnectionType, type FallbackOptions, type IAgentShieldBeacon, type JsonPrimitive, type JsonValue, type LargestContentfulPaintEntry, type MessagePriority, type NavigatorWithNetworkInformation, type NetworkInfo, type NetworkInformationLike, type OfflineQueueEntry, type PerformanceMemoryInfo, type PerformanceMetrics, type PerformanceWithMemory, type ProtocolVersion, type ResourceUsage, ResourceUsageSchema, type RetryStrategy, type SessionData, type TransportConfig, type TransportMetrics, type TransportOptions, type TransportResponse, type TransportState, type TrustedTypePolicyLike, type WindowWithBeaconMetadata, type WindowWithTrustedTypes, type WorkerAction, type WorkerCapabilities, type WorkerConfig, type WorkerError, type WorkerErrorType, type WorkerHealthStatus, type WorkerMessage, type WorkerMessageType, type WorkerMetrics, type WorkerPayload, type WorkerPoolConfig, WorkerPoolConfigSchema, type WorkerState, type WorkerTask, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
438
+ export { AgentShieldBeacon, type BatchEvent, type BeaconBatch, type BeaconCollectorData, type BeaconConfig, type BeaconCustomData, type BeaconEvent, type BeaconEventType, type BeaconIdentity, type BeaconJsonValue, type BeaconMetadata, type BeaconPayload, type BeaconPrimitive, type BeaconResponse, type BeaconWorkerMessage, type BeaconWorkerMessageType, type BrowserContext, type CircuitBreakerConfig, type CircuitBreakerState, type ConnectionType, type FallbackOptions, type IAgentShieldBeacon, type JsonPrimitive, type JsonValue, type LargestContentfulPaintEntry, type MessagePriority, type NavigatorWithNetworkInformation, type NetworkInfo, type NetworkInformationLike, type OfflineQueueEntry, type PerformanceMemoryInfo, type PerformanceMetrics, type PerformanceWithMemory, type ProtocolVersion, type ResourceUsage, ResourceUsageSchema, type RetryStrategy, type SessionData, type TransportConfig, type TransportMetrics, type TransportOptions, type TransportResponse, type TransportState, type TrustedTypePolicyLike, type WindowWithBeaconMetadata, type WindowWithTrustedTypes, type WorkerAction, type WorkerCapabilities, type WorkerConfig, type WorkerError, type WorkerErrorType, type WorkerHealthStatus, type WorkerMessage, type WorkerMessageType, type WorkerMetrics, type WorkerPayload, type WorkerPoolConfig, WorkerPoolConfigSchema, type WorkerState, type WorkerTask, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
@@ -18,11 +18,27 @@ function isBeaconTags(value) {
18
18
  (entry) => typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean"
19
19
  );
20
20
  }
21
+ function isBeaconIdentity(value) {
22
+ return isRecord(value) && typeof value.userId === "string" && value.userId.length > 0;
23
+ }
21
24
  function isLogLevel(value) {
22
25
  return value === "error" || value === "warn" || value === "info" || value === "debug";
23
26
  }
24
27
  function isBeaconWorkerMessageType(value) {
25
- 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;
26
42
  }
27
43
  function parseRetryStrategy(input) {
28
44
  const strategy = toRecord(input);
@@ -171,6 +187,10 @@ function parseBeaconConfig(input) {
171
187
  projectId: config.projectId,
172
188
  environment: stringOr(config.environment),
173
189
  tags: isBeaconTags(config.tags) ? config.tags : void 0,
190
+ identity: isBeaconIdentity(config.identity) ? config.identity : void 0,
191
+ // `parseBeaconConfig` is an allowlist: a key it does not name is dropped
192
+ // silently, which is how `identity` first shipped inert.
193
+ endpoint: stringOr(config.endpoint),
174
194
  enabled: config.enabled !== false,
175
195
  debug: config.debug === true,
176
196
  logLevel: isLogLevel(config.logLevel) ? config.logLevel : "error",
@@ -181,17 +201,29 @@ function parseBeaconConfig(input) {
181
201
  sessionCookieName: stringOr(config.sessionCookieName, "_as_beacon_session"),
182
202
  batchSize: numberOr(config.batchSize, 10),
183
203
  flushInterval: numberOr(config.flushInterval, 5e3),
204
+ // 1600ms — see packages/checkpoint-beacon/src/budget/thresholds.ts
205
+ // (MAX_PER_SOURCE_DEADLINE_MS) for the full measurement-backed rationale;
206
+ // sized to sit just above the vendored FingerprintJS pipeline's own
207
+ // already-ratified 1500ms TOTAL_COLLECTION_BUDGET_MS
208
+ // (collectors/entropy/vendored-fingerprint.ts), so a future collector
209
+ // wrapping that pipeline gets to use its own internal timeout instead
210
+ // of being truncated one layer up before it fires. Keep these two
211
+ // literals in sync; checkpoint-shared can't import from
212
+ // checkpoint-beacon (wrong direction of the package dependency graph).
213
+ collectorDeadlineMs: numberOr(config.collectorDeadlineMs, 1600),
184
214
  maxQueueSize: numberOr(config.maxQueueSize, 100),
185
215
  retryAttempts: numberOr(config.retryAttempts, 3),
186
216
  retryDelay: numberOr(config.retryDelay, 2e3),
187
- useWorker: config.useWorker !== false,
217
+ useWorker: resolveUseWorker(config),
188
218
  workerUrl: stringOr(config.workerUrl),
189
- workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0
219
+ workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0,
220
+ lazySignalsUrl: stringOr(config.lazySignalsUrl)
190
221
  };
191
222
  }
192
223
 
193
224
  exports.ResourceUsageSchema = ResourceUsageSchema;
194
225
  exports.WorkerPoolConfigSchema = WorkerPoolConfigSchema;
226
+ exports.isBeaconIdentity = isBeaconIdentity;
195
227
  exports.parseBeaconConfig = parseBeaconConfig;
196
228
  exports.parseBeaconWorkerMessage = parseBeaconWorkerMessage;
197
229
  exports.parseCircuitBreakerConfig = parseCircuitBreakerConfig;
@@ -16,11 +16,27 @@ function isBeaconTags(value) {
16
16
  (entry) => typeof entry === "string" || typeof entry === "number" || typeof entry === "boolean"
17
17
  );
18
18
  }
19
+ function isBeaconIdentity(value) {
20
+ return isRecord(value) && typeof value.userId === "string" && value.userId.length > 0;
21
+ }
19
22
  function isLogLevel(value) {
20
23
  return value === "error" || value === "warn" || value === "info" || value === "debug";
21
24
  }
22
25
  function isBeaconWorkerMessageType(value) {
23
- 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;
24
40
  }
25
41
  function parseRetryStrategy(input) {
26
42
  const strategy = toRecord(input);
@@ -169,6 +185,10 @@ function parseBeaconConfig(input) {
169
185
  projectId: config.projectId,
170
186
  environment: stringOr(config.environment),
171
187
  tags: isBeaconTags(config.tags) ? config.tags : void 0,
188
+ identity: isBeaconIdentity(config.identity) ? config.identity : void 0,
189
+ // `parseBeaconConfig` is an allowlist: a key it does not name is dropped
190
+ // silently, which is how `identity` first shipped inert.
191
+ endpoint: stringOr(config.endpoint),
172
192
  enabled: config.enabled !== false,
173
193
  debug: config.debug === true,
174
194
  logLevel: isLogLevel(config.logLevel) ? config.logLevel : "error",
@@ -179,13 +199,24 @@ function parseBeaconConfig(input) {
179
199
  sessionCookieName: stringOr(config.sessionCookieName, "_as_beacon_session"),
180
200
  batchSize: numberOr(config.batchSize, 10),
181
201
  flushInterval: numberOr(config.flushInterval, 5e3),
202
+ // 1600ms — see packages/checkpoint-beacon/src/budget/thresholds.ts
203
+ // (MAX_PER_SOURCE_DEADLINE_MS) for the full measurement-backed rationale;
204
+ // sized to sit just above the vendored FingerprintJS pipeline's own
205
+ // already-ratified 1500ms TOTAL_COLLECTION_BUDGET_MS
206
+ // (collectors/entropy/vendored-fingerprint.ts), so a future collector
207
+ // wrapping that pipeline gets to use its own internal timeout instead
208
+ // of being truncated one layer up before it fires. Keep these two
209
+ // literals in sync; checkpoint-shared can't import from
210
+ // checkpoint-beacon (wrong direction of the package dependency graph).
211
+ collectorDeadlineMs: numberOr(config.collectorDeadlineMs, 1600),
182
212
  maxQueueSize: numberOr(config.maxQueueSize, 100),
183
213
  retryAttempts: numberOr(config.retryAttempts, 3),
184
214
  retryDelay: numberOr(config.retryDelay, 2e3),
185
- useWorker: config.useWorker !== false,
215
+ useWorker: resolveUseWorker(config),
186
216
  workerUrl: stringOr(config.workerUrl),
187
- workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0
217
+ workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0,
218
+ lazySignalsUrl: stringOr(config.lazySignalsUrl)
188
219
  };
189
220
  }
190
221
 
191
- export { ResourceUsageSchema, WorkerPoolConfigSchema, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
222
+ export { ResourceUsageSchema, WorkerPoolConfigSchema, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
@@ -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 };