@disclos/sdk-web 0.1.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.
Files changed (84) hide show
  1. package/dist/batch-GICDMFCN.mjs +63 -0
  2. package/dist/batch-GICDMFCN.mjs.map +1 -0
  3. package/dist/batch-UBSRBBS5.cjs +65 -0
  4. package/dist/batch-UBSRBBS5.cjs.map +1 -0
  5. package/dist/cdn/sdk.min.global.js +122 -0
  6. package/dist/chatbot-banner-DGXTYL6P.cjs +15 -0
  7. package/dist/chatbot-banner-DGXTYL6P.cjs.map +1 -0
  8. package/dist/chatbot-banner-TN4LWAYQ.mjs +6 -0
  9. package/dist/chatbot-banner-TN4LWAYQ.mjs.map +1 -0
  10. package/dist/chunk-32Z4Q6ZD.cjs +68 -0
  11. package/dist/chunk-32Z4Q6ZD.cjs.map +1 -0
  12. package/dist/chunk-4JEHEDQP.mjs +56 -0
  13. package/dist/chunk-4JEHEDQP.mjs.map +1 -0
  14. package/dist/chunk-4KTDVK7J.cjs +53 -0
  15. package/dist/chunk-4KTDVK7J.cjs.map +1 -0
  16. package/dist/chunk-4QR2B5RG.cjs +46 -0
  17. package/dist/chunk-4QR2B5RG.cjs.map +1 -0
  18. package/dist/chunk-BHR3367P.mjs +48 -0
  19. package/dist/chunk-BHR3367P.mjs.map +1 -0
  20. package/dist/chunk-CZLDE2OZ.cjs +28 -0
  21. package/dist/chunk-CZLDE2OZ.cjs.map +1 -0
  22. package/dist/chunk-DG3Z3IAG.mjs +57 -0
  23. package/dist/chunk-DG3Z3IAG.mjs.map +1 -0
  24. package/dist/chunk-ESP33I43.mjs +67 -0
  25. package/dist/chunk-ESP33I43.mjs.map +1 -0
  26. package/dist/chunk-GFU3F3ZX.mjs +66 -0
  27. package/dist/chunk-GFU3F3ZX.mjs.map +1 -0
  28. package/dist/chunk-GYNG67I6.cjs +64 -0
  29. package/dist/chunk-GYNG67I6.cjs.map +1 -0
  30. package/dist/chunk-H724IVG6.cjs +119 -0
  31. package/dist/chunk-H724IVG6.cjs.map +1 -0
  32. package/dist/chunk-I7K3XSEO.cjs +71 -0
  33. package/dist/chunk-I7K3XSEO.cjs.map +1 -0
  34. package/dist/chunk-LNXULTZ5.mjs +62 -0
  35. package/dist/chunk-LNXULTZ5.mjs.map +1 -0
  36. package/dist/chunk-NFEGQTCC.mjs +24 -0
  37. package/dist/chunk-NFEGQTCC.mjs.map +1 -0
  38. package/dist/chunk-PZM26IE6.mjs +44 -0
  39. package/dist/chunk-PZM26IE6.mjs.map +1 -0
  40. package/dist/chunk-Q3245KZ2.cjs +58 -0
  41. package/dist/chunk-Q3245KZ2.cjs.map +1 -0
  42. package/dist/chunk-QOGWEWJP.cjs +62 -0
  43. package/dist/chunk-QOGWEWJP.cjs.map +1 -0
  44. package/dist/chunk-TTJMXFXE.cjs +186 -0
  45. package/dist/chunk-TTJMXFXE.cjs.map +1 -0
  46. package/dist/chunk-UU6VG7CJ.mjs +117 -0
  47. package/dist/chunk-UU6VG7CJ.mjs.map +1 -0
  48. package/dist/chunk-YJEYWPLR.mjs +182 -0
  49. package/dist/chunk-YJEYWPLR.mjs.map +1 -0
  50. package/dist/content-label-ITJPDODX.mjs +6 -0
  51. package/dist/content-label-ITJPDODX.mjs.map +1 -0
  52. package/dist/content-label-JFRT3OGU.cjs +15 -0
  53. package/dist/content-label-JFRT3OGU.cjs.map +1 -0
  54. package/dist/deepfake-marker-5FNO7W5J.cjs +15 -0
  55. package/dist/deepfake-marker-5FNO7W5J.cjs.map +1 -0
  56. package/dist/deepfake-marker-ILF66NVN.mjs +6 -0
  57. package/dist/deepfake-marker-ILF66NVN.mjs.map +1 -0
  58. package/dist/index.cjs +51 -0
  59. package/dist/index.cjs.map +1 -0
  60. package/dist/index.d.cts +157 -0
  61. package/dist/index.d.ts +157 -0
  62. package/dist/index.mjs +10 -0
  63. package/dist/index.mjs.map +1 -0
  64. package/dist/logger-IEU35PCN.cjs +14 -0
  65. package/dist/logger-IEU35PCN.cjs.map +1 -0
  66. package/dist/logger-X67CWRL4.mjs +5 -0
  67. package/dist/logger-X67CWRL4.mjs.map +1 -0
  68. package/dist/queue-CHODSJ4I.mjs +4 -0
  69. package/dist/queue-CHODSJ4I.mjs.map +1 -0
  70. package/dist/queue-LF4IPDT3.cjs +25 -0
  71. package/dist/queue-LF4IPDT3.cjs.map +1 -0
  72. package/dist/register-BA3KW4AJ.cjs +15 -0
  73. package/dist/register-BA3KW4AJ.cjs.map +1 -0
  74. package/dist/register-BBBSBMAF.mjs +13 -0
  75. package/dist/register-BBBSBMAF.mjs.map +1 -0
  76. package/dist/sender-EXBUUDTU.cjs +15 -0
  77. package/dist/sender-EXBUUDTU.cjs.map +1 -0
  78. package/dist/sender-RUX2MZKR.mjs +6 -0
  79. package/dist/sender-RUX2MZKR.mjs.map +1 -0
  80. package/dist/trust-page-HALUJVZU.cjs +15 -0
  81. package/dist/trust-page-HALUJVZU.cjs.map +1 -0
  82. package/dist/trust-page-NLFTM3WT.mjs +6 -0
  83. package/dist/trust-page-NLFTM3WT.mjs.map +1 -0
  84. package/package.json +60 -0
