@atlasauth/js 0.14.0 → 0.16.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 (63) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/account-hints.d.ts +53 -0
  3. package/dist/account-hints.js +114 -0
  4. package/dist/account-hints.js.map +1 -0
  5. package/dist/attempt.d.ts +3 -1
  6. package/dist/attempt.js.map +1 -1
  7. package/dist/captcha-controller.d.ts +21 -0
  8. package/dist/captcha-controller.js +35 -0
  9. package/dist/captcha-controller.js.map +1 -1
  10. package/dist/dev-browser.d.ts +30 -0
  11. package/dist/dev-browser.js +175 -0
  12. package/dist/dev-browser.js.map +1 -0
  13. package/dist/environment.d.ts +48 -0
  14. package/dist/environment.js +54 -1
  15. package/dist/environment.js.map +1 -1
  16. package/dist/fapi.d.ts +42 -3
  17. package/dist/fapi.js +94 -9
  18. package/dist/fapi.js.map +1 -1
  19. package/dist/impersonation.d.ts +44 -0
  20. package/dist/impersonation.js +47 -0
  21. package/dist/impersonation.js.map +1 -0
  22. package/dist/index.d.ts +11 -0
  23. package/dist/index.js +30 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/instance-settings.d.ts +7 -1
  26. package/dist/instance-settings.js +15 -1
  27. package/dist/instance-settings.js.map +1 -1
  28. package/dist/mfa-enrollment.d.ts +154 -0
  29. package/dist/mfa-enrollment.js +288 -0
  30. package/dist/mfa-enrollment.js.map +1 -0
  31. package/dist/organization-audit-log.d.ts +63 -0
  32. package/dist/organization-audit-log.js +96 -0
  33. package/dist/organization-audit-log.js.map +1 -0
  34. package/dist/organizations.d.ts +330 -0
  35. package/dist/organizations.js +375 -0
  36. package/dist/organizations.js.map +1 -0
  37. package/dist/passkey-sign-in.d.ts +40 -0
  38. package/dist/passkey-sign-in.js +41 -0
  39. package/dist/passkey-sign-in.js.map +1 -0
  40. package/dist/passkey-sign-up.d.ts +46 -0
  41. package/dist/passkey-sign-up.js +98 -0
  42. package/dist/passkey-sign-up.js.map +1 -0
  43. package/dist/password-reset.d.ts +12 -0
  44. package/dist/password-reset.js +15 -0
  45. package/dist/password-reset.js.map +1 -1
  46. package/dist/phone-numbers.d.ts +43 -0
  47. package/dist/phone-numbers.js +65 -0
  48. package/dist/phone-numbers.js.map +1 -0
  49. package/dist/profile.d.ts +24 -0
  50. package/dist/profile.js +24 -0
  51. package/dist/profile.js.map +1 -0
  52. package/dist/referral-detect.d.ts +90 -0
  53. package/dist/referral-detect.js +432 -0
  54. package/dist/referral-detect.js.map +1 -0
  55. package/dist/referral.d.ts +59 -29
  56. package/dist/referral.js +96 -47
  57. package/dist/referral.js.map +1 -1
  58. package/dist/sign-out-guard.d.ts +8 -0
  59. package/dist/sign-out-guard.js +15 -0
  60. package/dist/sign-out-guard.js.map +1 -1
  61. package/dist/version.d.ts +1 -1
  62. package/dist/version.js +1 -1
  63. package/package.json +2 -2
