@kya-os/checkpoint-shared 1.5.2 → 1.6.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 +98 -1
- package/dist/beacon-types/index.d.mts +12 -1
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +12 -1
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +18 -1
- package/dist/beacon-types/index.mjs +18 -2
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/{browser-posture-DVoHMHjY.d.mts → browser-posture-BuChqmH5.d.mts} +2 -2
- package/dist/{browser-posture-DVoHMHjY.d.mts.map → browser-posture-BuChqmH5.d.mts.map} +1 -1
- package/dist/{browser-posture-D4j2a5gi.d.ts → browser-posture-DIaVLuW3.d.ts} +2 -2
- package/dist/{browser-posture-D4j2a5gi.d.ts.map → browser-posture-DIaVLuW3.d.ts.map} +1 -1
- package/dist/browser-posture-proof.d.mts +2 -2
- package/dist/browser-posture-proof.d.ts +2 -2
- package/dist/browser-posture-proof.js +1 -1
- package/dist/browser-posture-proof.mjs +1 -1
- package/dist/browser-posture.d.mts +1 -1
- package/dist/browser-posture.d.ts +1 -1
- package/dist/browser-posture.js +3 -3
- package/dist/browser-posture.mjs +3 -3
- package/dist/browser-posture.mjs.map +1 -1
- package/dist/clearance.d.mts +1 -1
- package/dist/clearance.d.ts +1 -1
- package/dist/clearance.js +2 -2
- package/dist/clearance.mjs +2 -2
- package/dist/errors/index.d.mts +17 -0
- package/dist/errors/index.d.mts.map +1 -1
- package/dist/errors/index.d.ts +17 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +75 -3
- package/dist/errors/index.mjs +75 -3
- package/dist/errors/index.mjs.map +1 -1
- package/dist/{external-Ct8j_hto.d.ts → external-B7WI9FyQ.d.mts} +2 -2
- package/dist/{external-Ct8j_hto.d.mts.map → external-B7WI9FyQ.d.mts.map} +1 -1
- package/dist/{external-Ct8j_hto.d.mts → external-B7WI9FyQ.d.ts} +2 -2
- package/dist/{external-Ct8j_hto.d.ts.map → external-B7WI9FyQ.d.ts.map} +1 -1
- package/dist/gateway-client-ip.d.mts +1 -1
- package/dist/gateway-client-ip.d.ts +1 -1
- package/dist/gateway-client-ip.js +1 -1
- package/dist/gateway-client-ip.mjs +1 -1
- package/dist/index.d.mts +811 -132
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +811 -132
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1945 -145
- package/dist/index.mjs +1891 -145
- package/dist/index.mjs.map +1 -1
- package/dist/mcpi/approval-grant/index.d.mts.map +1 -1
- package/dist/mcpi/approval-grant/index.d.ts.map +1 -1
- package/dist/mcpi/approval-grant/index.js +10 -1
- package/dist/mcpi/approval-grant/index.mjs +10 -1
- package/dist/mcpi/approval-grant/index.mjs.map +1 -1
- package/dist/mcpi/dashboard-config/index.d.mts +3 -2
- package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
- package/dist/mcpi/dashboard-config/index.d.ts +3 -2
- package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
- package/dist/{posture-origins-CEm83u4D.js → posture-origins-LFkX80oF.js} +6 -0
- package/dist/{posture-origins-Dl7i8j93.mjs → posture-origins-Pn-ii-Pp.mjs} +2 -2
- package/dist/{posture-origins-Dl7i8j93.mjs.map → posture-origins-Pn-ii-Pp.mjs.map} +1 -1
- package/dist/{project-verification-key-CgSVX9_m.mjs → project-verification-key-66N4edKn.mjs} +2 -2
- package/dist/{project-verification-key-CgSVX9_m.mjs.map → project-verification-key-66N4edKn.mjs.map} +1 -1
- package/dist/{project-verification-key-C3L5rd8a.js → project-verification-key-BccT12tQ.js} +1 -1
- package/dist/{schemas-DxY-dk9y.mjs → schemas-7qodsG-Z.mjs} +49 -2
- package/dist/schemas-7qodsG-Z.mjs.map +1 -0
- package/dist/{schemas-BmjNLAE7.js → schemas-YhagYDx_.js} +59 -0
- package/fixtures/cli-registration.v2.json +115 -0
- package/fixtures/detection/reason-codes.json +1 -1
- package/fixtures/kya-http/README.md +34 -26
- package/fixtures/kya-http/protected-resource-metadata.full.json +14 -5
- package/fixtures/kya-http/protected-resource-metadata.invalid-issuer.json +51 -0
- package/fixtures/kya-http/protected-resource-metadata.no-issuer.json +32 -0
- package/fixtures/reviewer-grant-revocation.v1.json +285 -0
- package/package.json +4 -4
- package/dist/schemas-DxY-dk9y.mjs.map +0 -1
- package/fixtures/kya-http/protected-resource-metadata.global.json +0 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,103 @@
|
|
|
1
1
|
# @kya-os/checkpoint-shared
|
|
2
2
|
|
|
3
|
-
## Unreleased
|
|
3
|
+
## Unreleased - `CheckpointEvents` moves here; `AGENTSHIELD_WASM_PATH` is removed
|
|
4
|
+
|
|
5
|
+
- **Added:** `CheckpointEvents`, the event-handler map the Checkpoint SDKs accept, moved from `@kya-os/checkpoint`.
|
|
6
|
+
`@kya-os/checkpoint-nextjs` types its `events` option with it, so it no longer depends on `@kya-os/checkpoint`.
|
|
7
|
+
- **Removed:** `DEFAULT_ENV_VARS.AGENTSHIELD_WASM_PATH`, the path to the retired `agentshield_wasm` binary.
|
|
8
|
+
Nothing reads it.
|
|
9
|
+
Shipped under a minor because nothing consumes it yet.
|
|
10
|
+
|
|
11
|
+
RELEASE ORDER: publish this first; the `@kya-os/checkpoint-nextjs` release that drops `@kya-os/checkpoint` needs `CheckpointEvents`.
|
|
12
|
+
|
|
13
|
+
## Unreleased - zero-evidence requests and the `no_evidence` policy category
|
|
14
|
+
|
|
15
|
+
The engine now sends a zero-evidence request as `IncompleteData` with `metadata.detection_basis = "no_evidence"`, and
|
|
16
|
+
composed policies see it as the category `no_evidence`. `withNoEvidenceExclusion(cedar)` is the serve-time rewrite that
|
|
17
|
+
makes such a visitor read as `human` in a deployed rule: in each `forbid` or `permit` statement it replaces every read of
|
|
18
|
+
the category, ignoring text in strings and comments, with
|
|
19
|
+
`(if <read> == "no_evidence" then "human" else <read>)`, where `<read>` is the read as written. A direct read of the
|
|
20
|
+
category is rewritten: `principal.category`, `principal["category"]`, the same with the principal in parentheses
|
|
21
|
+
(`(principal).category`, `((principal))["category"]`), and a bracket key written with escapes
|
|
22
|
+
(`principal["cat\u{65}gory"]`, `\x65` or an underscored `\u{6_5}`), with whitespace or a `//` comment between any of
|
|
23
|
+
the tokens. A statement that reads the category through a computed value holding the principal, such as an `if` or a record that carries
|
|
24
|
+
`principal` (`(if c then principal else principal).category`, `{p: principal}.p.category`), is left as written and sees
|
|
25
|
+
`no_evidence`. A `principal` that is an attribute name or a record key (`context has principal`, `{principal: x}`) is
|
|
26
|
+
never rewritten, so the output is valid Cedar whenever the input is. Apart from those computed reads, a statement is left byte-identical only when it compares the principal's category to the literal
|
|
27
|
+
`"no_evidence"`: with `==` or `!=`, with the literal on either side, through any of those reads; with `like`, only when a
|
|
28
|
+
segment of the pattern, split on `*`, spells the whole name and the pattern can match it (`"no_evidence*"` and `"*no_evidence"`
|
|
29
|
+
do, `"no_*"` and `"*evidence"` do not); as a member of a list passed to `.contains(...)`, `.containsAny(...)` or
|
|
30
|
+
`.containsAll(...)` with the category on the other side, with a trailing comma allowed. A literal written with escapes
|
|
31
|
+
counts. The word `no_evidence` anywhere else in a statement, such as `resource.path != "/no_evidence"` or
|
|
32
|
+
`principal.name == "no_evidence"`, does not exempt it. Text that already carries the rewrite comes back unchanged.
|
|
33
|
+
Whitespace is exactly the 25 characters of Unicode `White_Space` that the Cedar 4.12.0 lexer accepts (U+0009 to U+000D,
|
|
34
|
+
U+0020, U+0085, U+00A0, U+1680, U+2000 to U+200A, U+2028, U+2029, U+202F, U+205F, U+3000), not the JavaScript `\s` class, and a
|
|
35
|
+
`//` comment ends only at a line feed or a carriage return, so a lone `\r` ends one. The dashboard serves the stored policy
|
|
36
|
+
text, so a release that predates the rewrite reads it as before; `@kya-os/checkpoint-wasm-runtime` and the .NET and Java
|
|
37
|
+
SDKs apply it inside the compile, which
|
|
38
|
+
their caches run once per distinct policy text on a miss and not on a hit, so text from a custom fetcher behaves the same
|
|
39
|
+
at no per-request cost. The three implementations scan in linear time and are tested against one shared vector file.
|
|
40
|
+
The inverse, `withoutNoEvidenceExclusion`, is internal to the package and not exported: `requiredScopesForRequest`,
|
|
41
|
+
`approvalQuorumForRequest` and the deny-rule analysis read the `@scopes`, `@approvers` and `@quorum` annotations and the
|
|
42
|
+
rule bodies from the text with the rewrite undone, and memoize that text per source, so a rule means the same whether or
|
|
43
|
+
not it was served rewritten. New exports: `withNoEvidenceExclusion`, `NO_EVIDENCE_CATEGORY` (`no_evidence`),
|
|
44
|
+
`NO_EVIDENCE_EXCLUSION_TERM` (`principal.category != "no_evidence"`) and `NO_EVIDENCE_EQUALITY_TERM`
|
|
45
|
+
(`principal.category == "no_evidence"`).
|
|
46
|
+
|
|
47
|
+
The deny-rule checks now parse each Cedar condition and evaluate each statement for a `human` and a `no_evidence` visitor
|
|
48
|
+
instead of scanning the text, and ignore text inside strings and comments: `isUnnarrowedDenyBlock`,
|
|
49
|
+
`pathHasUnnarrowedDenyRule` and `lintUnnarrowedDenyRules` can report different results for the same policy, and the lint
|
|
50
|
+
messages now mention `no_evidence` visitors. A statement the rewrite changes is evaluated with a `no_evidence` visitor
|
|
51
|
+
read as `human`, and one it leaves alone is evaluated literally, so the analysis matches what is served. A
|
|
52
|
+
comparison, set call or `like` that mentions the class being probed is evaluated with the category read as a value
|
|
53
|
+
that names no class, so it decides the rule only through the rest of the condition; a `like` mentions a class only
|
|
54
|
+
when a segment of its pattern spells the whole name and the pattern matches it; and `if ... then ... else` is
|
|
55
|
+
evaluated three-valued. A rule that reads `getTag` is undecided, because Cedar fails closed when the tag is absent;
|
|
56
|
+
escaped entity ids in a rule's principal scope are decoded; the unnamed-category placeholder is a lone surrogate, which
|
|
57
|
+
no Cedar string literal can hold; and a lint finding names the visitors a rule reaches (humans, zero-evidence visitors,
|
|
58
|
+
or both). A condition the
|
|
59
|
+
parser cannot read, or one nested or chained more than 48 deep, is treated as undecidable and counts as reaching the
|
|
60
|
+
visitor; a set that holds a set is read as unknown. Set membership, `containsAny`, `containsAll` and set equality run in
|
|
61
|
+
linear time, and a lint finding's line number is found in one pass over the text. A `forbid` statement that carries
|
|
62
|
+
`@verdict("ALLOW")` counts as a deny like any other, a `containsAny` between the category and a list is read like
|
|
63
|
+
`.contains`, and an annotation named `forbid` or `permit` never starts a statement. New exports:
|
|
64
|
+
`analyzePolicySource(cedar)`, which parses the policy once and returns a `PolicyHazardAnalysis` (also exported) whose
|
|
65
|
+
`unnarrowedDenyFor(path, probe)`, `explicitDenyFor(path, probe)`, `humanHazard(path)`, `noEvidenceHazard(path)` and
|
|
66
|
+
`noEvidenceNamed(path)` (a rule names `no_evidence` on the path) answer
|
|
67
|
+
per path without parsing again; `pathHasUnnarrowedDenyRuleFor(cedar, path, probe)` and
|
|
68
|
+
`pathHasExplicitDenyRuleFor(cedar, path, probe)` (`probe` is the new `ProbeClass`, `human` or `no_evidence`), which
|
|
69
|
+
parse on every call; `lintMissingBaselinePermit` (warns when a policy has no baseline permit, so unmatched visitors are
|
|
70
|
+
denied), `parseCedarStatements`, `statementApplies(statement, facts)` and `statementId`; and `ByteBoundedMemo`, a map that
|
|
71
|
+
evicts its oldest entries to stay under a byte budget and does not keep a value larger than the budget, which the gateway
|
|
72
|
+
worker uses to memoize one analysis per policy hash. A `like` pattern is now matched segment by segment, split on `*`, with `\*` read as a literal
|
|
73
|
+
star, instead of by a regular expression built from the policy text, and `pathLiteralMatches` splits a path literal on `*`
|
|
74
|
+
and matches the segments the same way, with the same results.
|
|
75
|
+
|
|
76
|
+
`AdminOrganizationSessionAnalytics.comparison` gains the optional `incompleteDataSessions`, the `incomplete_data`
|
|
77
|
+
sessions that complete the split beside AI agent, bot and human. A client that constructs the type does not have to set
|
|
78
|
+
it, and one that ignores unknown fields is unaffected. The optional `incompleteDataPercentage` joins the admin session
|
|
79
|
+
comparison (`SessionComparison`) the same way; `DashboardStatsResponse` gains an optional
|
|
80
|
+
`sessionBreakdown { botSessions, humanSessions, incompleteDataSessions }`, and `AnalyticsOverview` gains
|
|
81
|
+
`uniqueIncompleteDataSessions`. `ShopifyStatsResponseSchema` gains the optional `unidentifiedSessions`: sessions with no
|
|
82
|
+
AI agent, bot or human detection and at least one incomplete-data detection carrying the `no_evidence` basis. Those
|
|
83
|
+
visitors were counted as human before, including a visit that also sent a request with suspicious headers, so they are
|
|
84
|
+
counted in `totalRequests` and `humanSessions`; sessions whose incomplete data all comes from other reasons, such as
|
|
85
|
+
suspicious headers, are in no counter.
|
|
86
|
+
|
|
87
|
+
### Security
|
|
88
|
+
|
|
89
|
+
`verifySignedApprovalQuorum` now checks a grant's `approverDid` against `quorum.approvers` before it resolves the
|
|
90
|
+
approver's key. Before, it resolved the request-supplied DID first and checked the allowlist after, so a did:web
|
|
91
|
+
`approverDid` made the host fetch a URL the caller chose. A grant from an approver outside the list is dropped as
|
|
92
|
+
before and the result is unchanged (`quorum_not_met:k/n`); it just never reaches the `ApproverKeyResolver`.
|
|
93
|
+
`verifyApprovalGrant` on its own still resolves whatever DID it is given, so a caller with an allowlist must check it
|
|
94
|
+
first.
|
|
95
|
+
|
|
96
|
+
## 1.5.2
|
|
97
|
+
|
|
98
|
+
### Changed
|
|
99
|
+
|
|
100
|
+
`requestPresentedCredential(headers)` identifies KYA signatures, delegation-proof headers, and structurally recognized VC-JWTs. Opaque bearer tokens and unrelated JWTs do not count as delegation credentials. The helper only selects when callers resolve configured trusted roots; the engine verifies credential claims and trust chains.
|
|
4
101
|
|
|
5
102
|
### Changed
|
|
6
103
|
|
|
@@ -477,7 +477,18 @@ export declare const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
|
477
477
|
export declare const SESSION_IDLE_GAP_MAX_MS = 21600000;
|
|
478
478
|
export declare const BEACON_MAX_BATCH_ID_LENGTH = 255;
|
|
479
479
|
export declare const BEACON_ORIGIN_CONTRACT_VERSION = 1;
|
|
480
|
-
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1"];
|
|
480
|
+
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1", "receipt-posture-v1"];
|
|
481
481
|
export declare const POSTURE_TTL_SECONDS = 120;
|
|
482
|
+
export interface CachedPosture {
|
|
483
|
+
token: string;
|
|
484
|
+
expiresAt: number;
|
|
485
|
+
}
|
|
486
|
+
export interface PostureAnswer {
|
|
487
|
+
posture?: CachedPosture;
|
|
488
|
+
postureStatus?: string;
|
|
489
|
+
sessionId?: string;
|
|
490
|
+
answeredAtMs?: number;
|
|
491
|
+
}
|
|
492
|
+
export declare function parsePostureAnswer(value: unknown): PostureAnswer;
|
|
482
493
|
//#endregion
|
|
483
494
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/beacon-types/index.ts"],"mappings":";YAOY;YACA,YAAY,gBAAgB;GAAiB,cAAc;;YAC3D,kBAAkB;YAClB,kBAAkB;YAClB,mBAAmB,eAAe;YAClC,gBAAgB,sBAAsB;YACtC;wBA4KI,iBAAiB,iBAAiB,SAAS;iBA+C1C,+BAA+B;EAC9C;EACA;EACA;EACA;EACA;;iBAGe,wCAAwC;EACvD,aAAa;EACb,gBAAgB;EAChB,mBAAmB;EACnB;EACA;EACA;EACA;;iBAGe,iCAAiC;EAChD;EACA;IACE;;;iBAIa;EACf,gBAAgB;EAChB,aAAa;;iBAGE,+BAA+B;EAC9C;IACE,aACE,cACA;MACE,mBAAmB;MACnB,gBAAgB;QAEjB;;;iBAIU;EACf;EACA;EACA;;iBAGe,8BAA8B;EAC7C,SAAS;EACT,uCAAuC;;iBAGxB,oCAAoC;EACnD;EACA;;iBAiBe;EAKf;;iBAIe;EAEf;EAEA;EAEA;EAEA;EAEA;EAEA;EASA;;iBAGe;EAEf;EAOA,WAAW;EAaX;EAGA;EAGA,OAAO;EAQP;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U;;iBAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;;;iBAIa;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;IACE;IACA;IACA;;EAEF;IACE;IACA;;EAEF;IACE;IACA;IACA;IACA;;EAEF;;iBAGe;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;;YAGU;YAWA;iBAEK;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAWA;;iBAOe;EACf;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;;iBAOe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;;iBAUe;EACf;EACA;EACA;EACA;;iBAIe;EAOf;EAKA;EAEA;IAAY;IAAe;;EAE3B;;iBAGe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;EAEA;EAEA;EAEA;EAIA,YAAY;;iBAGG;EAEf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;GAGC;;YAGS;wBAaI,mBAAmB,iBAAiB;wBAWpC,0BAA0B,iBAAiB;wBAS3C,uBAAuB,iBAAiB;wBA2BxC,yBAAyB,iBAAiB;wBA8C1C,mBAAmB,iBAAiB;wBAkBpC,iBAAiB,iBAAiB;wBAclC,sBAAsB,iBAAiB;wBAcvC,mBAAmB,iBAAiB;qBAUvC;gBAAA;;qBAIA;gBAAA;;wBAIG,wBAAwB,iBAAiB;wBAiCzC,kBACd,gBACA,UAAU,2BACT;qBA6HkB,6BAA6B;EACpC,YAAA,QAAQ;EACpB,QAAQ,mBAAmB,OAAO,gBAAgB;E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BAAgB;EAK1D,cAAc,WAAW,gBAAgB;EAKzC,mBAAmB;EAKnB,aAAa,SAAS,QAAQ;EAK9B,WAAW;;iBAOI;EAEf;EAGA;EAGA;IACE;IACA;;;iBAQa;EAEf;IACE;IACA;IACA;;EAIF;IACE;IACA;;EAIF;IACE;IACA;IACA;;EAIF;IACE;IACA;IACA;IACA;;EAIF;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;;iBAOe;EACf;EACA;EACA;EACA;EACA;EAEA;;iBAGe;EACf;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;;iBAGe;EACf;EACA;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;iBAUK;EACf;EACA;EACA;EACA;EACA;;YAOU;YACA;YAWA;YAQA;iBAEK;EACf;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,WAAW;EACX;;YAGU;YAUA;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;iBAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;;;iBAIa;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;IACE;IACA;IACA;;EAEF;IACE;IACA;;EAEF;IACE;IACA;IACA;IACA;;EAEF;;iBAGe;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;;YAGU;YAWA;iBAEK;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAWA;;iBAOe;EACf;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;;iBAOe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;;iBAUe;EACf;EACA;EACA;EACA;;iBAIe;EAOf;EAKA;EAEA;IAAY;IAAe;;EAE3B;;iBAGe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;EAEA;EAEA;EAEA;EAIA,YAAY;;iBAGG;EAEf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;GAGC;;YAGS;wBAaI,mBAAmB,iBAAiB;wBAWpC,0BAA0B,iBAAiB;wBAS3C,uBAAuB,iBAAiB;wBA2BxC,yBAAyB,iBAAiB;wBA8C1C,mBAAmB,iBAAiB;wBAkBpC,iBAAiB,iBAAiB;wBAclC,sBAAsB,iBAAiB;wBAcvC,mBAAmB,iBAAiB;qBAUvC;gBAAA;;qBAIA;gBAAA;;wBAIG,wBAAwB,iBAAiB;wBAiCzC,kBACd,gBACA,UAAU,2BACT;qBA6HkB,6BAA6B;EACpC,YAAA,QAAQ;EACpB,QAAQ,mBAAmB,OAAO,gBAAgB;EAClD,WAAW,mBAAmB,YAAY,gBAAgB;EAC1D,cAAc,WAAW,gBAAgB;EACzC,mBAAmB;EACnB,aAAa,SAAS,QAAQ;EAC9B,WAAW;;qBAQA;qBAEA;qBACA;qBAEA;qBAEA;qBAWA;iBAEI;EACf;EACA;;iBAGe;EACf,UAAU;EACV;EACA;EACA;;wBAGc,mBAAmB,iBAAiB"}
|
|
@@ -477,7 +477,18 @@ export declare const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
|
477
477
|
export declare const SESSION_IDLE_GAP_MAX_MS = 21600000;
|
|
478
478
|
export declare const BEACON_MAX_BATCH_ID_LENGTH = 255;
|
|
479
479
|
export declare const BEACON_ORIGIN_CONTRACT_VERSION = 1;
|
|
480
|
-
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1"];
|
|
480
|
+
export declare const BEACON_ORIGIN_CAPABILITIES: readonly ["batch-replay-v1", "receipt-status-v1", "receipt-posture-v1"];
|
|
481
481
|
export declare const POSTURE_TTL_SECONDS = 120;
|
|
482
|
+
export interface CachedPosture {
|
|
483
|
+
token: string;
|
|
484
|
+
expiresAt: number;
|
|
485
|
+
}
|
|
486
|
+
export interface PostureAnswer {
|
|
487
|
+
posture?: CachedPosture;
|
|
488
|
+
postureStatus?: string;
|
|
489
|
+
sessionId?: string;
|
|
490
|
+
answeredAtMs?: number;
|
|
491
|
+
}
|
|
492
|
+
export declare function parsePostureAnswer(value: unknown): PostureAnswer;
|
|
482
493
|
//#endregion
|
|
483
494
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/beacon-types/index.ts"],"mappings":";YAOY;YACA,YAAY,gBAAgB;GAAiB,cAAc;;YAC3D,kBAAkB;YAClB,kBAAkB;YAClB,mBAAmB,eAAe;YAClC,gBAAgB,sBAAsB;YACtC;wBA4KI,iBAAiB,iBAAiB,SAAS;iBA+C1C,+BAA+B;EAC9C;EACA;EACA;EACA;EACA;;iBAGe,wCAAwC;EACvD,aAAa;EACb,gBAAgB;EAChB,mBAAmB;EACnB;EACA;EACA;EACA;;iBAGe,iCAAiC;EAChD;EACA;IACE;;;iBAIa;EACf,gBAAgB;EAChB,aAAa;;iBAGE,+BAA+B;EAC9C;IACE,aACE,cACA;MACE,mBAAmB;MACnB,gBAAgB;QAEjB;;;iBAIU;EACf;EACA;EACA;;iBAGe,8BAA8B;EAC7C,SAAS;EACT,uCAAuC;;iBAGxB,oCAAoC;EACnD;EACA;;iBAiBe;EAKf;;iBAIe;EAEf;EAEA;EA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A;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;iBAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;;;iBAIa;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;IACE;IACA;IACA;;EAEF;IACE;IACA;;EAEF;IACE;IACA;IACA;IACA;;EAEF;;iBAGe;EACf;EACA;EACA;EACA;EACA,gBAAgB;EAChB;EACA;EACA;;YAGU;YAWA;iBAEK;EACf,MAAM;EACN,OAAO;EACP,UAAU;EACV;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAWA;;iBAOe;EACf;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;;iBAOe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;;iBAUe;EACf;EACA;EACA;EACA;;iBAIe;EAOf;EAKA;EAEA;IAAY;IAAe;;EAE3B;;iBAGe;EACf;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;EAEA;EAEA;EAEA;EAIA,YAAY;;iBAGG;EAEf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;GAGC;;YAGS;wBAaI,mBAAmB,iBAAiB;wBAWpC,0BAA0B,iBAAiB;wBAS3C,uBAAuB,iBAAiB;wBA2BxC,yBAAyB,iBAAiB;wBA8C1C,mBAAmB,iBAAiB;wBAkBpC,iBAAiB,iBAAiB;wBAclC,sBAAsB,iBAAiB;wBAcvC,mBAAmB,iBAAiB;qBAUvC;gBAAA;;qBAIA;gBAAA;;wBAIG,wBAAwB,iBAAiB;wBAiCzC,kBACd,gBACA,UAA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AW;GAGV;;iBAOc;EAIf,QAAQ,mBAAmB,OAAO,gBAAgB;EAKlD,WAAW,mBAAmB,YAAY,gBAAgB;EAK1D,cAAc,WAAW,gBAAgB;EAKzC,mBAAmB;EAKnB,aAAa,SAAS,QAAQ;EAK9B,WAAW;;iBAOI;EAEf;EAGA;EAGA;IACE;IACA;;;iBAQa;EAEf;IACE;IACA;IACA;;EAIF;IACE;IACA;;EAIF;IACE;IACA;IACA;;EAIF;IACE;IACA;IACA;IACA;;EAIF;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;IACE;IACA;IACA;IACA;IACA;;;iBAQa;EAEf;EAGA;EAGA;EAGA;EAGA;EAGA;EAGA;;iBAOe;EACf;EACA;EACA;EACA;EACA;EAEA;;iBAGe;EACf;EACA;EACA;EACA;EACA,YAAY;EACZ;EACA;;iBAGe;EACf;EACA;EACA;EACA;;YAGU;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;YAGU;iBAUK;EACf;EACA;EACA;EACA;EACA;;YAOU;YACA;YAWA;YAQA;iBAEK;EACf;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,WAAW;EACX;;YAGU;YAUA;iBAEK;EACf;EACA;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;;iBAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;;EAEF;IACE;IACA;;;iBAIa;EACf;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;;iBAGe;EACf;EACA;EACA;EACA;EACA;;iBAGe;EACf;IACE;IACA;IACA;;EAEF;IACE;IACA;;EAEF;IACE;IACA;IACA;IACA;;EAEF;;iBAGe;EACf;EACA;EACA;EAC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
|
341
341
|
const SESSION_IDLE_GAP_MAX_MS = 216e5;
|
|
342
342
|
const BEACON_MAX_BATCH_ID_LENGTH = 255;
|
|
343
343
|
const BEACON_ORIGIN_CONTRACT_VERSION = 1;
|
|
344
|
-
const BEACON_ORIGIN_CAPABILITIES = [
|
|
344
|
+
const BEACON_ORIGIN_CAPABILITIES = [
|
|
345
|
+
"batch-replay-v1",
|
|
346
|
+
"receipt-status-v1",
|
|
347
|
+
"receipt-posture-v1"
|
|
348
|
+
];
|
|
345
349
|
/**
|
|
346
350
|
* Lifetime of the signed browser posture token, in seconds. Defined here and
|
|
347
351
|
* re-exported by `browser-posture.ts` (which imports `jose`) so the
|
|
348
352
|
* size-budgeted beacon bundle can read it without pulling in a JWT library.
|
|
349
353
|
*/
|
|
350
354
|
const POSTURE_TTL_SECONDS = 120;
|
|
355
|
+
function parsePostureAnswer(value) {
|
|
356
|
+
if (!isRecord(value)) return {};
|
|
357
|
+
const answer = {};
|
|
358
|
+
if (isRecord(value.posture) && typeof value.posture.token === "string" && value.posture.token.length > 0 && typeof value.posture.expiresAt === "number" && Number.isFinite(value.posture.expiresAt)) answer.posture = {
|
|
359
|
+
token: value.posture.token,
|
|
360
|
+
expiresAt: value.posture.expiresAt
|
|
361
|
+
};
|
|
362
|
+
else if (typeof value.postureStatus === "string" && value.postureStatus.length <= 64) answer.postureStatus = value.postureStatus;
|
|
363
|
+
if (typeof value.sessionId === "string" && value.sessionId.length <= 255) answer.sessionId = value.sessionId;
|
|
364
|
+
if (typeof value.answeredAtMs === "number" && Number.isFinite(value.answeredAtMs)) answer.answeredAtMs = value.answeredAtMs;
|
|
365
|
+
return answer;
|
|
366
|
+
}
|
|
351
367
|
|
|
352
368
|
//#endregion
|
|
353
369
|
exports.BEACON_MAX_BATCH_ID_LENGTH = BEACON_MAX_BATCH_ID_LENGTH;
|
|
@@ -363,6 +379,7 @@ exports.parseBeaconConfig = parseBeaconConfig;
|
|
|
363
379
|
exports.parseBeaconWorkerMessage = parseBeaconWorkerMessage;
|
|
364
380
|
exports.parseCircuitBreakerConfig = parseCircuitBreakerConfig;
|
|
365
381
|
exports.parseOfflineQueueEntry = parseOfflineQueueEntry;
|
|
382
|
+
exports.parsePostureAnswer = parsePostureAnswer;
|
|
366
383
|
exports.parseResourceUsage = parseResourceUsage;
|
|
367
384
|
exports.parseRetryStrategy = parseRetryStrategy;
|
|
368
385
|
exports.parseWorkerCapabilities = parseWorkerCapabilities;
|
|
@@ -340,14 +340,30 @@ const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
|
340
340
|
const SESSION_IDLE_GAP_MAX_MS = 216e5;
|
|
341
341
|
const BEACON_MAX_BATCH_ID_LENGTH = 255;
|
|
342
342
|
const BEACON_ORIGIN_CONTRACT_VERSION = 1;
|
|
343
|
-
const BEACON_ORIGIN_CAPABILITIES = [
|
|
343
|
+
const BEACON_ORIGIN_CAPABILITIES = [
|
|
344
|
+
"batch-replay-v1",
|
|
345
|
+
"receipt-status-v1",
|
|
346
|
+
"receipt-posture-v1"
|
|
347
|
+
];
|
|
344
348
|
/**
|
|
345
349
|
* Lifetime of the signed browser posture token, in seconds. Defined here and
|
|
346
350
|
* re-exported by `browser-posture.ts` (which imports `jose`) so the
|
|
347
351
|
* size-budgeted beacon bundle can read it without pulling in a JWT library.
|
|
348
352
|
*/
|
|
349
353
|
const POSTURE_TTL_SECONDS = 120;
|
|
354
|
+
function parsePostureAnswer(value) {
|
|
355
|
+
if (!isRecord(value)) return {};
|
|
356
|
+
const answer = {};
|
|
357
|
+
if (isRecord(value.posture) && typeof value.posture.token === "string" && value.posture.token.length > 0 && typeof value.posture.expiresAt === "number" && Number.isFinite(value.posture.expiresAt)) answer.posture = {
|
|
358
|
+
token: value.posture.token,
|
|
359
|
+
expiresAt: value.posture.expiresAt
|
|
360
|
+
};
|
|
361
|
+
else if (typeof value.postureStatus === "string" && value.postureStatus.length <= 64) answer.postureStatus = value.postureStatus;
|
|
362
|
+
if (typeof value.sessionId === "string" && value.sessionId.length <= 255) answer.sessionId = value.sessionId;
|
|
363
|
+
if (typeof value.answeredAtMs === "number" && Number.isFinite(value.answeredAtMs)) answer.answeredAtMs = value.answeredAtMs;
|
|
364
|
+
return answer;
|
|
365
|
+
}
|
|
350
366
|
|
|
351
367
|
//#endregion
|
|
352
|
-
export { BEACON_MAX_BATCH_ID_LENGTH, BEACON_MAX_EVENTS_PER_BATCH, BEACON_ORIGIN_CAPABILITIES, BEACON_ORIGIN_CONTRACT_VERSION, POSTURE_TTL_SECONDS, ResourceUsageSchema, SESSION_IDLE_GAP_MAX_MS, WorkerPoolConfigSchema, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
|
|
368
|
+
export { BEACON_MAX_BATCH_ID_LENGTH, BEACON_MAX_EVENTS_PER_BATCH, BEACON_ORIGIN_CAPABILITIES, BEACON_ORIGIN_CONTRACT_VERSION, POSTURE_TTL_SECONDS, ResourceUsageSchema, SESSION_IDLE_GAP_MAX_MS, WorkerPoolConfigSchema, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parsePostureAnswer, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
|
|
353
369
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/beacon-types/index.ts"],"sourcesContent":["/**\n * Public TypeScript types for Checkpoint Beacon\n *\n * This package contains only the public API types needed by beacon consumers.\n * No implementation details or detection rules are included.\n */\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue | undefined };\nexport type BeaconPrimitive = JsonPrimitive;\nexport type BeaconJsonValue = JsonValue;\nexport type BeaconCustomData = Record<string, JsonValue | undefined>;\nexport type BeaconPayload = BeaconCollectorData | BeaconCustomData | null;\nexport type WorkerPayload = unknown;\ntype UnknownRecord = Record<string, unknown>;\n\nfunction isRecord(input: unknown): input is UnknownRecord {\n return typeof input === 'object' && input !== null && !Array.isArray(input);\n}\n\nfunction toRecord(input: unknown): UnknownRecord {\n return isRecord(input) ? input : {};\n}\n\nfunction numberOr<Fallback extends number | undefined>(\n value: unknown,\n fallback: Fallback\n): number | Fallback {\n return typeof value === 'number' && Number.isFinite(value) && value !== 0 ? value : fallback;\n}\n\n/**\n * Validates a numeric config value against `ok`, falling back to `fallback`\n * when it fails. Only calls `onReject` when the caller actually supplied a\n * value (an `undefined` field, the common case, is not a rejection, it just\n * never overrode the default): H0BB5 (PR #5095 review, item 4) — a rejected\n * value used to fall back silently, with no way for a host to discover a\n * config typo.\n */\nfunction boundedNumberOr(\n value: unknown,\n fallback: number,\n ok: (n: number) => boolean,\n onReject?: (received: unknown) => void\n): number {\n if (typeof value === 'number' && Number.isFinite(value) && ok(value)) return value;\n if (value !== undefined) onReject?.(value);\n return fallback;\n}\n\n/** Same as `boundedNumberOr`, but an absent/rejected value stays `undefined` rather than defaulting. */\nfunction optionalPositiveNumber(\n value: unknown,\n onReject?: (received: unknown) => void\n): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'number' && Number.isFinite(value) && value > 0) return value;\n onReject?.(value);\n return undefined;\n}\n\n/** Same as `optionalPositiveNumber`, without the positivity requirement (a jitter seed may be any finite number). */\nfunction optionalFiniteNumber(\n value: unknown,\n onReject?: (received: unknown) => void\n): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n onReject?.(value);\n return undefined;\n}\n\n/** Same shape as `boundedNumberOr`/`optionalPositiveNumber`, for a boolean config flag. */\nfunction booleanOr(\n value: unknown,\n fallback: boolean,\n onReject?: (received: unknown) => void\n): boolean {\n if (value === undefined) return fallback;\n if (typeof value === 'boolean') return value;\n onReject?.(value);\n return fallback;\n}\n\n/** Ingest's own `sessionId` bound (1-255), limited to characters a cookie value carries unescaped. */\nconst RESUMABLE_SESSION_ID = /^[A-Za-z0-9._~-]{1,255}$/;\n\nfunction resumableSessionId(\n value: unknown,\n onReject?: (received: unknown) => void\n): string | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'string' && RESUMABLE_SESSION_ID.test(value)) return value;\n onReject?.(value);\n return undefined;\n}\n\nfunction receiptCallback(\n value: unknown,\n onReject?: (received: unknown) => void\n): BeaconConfig['onReceipt'] {\n if (value === undefined) return undefined;\n if (typeof value === 'function') return value as BeaconConfig['onReceipt'];\n onReject?.(value);\n return undefined;\n}\n\nconst DISPATCH_TRIGGER_NAMES = [\n 'arrival',\n 'signals',\n 'interaction',\n 'untrusted',\n 'posture',\n 'unload',\n 'navigation',\n] as const satisfies readonly (keyof BeaconDispatchTriggers)[];\n\n/**\n * Keeps only the known trigger names with a real boolean; anything else is\n * dropped and, when the caller actually named a known trigger with a\n * non-boolean value (`triggers: { posture: 0 }`, say), reported through\n * `onReject` — H0BB5 (PR #5095 review, item 4): a numeric `0` used to be\n * dropped silently and that trigger stayed at its default-enabled state,\n * the opposite of what the \"0 is falsy\" convention suggests.\n */\nfunction pickTriggers(\n value: unknown,\n onReject?: (name: string, received: unknown) => void\n): BeaconDispatchTriggers | undefined {\n if (!isRecord(value)) return undefined;\n const picked: BeaconDispatchTriggers = {};\n for (const name of DISPATCH_TRIGGER_NAMES) {\n const raw = value[name];\n if (typeof raw === 'boolean') {\n picked[name] = raw;\n } else if (raw !== undefined) {\n onReject?.(name, raw);\n }\n }\n return picked;\n}\n\nfunction stringOr(value: unknown, fallback?: string): string | undefined {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\n/**\n * Non-empty on purpose: an empty schedule would mean \"zero posture-recovery\n * attempts\", silently disabling recovery rather than configuring it. A\n * deployment that actually wants no retries sets `flushInterval` instead.\n */\nfunction isPositiveNumberArray(value: unknown): value is number[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((entry) => typeof entry === 'number' && Number.isFinite(entry) && entry > 0)\n );\n}\n\nfunction isBeaconTags(value: unknown): value is Record<string, string | number | boolean> {\n return (\n isRecord(value) &&\n Object.values(value).every(\n (entry) =>\n typeof entry === 'string' || typeof entry === 'number' || typeof entry === 'boolean'\n )\n );\n}\n\n/**\n * Exported because `parseBeaconConfig` is an allowlist: a key it does not\n * name is dropped, silently. The beacon's other public entry point\n * (`checkpoint-shared/browser`) carries its own copy of that allowlist, so\n * the CHECK at least lives in one place even while the two parsers do not —\n * see the note on `BeaconConfig.identity`.\n *\n * Rejects an identity with no usable `userId` rather than passing through a\n * half-formed object: downstream this becomes `detections.user_id`, and an\n * empty string there is worse than an absent one — it reads as \"identified\"\n * while naming nobody.\n */\nexport function isBeaconIdentity(value: unknown): value is BeaconIdentity {\n return isRecord(value) && typeof value.userId === 'string' && value.userId.length > 0;\n}\n\nfunction isLogLevel(value: unknown): value is BeaconConfig['logLevel'] {\n return value === 'error' || value === 'warn' || value === 'info' || value === 'debug';\n}\n\nfunction isBeaconWorkerMessageType(value: unknown): value is BeaconWorkerMessageType {\n return (\n value === 'init' ||\n value === 'collect' ||\n value === 'flush' ||\n value === 'config' ||\n value === 'status' ||\n value === 'error' ||\n // `beacon.worker.ts`'s `respond()` has always sent this on every\n // successful request (init/collect/flush/config/status) — the allowlist\n // just never named it, so `parseBeaconWorkerMessage` silently coerced\n // every success response to `'init'` (see that function's fallback).\n value === 'response' ||\n value === 'posture'\n );\n}\n\n/**\n * Resolves whether a beacon should use its Web Worker transport.\n *\n * `enableWebWorker` is accepted as an alias for `useWorker`: the package's\n * own test suite (`checkpoint-beacon/src/index.test.ts`) has always\n * constructed with `enableWebWorker: false`, but `parseBeaconConfig`'s\n * allowlist only ever named `useWorker`, so that key was silently dropped —\n * the beacon kept auto-detecting worker support regardless of what the\n * caller passed. `useWorker` wins when both are set, since it's the\n * canonical name every other config field (`workerUrl`, `workerConfig`)\n * pairs with.\n */\nfunction resolveUseWorker(config: UnknownRecord): boolean {\n if (typeof config.useWorker === 'boolean') {\n return config.useWorker;\n }\n if (typeof config.enableWebWorker === 'boolean') {\n return config.enableWebWorker;\n }\n return true;\n}\n\nexport interface NetworkInformationLike extends EventTarget {\n type?: string;\n effectiveType?: string;\n downlink?: number;\n rtt?: number;\n saveData?: boolean;\n}\n\nexport interface NavigatorWithNetworkInformation extends Navigator {\n connection?: NetworkInformationLike;\n mozConnection?: NetworkInformationLike;\n webkitConnection?: NetworkInformationLike;\n deviceMemory?: number;\n vendorSub: string;\n doNotTrack: string | null;\n msDoNotTrack?: string | null;\n}\n\nexport interface WindowWithBeaconMetadata extends Window {\n doNotTrack?: string | null;\n __NEXT_DATA__?: {\n buildId?: string;\n };\n}\n\nexport interface TrustedTypePolicyLike {\n createScriptURL(url: string): string;\n createScript(script: string): string;\n}\n\nexport interface WindowWithTrustedTypes extends Window {\n trustedTypes?: {\n createPolicy(\n name: string,\n rules: {\n createScriptURL?: (url: string) => string;\n createScript?: (script: string) => string;\n }\n ): TrustedTypePolicyLike;\n };\n}\n\nexport interface PerformanceMemoryInfo {\n usedJSHeapSize: number;\n totalJSHeapSize: number;\n jsHeapSizeLimit: number;\n}\n\nexport interface PerformanceWithMemory extends Performance {\n memory?: PerformanceMemoryInfo;\n measureUserAgentSpecificMemory?: () => Promise<unknown>;\n}\n\nexport interface LargestContentfulPaintEntry extends PerformanceEntry {\n renderTime?: number;\n loadTime?: number;\n}\n\n// ============================================================================\n// BEACON CONFIGURATION\n// ============================================================================\n\n/**\n * Who the current visitor is, when the host site knows.\n *\n * Deliberately just the id. The pixel's `identify` call also carries\n * `previousId` and `userTraits`, but those drive the server's profile and\n * alias-graph pipeline (tenant salt, profile-copy, write advisory locks),\n * which the beacon ingest route does not run — accepting them here would mean\n * collecting personal data the beacon path then silently discards. Both are\n * additive later: this is an optional field on an optional object.\n */\nexport interface BeaconIdentity {\n /**\n * The host site's own id for the signed-in user. Capped at 255 characters\n * to match `detections.user_id`; a longer value is rejected at ingest.\n */\n userId: string;\n}\n\n/** The beacon's automatic sends, each switchable off. See `BeaconConfig.triggers`. */\nexport interface BeaconDispatchTriggers {\n /** The `pageview` at construction and on consent restore. */\n arrival?: boolean;\n /** The follow-up send when the lazy signals chunk resolves after arrival missed it. */\n signals?: boolean;\n /** First interaction, first timing sample, and evidence growth. */\n interaction?: boolean;\n /** The first script-dispatched (untrusted) input. */\n untrusted?: boolean;\n /** An interaction after the posture token has gone stale. */\n posture?: boolean;\n /** The SDK-wired `visibilitychange` and `pagehide` critical send. */\n unload?: boolean;\n /**\n * The `pageview` for a page the visitor arrives at without a full load: a\n * back/forward-cache restore (`pageshow` with `persisted`, trigger\n * `bfcache_restore`) and a soft navigation that changes the path\n * (History API or Navigation API, trigger `soft_navigation`). Turn it off\n * when the host already calls `collect('pageview')` on its own route\n * changes, or each one sends twice.\n */\n navigation?: boolean;\n}\n\nexport interface BeaconConfig {\n /** Project ID for tracking (same as pixel data-project-id) */\n projectId: string;\n\n /**\n * Who the visitor is, when the page already knows at construction time.\n * When identity only becomes known later (a login part-way through the\n * session), call `identify()` instead.\n */\n identity?: BeaconIdentity;\n\n /**\n * Where batches are POSTed. Defaults to the hosted ingest endpoint declared\n * in `NETWORK_CONTRACT.md`.\n *\n * Set it to send somewhere else — a self-hosted deployment, a regional\n * install, or a test origin. An override means the destination is the\n * integrator's, not ours, so `NETWORK_CONTRACT.md` describes the DEFAULT and\n * says so explicitly.\n *\n * @default 'https://kya.vouched.id/api/v1/beacon'\n */\n endpoint?: string;\n\n /** Optional environment tag for data segmentation */\n environment?: 'development' | 'staging' | 'production' | string;\n\n /** Optional tags for custom data segmentation */\n tags?: Record<string, string | number | boolean>;\n\n /**\n * Not read by the SDK. Construct the beacon only when it should run, and\n * call `destroy()` to stop it.\n *\n * @deprecated\n */\n enabled?: boolean;\n\n /**\n * Verbose console logging.\n *\n * @default false\n */\n debug?: boolean;\n\n /**\n * Log verbosity.\n *\n * @default 'error'\n */\n logLevel?: 'error' | 'warn' | 'info' | 'debug';\n\n /**\n * When the browser sends Do Not Track, the beacon collects and sends nothing.\n *\n * @default true\n */\n respectDoNotTrack?: boolean;\n\n /**\n * Accepted and ignored. The beacon no longer withholds anything on\n * consent; only Do Not Track stops collection.\n *\n * @deprecated has no effect\n * @default false\n */\n requireConsent?: boolean;\n\n /**\n * Truncate the stored IP to /24 (IPv4) or /48 (IPv6) before persistence.\n *\n * @default false\n */\n anonymizeIp?: boolean;\n\n /**\n * Strip the `#fragment` from the `url`/`referrer` collector fields before\n * they leave the page. Defaults to `true`: a fragment is never sent to\n * the server by the browser in the first place for any OTHER surface\n * (it is script-visible only), so a beacon that forwards it is the one\n * place it can leak — and it is also the highest-risk part of the URL,\n * since SPA routers, magic-link auth, and OAuth implicit-flow responses\n * all put tokens there. Set to `false` only if a project genuinely\n * consumes `url`'s fragment server-side.\n *\n * @default true\n */\n stripUrlFragment?: boolean;\n\n /**\n * Query parameter names (matched case-insensitively) to redact from the\n * `url`/`referrer` collector fields before they leave the page. Each\n * matching value is replaced with the literal string `\"[redacted]\"`; the\n * parameter itself stays present so the URL's shape is unchanged. Empty\n * by default — nothing is scrubbed unless a project opts in with the\n * param names it puts tokens/PII behind (e.g. `[\"token\", \"email\"]`).\n * Ignored for a parameter when `dropQueryParams` is also `true`, since\n * there is no query string left to scrub.\n *\n * @default []\n */\n scrubQueryParams?: string[];\n\n /**\n * Drop the entire query string from the `url`/`referrer` collector\n * fields before they leave the page. Off by default. Takes priority over\n * `scrubQueryParams` when both are set — there is nothing left to scrub\n * once the whole query string is gone.\n *\n * @default false\n */\n dropQueryParams?: boolean;\n\n /**\n * Idle-gap override in milliseconds, at most six hours. Unset: one hour on\n * phones, six hours elsewhere. Every send extends it.\n */\n sessionTimeout?: number;\n\n /**\n * Name of the visitor session cookie shared by pixel, beacon, gateway, and\n * SDK rows. Query it with `?sessionId=` on the\n * [detections endpoint](/docs/api-reference#get-project-detections).\n *\n * @default '_as_beacon_session'\n */\n sessionCookieName?: string;\n\n /**\n * Resume a browser session id the page stored earlier (a receipt's\n * `browserSessionId`, see `onReceipt`) instead of reading the session\n * cookie or minting a new id. With cookies off this is the only way two\n * page loads stay one session, and a posture token verifies only against\n * the session id it was issued to. 1 to 255 characters of\n * `A-Z a-z 0-9 . _ ~ -`; anything else is ignored with a warning.\n * `updateConfig({ browserSessionId })` switches a running beacon to it.\n */\n browserSessionId?: string;\n\n /**\n * Called with every ingest receipt: the server's session id, the browser\n * session id the batch was sent under, and the posture token or the reason\n * there is none. Runs on the main thread in worker mode too, after the\n * posture cookie write. An error it throws is logged at `warn` and never\n * affects delivery.\n */\n onReceipt?: (receipt: BeaconReceipt) => void;\n\n /**\n * @deprecated The beacon no longer batches; every dispatch sends\n * immediately. Accepted and ignored so a caller upgrading from an older\n * SDK version keeps compiling and does not need to touch its config.\n */\n batchSize?: number;\n\n /**\n * @deprecated The beacon no longer polls on an interval; it dispatches on\n * evidence transitions instead (arrival, first interaction, evidence\n * doubling, untrusted input, posture staleness, hidden/pagehide). Accepted\n * and ignored so a caller upgrading from an older SDK version keeps\n * compiling and does not need to touch its config.\n */\n flushInterval?: number;\n\n /**\n * How much `keyDwellCount + pressCount + untrustedEvents` has to grow, as a\n * multiple of its value at the last send, before an interaction sends\n * again. 2 sends at 1, 2, 4, 8, 16 samples; 1.5 sends more often, 3 less.\n * A value at or below 1 falls back to the default.\n *\n * @default 2\n */\n evidenceGrowthFactor?: number;\n\n /**\n * Fraction of the posture token's lifetime after which a counted\n * interaction sends again, so the token stays fresh under a live hand.\n * 0.5 refreshes the 120 s token once an interaction lands more than 60 s\n * after the last send. A value outside (0, 1] falls back to the default.\n *\n * @default 0.5\n */\n postureRefreshFraction?: number;\n\n /**\n * Which automatic sends fire. Every trigger is on unless set to `false`.\n * Turning `unload` off leaves `trackPageUnload()` available for a host\n * that wires its own listener; turning `arrival` off leaves `collect()`.\n */\n triggers?: BeaconDispatchTriggers;\n\n /**\n * Low-frequency backstop that refreshes posture on a jittered timer,\n * independent of interaction, so a visitor who goes idle past the posture\n * TTL with no counted interaction is not one stale click on a critical\n * action away from an expired token (H0BB5, PR #5095 review). The actual\n * interval on each tick is `proactiveRefreshMinIntervalMs` plus a random\n * `[0, max - min)` jitter, so a fleet of clients loaded at the same moment\n * does not all refresh on the same wall-clock boundary. Paused while the\n * page is hidden, resumed on `visibilitychange`. Gated by\n * `triggers.posture`, the same switch that already turns off the\n * interaction-triggered staleness check — this timer is that same\n * `'posture'` trigger firing proactively, not a second mechanism. A\n * non-positive value falls back to the default.\n *\n * @default 30000\n */\n proactiveRefreshMinIntervalMs?: number;\n\n /**\n * The upper bound of the proactive-refresh jitter window; see\n * `proactiveRefreshMinIntervalMs`. A non-positive value falls back to the\n * default; a value below `proactiveRefreshMinIntervalMs` degrades to the\n * minimum on every tick rather than throwing.\n *\n * @default 60000\n */\n proactiveRefreshMaxIntervalMs?: number;\n\n /**\n * How old the last send must be, in milliseconds, before a visibility\n * resume forces an immediate posture refresh. Defaults to the same\n * threshold the interaction-triggered check already uses\n * (`postureRefreshFraction` of the posture token's lifetime), so the two\n * stay in lockstep unless a host deliberately wants the visibility check\n * to be stricter or looser. A non-positive value falls back to that\n * default.\n */\n proactiveRefreshFreshnessMs?: number;\n\n /**\n * On `visibilitychange` back to visible, force an immediate posture\n * refresh when it is stale (see `proactiveRefreshFreshnessMs`); a fresh\n * tab regaining focus does not get an unnecessary send either way. Set to\n * `false` to leave visibility resume to the plain interval alone.\n *\n * @default true\n */\n proactiveRefreshOnVisibilityResume?: boolean;\n\n /**\n * Refresh posture (and drain anything the offline queue is still holding)\n * when the browser fires `online`. Set to `false` to leave reconnection\n * recovery to the offline queue's own `online` listener alone.\n *\n * @default true\n */\n proactiveRefreshOnOnline?: boolean;\n\n /**\n * A fixed seed for the proactive-refresh jitter roll, for deterministic\n * tests. Omit in production for real `Math.random()` jitter.\n */\n proactiveRefreshJitterSeed?: number;\n\n /**\n * Per-collector deadline in milliseconds. A collector still running past\n * this deadline is dropped from the current collection round rather than\n * awaited further — see `collectWithDeadline` in checkpoint-beacon.\n * Default and rationale documented in checkpoint-beacon's\n * `src/budget/thresholds.ts`.\n *\n * @default 1600\n */\n collectorDeadlineMs?: number;\n\n /**\n * Maximum number of queued events.\n *\n * @default 100\n */\n maxQueueSize?: number;\n\n /**\n * Retry count for failed sends.\n *\n * @default 3\n */\n retryAttempts?: number;\n\n /**\n * Base retry delay in milliseconds.\n *\n * @default 2000\n */\n retryDelay?: number;\n\n /**\n * Delays in milliseconds between posture-recovery attempts after a\n * durably-queued ingest response that carried no posture verdict. The\n * array's length is the attempt ceiling. Defaults to the shipped ladder;\n * override only in tests and in a self-hosted deployment with a\n * different outage profile.\n */\n postureRetryScheduleMs?: number[];\n\n /**\n * Prefer a Web Worker for event processing, batching, and transport.\n * Page-dependent collection remains on the main thread. Unsupported\n * browsers fall back to the main thread; SSR never starts a worker.\n * Set false to disable the processing worker.\n *\n * @default true\n */\n useWorker?: boolean;\n\n /**\n * Alias for `useWorker`, accepted for callers using the older option\n * name. When both are set, `useWorker` wins — see `resolveUseWorker`.\n */\n enableWebWorker?: boolean;\n\n /**\n * URL of the worker script (`beacon.worker.js`, exported as\n * `@kya-os/checkpoint-beacon/worker`). Classic workers must be same-origin.\n * When unset, the beacon derives `beacon.worker.js` next to the `<script>`\n * tag that loaded `beacon.min.js`, else `/beacon.worker.js` at the site root.\n */\n workerUrl?: string;\n\n /**\n * Worker lifecycle tuning: `initTimeoutMs` (3000), `messageTimeout` (30000),\n * `heartbeatInterval` (5000), `maxRetries` (3), `retryDelay` (1000),\n * `compressionThreshold` (5120), `allowFallback` (true).\n */\n workerConfig?: WorkerConfig;\n\n lazySignalsUrl?: string;\n}\n\n// ============================================================================\n// BEACON EVENTS\n// ============================================================================\n\nexport interface BeaconEvent {\n /** Event type identifier */\n type: BeaconEventType;\n\n /** Event data payload */\n data: BeaconCollectorData;\n\n /** Event metadata */\n metadata: BeaconMetadata;\n}\n\nexport interface BeaconMetadata {\n /** Session ID */\n sessionId: string;\n\n /** Event timestamp */\n timestamp: number;\n\n /** Optional event name */\n eventName?: string;\n\n /** Present only once the host site has told us who the visitor is. */\n identity?: BeaconIdentity;\n\n /** Allow additional metadata */\n [key: string]: unknown;\n}\n\n// ============================================================================\n// BEACON API\n// ============================================================================\n\nexport interface IAgentShieldBeacon {\n /**\n * Collect a generic event\n */\n collect(eventType: string, data?: BeaconPayload): Promise<void>;\n\n /**\n * Track a custom event\n */\n trackEvent(eventName: string, eventData?: BeaconPayload): Promise<void>;\n\n /**\n * Track a pageview\n */\n trackPageview(pageData?: BeaconPayload): Promise<void>;\n\n /**\n * Track page unload\n */\n trackPageUnload(): Promise<void>;\n\n /**\n * Update configuration\n */\n updateConfig(updates: Partial<BeaconConfig>): void;\n\n /**\n * Destroy the beacon and clean up\n */\n destroy(): Promise<void>;\n}\n\n// ============================================================================\n// RESPONSE TYPES\n// ============================================================================\n\nexport interface BeaconResponse {\n /** Response status */\n status: 'success' | 'error';\n\n /** Optional message */\n message?: string;\n\n /** Optional error details */\n error?: {\n code: string;\n message: string;\n };\n}\n\n// ============================================================================\n// BROWSER CONTEXT\n// ============================================================================\n\nexport interface BrowserContext {\n /** Browser name and version */\n browser: {\n name: string;\n version: string;\n engine: string;\n };\n\n /** Operating system */\n os: {\n name: string;\n version: string;\n };\n\n /** Device information */\n device: {\n type: 'desktop' | 'mobile' | 'tablet' | 'tv' | 'unknown';\n vendor?: string;\n model?: string;\n };\n\n /** Screen information */\n screen: {\n width: number;\n height: number;\n pixelRatio: number;\n colorDepth: number;\n };\n\n /** Connection information */\n connection?: {\n type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';\n effectiveType?: '2g' | '3g' | '4g' | '5g';\n downlink?: number;\n rtt?: number;\n saveData?: boolean;\n };\n}\n\n// ============================================================================\n// PERFORMANCE METRICS\n// ============================================================================\n\nexport interface PerformanceMetrics {\n /** Page load time in milliseconds */\n pageLoadTime?: number;\n\n /** DOM content loaded time */\n domContentLoadedTime?: number;\n\n /** Time to interactive */\n timeToInteractive?: number;\n\n /** First paint time */\n firstPaintTime?: number;\n\n /** First contentful paint time */\n firstContentfulPaintTime?: number;\n\n /** Largest contentful paint time */\n largestContentfulPaintTime?: number;\n\n /** DNS lookup time */\n dnsLookupTime?: number;\n\n /** TCP connection time */\n tcpConnectionTime?: number;\n\n /** Server response time */\n serverResponseTime?: number;\n\n /** Resource timing */\n resources?: {\n scripts: number;\n stylesheets: number;\n images: number;\n fonts: number;\n total: number;\n };\n}\n\n// ============================================================================\n// SESSION TYPES\n// ============================================================================\n\nexport interface SessionData {\n /** Unique session ID */\n id: string;\n\n /** Session start timestamp */\n startTime: number;\n\n /** Last activity timestamp */\n lastActivity: number;\n\n /** Page view count in session */\n pageViews: number;\n\n /** Event count in session */\n eventCount: number;\n\n /** Session duration in milliseconds */\n duration: number;\n\n /** Is this a new session */\n isNew: boolean;\n}\n\n// ============================================================================\n// TRANSPORT TYPES\n// ============================================================================\n\nexport interface TransportConfig {\n maxRetries: number;\n retryDelayBase: number;\n offlineQueueSize: number;\n useCompression: boolean;\n compressionThreshold: number;\n /** Build item 6: carried onto every outgoing `BeaconBatch` — see `BeaconConfig.anonymizeIp`. */\n anonymizeIp?: boolean;\n}\n\nexport interface TransportOptions {\n immediate?: boolean;\n priority?: 'low' | 'normal' | 'high' | 'critical';\n retry?: boolean;\n timeout?: number;\n publicJwk?: EcPublicJwk;\n deviceId?: string;\n handoffToken?: string;\n}\n\nexport interface TransportResponse {\n success: boolean;\n timestamp: number;\n batchId?: string;\n error?: string;\n}\n\nexport type TransportState = 'idle' | 'sending' | 'offline' | 'paused' | 'error';\n\nexport interface TransportMetrics {\n eventsSent: number;\n eventsFailed: number;\n eventsQueued: number;\n batchesSent: number;\n batchesFailed: number;\n bytesTransferred: number;\n compressionRatio?: number;\n averageLatency?: number;\n lastSuccessTimestamp?: number;\n lastErrorTimestamp?: number;\n}\n\nexport type ConnectionType =\n | 'bluetooth'\n | 'cellular'\n | 'ethernet'\n | 'none'\n | 'wifi'\n | 'wimax'\n | 'other'\n | 'unknown';\n\nexport interface NetworkInfo {\n type?: string;\n effectiveType?: string;\n downlink?: number;\n rtt?: number;\n saveData?: boolean;\n}\n\n// ============================================================================\n// WORKER TYPES\n// ============================================================================\n\nexport type MessagePriority = 'low' | 'normal' | 'high' | 'critical';\nexport type WorkerErrorType =\n | 'initialization'\n | 'runtime'\n | 'communication'\n | 'timeout'\n | 'memory'\n | 'network'\n | 'permission'\n | 'validation'\n | 'processing'\n | 'unknown';\nexport type WorkerAction =\n | 'process'\n | 'init'\n | 'terminate'\n | 'pause'\n | 'resume'\n | 'status'\n | 'health';\nexport type WorkerMessageType = 'request' | 'response' | 'error' | 'heartbeat' | 'status';\n\nexport interface WorkerMessage {\n id: string;\n type: 'request' | 'response' | 'error' | 'heartbeat' | 'status';\n action?: string;\n payload?: WorkerPayload;\n timestamp: number;\n compressed?: boolean;\n priority?: MessagePriority;\n correlationId?: string;\n}\n\nexport type WorkerState =\n | 'idle'\n | 'initializing'\n | 'ready'\n | 'processing'\n | 'busy'\n | 'error'\n | 'terminating'\n | 'terminated';\n\nexport type WorkerHealthStatus = 'healthy' | 'degraded' | 'unhealthy' | 'unknown';\n\nexport interface WorkerMetrics {\n tasksProcessed: number;\n tasksFailed: number;\n averageProcessingTime?: number;\n memoryUsage?: number;\n cpuUsage?: number;\n healthStatus: WorkerHealthStatus;\n lastHealthCheck: number;\n restartCount: number;\n errorRate?: number;\n errorCount: number;\n messageQueueSize: number;\n startTime: number;\n uptime: number;\n averageTaskTime?: number;\n lastTaskTime?: number;\n}\n\nexport interface WorkerError {\n type: WorkerErrorType;\n code?: string;\n message: string;\n stack?: string;\n timestamp: number;\n recoverable: boolean;\n retryAfter?: number;\n context?: Record<string, unknown>;\n}\n\nexport interface WorkerCapabilities {\n workerAPI: boolean;\n sharedArrayBuffer: boolean;\n transferableObjects: boolean;\n offscreenCanvas: boolean;\n webAssembly: boolean;\n atomics: boolean;\n bigInt: boolean;\n csp: {\n workerSrc: boolean;\n scriptSrc: boolean;\n blobUrls: boolean;\n inlineWorkers: boolean;\n };\n performance: {\n memory: boolean;\n measureUserAgentSpecificMemory: boolean;\n };\n}\n\nexport interface WorkerTask {\n id: string;\n type: string;\n data: WorkerPayload;\n priority: 'low' | 'normal' | 'high' | 'critical';\n createdAt: number;\n startedAt?: number;\n completedAt?: number;\n error?: WorkerError;\n maxRetries?: number;\n retries?: number;\n timeout?: number;\n}\n\nexport interface FallbackOptions {\n useRequestIdleCallback: boolean;\n idleTimeout: number;\n chunkSize: number;\n throttleMs: number;\n maxExecutionTime: number;\n}\n\nexport interface ResourceUsage {\n memory: {\n used: number;\n limit: number;\n percentage: number;\n };\n cpu: {\n usage: number;\n limit: number;\n };\n tasks: {\n pending: number;\n active: number;\n completed: number;\n failed: number;\n };\n activeWorkers: number;\n}\n\nexport interface WorkerPoolConfig {\n maxWorkers: number;\n minWorkers: number;\n workerIdleTimeout: number;\n taskQueueSize: number;\n resourceLimits: Record<string, number>;\n autoScale?: boolean;\n scaleUpThreshold?: number;\n scaleDownThreshold?: number;\n}\n\nexport type BeaconWorkerMessageType =\n | 'init'\n | 'collect'\n | 'flush'\n | 'config'\n | 'status'\n | 'error'\n | 'response'\n // Unsolicited worker -> main relay of a 202 ingest body (posture cookie\n // delivery needs `document`, which the worker lacks).\n | 'posture';\nexport type ProtocolVersion = '1.0' | '1.1' | '2.0';\n\nexport interface BeaconWorkerMessage {\n type: BeaconWorkerMessageType;\n data?: WorkerPayload;\n payload?: WorkerPayload;\n messageId: string;\n timestamp: number;\n id: string;\n}\n\nexport interface WorkerConfig {\n enabled?: boolean;\n url?: string;\n heartbeatInterval?: number;\n maxUnhealthyCount?: number;\n maxRetries?: number;\n retryDelay?: number;\n restartDelay?: number;\n messageTimeout?: number;\n compressionThreshold?: number;\n allowFallback?: boolean;\n crossOriginIsolated?: boolean;\n maxRestartAttempts?: number;\n terminationTimeout?: number;\n taskTimeout?: number;\n fallbackDelay?: number;\n enableFallback?: boolean;\n /**\n * Hard ceiling on how long worker startup (script load + init handshake)\n * gets before the caller gives up and falls back to the main-thread\n * transport. Deliberately separate from `taskTimeout`/`messageTimeout`\n * (which govern steady-state message round trips once the worker is\n * already up): a slow or hung worker script would otherwise hold up\n * every event for the full 30s message timeout before anything left the\n * page. A few seconds is enough for a healthy worker to load and answer\n * its init message; anything slower isn't worth waiting on.\n */\n initTimeoutMs?: number;\n}\n\n// ============================================================================\n// CIRCUIT BREAKER & RETRY\n// ============================================================================\n\nexport interface CircuitBreakerConfig {\n threshold: number;\n timeout: number;\n resetTimeout: number;\n}\n\nexport type CircuitBreakerState = 'closed' | 'open' | 'half-open';\n\nexport interface RetryStrategy {\n maxAttempts: number;\n baseDelay: number;\n maxDelay: number;\n factor: number;\n jitter: boolean;\n}\n\n// ============================================================================\n// OFFLINE QUEUE\n// ============================================================================\n\nexport interface OfflineQueueEntry {\n id: string;\n events: BeaconEvent[];\n timestamp: number;\n expiresAt: number;\n retryCount: number;\n size: number;\n}\n\n// ============================================================================\n// BEACON BATCH\n// ============================================================================\n\n/** The minimal EC-P256 public JWK shape the beacon can construct without\n * a JOSE library dependency (see P37's findings on bundle-size discipline).\n * Structurally compatible with `jose`'s wider `JWK` type on the server side. */\nexport interface EcPublicJwk {\n kty: 'EC';\n crv: 'P-256';\n x: string;\n y: string;\n}\n\n/** What `BeaconConfig.onReceipt` receives for each 202 ingest response. */\nexport interface BeaconReceipt {\n /**\n * The server's session id for this visit, the key\n * `GET /api/v1/projects/{id}/sessions/{sessionId}` reads. On a receipt from\n * the queue-only edge it is present once the origin has answered for the\n * session, and absent before (`postureStatus: 'pending'`).\n */\n sessionId?: string;\n /**\n * The beacon's own session id the batch was sent under: what a posture\n * token is bound to, and what `BeaconConfig.browserSessionId` resumes.\n */\n browserSessionId: string;\n /** The signed posture token, when ingest issued one. `expiresAt` is Unix seconds. */\n posture?: { token: string; expiresAt: number };\n /** Why `posture` is absent: `'pending'` while a queued batch awaits replay, otherwise the withheld reason. */\n postureStatus?: string;\n}\n\nexport interface BeaconBatch {\n projectId: string;\n events: BeaconEvent[];\n sessionId: string;\n handoffToken?: string;\n deviceId?: string;\n batchId: string;\n timestamp: number;\n /** Build item 6: mirrors `BeaconConfig.anonymizeIp` (default `false`) — see the beacon route's own doc comment. */\n anonymizeIp?: boolean;\n /** Nonce-bound ingest (build item 5): the value from the prior 202 response's `nonce`. */\n nonce?: string;\n /** Nonce-bound ingest (build item 5): declares this client echoes nonces — see checkpoint-beacon's `BeaconBatch`. */\n nonceEcho?: boolean;\n /** Holder-of-key posture binding (P37): the beacon's own DPoP public key,\n * sent once per browser session (first batch only) so the issuer can bind\n * every subsequent posture mint to it via `cnf.jkt`. */\n publicJwk?: EcPublicJwk;\n}\n\nexport interface BeaconCollectorData {\n // Browser collector data\n userAgent?: string;\n language?: string;\n platform?: string;\n screenResolution?: string;\n viewport?: string;\n cookiesEnabled?: boolean;\n doNotTrack?: boolean;\n timezone?: string;\n referrer?: string;\n url?: string;\n title?: string;\n vendor?: string;\n\n // Performance collector data\n pageLoadTime?: number;\n domContentLoadedTime?: number;\n firstPaintTime?: number;\n firstContentfulPaintTime?: number;\n connectionType?: string;\n\n // Session data\n sessionId?: string;\n timestamp?: number;\n\n // Allow additional properties\n [key: string]: unknown;\n}\n\nexport type BeaconEventType =\n | 'pageview'\n | 'pageunload'\n | 'heartbeat'\n | 'evidence'\n | 'custom'\n | 'error'\n | 'performance';\n\n// ============================================================================\n// PARSER FUNCTIONS\n// ============================================================================\n\nexport function parseRetryStrategy(input: unknown): RetryStrategy {\n const strategy = toRecord(input);\n return {\n maxAttempts: numberOr(strategy.maxAttempts, 3),\n baseDelay: numberOr(strategy.baseDelay, 1000),\n maxDelay: numberOr(strategy.maxDelay, 30000),\n factor: numberOr(strategy.factor, 2),\n jitter: strategy.jitter !== false,\n };\n}\n\nexport function parseCircuitBreakerConfig(input: unknown): CircuitBreakerConfig {\n const config = toRecord(input);\n return {\n threshold: numberOr(config.threshold, 5),\n timeout: numberOr(config.timeout, 60000),\n resetTimeout: numberOr(config.resetTimeout, 30000),\n };\n}\n\nexport function parseOfflineQueueEntry(input: unknown): OfflineQueueEntry {\n if (!isRecord(input)) {\n throw new Error('Invalid offline queue entry');\n }\n\n const entry = input;\n return {\n id: stringOr(\n entry.id,\n `${Date.now()}_${Array.from(crypto.getRandomValues(new Uint8Array(6)), (byte) => byte.toString(16).padStart(2, '0')).join('')}`\n )!,\n events: Array.isArray(entry.events) ? (entry.events as BeaconEvent[]) : [],\n timestamp: numberOr(entry.timestamp, Date.now()),\n expiresAt: numberOr(entry.expiresAt, Date.now() + 86400000), // 24 hours\n retryCount: numberOr(entry.retryCount, 0),\n size: numberOr(entry.size, 0),\n };\n}\n\nfunction randomId(): string {\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nexport function parseBeaconWorkerMessage(input: unknown): BeaconWorkerMessage {\n if (!isRecord(input)) {\n throw new Error('Invalid beacon worker message');\n }\n\n const msg = input;\n const messageId = stringOr(msg.messageId) ?? stringOr(msg.id) ?? randomId();\n return {\n type: isBeaconWorkerMessageType(msg.type) ? msg.type : 'init',\n data: msg.data,\n payload: msg.payload,\n messageId,\n timestamp: numberOr(msg.timestamp, Date.now()),\n id: stringOr(msg.id, messageId)!,\n };\n}\n\nfunction isMessagePriority(value: unknown): value is MessagePriority {\n return value === 'low' || value === 'normal' || value === 'high' || value === 'critical';\n}\n\nfunction isWorkerMessageType(value: unknown): value is WorkerMessageType {\n return (\n value === 'request' ||\n value === 'response' ||\n value === 'error' ||\n value === 'heartbeat' ||\n value === 'status'\n );\n}\n\nfunction isWorkerErrorType(value: unknown): value is WorkerErrorType {\n return (\n value === 'initialization' ||\n value === 'runtime' ||\n value === 'communication' ||\n value === 'timeout' ||\n value === 'memory' ||\n value === 'network' ||\n value === 'permission' ||\n value === 'validation' ||\n value === 'processing' ||\n value === 'unknown'\n );\n}\n\nexport function parseWorkerMessage(input: unknown): WorkerMessage {\n const msg = (input && typeof input === 'object' ? input : null) as Partial<WorkerMessage> | null;\n if (!msg) {\n throw new Error('Invalid worker message');\n }\n\n return {\n id: msg.id || randomId(),\n type: isWorkerMessageType(msg.type) ? msg.type : 'request',\n action: msg.action,\n payload: msg.payload,\n timestamp: msg.timestamp || Date.now(),\n compressed: msg.compressed,\n priority: isMessagePriority(msg.priority) ? msg.priority : 'normal',\n correlationId: msg.correlationId,\n };\n}\n\nexport function parseWorkerError(input: unknown): WorkerError {\n const error = (input && typeof input === 'object' ? input : {}) as Partial<WorkerError>;\n return {\n type: isWorkerErrorType(error.type) ? error.type : 'unknown',\n code: typeof error.code === 'string' ? error.code : undefined,\n message: typeof error.message === 'string' ? error.message : 'Worker error',\n stack: typeof error.stack === 'string' ? error.stack : undefined,\n timestamp: typeof error.timestamp === 'number' ? error.timestamp : Date.now(),\n recoverable: error.recoverable !== false,\n retryAfter: typeof error.retryAfter === 'number' ? error.retryAfter : undefined,\n context: error.context,\n };\n}\n\nexport function parseWorkerPoolConfig(input: unknown): WorkerPoolConfig {\n const config = (input && typeof input === 'object' ? input : {}) as Partial<WorkerPoolConfig>;\n return {\n maxWorkers: config.maxWorkers ?? 4,\n minWorkers: config.minWorkers ?? 1,\n workerIdleTimeout: config.workerIdleTimeout ?? 30000,\n taskQueueSize: config.taskQueueSize ?? 100,\n resourceLimits: config.resourceLimits ?? {},\n autoScale: config.autoScale ?? true,\n scaleUpThreshold: config.scaleUpThreshold ?? 75,\n scaleDownThreshold: config.scaleDownThreshold ?? 25,\n };\n}\n\nexport function parseResourceUsage(input: unknown): ResourceUsage {\n const usage = (input && typeof input === 'object' ? input : {}) as Partial<ResourceUsage>;\n return {\n memory: usage.memory ?? { used: 0, limit: 0, percentage: 0 },\n cpu: usage.cpu ?? { usage: 0, limit: 100 },\n tasks: usage.tasks ?? { pending: 0, active: 0, completed: 0, failed: 0 },\n activeWorkers: usage.activeWorkers ?? 0,\n };\n}\n\nexport const ResourceUsageSchema = {\n parse: parseResourceUsage,\n};\n\nexport const WorkerPoolConfigSchema = {\n parse: parseWorkerPoolConfig,\n};\n\nexport function parseWorkerCapabilities(input: unknown): WorkerCapabilities {\n const cap = toRecord(input);\n const csp = toRecord(cap.csp);\n const performance = toRecord(cap.performance);\n\n return {\n workerAPI: cap.workerAPI !== false,\n sharedArrayBuffer: cap.sharedArrayBuffer === true,\n transferableObjects: cap.transferableObjects === true,\n offscreenCanvas: cap.offscreenCanvas === true,\n webAssembly: cap.webAssembly === true,\n atomics: cap.atomics === true,\n bigInt: cap.bigInt === true,\n csp: {\n workerSrc: csp.workerSrc === true,\n scriptSrc: csp.scriptSrc === true,\n blobUrls: csp.blobUrls === true,\n inlineWorkers: csp.inlineWorkers === true,\n },\n performance: {\n memory: performance.memory === true,\n measureUserAgentSpecificMemory: performance.measureUserAgentSpecificMemory === true,\n },\n };\n}\n\n/**\n * @param onWarn Called once per rejected config value (a supplied value that\n * failed validation and fell back to its default), for a caller that wants\n * to surface it — `BeaconConfigManager.validateAndMergeConfig` wires this to\n * `log('warn', ...)`. Never called for an omitted field; only for one the\n * caller actually set to something invalid.\n */\nexport function parseBeaconConfig(\n input: unknown,\n onWarn?: (message: string) => void\n): BeaconConfig {\n const config = toRecord(input);\n\n if (typeof config.projectId !== 'string' || config.projectId.length === 0) {\n throw new Error('Project ID is required');\n }\n\n return {\n projectId: config.projectId,\n environment: stringOr(config.environment),\n tags: isBeaconTags(config.tags) ? config.tags : undefined,\n identity: isBeaconIdentity(config.identity) ? config.identity : undefined,\n // `parseBeaconConfig` is an allowlist: a key it does not name is dropped\n // silently, which is how `identity` first shipped inert.\n endpoint: stringOr(config.endpoint),\n enabled: config.enabled !== false,\n debug: config.debug === true,\n logLevel: isLogLevel(config.logLevel) ? config.logLevel : 'error',\n respectDoNotTrack: config.respectDoNotTrack !== false,\n requireConsent: config.requireConsent === true,\n anonymizeIp: config.anonymizeIp === true,\n stripUrlFragment: config.stripUrlFragment !== false,\n scrubQueryParams: isStringArray(config.scrubQueryParams) ? config.scrubQueryParams : undefined,\n dropQueryParams: config.dropQueryParams === true,\n sessionTimeout: numberOr(config.sessionTimeout, undefined),\n sessionCookieName: stringOr(config.sessionCookieName, '_as_beacon_session'),\n browserSessionId: resumableSessionId(config.browserSessionId, (received) =>\n onWarn?.(\n `browserSessionId must match ${RESUMABLE_SESSION_ID} (received ${JSON.stringify(received)}); ignoring it`\n )\n ),\n onReceipt: receiptCallback(config.onReceipt, (received) =>\n onWarn?.(`onReceipt must be a function (received ${typeof received}); ignoring it`)\n ),\n // Deprecated no-ops (see BeaconConfig.batchSize/flushInterval): passed\n // through when a caller sets them so a stale value round-trips through\n // `get()`, never defaulted, since nothing reads them anymore.\n batchSize: typeof config.batchSize === 'number' ? config.batchSize : undefined,\n flushInterval: typeof config.flushInterval === 'number' ? config.flushInterval : undefined,\n collectorDeadlineMs: numberOr(config.collectorDeadlineMs, 1600),\n evidenceGrowthFactor: boundedNumberOr(\n config.evidenceGrowthFactor,\n 2,\n (n) => n > 1,\n (received) =>\n onWarn?.(\n `evidenceGrowthFactor must be a number greater than 1 (received ${JSON.stringify(received)}); using default 2`\n )\n ),\n postureRefreshFraction: boundedNumberOr(\n config.postureRefreshFraction,\n 0.5,\n (n) => n > 0 && n <= 1,\n (received) =>\n onWarn?.(\n `postureRefreshFraction must be a number in (0, 1] (received ${JSON.stringify(received)}); using default 0.5`\n )\n ),\n triggers: pickTriggers(config.triggers, (name, received) =>\n onWarn?.(\n `triggers.${name} must be a boolean (received ${JSON.stringify(received)}); ignoring it and keeping its default`\n )\n ),\n maxQueueSize: numberOr(config.maxQueueSize, 100),\n retryAttempts: numberOr(config.retryAttempts, 3),\n retryDelay: numberOr(config.retryDelay, 2000),\n postureRetryScheduleMs: isPositiveNumberArray(config.postureRetryScheduleMs)\n ? config.postureRetryScheduleMs\n : undefined,\n useWorker: resolveUseWorker(config),\n workerUrl: stringOr(config.workerUrl),\n workerConfig: isRecord(config.workerConfig) ? (config.workerConfig as WorkerConfig) : undefined,\n lazySignalsUrl: stringOr(config.lazySignalsUrl),\n proactiveRefreshMinIntervalMs: boundedNumberOr(\n config.proactiveRefreshMinIntervalMs,\n 30_000,\n (n) => n > 0,\n (received) =>\n onWarn?.(\n `proactiveRefreshMinIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 30000`\n )\n ),\n proactiveRefreshMaxIntervalMs: boundedNumberOr(\n config.proactiveRefreshMaxIntervalMs,\n 60_000,\n (n) => n > 0,\n (received) =>\n onWarn?.(\n `proactiveRefreshMaxIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 60000`\n )\n ),\n proactiveRefreshFreshnessMs: optionalPositiveNumber(\n config.proactiveRefreshFreshnessMs,\n (received) =>\n onWarn?.(\n `proactiveRefreshFreshnessMs must be a positive number (received ${JSON.stringify(received)}); ignoring it and inheriting postureRefreshFraction's threshold`\n )\n ),\n proactiveRefreshOnVisibilityResume: booleanOr(\n config.proactiveRefreshOnVisibilityResume,\n true,\n (received) =>\n onWarn?.(\n `proactiveRefreshOnVisibilityResume must be a boolean (received ${JSON.stringify(received)}); using default true`\n )\n ),\n proactiveRefreshOnOnline: booleanOr(config.proactiveRefreshOnOnline, true, (received) =>\n onWarn?.(\n `proactiveRefreshOnOnline must be a boolean (received ${JSON.stringify(received)}); using default true`\n )\n ),\n proactiveRefreshJitterSeed: optionalFiniteNumber(\n config.proactiveRefreshJitterSeed,\n (received) =>\n onWarn?.(\n `proactiveRefreshJitterSeed must be a finite number (received ${JSON.stringify(received)}); ignoring it, jitter will use Math.random()`\n )\n ),\n };\n}\n\n// ============================================================================\n// EXPORT MAIN CLASS TYPE\n// ============================================================================\n\nexport declare class AgentShieldBeacon implements IAgentShieldBeacon {\n constructor(config: BeaconConfig);\n collect(eventType: string, data?: BeaconPayload): Promise<void>;\n trackEvent(eventName: string, eventData?: BeaconPayload): Promise<void>;\n trackPageview(pageData?: BeaconPayload): Promise<void>;\n trackPageUnload(): Promise<void>;\n updateConfig(updates: Partial<BeaconConfig>): void;\n destroy(): Promise<void>;\n}\n\n/**\n * The most events one beacon POST may carry. The ingest route's\n * `BeaconBatchSchema` refuses a larger batch whole (a 400, not a retry), so\n * the SDK's offline drain never dequeues more than this per request.\n */\nexport const BEACON_MAX_EVENTS_PER_BATCH = 100;\n\nexport const SESSION_IDLE_GAP_MAX_MS = 21_600_000;\nexport const BEACON_MAX_BATCH_ID_LENGTH = 255;\n\nexport const BEACON_ORIGIN_CONTRACT_VERSION = 1;\n\nexport const BEACON_ORIGIN_CAPABILITIES = ['batch-replay-v1', 'receipt-status-v1'] as const;\n\n/**\n * Lifetime of the signed browser posture token, in seconds. Defined here and\n * re-exported by `browser-posture.ts` (which imports `jose`) so the\n * size-budgeted beacon bundle can read it without pulling in a JWT library.\n */\nexport const POSTURE_TTL_SECONDS = 120;\n"],"mappings":";AAgBA,SAAS,SAAS,OAAwC;CACxD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,SAAS,OAA+B;CAC/C,OAAO,SAAS,KAAK,IAAI,QAAQ,CAAC;AACpC;AAEA,SAAS,SACP,OACA,UACmB;CACnB,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,UAAU,IAAI,QAAQ;AACtF;;;;;;;;;AAUA,SAAS,gBACP,OACA,UACA,IACA,UACQ;CACR,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,GAAG,KAAK,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A0B,OAAO,aAC1E,SACE,wDAAwD,KAAK,UAAU,QAAQ,EAAE,sBACnF,CACF;EACA,4BAA4B,qBAC1B,OAAO,6BACN,aACC,SACE,gEAAgE,KAAK,UAAU,QAAQ,EAAE,8CAC3F,CACJ;CACF;AACF;;;;;;AAqBA,MAAa,8BAA8B;AAE3C,MAAa,0BAA0B;AACvC,MAAa,6BAA6B;AAE1C,MAAa,iCAAiC;AAE9C,MAAa,6BAA6B,CAAC,mBAAmB,mBAAmB;;;;;;AAOjF,MAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/beacon-types/index.ts"],"sourcesContent":["/**\n * Public TypeScript types for Checkpoint Beacon\n *\n * This package contains only the public API types needed by beacon consumers.\n * No implementation details or detection rules are included.\n */\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue | undefined };\nexport type BeaconPrimitive = JsonPrimitive;\nexport type BeaconJsonValue = JsonValue;\nexport type BeaconCustomData = Record<string, JsonValue | undefined>;\nexport type BeaconPayload = BeaconCollectorData | BeaconCustomData | null;\nexport type WorkerPayload = unknown;\ntype UnknownRecord = Record<string, unknown>;\n\nfunction isRecord(input: unknown): input is UnknownRecord {\n return typeof input === 'object' && input !== null && !Array.isArray(input);\n}\n\nfunction toRecord(input: unknown): UnknownRecord {\n return isRecord(input) ? input : {};\n}\n\nfunction numberOr<Fallback extends number | undefined>(\n value: unknown,\n fallback: Fallback\n): number | Fallback {\n return typeof value === 'number' && Number.isFinite(value) && value !== 0 ? value : fallback;\n}\n\n/**\n * Validates a numeric config value against `ok`, falling back to `fallback`\n * when it fails. Only calls `onReject` when the caller actually supplied a\n * value (an `undefined` field, the common case, is not a rejection, it just\n * never overrode the default): H0BB5 (PR #5095 review, item 4) — a rejected\n * value used to fall back silently, with no way for a host to discover a\n * config typo.\n */\nfunction boundedNumberOr(\n value: unknown,\n fallback: number,\n ok: (n: number) => boolean,\n onReject?: (received: unknown) => void\n): number {\n if (typeof value === 'number' && Number.isFinite(value) && ok(value)) return value;\n if (value !== undefined) onReject?.(value);\n return fallback;\n}\n\n/** Same as `boundedNumberOr`, but an absent/rejected value stays `undefined` rather than defaulting. */\nfunction optionalPositiveNumber(\n value: unknown,\n onReject?: (received: unknown) => void\n): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'number' && Number.isFinite(value) && value > 0) return value;\n onReject?.(value);\n return undefined;\n}\n\n/** Same as `optionalPositiveNumber`, without the positivity requirement (a jitter seed may be any finite number). */\nfunction optionalFiniteNumber(\n value: unknown,\n onReject?: (received: unknown) => void\n): number | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n onReject?.(value);\n return undefined;\n}\n\n/** Same shape as `boundedNumberOr`/`optionalPositiveNumber`, for a boolean config flag. */\nfunction booleanOr(\n value: unknown,\n fallback: boolean,\n onReject?: (received: unknown) => void\n): boolean {\n if (value === undefined) return fallback;\n if (typeof value === 'boolean') return value;\n onReject?.(value);\n return fallback;\n}\n\n/** Ingest's own `sessionId` bound (1-255), limited to characters a cookie value carries unescaped. */\nconst RESUMABLE_SESSION_ID = /^[A-Za-z0-9._~-]{1,255}$/;\n\nfunction resumableSessionId(\n value: unknown,\n onReject?: (received: unknown) => void\n): string | undefined {\n if (value === undefined) return undefined;\n if (typeof value === 'string' && RESUMABLE_SESSION_ID.test(value)) return value;\n onReject?.(value);\n return undefined;\n}\n\nfunction receiptCallback(\n value: unknown,\n onReject?: (received: unknown) => void\n): BeaconConfig['onReceipt'] {\n if (value === undefined) return undefined;\n if (typeof value === 'function') return value as BeaconConfig['onReceipt'];\n onReject?.(value);\n return undefined;\n}\n\nconst DISPATCH_TRIGGER_NAMES = [\n 'arrival',\n 'signals',\n 'interaction',\n 'untrusted',\n 'posture',\n 'unload',\n 'navigation',\n] as const satisfies readonly (keyof BeaconDispatchTriggers)[];\n\n/**\n * Keeps only the known trigger names with a real boolean; anything else is\n * dropped and, when the caller actually named a known trigger with a\n * non-boolean value (`triggers: { posture: 0 }`, say), reported through\n * `onReject` — H0BB5 (PR #5095 review, item 4): a numeric `0` used to be\n * dropped silently and that trigger stayed at its default-enabled state,\n * the opposite of what the \"0 is falsy\" convention suggests.\n */\nfunction pickTriggers(\n value: unknown,\n onReject?: (name: string, received: unknown) => void\n): BeaconDispatchTriggers | undefined {\n if (!isRecord(value)) return undefined;\n const picked: BeaconDispatchTriggers = {};\n for (const name of DISPATCH_TRIGGER_NAMES) {\n const raw = value[name];\n if (typeof raw === 'boolean') {\n picked[name] = raw;\n } else if (raw !== undefined) {\n onReject?.(name, raw);\n }\n }\n return picked;\n}\n\nfunction stringOr(value: unknown, fallback?: string): string | undefined {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every((entry) => typeof entry === 'string');\n}\n\n/**\n * Non-empty on purpose: an empty schedule would mean \"zero posture-recovery\n * attempts\", silently disabling recovery rather than configuring it. A\n * deployment that actually wants no retries sets `flushInterval` instead.\n */\nfunction isPositiveNumberArray(value: unknown): value is number[] {\n return (\n Array.isArray(value) &&\n value.length > 0 &&\n value.every((entry) => typeof entry === 'number' && Number.isFinite(entry) && entry > 0)\n );\n}\n\nfunction isBeaconTags(value: unknown): value is Record<string, string | number | boolean> {\n return (\n isRecord(value) &&\n Object.values(value).every(\n (entry) =>\n typeof entry === 'string' || typeof entry === 'number' || typeof entry === 'boolean'\n )\n );\n}\n\n/**\n * Exported because `parseBeaconConfig` is an allowlist: a key it does not\n * name is dropped, silently. The beacon's other public entry point\n * (`checkpoint-shared/browser`) carries its own copy of that allowlist, so\n * the CHECK at least lives in one place even while the two parsers do not —\n * see the note on `BeaconConfig.identity`.\n *\n * Rejects an identity with no usable `userId` rather than passing through a\n * half-formed object: downstream this becomes `detections.user_id`, and an\n * empty string there is worse than an absent one — it reads as \"identified\"\n * while naming nobody.\n */\nexport function isBeaconIdentity(value: unknown): value is BeaconIdentity {\n return isRecord(value) && typeof value.userId === 'string' && value.userId.length > 0;\n}\n\nfunction isLogLevel(value: unknown): value is BeaconConfig['logLevel'] {\n return value === 'error' || value === 'warn' || value === 'info' || value === 'debug';\n}\n\nfunction isBeaconWorkerMessageType(value: unknown): value is BeaconWorkerMessageType {\n return (\n value === 'init' ||\n value === 'collect' ||\n value === 'flush' ||\n value === 'config' ||\n value === 'status' ||\n value === 'error' ||\n // `beacon.worker.ts`'s `respond()` has always sent this on every\n // successful request (init/collect/flush/config/status) — the allowlist\n // just never named it, so `parseBeaconWorkerMessage` silently coerced\n // every success response to `'init'` (see that function's fallback).\n value === 'response' ||\n value === 'posture'\n );\n}\n\n/**\n * Resolves whether a beacon should use its Web Worker transport.\n *\n * `enableWebWorker` is accepted as an alias for `useWorker`: the package's\n * own test suite (`checkpoint-beacon/src/index.test.ts`) has always\n * constructed with `enableWebWorker: false`, but `parseBeaconConfig`'s\n * allowlist only ever named `useWorker`, so that key was silently dropped —\n * the beacon kept auto-detecting worker support regardless of what the\n * caller passed. `useWorker` wins when both are set, since it's the\n * canonical name every other config field (`workerUrl`, `workerConfig`)\n * pairs with.\n */\nfunction resolveUseWorker(config: UnknownRecord): boolean {\n if (typeof config.useWorker === 'boolean') {\n return config.useWorker;\n }\n if (typeof config.enableWebWorker === 'boolean') {\n return config.enableWebWorker;\n }\n return true;\n}\n\nexport interface NetworkInformationLike extends EventTarget {\n type?: string;\n effectiveType?: string;\n downlink?: number;\n rtt?: number;\n saveData?: boolean;\n}\n\nexport interface NavigatorWithNetworkInformation extends Navigator {\n connection?: NetworkInformationLike;\n mozConnection?: NetworkInformationLike;\n webkitConnection?: NetworkInformationLike;\n deviceMemory?: number;\n vendorSub: string;\n doNotTrack: string | null;\n msDoNotTrack?: string | null;\n}\n\nexport interface WindowWithBeaconMetadata extends Window {\n doNotTrack?: string | null;\n __NEXT_DATA__?: {\n buildId?: string;\n };\n}\n\nexport interface TrustedTypePolicyLike {\n createScriptURL(url: string): string;\n createScript(script: string): string;\n}\n\nexport interface WindowWithTrustedTypes extends Window {\n trustedTypes?: {\n createPolicy(\n name: string,\n rules: {\n createScriptURL?: (url: string) => string;\n createScript?: (script: string) => string;\n }\n ): TrustedTypePolicyLike;\n };\n}\n\nexport interface PerformanceMemoryInfo {\n usedJSHeapSize: number;\n totalJSHeapSize: number;\n jsHeapSizeLimit: number;\n}\n\nexport interface PerformanceWithMemory extends Performance {\n memory?: PerformanceMemoryInfo;\n measureUserAgentSpecificMemory?: () => Promise<unknown>;\n}\n\nexport interface LargestContentfulPaintEntry extends PerformanceEntry {\n renderTime?: number;\n loadTime?: number;\n}\n\n// ============================================================================\n// BEACON CONFIGURATION\n// ============================================================================\n\n/**\n * Who the current visitor is, when the host site knows.\n *\n * Deliberately just the id. The pixel's `identify` call also carries\n * `previousId` and `userTraits`, but those drive the server's profile and\n * alias-graph pipeline (tenant salt, profile-copy, write advisory locks),\n * which the beacon ingest route does not run — accepting them here would mean\n * collecting personal data the beacon path then silently discards. Both are\n * additive later: this is an optional field on an optional object.\n */\nexport interface BeaconIdentity {\n /**\n * The host site's own id for the signed-in user. Capped at 255 characters\n * to match `detections.user_id`; a longer value is rejected at ingest.\n */\n userId: string;\n}\n\n/** The beacon's automatic sends, each switchable off. See `BeaconConfig.triggers`. */\nexport interface BeaconDispatchTriggers {\n /** The `pageview` at construction and on consent restore. */\n arrival?: boolean;\n /** The follow-up send when the lazy signals chunk resolves after arrival missed it. */\n signals?: boolean;\n /** First interaction, first timing sample, and evidence growth. */\n interaction?: boolean;\n /** The first script-dispatched (untrusted) input. */\n untrusted?: boolean;\n /** An interaction after the posture token has gone stale. */\n posture?: boolean;\n /** The SDK-wired `visibilitychange` and `pagehide` critical send. */\n unload?: boolean;\n /**\n * The `pageview` for a page the visitor arrives at without a full load: a\n * back/forward-cache restore (`pageshow` with `persisted`, trigger\n * `bfcache_restore`) and a soft navigation that changes the path\n * (History API or Navigation API, trigger `soft_navigation`). Turn it off\n * when the host already calls `collect('pageview')` on its own route\n * changes, or each one sends twice.\n */\n navigation?: boolean;\n}\n\nexport interface BeaconConfig {\n /** Project ID for tracking (same as pixel data-project-id) */\n projectId: string;\n\n /**\n * Who the visitor is, when the page already knows at construction time.\n * When identity only becomes known later (a login part-way through the\n * session), call `identify()` instead.\n */\n identity?: BeaconIdentity;\n\n /**\n * Where batches are POSTed. Defaults to the hosted ingest endpoint declared\n * in `NETWORK_CONTRACT.md`.\n *\n * Set it to send somewhere else — a self-hosted deployment, a regional\n * install, or a test origin. An override means the destination is the\n * integrator's, not ours, so `NETWORK_CONTRACT.md` describes the DEFAULT and\n * says so explicitly.\n *\n * @default 'https://kya.vouched.id/api/v1/beacon'\n */\n endpoint?: string;\n\n /** Optional environment tag for data segmentation */\n environment?: 'development' | 'staging' | 'production' | string;\n\n /** Optional tags for custom data segmentation */\n tags?: Record<string, string | number | boolean>;\n\n /**\n * Not read by the SDK. Construct the beacon only when it should run, and\n * call `destroy()` to stop it.\n *\n * @deprecated\n */\n enabled?: boolean;\n\n /**\n * Verbose console logging.\n *\n * @default false\n */\n debug?: boolean;\n\n /**\n * Log verbosity.\n *\n * @default 'error'\n */\n logLevel?: 'error' | 'warn' | 'info' | 'debug';\n\n /**\n * When the browser sends Do Not Track, the beacon collects and sends nothing.\n *\n * @default true\n */\n respectDoNotTrack?: boolean;\n\n /**\n * Accepted and ignored. The beacon no longer withholds anything on\n * consent; only Do Not Track stops collection.\n *\n * @deprecated has no effect\n * @default false\n */\n requireConsent?: boolean;\n\n /**\n * Truncate the stored IP to /24 (IPv4) or /48 (IPv6) before persistence.\n *\n * @default false\n */\n anonymizeIp?: boolean;\n\n /**\n * Strip the `#fragment` from the `url`/`referrer` collector fields before\n * they leave the page. Defaults to `true`: a fragment is never sent to\n * the server by the browser in the first place for any OTHER surface\n * (it is script-visible only), so a beacon that forwards it is the one\n * place it can leak — and it is also the highest-risk part of the URL,\n * since SPA routers, magic-link auth, and OAuth implicit-flow responses\n * all put tokens there. Set to `false` only if a project genuinely\n * consumes `url`'s fragment server-side.\n *\n * @default true\n */\n stripUrlFragment?: boolean;\n\n /**\n * Query parameter names (matched case-insensitively) to redact from the\n * `url`/`referrer` collector fields before they leave the page. Each\n * matching value is replaced with the literal string `\"[redacted]\"`; the\n * parameter itself stays present so the URL's shape is unchanged. Empty\n * by default — nothing is scrubbed unless a project opts in with the\n * param names it puts tokens/PII behind (e.g. `[\"token\", \"email\"]`).\n * Ignored for a parameter when `dropQueryParams` is also `true`, since\n * there is no query string left to scrub.\n *\n * @default []\n */\n scrubQueryParams?: string[];\n\n /**\n * Drop the entire query string from the `url`/`referrer` collector\n * fields before they leave the page. Off by default. Takes priority over\n * `scrubQueryParams` when both are set — there is nothing left to scrub\n * once the whole query string is gone.\n *\n * @default false\n */\n dropQueryParams?: boolean;\n\n /**\n * Idle-gap override in milliseconds, at most six hours. Unset: one hour on\n * phones, six hours elsewhere. Every send extends it.\n */\n sessionTimeout?: number;\n\n /**\n * Name of the visitor session cookie shared by pixel, beacon, gateway, and\n * SDK rows. Query it with `?sessionId=` on the\n * [detections endpoint](/docs/api-reference#get-project-detections).\n *\n * @default '_as_beacon_session'\n */\n sessionCookieName?: string;\n\n /**\n * Resume a browser session id the page stored earlier (a receipt's\n * `browserSessionId`, see `onReceipt`) instead of reading the session\n * cookie or minting a new id. With cookies off this is the only way two\n * page loads stay one session, and a posture token verifies only against\n * the session id it was issued to. 1 to 255 characters of\n * `A-Z a-z 0-9 . _ ~ -`; anything else is ignored with a warning.\n * `updateConfig({ browserSessionId })` switches a running beacon to it.\n */\n browserSessionId?: string;\n\n /**\n * Called with every ingest receipt: the server's session id, the browser\n * session id the batch was sent under, and the posture token or the reason\n * there is none. Runs on the main thread in worker mode too, after the\n * posture cookie write. An error it throws is logged at `warn` and never\n * affects delivery.\n */\n onReceipt?: (receipt: BeaconReceipt) => void;\n\n /**\n * @deprecated The beacon no longer batches; every dispatch sends\n * immediately. Accepted and ignored so a caller upgrading from an older\n * SDK version keeps compiling and does not need to touch its config.\n */\n batchSize?: number;\n\n /**\n * @deprecated The beacon no longer polls on an interval; it dispatches on\n * evidence transitions instead (arrival, first interaction, evidence\n * doubling, untrusted input, posture staleness, hidden/pagehide). Accepted\n * and ignored so a caller upgrading from an older SDK version keeps\n * compiling and does not need to touch its config.\n */\n flushInterval?: number;\n\n /**\n * How much `keyDwellCount + pressCount + untrustedEvents` has to grow, as a\n * multiple of its value at the last send, before an interaction sends\n * again. 2 sends at 1, 2, 4, 8, 16 samples; 1.5 sends more often, 3 less.\n * A value at or below 1 falls back to the default.\n *\n * @default 2\n */\n evidenceGrowthFactor?: number;\n\n /**\n * Fraction of the posture token's lifetime after which a counted\n * interaction sends again, so the token stays fresh under a live hand.\n * 0.5 refreshes the 120 s token once an interaction lands more than 60 s\n * after the last send. A value outside (0, 1] falls back to the default.\n *\n * @default 0.5\n */\n postureRefreshFraction?: number;\n\n /**\n * Which automatic sends fire. Every trigger is on unless set to `false`.\n * Turning `unload` off leaves `trackPageUnload()` available for a host\n * that wires its own listener; turning `arrival` off leaves `collect()`.\n */\n triggers?: BeaconDispatchTriggers;\n\n /**\n * Low-frequency backstop that refreshes posture on a jittered timer,\n * independent of interaction, so a visitor who goes idle past the posture\n * TTL with no counted interaction is not one stale click on a critical\n * action away from an expired token (H0BB5, PR #5095 review). The actual\n * interval on each tick is `proactiveRefreshMinIntervalMs` plus a random\n * `[0, max - min)` jitter, so a fleet of clients loaded at the same moment\n * does not all refresh on the same wall-clock boundary. Paused while the\n * page is hidden, resumed on `visibilitychange`. Gated by\n * `triggers.posture`, the same switch that already turns off the\n * interaction-triggered staleness check — this timer is that same\n * `'posture'` trigger firing proactively, not a second mechanism. A\n * non-positive value falls back to the default.\n *\n * @default 30000\n */\n proactiveRefreshMinIntervalMs?: number;\n\n /**\n * The upper bound of the proactive-refresh jitter window; see\n * `proactiveRefreshMinIntervalMs`. A non-positive value falls back to the\n * default; a value below `proactiveRefreshMinIntervalMs` degrades to the\n * minimum on every tick rather than throwing.\n *\n * @default 60000\n */\n proactiveRefreshMaxIntervalMs?: number;\n\n /**\n * How old the last send must be, in milliseconds, before a visibility\n * resume forces an immediate posture refresh. Defaults to the same\n * threshold the interaction-triggered check already uses\n * (`postureRefreshFraction` of the posture token's lifetime), so the two\n * stay in lockstep unless a host deliberately wants the visibility check\n * to be stricter or looser. A non-positive value falls back to that\n * default.\n */\n proactiveRefreshFreshnessMs?: number;\n\n /**\n * On `visibilitychange` back to visible, force an immediate posture\n * refresh when it is stale (see `proactiveRefreshFreshnessMs`); a fresh\n * tab regaining focus does not get an unnecessary send either way. Set to\n * `false` to leave visibility resume to the plain interval alone.\n *\n * @default true\n */\n proactiveRefreshOnVisibilityResume?: boolean;\n\n /**\n * Refresh posture (and drain anything the offline queue is still holding)\n * when the browser fires `online`. Set to `false` to leave reconnection\n * recovery to the offline queue's own `online` listener alone.\n *\n * @default true\n */\n proactiveRefreshOnOnline?: boolean;\n\n /**\n * A fixed seed for the proactive-refresh jitter roll, for deterministic\n * tests. Omit in production for real `Math.random()` jitter.\n */\n proactiveRefreshJitterSeed?: number;\n\n /**\n * Per-collector deadline in milliseconds. A collector still running past\n * this deadline is dropped from the current collection round rather than\n * awaited further — see `collectWithDeadline` in checkpoint-beacon.\n * Default and rationale documented in checkpoint-beacon's\n * `src/budget/thresholds.ts`.\n *\n * @default 1600\n */\n collectorDeadlineMs?: number;\n\n /**\n * Maximum number of queued events.\n *\n * @default 100\n */\n maxQueueSize?: number;\n\n /**\n * Retry count for failed sends.\n *\n * @default 3\n */\n retryAttempts?: number;\n\n /**\n * Base retry delay in milliseconds.\n *\n * @default 2000\n */\n retryDelay?: number;\n\n /**\n * Delays in milliseconds between posture-recovery attempts after a\n * durably-queued ingest response that carried no posture verdict. The\n * array's length is the attempt ceiling. Defaults to the shipped ladder;\n * override only in tests and in a self-hosted deployment with a\n * different outage profile.\n */\n postureRetryScheduleMs?: number[];\n\n /**\n * Prefer a Web Worker for event processing, batching, and transport.\n * Page-dependent collection remains on the main thread. Unsupported\n * browsers fall back to the main thread; SSR never starts a worker.\n * Set false to disable the processing worker.\n *\n * @default true\n */\n useWorker?: boolean;\n\n /**\n * Alias for `useWorker`, accepted for callers using the older option\n * name. When both are set, `useWorker` wins — see `resolveUseWorker`.\n */\n enableWebWorker?: boolean;\n\n /**\n * URL of the worker script (`beacon.worker.js`, exported as\n * `@kya-os/checkpoint-beacon/worker`). Classic workers must be same-origin.\n * When unset, the beacon derives `beacon.worker.js` next to the `<script>`\n * tag that loaded `beacon.min.js`, else `/beacon.worker.js` at the site root.\n */\n workerUrl?: string;\n\n /**\n * Worker lifecycle tuning: `initTimeoutMs` (3000), `messageTimeout` (30000),\n * `heartbeatInterval` (5000), `maxRetries` (3), `retryDelay` (1000),\n * `compressionThreshold` (5120), `allowFallback` (true).\n */\n workerConfig?: WorkerConfig;\n\n lazySignalsUrl?: string;\n}\n\n// ============================================================================\n// BEACON EVENTS\n// ============================================================================\n\nexport interface BeaconEvent {\n /** Event type identifier */\n type: BeaconEventType;\n\n /** Event data payload */\n data: BeaconCollectorData;\n\n /** Event metadata */\n metadata: BeaconMetadata;\n}\n\nexport interface BeaconMetadata {\n /** Session ID */\n sessionId: string;\n\n /** Event timestamp */\n timestamp: number;\n\n /** Optional event name */\n eventName?: string;\n\n /** Present only once the host site has told us who the visitor is. */\n identity?: BeaconIdentity;\n\n /** Allow additional metadata */\n [key: string]: unknown;\n}\n\n// ============================================================================\n// BEACON API\n// ============================================================================\n\nexport interface IAgentShieldBeacon {\n /**\n * Collect a generic event\n */\n collect(eventType: string, data?: BeaconPayload): Promise<void>;\n\n /**\n * Track a custom event\n */\n trackEvent(eventName: string, eventData?: BeaconPayload): Promise<void>;\n\n /**\n * Track a pageview\n */\n trackPageview(pageData?: BeaconPayload): Promise<void>;\n\n /**\n * Track page unload\n */\n trackPageUnload(): Promise<void>;\n\n /**\n * Update configuration\n */\n updateConfig(updates: Partial<BeaconConfig>): void;\n\n /**\n * Destroy the beacon and clean up\n */\n destroy(): Promise<void>;\n}\n\n// ============================================================================\n// RESPONSE TYPES\n// ============================================================================\n\nexport interface BeaconResponse {\n /** Response status */\n status: 'success' | 'error';\n\n /** Optional message */\n message?: string;\n\n /** Optional error details */\n error?: {\n code: string;\n message: string;\n };\n}\n\n// ============================================================================\n// BROWSER CONTEXT\n// ============================================================================\n\nexport interface BrowserContext {\n /** Browser name and version */\n browser: {\n name: string;\n version: string;\n engine: string;\n };\n\n /** Operating system */\n os: {\n name: string;\n version: string;\n };\n\n /** Device information */\n device: {\n type: 'desktop' | 'mobile' | 'tablet' | 'tv' | 'unknown';\n vendor?: string;\n model?: string;\n };\n\n /** Screen information */\n screen: {\n width: number;\n height: number;\n pixelRatio: number;\n colorDepth: number;\n };\n\n /** Connection information */\n connection?: {\n type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';\n effectiveType?: '2g' | '3g' | '4g' | '5g';\n downlink?: number;\n rtt?: number;\n saveData?: boolean;\n };\n}\n\n// ============================================================================\n// PERFORMANCE METRICS\n// ============================================================================\n\nexport interface PerformanceMetrics {\n /** Page load time in milliseconds */\n pageLoadTime?: number;\n\n /** DOM content loaded time */\n domContentLoadedTime?: number;\n\n /** Time to interactive */\n timeToInteractive?: number;\n\n /** First paint time */\n firstPaintTime?: number;\n\n /** First contentful paint time */\n firstContentfulPaintTime?: number;\n\n /** Largest contentful paint time */\n largestContentfulPaintTime?: number;\n\n /** DNS lookup time */\n dnsLookupTime?: number;\n\n /** TCP connection time */\n tcpConnectionTime?: number;\n\n /** Server response time */\n serverResponseTime?: number;\n\n /** Resource timing */\n resources?: {\n scripts: number;\n stylesheets: number;\n images: number;\n fonts: number;\n total: number;\n };\n}\n\n// ============================================================================\n// SESSION TYPES\n// ============================================================================\n\nexport interface SessionData {\n /** Unique session ID */\n id: string;\n\n /** Session start timestamp */\n startTime: number;\n\n /** Last activity timestamp */\n lastActivity: number;\n\n /** Page view count in session */\n pageViews: number;\n\n /** Event count in session */\n eventCount: number;\n\n /** Session duration in milliseconds */\n duration: number;\n\n /** Is this a new session */\n isNew: boolean;\n}\n\n// ============================================================================\n// TRANSPORT TYPES\n// ============================================================================\n\nexport interface TransportConfig {\n maxRetries: number;\n retryDelayBase: number;\n offlineQueueSize: number;\n useCompression: boolean;\n compressionThreshold: number;\n /** Build item 6: carried onto every outgoing `BeaconBatch` — see `BeaconConfig.anonymizeIp`. */\n anonymizeIp?: boolean;\n}\n\nexport interface TransportOptions {\n immediate?: boolean;\n priority?: 'low' | 'normal' | 'high' | 'critical';\n retry?: boolean;\n timeout?: number;\n publicJwk?: EcPublicJwk;\n deviceId?: string;\n handoffToken?: string;\n}\n\nexport interface TransportResponse {\n success: boolean;\n timestamp: number;\n batchId?: string;\n error?: string;\n}\n\nexport type TransportState = 'idle' | 'sending' | 'offline' | 'paused' | 'error';\n\nexport interface TransportMetrics {\n eventsSent: number;\n eventsFailed: number;\n eventsQueued: number;\n batchesSent: number;\n batchesFailed: number;\n bytesTransferred: number;\n compressionRatio?: number;\n averageLatency?: number;\n lastSuccessTimestamp?: number;\n lastErrorTimestamp?: number;\n}\n\nexport type ConnectionType =\n | 'bluetooth'\n | 'cellular'\n | 'ethernet'\n | 'none'\n | 'wifi'\n | 'wimax'\n | 'other'\n | 'unknown';\n\nexport interface NetworkInfo {\n type?: string;\n effectiveType?: string;\n downlink?: number;\n rtt?: number;\n saveData?: boolean;\n}\n\n// ============================================================================\n// WORKER TYPES\n// ============================================================================\n\nexport type MessagePriority = 'low' | 'normal' | 'high' | 'critical';\nexport type WorkerErrorType =\n | 'initialization'\n | 'runtime'\n | 'communication'\n | 'timeout'\n | 'memory'\n | 'network'\n | 'permission'\n | 'validation'\n | 'processing'\n | 'unknown';\nexport type WorkerAction =\n | 'process'\n | 'init'\n | 'terminate'\n | 'pause'\n | 'resume'\n | 'status'\n | 'health';\nexport type WorkerMessageType = 'request' | 'response' | 'error' | 'heartbeat' | 'status';\n\nexport interface WorkerMessage {\n id: string;\n type: 'request' | 'response' | 'error' | 'heartbeat' | 'status';\n action?: string;\n payload?: WorkerPayload;\n timestamp: number;\n compressed?: boolean;\n priority?: MessagePriority;\n correlationId?: string;\n}\n\nexport type WorkerState =\n | 'idle'\n | 'initializing'\n | 'ready'\n | 'processing'\n | 'busy'\n | 'error'\n | 'terminating'\n | 'terminated';\n\nexport type WorkerHealthStatus = 'healthy' | 'degraded' | 'unhealthy' | 'unknown';\n\nexport interface WorkerMetrics {\n tasksProcessed: number;\n tasksFailed: number;\n averageProcessingTime?: number;\n memoryUsage?: number;\n cpuUsage?: number;\n healthStatus: WorkerHealthStatus;\n lastHealthCheck: number;\n restartCount: number;\n errorRate?: number;\n errorCount: number;\n messageQueueSize: number;\n startTime: number;\n uptime: number;\n averageTaskTime?: number;\n lastTaskTime?: number;\n}\n\nexport interface WorkerError {\n type: WorkerErrorType;\n code?: string;\n message: string;\n stack?: string;\n timestamp: number;\n recoverable: boolean;\n retryAfter?: number;\n context?: Record<string, unknown>;\n}\n\nexport interface WorkerCapabilities {\n workerAPI: boolean;\n sharedArrayBuffer: boolean;\n transferableObjects: boolean;\n offscreenCanvas: boolean;\n webAssembly: boolean;\n atomics: boolean;\n bigInt: boolean;\n csp: {\n workerSrc: boolean;\n scriptSrc: boolean;\n blobUrls: boolean;\n inlineWorkers: boolean;\n };\n performance: {\n memory: boolean;\n measureUserAgentSpecificMemory: boolean;\n };\n}\n\nexport interface WorkerTask {\n id: string;\n type: string;\n data: WorkerPayload;\n priority: 'low' | 'normal' | 'high' | 'critical';\n createdAt: number;\n startedAt?: number;\n completedAt?: number;\n error?: WorkerError;\n maxRetries?: number;\n retries?: number;\n timeout?: number;\n}\n\nexport interface FallbackOptions {\n useRequestIdleCallback: boolean;\n idleTimeout: number;\n chunkSize: number;\n throttleMs: number;\n maxExecutionTime: number;\n}\n\nexport interface ResourceUsage {\n memory: {\n used: number;\n limit: number;\n percentage: number;\n };\n cpu: {\n usage: number;\n limit: number;\n };\n tasks: {\n pending: number;\n active: number;\n completed: number;\n failed: number;\n };\n activeWorkers: number;\n}\n\nexport interface WorkerPoolConfig {\n maxWorkers: number;\n minWorkers: number;\n workerIdleTimeout: number;\n taskQueueSize: number;\n resourceLimits: Record<string, number>;\n autoScale?: boolean;\n scaleUpThreshold?: number;\n scaleDownThreshold?: number;\n}\n\nexport type BeaconWorkerMessageType =\n | 'init'\n | 'collect'\n | 'flush'\n | 'config'\n | 'status'\n | 'error'\n | 'response'\n // Unsolicited worker -> main relay of a 202 ingest body (posture cookie\n // delivery needs `document`, which the worker lacks).\n | 'posture';\nexport type ProtocolVersion = '1.0' | '1.1' | '2.0';\n\nexport interface BeaconWorkerMessage {\n type: BeaconWorkerMessageType;\n data?: WorkerPayload;\n payload?: WorkerPayload;\n messageId: string;\n timestamp: number;\n id: string;\n}\n\nexport interface WorkerConfig {\n enabled?: boolean;\n url?: string;\n heartbeatInterval?: number;\n maxUnhealthyCount?: number;\n maxRetries?: number;\n retryDelay?: number;\n restartDelay?: number;\n messageTimeout?: number;\n compressionThreshold?: number;\n allowFallback?: boolean;\n crossOriginIsolated?: boolean;\n maxRestartAttempts?: number;\n terminationTimeout?: number;\n taskTimeout?: number;\n fallbackDelay?: number;\n enableFallback?: boolean;\n /**\n * Hard ceiling on how long worker startup (script load + init handshake)\n * gets before the caller gives up and falls back to the main-thread\n * transport. Deliberately separate from `taskTimeout`/`messageTimeout`\n * (which govern steady-state message round trips once the worker is\n * already up): a slow or hung worker script would otherwise hold up\n * every event for the full 30s message timeout before anything left the\n * page. A few seconds is enough for a healthy worker to load and answer\n * its init message; anything slower isn't worth waiting on.\n */\n initTimeoutMs?: number;\n}\n\n// ============================================================================\n// CIRCUIT BREAKER & RETRY\n// ============================================================================\n\nexport interface CircuitBreakerConfig {\n threshold: number;\n timeout: number;\n resetTimeout: number;\n}\n\nexport type CircuitBreakerState = 'closed' | 'open' | 'half-open';\n\nexport interface RetryStrategy {\n maxAttempts: number;\n baseDelay: number;\n maxDelay: number;\n factor: number;\n jitter: boolean;\n}\n\n// ============================================================================\n// OFFLINE QUEUE\n// ============================================================================\n\nexport interface OfflineQueueEntry {\n id: string;\n events: BeaconEvent[];\n timestamp: number;\n expiresAt: number;\n retryCount: number;\n size: number;\n}\n\n// ============================================================================\n// BEACON BATCH\n// ============================================================================\n\n/** The minimal EC-P256 public JWK shape the beacon can construct without\n * a JOSE library dependency (see P37's findings on bundle-size discipline).\n * Structurally compatible with `jose`'s wider `JWK` type on the server side. */\nexport interface EcPublicJwk {\n kty: 'EC';\n crv: 'P-256';\n x: string;\n y: string;\n}\n\n/** What `BeaconConfig.onReceipt` receives for each 202 ingest response. */\nexport interface BeaconReceipt {\n /**\n * The server's session id for this visit, the key\n * `GET /api/v1/projects/{id}/sessions/{sessionId}` reads. On a receipt from\n * the queue-only edge it is present once the origin has answered for the\n * session, and absent before (`postureStatus: 'pending'`).\n */\n sessionId?: string;\n /**\n * The beacon's own session id the batch was sent under: what a posture\n * token is bound to, and what `BeaconConfig.browserSessionId` resumes.\n */\n browserSessionId: string;\n /** The signed posture token, when ingest issued one. `expiresAt` is Unix seconds. */\n posture?: { token: string; expiresAt: number };\n /** Why `posture` is absent: `'pending'` while a queued batch awaits replay, otherwise the withheld reason. */\n postureStatus?: string;\n}\n\nexport interface BeaconBatch {\n projectId: string;\n events: BeaconEvent[];\n sessionId: string;\n handoffToken?: string;\n deviceId?: string;\n batchId: string;\n timestamp: number;\n /** Build item 6: mirrors `BeaconConfig.anonymizeIp` (default `false`) — see the beacon route's own doc comment. */\n anonymizeIp?: boolean;\n /** Nonce-bound ingest (build item 5): the value from the prior 202 response's `nonce`. */\n nonce?: string;\n /** Nonce-bound ingest (build item 5): declares this client echoes nonces — see checkpoint-beacon's `BeaconBatch`. */\n nonceEcho?: boolean;\n /** Holder-of-key posture binding (P37): the beacon's own DPoP public key,\n * sent once per browser session (first batch only) so the issuer can bind\n * every subsequent posture mint to it via `cnf.jkt`. */\n publicJwk?: EcPublicJwk;\n}\n\nexport interface BeaconCollectorData {\n // Browser collector data\n userAgent?: string;\n language?: string;\n platform?: string;\n screenResolution?: string;\n viewport?: string;\n cookiesEnabled?: boolean;\n doNotTrack?: boolean;\n timezone?: string;\n referrer?: string;\n url?: string;\n title?: string;\n vendor?: string;\n\n // Performance collector data\n pageLoadTime?: number;\n domContentLoadedTime?: number;\n firstPaintTime?: number;\n firstContentfulPaintTime?: number;\n connectionType?: string;\n\n // Session data\n sessionId?: string;\n timestamp?: number;\n\n // Allow additional properties\n [key: string]: unknown;\n}\n\nexport type BeaconEventType =\n | 'pageview'\n | 'pageunload'\n | 'heartbeat'\n | 'evidence'\n | 'custom'\n | 'error'\n | 'performance';\n\n// ============================================================================\n// PARSER FUNCTIONS\n// ============================================================================\n\nexport function parseRetryStrategy(input: unknown): RetryStrategy {\n const strategy = toRecord(input);\n return {\n maxAttempts: numberOr(strategy.maxAttempts, 3),\n baseDelay: numberOr(strategy.baseDelay, 1000),\n maxDelay: numberOr(strategy.maxDelay, 30000),\n factor: numberOr(strategy.factor, 2),\n jitter: strategy.jitter !== false,\n };\n}\n\nexport function parseCircuitBreakerConfig(input: unknown): CircuitBreakerConfig {\n const config = toRecord(input);\n return {\n threshold: numberOr(config.threshold, 5),\n timeout: numberOr(config.timeout, 60000),\n resetTimeout: numberOr(config.resetTimeout, 30000),\n };\n}\n\nexport function parseOfflineQueueEntry(input: unknown): OfflineQueueEntry {\n if (!isRecord(input)) {\n throw new Error('Invalid offline queue entry');\n }\n\n const entry = input;\n return {\n id: stringOr(\n entry.id,\n `${Date.now()}_${Array.from(crypto.getRandomValues(new Uint8Array(6)), (byte) => byte.toString(16).padStart(2, '0')).join('')}`\n )!,\n events: Array.isArray(entry.events) ? (entry.events as BeaconEvent[]) : [],\n timestamp: numberOr(entry.timestamp, Date.now()),\n expiresAt: numberOr(entry.expiresAt, Date.now() + 86400000), // 24 hours\n retryCount: numberOr(entry.retryCount, 0),\n size: numberOr(entry.size, 0),\n };\n}\n\nfunction randomId(): string {\n const bytes = crypto.getRandomValues(new Uint8Array(16));\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\nexport function parseBeaconWorkerMessage(input: unknown): BeaconWorkerMessage {\n if (!isRecord(input)) {\n throw new Error('Invalid beacon worker message');\n }\n\n const msg = input;\n const messageId = stringOr(msg.messageId) ?? stringOr(msg.id) ?? randomId();\n return {\n type: isBeaconWorkerMessageType(msg.type) ? msg.type : 'init',\n data: msg.data,\n payload: msg.payload,\n messageId,\n timestamp: numberOr(msg.timestamp, Date.now()),\n id: stringOr(msg.id, messageId)!,\n };\n}\n\nfunction isMessagePriority(value: unknown): value is MessagePriority {\n return value === 'low' || value === 'normal' || value === 'high' || value === 'critical';\n}\n\nfunction isWorkerMessageType(value: unknown): value is WorkerMessageType {\n return (\n value === 'request' ||\n value === 'response' ||\n value === 'error' ||\n value === 'heartbeat' ||\n value === 'status'\n );\n}\n\nfunction isWorkerErrorType(value: unknown): value is WorkerErrorType {\n return (\n value === 'initialization' ||\n value === 'runtime' ||\n value === 'communication' ||\n value === 'timeout' ||\n value === 'memory' ||\n value === 'network' ||\n value === 'permission' ||\n value === 'validation' ||\n value === 'processing' ||\n value === 'unknown'\n );\n}\n\nexport function parseWorkerMessage(input: unknown): WorkerMessage {\n const msg = (input && typeof input === 'object' ? input : null) as Partial<WorkerMessage> | null;\n if (!msg) {\n throw new Error('Invalid worker message');\n }\n\n return {\n id: msg.id || randomId(),\n type: isWorkerMessageType(msg.type) ? msg.type : 'request',\n action: msg.action,\n payload: msg.payload,\n timestamp: msg.timestamp || Date.now(),\n compressed: msg.compressed,\n priority: isMessagePriority(msg.priority) ? msg.priority : 'normal',\n correlationId: msg.correlationId,\n };\n}\n\nexport function parseWorkerError(input: unknown): WorkerError {\n const error = (input && typeof input === 'object' ? input : {}) as Partial<WorkerError>;\n return {\n type: isWorkerErrorType(error.type) ? error.type : 'unknown',\n code: typeof error.code === 'string' ? error.code : undefined,\n message: typeof error.message === 'string' ? error.message : 'Worker error',\n stack: typeof error.stack === 'string' ? error.stack : undefined,\n timestamp: typeof error.timestamp === 'number' ? error.timestamp : Date.now(),\n recoverable: error.recoverable !== false,\n retryAfter: typeof error.retryAfter === 'number' ? error.retryAfter : undefined,\n context: error.context,\n };\n}\n\nexport function parseWorkerPoolConfig(input: unknown): WorkerPoolConfig {\n const config = (input && typeof input === 'object' ? input : {}) as Partial<WorkerPoolConfig>;\n return {\n maxWorkers: config.maxWorkers ?? 4,\n minWorkers: config.minWorkers ?? 1,\n workerIdleTimeout: config.workerIdleTimeout ?? 30000,\n taskQueueSize: config.taskQueueSize ?? 100,\n resourceLimits: config.resourceLimits ?? {},\n autoScale: config.autoScale ?? true,\n scaleUpThreshold: config.scaleUpThreshold ?? 75,\n scaleDownThreshold: config.scaleDownThreshold ?? 25,\n };\n}\n\nexport function parseResourceUsage(input: unknown): ResourceUsage {\n const usage = (input && typeof input === 'object' ? input : {}) as Partial<ResourceUsage>;\n return {\n memory: usage.memory ?? { used: 0, limit: 0, percentage: 0 },\n cpu: usage.cpu ?? { usage: 0, limit: 100 },\n tasks: usage.tasks ?? { pending: 0, active: 0, completed: 0, failed: 0 },\n activeWorkers: usage.activeWorkers ?? 0,\n };\n}\n\nexport const ResourceUsageSchema = {\n parse: parseResourceUsage,\n};\n\nexport const WorkerPoolConfigSchema = {\n parse: parseWorkerPoolConfig,\n};\n\nexport function parseWorkerCapabilities(input: unknown): WorkerCapabilities {\n const cap = toRecord(input);\n const csp = toRecord(cap.csp);\n const performance = toRecord(cap.performance);\n\n return {\n workerAPI: cap.workerAPI !== false,\n sharedArrayBuffer: cap.sharedArrayBuffer === true,\n transferableObjects: cap.transferableObjects === true,\n offscreenCanvas: cap.offscreenCanvas === true,\n webAssembly: cap.webAssembly === true,\n atomics: cap.atomics === true,\n bigInt: cap.bigInt === true,\n csp: {\n workerSrc: csp.workerSrc === true,\n scriptSrc: csp.scriptSrc === true,\n blobUrls: csp.blobUrls === true,\n inlineWorkers: csp.inlineWorkers === true,\n },\n performance: {\n memory: performance.memory === true,\n measureUserAgentSpecificMemory: performance.measureUserAgentSpecificMemory === true,\n },\n };\n}\n\n/**\n * @param onWarn Called once per rejected config value (a supplied value that\n * failed validation and fell back to its default), for a caller that wants\n * to surface it — `BeaconConfigManager.validateAndMergeConfig` wires this to\n * `log('warn', ...)`. Never called for an omitted field; only for one the\n * caller actually set to something invalid.\n */\nexport function parseBeaconConfig(\n input: unknown,\n onWarn?: (message: string) => void\n): BeaconConfig {\n const config = toRecord(input);\n\n if (typeof config.projectId !== 'string' || config.projectId.length === 0) {\n throw new Error('Project ID is required');\n }\n\n return {\n projectId: config.projectId,\n environment: stringOr(config.environment),\n tags: isBeaconTags(config.tags) ? config.tags : undefined,\n identity: isBeaconIdentity(config.identity) ? config.identity : undefined,\n // `parseBeaconConfig` is an allowlist: a key it does not name is dropped\n // silently, which is how `identity` first shipped inert.\n endpoint: stringOr(config.endpoint),\n enabled: config.enabled !== false,\n debug: config.debug === true,\n logLevel: isLogLevel(config.logLevel) ? config.logLevel : 'error',\n respectDoNotTrack: config.respectDoNotTrack !== false,\n requireConsent: config.requireConsent === true,\n anonymizeIp: config.anonymizeIp === true,\n stripUrlFragment: config.stripUrlFragment !== false,\n scrubQueryParams: isStringArray(config.scrubQueryParams) ? config.scrubQueryParams : undefined,\n dropQueryParams: config.dropQueryParams === true,\n sessionTimeout: numberOr(config.sessionTimeout, undefined),\n sessionCookieName: stringOr(config.sessionCookieName, '_as_beacon_session'),\n browserSessionId: resumableSessionId(config.browserSessionId, (received) =>\n onWarn?.(\n `browserSessionId must match ${RESUMABLE_SESSION_ID} (received ${JSON.stringify(received)}); ignoring it`\n )\n ),\n onReceipt: receiptCallback(config.onReceipt, (received) =>\n onWarn?.(`onReceipt must be a function (received ${typeof received}); ignoring it`)\n ),\n // Deprecated no-ops (see BeaconConfig.batchSize/flushInterval): passed\n // through when a caller sets them so a stale value round-trips through\n // `get()`, never defaulted, since nothing reads them anymore.\n batchSize: typeof config.batchSize === 'number' ? config.batchSize : undefined,\n flushInterval: typeof config.flushInterval === 'number' ? config.flushInterval : undefined,\n collectorDeadlineMs: numberOr(config.collectorDeadlineMs, 1600),\n evidenceGrowthFactor: boundedNumberOr(\n config.evidenceGrowthFactor,\n 2,\n (n) => n > 1,\n (received) =>\n onWarn?.(\n `evidenceGrowthFactor must be a number greater than 1 (received ${JSON.stringify(received)}); using default 2`\n )\n ),\n postureRefreshFraction: boundedNumberOr(\n config.postureRefreshFraction,\n 0.5,\n (n) => n > 0 && n <= 1,\n (received) =>\n onWarn?.(\n `postureRefreshFraction must be a number in (0, 1] (received ${JSON.stringify(received)}); using default 0.5`\n )\n ),\n triggers: pickTriggers(config.triggers, (name, received) =>\n onWarn?.(\n `triggers.${name} must be a boolean (received ${JSON.stringify(received)}); ignoring it and keeping its default`\n )\n ),\n maxQueueSize: numberOr(config.maxQueueSize, 100),\n retryAttempts: numberOr(config.retryAttempts, 3),\n retryDelay: numberOr(config.retryDelay, 2000),\n postureRetryScheduleMs: isPositiveNumberArray(config.postureRetryScheduleMs)\n ? config.postureRetryScheduleMs\n : undefined,\n useWorker: resolveUseWorker(config),\n workerUrl: stringOr(config.workerUrl),\n workerConfig: isRecord(config.workerConfig) ? (config.workerConfig as WorkerConfig) : undefined,\n lazySignalsUrl: stringOr(config.lazySignalsUrl),\n proactiveRefreshMinIntervalMs: boundedNumberOr(\n config.proactiveRefreshMinIntervalMs,\n 30_000,\n (n) => n > 0,\n (received) =>\n onWarn?.(\n `proactiveRefreshMinIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 30000`\n )\n ),\n proactiveRefreshMaxIntervalMs: boundedNumberOr(\n config.proactiveRefreshMaxIntervalMs,\n 60_000,\n (n) => n > 0,\n (received) =>\n onWarn?.(\n `proactiveRefreshMaxIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 60000`\n )\n ),\n proactiveRefreshFreshnessMs: optionalPositiveNumber(\n config.proactiveRefreshFreshnessMs,\n (received) =>\n onWarn?.(\n `proactiveRefreshFreshnessMs must be a positive number (received ${JSON.stringify(received)}); ignoring it and inheriting postureRefreshFraction's threshold`\n )\n ),\n proactiveRefreshOnVisibilityResume: booleanOr(\n config.proactiveRefreshOnVisibilityResume,\n true,\n (received) =>\n onWarn?.(\n `proactiveRefreshOnVisibilityResume must be a boolean (received ${JSON.stringify(received)}); using default true`\n )\n ),\n proactiveRefreshOnOnline: booleanOr(config.proactiveRefreshOnOnline, true, (received) =>\n onWarn?.(\n `proactiveRefreshOnOnline must be a boolean (received ${JSON.stringify(received)}); using default true`\n )\n ),\n proactiveRefreshJitterSeed: optionalFiniteNumber(\n config.proactiveRefreshJitterSeed,\n (received) =>\n onWarn?.(\n `proactiveRefreshJitterSeed must be a finite number (received ${JSON.stringify(received)}); ignoring it, jitter will use Math.random()`\n )\n ),\n };\n}\n\n// ============================================================================\n// EXPORT MAIN CLASS TYPE\n// ============================================================================\n\nexport declare class AgentShieldBeacon implements IAgentShieldBeacon {\n constructor(config: BeaconConfig);\n collect(eventType: string, data?: BeaconPayload): Promise<void>;\n trackEvent(eventName: string, eventData?: BeaconPayload): Promise<void>;\n trackPageview(pageData?: BeaconPayload): Promise<void>;\n trackPageUnload(): Promise<void>;\n updateConfig(updates: Partial<BeaconConfig>): void;\n destroy(): Promise<void>;\n}\n\n/**\n * The most events one beacon POST may carry. The ingest route's\n * `BeaconBatchSchema` refuses a larger batch whole (a 400, not a retry), so\n * the SDK's offline drain never dequeues more than this per request.\n */\nexport const BEACON_MAX_EVENTS_PER_BATCH = 100;\n\nexport const SESSION_IDLE_GAP_MAX_MS = 21_600_000;\nexport const BEACON_MAX_BATCH_ID_LENGTH = 255;\n\nexport const BEACON_ORIGIN_CONTRACT_VERSION = 1;\n\nexport const BEACON_ORIGIN_CAPABILITIES = [\n 'batch-replay-v1',\n 'receipt-status-v1',\n 'receipt-posture-v1',\n] as const;\n\n/**\n * Lifetime of the signed browser posture token, in seconds. Defined here and\n * re-exported by `browser-posture.ts` (which imports `jose`) so the\n * size-budgeted beacon bundle can read it without pulling in a JWT library.\n */\nexport const POSTURE_TTL_SECONDS = 120;\n\nexport interface CachedPosture {\n token: string;\n expiresAt: number;\n}\n\nexport interface PostureAnswer {\n posture?: CachedPosture;\n postureStatus?: string;\n sessionId?: string;\n answeredAtMs?: number;\n}\n\nexport function parsePostureAnswer(value: unknown): PostureAnswer {\n if (!isRecord(value)) return {};\n const answer: PostureAnswer = {};\n if (\n isRecord(value.posture) &&\n typeof value.posture.token === 'string' &&\n value.posture.token.length > 0 &&\n typeof value.posture.expiresAt === 'number' &&\n Number.isFinite(value.posture.expiresAt)\n ) {\n answer.posture = { token: value.posture.token, expiresAt: value.posture.expiresAt };\n } else if (typeof value.postureStatus === 'string' && value.postureStatus.length <= 64) {\n answer.postureStatus = value.postureStatus;\n }\n if (typeof value.sessionId === 'string' && value.sessionId.length <= 255) {\n answer.sessionId = value.sessionId;\n }\n if (typeof value.answeredAtMs === 'number' && Number.isFinite(value.answeredAtMs)) {\n answer.answeredAtMs = value.answeredAtMs;\n }\n return answer;\n}\n"],"mappings":";AAgBA,SAAS,SAAS,OAAwC;CACxD,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,SAAS,OAA+B;CAC/C,OAAO,SAAS,KAAK,IAAI,QAAQ,CAAC;AACpC;AAEA,SAAS,SACP,OACA,UACmB;CACnB,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,UAAU,IAAI,QAAQ;AACtF;;;;;;;;;AAUA,SAAS,gBACP,OACA,UACA,IACA,UACQ;CACR,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,GAAG,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O,0BAA0B,OAAO,aAC1E,SACE,wDAAwD,KAAK,UAAU,QAAQ,EAAE,sBACnF,CACF;EACA,4BAA4B,qBAC1B,OAAO,6BACN,aACC,SACE,gEAAgE,KAAK,UAAU,QAAQ,EAAE,8CAC3F,CACJ;CACF;AACF;;;;;;AAqBA,MAAa,8BAA8B;AAE3C,MAAa,0BAA0B;AACvC,MAAa,6BAA6B;AAE1C,MAAa,iCAAiC;AAE9C,MAAa,6BAA6B;CACxC;CACA;CACA;AACF;;;;;;AAOA,MAAa,sBAAsB;AAcnC,SAAgB,mBAAmB,OAA+B;CAChE,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO,CAAC;CAC9B,MAAM,SAAwB,CAAC;CAC/B,IACE,SAAS,MAAM,OAAO,KACtB,OAAO,MAAM,QAAQ,UAAU,YAC/B,MAAM,QAAQ,MAAM,SAAS,KAC7B,OAAO,MAAM,QAAQ,cAAc,YACnC,OAAO,SAAS,MAAM,QAAQ,SAAS,GAEvC,OAAO,UAAU;EAAE,OAAO,MAAM,QAAQ;EAAO,WAAW,MAAM,QAAQ;CAAU;MAC7E,IAAI,OAAO,MAAM,kBAAkB,YAAY,MAAM,cAAc,UAAU,IAClF,OAAO,gBAAgB,MAAM;CAE/B,IAAI,OAAO,MAAM,cAAc,YAAY,MAAM,UAAU,UAAU,KACnE,OAAO,YAAY,MAAM;CAE3B,IAAI,OAAO,MAAM,iBAAiB,YAAY,OAAO,SAAS,MAAM,YAAY,GAC9E,OAAO,eAAe,MAAM;CAE9B,OAAO;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as ZodOptional, E as ZodObject, L as output, T as ZodNumber, V as $strip, _ as ZodGUID, g as ZodEnum, j as ZodString, l as ZodArray, m as ZodDefault, t as external_d_exports, u as ZodBoolean, w as ZodNullable, x as ZodLiteral } from "./external-B7WI9FyQ.mjs";
|
|
2
2
|
import { JWK, JWK as JWK$1 } from "jose";
|
|
3
3
|
//#region src/browser-posture-cookie.d.ts
|
|
4
4
|
declare function postureCookieName(projectId: string): string;
|
|
@@ -166,4 +166,4 @@ declare function postureRequiredScopes(config: BrowserPostureConfig, path: strin
|
|
|
166
166
|
declare function validateBrowserPostureConfig(config: BrowserPostureConfig, projectId: string | undefined): void;
|
|
167
167
|
//#endregion
|
|
168
168
|
export { POSTURE_VERIFICATION_STATUSES as A, verifyBrowserPosture as C, BrowserPostureRejectionReason as D, BrowserPostureOutcomeSchema as E, POSTURE_TTL_SECONDS as F, postureCookieName as I, browserPostureReport as M, BrowserPosture as N, BrowserPostureReportIngestSchema as O, BrowserPostureSchema as P, validateBrowserPostureConfig as S, BrowserPostureOutcome as T, postureRequiredScopes as _, POSTURE_SESSION_HEADER as a, readPostureCookie as b, PostureVerification as c, inspectBrowserPosture as d, postureFromCookies as f, postureRequestFromHeaders as g, postureOutcomeReport as h, POSTURE_ISSUER as i, PostureVerificationStatus as j, BrowserPostureReportSchema as k, UNSIGNED_BROWSER_AGENT as l, postureOutcomeFromRequest as m, JWK$1 as n, POSTURE_TYPE as o, postureFromRequest as p, POSTURE_HEADER as r, PostureRequest as s, BrowserPostureConfig as t, behavioralConfidence as u, postureSessionBinding as v, BROWSER_POSTURE_REJECTION_REASONS as w, signBrowserPosture as x, postureUpgrade as y };
|
|
169
|
-
//# sourceMappingURL=browser-posture-
|
|
169
|
+
//# sourceMappingURL=browser-posture-BuChqmH5.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-posture-
|
|
1
|
+
{"version":3,"file":"browser-posture-BuChqmH5.d.mts","names":[],"sources":["../src/browser-posture-cookie.ts","../src/beacon-types/index.ts","../src/browser-posture-schema.ts","../src/browser-posture-report.ts","../src/browser-posture.ts"],"mappings":";;;iBAgBgB,kBAAkB;;;cC4jDrB;;;cC1kDA,sBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2C/B;KAGU,iBAAiB,cAAe;;;cC7C/B;KACD,oCAAoC;cAGnC,4BAA0B;;;;;;;;;;;;;;GAWrC;cAEW;KAaD,wCAAwC;cAEvC,6BAA2B;;;;;;;;;;;;;;;;;;;GAQpC;KACQ,wBAAwB,cAAe;cA2BtC,kCAAgC;;;;;;;;;;;;;;GAE3C;iBAEc,qBAAqB,SAAS;;;;;;;;;;;;;cClDjC;;;;;cAKA,uBAAwB;UAG3B;EACR;EACA;EACA;EACA;EACA;EACA;;iBAGc,eAAe,SAAS,iBAAiB;cAyC5C;cAGA;UAEI;EAEf,WAAW;EACX;EAEA;EACA;EACA;EAEA,kBAAkB;IAAQ;IAAc;;;iBAI1B,kBACd,mCACA;iBAcoB,sBAAsB,oBAAoB;iBAc1C,mBACpB,SAAS,gBACT,YAAY,KACZ,gBACC;KAqBS;EACN;EAAoB,SAAS;;EAC7B;;EACA;EAAoB,QAAQ;;cAOrB,uBAAwB,SAAS,wBAAsB;iBAM9C,sBACpB,2BACA,QAAQ,sBACR,mBACA,sCACA,eACC,QAAQ;iBA2EW,qBACpB,2BACA,QAAQ,sBACR,mBACA,sCACA,eACC,QAAQ;cAYE;cACA;UAGI;EACf;EAEA;EAEA;;iBAIc,0BACd,MAAM,iEACL;iBA6BmB,0BACpB,SAAS,gBACT,QAAQ,sBACR,mBACA,eACC,QAAQ;iBAcW,mBACpB,SAAS,gBACT,QAAQ,sBACR,mBACA,eACC,QAAQ;iBAIW,mBACpB,mCACA,QAAQ,sBACR,oBACC,QAAQ;iBAKK,sBACd,QAAQ,sBACR;iBAmBc,6BACd,QAAQ,sBACR"}
|