@@ -0,0 +1,182 @@
1
+ import { init_state, state_exports, getState, setState } from './chunk-BHR3367P.mjs';
2
+ import { __toCommonJS } from './chunk-NFEGQTCC.mjs';
3
+
4
+ // src/core/config.ts
5
+ var DEFAULT_CDN = "https://cdn.disclos.dev/v1/config";
6
+ var CACHE_KEY_PREFIX = "disclos_cfg_";
7
+ var FETCH_TIMEOUT_MS = 3e3;
8
+ var DEFAULT_CONFIG = {
9
+ version: 1,
10
+ locale: "en",
11
+ ingestionEndpoint: "https://ingest.disclos.dev",
12
+ samplingRate: 1,
13
+ disclosures: {
14
+ chatbot: "You are interacting with an AI system.",
15
+ contentLabel: {
16
+ text: "AI-generated text",
17
+ image: "AI-generated image",
18
+ audio: "AI-generated audio",
19
+ video: "AI-generated video"
20
+ },
21
+ deepfake: "This content has been artificially generated or manipulated using AI."
22
+ },
23
+ features: { contentLabeling: true, trustPage: false },
24
+ ttl: 36e5
25
+ // 1 hour
26
+ };
27
+ function cacheKey(apiKey) {
28
+ return CACHE_KEY_PREFIX + apiKey.slice(-8);
29
+ }
30
+ function saveToCacheStorage(apiKey, config) {
31
+ try {
32
+ localStorage.setItem(
33
+ cacheKey(apiKey),
34
+ JSON.stringify({ ...config, cachedAt: Date.now() })
35
+ );
36
+ } catch {
37
+ }
38
+ }
39
+ function loadFromCacheStorage(apiKey) {
40
+ try {
41
+ const raw = localStorage.getItem(cacheKey(apiKey));
42
+ if (!raw) return null;
43
+ return JSON.parse(raw);
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+ function isFresh(config) {
49
+ if (!config.cachedAt) return false;
50
+ return Date.now() - config.cachedAt < config.ttl;
51
+ }
52
+ async function fetchConfig(apiKey, locale, endpointOverride) {
53
+ const cached = loadFromCacheStorage(apiKey);
54
+ if (cached && isFresh(cached)) return cached;
55
+ const endpoint = endpointOverride ?? DEFAULT_CDN;
56
+ try {
57
+ const url = new URL(endpoint);
58
+ url.searchParams.set("key", apiKey);
59
+ url.searchParams.set("locale", locale);
60
+ const res = await fetch(url.toString(), {
61
+ headers: { Accept: "application/json" },
62
+ signal: AbortSignal.timeout(FETCH_TIMEOUT_MS)
63
+ });
64
+ if (res.ok) {
65
+ const data = await res.json();
66
+ data.cachedAt = Date.now();
67
+ saveToCacheStorage(apiKey, data);
68
+ return data;
69
+ }
70
+ } catch {
71
+ }
72
+ if (cached) return cached;
73
+ return { ...DEFAULT_CONFIG, locale };
74
+ }
75
+ function getConfig() {
76
+ try {
77
+ const { getState: getState2 } = (init_state(), __toCommonJS(state_exports));
78
+ return getState2().config;
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+
84
+ // src/components/base.ts
85
+ init_state();
86
+
87
+ // src/core/init.ts
88
+ init_state();
89
+ var CONFIG_LOADED_EVENT = "disclos:config-loaded";
90
+ async function init(options) {
91
+ const state = getState();
92
+ if (state.initialized) {
93
+ if (state.debug) console.warn("[Disclos] Already initialized \u2014 ignoring duplicate init()");
94
+ return;
95
+ }
96
+ if (!options.apiKey) throw new Error("[Disclos] apiKey is required");
97
+ if (!options.aiSystemId) throw new Error("[Disclos] aiSystemId is required");
98
+ const [{ EventBatcher }, { drainQueue }, { registerElements }] = await Promise.all([
99
+ import('./batch-GICDMFCN.mjs'),
100
+ import('./queue-CHODSJ4I.mjs'),
101
+ import('./register-BBBSBMAF.mjs')
102
+ ]);
103
+ setState({
104
+ initialized: true,
105
+ apiKey: options.apiKey,
106
+ aiSystemId: options.aiSystemId,
107
+ locale: options.locale ?? "en",
108
+ debug: options.debug ?? false,
109
+ logContent: options.logContent ?? false,
110
+ options,
111
+ batcher: new EventBatcher(options)
112
+ });
113
+ registerElements();
114
+ void fetchConfig(options.apiKey, options.locale ?? "en", options.configEndpoint).then((config) => {
115
+ setState({ config });
116
+ if (typeof window !== "undefined") {
117
+ window.dispatchEvent(new CustomEvent(CONFIG_LOADED_EVENT, { detail: config }));
118
+ }
119
+ if (options.debug) console.debug("[Disclos] Config loaded:", config);
120
+ }).catch((err) => {
121
+ if (options.debug) console.error("[Disclos] Config fetch error:", err);
122
+ });
123
+ void drainQueue().catch((err) => {
124
+ if (options.debug) console.warn("[Disclos] Queue drain error:", err);
125
+ });
126
+ }
127
+
128
+ // src/components/base.ts
129
+ var DisclosElement = class extends HTMLElement {
130
+ constructor() {
131
+ super(...arguments);
132
+ this._observer = null;
133
+ this._disclosed = false;
134
+ this._onConfigLoaded = () => this._update();
135
+ }
136
+ connectedCallback() {
137
+ if (!this.shadowRoot) this.attachShadow({ mode: "open" });
138
+ this._update();
139
+ this._trackVisibility();
140
+ window.addEventListener(CONFIG_LOADED_EVENT, this._onConfigLoaded);
141
+ }
142
+ disconnectedCallback() {
143
+ this._observer?.disconnect();
144
+ window.removeEventListener(CONFIG_LOADED_EVENT, this._onConfigLoaded);
145
+ }
146
+ attributeChangedCallback() {
147
+ if (this.shadowRoot) this._update();
148
+ }
149
+ /** Called once when the element becomes ≥50% visible in the viewport */
150
+ _onVisible() {
151
+ }
152
+ getConfig() {
153
+ return getState().config;
154
+ }
155
+ _update() {
156
+ if (!this.shadowRoot) return;
157
+ this.shadowRoot.innerHTML = this._html(this.getConfig());
158
+ }
159
+ _trackVisibility() {
160
+ if (typeof IntersectionObserver === "undefined") {
161
+ if (!this._disclosed) {
162
+ this._disclosed = true;
163
+ this._onVisible();
164
+ }
165
+ return;
166
+ }
167
+ this._observer = new IntersectionObserver(
168
+ ([entry]) => {
169
+ if (entry?.isIntersecting && !this._disclosed) {
170
+ this._disclosed = true;
171
+ this._onVisible();
172
+ }
173
+ },
174
+ { threshold: 0.5 }
175
+ );
176
+ this._observer.observe(this);
177
+ }
178
+ };
179
+
180
+ export { DisclosElement, getConfig, init };
181
+ //# sourceMappingURL=chunk-YJEYWPLR.mjs.map
182
+ //# sourceMappingURL=chunk-YJEYWPLR.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/config.ts","../src/components/base.ts","../src/core/init.ts"],"names":["getState"],"mappings":";;;;AAIA,IAAM,WAAA,GAAc,mCAAA;AACpB,IAAM,gBAAA,GAAmB,cAAA;AACzB,IAAM,gBAAA,GAAmB,GAAA;AAIlB,IAAM,cAAA,GAA+B;AAAA,EAC1C,OAAA,EAAS,CAAA;AAAA,EACT,MAAA,EAAQ,IAAA;AAAA,EACR,iBAAA,EAAmB,4BAAA;AAAA,EACnB,YAAA,EAAc,CAAA;AAAA,EACd,WAAA,EAAa;AAAA,IACX,OAAA,EAAS,wCAAA;AAAA,IACT,YAAA,EAAc;AAAA,MACZ,IAAA,EAAM,mBAAA;AAAA,MACN,KAAA,EAAO,oBAAA;AAAA,MACP,KAAA,EAAO,oBAAA;AAAA,MACP,KAAA,EAAO;AAAA,KACT;AAAA,IACA,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,QAAA,EAAU,EAAE,eAAA,EAAiB,IAAA,EAAM,WAAW,KAAA,EAAM;AAAA,EACpD,GAAA,EAAK;AAAA;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AE7B;AAAA,EAEU,SAAA,GAAiC;AACzC,IAAA,OAAO,UAAS,CAAE,MAAA;AAAA,EACpB;AAAA,EAEQ,OAAA,GAAgB;AACtB,IAAA,IAAI,CAAC,KAAK,UAAA,EAAY;AACtB,IAAA,IAAA,CAAK,WAAW,SAAA,GAAY,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,WAAW,CAAA;AAAA,EACzD;AAAA,EAEQ,gBAAA,GAAyB;AAC/B,IAAA,IAAI,OAAO,yBAAyB,WAAA,EAAa;AAE/C,MAAA,IAAI,CAAC,KAAK,UAAA,EAAY;AACpB,QAAA,IAAA,CAAK,UAAA,GAAa,IAAA;AAClB,QAAA,IAAA,CAAK,UAAA,EAAW;AAAA,MAClB;AACA,MAAA;AAAA,IACF;AAEA,IAAA,IAAA,CAAK,YAAY,IAAI,oBAAA;AAAA,MACnB,CAAC,CAAC,KAAK,CAAA,KAAM;AACX,QAAA,IAAI,KAAA,EAAO,cAAA,IAAkB,CAAC,IAAA,CAAK,UAAA,EAAY;AAC7C,UAAA,IAAA,CAAK,UAAA,GAAa,IAAA;AAClB,UAAA,IAAA,CAAK,UAAA,EAAW;AAAA,QAClB;AAAA,MACF,CAAA;AAAA,MACA,EAAE,WAAW,GAAA;AAAI,KACnB;AACA,IAAA,IAAA,CAAK,SAAA,CAAU,QAAQ,IAAI,CAAA;AAAA,EAC7B;AACF","file":"chunk-YJEYWPLR.mjs","sourcesContent":["// Remote config: fetch, cache, fallback chain.\n// Priority: remote CDN → localStorage (stale-ok) → bundled default\nimport type { RemoteConfig } from './types';\n\nconst DEFAULT_CDN = 'https://cdn.disclos.dev/v1/config';\nconst CACHE_KEY_PREFIX = 'disclos_cfg_';\nconst FETCH_TIMEOUT_MS = 3_000;\n\n// ── Bundled default (no network dependency) ───────────────────────────────────\n\nexport const DEFAULT_CONFIG: RemoteConfig = {\n version: 1,\n locale: 'en',\n ingestionEndpoint: 'https://ingest.disclos.dev',\n samplingRate: 1.0,\n disclosures: {\n chatbot: 'You are interacting with an AI system.',\n contentLabel: {\n text: 'AI-generated text',\n image: 'AI-generated image',\n audio: 'AI-generated audio',\n video: 'AI-generated video',\n },\n deepfake: 'This content has been artificially generated or manipulated using AI.',\n },\n features: { contentLabeling: true, trustPage: false },\n ttl: 3_600_000, // 1 hour\n};\n\n// ── localStorage helpers ──────────────────────────────────────────────────────\n\nfunction cacheKey(apiKey: string): string {\n return CACHE_KEY_PREFIX + apiKey.slice(-8);\n}\n\nfunction saveToCacheStorage(apiKey: string, config: RemoteConfig): void {\n try {\n localStorage.setItem(\n cacheKey(apiKey),\n JSON.stringify({ ...config, cachedAt: Date.now() }),\n );\n } catch {\n /* private browsing / storage quota */\n }\n}\n\nfunction loadFromCacheStorage(apiKey: string): RemoteConfig | null {\n try {\n const raw = localStorage.getItem(cacheKey(apiKey));\n if (!raw) return null;\n return JSON.parse(raw) as RemoteConfig;\n } catch {\n return null;\n }\n}\n\nfunction isFresh(config: RemoteConfig): boolean {\n if (!config.cachedAt) return false;\n return Date.now() - config.cachedAt < config.ttl;\n}\n\n// ── Public API ────────────────────────────────────────────────────────────────\n\n/**\n * Fetches the remote config with full fallback chain.\n * Never rejects — always returns a usable config.\n */\nexport async function fetchConfig(\n apiKey: string,\n locale: string,\n endpointOverride?: string,\n): Promise<RemoteConfig> {\n // 1. localStorage — fresh\n const cached = loadFromCacheStorage(apiKey);\n if (cached && isFresh(cached)) return cached;\n\n // 2. Remote CDN (with timeout)\n const endpoint = endpointOverride ?? DEFAULT_CDN;\n try {\n const url = new URL(endpoint);\n url.searchParams.set('key', apiKey);\n url.searchParams.set('locale', locale);\n\n const res = await fetch(url.toString(), {\n headers: { Accept: 'application/json' },\n signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),\n });\n\n if (res.ok) {\n const data = (await res.json()) as RemoteConfig;\n data.cachedAt = Date.now();\n saveToCacheStorage(apiKey, data);\n return data;\n }\n } catch {\n /* network error, CSP block, timeout — fall through */\n }\n\n // 3. localStorage — stale (better than nothing)\n if (cached) return cached;\n\n // 4. Bundled default\n return { ...DEFAULT_CONFIG, locale };\n}\n\nexport function getConfig(): RemoteConfig | null {\n // Re-exported from index so callers can inspect the live config\n // (populated asynchronously after init)\n try {\n const { getState } = require('./state') as typeof import('./state');\n return getState().config;\n } catch {\n return null;\n }\n}\n","// DisclosElement — base class for all Disclos Custom Elements\n// Handles config-aware rendering and IntersectionObserver-based visibility tracking.\nimport { getState } from '../core/state';\nimport { CONFIG_LOADED_EVENT } from '../core/init';\nimport type { RemoteConfig } from '../core/types';\n\nexport abstract class DisclosElement extends HTMLElement {\n private _observer: IntersectionObserver | null = null;\n private _disclosed = false;\n private readonly _onConfigLoaded: EventListener = () => this._update();\n\n connectedCallback(): void {\n if (!this.shadowRoot) this.attachShadow({ mode: 'open' });\n this._update();\n this._trackVisibility();\n window.addEventListener(CONFIG_LOADED_EVENT, this._onConfigLoaded);\n }\n\n disconnectedCallback(): void {\n this._observer?.disconnect();\n window.removeEventListener(CONFIG_LOADED_EVENT, this._onConfigLoaded);\n }\n\n attributeChangedCallback(): void {\n if (this.shadowRoot) this._update();\n }\n\n /** Subclasses implement this to produce Shadow DOM HTML */\n protected abstract _html(config: RemoteConfig | null): string;\n\n /** Called once when the element becomes ≥50% visible in the viewport */\n protected _onVisible(): void {\n // Default: no-op. Subclasses override to fire disclosure_shown events.\n }\n\n protected getConfig(): RemoteConfig | null {\n return getState().config;\n }\n\n private _update(): void {\n if (!this.shadowRoot) return;\n this.shadowRoot.innerHTML = this._html(this.getConfig());\n }\n\n private _trackVisibility(): void {\n if (typeof IntersectionObserver === 'undefined') {\n // Fallback for environments without IntersectionObserver (tests, old browsers)\n if (!this._disclosed) {\n this._disclosed = true;\n this._onVisible();\n }\n return;\n }\n\n this._observer = new IntersectionObserver(\n ([entry]) => {\n if (entry?.isIntersecting && !this._disclosed) {\n this._disclosed = true;\n this._onVisible();\n }\n },\n { threshold: 0.5 },\n );\n this._observer.observe(this);\n }\n}\n","// Disclos.init() — non-blocking bootstrap for the entire SDK\nimport { getState, setState } from './state';\nimport { fetchConfig } from './config';\nimport type { InitOptions } from './types';\n\nconst CONFIG_LOADED_EVENT = 'disclos:config-loaded';\n\n/**\n * Initialises the SDK. Safe to call multiple times (idempotent after first call).\n *\n * - Sets up the API key, aiSystemId, locale, and options\n * - Creates the event batcher\n * - Kicks off a non-blocking config fetch from the CDN\n * - Drains any localStorage event queue from previous page sessions\n * - Registers all Custom Elements (idempotent)\n *\n * Returns immediately; config fetch happens in the background.\n */\nexport async function init(options: InitOptions): Promise<void> {\n const state = getState();\n\n if (state.initialized) {\n if (state.debug) console.warn('[Disclos] Already initialized — ignoring duplicate init()');\n return;\n }\n\n if (!options.apiKey) throw new Error('[Disclos] apiKey is required');\n if (!options.aiSystemId) throw new Error('[Disclos] aiSystemId is required');\n\n // Lazy-import to preserve tree-shaking for log-only consumers\n const [{ EventBatcher }, { drainQueue }, { registerElements }] = await Promise.all([\n import('../log/batch'),\n import('../log/queue'),\n import('../components/register'),\n ]);\n\n setState({\n initialized: true,\n apiKey: options.apiKey,\n aiSystemId: options.aiSystemId,\n locale: options.locale ?? 'en',\n debug: options.debug ?? false,\n logContent: options.logContent ?? false,\n options,\n batcher: new EventBatcher(options),\n });\n\n // Register Custom Elements — safe to call multiple times\n registerElements();\n\n // Background config fetch — never blocks init()\n void fetchConfig(options.apiKey, options.locale ?? 'en', options.configEndpoint)\n .then((config) => {\n setState({ config });\n // Notify all mounted DisclosElement components to re-render with live text\n if (typeof window !== 'undefined') {\n window.dispatchEvent(new CustomEvent(CONFIG_LOADED_EVENT, { detail: config }));\n }\n if (options.debug) console.debug('[Disclos] Config loaded:', config);\n })\n .catch((err: unknown) => {\n if (options.debug) console.error('[Disclos] Config fetch error:', err);\n });\n\n // Drain any events queued from failed sends in previous page sessions\n void drainQueue().catch((err: unknown) => {\n if (options.debug) console.warn('[Disclos] Queue drain error:', err);\n });\n}\n\nexport { CONFIG_LOADED_EVENT };\n"]}
@@ -0,0 +1,6 @@
1
+ export { ContentLabel } from './chunk-GFU3F3ZX.mjs';
2
+ import './chunk-YJEYWPLR.mjs';
3
+ import './chunk-BHR3367P.mjs';
4
+ import './chunk-NFEGQTCC.mjs';
5
+ //# sourceMappingURL=content-label-ITJPDODX.mjs.map
6
+ //# sourceMappingURL=content-label-ITJPDODX.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"content-label-ITJPDODX.mjs"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var chunk32Z4Q6ZD_cjs = require('./chunk-32Z4Q6ZD.cjs');
4
+ require('./chunk-TTJMXFXE.cjs');
5
+ require('./chunk-4KTDVK7J.cjs');
6
+ require('./chunk-CZLDE2OZ.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "ContentLabel", {
11
+ enumerable: true,
12
+ get: function () { return chunk32Z4Q6ZD_cjs.ContentLabel; }
13
+ });
14
+ //# sourceMappingURL=content-label-JFRT3OGU.cjs.map
15
+ //# sourceMappingURL=content-label-JFRT3OGU.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"content-label-JFRT3OGU.cjs"}
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var chunkGYNG67I6_cjs = require('./chunk-GYNG67I6.cjs');
4
+ require('./chunk-TTJMXFXE.cjs');
5
+ require('./chunk-4KTDVK7J.cjs');
6
+ require('./chunk-CZLDE2OZ.cjs');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "DeepfakeMarker", {
11
+ enumerable: true,
12
+ get: function () { return chunkGYNG67I6_cjs.DeepfakeMarker; }
13
+ });
14
+ //# sourceMappingURL=deepfake-marker-5FNO7W5J.cjs.map
15
+ //# sourceMappingURL=deepfake-marker-5FNO7W5J.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"deepfake-marker-5FNO7W5J.cjs"}
@@ -0,0 +1,6 @@
1
+ export { DeepfakeMarker } from './chunk-LNXULTZ5.mjs';
2
+ import './chunk-YJEYWPLR.mjs';
3
+ import './chunk-BHR3367P.mjs';
4
+ import './chunk-NFEGQTCC.mjs';
5
+ //# sourceMappingURL=deepfake-marker-ILF66NVN.mjs.map
6
+ //# sourceMappingURL=deepfake-marker-ILF66NVN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"deepfake-marker-ILF66NVN.mjs"}
package/dist/index.cjs ADDED
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var chunkH724IVG6_cjs = require('./chunk-H724IVG6.cjs');
4
+ var chunkI7K3XSEO_cjs = require('./chunk-I7K3XSEO.cjs');
5
+ var chunkQ3245KZ2_cjs = require('./chunk-Q3245KZ2.cjs');
6
+ var chunk32Z4Q6ZD_cjs = require('./chunk-32Z4Q6ZD.cjs');
7
+ var chunkGYNG67I6_cjs = require('./chunk-GYNG67I6.cjs');
8
+ var chunkTTJMXFXE_cjs = require('./chunk-TTJMXFXE.cjs');
9
+ require('./chunk-4KTDVK7J.cjs');
10
+ require('./chunk-CZLDE2OZ.cjs');
11
+
12
+
13
+
14
+ Object.defineProperty(exports, "TrustPage", {
15
+ enumerable: true,
16
+ get: function () { return chunkH724IVG6_cjs.TrustPage; }
17
+ });
18
+ Object.defineProperty(exports, "hashSessionId", {
19
+ enumerable: true,
20
+ get: function () { return chunkI7K3XSEO_cjs.hashSessionId; }
21
+ });
22
+ Object.defineProperty(exports, "hashSessionIdSync", {
23
+ enumerable: true,
24
+ get: function () { return chunkI7K3XSEO_cjs.hashSessionIdSync; }
25
+ });
26
+ Object.defineProperty(exports, "log", {
27
+ enumerable: true,
28
+ get: function () { return chunkI7K3XSEO_cjs.log; }
29
+ });
30
+ Object.defineProperty(exports, "ChatbotBanner", {
31
+ enumerable: true,
32
+ get: function () { return chunkQ3245KZ2_cjs.ChatbotBanner; }
33
+ });
34
+ Object.defineProperty(exports, "ContentLabel", {
35
+ enumerable: true,
36
+ get: function () { return chunk32Z4Q6ZD_cjs.ContentLabel; }
37
+ });
38
+ Object.defineProperty(exports, "DeepfakeMarker", {
39
+ enumerable: true,
40
+ get: function () { return chunkGYNG67I6_cjs.DeepfakeMarker; }
41
+ });
42
+ Object.defineProperty(exports, "getConfig", {
43
+ enumerable: true,
44
+ get: function () { return chunkTTJMXFXE_cjs.getConfig; }
45
+ });
46
+ Object.defineProperty(exports, "init", {
47
+ enumerable: true,
48
+ get: function () { return chunkTTJMXFXE_cjs.init; }
49
+ });
50
+ //# sourceMappingURL=index.cjs.map
51
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,157 @@
1
+ /** Options passed to Disclos.init() */
2
+ interface InitOptions {
3
+ /** SDK API key from the Disclos dashboard (dsc_live_…) */
4
+ apiKey: string;
5
+ /** Stable ai_systems.system_id for this integration point */
6
+ aiSystemId: string;
7
+ /** BCP-47 locale for disclosure text; default: 'en' */
8
+ locale?: string;
9
+ /** Emit debug logs to console; default: false */
10
+ debug?: boolean;
11
+ /**
12
+ * Whether to include raw model input/output in ai_interaction events.
13
+ * Off by default — customers must explicitly opt in after legal review.
14
+ */
15
+ logContent?: boolean;
16
+ /** Override the ingestion endpoint (for testing / on-premise) */
17
+ endpoint?: string;
18
+ /** Override the config CDN endpoint */
19
+ configEndpoint?: string;
20
+ }
21
+ /** Remote config fetched from cdn.disclos.dev on init */
22
+ interface RemoteConfig {
23
+ version: number;
24
+ locale: string;
25
+ ingestionEndpoint: string;
26
+ /** Fraction of events to send; 0 = none, 1 = all */
27
+ samplingRate: number;
28
+ disclosures: {
29
+ chatbot: string;
30
+ contentLabel: {
31
+ text: string;
32
+ image: string;
33
+ audio: string;
34
+ video: string;
35
+ };
36
+ deepfake: string;
37
+ };
38
+ features: {
39
+ contentLabeling: boolean;
40
+ trustPage: boolean;
41
+ };
42
+ /** Client-side cache TTL in milliseconds */
43
+ ttl: number;
44
+ /** Populated by the SDK when storing to localStorage */
45
+ cachedAt?: number;
46
+ }
47
+ /** The three EU AI Act Article 50 event types */
48
+ type EventType = 'ai_interaction' | 'disclosure_shown' | 'content_labeled';
49
+ /** Public event shape passed to Disclos.log() */
50
+ interface LogEvent {
51
+ type: EventType;
52
+ /** Override the aiSystemId set in init(); rare */
53
+ aiSystemId?: string;
54
+ /**
55
+ * Opaque session identifier. One-way hashed before transmission —
56
+ * the raw value never leaves the browser.
57
+ */
58
+ sessionId?: string;
59
+ /** ISO 8601 timestamp; defaults to now */
60
+ timestamp?: string;
61
+ /**
62
+ * Event-type-specific metadata.
63
+ * Content (raw prompt/response) is only included when logContent: true in init().
64
+ */
65
+ metadata?: Record<string, unknown>;
66
+ }
67
+
68
+ /**
69
+ * Initialises the SDK. Safe to call multiple times (idempotent after first call).
70
+ *
71
+ * - Sets up the API key, aiSystemId, locale, and options
72
+ * - Creates the event batcher
73
+ * - Kicks off a non-blocking config fetch from the CDN
74
+ * - Drains any localStorage event queue from previous page sessions
75
+ * - Registers all Custom Elements (idempotent)
76
+ *
77
+ * Returns immediately; config fetch happens in the background.
78
+ */
79
+ declare function init(options: InitOptions): Promise<void>;
80
+
81
+ declare function getConfig(): RemoteConfig | null;
82
+
83
+ /**
84
+ * Enqueues a compliance event for batched delivery to the Disclos ingestion plane.
85
+ *
86
+ * - Synchronous and non-blocking: event is added to the in-memory batcher
87
+ * - Session ID is one-way hashed before it leaves the browser
88
+ * - Content (prompts, responses) is stripped unless `logContent: true` was set in init()
89
+ * - Safe to call before init() — emits a console warning and no-ops
90
+ * - Respects the `samplingRate` from the remote config
91
+ *
92
+ * @example
93
+ * Disclos.log({ type: 'ai_interaction', metadata: { model: 'gpt-4o', latency_ms: 312 } });
94
+ */
95
+ declare function log(event: LogEvent): void;
96
+
97
+ /**
98
+ * Returns a 16-character hex one-way hash of the raw session ID.
99
+ * Salted with the API key so the same session produces different
100
+ * hashes across different Disclos customers — prevents cross-customer linkage.
101
+ *
102
+ * Async (uses SubtleCrypto). Falls back to synchronous FNV-1a if
103
+ * SubtleCrypto is unavailable (rare edge case).
104
+ */
105
+ declare function hashSessionId(rawId: string, apiKeySalt: string): Promise<string>;
106
+ /**
107
+ * Synchronous fallback using FNV-1a 32-bit hash.
108
+ * Only used when SubtleCrypto is unavailable (pre-Safari 14 legacy).
109
+ * Deterministic and collision-resistant for our purposes.
110
+ */
111
+ declare function hashSessionIdSync(rawId: string, apiKeySalt: string): string;
112
+
113
+ declare abstract class DisclosElement extends HTMLElement {
114
+ private _observer;
115
+ private _disclosed;
116
+ private readonly _onConfigLoaded;
117
+ connectedCallback(): void;
118
+ disconnectedCallback(): void;
119
+ attributeChangedCallback(): void;
120
+ /** Subclasses implement this to produce Shadow DOM HTML */
121
+ protected abstract _html(config: RemoteConfig | null): string;
122
+ /** Called once when the element becomes ≥50% visible in the viewport */
123
+ protected _onVisible(): void;
124
+ protected getConfig(): RemoteConfig | null;
125
+ private _update;
126
+ private _trackVisibility;
127
+ }
128
+
129
+ declare class ChatbotBanner extends DisclosElement {
130
+ static get observedAttributes(): string[];
131
+ protected _html(config: RemoteConfig | null): string;
132
+ protected _onVisible(): void;
133
+ }
134
+
135
+ declare class ContentLabel extends DisclosElement {
136
+ static get observedAttributes(): string[];
137
+ protected _html(config: RemoteConfig | null): string;
138
+ protected _onVisible(): void;
139
+ }
140
+
141
+ declare class DeepfakeMarker extends DisclosElement {
142
+ static get observedAttributes(): string[];
143
+ protected _html(config: RemoteConfig | null): string;
144
+ protected _onVisible(): void;
145
+ }
146
+
147
+ declare class TrustPage extends DisclosElement {
148
+ private _data;
149
+ private _error;
150
+ private _loading;
151
+ static get observedAttributes(): string[];
152
+ connectedCallback(): void;
153
+ protected _html(_config: RemoteConfig | null): string;
154
+ private _load;
155
+ }
156
+
157
+ export { ChatbotBanner, ContentLabel, DeepfakeMarker, type EventType, type InitOptions, type LogEvent, type RemoteConfig, TrustPage, getConfig, hashSessionId, hashSessionIdSync, init, log };
@@ -0,0 +1,157 @@
1
+ /** Options passed to Disclos.init() */
2
+ interface InitOptions {
3
+ /** SDK API key from the Disclos dashboard (dsc_live_…) */
4
+ apiKey: string;
5
+ /** Stable ai_systems.system_id for this integration point */
6
+ aiSystemId: string;
7
+ /** BCP-47 locale for disclosure text; default: 'en' */
8
+ locale?: string;
9
+ /** Emit debug logs to console; default: false */
10
+ debug?: boolean;
11
+ /**
12
+ * Whether to include raw model input/output in ai_interaction events.
13
+ * Off by default — customers must explicitly opt in after legal review.
14
+ */
15
+ logContent?: boolean;
16
+ /** Override the ingestion endpoint (for testing / on-premise) */
17
+ endpoint?: string;
18
+ /** Override the config CDN endpoint */
19
+ configEndpoint?: string;
20
+ }
21
+ /** Remote config fetched from cdn.disclos.dev on init */
22
+ interface RemoteConfig {
23
+ version: number;
24
+ locale: string;
25
+ ingestionEndpoint: string;
26
+ /** Fraction of events to send; 0 = none, 1 = all */
27
+ samplingRate: number;
28
+ disclosures: {
29
+ chatbot: string;
30
+ contentLabel: {
31
+ text: string;
32
+ image: string;
33
+ audio: string;
34
+ video: string;
35
+ };
36
+ deepfake: string;
37
+ };
38
+ features: {
39
+ contentLabeling: boolean;
40
+ trustPage: boolean;
41
+ };
42
+ /** Client-side cache TTL in milliseconds */
43
+ ttl: number;
44
+ /** Populated by the SDK when storing to localStorage */
45
+ cachedAt?: number;
46
+ }
47
+ /** The three EU AI Act Article 50 event types */
48
+ type EventType = 'ai_interaction' | 'disclosure_shown' | 'content_labeled';
49
+ /** Public event shape passed to Disclos.log() */
50
+ interface LogEvent {
51
+ type: EventType;
52
+ /** Override the aiSystemId set in init(); rare */
53
+ aiSystemId?: string;
54
+ /**
55
+ * Opaque session identifier. One-way hashed before transmission —
56
+ * the raw value never leaves the browser.
57
+ */
58
+ sessionId?: string;
59
+ /** ISO 8601 timestamp; defaults to now */
60
+ timestamp?: string;
61
+ /**
62
+ * Event-type-specific metadata.
63
+ * Content (raw prompt/response) is only included when logContent: true in init().
64
+ */
65
+ metadata?: Record<string, unknown>;
66
+ }
67
+
68
+ /**
69
+ * Initialises the SDK. Safe to call multiple times (idempotent after first call).
70
+ *
71
+ * - Sets up the API key, aiSystemId, locale, and options
72
+ * - Creates the event batcher
73
+ * - Kicks off a non-blocking config fetch from the CDN
74
+ * - Drains any localStorage event queue from previous page sessions
75
+ * - Registers all Custom Elements (idempotent)
76
+ *
77
+ * Returns immediately; config fetch happens in the background.
78
+ */
79
+ declare function init(options: InitOptions): Promise<void>;
80
+
81
+ declare function getConfig(): RemoteConfig | null;
82
+
83
+ /**
84
+ * Enqueues a compliance event for batched delivery to the Disclos ingestion plane.
85
+ *
86
+ * - Synchronous and non-blocking: event is added to the in-memory batcher
87
+ * - Session ID is one-way hashed before it leaves the browser
88
+ * - Content (prompts, responses) is stripped unless `logContent: true` was set in init()
89
+ * - Safe to call before init() — emits a console warning and no-ops
90
+ * - Respects the `samplingRate` from the remote config
91
+ *
92
+ * @example
93
+ * Disclos.log({ type: 'ai_interaction', metadata: { model: 'gpt-4o', latency_ms: 312 } });
94
+ */
95
+ declare function log(event: LogEvent): void;
96
+
97
+ /**
98
+ * Returns a 16-character hex one-way hash of the raw session ID.
99
+ * Salted with the API key so the same session produces different
100
+ * hashes across different Disclos customers — prevents cross-customer linkage.
101
+ *
102
+ * Async (uses SubtleCrypto). Falls back to synchronous FNV-1a if
103
+ * SubtleCrypto is unavailable (rare edge case).
104
+ */
105
+ declare function hashSessionId(rawId: string, apiKeySalt: string): Promise<string>;
106
+ /**
107
+ * Synchronous fallback using FNV-1a 32-bit hash.
108
+ * Only used when SubtleCrypto is unavailable (pre-Safari 14 legacy).
109
+ * Deterministic and collision-resistant for our purposes.
110
+ */
111
+ declare function hashSessionIdSync(rawId: string, apiKeySalt: string): string;
112
+
113
+ declare abstract class DisclosElement extends HTMLElement {
114
+ private _observer;
115
+ private _disclosed;
116
+ private readonly _onConfigLoaded;
117
+ connectedCallback(): void;
118
+ disconnectedCallback(): void;
119
+ attributeChangedCallback(): void;
120
+ /** Subclasses implement this to produce Shadow DOM HTML */
121
+ protected abstract _html(config: RemoteConfig | null): string;
122
+ /** Called once when the element becomes ≥50% visible in the viewport */
123
+ protected _onVisible(): void;
124
+ protected getConfig(): RemoteConfig | null;
125
+ private _update;
126
+ private _trackVisibility;
127
+ }
128
+
129
+ declare class ChatbotBanner extends DisclosElement {
130
+ static get observedAttributes(): string[];
131
+ protected _html(config: RemoteConfig | null): string;
132
+ protected _onVisible(): void;
133
+ }
134
+
135
+ declare class ContentLabel extends DisclosElement {
136
+ static get observedAttributes(): string[];
137
+ protected _html(config: RemoteConfig | null): string;
138
+ protected _onVisible(): void;
139
+ }
140
+
141
+ declare class DeepfakeMarker extends DisclosElement {
142
+ static get observedAttributes(): string[];
143
+ protected _html(config: RemoteConfig | null): string;
144
+ protected _onVisible(): void;
145
+ }
146
+
147
+ declare class TrustPage extends DisclosElement {
148
+ private _data;
149
+ private _error;
150
+ private _loading;
151
+ static get observedAttributes(): string[];
152
+ connectedCallback(): void;
153
+ protected _html(_config: RemoteConfig | null): string;
154
+ private _load;
155
+ }
156
+
157
+ export { ChatbotBanner, ContentLabel, DeepfakeMarker, type EventType, type InitOptions, type LogEvent, type RemoteConfig, TrustPage, getConfig, hashSessionId, hashSessionIdSync, init, log };
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ export { TrustPage } from './chunk-UU6VG7CJ.mjs';
2
+ export { hashSessionId, hashSessionIdSync, log } from './chunk-ESP33I43.mjs';
3
+ export { ChatbotBanner } from './chunk-4JEHEDQP.mjs';
4
+ export { ContentLabel } from './chunk-GFU3F3ZX.mjs';
5
+ export { DeepfakeMarker } from './chunk-LNXULTZ5.mjs';
6
+ export { getConfig, init } from './chunk-YJEYWPLR.mjs';
7
+ import './chunk-BHR3367P.mjs';
8
+ import './chunk-NFEGQTCC.mjs';
9
+ //# sourceMappingURL=index.mjs.map
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var chunkI7K3XSEO_cjs = require('./chunk-I7K3XSEO.cjs');
4
+ require('./chunk-4KTDVK7J.cjs');
5
+ require('./chunk-CZLDE2OZ.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "log", {
10
+ enumerable: true,
11
+ get: function () { return chunkI7K3XSEO_cjs.log; }
12
+ });
13
+ //# sourceMappingURL=logger-IEU35PCN.cjs.map
14
+ //# sourceMappingURL=logger-IEU35PCN.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"logger-IEU35PCN.cjs"}