@@ -0,0 +1,432 @@
1
+ "use strict";
2
+ /**
3
+ * Referral sources and consent managers the SDK recognises on the page, so
4
+ * referral capture works with any referral program and any consent manager.
5
+ *
6
+ * Sources: the referral script or cookie a program puts on the merchant's
7
+ * site. Each reader returns `{code, clickId, anonId}` (and `capturedAt` when
8
+ * the source says when): the code is the referrer's, the ids are the
9
+ * visitor's (sent only with consent). The instance lists which sources to read
10
+ * (`browser_sources`), so one program's script never feeds another program's
11
+ * connection. A custom program passes its own reader as `referralSource`.
12
+ *
13
+ * Consent: the first consent manager found on the page decides whether the
14
+ * referral cookie's ids may be read, for the instance's consent category, else
15
+ * its fallback category. The visitor's answer in a consent manager is the
16
+ * source of truth: the app's own decision (`referralConsent`) applies only
17
+ * when no manager is on the page, or when the instance says the app decides
18
+ * (`consent_provider: 'app'`). Common names map onto each manager's own:
19
+ * `marketing` (also advertising / targeting), `statistics` (analytics /
20
+ * performance) and `preferences` (functional / personalization); any other
21
+ * name is looked up as the manager's own category id. IAB TCF v2 managers
22
+ * answer with Purpose 1 (store and access information on a device).
23
+ *
24
+ * Every reader is defensive: a missing, half-loaded or throwing script reads
25
+ * as "nothing here". The ES5 copy in the Atlas API (hosted pages and the Sign
26
+ * in with Atlas button) follows the same rules and is tested against the same
27
+ * fixtures.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.CONSENT_PROVIDERS = exports.REFERRAL_BROWSER_SOURCES = void 0;
31
+ exports.customReferral = customReferral;
32
+ exports.detectReferralSource = detectReferralSource;
33
+ exports.canonicalCategory = canonicalCategory;
34
+ exports.listenForTcfConsent = listenForTcfConsent;
35
+ exports.resetConsentDetection = resetConsentDetection;
36
+ exports.detectConsent = detectConsent;
37
+ exports.detectConsentProvider = detectConsentProvider;
38
+ const TOKEN = /^[A-Za-z0-9_-]{3,64}$/;
39
+ const isBag = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
40
+ const token = (v) => (typeof v === 'string' && TOKEN.test(v.trim()) ? v.trim() : null);
41
+ /** The browser sources the SDK reads, in the order it tries them. */
42
+ exports.REFERRAL_BROWSER_SOURCES = [
43
+ 'referally',
44
+ 'rewardful',
45
+ 'tolt',
46
+ 'promotekit',
47
+ 'firstpromoter',
48
+ 'partnerstack',
49
+ 'dub',
50
+ ];
51
+ /** The consent managers the SDK reads, in the order `auto` tries them. */
52
+ exports.CONSENT_PROVIDERS = [
53
+ 'cookiemunch',
54
+ 'onetrust',
55
+ 'cookiebot',
56
+ 'didomi',
57
+ 'usercentrics',
58
+ 'osano',
59
+ 'cookieyes',
60
+ 'complianz',
61
+ 'klaro',
62
+ 'tcf',
63
+ 'consent_mode',
64
+ ];
65
+ function prop(o, key) {
66
+ try {
67
+ return o != null && (typeof o === 'object' || typeof o === 'function') ? o[key] : undefined;
68
+ }
69
+ catch {
70
+ return undefined;
71
+ }
72
+ }
73
+ function call(fn, self, ...args) {
74
+ try {
75
+ return typeof fn === 'function' ? fn.apply(self, args) : undefined;
76
+ }
77
+ catch {
78
+ return undefined;
79
+ }
80
+ }
81
+ function cookie(cookies, name) {
82
+ if (!cookies)
83
+ return null;
84
+ for (const part of cookies.split(';')) {
85
+ const p = part.trim();
86
+ if (p.startsWith(`${name}=`)) {
87
+ const raw = p.slice(name.length + 1);
88
+ try {
89
+ return decodeURIComponent(raw);
90
+ }
91
+ catch {
92
+ return raw;
93
+ }
94
+ }
95
+ }
96
+ return null;
97
+ }
98
+ function time(v) {
99
+ if (typeof v === 'number' && Number.isFinite(v) && v > 0)
100
+ return new Date(v < 1e12 ? v * 1000 : v).toISOString();
101
+ if (typeof v === 'string' && v && v.length <= 40) {
102
+ if (/^\d{9,13}$/.test(v))
103
+ return time(Number(v));
104
+ const t = Date.parse(v);
105
+ if (Number.isFinite(t))
106
+ return new Date(t).toISOString();
107
+ }
108
+ return undefined;
109
+ }
110
+ function found(source, code, clickId, anonId, at) {
111
+ const out = { source, code: token(code), clickId: token(clickId), anonId: token(anonId) };
112
+ const ts = time(at);
113
+ if (ts)
114
+ out.capturedAt = ts;
115
+ return out.code || out.clickId || out.anonId ? out : null;
116
+ }
117
+ /** Each known source: where its script or cookie keeps the referral. */
118
+ const READERS = {
119
+ // Referalli's aff.js: aff.getReferral() → {code, clickId, anonId, ts}.
120
+ referally: ({ win }) => {
121
+ const aff = prop(win, 'aff');
122
+ const r = call(prop(aff, 'getReferral'), aff);
123
+ if (!isBag(r))
124
+ return null;
125
+ return found('referally', r.code, r.clickId ?? r.click_id, r.anonId ?? r.anon_id, r.ts);
126
+ },
127
+ // Rewardful's rw.js: Rewardful.referral (the referral id) and Rewardful.affiliate.token (the link code).
128
+ rewardful: ({ win }) => {
129
+ const rw = prop(win, 'Rewardful');
130
+ return found('rewardful', prop(prop(rw, 'affiliate'), 'token'), prop(rw, 'referral'), null);
131
+ },
132
+ // Tolt's script: window.tolt_referral (the referral id).
133
+ tolt: ({ win }) => found('tolt', null, prop(win, 'tolt_referral'), null),
134
+ // PromoteKit's script: window.promotekit_referral (the referral id).
135
+ promotekit: ({ win }) => found('promotekit', null, prop(win, 'promotekit_referral'), null),
136
+ // FirstPromoter's cookies: _fprom_tid (tracking id) and _fprom_ref (the referral code).
137
+ firstpromoter: ({ cookies }) => found('firstpromoter', cookie(cookies, '_fprom_ref'), cookie(cookies, '_fprom_tid'), null),
138
+ // PartnerStack's cookies: ps_xid (click id) and ps_partner_key (the partner's key).
139
+ partnerstack: ({ cookies }) => found('partnerstack', cookie(cookies, 'ps_partner_key'), cookie(cookies, 'ps_xid'), null),
140
+ // Dub's analytics script cookie: dub_id (click id).
141
+ dub: ({ cookies }) => found('dub', null, cookie(cookies, 'dub_id'), null),
142
+ };
143
+ /** The app's own reader, as a detected referral (source `custom`). Never throws. */
144
+ function customReferral(reader) {
145
+ if (typeof reader !== 'function')
146
+ return null;
147
+ let r;
148
+ try {
149
+ r = reader();
150
+ }
151
+ catch {
152
+ return null;
153
+ }
154
+ if (!isBag(r))
155
+ return null;
156
+ return found('custom', r.code, r.clickId ?? r.click_id, r.anonId ?? r.anon_id, r.capturedAt ?? r.ts);
157
+ }
158
+ /** The first of `sources` with a referral on the page, or null. Unknown ids are skipped. */
159
+ function detectReferralSource(page, sources) {
160
+ for (const id of sources) {
161
+ const read = READERS[id];
162
+ if (!read)
163
+ continue;
164
+ let r = null;
165
+ try {
166
+ r = read(page);
167
+ }
168
+ catch {
169
+ r = null;
170
+ }
171
+ if (r)
172
+ return r;
173
+ }
174
+ return null;
175
+ }
176
+ const ALIASES = {
177
+ necessary: 'necessary',
178
+ essential: 'necessary',
179
+ strictly_necessary: 'necessary',
180
+ preferences: 'preferences',
181
+ functional: 'preferences',
182
+ functionality: 'preferences',
183
+ personalization: 'preferences',
184
+ statistics: 'statistics',
185
+ analytics: 'statistics',
186
+ performance: 'statistics',
187
+ marketing: 'marketing',
188
+ advertising: 'marketing',
189
+ advertisement: 'marketing',
190
+ targeting: 'marketing',
191
+ ads: 'marketing',
192
+ };
193
+ /** A consent category's common meaning, if it has one. */
194
+ function canonicalCategory(name) {
195
+ return ALIASES[name.trim().toLowerCase()] ?? null;
196
+ }
197
+ const bool = (v) => (typeof v === 'boolean' ? v : undefined);
198
+ /** Look a category up by its own name, then by its common meaning's native name. */
199
+ function byName(native, lookup) {
200
+ return (_win, category) => {
201
+ const own = lookup(category);
202
+ if (own !== undefined)
203
+ return own;
204
+ const c = canonicalCategory(category);
205
+ const mapped = c ? native[c] : undefined;
206
+ return mapped ? lookup(mapped) : undefined;
207
+ };
208
+ }
209
+ /** The latest IAB TCF data, kept by a listener registered when the SDK loads. */
210
+ let tcfCache = null;
211
+ let tcfListening = false;
212
+ /**
213
+ * Start listening to an IAB TCF v2 manager (`__tcfapi`), so its answer is
214
+ * ready synchronously when a sign-in starts. Safe to call more than once.
215
+ */
216
+ function listenForTcfConsent(win) {
217
+ const api = prop(win, '__tcfapi');
218
+ if (tcfListening || typeof api !== 'function')
219
+ return;
220
+ tcfListening = true;
221
+ call(api, win, 'addEventListener', 2, (data, ok) => {
222
+ if (ok && isBag(data))
223
+ tcfCache = data;
224
+ });
225
+ }
226
+ /** Forget the cached TCF data (tests). */
227
+ function resetConsentDetection() {
228
+ tcfCache = null;
229
+ tcfListening = false;
230
+ }
231
+ function tcfData(win) {
232
+ if (tcfCache)
233
+ return tcfCache;
234
+ // Most managers answer getTCData synchronously once loaded.
235
+ let data = null;
236
+ call(prop(win, '__tcfapi'), win, 'getTCData', 2, (d, ok) => {
237
+ if (ok && isBag(d))
238
+ data = d;
239
+ });
240
+ return data;
241
+ }
242
+ const STANDARD = { necessary: 'necessary', preferences: 'preferences', statistics: 'statistics', marketing: 'marketing' };
243
+ const has = (list, k) => Array.isArray(list) && list.includes(k);
244
+ const MANAGERS = {
245
+ // Cookie Munch: CookieMunch.consent → {necessary, preferences, statistics, marketing, <custom>…}.
246
+ cookiemunch: {
247
+ present: (w) => isBag(prop(prop(w, 'CookieMunch'), 'consent')),
248
+ ask: (w, category) => {
249
+ const c = prop(prop(w, 'CookieMunch'), 'consent');
250
+ return byName(STANDARD, (k) => bool(prop(c, k)))(w, category);
251
+ },
252
+ },
253
+ // OneTrust: OnetrustActiveGroups = ",C0001,C0002,…" (the groups consented to).
254
+ onetrust: {
255
+ present: (w) => typeof (prop(w, 'OnetrustActiveGroups') ?? prop(w, 'OptanonActiveGroups')) === 'string',
256
+ ask: (w, category) => {
257
+ const groups = String(prop(w, 'OnetrustActiveGroups') ?? prop(w, 'OptanonActiveGroups') ?? '')
258
+ .split(',')
259
+ .map((g) => g.trim())
260
+ .filter(Boolean);
261
+ // A group id (C0004, or a custom one the page uses) is answered by membership; other names are unknown.
262
+ return byName({ necessary: 'C0001', statistics: 'C0002', preferences: 'C0003', marketing: 'C0004' }, (k) => /^C\d{4}$/.test(k) || groups.includes(k) ? groups.includes(k) : undefined)(w, category);
263
+ },
264
+ },
265
+ // Cookiebot: Cookiebot.consent → {necessary, preferences, statistics, marketing}. Cookie Munch also
266
+ // publishes a Cookiebot alias, so Cookiebot counts only without Cookie Munch.
267
+ cookiebot: {
268
+ present: (w) => !prop(w, 'CookieMunch') && isBag(prop(prop(w, 'Cookiebot'), 'consent')),
269
+ ask: (w, category) => {
270
+ const c = prop(prop(w, 'Cookiebot'), 'consent');
271
+ return byName(STANDARD, (k) => bool(prop(c, k)))(w, category);
272
+ },
273
+ },
274
+ // Didomi: Didomi.getUserStatus().purposes.global.{enabled, disabled}. Marketing maps to
275
+ // Purpose 1 ("cookies": store and access information on a device).
276
+ didomi: {
277
+ present: (w) => typeof prop(prop(w, 'Didomi'), 'getUserStatus') === 'function',
278
+ ask: (w, category) => {
279
+ const didomi = prop(w, 'Didomi');
280
+ const global = prop(prop(call(prop(didomi, 'getUserStatus'), didomi), 'purposes'), 'global');
281
+ const enabled = prop(global, 'enabled');
282
+ const disabled = prop(global, 'disabled');
283
+ return byName({ marketing: 'cookies', statistics: 'measure_content_performance' }, (k) => has(enabled, k) ? true : has(disabled, k) ? false : undefined)(w, category);
284
+ },
285
+ },
286
+ // Usercentrics: UC_UI.getServicesBaseInfo() → [{categorySlug, consent: {status}}]; a category is
287
+ // granted when every service in it is.
288
+ usercentrics: {
289
+ present: (w) => typeof prop(prop(w, 'UC_UI'), 'getServicesBaseInfo') === 'function',
290
+ ask: (w, category) => {
291
+ const uc = prop(w, 'UC_UI');
292
+ const services = call(prop(uc, 'getServicesBaseInfo'), uc);
293
+ if (!Array.isArray(services))
294
+ return undefined;
295
+ return byName({ necessary: 'essential', preferences: 'functional', statistics: 'functional', marketing: 'marketing' }, (slug) => {
296
+ const inCategory = services.filter((s) => prop(s, 'categorySlug') === slug);
297
+ return inCategory.length ? inCategory.every((s) => prop(prop(s, 'consent'), 'status') === true) : undefined;
298
+ })(w, category);
299
+ },
300
+ },
301
+ // Osano: Osano.cm.getConsent() → {MARKETING: 'ACCEPT' | 'DENY', ANALYTICS, PERSONALIZATION, ESSENTIAL}.
302
+ osano: {
303
+ present: (w) => typeof prop(prop(prop(w, 'Osano'), 'cm'), 'getConsent') === 'function',
304
+ ask: (w, category) => {
305
+ const cm = prop(prop(w, 'Osano'), 'cm');
306
+ const consent = call(prop(cm, 'getConsent'), cm);
307
+ return byName({ necessary: 'ESSENTIAL', preferences: 'PERSONALIZATION', statistics: 'ANALYTICS', marketing: 'MARKETING' }, (k) => {
308
+ const v = prop(consent, k) ?? prop(consent, k.toUpperCase());
309
+ return v === 'ACCEPT' ? true : v === 'DENY' ? false : undefined;
310
+ })(w, category);
311
+ },
312
+ },
313
+ // CookieYes: getCkyConsent().categories → {necessary, functional, analytics, performance, advertisement}.
314
+ cookieyes: {
315
+ present: (w) => typeof prop(w, 'getCkyConsent') === 'function',
316
+ ask: (w, category) => {
317
+ const categories = prop(call(prop(w, 'getCkyConsent'), w), 'categories');
318
+ return byName({ necessary: 'necessary', preferences: 'functional', statistics: 'analytics', marketing: 'advertisement' }, (k) => bool(prop(categories, k)))(w, category);
319
+ },
320
+ },
321
+ // Complianz: cmplz_has_consent(category) → boolean.
322
+ complianz: {
323
+ present: (w) => typeof prop(w, 'cmplz_has_consent') === 'function',
324
+ ask: (w, category) => byName({ necessary: 'functional', preferences: 'preferences', statistics: 'statistics', marketing: 'marketing' }, (k) => bool(call(prop(w, 'cmplz_has_consent'), w, k)))(w, category),
325
+ },
326
+ // Klaro: klaro.getManager().consents → {service: boolean}; the category names a service.
327
+ klaro: {
328
+ present: (w) => typeof prop(prop(w, 'klaro'), 'getManager') === 'function',
329
+ ask: (w, category) => {
330
+ const klaro = prop(w, 'klaro');
331
+ const consents = prop(call(prop(klaro, 'getManager'), klaro), 'consents');
332
+ return bool(prop(consents, category));
333
+ },
334
+ },
335
+ // IAB TCF v2: Purpose 1 (store and access information on a device) governs the cookie; where
336
+ // GDPR doesn't apply, no consent is needed.
337
+ tcf: {
338
+ present: (w) => typeof prop(w, '__tcfapi') === 'function',
339
+ ask: (w) => {
340
+ const data = tcfData(w);
341
+ if (!data)
342
+ return undefined;
343
+ if (data.gdprApplies === false)
344
+ return true;
345
+ return bool(prop(prop(prop(data, 'purpose'), 'consents'), '1')) ?? false;
346
+ },
347
+ },
348
+ // Google Consent Mode: ad_storage / analytics_storage / functionality_storage, updated else default.
349
+ consent_mode: {
350
+ present: (w) => isBag(prop(prop(prop(w, 'google_tag_data'), 'ics'), 'entries')),
351
+ ask: (w, category) => {
352
+ const entries = prop(prop(prop(w, 'google_tag_data'), 'ics'), 'entries');
353
+ return byName({ preferences: 'functionality_storage', statistics: 'analytics_storage', marketing: 'ad_storage' }, (k) => {
354
+ const e = prop(entries, k);
355
+ return bool(prop(e, 'update')) ?? bool(prop(e, 'default'));
356
+ })(w, category);
357
+ },
358
+ },
359
+ };
360
+ function appDecision(appConsent) {
361
+ let d = appConsent;
362
+ if (typeof appConsent === 'function') {
363
+ try {
364
+ d = appConsent();
365
+ }
366
+ catch {
367
+ d = undefined;
368
+ }
369
+ }
370
+ if (d === 'granted' || d === true)
371
+ return true;
372
+ if (d === 'denied' || d === false)
373
+ return false;
374
+ return undefined;
375
+ }
376
+ /**
377
+ * Whether the referral cookie's ids may be read, and who decided. A consent
378
+ * manager on the page decides (`provider`: `auto` tries each in order, a
379
+ * manager id asks only that one); a manager that doesn't know either category
380
+ * answers no. With no manager, or `provider: 'app'`, the app's definite answer
381
+ * decides; else no.
382
+ */
383
+ function detectConsent(win, categories, options = {}) {
384
+ const provider = options.provider || 'auto';
385
+ const fromApp = () => {
386
+ const app = appDecision(options.appConsent);
387
+ return app === undefined ? { granted: false, by: 'none' } : { granted: app, by: 'app' };
388
+ };
389
+ if (provider === 'app')
390
+ return fromApp();
391
+ const ids = provider === 'auto' ? exports.CONSENT_PROVIDERS : [provider];
392
+ const names = categories.filter((c) => typeof c === 'string' && c.trim().length > 0);
393
+ for (const id of ids) {
394
+ const m = MANAGERS[id];
395
+ let present = false;
396
+ try {
397
+ present = !!m && m.present(win);
398
+ }
399
+ catch {
400
+ present = false;
401
+ }
402
+ if (!m || !present)
403
+ continue;
404
+ for (const name of names) {
405
+ let v;
406
+ try {
407
+ v = m.ask(win, name);
408
+ }
409
+ catch {
410
+ v = undefined;
411
+ }
412
+ if (v !== undefined)
413
+ return { granted: v, by: id };
414
+ }
415
+ return { granted: false, by: id };
416
+ }
417
+ return fromApp();
418
+ }
419
+ /** Which consent manager is on the page (`auto` order), or null. For diagnostics. */
420
+ function detectConsentProvider(win) {
421
+ for (const id of exports.CONSENT_PROVIDERS) {
422
+ try {
423
+ if (MANAGERS[id].present(win))
424
+ return id;
425
+ }
426
+ catch {
427
+ // keep looking
428
+ }
429
+ }
430
+ return null;
431
+ }
432
+ //# sourceMappingURL=referral-detect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"referral-detect.js","sourceRoot":"","sources":["../src/referral-detect.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;AAuIH,wCAUC;AAGD,oDAaC;AAwBD,8CAEC;AA+BD,kDAOC;AAGD,sDAGC;AAwKD,sCAkCC;AAGD,sDASC;AA3bD,MAAM,KAAK,GAAG,uBAAuB,CAAC;AAGtC,MAAM,KAAK,GAAG,CAAC,CAAU,E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AC;gBAAE,OAAO,EAAE,CAAC;QAC3C,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -6,25 +6,31 @@
6
6
  * What is captured, when the instance has referrals on (`referrals` in
7
7
  * `GET /v1/client/environment`): ONE source, in precedence order, never
