@zerogpu/browser-extension-sdk 0.2.1 → 0.2.2
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/README.md +31 -6
- package/dist/assets/zerogpu-assets.json +2 -2
- package/dist/extension/zerogpu-offscreen.js +373 -229
- package/dist/extension/zerogpu-offscreen.js.map +1 -1
- package/dist/manifest.json +5 -5
- package/dist/types/config/types.d.ts +6 -1
- package/dist/types/device/types.d.ts +0 -12
- package/dist/types/runtime/host-api.d.ts +1 -2
- package/dist/types/runtime/tracking-script.d.ts +9 -5
- package/dist/types/transport/websocket.d.ts +0 -1
- package/dist/types/utils/logger.d.ts +44 -5
- package/dist/v/{zerogpu-browser-sdk.b4f27a5bea4f.umd.js → zerogpu-browser-sdk.1d7d5ce752ee.umd.js} +377 -231
- package/dist/v/zerogpu-browser-sdk.1d7d5ce752ee.umd.js.map +1 -0
- package/dist/zerogpu-browser-sdk.cjs +376 -230
- package/dist/zerogpu-browser-sdk.cjs.map +1 -1
- package/dist/zerogpu-browser-sdk.esm.js +376 -230
- package/dist/zerogpu-browser-sdk.esm.js.map +1 -1
- package/dist/zerogpu-browser-sdk.umd.js +376 -230
- package/dist/zerogpu-browser-sdk.umd.js.map +1 -1
- package/package.json +3 -2
- package/dist/v/zerogpu-browser-sdk.b4f27a5bea4f.umd.js.map +0 -1
package/dist/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.2+0a17606",
|
|
3
3
|
"channel": "official",
|
|
4
|
-
"buildId": "
|
|
5
|
-
"coreBundleUrl": "v/zerogpu-browser-sdk.
|
|
6
|
-
"integrity": "sha384-
|
|
7
|
-
"builtAt": "2026-08-
|
|
4
|
+
"buildId": "1d7d5ce752ee",
|
|
5
|
+
"coreBundleUrl": "v/zerogpu-browser-sdk.1d7d5ce752ee.umd.js",
|
|
6
|
+
"integrity": "sha384-r6E47LUMQlP8cLyatfSeKpN6VL5iWQW0ZHoR/HFBmUSDUjzy0i48KJ4b05Elw73F",
|
|
7
|
+
"builtAt": "2026-08-19T11:39:56.086Z"
|
|
8
8
|
}
|
|
@@ -58,7 +58,12 @@ export interface OrchestratorConfig {
|
|
|
58
58
|
export interface TelemetryConfig {
|
|
59
59
|
enableConsoleLogs: boolean;
|
|
60
60
|
locationData: boolean;
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @deprecated The camera-capture path was removed from the SDK (ZGA-538).
|
|
63
|
+
* The flag is accepted for backwards type-compatibility and ignored; no
|
|
64
|
+
* camera code exists in the bundle.
|
|
65
|
+
*/
|
|
66
|
+
cameraData?: boolean;
|
|
62
67
|
events: boolean;
|
|
63
68
|
}
|
|
64
69
|
export interface SdkConfig {
|
|
@@ -17,17 +17,6 @@ export interface LocationInfo {
|
|
|
17
17
|
lon: number;
|
|
18
18
|
accuracy: number;
|
|
19
19
|
}
|
|
20
|
-
export interface CameraSampleInfo {
|
|
21
|
-
permission: 'granted' | 'denied' | 'error';
|
|
22
|
-
facingMode?: string;
|
|
23
|
-
width?: number;
|
|
24
|
-
height?: number;
|
|
25
|
-
bytes?: number;
|
|
26
|
-
mime?: string;
|
|
27
|
-
timestamp?: number;
|
|
28
|
-
error?: string;
|
|
29
|
-
previewDataUrl?: string;
|
|
30
|
-
}
|
|
31
20
|
export interface DeviceInfo {
|
|
32
21
|
appUserId?: string;
|
|
33
22
|
appUsername?: string;
|
|
@@ -54,5 +43,4 @@ export interface DeviceInfo {
|
|
|
54
43
|
pageUrl?: string;
|
|
55
44
|
referrer?: string;
|
|
56
45
|
location?: LocationInfo;
|
|
57
|
-
camera?: CameraSampleInfo;
|
|
58
46
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Host-facing lifecycle status and events. The SDK is a guest in someone
|
|
3
3
|
* else's app: this module is how the host observes guardrail state (degraded /
|
|
4
4
|
* recovered / shutdown) without the SDK ever throwing into it. Script-tag
|
|
5
|
-
* consumers get the same signals as `zerogpu:*` window events
|
|
6
|
-
* existing `zerogpu:cameraPreview` pattern.
|
|
5
|
+
* consumers get the same signals as `zerogpu:*` window events.
|
|
7
6
|
*/
|
|
8
7
|
export type SdkLifecycleStatus = 'starting' | 'running' | 'degraded' | 'shutdown' | 'error';
|
|
9
8
|
export type HostEventName = 'degraded' | 'recovered' | 'shutdown';
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Progressive:
|
|
16
16
|
* 1. If a runner URL is configured, run the tag in the framed runner.
|
|
17
|
-
* 2. Otherwise
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* 2. Otherwise, on an ordinary web page or WebView (including a Telegram Mini
|
|
18
|
+
* App) with no restrictive `script-src` CSP, inject a real `<script>`
|
|
19
|
+
* element so the tag executes directly in the page.
|
|
20
|
+
* 3. Failing both (no DOM, or a CSP that blocks the injected script), fall back
|
|
21
|
+
* to a credentialed request beacon so the impression at least reaches the ad
|
|
22
|
+
* server with the user's real IP/UA/cookies (the tag's JS does not run).
|
|
20
23
|
*
|
|
21
24
|
* Never rejects: a tag is best-effort and must not affect inference.
|
|
22
25
|
*/
|
|
@@ -27,7 +30,8 @@ import { TrackingPixelOutcome } from './tracking-pixel';
|
|
|
27
30
|
*/
|
|
28
31
|
export declare const setTrackingScriptRunnerUrl: (url: string | null | undefined) => void;
|
|
29
32
|
/**
|
|
30
|
-
* Fire a JavaScript tracking tag.
|
|
31
|
-
*
|
|
33
|
+
* Fire a JavaScript tracking tag. Executes it wherever it can — the framed
|
|
34
|
+
* runner, or an injected `<script>` on a normal page/WebView — and only falls
|
|
35
|
+
* back to a non-executing beacon when neither can run it. Never rejects.
|
|
32
36
|
*/
|
|
33
37
|
export declare const fireTrackingScript: (url: string, timeoutMs?: number) => Promise<TrackingPixelOutcome>;
|
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
import { TelemetryConfig } from '../config/types';
|
|
2
2
|
export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
3
|
+
/**
|
|
4
|
+
* Redaction-safe logging (ZGA-538).
|
|
5
|
+
*
|
|
6
|
+
* The SDK runs inside someone else's app, and with console logs enabled the
|
|
7
|
+
* host's crash/session-replay tooling may collect whatever we print. So the
|
|
8
|
+
* logger's contract is: *what happened, ids, sizes, timings — never content.*
|
|
9
|
+
* Every field passes through `sanitizeLogFields` before it reaches the
|
|
10
|
+
* console; there is no code path that prints a value verbatim:
|
|
11
|
+
*
|
|
12
|
+
* - numbers / booleans / null / undefined pass through (counts, byte lengths,
|
|
13
|
+
* durations, flags);
|
|
14
|
+
* - strings pass through only under an allowlisted identifier/enum key
|
|
15
|
+
* (requestId, modelId, code, reason, …), capped in length;
|
|
16
|
+
* - URL-shaped keys are stripped to origin + path — query strings carry
|
|
17
|
+
* session credentials on our WS URLs;
|
|
18
|
+
* - keys that look like credentials (sessionKey, token, operator key, …) are
|
|
19
|
+
* always `[redacted]`, whatever the value;
|
|
20
|
+
* - error/message keys keep a capped error summary (diagnostics, not payload);
|
|
21
|
+
* - any other string is replaced by `[string:<length>]`, and objects/arrays of
|
|
22
|
+
* objects collapse to a shape summary — full frames, payloads and model
|
|
23
|
+
* output are unprintable by construction.
|
|
24
|
+
*
|
|
25
|
+
* This module is the single allowed `console.*` sink in the SDK runtime (the
|
|
26
|
+
* self-contained loader stub and the offscreen console-silencer are the two
|
|
27
|
+
* audited exceptions) — enforced by the `no-console` lint rule and
|
|
28
|
+
* `scripts/check-safe-logging.mjs`.
|
|
29
|
+
*/
|
|
30
|
+
type SafePrimitive = string | number | boolean | null | undefined;
|
|
31
|
+
export type SafeFieldValue = SafePrimitive | Error | ReadonlyArray<SafePrimitive>;
|
|
32
|
+
export type SafeFields = Record<string, SafeFieldValue>;
|
|
33
|
+
/** One-line, capped error summary — diagnostics survive, payloads cannot ride along uncapped. */
|
|
34
|
+
export declare const summarizeError: (error: unknown) => string;
|
|
35
|
+
/**
|
|
36
|
+
* The runtime redaction gate. Whatever a caller manages to pass (the types
|
|
37
|
+
* merely guide), nothing but ids, enums, counts, sizes, durations and capped
|
|
38
|
+
* error summaries comes out the other side.
|
|
39
|
+
*/
|
|
40
|
+
export declare const sanitizeLogFields: (fields: unknown) => Record<string, unknown>;
|
|
3
41
|
declare class Logger {
|
|
4
42
|
private enabled;
|
|
5
43
|
constructor(config: TelemetryConfig);
|
|
6
44
|
setEnabled(enabled: boolean): void;
|
|
7
45
|
isEnabled(): boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
46
|
+
private emit;
|
|
47
|
+
debug(message: string, fields?: SafeFields | Error): void;
|
|
48
|
+
info(message: string, fields?: SafeFields | Error): void;
|
|
49
|
+
warn(message: string, fields?: SafeFields | Error): void;
|
|
50
|
+
error(message: string, fields?: SafeFields | Error): void;
|
|
12
51
|
}
|
|
52
|
+
export type { Logger };
|
|
13
53
|
export declare const initLogger: (config: TelemetryConfig) => Logger;
|
|
14
54
|
export declare const getLogger: () => Logger;
|
|
15
|
-
export {};
|