@incodetech/core 2.5.0-agentic.1 → 2.5.0-agentic.3
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/dist/{FaceDetectionProvider-Cy2EAL0i.esm.js → FaceDetectionProvider-CAPKXGuF.esm.js} +4 -4
- package/dist/ae-signature.esm.js +1 -1
- package/dist/{apiError-B9-B3cMq.esm.js → apiError-CmvdtW2M.esm.js} +1 -1
- package/dist/authentication.d.ts +3 -3
- package/dist/authentication.esm.js +2 -2
- package/dist/{authenticationManager-DNWtc0eq.esm.js → authenticationManager-CsioEjTk.esm.js} +3 -3
- package/dist/{authenticationManager-CkD0JR7Q.d.ts → authenticationManager-D_dz2zK4.d.ts} +1 -1
- package/dist/{authenticationStateMachine-CJ9i4Al-.esm.js → authenticationStateMachine-BoGEvdpR.esm.js} +3 -3
- package/dist/{browser-pQZA35G2-B4Dwja1e.esm.js → browser-pQZA35G2-DveVe0Ui.esm.js} +1 -1
- package/dist/consent.d.ts +1 -1
- package/dist/{consentManager-B0YKqYtZ.d.ts → consentManager-CMed_O5F.d.ts} +8 -8
- package/dist/curp-validation.d.ts +1 -1
- package/dist/{curpValidationManager-HOidAKvT.d.ts → curpValidationManager-tNhzv7vZ.d.ts} +1 -1
- package/dist/{deepsightCaptureConfig-BxD3mSac.esm.js → deepsightCaptureConfig-tYJhVK_Z.esm.js} +2 -2
- package/dist/{deepsightLoader-KYZP8_x-.esm.js → deepsightLoader-VASYET0q.esm.js} +4 -4
- package/dist/{desktopCameraElection-BGQRIA2u.esm.js → desktopCameraElection-Bx8PyF2-.esm.js} +4 -4
- package/dist/document-capture.d.ts +1 -1
- package/dist/document-signature.esm.js +1 -1
- package/dist/{documentCaptureManager-sJWgqtUy.d.ts → documentCaptureManager-Bul0b4KJ.d.ts} +5 -5
- package/dist/{documentSignatureStateMachine-CLljjltG.esm.js → documentSignatureStateMachine-BeA6fc5n.esm.js} +1 -1
- package/dist/dynamic-forms.esm.js +2 -2
- package/dist/{dynamicFormsManager-CnU2hRvl.esm.js → dynamicFormsManager-f5Uyu4UK.esm.js} +1 -1
- package/dist/{dynamicFormsStateMachine-huYmjamB.esm.js → dynamicFormsStateMachine-Dkug_fKn.esm.js} +1 -1
- package/dist/ekyb.d.ts +1 -1
- package/dist/ekyb.esm.js +2 -2
- package/dist/{ekybManager-CaEErq39.esm.js → ekybManager-KiG_tDCV.esm.js} +1 -1
- package/dist/{ekybStateMachine-BIU8KIMv.esm.js → ekybStateMachine-dDlZntM8.esm.js} +1 -1
- package/dist/ekyc-prefill.d.ts +1 -1
- package/dist/ekyc-prefill.esm.js +2 -2
- package/dist/ekyc.d.ts +2 -2
- package/dist/ekyc.esm.js +3 -3
- package/dist/{ekycManager-D2K8AaMV.esm.js → ekycManager-SUIAHlrm.esm.js} +1 -1
- package/dist/{ekycManager-DusmB-4j.d.ts → ekycManager-mv2rWxc4.d.ts} +1 -1
- package/dist/{ekycPrefillManager-CENQjdNq.esm.js → ekycPrefillManager-BsFZnV2a.esm.js} +1 -1
- package/dist/{ekycPrefillManager-BwmPXfhY.d.ts → ekycPrefillManager-QKqXYPH_.d.ts} +5 -5
- package/dist/{ekycPrefillStateMachine-jT3hIt2X.esm.js → ekycPrefillStateMachine-B6ZTcy7R.esm.js} +21 -4
- package/dist/{ekycStateMachine-6EKndBd7.esm.js → ekycStateMachine-Czn2CaTV.esm.js} +134 -3
- package/dist/{ekycUtils-C6HZB46m.esm.js → ekycUtils-BnTyeA-_.esm.js} +12 -0
- package/dist/electronic-signature.esm.js +1 -1
- package/dist/{electronicSignatureManager-wM8WTgzP.esm.js → electronicSignatureManager-BIjhPcO0.esm.js} +1 -1
- package/dist/extensibility.d.ts +15 -15
- package/dist/extensibility.esm.js +13 -13
- package/dist/{faceCaptureManagerFactory-DbEARG3h.esm.js → faceCaptureManagerFactory-6Hk2GxNz.esm.js} +2 -2
- package/dist/{faceCaptureManagerFactory-D1EJw36F.d.ts → faceCaptureManagerFactory-B1WfKaGJ.d.ts} +3 -3
- package/dist/{faceCaptureSetup-VaAjMpWX.esm.js → faceCaptureSetup-BM0mj2GE.esm.js} +7 -7
- package/dist/{feature-management-D7oLtULO.esm.js → feature-management-DG39VwqE.esm.js} +1 -1
- package/dist/feature-management.esm.js +1 -1
- package/dist/flow-events.d.ts +1 -1
- package/dist/flow.d.ts +6 -6
- package/dist/flow.esm.js +3 -3
- package/dist/{flowCompletionService-CIjaIpMH.esm.js → flowCompletionService-QycHxT5Z.esm.js} +1 -1
- package/dist/{flowServices-Dqt75TXx.esm.js → flowServices-5d7en_Aq.esm.js} +5 -5
- package/dist/geolocation.d.ts +1 -1
- package/dist/geolocation.esm.js +2 -2
- package/dist/{geolocationManager-CENrvxpK.d.ts → geolocationManager-Del2ddmt.d.ts} +1 -1
- package/dist/{geolocationManager-DHfgXhEs.esm.js → geolocationManager-_DJwOuei.esm.js} +1 -1
- package/dist/{geolocationStateMachine-CrEspaN-.esm.js → geolocationStateMachine-CyjGgKJ7.esm.js} +1 -1
- package/dist/home.d.ts +1 -1
- package/dist/id-ocr.d.ts +1 -1
- package/dist/id-selfie-flow.d.ts +1 -1
- package/dist/id-selfie-flow.esm.js +6 -6
- package/dist/id.d.ts +2 -2
- package/dist/id.esm.js +3 -3
- package/dist/{idCaptureManager-BPDCAV04.esm.js → idCaptureManager-BjTr4lOA.esm.js} +4 -4
- package/dist/{idCaptureManager-CNFBeYgV.d.ts → idCaptureManager-DXqvtLr9.d.ts} +2 -2
- package/dist/{idCaptureServices-CWZFmS7l.esm.js → idCaptureServices-D6sRW-qd.esm.js} +2 -2
- package/dist/{idCaptureStateMachine-Cyt2BvPB.esm.js → idCaptureStateMachine-BBlWr1aL.esm.js} +45 -25
- package/dist/{idOcrManager-DflRx-_u.d.ts → idOcrManager-voLpv_jJ.d.ts} +1 -1
- package/dist/identity-reuse.d.ts +1 -1
- package/dist/{identityReuseManager-CZ-qJ_Aa.d.ts → identityReuseManager-D_jiHp1n.d.ts} +4 -4
- package/dist/{index-BMr3MZEI.d.ts → index-B3BI8mVu.d.ts} +32 -4
- package/dist/{index-BoGlwLGK.d.ts → index-BnKhmWhM.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/kyb-checks.esm.js +2 -2
- package/dist/{kybChecksManager-BF2vf0Q2.esm.js → kybChecksManager-Cpm2waJh.esm.js} +1 -1
- package/dist/{kybChecksStateMachine-oBQfgdka.esm.js → kybChecksStateMachine-Cg96E65N.esm.js} +1 -1
- package/dist/mandatory-consent.d.ts +2 -2
- package/dist/{mandatoryConsentManager-BcxCesP5.d.ts → mandatoryConsentManager-D2LkPii6.d.ts} +9 -9
- package/dist/qe-signature.esm.js +1 -1
- package/dist/{recordingService-DK3kjUby.esm.js → recordingService-wGNpJV_s.esm.js} +1 -1
- package/dist/{runChildModule-x1rrxjYY.esm.js → runChildModule-DCXy_h7V.esm.js} +1 -1
- package/dist/{numericRange-2e1vw1W0.esm.js → scriptCharacters-D7swUycV.esm.js} +13 -1
- package/dist/{sdkVersion-kRh5h82H.esm.js → sdkVersion-CzRrIbvf.esm.js} +1 -1
- package/dist/selfie.d.ts +3 -3
- package/dist/selfie.esm.js +7 -7
- package/dist/{selfieErrorUtils-B9GfiS9f.esm.js → selfieErrorUtils-DFJC36jx.esm.js} +1 -1
- package/dist/{selfieManager-CqDlUy6B.d.ts → selfieManager-B2j448t4.d.ts} +1 -1
- package/dist/{selfieManager-CivYjnF5.esm.js → selfieManager-KXkwfGvO.esm.js} +3 -3
- package/dist/{selfieStateMachine-dLwrXWll.esm.js → selfieStateMachine-CqHL6qf_.esm.js} +3 -3
- package/dist/{session-DeJ-rd9u.esm.js → session-DhNeT_WW.esm.js} +4 -4
- package/dist/session.d.ts +1 -1
- package/dist/session.esm.js +4 -4
- package/dist/{sessionInitializer-uZgyxsrL.esm.js → sessionInitializer-CfF_kFfS.esm.js} +6 -6
- package/dist/{setup-D0QZHkS8.esm.js → setup-BoCn7daH.esm.js} +8 -7
- package/dist/{setup-Cr2KCwau.d.ts → setup-DprzbOsJ.d.ts} +1 -1
- package/dist/tri-D5hWs0qJ.esm.js +559 -0
- package/dist/tri.d.ts +1 -1
- package/dist/{tri.esm-CftnGf9w.esm.js → tri.esm-DnXGKdlE.esm.js} +1296 -1057
- package/dist/tri.esm.js +1 -1
- package/dist/trueSight-CXzqdA0V.esm.js +1 -0
- package/dist/{trueSightService-BMp8g65B.esm.js → trueSightService-BYsRo-fK.esm.js} +1 -1
- package/dist/{types-BZsmNYom.d.ts → types-BFoC3IpR.d.ts} +2 -2
- package/dist/{types-PnJXvTkV.d.ts → types-BkxI3PHf.d.ts} +1 -1
- package/dist/{types-D-FEM1rT.d.ts → types-BxJWsAHc.d.ts} +4 -4
- package/dist/{types-HHgsFhZn.d.ts → types-CAzi8tyi.d.ts} +1 -1
- package/dist/types-CEdI4tfR.d.ts +6 -0
- package/dist/{types-tOSLpcSa.d.ts → types-CkzE2gPZ.d.ts} +5 -0
- package/dist/{types-LbccjQYX.d.ts → types-DuARPzVa.d.ts} +1 -1
- package/dist/video-selfie.d.ts +1 -1
- package/dist/video-selfie.esm.js +3 -3
- package/dist/{videoSelfieCameraWarmer-BpP0_lDr.esm.js → videoSelfieCameraWarmer-Co4dAC64.esm.js} +3 -3
- package/dist/{videoSelfieStepDetector-CxOc3kSI.d.ts → videoSelfieStepDetector-CrlbZ-rN.d.ts} +2 -2
- package/dist/wasm.d.ts +1 -1
- package/dist/wasm.esm.js +1 -1
- package/dist/workflow.d.ts +1 -1
- package/dist/workflow.esm.js +19 -19
- package/package.json +4 -3
- package/dist/tri-D_gHPWrq.esm.js +0 -402
- package/dist/trueSight-CbrZUzLx.esm.js +0 -1
- package/dist/types-BinnzVrL.d.ts +0 -6
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { t as SDK_VERSION } from "./sdkVersion-CzRrIbvf.esm.js";
|
|
2
|
+
import { t as BrowserTimerProvider } from "./BrowserTimerProvider-BXhgNxLt.esm.js";
|
|
3
|
+
import { t as BrowserLazyImportProvider } from "./BrowserLazyImportProvider-BhoA957O.esm.js";
|
|
4
|
+
//#region ../infra/src/providers/browser/TransactionalRiskIntelligenceProvider.ts
|
|
5
|
+
const LAZY_IMPORT_OPTIONS = {
|
|
6
|
+
label: "TRI",
|
|
7
|
+
moduleName: "@incodetech/tri-sdk",
|
|
8
|
+
timeoutMs: 1e4,
|
|
9
|
+
disabledMessage: "TRI will be disabled for this session."
|
|
10
|
+
};
|
|
11
|
+
const importSdk = () => import("./tri.esm-DnXGKdlE.esm.js");
|
|
12
|
+
const PAGE_TRI_KEY = Symbol.for("@incodetech/tri/page/v1");
|
|
13
|
+
const TRI_DEFAULT_API_VERSION = "1.0";
|
|
14
|
+
const page = globalThis;
|
|
15
|
+
function pageTri() {
|
|
16
|
+
return page[PAGE_TRI_KEY] ??= {
|
|
17
|
+
sdk: void 0,
|
|
18
|
+
state: "idle",
|
|
19
|
+
setUpWith: void 0,
|
|
20
|
+
queue: Promise.resolve(),
|
|
21
|
+
holders: /* @__PURE__ */ new Set(),
|
|
22
|
+
keptForPage: false,
|
|
23
|
+
resets: 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function enqueue(tri, operation) {
|
|
27
|
+
const run = tri.queue.then(operation, operation);
|
|
28
|
+
tri.queue = run.catch(() => void 0);
|
|
29
|
+
return run;
|
|
30
|
+
}
|
|
31
|
+
function isSetUpState$1(state) {
|
|
32
|
+
return state === "ready" || state === "started";
|
|
33
|
+
}
|
|
34
|
+
function isRecord(value) {
|
|
35
|
+
return typeof value === "object" && value !== null;
|
|
36
|
+
}
|
|
37
|
+
function stringOrUndefined(value) {
|
|
38
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
39
|
+
}
|
|
40
|
+
function tokenClaims(token) {
|
|
41
|
+
try {
|
|
42
|
+
const base64 = (token.split(".")[1] ?? "").replace(/-/g, "+").replace(/_/g, "/");
|
|
43
|
+
const claims = JSON.parse(atob(base64.padEnd(Math.ceil(base64.length / 4) * 4, "=")));
|
|
44
|
+
return isRecord(claims) ? claims : {};
|
|
45
|
+
} catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function stableJson(value) {
|
|
50
|
+
return JSON.stringify(value, (_key, item) => isRecord(item) && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).sort().map((key) => [key, item[key]])) : item);
|
|
51
|
+
}
|
|
52
|
+
function withoutTrailingSlashes(url) {
|
|
53
|
+
let end = url.length;
|
|
54
|
+
while (end > 0 && url[end - 1] === "/") end -= 1;
|
|
55
|
+
return url.slice(0, end);
|
|
56
|
+
}
|
|
57
|
+
function identityOf(config) {
|
|
58
|
+
const claims = tokenClaims(config.token);
|
|
59
|
+
const selection = config;
|
|
60
|
+
return {
|
|
61
|
+
apiURL: withoutTrailingSlashes(config.apiURL),
|
|
62
|
+
org: stringOrUndefined(claims.org_ref),
|
|
63
|
+
source: stringOrUndefined(claims.source_id),
|
|
64
|
+
settings: stableJson({
|
|
65
|
+
capture: {
|
|
66
|
+
element: config.capture?.element ?? "redact",
|
|
67
|
+
content: config.capture?.content ?? "off"
|
|
68
|
+
},
|
|
69
|
+
layers: selection.layers,
|
|
70
|
+
collectors: selection.collectors,
|
|
71
|
+
apiVersion: config.apiVersion ?? TRI_DEFAULT_API_VERSION
|
|
72
|
+
}),
|
|
73
|
+
sanitizeUrl: config.sanitizeUrl
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Why a setup can't reuse TRI that was set up as `running`, if it can't. */
|
|
77
|
+
function refusalOf(running, next) {
|
|
78
|
+
if (next.apiURL !== running.apiURL) return `with another apiURL (${running.apiURL})`;
|
|
79
|
+
if (running.org && next.org && running.org !== next.org) return "for another organization";
|
|
80
|
+
if (next.source && next.source !== running.source) return "for another source";
|
|
81
|
+
if (next.settings !== running.settings) return "with other capture, layers, collectors or apiVersion settings";
|
|
82
|
+
if (next.sanitizeUrl !== running.sanitizeUrl) return "with another sanitizeUrl";
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Concrete implementation of {@link ITransactionalRiskIntelligenceCapability}.
|
|
86
|
+
*
|
|
87
|
+
* This is the **only** file in the repo that references `@incodetech/tri-sdk`.
|
|
88
|
+
* The third-party module is loaded via a dynamic `import()` the first time
|
|
89
|
+
* {@link setup} is called, so consumers that never opt into TRI (i.e. never
|
|
90
|
+
* pass `tri` to `setup()`) do not pay the bundle cost.
|
|
91
|
+
*
|
|
92
|
+
* `start()`, `stop()`, and `linkInterview()` require a prior
|
|
93
|
+
* successful `setup()` call. The SDK cannot start without the foundation,
|
|
94
|
+
* collection-status check, and managers that `setup()` establishes. Calling
|
|
95
|
+
* these methods before `setup()` is a no-op that returns `'init-failed'` or
|
|
96
|
+
* `false` respectively.
|
|
97
|
+
*
|
|
98
|
+
* The dynamic `import('@incodetech/tri-sdk')` is managed by
|
|
99
|
+
* {@link BrowserLazyImportProvider}, which races the import against a
|
|
100
|
+
* {@link LOAD_TIMEOUT_MS}-ms timeout. On timeout the provider warns, clears
|
|
101
|
+
* the cached promise (so a subsequent `setup()` can retry), and resolves
|
|
102
|
+
* `undefined`, gracefully disabling TRI for the session.
|
|
103
|
+
*/
|
|
104
|
+
var TransactionalRiskIntelligenceProvider = class TransactionalRiskIntelligenceProvider {
|
|
105
|
+
constructor() {
|
|
106
|
+
this._lazySdk = BrowserLazyImportProvider.getInstance().create(importSdk, LAZY_IMPORT_OPTIONS);
|
|
107
|
+
}
|
|
108
|
+
static getInstance() {
|
|
109
|
+
return this._instance ??= new TransactionalRiskIntelligenceProvider();
|
|
110
|
+
}
|
|
111
|
+
/** Forgets this copy's provider and the page's TRI. For tests. */
|
|
112
|
+
static resetInstance() {
|
|
113
|
+
this._instance = void 0;
|
|
114
|
+
delete page[PAGE_TRI_KEY];
|
|
115
|
+
}
|
|
116
|
+
get isStarted() {
|
|
117
|
+
return pageTri().state === "started";
|
|
118
|
+
}
|
|
119
|
+
get resetCount() {
|
|
120
|
+
return pageTri().resets;
|
|
121
|
+
}
|
|
122
|
+
async createSession(apiKeyOrOptions, options) {
|
|
123
|
+
const module = await this._lazySdk.load();
|
|
124
|
+
if (!module) return {
|
|
125
|
+
token: null,
|
|
126
|
+
expiresAt: null,
|
|
127
|
+
tokenType: null,
|
|
128
|
+
eventsCollectionEnabled: false,
|
|
129
|
+
error: {
|
|
130
|
+
status: 0,
|
|
131
|
+
message: "TRI SDK failed to load"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
if (typeof apiKeyOrOptions === "object" && apiKeyOrOptions !== null) return module.createSession(apiKeyOrOptions);
|
|
135
|
+
return module.createSession(apiKeyOrOptions, {
|
|
136
|
+
...options,
|
|
137
|
+
apiURL: options?.apiURL ?? ""
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Lazy-loads `@incodetech/tri-sdk` on first call (with a {@link LOAD_TIMEOUT_MS}-ms
|
|
142
|
+
* timeout), then delegates to its `setup()`. Returns a promise that resolves
|
|
143
|
+
* once the SDK module has been fetched and the backend collection-status
|
|
144
|
+
* check has completed.
|
|
145
|
+
*
|
|
146
|
+
* When `config.autostart` is `true` (the default), the underlying `setup()`
|
|
147
|
+
* also calls `start()` and returns `'started'` on success, so `isStarted` is
|
|
148
|
+
* accurate as soon as `setup()` returns.
|
|
149
|
+
*
|
|
150
|
+
* A TRI that is already set up on the page is reused, and one whose setup
|
|
151
|
+
* failed is reset and set up again: see the capability for the rules.
|
|
152
|
+
*/
|
|
153
|
+
setup(config, holder) {
|
|
154
|
+
const tri = pageTri();
|
|
155
|
+
return enqueue(tri, () => this._setup(tri, config, holder));
|
|
156
|
+
}
|
|
157
|
+
release(holder) {
|
|
158
|
+
const tri = pageTri();
|
|
159
|
+
return enqueue(tri, async () => {
|
|
160
|
+
if (!tri.holders.delete(holder)) return;
|
|
161
|
+
if (tri.keptForPage || tri.holders.size > 0) return;
|
|
162
|
+
await this._reset(tri);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Begins behavioral data collection. Requires a prior successful `setup()`.
|
|
167
|
+
* Returns `'init-failed'` without starting if called before `setup()`.
|
|
168
|
+
*/
|
|
169
|
+
start() {
|
|
170
|
+
const tri = pageTri();
|
|
171
|
+
return enqueue(tri, async () => {
|
|
172
|
+
if (!tri.sdk) return "init-failed";
|
|
173
|
+
tri.state = await tri.sdk.start();
|
|
174
|
+
return tri.state;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Stops all collectors and managers. No-op when called before `setup()`.
|
|
179
|
+
*/
|
|
180
|
+
stop() {
|
|
181
|
+
const tri = pageTri();
|
|
182
|
+
return enqueue(tri, async () => {
|
|
183
|
+
if (!tri.sdk) return "init-failed";
|
|
184
|
+
tri.state = await tri.sdk.stop();
|
|
185
|
+
return tri.state;
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Resets the TRI SDK to its initial state. Before `setup()` it loads TRI
|
|
190
|
+
* first, so a reset on a fresh page forgets an earlier page's activity.
|
|
191
|
+
*/
|
|
192
|
+
reset() {
|
|
193
|
+
const tri = pageTri();
|
|
194
|
+
tri.resets += 1;
|
|
195
|
+
return enqueue(tri, () => this._reset(tri));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Links an interview to the current TRI activity. Returns `false` when
|
|
199
|
+
* called before `setup()` or when the backend request fails. Never throws,
|
|
200
|
+
* so the boot/flow path is never blocked by a failed link.
|
|
201
|
+
*
|
|
202
|
+
* @param sessionToken - The Incode session token to link.
|
|
203
|
+
*/
|
|
204
|
+
async linkInterview(sessionToken) {
|
|
205
|
+
try {
|
|
206
|
+
return await this._getSdk()?.linkInterview(sessionToken) ?? false;
|
|
207
|
+
} catch {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* TRI's fpSignals PID and DEVICE results. Resolves `null` before `setup()`
|
|
213
|
+
* and on any failure, so a caller can always fall back to its own runtime.
|
|
214
|
+
*/
|
|
215
|
+
async getFpSignals() {
|
|
216
|
+
try {
|
|
217
|
+
return await this._getSdk()?.getFpSignals() ?? null;
|
|
218
|
+
} catch {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Passes one signed result of the host's runtime to TRI, unchanged. Returns
|
|
224
|
+
* `false` before `setup()` and on any failure.
|
|
225
|
+
*/
|
|
226
|
+
addFpSignals(signals) {
|
|
227
|
+
try {
|
|
228
|
+
return this._getSdk()?.addFpSignals(signals) ?? false;
|
|
229
|
+
} catch {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The current activity id, or `null` when TRI is not loaded or not set up,
|
|
235
|
+
* has no active activity, or fails. Reads only an already loaded TRI.
|
|
236
|
+
*/
|
|
237
|
+
getActivityId() {
|
|
238
|
+
try {
|
|
239
|
+
return this._getSdk()?.getActivityId() ?? null;
|
|
240
|
+
} catch {
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
async _setup(tri, config, holder) {
|
|
245
|
+
try {
|
|
246
|
+
if (!tri.sdk) {
|
|
247
|
+
const module = await this._lazySdk.load();
|
|
248
|
+
if (!module) return "init-failed";
|
|
249
|
+
tri.sdk = module.default;
|
|
250
|
+
}
|
|
251
|
+
if (isSetUpState$1(tri.state)) {
|
|
252
|
+
if (!config.token || !config.apiURL) {
|
|
253
|
+
console.warn("[TRI] Not set up: token and apiURL are required.");
|
|
254
|
+
return "init-failed";
|
|
255
|
+
}
|
|
256
|
+
const refusal = tri.setUpWith ? refusalOf(tri.setUpWith, identityOf(config)) : void 0;
|
|
257
|
+
if (refusal) {
|
|
258
|
+
console.warn(`[TRI] Not set up: TRI already runs on this page ${refusal}.`);
|
|
259
|
+
return "init-failed";
|
|
260
|
+
}
|
|
261
|
+
console.warn("[TRI] Already set up: reusing the running TRI. This TRI config is ignored.");
|
|
262
|
+
this._hold(tri, holder);
|
|
263
|
+
return tri.state;
|
|
264
|
+
}
|
|
265
|
+
if (tri.state !== "idle") await this._reset(tri);
|
|
266
|
+
tri.state = await tri.sdk.setup(config);
|
|
267
|
+
if (isSetUpState$1(tri.state)) {
|
|
268
|
+
tri.setUpWith = identityOf(config);
|
|
269
|
+
this._hold(tri, holder);
|
|
270
|
+
}
|
|
271
|
+
return tri.state;
|
|
272
|
+
} catch {
|
|
273
|
+
tri.state = "init-failed";
|
|
274
|
+
return "init-failed";
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
_hold(tri, holder) {
|
|
278
|
+
if (holder) tri.holders.add(holder);
|
|
279
|
+
else tri.keptForPage = true;
|
|
280
|
+
}
|
|
281
|
+
async _reset(tri) {
|
|
282
|
+
tri.holders.clear();
|
|
283
|
+
tri.keptForPage = false;
|
|
284
|
+
tri.setUpWith = void 0;
|
|
285
|
+
try {
|
|
286
|
+
if (!tri.sdk) {
|
|
287
|
+
const module = await this._lazySdk.load();
|
|
288
|
+
if (!module) return "init-failed";
|
|
289
|
+
tri.sdk = module.default;
|
|
290
|
+
}
|
|
291
|
+
const state = await tri.sdk.reset();
|
|
292
|
+
tri.state = "idle";
|
|
293
|
+
return state;
|
|
294
|
+
} catch {
|
|
295
|
+
tri.state = "init-failed";
|
|
296
|
+
return "init-failed";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
_getSdk() {
|
|
300
|
+
return pageTri().sdk ?? null;
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/integrations/tri/tri.ts
|
|
305
|
+
const SDK_HOST = {
|
|
306
|
+
platform: "sdk2",
|
|
307
|
+
version: SDK_VERSION
|
|
308
|
+
};
|
|
309
|
+
const FP_SIGNALS_WAIT_MS = 5e3;
|
|
310
|
+
const SDK_HOLDER = { name: "setup({ tri })" };
|
|
311
|
+
let sdkHoldsTRI = false;
|
|
312
|
+
let hostAcceptedAt;
|
|
313
|
+
let sdkAcceptedAt;
|
|
314
|
+
let sdkTRIRun = 0;
|
|
315
|
+
/**
|
|
316
|
+
* `setup({ tri })` is about to ask for TRI: until the provider answers, the
|
|
317
|
+
* SDK uses no TRI, not even one this copy accepted before. `setup()` calls it
|
|
318
|
+
* before it activates the session, which would otherwise link the new
|
|
319
|
+
* session token to that TRI before the new `tri` config is checked.
|
|
320
|
+
*/
|
|
321
|
+
function markSdkTRIPending() {
|
|
322
|
+
sdkHoldsTRI = true;
|
|
323
|
+
sdkAcceptedAt = void 0;
|
|
324
|
+
sdkTRIRun += 1;
|
|
325
|
+
}
|
|
326
|
+
function isSetUpState(state) {
|
|
327
|
+
return state === "started" || state === "ready";
|
|
328
|
+
}
|
|
329
|
+
async function acceptedSetup(config, holder) {
|
|
330
|
+
const provider = getProvider();
|
|
331
|
+
const resets = provider.resetCount;
|
|
332
|
+
const state = await (holder ? provider.setup(config, holder) : provider.setup(config));
|
|
333
|
+
return {
|
|
334
|
+
state,
|
|
335
|
+
acceptedAt: isSetUpState(state) && provider.resetCount === resets ? resets : void 0
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Returns the active TRI capability implementation.
|
|
340
|
+
*
|
|
341
|
+
* Core functions depend on {@link ITransactionalRiskIntelligenceCapability}
|
|
342
|
+
* (the interface) rather than the concrete provider class. The provider is
|
|
343
|
+
* referenced here only to supply the default singleton. This integration
|
|
344
|
+
* module is the single owner of the concrete provider reference — the rest of
|
|
345
|
+
* core goes through these functions ({@link isTRIStarted},
|
|
346
|
+
* {@link resetTRIProviderInstance}, etc.) instead of importing the provider.
|
|
347
|
+
*/
|
|
348
|
+
function getProvider() {
|
|
349
|
+
return TransactionalRiskIntelligenceProvider.getInstance();
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Returns `true` when TRI collectors are currently running (a successful
|
|
353
|
+
* `setupTRI()` autostart or explicit `startTRI()`, with no subsequent
|
|
354
|
+
* `stopTRI()`/`resetTRI()`). Returns `false` before setup or after teardown.
|
|
355
|
+
*/
|
|
356
|
+
function isTRIStarted() {
|
|
357
|
+
return getProvider().isStarted;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Whether the page's TRI is started and this copy of the SDK may use it: its
|
|
361
|
+
* own `setupTRI()` or `setup({ tri })` set it up or reused it, with no reset
|
|
362
|
+
* since. Session linking and fingerprint forwarding go by this, not by
|
|
363
|
+
* {@link isTRIStarted}, which reports any copy's TRI.
|
|
364
|
+
*/
|
|
365
|
+
function isOwnTRIStarted() {
|
|
366
|
+
const acceptedAt = sdkHoldsTRI ? sdkAcceptedAt : hostAcceptedAt;
|
|
367
|
+
if (acceptedAt === void 0) return false;
|
|
368
|
+
const provider = getProvider();
|
|
369
|
+
return acceptedAt === provider.resetCount && provider.isStarted;
|
|
370
|
+
}
|
|
371
|
+
async function createTRISession(apiKeyOrOptions, options) {
|
|
372
|
+
if (typeof apiKeyOrOptions === "object" && apiKeyOrOptions !== null) return getProvider().createSession(apiKeyOrOptions);
|
|
373
|
+
return getProvider().createSession(apiKeyOrOptions, options);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Initializes TRI in a single step: resolves the config, calls `setupTRI`
|
|
377
|
+
* (which autostarts unless `config.autostart` is `false`), and optionally
|
|
378
|
+
* links the current Incode session.
|
|
379
|
+
*
|
|
380
|
+
* Returns the resolved {@link TransactionalRiskIntelligenceState}. If the
|
|
381
|
+
* config cannot be resolved (e.g. missing `token` or `apiURL`), returns
|
|
382
|
+
* `'init-failed'` after emitting a `[TRI]` warning.
|
|
383
|
+
*
|
|
384
|
+
* When `config.autostart` is `false`, the underlying `setupTRI` returns
|
|
385
|
+
* `'ready'` without starting collection — call `startTRI()` explicitly when
|
|
386
|
+
* ready (e.g. after a consent gate). Linking is skipped in that case since
|
|
387
|
+
* TRI has not started.
|
|
388
|
+
*
|
|
389
|
+
* A TRI that is already set up on the page, by the host through
|
|
390
|
+
* `@incodetech/core/tri`, the script tag or another copy of the SDK, is reused
|
|
391
|
+
* instead, after any setup still in flight finishes, when `config` matches it
|
|
392
|
+
* (see `setupTRI`): the session is linked to the running activity, and the
|
|
393
|
+
* result is `'started'`, or `'ready'` when it is not running. A `config` that
|
|
394
|
+
* doesn't match gets `'init-failed'`, and nothing is linked.
|
|
395
|
+
*
|
|
396
|
+
* Either way the SDK holds TRI until its `reset()`, which resets TRI only when
|
|
397
|
+
* nothing else on the page uses it.
|
|
398
|
+
*
|
|
399
|
+
* @param config - TRI setup config (must include `token` and `apiURL`).
|
|
400
|
+
* @param options - Optional session-linking hints (`sessionToken`).
|
|
401
|
+
*/
|
|
402
|
+
async function initializeTRI(config, options = {}) {
|
|
403
|
+
const resolvedTriConfig = resolveTRIConfig(config);
|
|
404
|
+
if (!resolvedTriConfig) return "init-failed";
|
|
405
|
+
markSdkTRIPending();
|
|
406
|
+
const run = sdkTRIRun;
|
|
407
|
+
const { state, acceptedAt } = await acceptedSetup({
|
|
408
|
+
...resolvedTriConfig,
|
|
409
|
+
host: SDK_HOST
|
|
410
|
+
}, SDK_HOLDER);
|
|
411
|
+
if (run !== sdkTRIRun) return state;
|
|
412
|
+
sdkAcceptedAt = acceptedAt;
|
|
413
|
+
if (isOwnTRIStarted() && options.sessionToken) await linkSessionWithTRI(options.sessionToken);
|
|
414
|
+
return state;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* TRI's fpSignals PID and DEVICE results, waiting at most
|
|
418
|
+
* {@link FP_SIGNALS_WAIT_MS} for the module to finish. Resolves `null` when
|
|
419
|
+
* no TRI is started on the page, its `fpsignals` collector is off or failed
|
|
420
|
+
* (CSP, load error), or the wait ran out. The strings are signed: pass them on
|
|
421
|
+
* unchanged.
|
|
422
|
+
*
|
|
423
|
+
* Any copy's TRI counts ({@link isTRIStarted}): these are the device's own
|
|
424
|
+
* results, signed the same way for every session, and reading them sends
|
|
425
|
+
* nothing to that TRI.
|
|
426
|
+
*/
|
|
427
|
+
async function readTRIFpSignals() {
|
|
428
|
+
if (!isTRIStarted()) return null;
|
|
429
|
+
const timer = BrowserTimerProvider.getInstance();
|
|
430
|
+
let timeout;
|
|
431
|
+
const timedOut = new Promise((resolve) => {
|
|
432
|
+
timeout = timer.setTimeout(() => resolve(null), FP_SIGNALS_WAIT_MS);
|
|
433
|
+
});
|
|
434
|
+
try {
|
|
435
|
+
return await Promise.race([getProvider().getFpSignals(), timedOut]);
|
|
436
|
+
} finally {
|
|
437
|
+
if (timeout !== void 0) timer.clearTimeout(timeout);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Passes one signed result of the SDK's runtime to TRI as an `fp_signals`
|
|
442
|
+
* event, unchanged. Returns `false` when TRI is not started for this copy
|
|
443
|
+
* ({@link isOwnTRIStarted}) or runs its own `fpsignals` collector.
|
|
444
|
+
*/
|
|
445
|
+
function addTRIFpSignals(signals) {
|
|
446
|
+
return isOwnTRIStarted() && getProvider().addFpSignals(signals);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The id of TRI's current activity, for the host's server to send to the
|
|
450
|
+
* Decision API. Read it right before each request and never keep it: the
|
|
451
|
+
* activity can change while the page is open (after 60 minutes, or on a
|
|
452
|
+
* back-forward cache restore). Returns `null` when TRI is not started or no
|
|
453
|
+
* activity is active. Synchronous; never throws and never loads TRI.
|
|
454
|
+
*/
|
|
455
|
+
function getTRIActivityId() {
|
|
456
|
+
return getProvider().getActivityId();
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Calls the provider's `setup()` with the given config. This is the step that
|
|
460
|
+
* lazy-loads `@incodetech/tri-sdk`, validates the config, and checks the
|
|
461
|
+
* backend collection-status endpoint. When `config.autostart` is `true` (the
|
|
462
|
+
* default), also calls `start()` internally and returns `'started'` on
|
|
463
|
+
* success. Pass `autostart: false` to receive `'ready'` and start explicitly.
|
|
464
|
+
*
|
|
465
|
+
* A page has one TRI, shared by every copy of the SDK on it. When another
|
|
466
|
+
* copy, or an earlier call, has set it up, this reuses it, with a `[TRI]`
|
|
467
|
+
* warning: the result is `'started'`, or `'ready'` when it is not running.
|
|
468
|
+
* A config that differs in where TRI sends what gets `'init-failed'` instead:
|
|
469
|
+
* another `apiURL`, a token for another organization or source, other
|
|
470
|
+
* `capture`, `layers`, `collectors` or `apiVersion`, or another `sanitizeUrl`.
|
|
471
|
+
* After a failed setup, a new call sets TRI up again.
|
|
472
|
+
*
|
|
473
|
+
* TRI reports the SDK as its host: `{ platform: 'sdk2', version }`.
|
|
474
|
+
*
|
|
475
|
+
* @param config - Resolved TRI config (`token` and `apiURL` required).
|
|
476
|
+
* @returns The resulting {@link TransactionalRiskIntelligenceState}.
|
|
477
|
+
*/
|
|
478
|
+
async function setupTRI(config) {
|
|
479
|
+
const { state, acceptedAt } = await acceptedSetup({
|
|
480
|
+
...config,
|
|
481
|
+
host: SDK_HOST
|
|
482
|
+
});
|
|
483
|
+
if (acceptedAt !== void 0) hostAcceptedAt = acceptedAt;
|
|
484
|
+
return state;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Begins behavioral data collection. Requires a prior successful `setupTRI()`
|
|
488
|
+
* call with `autostart: false`. Returns `'init-failed'` without starting if
|
|
489
|
+
* called before setup, or is a no-op if already started.
|
|
490
|
+
*
|
|
491
|
+
* @returns The resulting {@link TransactionalRiskIntelligenceState}.
|
|
492
|
+
*/
|
|
493
|
+
async function startTRI() {
|
|
494
|
+
return getProvider().start();
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Stops all TRI collectors and managers. Idempotent. No-op if TRI was never
|
|
498
|
+
* set up.
|
|
499
|
+
*/
|
|
500
|
+
async function stopTRI() {
|
|
501
|
+
return getProvider().stop();
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Resets the TRI SDK to its initial state, so that a subsequent `setupTRI` /
|
|
505
|
+
* `startTRI` can begin fresh. It resets the page's one TRI, also for the
|
|
506
|
+
* script tag and every other copy of the SDK on the page.
|
|
507
|
+
*/
|
|
508
|
+
async function resetTRI() {
|
|
509
|
+
return getProvider().reset();
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* The SDK's `reset()` step for TRI: gives back the TRI that `setup({ tri })`
|
|
513
|
+
* set up or reused, which resets it only when nothing else on the page holds
|
|
514
|
+
* it. A TRI the host set up through `@incodetech/core/tri`, or the script tag,
|
|
515
|
+
* keeps its activity, and the next session still links to it.
|
|
516
|
+
*/
|
|
517
|
+
function resetSdkOwnedTRI() {
|
|
518
|
+
sdkAcceptedAt = void 0;
|
|
519
|
+
sdkTRIRun += 1;
|
|
520
|
+
if (!sdkHoldsTRI) return;
|
|
521
|
+
sdkHoldsTRI = false;
|
|
522
|
+
getProvider().release(SDK_HOLDER);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Links the current Incode interview session to the active TRI activity.
|
|
526
|
+
*
|
|
527
|
+
* Returns `false` when the session token is missing or TRI has not been set up.
|
|
528
|
+
*
|
|
529
|
+
* @param sessionToken - Incode session JWT.
|
|
530
|
+
*/
|
|
531
|
+
async function linkSessionWithTRI(sessionToken) {
|
|
532
|
+
if (!sessionToken) return false;
|
|
533
|
+
return getProvider().linkInterview(sessionToken);
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* @private This function is not used outside of this file.
|
|
537
|
+
*
|
|
538
|
+
* Validates a {@link TransactionalRiskIntelligenceSetupConfig} before it is
|
|
539
|
+
* passed to {@link setupTRI}.
|
|
540
|
+
*
|
|
541
|
+
* Returns `null` (with a `[TRI]` warning) when a required field is missing.
|
|
542
|
+
* Returns `null` silently when `config` is `undefined` (intentional opt-out).
|
|
543
|
+
*
|
|
544
|
+
* @param config - Raw setup-time config from `SetupOptions.tri`.
|
|
545
|
+
*/
|
|
546
|
+
function resolveTRIConfig(config) {
|
|
547
|
+
if (!config) return null;
|
|
548
|
+
if (!config.token) {
|
|
549
|
+
console.warn("[TRI] Not initialized: token is required.");
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
if (!config.apiURL) {
|
|
553
|
+
console.warn("[TRI] Not initialized: apiURL is required.");
|
|
554
|
+
return null;
|
|
555
|
+
}
|
|
556
|
+
return config;
|
|
557
|
+
}
|
|
558
|
+
//#endregion
|
|
559
|
+
export { isOwnTRIStarted as a, markSdkTRIPending as c, resetTRI as d, setupTRI as f, initializeTRI as i, readTRIFpSignals as l, stopTRI as m, createTRISession as n, isTRIStarted as o, startTRI as p, getTRIActivityId as r, linkSessionWithTRI as s, addTRIFpSignals as t, resetSdkOwnedTRI as u };
|
package/dist/tri.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as setupTRI, c as TransactionalRiskIntelligenceSetupConfig, i as resetTRI, n as getTRIActivityId, o as startTRI, r as isTRIStarted, s as stopTRI, t as createTRISession } from "./index-
|
|
1
|
+
import { a as setupTRI, c as TransactionalRiskIntelligenceSetupConfig, i as resetTRI, n as getTRIActivityId, o as startTRI, r as isTRIStarted, s as stopTRI, t as createTRISession } from "./index-B3BI8mVu.js";
|
|
2
2
|
export { type TransactionalRiskIntelligenceSetupConfig, createTRISession, getTRIActivityId, isTRIStarted, resetTRI, setupTRI, startTRI, stopTRI };
|