8
8
  * mixing fields across sources:
9
- * 1. the page's referral script, `window.aff.getReferral()`
10
- * (`{code, clickId, anonId, ts}`), or explicit `ref_*` parameters
11
- * (`ref`, `ref_click_id`, `ref_anon_id`, `ref_consent`, `ref_captured_at`)
12
- * on the page URL;
13
- * 2. the referral code from the page URL — the instance's URL parameters
9
+ * 1. the app's own reader (`referralSource`), for any referral program;
10
+ * 2. a referral program's script on the page, among the instance's
11
+ * `browser_sources` (Referalli's `aff.getReferral()`, Rewardful, Tolt,
12
+ * PromoteKit; see ./referral-detect);
13
+ * 3. explicit `ref_*` parameters (`ref`, `ref_click_id`, `ref_anon_id`,
14
+ * `ref_consent`, `ref_captured_at`) on the page URL;
15
+ * 4. the referral code from the page URL — the instance's URL parameters
14
16
  * (default `ref`, `via`, `aff`) on the current page, the page the SDK first
15
17
  * loaded on, and the `redirect_url` / `after_url` query of either;
16
- * 3. the referral platform's first-party tracking cookie (the instance's
17
- * `context_cookie`): JSON or URL-encoded JSON
18
- * `{code?, clickId?, anonId?, ts?, exp?}`, or a plain click id. An expired
19
- * cookie is ignored.
18
+ * 5. the instance's tracking cookie (`context_cookie`): JSON or URL-encoded
19
+ * JSON `{code?, clickId?, anonId?, ts?, exp?}`, or a plain click id. An
20
+ * expired cookie is ignored;
21
+ * 6. a referral program's own cookies, among `browser_sources`
22
+ * (FirstPromoter, PartnerStack, Dub).
20
23
  * Click and anonymous ids are sent only with consent; without it only the
