//#region ../../node_modules/.pnpm/@incodetech+tri-sdk@0.5.1/node_modules/@incodetech/tri-sdk/dist/index.d.ts type CollectorKey = 'fingerprint' | 'pointer' | 'pointermove' | 'focus' | 'input' | 'keystroke' | 'clipboard' | 'form' | 'change' | 'selection' | 'tab' | 'visibility' | 'navigation' | 'viewportresize' | 'viewport' | 'scroll' | 'sensors' | 'network-request' | 'networkconnection' | 'screen'; type CollectorEventMap = { /** * Configurable unit keys. `'pointer'` represents the paired pointerdown/pointerup * listeners; `'click'`, `'dblclick'`, and `'contextmenu'` are independent. */ pointer: 'pointer' | 'click' | 'dblclick' | 'contextmenu'; clipboard: 'paste' | 'cut' | 'copy'; form: 'submit' | 'invalid'; tab: 'state' | 'count'; viewport: 'orientationchange' | 'devicepixelratiochange'; /** All-or-nothing: single events or inseparable pairs — no sub-event config. */ input: never; focus: never; keystroke: never; change: never; selection: never; visibility: never; pointermove: never; fingerprint: never; navigation: never; viewportresize: never; scroll: never; sensors: 'motion' | 'orientation' | 'light'; 'network-request': never; networkconnection: never; screen: never; }; type Layer = 'session' | 'behavioral' | 'device-fingerprinting'; /** * Hook that allows the host application to extend or replace the SDK's default * URL sanitiser. Called for every URL before it is placed on the wire. * * Receives the raw URL and the SDK's `defaultSanitize` implementation. * The host may call `defaultSanitize(url)` to obtain the already-sanitised * string and further transform it (e.g. remove additional path segments it * knows are PII), or may bypass the default entirely for full control. * * If this function throws, the SDK falls back to `defaultSanitize(url)`. * * @example * ```ts * sanitizeUrl: (url, defaultSanitize) => { * const sanitised = defaultSanitize(url) * return sanitised.replace(/\/internal\/[^/]+/, '/internal/:id') * } * ``` */ type IncodeSanitizeUrlHook = (url: string, defaultSanitize: (url: string) => string) => string; /** * Global PII capture level for element context. * * - `'all'` — all element fields emitted; PII identifiers and labels included. * Consumers should annotate sensitive elements with `data-tri-redact`. * - `'redact'` — PII identifiers (`id`, `name`, label, classes) set to `null`. * **Default.** Per-element overrides via `data-tri-redact` / `data-tri-ignore`. * - `'off'` — Element Context Processor is skipped entirely; `element` is always `null`. */ type CaptureElementLevel = 'all' | 'redact' | 'off'; /** * Controls whether text content is captured from interacted elements. * * - `'on'` — text content emitted (default). * - `'off'` — text content field is always `null`. */ type CaptureContentLevel = 'on' | 'off'; /** * Public SDK configuration. Both `layers` and `collectors` are optional; pass at * most one. When neither is provided, every collector defaults to enabled (same * behaviour as calling `start()` with no config). */ type IncodeTRIConfig = TRIConfigBase & (LayerBasedConfig | CollectorBasedConfig | NoCollectorSelectionConfig); /** Shared config fields present regardless of which selector variant is used. */ type TRIConfigBase = { apiURL: string; /** * SDK token obtained from a B2B server call or via `createSession`. * This is the short-lived token that identifies a specific SDK session — * the consumer's API key must never be passed here. */ token: string; /** * When `true` (the default), `setup()` calls `start()` automatically after * configuration completes and returns the resulting started state. When * `false`, `setup()` returns `'ready'` and collection is deferred — call * `start()` explicitly when collection should begin (e.g. after a consent * gate). */ autostart?: boolean; capture?: { element?: CaptureElementLevel; content?: CaptureContentLevel; }; apiVersion?: string; /** * Optional URL sanitiser hook. When omitted, the SDK applies its built-in * default (strip credentials + fragment, redact query values, tokenise * identifier path segments). Supply this to apply additional redaction * on top of the default or to replace it entirely. */ sanitizeUrl?: IncodeSanitizeUrlHook; /** * When `true`, the SDK emits diagnostic messages via `logger.warn`, * `logger.error`, and `logger.info`. Defaults to `false`. Has no effect on * `logger.fatal`, which always emits regardless of this flag. */ DEBUG?: boolean; }; /** * Per-collector event configuration exposed in the public `CollectorsConfig`. * Each key maps to an optional boolean; omitted events default to enabled (`true`). */ type CollectorEventsConfig = { [E in CollectorEventMap[C]]?: boolean; }; /** * Per-collector configuration. Eventless collectors (whose `CollectorEventMap` * entry is `never`) only accept `enabled`; event-bearing collectors additionally * accept an `events` map. */ type CollectorConfig = [CollectorEventMap[C]] extends [never] ? { enabled?: boolean; } : { enabled?: boolean; events?: CollectorEventsConfig; }; /** * Host-supplied collector configuration map. Every key is optional — omitted * collectors default to `disabled` when this field is present on `IncodeTRIConfig`. */ type CollectorsConfig = { [C in CollectorKey]?: CollectorConfig; }; /** Enables all collectors whose `layer` matches one of the provided keys. Omitted layers default to disabled. */ type LayerBasedConfig = { layers: Partial>; collectors?: never; }; /** Enables only the collectors explicitly listed, each with optional per-event overrides. */ type CollectorBasedConfig = { layers?: never; collectors: CollectorsConfig; }; /** No collector filtering — all collectors are enabled by default. */ type NoCollectorSelectionConfig = { layers?: never; collectors?: never; }; /** * Life-cycle states for an `IncodeTRI` instance. * * - `'idle'` — initial state; `setup()` has not completed successfully. * - `'ready'` — managers are wired and ready; `start()` may be called. * - `'starting'` — `start()` has been called; async sequence in progress. * - `'started'` — all managers are running and collecting. * - `'collection-disabled'` — collection is disabled for the provided SDK token. * - `'init-failed'` — setup failed. */ type IncodeTRIState = 'idle' | 'ready' | 'starting' | 'started' | 'collection-disabled' | 'init-failed'; interface SessionError { status: number; message: string; } interface Session { token: string | null; expiresAt: number | null; tokenType: 'sdk' | null; eventsCollectionEnabled: boolean; error: SessionError | null; } //#endregion //#region ../infra/src/tri/TransactionalRiskIntelligence.d.ts /** * Runtime TRI configuration passed to `IncodeTRI.setup`. * Mirrors the upstream `IncodeTRIConfig` (a `TRIConfigBase` intersected with a * layer-/collector-based selector union). */ type TransactionalRiskIntelligenceConfig = IncodeTRIConfig; type TransactionalRiskIntelligenceState = IncodeTRIState; /** * Result of exchanging an organization API key for a short-lived TRI SDK token. * Mirrors the upstream `Session` shape: `{ token, eventsCollectionEnabled, error? }`. */ type TransactionalRiskIntelligenceSession = Session; /** * Options accepted by the TRI `createSession` exchange. The upstream SDK does * not export this shape, so it is mirrored here. */ type TransactionalRiskIntelligenceSessionOptions = { apiURL?: string; signal?: AbortSignal; timeout?: number; }; //#endregion //#region src/integrations/tri/types.d.ts /** * Setup-time TRI configuration supplied as `SetupOptions.tri`. * * Alias for `TransactionalRiskIntelligenceConfig`. `autostart` is defined on * the base config (`IncodeTRIConfig.autostart`) — when `true` (the default), * `setupTRI()` also starts collection automatically. Pass `autostart: false` * to defer collection to an explicit `startTRI()` call (e.g. after a consent * gate). * * `token` and `apiURL` are both required. TRI will not start unless both are * present — omitting either is the implicit opt-out. */ type TransactionalRiskIntelligenceSetupConfig = TransactionalRiskIntelligenceConfig; //#endregion //#region src/integrations/tri/tri.d.ts /** * Returns `true` when TRI collectors are currently running (a successful * `setupTRI()` autostart or explicit `startTRI()`, with no subsequent * `stopTRI()`/`resetTRI()`). Returns `false` before setup or after teardown. */ declare function isTRIStarted(): boolean; /** * Exchanges an organization API key for a short-lived TRI SDK token. This is * the entry point that triggers the lazy-load of `@incodetech/tri-sdk` (via the * provider's dynamic `import()`); the cached lazy handle is reused by a * subsequent `setupTRI()`. * * In production the exchange should happen server-side. On a load timeout or * failure the returned session carries `token: null` and an `error`, rather * than throwing. * * @param apiKey - Organization API key. * @param options - Optional `apiURL`, `signal`, and `timeout` overrides. */ declare function createTRISession(apiKey: string, options?: TransactionalRiskIntelligenceSessionOptions): Promise; /** * Calls the provider's `setup()` with the given config. This is the step that * lazy-loads `@incodetech/tri-sdk`, validates the config, and checks the * backend collection-status endpoint. When `config.autostart` is `true` (the * default), also calls `start()` internally and returns `'started'` on * success. Pass `autostart: false` to receive `'ready'` and start explicitly. * * @param config - Resolved TRI config (`token` and `apiURL` required). * @returns The resulting {@link TransactionalRiskIntelligenceState}. */ declare function setupTRI(config: TransactionalRiskIntelligenceConfig): Promise; /** * Begins behavioral data collection. Requires a prior successful `setupTRI()` * call with `autostart: false`. Returns `'init-failed'` without starting if * called before setup, or is a no-op if already started. * * @returns The resulting {@link TransactionalRiskIntelligenceState}. */ declare function startTRI(): Promise; /** * Stops all TRI collectors and managers. Idempotent. No-op if TRI was never * set up. */ declare function stopTRI(): Promise; /** * Resets the TRI SDK to its initial state. Call this from the SDK's `reset()` * so that a subsequent `setupTRI` / `startTRI` can begin fresh. */ declare function resetTRI(): Promise; //#endregion export { startTRI as a, setupTRI as i, isTRIStarted as n, stopTRI as o, resetTRI as r, TransactionalRiskIntelligenceSetupConfig as s, createTRISession as t };