@kya-os/checkpoint-shared 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/beacon-types/index.d.mts +21 -14
- package/dist/beacon-types/index.d.mts.map +1 -1
- package/dist/beacon-types/index.d.ts +21 -14
- package/dist/beacon-types/index.d.ts.map +1 -1
- package/dist/beacon-types/index.js +92 -4
- package/dist/beacon-types/index.mjs +91 -5
- package/dist/beacon-types/index.mjs.map +1 -1
- package/dist/browser-posture.d.mts +3 -1
- package/dist/browser-posture.d.mts.map +1 -1
- package/dist/browser-posture.d.ts +3 -1
- package/dist/browser-posture.d.ts.map +1 -1
- package/dist/browser-posture.js +9 -1
- package/dist/browser-posture.mjs +9 -1
- package/dist/browser-posture.mjs.map +1 -1
- package/dist/browser.d.mts +3 -3
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +3 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +109 -109
- package/dist/index.d.ts +109 -109
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @kya-os/checkpoint-shared
|
|
2
2
|
|
|
3
|
+
## 1.5.1
|
|
4
|
+
|
|
5
|
+
Adds `POSTURE_TTL_SECONDS` and `BEACON_MAX_EVENTS_PER_BATCH` to `./beacon-types`,
|
|
6
|
+
both consumed by `@kya-os/checkpoint-beacon` 1.4.1 (#5095).
|
|
7
|
+
|
|
8
|
+
`./browser`'s `BeaconEventType` gains `'evidence'`, matching `./beacon-types`'
|
|
9
|
+
canonical union. `TransportConfig.batchSize`/`flushInterval` are now optional;
|
|
10
|
+
nothing in this package reads them.
|
|
11
|
+
|
|
3
12
|
## 1.5.0
|
|
4
13
|
|
|
5
14
|
Two changes below carry breaking content under a minor, the same call as
|
|
@@ -59,6 +59,14 @@ export interface LargestContentfulPaintEntry extends PerformanceEntry {
|
|
|
59
59
|
export interface BeaconIdentity {
|
|
60
60
|
userId: string;
|
|
61
61
|
}
|
|
62
|
+
export interface BeaconDispatchTriggers {
|
|
63
|
+
arrival?: boolean;
|
|
64
|
+
signals?: boolean;
|
|
65
|
+
interaction?: boolean;
|
|
66
|
+
untrusted?: boolean;
|
|
67
|
+
posture?: boolean;
|
|
68
|
+
unload?: boolean;
|
|
69
|
+
}
|
|
62
70
|
export interface BeaconConfig {
|
|
63
71
|
projectId: string;
|
|
64
72
|
identity?: BeaconIdentity;
|
|
@@ -77,6 +85,15 @@ export interface BeaconConfig {
|
|
|
77
85
|
sessionCookieName?: string;
|
|
78
86
|
batchSize?: number;
|
|
79
87
|
flushInterval?: number;
|
|
88
|
+
evidenceGrowthFactor?: number;
|
|
89
|
+
postureRefreshFraction?: number;
|
|
90
|
+
triggers?: BeaconDispatchTriggers;
|
|
91
|
+
proactiveRefreshMinIntervalMs?: number;
|
|
92
|
+
proactiveRefreshMaxIntervalMs?: number;
|
|
93
|
+
proactiveRefreshFreshnessMs?: number;
|
|
94
|
+
proactiveRefreshOnVisibilityResume?: boolean;
|
|
95
|
+
proactiveRefreshOnOnline?: boolean;
|
|
96
|
+
proactiveRefreshJitterSeed?: number;
|
|
80
97
|
collectorDeadlineMs?: number;
|
|
81
98
|
maxQueueSize?: number;
|
|
82
99
|
retryAttempts?: number;
|
|
@@ -173,15 +190,11 @@ export interface SessionData {
|
|
|
173
190
|
isNew: boolean;
|
|
174
191
|
}
|
|
175
192
|
export interface TransportConfig {
|
|
176
|
-
batchSize: number;
|
|
177
|
-
flushInterval: number;
|
|
178
193
|
maxRetries: number;
|
|
179
194
|
retryDelayBase: number;
|
|
180
195
|
offlineQueueSize: number;
|
|
181
196
|
useCompression: boolean;
|
|
182
197
|
compressionThreshold: number;
|
|
183
|
-
networkAdaptation: boolean;
|
|
184
|
-
dedupWindow: number;
|
|
185
198
|
anonymizeIp?: boolean;
|
|
186
199
|
}
|
|
187
200
|
export interface TransportOptions {
|
|
@@ -209,14 +222,6 @@ export interface TransportMetrics {
|
|
|
209
222
|
lastSuccessTimestamp?: number;
|
|
210
223
|
lastErrorTimestamp?: number;
|
|
211
224
|
}
|
|
212
|
-
export interface BatchEvent {
|
|
213
|
-
id: string;
|
|
214
|
-
event: BeaconEvent;
|
|
215
|
-
timestamp: number;
|
|
216
|
-
retryCount: number;
|
|
217
|
-
hash: string;
|
|
218
|
-
priority: 'low' | 'normal' | 'high' | 'critical';
|
|
219
|
-
}
|
|
220
225
|
export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
|
|
221
226
|
export interface NetworkInfo {
|
|
222
227
|
type?: string;
|
|
@@ -417,7 +422,7 @@ export interface BeaconCollectorData {
|
|
|
417
422
|
timestamp?: number;
|
|
418
423
|
[key: string]: unknown;
|
|
419
424
|
}
|
|
420
|
-
export type BeaconEventType = 'pageview' | 'pageunload' | 'heartbeat' | 'custom' | 'error' | 'performance';
|
|
425
|
+
export type BeaconEventType = 'pageview' | 'pageunload' | 'heartbeat' | 'evidence' | 'custom' | 'error' | 'performance';
|
|
421
426
|
export declare function parseRetryStrategy(input: unknown): RetryStrategy;
|
|
422
427
|
export declare function parseCircuitBreakerConfig(input: unknown): CircuitBreakerConfig;
|
|
423
428
|
export declare function parseOfflineQueueEntry(input: unknown): OfflineQueueEntry;
|
|
@@ -433,7 +438,7 @@ export declare const WorkerPoolConfigSchema: {
|
|
|
433
438
|
parse: typeof parseWorkerPoolConfig;
|
|
434
439
|
};
|
|
435
440
|
export declare function parseWorkerCapabilities(input: unknown): WorkerCapabilities;
|
|
436
|
-
export declare function parseBeaconConfig(input: unknown): BeaconConfig;
|
|
441
|
+
export declare function parseBeaconConfig(input: unknown, onWarn?: (message: string) => void): BeaconConfig;
|
|
437
442
|
export declare class AgentShieldBeacon implements IAgentShieldBeacon {
|
|
438
443
|
constructor(config: BeaconConfig);
|
|
439
444
|
collect(eventType: string, data?: BeaconPayload): Promise<void>;
|
|
@@ -443,5 +448,7 @@ export declare class AgentShieldBeacon implements IAgentShieldBeacon {
|
|
|
443
448
|
updateConfig(updates: Partial<BeaconConfig>): void;
|
|
444
449
|
destroy(): Promise<void>;
|
|
445
450
|
}
|
|
451
|
+
export declare const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
452
|
+
export declare const POSTURE_TTL_SECONDS = 120;
|
|
446
453
|
//#endregion
|
|
447
454
|
//# 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;
|
|
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;wBAiJI,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;;iBAGe;EAEf;EAOA,WAAW;EAaX;EAGA;EAGA,OAAO;EAQP;EAO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 @@ export interface LargestContentfulPaintEntry extends PerformanceEntry {
|
|
|
59
59
|
export interface BeaconIdentity {
|
|
60
60
|
userId: string;
|
|
61
61
|
}
|
|
62
|
+
export interface BeaconDispatchTriggers {
|
|
63
|
+
arrival?: boolean;
|
|
64
|
+
signals?: boolean;
|
|
65
|
+
interaction?: boolean;
|
|
66
|
+
untrusted?: boolean;
|
|
67
|
+
posture?: boolean;
|
|
68
|
+
unload?: boolean;
|
|
69
|
+
}
|
|
62
70
|
export interface BeaconConfig {
|
|
63
71
|
projectId: string;
|
|
64
72
|
identity?: BeaconIdentity;
|
|
@@ -77,6 +85,15 @@ export interface BeaconConfig {
|
|
|
77
85
|
sessionCookieName?: string;
|
|
78
86
|
batchSize?: number;
|
|
79
87
|
flushInterval?: number;
|
|
88
|
+
evidenceGrowthFactor?: number;
|
|
89
|
+
postureRefreshFraction?: number;
|
|
90
|
+
triggers?: BeaconDispatchTriggers;
|
|
91
|
+
proactiveRefreshMinIntervalMs?: number;
|
|
92
|
+
proactiveRefreshMaxIntervalMs?: number;
|
|
93
|
+
proactiveRefreshFreshnessMs?: number;
|
|
94
|
+
proactiveRefreshOnVisibilityResume?: boolean;
|
|
95
|
+
proactiveRefreshOnOnline?: boolean;
|
|
96
|
+
proactiveRefreshJitterSeed?: number;
|
|
80
97
|
collectorDeadlineMs?: number;
|
|
81
98
|
maxQueueSize?: number;
|
|
82
99
|
retryAttempts?: number;
|
|
@@ -173,15 +190,11 @@ export interface SessionData {
|
|
|
173
190
|
isNew: boolean;
|
|
174
191
|
}
|
|
175
192
|
export interface TransportConfig {
|
|
176
|
-
batchSize: number;
|
|
177
|
-
flushInterval: number;
|
|
178
193
|
maxRetries: number;
|
|
179
194
|
retryDelayBase: number;
|
|
180
195
|
offlineQueueSize: number;
|
|
181
196
|
useCompression: boolean;
|
|
182
197
|
compressionThreshold: number;
|
|
183
|
-
networkAdaptation: boolean;
|
|
184
|
-
dedupWindow: number;
|
|
185
198
|
anonymizeIp?: boolean;
|
|
186
199
|
}
|
|
187
200
|
export interface TransportOptions {
|
|
@@ -209,14 +222,6 @@ export interface TransportMetrics {
|
|
|
209
222
|
lastSuccessTimestamp?: number;
|
|
210
223
|
lastErrorTimestamp?: number;
|
|
211
224
|
}
|
|
212
|
-
export interface BatchEvent {
|
|
213
|
-
id: string;
|
|
214
|
-
event: BeaconEvent;
|
|
215
|
-
timestamp: number;
|
|
216
|
-
retryCount: number;
|
|
217
|
-
hash: string;
|
|
218
|
-
priority: 'low' | 'normal' | 'high' | 'critical';
|
|
219
|
-
}
|
|
220
225
|
export type ConnectionType = 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown';
|
|
221
226
|
export interface NetworkInfo {
|
|
222
227
|
type?: string;
|
|
@@ -417,7 +422,7 @@ export interface BeaconCollectorData {
|
|
|
417
422
|
timestamp?: number;
|
|
418
423
|
[key: string]: unknown;
|
|
419
424
|
}
|
|
420
|
-
export type BeaconEventType = 'pageview' | 'pageunload' | 'heartbeat' | 'custom' | 'error' | 'performance';
|
|
425
|
+
export type BeaconEventType = 'pageview' | 'pageunload' | 'heartbeat' | 'evidence' | 'custom' | 'error' | 'performance';
|
|
421
426
|
export declare function parseRetryStrategy(input: unknown): RetryStrategy;
|
|
422
427
|
export declare function parseCircuitBreakerConfig(input: unknown): CircuitBreakerConfig;
|
|
423
428
|
export declare function parseOfflineQueueEntry(input: unknown): OfflineQueueEntry;
|
|
@@ -433,7 +438,7 @@ export declare const WorkerPoolConfigSchema: {
|
|
|
433
438
|
parse: typeof parseWorkerPoolConfig;
|
|
434
439
|
};
|
|
435
440
|
export declare function parseWorkerCapabilities(input: unknown): WorkerCapabilities;
|
|
436
|
-
export declare function parseBeaconConfig(input: unknown): BeaconConfig;
|
|
441
|
+
export declare function parseBeaconConfig(input: unknown, onWarn?: (message: string) => void): BeaconConfig;
|
|
437
442
|
export declare class AgentShieldBeacon implements IAgentShieldBeacon {
|
|
438
443
|
constructor(config: BeaconConfig);
|
|
439
444
|
collect(eventType: string, data?: BeaconPayload): Promise<void>;
|
|
@@ -443,5 +448,7 @@ export declare class AgentShieldBeacon implements IAgentShieldBeacon {
|
|
|
443
448
|
updateConfig(updates: Partial<BeaconConfig>): void;
|
|
444
449
|
destroy(): Promise<void>;
|
|
445
450
|
}
|
|
451
|
+
export declare const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
452
|
+
export declare const POSTURE_TTL_SECONDS = 120;
|
|
446
453
|
//#endregion
|
|
447
454
|
//# 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;
|
|
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;wBAiJI,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;;iBAGe;EAEf;EAOA,WAAW;EAaX;EAGA;E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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;;iBAOe;EACf;EACA,QAAQ;EACR;EACA;EACA;EAEA;EAEA;EAEA;;iBAGe;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;wBAgBxC,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;;qBAYA;qBAOA"}
|
|
@@ -9,6 +9,64 @@ function toRecord(input) {
|
|
|
9
9
|
function numberOr(value, fallback) {
|
|
10
10
|
return typeof value === "number" && Number.isFinite(value) && value !== 0 ? value : fallback;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Validates a numeric config value against `ok`, falling back to `fallback`
|
|
14
|
+
* when it fails. Only calls `onReject` when the caller actually supplied a
|
|
15
|
+
* value (an `undefined` field, the common case, is not a rejection, it just
|
|
16
|
+
* never overrode the default): H0BB5 (PR #5095 review, item 4) — a rejected
|
|
17
|
+
* value used to fall back silently, with no way for a host to discover a
|
|
18
|
+
* config typo.
|
|
19
|
+
*/
|
|
20
|
+
function boundedNumberOr(value, fallback, ok, onReject) {
|
|
21
|
+
if (typeof value === "number" && Number.isFinite(value) && ok(value)) return value;
|
|
22
|
+
if (value !== void 0) onReject?.(value);
|
|
23
|
+
return fallback;
|
|
24
|
+
}
|
|
25
|
+
/** Same as `boundedNumberOr`, but an absent/rejected value stays `undefined` rather than defaulting. */
|
|
26
|
+
function optionalPositiveNumber(value, onReject) {
|
|
27
|
+
if (value === void 0) return void 0;
|
|
28
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
29
|
+
onReject?.(value);
|
|
30
|
+
}
|
|
31
|
+
/** Same as `optionalPositiveNumber`, without the positivity requirement (a jitter seed may be any finite number). */
|
|
32
|
+
function optionalFiniteNumber(value, onReject) {
|
|
33
|
+
if (value === void 0) return void 0;
|
|
34
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
35
|
+
onReject?.(value);
|
|
36
|
+
}
|
|
37
|
+
/** Same shape as `boundedNumberOr`/`optionalPositiveNumber`, for a boolean config flag. */
|
|
38
|
+
function booleanOr(value, fallback, onReject) {
|
|
39
|
+
if (value === void 0) return fallback;
|
|
40
|
+
if (typeof value === "boolean") return value;
|
|
41
|
+
onReject?.(value);
|
|
42
|
+
return fallback;
|
|
43
|
+
}
|
|
44
|
+
const DISPATCH_TRIGGER_NAMES = [
|
|
45
|
+
"arrival",
|
|
46
|
+
"signals",
|
|
47
|
+
"interaction",
|
|
48
|
+
"untrusted",
|
|
49
|
+
"posture",
|
|
50
|
+
"unload"
|
|
51
|
+
];
|
|
52
|
+
/**
|
|
53
|
+
* Keeps only the known trigger names with a real boolean; anything else is
|
|
54
|
+
* dropped and, when the caller actually named a known trigger with a
|
|
55
|
+
* non-boolean value (`triggers: { posture: 0 }`, say), reported through
|
|
56
|
+
* `onReject` — H0BB5 (PR #5095 review, item 4): a numeric `0` used to be
|
|
57
|
+
* dropped silently and that trigger stayed at its default-enabled state,
|
|
58
|
+
* the opposite of what the "0 is falsy" convention suggests.
|
|
59
|
+
*/
|
|
60
|
+
function pickTriggers(value, onReject) {
|
|
61
|
+
if (!isRecord(value)) return void 0;
|
|
62
|
+
const picked = {};
|
|
63
|
+
for (const name of DISPATCH_TRIGGER_NAMES) {
|
|
64
|
+
const raw = value[name];
|
|
65
|
+
if (typeof raw === "boolean") picked[name] = raw;
|
|
66
|
+
else if (raw !== void 0) onReject?.(name, raw);
|
|
67
|
+
}
|
|
68
|
+
return picked;
|
|
69
|
+
}
|
|
12
70
|
function stringOr(value, fallback) {
|
|
13
71
|
return typeof value === "string" ? value : fallback;
|
|
14
72
|
}
|
|
@@ -203,7 +261,14 @@ function parseWorkerCapabilities(input) {
|
|
|
203
261
|
}
|
|
204
262
|
};
|
|
205
263
|
}
|
|
206
|
-
|
|
264
|
+
/**
|
|
265
|
+
* @param onWarn Called once per rejected config value (a supplied value that
|
|
266
|
+
* failed validation and fell back to its default), for a caller that wants
|
|
267
|
+
* to surface it — `BeaconConfigManager.validateAndMergeConfig` wires this to
|
|
268
|
+
* `log('warn', ...)`. Never called for an omitted field; only for one the
|
|
269
|
+
* caller actually set to something invalid.
|
|
270
|
+
*/
|
|
271
|
+
function parseBeaconConfig(input, onWarn) {
|
|
207
272
|
const config = toRecord(input);
|
|
208
273
|
if (typeof config.projectId !== "string" || config.projectId.length === 0) throw new Error("Project ID is required");
|
|
209
274
|
return {
|
|
@@ -222,9 +287,12 @@ function parseBeaconConfig(input) {
|
|
|
222
287
|
dropQueryParams: config.dropQueryParams === true,
|
|
223
288
|
sessionTimeout: numberOr(config.sessionTimeout, 18e5),
|
|
224
289
|
sessionCookieName: stringOr(config.sessionCookieName, "_as_beacon_session"),
|
|
225
|
-
batchSize:
|
|
226
|
-
flushInterval:
|
|
290
|
+
batchSize: typeof config.batchSize === "number" ? config.batchSize : void 0,
|
|
291
|
+
flushInterval: typeof config.flushInterval === "number" ? config.flushInterval : void 0,
|
|
227
292
|
collectorDeadlineMs: numberOr(config.collectorDeadlineMs, 1600),
|
|
293
|
+
evidenceGrowthFactor: boundedNumberOr(config.evidenceGrowthFactor, 2, (n) => n > 1, (received) => onWarn?.(`evidenceGrowthFactor must be a number greater than 1 (received ${JSON.stringify(received)}); using default 2`)),
|
|
294
|
+
postureRefreshFraction: boundedNumberOr(config.postureRefreshFraction, .5, (n) => n > 0 && n <= 1, (received) => onWarn?.(`postureRefreshFraction must be a number in (0, 1] (received ${JSON.stringify(received)}); using default 0.5`)),
|
|
295
|
+
triggers: pickTriggers(config.triggers, (name, received) => onWarn?.(`triggers.${name} must be a boolean (received ${JSON.stringify(received)}); ignoring it and keeping its default`)),
|
|
228
296
|
maxQueueSize: numberOr(config.maxQueueSize, 100),
|
|
229
297
|
retryAttempts: numberOr(config.retryAttempts, 3),
|
|
230
298
|
retryDelay: numberOr(config.retryDelay, 2e3),
|
|
@@ -232,11 +300,31 @@ function parseBeaconConfig(input) {
|
|
|
232
300
|
useWorker: resolveUseWorker(config),
|
|
233
301
|
workerUrl: stringOr(config.workerUrl),
|
|
234
302
|
workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0,
|
|
235
|
-
lazySignalsUrl: stringOr(config.lazySignalsUrl)
|
|
303
|
+
lazySignalsUrl: stringOr(config.lazySignalsUrl),
|
|
304
|
+
proactiveRefreshMinIntervalMs: boundedNumberOr(config.proactiveRefreshMinIntervalMs, 3e4, (n) => n > 0, (received) => onWarn?.(`proactiveRefreshMinIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 30000`)),
|
|
305
|
+
proactiveRefreshMaxIntervalMs: boundedNumberOr(config.proactiveRefreshMaxIntervalMs, 6e4, (n) => n > 0, (received) => onWarn?.(`proactiveRefreshMaxIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 60000`)),
|
|
306
|
+
proactiveRefreshFreshnessMs: optionalPositiveNumber(config.proactiveRefreshFreshnessMs, (received) => onWarn?.(`proactiveRefreshFreshnessMs must be a positive number (received ${JSON.stringify(received)}); ignoring it and inheriting postureRefreshFraction's threshold`)),
|
|
307
|
+
proactiveRefreshOnVisibilityResume: booleanOr(config.proactiveRefreshOnVisibilityResume, true, (received) => onWarn?.(`proactiveRefreshOnVisibilityResume must be a boolean (received ${JSON.stringify(received)}); using default true`)),
|
|
308
|
+
proactiveRefreshOnOnline: booleanOr(config.proactiveRefreshOnOnline, true, (received) => onWarn?.(`proactiveRefreshOnOnline must be a boolean (received ${JSON.stringify(received)}); using default true`)),
|
|
309
|
+
proactiveRefreshJitterSeed: optionalFiniteNumber(config.proactiveRefreshJitterSeed, (received) => onWarn?.(`proactiveRefreshJitterSeed must be a finite number (received ${JSON.stringify(received)}); ignoring it, jitter will use Math.random()`))
|
|
236
310
|
};
|
|
237
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* The most events one beacon POST may carry. The ingest route's
|
|
314
|
+
* `BeaconBatchSchema` refuses a larger batch whole (a 400, not a retry), so
|
|
315
|
+
* the SDK's offline drain never dequeues more than this per request.
|
|
316
|
+
*/
|
|
317
|
+
const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
318
|
+
/**
|
|
319
|
+
* Lifetime of the signed browser posture token, in seconds. Defined here and
|
|
320
|
+
* re-exported by `browser-posture.ts` (which imports `jose`) so the
|
|
321
|
+
* size-budgeted beacon bundle can read it without pulling in a JWT library.
|
|
322
|
+
*/
|
|
323
|
+
const POSTURE_TTL_SECONDS = 120;
|
|
238
324
|
|
|
239
325
|
//#endregion
|
|
326
|
+
exports.BEACON_MAX_EVENTS_PER_BATCH = BEACON_MAX_EVENTS_PER_BATCH;
|
|
327
|
+
exports.POSTURE_TTL_SECONDS = POSTURE_TTL_SECONDS;
|
|
240
328
|
exports.ResourceUsageSchema = ResourceUsageSchema;
|
|
241
329
|
exports.WorkerPoolConfigSchema = WorkerPoolConfigSchema;
|
|
242
330
|
exports.isBeaconIdentity = isBeaconIdentity;
|
|
@@ -8,6 +8,64 @@ function toRecord(input) {
|
|
|
8
8
|
function numberOr(value, fallback) {
|
|
9
9
|
return typeof value === "number" && Number.isFinite(value) && value !== 0 ? value : fallback;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Validates a numeric config value against `ok`, falling back to `fallback`
|
|
13
|
+
* when it fails. Only calls `onReject` when the caller actually supplied a
|
|
14
|
+
* value (an `undefined` field, the common case, is not a rejection, it just
|
|
15
|
+
* never overrode the default): H0BB5 (PR #5095 review, item 4) — a rejected
|
|
16
|
+
* value used to fall back silently, with no way for a host to discover a
|
|
17
|
+
* config typo.
|
|
18
|
+
*/
|
|
19
|
+
function boundedNumberOr(value, fallback, ok, onReject) {
|
|
20
|
+
if (typeof value === "number" && Number.isFinite(value) && ok(value)) return value;
|
|
21
|
+
if (value !== void 0) onReject?.(value);
|
|
22
|
+
return fallback;
|
|
23
|
+
}
|
|
24
|
+
/** Same as `boundedNumberOr`, but an absent/rejected value stays `undefined` rather than defaulting. */
|
|
25
|
+
function optionalPositiveNumber(value, onReject) {
|
|
26
|
+
if (value === void 0) return void 0;
|
|
27
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
|
|
28
|
+
onReject?.(value);
|
|
29
|
+
}
|
|
30
|
+
/** Same as `optionalPositiveNumber`, without the positivity requirement (a jitter seed may be any finite number). */
|
|
31
|
+
function optionalFiniteNumber(value, onReject) {
|
|
32
|
+
if (value === void 0) return void 0;
|
|
33
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
34
|
+
onReject?.(value);
|
|
35
|
+
}
|
|
36
|
+
/** Same shape as `boundedNumberOr`/`optionalPositiveNumber`, for a boolean config flag. */
|
|
37
|
+
function booleanOr(value, fallback, onReject) {
|
|
38
|
+
if (value === void 0) return fallback;
|
|
39
|
+
if (typeof value === "boolean") return value;
|
|
40
|
+
onReject?.(value);
|
|
41
|
+
return fallback;
|
|
42
|
+
}
|
|
43
|
+
const DISPATCH_TRIGGER_NAMES = [
|
|
44
|
+
"arrival",
|
|
45
|
+
"signals",
|
|
46
|
+
"interaction",
|
|
47
|
+
"untrusted",
|
|
48
|
+
"posture",
|
|
49
|
+
"unload"
|
|
50
|
+
];
|
|
51
|
+
/**
|
|
52
|
+
* Keeps only the known trigger names with a real boolean; anything else is
|
|
53
|
+
* dropped and, when the caller actually named a known trigger with a
|
|
54
|
+
* non-boolean value (`triggers: { posture: 0 }`, say), reported through
|
|
55
|
+
* `onReject` — H0BB5 (PR #5095 review, item 4): a numeric `0` used to be
|
|
56
|
+
* dropped silently and that trigger stayed at its default-enabled state,
|
|
57
|
+
* the opposite of what the "0 is falsy" convention suggests.
|
|
58
|
+
*/
|
|
59
|
+
function pickTriggers(value, onReject) {
|
|
60
|
+
if (!isRecord(value)) return void 0;
|
|
61
|
+
const picked = {};
|
|
62
|
+
for (const name of DISPATCH_TRIGGER_NAMES) {
|
|
63
|
+
const raw = value[name];
|
|
64
|
+
if (typeof raw === "boolean") picked[name] = raw;
|
|
65
|
+
else if (raw !== void 0) onReject?.(name, raw);
|
|
66
|
+
}
|
|
67
|
+
return picked;
|
|
68
|
+
}
|
|
11
69
|
function stringOr(value, fallback) {
|
|
12
70
|
return typeof value === "string" ? value : fallback;
|
|
13
71
|
}
|
|
@@ -202,7 +260,14 @@ function parseWorkerCapabilities(input) {
|
|
|
202
260
|
}
|
|
203
261
|
};
|
|
204
262
|
}
|
|
205
|
-
|
|
263
|
+
/**
|
|
264
|
+
* @param onWarn Called once per rejected config value (a supplied value that
|
|
265
|
+
* failed validation and fell back to its default), for a caller that wants
|
|
266
|
+
* to surface it — `BeaconConfigManager.validateAndMergeConfig` wires this to
|
|
267
|
+
* `log('warn', ...)`. Never called for an omitted field; only for one the
|
|
268
|
+
* caller actually set to something invalid.
|
|
269
|
+
*/
|
|
270
|
+
function parseBeaconConfig(input, onWarn) {
|
|
206
271
|
const config = toRecord(input);
|
|
207
272
|
if (typeof config.projectId !== "string" || config.projectId.length === 0) throw new Error("Project ID is required");
|
|
208
273
|
return {
|
|
@@ -221,9 +286,12 @@ function parseBeaconConfig(input) {
|
|
|
221
286
|
dropQueryParams: config.dropQueryParams === true,
|
|
222
287
|
sessionTimeout: numberOr(config.sessionTimeout, 18e5),
|
|
223
288
|
sessionCookieName: stringOr(config.sessionCookieName, "_as_beacon_session"),
|
|
224
|
-
batchSize:
|
|
225
|
-
flushInterval:
|
|
289
|
+
batchSize: typeof config.batchSize === "number" ? config.batchSize : void 0,
|
|
290
|
+
flushInterval: typeof config.flushInterval === "number" ? config.flushInterval : void 0,
|
|
226
291
|
collectorDeadlineMs: numberOr(config.collectorDeadlineMs, 1600),
|
|
292
|
+
evidenceGrowthFactor: boundedNumberOr(config.evidenceGrowthFactor, 2, (n) => n > 1, (received) => onWarn?.(`evidenceGrowthFactor must be a number greater than 1 (received ${JSON.stringify(received)}); using default 2`)),
|
|
293
|
+
postureRefreshFraction: boundedNumberOr(config.postureRefreshFraction, .5, (n) => n > 0 && n <= 1, (received) => onWarn?.(`postureRefreshFraction must be a number in (0, 1] (received ${JSON.stringify(received)}); using default 0.5`)),
|
|
294
|
+
triggers: pickTriggers(config.triggers, (name, received) => onWarn?.(`triggers.${name} must be a boolean (received ${JSON.stringify(received)}); ignoring it and keeping its default`)),
|
|
227
295
|
maxQueueSize: numberOr(config.maxQueueSize, 100),
|
|
228
296
|
retryAttempts: numberOr(config.retryAttempts, 3),
|
|
229
297
|
retryDelay: numberOr(config.retryDelay, 2e3),
|
|
@@ -231,10 +299,28 @@ function parseBeaconConfig(input) {
|
|
|
231
299
|
useWorker: resolveUseWorker(config),
|
|
232
300
|
workerUrl: stringOr(config.workerUrl),
|
|
233
301
|
workerConfig: isRecord(config.workerConfig) ? config.workerConfig : void 0,
|
|
234
|
-
lazySignalsUrl: stringOr(config.lazySignalsUrl)
|
|
302
|
+
lazySignalsUrl: stringOr(config.lazySignalsUrl),
|
|
303
|
+
proactiveRefreshMinIntervalMs: boundedNumberOr(config.proactiveRefreshMinIntervalMs, 3e4, (n) => n > 0, (received) => onWarn?.(`proactiveRefreshMinIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 30000`)),
|
|
304
|
+
proactiveRefreshMaxIntervalMs: boundedNumberOr(config.proactiveRefreshMaxIntervalMs, 6e4, (n) => n > 0, (received) => onWarn?.(`proactiveRefreshMaxIntervalMs must be a positive number (received ${JSON.stringify(received)}); using default 60000`)),
|
|
305
|
+
proactiveRefreshFreshnessMs: optionalPositiveNumber(config.proactiveRefreshFreshnessMs, (received) => onWarn?.(`proactiveRefreshFreshnessMs must be a positive number (received ${JSON.stringify(received)}); ignoring it and inheriting postureRefreshFraction's threshold`)),
|
|
306
|
+
proactiveRefreshOnVisibilityResume: booleanOr(config.proactiveRefreshOnVisibilityResume, true, (received) => onWarn?.(`proactiveRefreshOnVisibilityResume must be a boolean (received ${JSON.stringify(received)}); using default true`)),
|
|
307
|
+
proactiveRefreshOnOnline: booleanOr(config.proactiveRefreshOnOnline, true, (received) => onWarn?.(`proactiveRefreshOnOnline must be a boolean (received ${JSON.stringify(received)}); using default true`)),
|
|
308
|
+
proactiveRefreshJitterSeed: optionalFiniteNumber(config.proactiveRefreshJitterSeed, (received) => onWarn?.(`proactiveRefreshJitterSeed must be a finite number (received ${JSON.stringify(received)}); ignoring it, jitter will use Math.random()`))
|
|
235
309
|
};
|
|
236
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* The most events one beacon POST may carry. The ingest route's
|
|
313
|
+
* `BeaconBatchSchema` refuses a larger batch whole (a 400, not a retry), so
|
|
314
|
+
* the SDK's offline drain never dequeues more than this per request.
|
|
315
|
+
*/
|
|
316
|
+
const BEACON_MAX_EVENTS_PER_BATCH = 100;
|
|
317
|
+
/**
|
|
318
|
+
* Lifetime of the signed browser posture token, in seconds. Defined here and
|
|
319
|
+
* re-exported by `browser-posture.ts` (which imports `jose`) so the
|
|
320
|
+
* size-budgeted beacon bundle can read it without pulling in a JWT library.
|
|
321
|
+
*/
|
|
322
|
+
const POSTURE_TTL_SECONDS = 120;
|
|
237
323
|
|
|
238
324
|
//#endregion
|
|
239
|
-
export { ResourceUsageSchema, WorkerPoolConfigSchema, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
|
|
325
|
+
export { BEACON_MAX_EVENTS_PER_BATCH, POSTURE_TTL_SECONDS, ResourceUsageSchema, WorkerPoolConfigSchema, isBeaconIdentity, parseBeaconConfig, parseBeaconWorkerMessage, parseCircuitBreakerConfig, parseOfflineQueueEntry, parseResourceUsage, parseRetryStrategy, parseWorkerCapabilities, parseWorkerError, parseWorkerMessage, parseWorkerPoolConfig };
|
|
240
326
|
//# sourceMappingURL=index.mjs.map
|