21
- * code goes.
24
+ * code goes. The capture says where it came from (`source`) and who decided
25
+ * consent (`consent_by`), for the delivery log.
22
26
  *
23
- * Consent: when Cookie Munch is on the page (`window.CookieMunch`), the cookie
24
- * is read only when the instance's consent category is granted (else its
25
- * fallback category). Without a consent manager the cookie is read only when
26
- * the app says its own consent manager allowed it (`referralConsent:
27
- * 'granted'`). Otherwise the URL code alone is sent. The SDK never writes the
27
+ * Consent: the consent manager on the page decides (the instance's
28
+ * `consent_provider`: `auto` finds Cookie Munch, OneTrust, Cookiebot, Didomi,
29
+ * Usercentrics, Osano, CookieYes, Complianz, Klaro, any IAB TCF v2 manager or
30
+ * Google Consent Mode), for the instance's consent category, else its fallback
31
+ * category. With no manager on the page, or `consent_provider: 'app'`, the
32
+ * app's own decision (`referralConsent`) applies. Otherwise only the code is
33
+ * sent. The SDK never writes a
28
34
  * cookie. Nothing captured is trusted: the server re-validates every field.
29
35
  *
30
36
  * Opt out with `referral: false` (per client, or page-wide with
@@ -34,9 +40,15 @@
34
40
  * `ref_*` query parameters: {@link signIn} / {@link signUp},
35
41
  * {@link withReferralParams} and {@link referralParams}.
36
42
  */
43
+ import { type ReferralSourceReader } from './referral-detect';
44
+ export type { ReferralSourceReader } from './referral-detect';
37
45
  /** The instance's public referral settings, camelCased. */
38
46
  export interface ReferralConfig {
39
47
  enabled: boolean;
48
+ /** The referral programs' scripts and cookies to read (`browser_sources`), in order. */
49
+ sources: string[];
50
+ /** Which consent manager decides: `auto`, a manager id, or `app` (only the app's `referralConsent`). */
51
+ consentProvider: string;
40
52
  /** URL query parameters that carry a code, in priority order. */
41
53
  urlParams: string[];
42
54
  /** The tracking cookie to read under consent; null = never read a cookie. */
@@ -58,6 +70,10 @@ export interface ReferralCapture {
58
70
  consent: 'granted' | 'not_required';
59
71
  /** ISO 8601. */
60
72
  captured_at: string;
73
+ /** Where it came from: `custom`, a program id (e.g. `rewardful`), `url` or `cookie`. */
74
+ source?: string;
75
+ /** Who decided consent for the ids: `app`, `url`, a consent manager id, or `none`. */
76
+ consent_by?: string;
61
77
  }
62
78
  /**
63
79
  * The app's own consent decision for the referral cookie, used only when no
@@ -71,6 +87,11 @@ export interface ReferralCaptureOptions {
71
87
  referral?: false | 'auto' | undefined;
72
88
  /** See {@link ReferralConsent}. */
73
89
  referralConsent?: ReferralConsent;
90
+ /**
91
+ * Your own reader, for a referral program the SDK doesn't know: return
92
+ * `{code, clickId, anonId}` (any of them) or null. Tried before everything else.
93
+ */
94
+ referralSource?: ReferralSourceReader;
74
95
  }
75
96
  export declare const DISABLED_REFERRAL_CONFIG: Readonly<ReferralConfig>;
76
97
  /** A well-formed code / click id / anonymous id, or null. */
@@ -104,9 +125,11 @@ export declare function parseReferralCookie(value: string | null | undefined, no
104
125
  /** A cookie's value from a `document.cookie` string, or null. */
105
126
  export declare function readCookieValue(cookies: string | null | undefined, name: string): string | null;
106
127
  /**
107
- * Whether the referral cookie may be read. Cookie Munch on the page decides
108
- * when present (the instance's category, else its fallback category); else
109
- * the app's own `referralConsent`.
128
+ * Whether the referral cookie may be read, with only Cookie Munch to ask (the
129
+ * shape before consent managers were detected generally). Cookie Munch on the
130
+ * page decides when present (the instance's category, else its fallback
131
+ * category); else the app's own `referralConsent`. See {@link detectConsent}
132
+ * for every manager.
110
133
  */
111
134
  export declare function referralConsentGranted(config: Pick<ReferralConfig, 'consentCategory' | 'consentFallbackCategory'>, cookieMunch: unknown, appConsent: ReferralConsent | undefined): boolean;
112
135
  /** Everything {@link captureReferral} reads from the page. */
@@ -115,9 +138,11 @@ export interface ReferralPage {
115
138
  searches: readonly string[];
116
139
  /** `document.cookie`. */
117
140
  cookies?: string | null;
118
- /** `window.CookieMunch`, if any. */
141
+ /** `window`: its referral scripts and consent manager are read. */
142
+ win?: unknown;
143
+ /** `window.CookieMunch`, when no `win` is given (older callers). */
119
144
  cookieMunch?: unknown;
120
- /** `window.aff`, the page's referral script, if any (`getReferral()` → `{code, clickId, anonId, ts}`). */
145
+ /** `window.aff`, when no `win` is given (older callers). */
121
146
  aff?: unknown;
122
147
  /** Base for resolving a relative redirect_url. */
123
148
  base?: string;
@@ -132,13 +157,12 @@ export declare function explicitReferralFromSearch(search: string | null | undef
132
157
  }) | null;
133
158
  /**
134
159
  * Capture the referral for a request, or null when there is nothing to send.
135
- * Pure. One source wins, in order: the page's referral script, explicit
136
- * `ref_*` URL parameters, a code in the instance's URL parameters, the
137
- * tracking cookie. Fields are never mixed across sources. Ids need consent
138
- * (Cookie Munch, the app's `referralConsent`, or `ref_consent=granted` on an
139
- * explicit URL).
160
+ * Pure. One source wins, in the order described at the top of this module;
161
+ * fields are never mixed across sources. Ids need consent: the app's
162
+ * `referralConsent`, `ref_consent=granted` on an explicit URL, or the consent
163
+ * manager on the page.
140
164
  */
141
- export declare function captureReferral(config: ReferralConfig, page: ReferralPage, appConsent?: ReferralConsent): ReferralCapture | null;
165
+ export declare function captureReferral(config: ReferralConfig, page: ReferralPage, appConsent?: ReferralConsent, customSource?: ReferralSourceReader): ReferralCapture | null;
142
166
  /** Whether a FAPI POST path starts or continues a sign-in / sign-up (and so takes `referral`). */
143
167
  export declare function acceptsReferral(path: string): boolean;
144
168
  /**
@@ -191,11 +215,17 @@ export interface ReferralRedirectOptions {
191
215
  referral?: false | 'auto';
192
216
  /**
193
217
  * The app's consent for referral tracking (click and anonymous ids). When
194
- * omitted, the page-wide `referralConsent` applies, else Cookie Munch on the
195
- * page (`referrals`, else `marketing`), else no consent (code only).
218
+ * omitted, the page-wide `referralConsent` applies, else the consent manager
219
+ * on the page (`referrals`, else `marketing`), else no consent (code only).
196
220
  */
197
221
  consent?: ReferralConsent;
198
- /** The instance's config, when the app has it; defaults to `ref` / `via` / `aff` and no cookie. */
222
+ /** Your own reader for a referral program the SDK doesn't know (see {@link ReferralCaptureOptions.referralSource}). */
223
+ source?: ReferralSourceReader;
224
+ /**
225
+ * The instance's config, when the app has it. Defaults: `ref` / `via` /
226
+ * `aff`, no tracking cookie, every known referral script and cookie, and
227
+ * any consent manager.
228
+ */
199
229
  config?: ReferralConfig;
200
230
  }
201
231
  /**