@referalli/sdk 0.0.0-stage → 0.3.20
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/CHANGELOG.md +128 -0
- package/LICENSE +21 -0
- package/README.md +236 -2
- package/dist/cjs/attribution.d.ts +105 -0
- package/dist/cjs/attribution.js +200 -0
- package/dist/cjs/browser.d.ts +41 -0
- package/dist/cjs/browser.js +88 -0
- package/dist/cjs/client.d.ts +97 -0
- package/dist/cjs/client.js +301 -0
- package/dist/cjs/consent/adapters/cookiebot.d.ts +7 -0
- package/dist/cjs/consent/adapters/cookiebot.js +49 -0
- package/dist/cjs/consent/adapters/cookiemunch.d.ts +8 -0
- package/dist/cjs/consent/adapters/cookiemunch.js +56 -0
- package/dist/cjs/consent/adapters/custom.d.ts +8 -0
- package/dist/cjs/consent/adapters/custom.js +39 -0
- package/dist/cjs/consent/adapters/didomi.d.ts +9 -0
- package/dist/cjs/consent/adapters/didomi.js +67 -0
- package/dist/cjs/consent/adapters/gcm.d.ts +10 -0
- package/dist/cjs/consent/adapters/gcm.js +78 -0
- package/dist/cjs/consent/adapters/gpp.d.ts +9 -0
- package/dist/cjs/consent/adapters/gpp.js +92 -0
- package/dist/cjs/consent/adapters/none.d.ts +3 -0
- package/dist/cjs/consent/adapters/none.js +30 -0
- package/dist/cjs/consent/adapters/onetrust.d.ts +8 -0
- package/dist/cjs/consent/adapters/onetrust.js +71 -0
- package/dist/cjs/consent/adapters/osano.d.ts +9 -0
- package/dist/cjs/consent/adapters/osano.js +71 -0
- package/dist/cjs/consent/adapters/tcf.d.ts +8 -0
- package/dist/cjs/consent/adapters/tcf.js +79 -0
- package/dist/cjs/consent/adapters/termly.d.ts +10 -0
- package/dist/cjs/consent/adapters/termly.js +61 -0
- package/dist/cjs/consent/adapters/usercentrics.d.ts +9 -0
- package/dist/cjs/consent/adapters/usercentrics.js +106 -0
- package/dist/cjs/consent/conformance.d.ts +22 -0
- package/dist/cjs/consent/conformance.js +33 -0
- package/dist/cjs/consent/gate.d.ts +23 -0
- package/dist/cjs/consent/gate.js +220 -0
- package/dist/cjs/consent/port.d.ts +105 -0
- package/dist/cjs/consent/port.js +72 -0
- package/dist/cjs/consent/registry.d.ts +17 -0
- package/dist/cjs/consent/registry.js +61 -0
- package/dist/cjs/consent/served.d.ts +15 -0
- package/dist/cjs/consent/served.js +26 -0
- package/dist/cjs/core.d.ts +77 -0
- package/dist/cjs/core.js +64 -0
- package/dist/cjs/errors.d.ts +42 -0
- package/dist/cjs/errors.generated.d.ts +183 -0
- package/dist/cjs/errors.generated.js +279 -0
- package/dist/cjs/errors.js +47 -0
- package/dist/cjs/generated.d.ts +15146 -0
- package/dist/cjs/generated.js +625 -0
- package/dist/cjs/index.d.ts +22 -0
- package/dist/cjs/index.js +93 -0
- package/dist/cjs/mobile.d.ts +66 -0
- package/dist/cjs/mobile.js +69 -0
- package/dist/cjs/node.d.ts +209 -0
- package/dist/cjs/node.js +140 -0
- package/dist/cjs/outbox.d.ts +186 -0
- package/dist/cjs/outbox.js +324 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/resources.generated.d.ts +6002 -0
- package/dist/cjs/resources.generated.js +2090 -0
- package/dist/cjs/served.d.ts +25 -0
- package/dist/cjs/served.js +214 -0
- package/dist/cjs/sha256.d.ts +2 -0
- package/dist/cjs/sha256.js +86 -0
- package/dist/cjs/snippet.d.ts +99 -0
- package/dist/cjs/snippet.js +213 -0
- package/dist/cjs/stripe-events.d.ts +25 -0
- package/dist/cjs/stripe-events.js +117 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/webhooks.d.ts +76 -0
- package/dist/cjs/webhooks.js +159 -0
- package/dist/esm/attribution.d.ts +105 -0
- package/dist/esm/attribution.js +186 -0
- package/dist/esm/browser.d.ts +41 -0
- package/dist/esm/browser.js +68 -0
- package/dist/esm/client.d.ts +97 -0
- package/dist/esm/client.js +297 -0
- package/dist/esm/consent/adapters/cookiebot.d.ts +7 -0
- package/dist/esm/consent/adapters/cookiebot.js +46 -0
- package/dist/esm/consent/adapters/cookiemunch.d.ts +8 -0
- package/dist/esm/consent/adapters/cookiemunch.js +53 -0
- package/dist/esm/consent/adapters/custom.d.ts +8 -0
- package/dist/esm/consent/adapters/custom.js +36 -0
- package/dist/esm/consent/adapters/didomi.d.ts +9 -0
- package/dist/esm/consent/adapters/didomi.js +64 -0
- package/dist/esm/consent/adapters/gcm.d.ts +10 -0
- package/dist/esm/consent/adapters/gcm.js +75 -0
- package/dist/esm/consent/adapters/gpp.d.ts +9 -0
- package/dist/esm/consent/adapters/gpp.js +89 -0
- package/dist/esm/consent/adapters/none.d.ts +3 -0
- package/dist/esm/consent/adapters/none.js +27 -0
- package/dist/esm/consent/adapters/onetrust.d.ts +8 -0
- package/dist/esm/consent/adapters/onetrust.js +68 -0
- package/dist/esm/consent/adapters/osano.d.ts +9 -0
- package/dist/esm/consent/adapters/osano.js +68 -0
- package/dist/esm/consent/adapters/tcf.d.ts +8 -0
- package/dist/esm/consent/adapters/tcf.js +76 -0
- package/dist/esm/consent/adapters/termly.d.ts +10 -0
- package/dist/esm/consent/adapters/termly.js +58 -0
- package/dist/esm/consent/adapters/usercentrics.d.ts +9 -0
- package/dist/esm/consent/adapters/usercentrics.js +103 -0
- package/dist/esm/consent/conformance.d.ts +22 -0
- package/dist/esm/consent/conformance.js +30 -0
- package/dist/esm/consent/gate.d.ts +23 -0
- package/dist/esm/consent/gate.js +217 -0
- package/dist/esm/consent/port.d.ts +105 -0
- package/dist/esm/consent/port.js +67 -0
- package/dist/esm/consent/registry.d.ts +17 -0
- package/dist/esm/consent/registry.js +55 -0
- package/dist/esm/consent/served.d.ts +15 -0
- package/dist/esm/consent/served.js +22 -0
- package/dist/esm/core.d.ts +77 -0
- package/dist/esm/core.js +60 -0
- package/dist/esm/errors.d.ts +42 -0
- package/dist/esm/errors.generated.d.ts +183 -0
- package/dist/esm/errors.generated.js +231 -0
- package/dist/esm/errors.js +40 -0
- package/dist/esm/generated.d.ts +15146 -0
- package/dist/esm/generated.js +622 -0
- package/dist/esm/index.d.ts +22 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/mobile.d.ts +66 -0
- package/dist/esm/mobile.js +64 -0
- package/dist/esm/node.d.ts +209 -0
- package/dist/esm/node.js +135 -0
- package/dist/esm/outbox.d.ts +186 -0
- package/dist/esm/outbox.js +316 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/resources.generated.d.ts +6002 -0
- package/dist/esm/resources.generated.js +2086 -0
- package/dist/esm/served.d.ts +25 -0
- package/dist/esm/served.js +207 -0
- package/dist/esm/sha256.d.ts +2 -0
- package/dist/esm/sha256.js +82 -0
- package/dist/esm/snippet.d.ts +99 -0
- package/dist/esm/snippet.js +210 -0
- package/dist/esm/stripe-events.d.ts +25 -0
- package/dist/esm/stripe-events.js +114 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/webhooks.d.ts +76 -0
- package/dist/esm/webhooks.js +153 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/package.json +105 -4
- package/src/attribution.ts +216 -0
- package/src/browser.ts +107 -0
- package/src/client.ts +351 -0
- package/src/codegen.ts +130 -0
- package/src/consent/adapters/cookiebot.ts +42 -0
- package/src/consent/adapters/cookiemunch.ts +49 -0
- package/src/consent/adapters/custom.ts +37 -0
- package/src/consent/adapters/didomi.ts +59 -0
- package/src/consent/adapters/gcm.ts +68 -0
- package/src/consent/adapters/gpp.ts +81 -0
- package/src/consent/adapters/none.ts +28 -0
- package/src/consent/adapters/onetrust.ts +64 -0
- package/src/consent/adapters/osano.ts +63 -0
- package/src/consent/adapters/tcf.ts +67 -0
- package/src/consent/adapters/termly.ts +54 -0
- package/src/consent/adapters/usercentrics.ts +97 -0
- package/src/consent/conformance.ts +47 -0
- package/src/consent/gate.ts +216 -0
- package/src/consent/port.ts +148 -0
- package/src/consent/registry.ts +60 -0
- package/src/consent/served.ts +24 -0
- package/src/core.ts +127 -0
- package/src/errors.generated.ts +277 -0
- package/src/errors.ts +57 -0
- package/src/generated.ts +14540 -0
- package/src/index.ts +100 -0
- package/src/mobile.ts +96 -0
- package/src/node.ts +291 -0
- package/src/outbox.ts +452 -0
- package/src/resources.generated.ts +2097 -0
- package/src/served.ts +229 -0
- package/src/sha256.ts +82 -0
- package/src/snippet.ts +305 -0
- package/src/stripe-events.ts +130 -0
- package/src/version.ts +2 -0
- package/src/webhooks.ts +207 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.consentGate = consentGate;
|
|
4
|
+
/**
|
|
5
|
+
* The one consent state machine, shared by `referalli/browser` (snippet.ts)
|
|
6
|
+
* and the served `aff.js` (served.ts inlines this function's source text, so
|
|
7
|
+
* it must stay self-contained: parameters and browser globals only).
|
|
8
|
+
*
|
|
9
|
+
* `change(state, evidence)` is called on every transition (never for the
|
|
10
|
+
* initial `unknown`). `auto` polls every 100 ms for up to `waitMs` for a CMP
|
|
11
|
+
* to appear; if the page is being left before then with none found, the
|
|
12
|
+
* no-CMP rule applies at once so a quick click-through still keeps its referral.
|
|
13
|
+
*/
|
|
14
|
+
function consentGate(w, cfg, adapters, order, change) {
|
|
15
|
+
let reader = null;
|
|
16
|
+
let readerId = null;
|
|
17
|
+
let current = 'unknown';
|
|
18
|
+
let pushed = null;
|
|
19
|
+
let fallback = false;
|
|
20
|
+
let finished = false;
|
|
21
|
+
let timer = null;
|
|
22
|
+
let unsub = null;
|
|
23
|
+
let started = false;
|
|
24
|
+
const wait = typeof cfg.waitMs === 'number' ? cfg.waitMs : 3000;
|
|
25
|
+
let deadline = 0;
|
|
26
|
+
function read() {
|
|
27
|
+
if (pushed !== null)
|
|
28
|
+
return pushed ? 'granted' : 'denied';
|
|
29
|
+
if (cfg.mode === 'none')
|
|
30
|
+
return 'granted';
|
|
31
|
+
if (reader) {
|
|
32
|
+
try {
|
|
33
|
+
const s = reader.state(cfg);
|
|
34
|
+
return s === 'granted' || s === 'denied' ? s : 'unknown';
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return 'unknown';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (fallback && cfg.noCmp === 'persist')
|
|
41
|
+
return 'granted';
|
|
42
|
+
return 'unknown';
|
|
43
|
+
}
|
|
44
|
+
function provider() {
|
|
45
|
+
if (pushed !== null)
|
|
46
|
+
return 'custom';
|
|
47
|
+
if (readerId)
|
|
48
|
+
return readerId;
|
|
49
|
+
if (cfg.mode === 'none')
|
|
50
|
+
return 'none';
|
|
51
|
+
if (fallback)
|
|
52
|
+
return 'no-cmp';
|
|
53
|
+
return String(cfg.mode);
|
|
54
|
+
}
|
|
55
|
+
function evidence(s) {
|
|
56
|
+
const ev = { provider: provider(), state: s, at: new Date().toISOString() };
|
|
57
|
+
if (reader && pushed === null) {
|
|
58
|
+
try {
|
|
59
|
+
const x = reader.evidence(cfg);
|
|
60
|
+
if (x) {
|
|
61
|
+
if (typeof x.stamp === 'string' && x.stamp)
|
|
62
|
+
ev.stamp = x.stamp.slice(0, 200);
|
|
63
|
+
if (typeof x.tcString === 'string' && x.tcString)
|
|
64
|
+
ev.tcString = x.tcString.slice(0, 4000);
|
|
65
|
+
if (typeof x.gppString === 'string' && x.gppString)
|
|
66
|
+
ev.gppString = x.gppString.slice(0, 4000);
|
|
67
|
+
if (x.purposes && x.purposes.length)
|
|
68
|
+
ev.purposes = x.purposes.slice(0, 40).map(String);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* evidence is best-effort */
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return ev;
|
|
76
|
+
}
|
|
77
|
+
function emit() {
|
|
78
|
+
if (!started)
|
|
79
|
+
return;
|
|
80
|
+
const s = read();
|
|
81
|
+
if (s === current)
|
|
82
|
+
return;
|
|
83
|
+
current = s;
|
|
84
|
+
change(s, s === 'unknown' ? null : evidence(s));
|
|
85
|
+
}
|
|
86
|
+
function onCmp() {
|
|
87
|
+
pushed = null;
|
|
88
|
+
emit();
|
|
89
|
+
}
|
|
90
|
+
function attach() {
|
|
91
|
+
const ids = cfg.mode === 'auto' ? order : [String(cfg.mode)];
|
|
92
|
+
for (let i = 0; i < ids.length; i++) {
|
|
93
|
+
const id = ids[i];
|
|
94
|
+
const factory = adapters[id];
|
|
95
|
+
if (!factory)
|
|
96
|
+
continue;
|
|
97
|
+
let r;
|
|
98
|
+
try {
|
|
99
|
+
r = factory(w);
|
|
100
|
+
if (!r.detect())
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
reader = r;
|
|
107
|
+
readerId = id;
|
|
108
|
+
try {
|
|
109
|
+
unsub = r.subscribe(cfg, onCmp);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
unsub = null;
|
|
113
|
+
}
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
function settle() {
|
|
119
|
+
finished = true;
|
|
120
|
+
if (timer !== null) {
|
|
121
|
+
try {
|
|
122
|
+
w.clearTimeout(timer);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
/* ignore */
|
|
126
|
+
}
|
|
127
|
+
timer = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function poll() {
|
|
131
|
+
timer = null;
|
|
132
|
+
if (finished)
|
|
133
|
+
return;
|
|
134
|
+
if (attach()) {
|
|
135
|
+
settle();
|
|
136
|
+
emit();
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (Date.now() >= deadline) {
|
|
140
|
+
settle();
|
|
141
|
+
if (cfg.mode === 'auto')
|
|
142
|
+
fallback = true;
|
|
143
|
+
emit();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
timer = w.setTimeout(poll, 100);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
settle();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Leaving the page before a CMP showed up: apply the no-CMP rule now.
|
|
154
|
+
function onHide(e) {
|
|
155
|
+
if (finished || cfg.mode !== 'auto')
|
|
156
|
+
return;
|
|
157
|
+
if (e && e.type === 'visibilitychange' && w.document && w.document.visibilityState !== 'hidden')
|
|
158
|
+
return;
|
|
159
|
+
if (attach()) {
|
|
160
|
+
settle();
|
|
161
|
+
emit();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
settle();
|
|
165
|
+
fallback = true;
|
|
166
|
+
emit();
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
start() {
|
|
170
|
+
if (started)
|
|
171
|
+
return;
|
|
172
|
+
started = true;
|
|
173
|
+
deadline = Date.now() + wait;
|
|
174
|
+
if (cfg.mode === 'none' || cfg.mode === 'pending') {
|
|
175
|
+
finished = true;
|
|
176
|
+
emit();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
try {
|
|
180
|
+
w.addEventListener('pagehide', onHide);
|
|
181
|
+
w.addEventListener('visibilitychange', onHide);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
/* no events: rely on the timer */
|
|
185
|
+
}
|
|
186
|
+
poll();
|
|
187
|
+
},
|
|
188
|
+
state: () => current,
|
|
189
|
+
mode() {
|
|
190
|
+
if (readerId)
|
|
191
|
+
return readerId;
|
|
192
|
+
if (cfg.mode === 'auto')
|
|
193
|
+
return fallback ? 'no-cmp' : 'auto';
|
|
194
|
+
return String(cfg.mode);
|
|
195
|
+
},
|
|
196
|
+
push(granted) {
|
|
197
|
+
pushed = granted === true;
|
|
198
|
+
emit();
|
|
199
|
+
},
|
|
200
|
+
evidence: () => (current === 'unknown' ? null : evidence(current)),
|
|
201
|
+
stop() {
|
|
202
|
+
settle();
|
|
203
|
+
if (unsub) {
|
|
204
|
+
try {
|
|
205
|
+
unsub();
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
/* ignore */
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
w.removeEventListener('pagehide', onHide);
|
|
213
|
+
w.removeEventListener('visibilitychange', onHide);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
/* ignore */
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The consent port: how the browser tracker (`aff.js`, `referalli/browser`)
|
|
3
|
+
* learns whether the visitor allows the referral context to be stored.
|
|
4
|
+
*
|
|
5
|
+
* Each adapter reads one consent-management platform (CMP) through that
|
|
6
|
+
* vendor's documented browser API. One state machine (gate.ts) turns the
|
|
7
|
+
* adapter's answer into what the tracker may do:
|
|
8
|
+
*
|
|
9
|
+
* unknown nothing stored, no beacon; the referral stays in memory, so
|
|
10
|
+
* `getReferral()` / `signupMetadata()` still attribute a sign-up
|
|
11
|
+
* granted `referalli_ctx` (and its legacy twin) written, visit beacon sent
|
|
12
|
+
* with consent evidence
|
|
13
|
+
* denied storage cleared within one tick, nothing sent, referral dropped
|
|
14
|
+
*
|
|
15
|
+
* Adapter factories and the gate are SELF-CONTAINED functions: the served
|
|
16
|
+
* `aff.js` (served.ts) inlines their source text, so they may only use their
|
|
17
|
+
* parameters and browser globals, never an import or a module-level helper.
|
|
18
|
+
* `test/consent/conformance.ts` runs every adapter through the same cases in
|
|
19
|
+
* both the module build and the served script.
|
|
20
|
+
*/
|
|
21
|
+
/** `unknown` means no decision yet (or no readable CMP). It is never "declined". */
|
|
22
|
+
export type ConsentState = 'granted' | 'denied' | 'unknown';
|
|
23
|
+
/**
|
|
24
|
+
* Adapters `auto` tries, in this order. The merchant's own `referalliConsent`
|
|
25
|
+
* hook wins, then vendor CMPs (their own category model), then the IAB
|
|
26
|
+
* frameworks and Google Consent Mode, which many CMPs also feed.
|
|
27
|
+
*/
|
|
28
|
+
export declare const AUTO_ORDER: readonly ["custom", "cookiemunch", "onetrust", "cookiebot", "usercentrics", "didomi", "osano", "termly", "tcf", "gpp", "gcm"];
|
|
29
|
+
export type ConsentAdapterId = (typeof AUTO_ORDER)[number] | 'none';
|
|
30
|
+
export declare const CONSENT_ADAPTER_IDS: readonly ConsentAdapterId[];
|
|
31
|
+
/**
|
|
32
|
+
* `auto`: the first CMP detected, in `AUTO_ORDER`. `none`: always granted
|
|
33
|
+
* (the tracker's behaviour before consent support; only for sites that need
|
|
34
|
+
* no opt-in). `pending`: unknown until the page calls `aff.consent(true|false)`.
|
|
35
|
+
*/
|
|
36
|
+
export type ConsentMode = 'auto' | 'none' | 'pending' | ConsentAdapterId;
|
|
37
|
+
export declare const CONSENT_MODES: readonly ConsentMode[];
|
|
38
|
+
export interface ConsentEvidence {
|
|
39
|
+
/** The adapter that decided (`onetrust`, `tcf`, …), `custom` for `aff.consent()`, `none`, or `no-cmp` for auto's fallback. */
|
|
40
|
+
provider: string;
|
|
41
|
+
state: ConsentState;
|
|
42
|
+
/** ISO time the state was read. */
|
|
43
|
+
at: string;
|
|
44
|
+
/** The CMP's consent record id, when it exposes one. */
|
|
45
|
+
stamp?: string;
|
|
46
|
+
tcString?: string;
|
|
47
|
+
gppString?: string;
|
|
48
|
+
/** Purposes, categories or groups the CMP reported as allowed. */
|
|
49
|
+
purposes?: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface ConsentConfig {
|
|
52
|
+
mode: ConsentMode;
|
|
53
|
+
/** Adapter-specific category, group, purpose or service; each adapter has a default. */
|
|
54
|
+
category?: string;
|
|
55
|
+
/** IAB TCF vendor id; when set, TCF requires that vendor's consent instead of publisher purposes 7/9. */
|
|
56
|
+
tcfVendorId?: number;
|
|
57
|
+
/** Google Consent Mode signal to follow. Default `ad_storage`. */
|
|
58
|
+
gcmSignal?: 'ad_storage' | 'analytics_storage';
|
|
59
|
+
/** `auto` with no CMP found: `persist` behaves as granted, `memory` stays unknown. */
|
|
60
|
+
noCmp: 'persist' | 'memory';
|
|
61
|
+
/** How long to wait for a late CMP before `auto` gives up. Default 3000, at most 10000. */
|
|
62
|
+
waitMs?: number;
|
|
63
|
+
}
|
|
64
|
+
/** What a merchant passes to `initSnippet` / `createTracker`: any subset, mode defaulting to `none`. */
|
|
65
|
+
export type ConsentOptions = Partial<ConsentConfig> | ConsentMode;
|
|
66
|
+
/** One adapter bound to a window. Every method may throw; the gate reads a throw as `unknown`. */
|
|
67
|
+
export interface ConsentReader {
|
|
68
|
+
/** Is this CMP's API (or its stub) on the page? */
|
|
69
|
+
detect(): boolean;
|
|
70
|
+
state(cfg: ConsentConfig): ConsentState;
|
|
71
|
+
/** Calls `cb` whenever the CMP reports a load, a decision or a change. Returns an unsubscribe. */
|
|
72
|
+
subscribe(cfg: ConsentConfig, cb: () => void): () => void;
|
|
73
|
+
/** Extra evidence fields (stamp, tcString, gppString, purposes). */
|
|
74
|
+
evidence(cfg: ConsentConfig): Omit<ConsentEvidence, 'provider' | 'state' | 'at'> | null;
|
|
75
|
+
}
|
|
76
|
+
/** Self-contained: inlined into aff.js by its source text. */
|
|
77
|
+
export type ConsentAdapterFactory = (w: any) => ConsentReader;
|
|
78
|
+
export interface ConsentSource {
|
|
79
|
+
readonly id: ConsentAdapterId;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
/** What the adapter reads when no `category` is configured. */
|
|
82
|
+
readonly defaultCategory: string | null;
|
|
83
|
+
readonly factory: ConsentAdapterFactory;
|
|
84
|
+
readonly status: 'ga' | 'beta';
|
|
85
|
+
/** Referalli's page for this CMP. */
|
|
86
|
+
readonly docsUrl: string;
|
|
87
|
+
/** The vendor's API documentation the adapter follows. */
|
|
88
|
+
readonly vendorDocsUrl: string;
|
|
89
|
+
/** Health (docs/PORTS.md): cheap, read-only, never throws. */
|
|
90
|
+
readonly check: (cfg?: Partial<ConsentConfig>) => Promise<PortCheck>;
|
|
91
|
+
}
|
|
92
|
+
export interface PortCheck {
|
|
93
|
+
ok: boolean;
|
|
94
|
+
detail: string;
|
|
95
|
+
fix?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Every consent adapter's `check()`. The CMP lives in the visitor's browser,
|
|
99
|
+
* so there is nothing to probe from a server: the health signal is the
|
|
100
|
+
* consent evidence each visit carries (its `provider` and `state`). This says
|
|
101
|
+
* what the adapter will read with the given config.
|
|
102
|
+
*/
|
|
103
|
+
export declare function browserCheck(source: Pick<ConsentSource, 'name' | 'defaultCategory'>, cfg?: Partial<ConsentConfig>): Promise<PortCheck>;
|
|
104
|
+
/** Normalise merchant options into a full config (mode `none` when absent: the pre-consent behaviour). */
|
|
105
|
+
export declare function consentConfig(opts: ConsentOptions | undefined | null): ConsentConfig;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The consent port: how the browser tracker (`aff.js`, `referalli/browser`)
|
|
4
|
+
* learns whether the visitor allows the referral context to be stored.
|
|
5
|
+
*
|
|
6
|
+
* Each adapter reads one consent-management platform (CMP) through that
|
|
7
|
+
* vendor's documented browser API. One state machine (gate.ts) turns the
|
|
8
|
+
* adapter's answer into what the tracker may do:
|
|
9
|
+
*
|
|
10
|
+
* unknown nothing stored, no beacon; the referral stays in memory, so
|
|
11
|
+
* `getReferral()` / `signupMetadata()` still attribute a sign-up
|
|
12
|
+
* granted `referalli_ctx` (and its legacy twin) written, visit beacon sent
|
|
13
|
+
* with consent evidence
|
|
14
|
+
* denied storage cleared within one tick, nothing sent, referral dropped
|
|
15
|
+
*
|
|
16
|
+
* Adapter factories and the gate are SELF-CONTAINED functions: the served
|
|
17
|
+
* `aff.js` (served.ts) inlines their source text, so they may only use their
|
|
18
|
+
* parameters and browser globals, never an import or a module-level helper.
|
|
19
|
+
* `test/consent/conformance.ts` runs every adapter through the same cases in
|
|
20
|
+
* both the module build and the served script.
|
|
21
|
+
*/
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.CONSENT_MODES = exports.CONSENT_ADAPTER_IDS = exports.AUTO_ORDER = void 0;
|
|
24
|
+
exports.browserCheck = browserCheck;
|
|
25
|
+
exports.consentConfig = consentConfig;
|
|
26
|
+
/**
|
|
27
|
+
* Adapters `auto` tries, in this order. The merchant's own `referalliConsent`
|
|
28
|
+
* hook wins, then vendor CMPs (their own category model), then the IAB
|
|
29
|
+
* frameworks and Google Consent Mode, which many CMPs also feed.
|
|
30
|
+
*/
|
|
31
|
+
exports.AUTO_ORDER = [
|
|
32
|
+
'custom',
|
|
33
|
+
'cookiemunch',
|
|
34
|
+
'onetrust',
|
|
35
|
+
'cookiebot',
|
|
36
|
+
'usercentrics',
|
|
37
|
+
'didomi',
|
|
38
|
+
'osano',
|
|
39
|
+
'termly',
|
|
40
|
+
'tcf',
|
|
41
|
+
'gpp',
|
|
42
|
+
'gcm',
|
|
43
|
+
];
|
|
44
|
+
exports.CONSENT_ADAPTER_IDS = [...exports.AUTO_ORDER, 'none'];
|
|
45
|
+
exports.CONSENT_MODES = ['auto', 'pending', ...exports.CONSENT_ADAPTER_IDS];
|
|
46
|
+
/**
|
|
47
|
+
* Every consent adapter's `check()`. The CMP lives in the visitor's browser,
|
|
48
|
+
* so there is nothing to probe from a server: the health signal is the
|
|
49
|
+
* consent evidence each visit carries (its `provider` and `state`). This says
|
|
50
|
+
* what the adapter will read with the given config.
|
|
51
|
+
*/
|
|
52
|
+
async function browserCheck(source, cfg) {
|
|
53
|
+
const what = cfg?.category ?? source.defaultCategory;
|
|
54
|
+
return {
|
|
55
|
+
ok: true,
|
|
56
|
+
detail: `${source.name} is read in the visitor's browser${what ? ` (${what})` : ''}; each visit's consent evidence shows its answer.`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Normalise merchant options into a full config (mode `none` when absent: the pre-consent behaviour). */
|
|
60
|
+
function consentConfig(opts) {
|
|
61
|
+
const o = typeof opts === 'string' ? { mode: opts } : (opts ?? {});
|
|
62
|
+
const mode = o.mode && exports.CONSENT_MODES.includes(o.mode) ? o.mode : 'none';
|
|
63
|
+
const waitMs = typeof o.waitMs === 'number' && o.waitMs >= 0 ? Math.min(10_000, Math.round(o.waitMs)) : 3000;
|
|
64
|
+
return {
|
|
65
|
+
mode,
|
|
66
|
+
...(typeof o.category === 'string' && o.category ? { category: o.category.slice(0, 80) } : {}),
|
|
67
|
+
...(typeof o.tcfVendorId === 'number' && o.tcfVendorId > 0 ? { tcfVendorId: Math.round(o.tcfVendorId) } : {}),
|
|
68
|
+
...(o.gcmSignal === 'analytics_storage' || o.gcmSignal === 'ad_storage' ? { gcmSignal: o.gcmSignal } : {}),
|
|
69
|
+
noCmp: o.noCmp === 'memory' ? 'memory' : 'persist',
|
|
70
|
+
waitMs,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ConsentAdapterFactory, type ConsentAdapterId, type ConsentSource } from './port.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every consent adapter, `auto`'s detection order first, then `none`.
|
|
4
|
+
* (`fd-consent`, the suite's `window.__fdConsent`, joins when Cookie Munch
|
|
5
|
+
* ships that contract: CMU-X16.)
|
|
6
|
+
*/
|
|
7
|
+
export declare const CONSENT_SOURCES: readonly ConsentSource[];
|
|
8
|
+
/**
|
|
9
|
+
* The consent port's adapters (docs/PORTS.md): every CMP reader, `custom`
|
|
10
|
+
* first. `none` is left out: it reads nothing (it is the "always store" mode,
|
|
11
|
+
* like `auto` and `pending`), so it has no vendor, fixtures or conformance run.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ADAPTERS: readonly ConsentSource[];
|
|
14
|
+
export declare function adapterOf(id: string): ConsentSource | undefined;
|
|
15
|
+
/** `{ id: factory }` for the gate, limited to `ids` (default: every adapter). */
|
|
16
|
+
export declare function adapterFactories(ids?: readonly string[]): Record<string, ConsentAdapterFactory>;
|
|
17
|
+
export declare function isConsentAdapterId(id: unknown): id is ConsentAdapterId;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ADAPTERS = exports.CONSENT_SOURCES = void 0;
|
|
4
|
+
exports.adapterOf = adapterOf;
|
|
5
|
+
exports.adapterFactories = adapterFactories;
|
|
6
|
+
exports.isConsentAdapterId = isConsentAdapterId;
|
|
7
|
+
const cookiebot_js_1 = require("./adapters/cookiebot.js");
|
|
8
|
+
const cookiemunch_js_1 = require("./adapters/cookiemunch.js");
|
|
9
|
+
const custom_js_1 = require("./adapters/custom.js");
|
|
10
|
+
const didomi_js_1 = require("./adapters/didomi.js");
|
|
11
|
+
const gcm_js_1 = require("./adapters/gcm.js");
|
|
12
|
+
const gpp_js_1 = require("./adapters/gpp.js");
|
|
13
|
+
const none_js_1 = require("./adapters/none.js");
|
|
14
|
+
const onetrust_js_1 = require("./adapters/onetrust.js");
|
|
15
|
+
const osano_js_1 = require("./adapters/osano.js");
|
|
16
|
+
const tcf_js_1 = require("./adapters/tcf.js");
|
|
17
|
+
const termly_js_1 = require("./adapters/termly.js");
|
|
18
|
+
const usercentrics_js_1 = require("./adapters/usercentrics.js");
|
|
19
|
+
const port_js_1 = require("./port.js");
|
|
20
|
+
/**
|
|
21
|
+
* Every consent adapter, `auto`'s detection order first, then `none`.
|
|
22
|
+
* (`fd-consent`, the suite's `window.__fdConsent`, joins when Cookie Munch
|
|
23
|
+
* ships that contract: CMU-X16.)
|
|
24
|
+
*/
|
|
25
|
+
exports.CONSENT_SOURCES = [
|
|
26
|
+
custom_js_1.custom,
|
|
27
|
+
cookiemunch_js_1.cookiemunch,
|
|
28
|
+
onetrust_js_1.onetrust,
|
|
29
|
+
cookiebot_js_1.cookiebot,
|
|
30
|
+
usercentrics_js_1.usercentrics,
|
|
31
|
+
didomi_js_1.didomi,
|
|
32
|
+
osano_js_1.osano,
|
|
33
|
+
termly_js_1.termly,
|
|
34
|
+
tcf_js_1.tcf,
|
|
35
|
+
gpp_js_1.gpp,
|
|
36
|
+
gcm_js_1.gcm,
|
|
37
|
+
none_js_1.none,
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* The consent port's adapters (docs/PORTS.md): every CMP reader, `custom`
|
|
41
|
+
* first. `none` is left out: it reads nothing (it is the "always store" mode,
|
|
42
|
+
* like `auto` and `pending`), so it has no vendor, fixtures or conformance run.
|
|
43
|
+
*/
|
|
44
|
+
exports.ADAPTERS = exports.CONSENT_SOURCES.filter((s) => s.id !== 'none');
|
|
45
|
+
const BY_ID = new Map(exports.CONSENT_SOURCES.map((s) => [s.id, s]));
|
|
46
|
+
function adapterOf(id) {
|
|
47
|
+
return BY_ID.get(id);
|
|
48
|
+
}
|
|
49
|
+
/** `{ id: factory }` for the gate, limited to `ids` (default: every adapter). */
|
|
50
|
+
function adapterFactories(ids = port_js_1.AUTO_ORDER) {
|
|
51
|
+
const out = {};
|
|
52
|
+
for (const id of ids) {
|
|
53
|
+
const s = BY_ID.get(id);
|
|
54
|
+
if (s)
|
|
55
|
+
out[id] = s.factory;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
function isConsentAdapterId(id) {
|
|
60
|
+
return typeof id === 'string' && BY_ID.has(id);
|
|
61
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The consent gate and adapters as JavaScript source, for the served aff.js.
|
|
3
|
+
* Built from the same functions the module build runs (their source text), so
|
|
4
|
+
* there is one implementation. `__name` is a no-op stand-in for the helper
|
|
5
|
+
* esbuild (tsx, vitest) inserts into function bodies under keepNames.
|
|
6
|
+
*
|
|
7
|
+
* `ids`: the adapters to inline (default: all of `auto`'s, in order).
|
|
8
|
+
*/
|
|
9
|
+
export declare function consentSource(ids?: readonly string[]): {
|
|
10
|
+
gate: string;
|
|
11
|
+
adapters: string;
|
|
12
|
+
order: string;
|
|
13
|
+
};
|
|
14
|
+
/** The no-op `__name` shim (see consentSource). */
|
|
15
|
+
export declare const NAME_SHIM = "var __name=function(t){return t;};";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NAME_SHIM = void 0;
|
|
4
|
+
exports.consentSource = consentSource;
|
|
5
|
+
const gate_js_1 = require("./gate.js");
|
|
6
|
+
const port_js_1 = require("./port.js");
|
|
7
|
+
const registry_js_1 = require("./registry.js");
|
|
8
|
+
/**
|
|
9
|
+
* The consent gate and adapters as JavaScript source, for the served aff.js.
|
|
10
|
+
* Built from the same functions the module build runs (their source text), so
|
|
11
|
+
* there is one implementation. `__name` is a no-op stand-in for the helper
|
|
12
|
+
* esbuild (tsx, vitest) inserts into function bodies under keepNames.
|
|
13
|
+
*
|
|
14
|
+
* `ids`: the adapters to inline (default: all of `auto`'s, in order).
|
|
15
|
+
*/
|
|
16
|
+
function consentSource(ids = port_js_1.AUTO_ORDER) {
|
|
17
|
+
const list = port_js_1.AUTO_ORDER.filter((id) => ids.includes(id));
|
|
18
|
+
const adapters = list.map((id) => `${JSON.stringify(id)}:(${String((0, registry_js_1.adapterOf)(id).factory)})`).join(',\n');
|
|
19
|
+
return {
|
|
20
|
+
gate: `(${String(gate_js_1.consentGate)})`,
|
|
21
|
+
adapters: `{${adapters}}`,
|
|
22
|
+
order: JSON.stringify(list),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** The no-op `__name` shim (see consentSource). */
|
|
26
|
+
exports.NAME_SHIM = 'var __name=function(t){return t;};';
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
2
|
+
/** One operation in the generated table. */
|
|
3
|
+
export interface OperationSpec {
|
|
4
|
+
method: HttpMethod;
|
|
5
|
+
path: string;
|
|
6
|
+
pathParams: readonly string[];
|
|
7
|
+
/** Query parameters, by wire name. */
|
|
8
|
+
query: readonly string[];
|
|
9
|
+
body: boolean;
|
|
10
|
+
kind: 'json' | 'list' | 'text' | 'empty';
|
|
11
|
+
/** Callable without an API key. */
|
|
12
|
+
public?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** Per-request overrides. */
|
|
15
|
+
export interface RequestOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Sent as `Idempotency-Key`. Every POST gets a generated one when you don't
|
|
18
|
+
* pass it, and the same key is reused on every retry.
|
|
19
|
+
*/
|
|
20
|
+
idempotencyKey?: string;
|
|
21
|
+
/** Milliseconds before the request is abandoned (and retried, if it can be). */
|
|
22
|
+
timeout?: number;
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
/** Override the `referalli-version` for this request (`null` sends none). */
|
|
27
|
+
apiVersion?: string | null;
|
|
28
|
+
}
|
|
29
|
+
/** Query values the SDK can encode. Arrays repeat the key; dates are ISO 8601. */
|
|
30
|
+
export type QueryValue = string | number | boolean | Date | null | undefined | ReadonlyArray<string | number | boolean>;
|
|
31
|
+
export interface OperationInput {
|
|
32
|
+
path?: Record<string, string>;
|
|
33
|
+
query?: object;
|
|
34
|
+
body?: unknown;
|
|
35
|
+
}
|
|
36
|
+
/** Cursor paging params every list operation accepts. */
|
|
37
|
+
export interface PageParams {
|
|
38
|
+
/** 1–100 items per page. */
|
|
39
|
+
limit?: number;
|
|
40
|
+
starting_after?: string;
|
|
41
|
+
ending_before?: string;
|
|
42
|
+
'created[gte]'?: string;
|
|
43
|
+
'created[lte]'?: string;
|
|
44
|
+
}
|
|
45
|
+
/** The list envelope (referalli-version 2026-11-01 and later). */
|
|
46
|
+
export interface ListEnvelope<T> {
|
|
47
|
+
object: 'list';
|
|
48
|
+
data: T[];
|
|
49
|
+
has_more: boolean;
|
|
50
|
+
next_cursor: string | null;
|
|
51
|
+
}
|
|
52
|
+
/** What the generated resources call into (the client implements it). */
|
|
53
|
+
export interface Transport {
|
|
54
|
+
op<R>(id: string, input: OperationInput, options?: RequestOptions): Promise<R>;
|
|
55
|
+
list<Item, Page extends ListEnvelope<Item>>(id: string, input: OperationInput, options?: RequestOptions): ListPromise<Item, Page>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A list call. Await it for the first page, or iterate it with `for await`
|
|
59
|
+
* to get every item, fetching further pages (`starting_after`) as you go.
|
|
60
|
+
* Nothing is requested until you do one or the other.
|
|
61
|
+
*/
|
|
62
|
+
export declare class ListPromise<Item, Page extends ListEnvelope<Item> = ListEnvelope<Item>> implements PromiseLike<Page>, AsyncIterable<Item> {
|
|
63
|
+
private readonly fetchPage;
|
|
64
|
+
private first;
|
|
65
|
+
constructor(fetchPage: (cursor: string | undefined) => Promise<Page>);
|
|
66
|
+
private firstPage;
|
|
67
|
+
then<A = Page, B = never>(onfulfilled?: ((page: Page) => A | PromiseLike<A>) | null, onrejected?: ((reason: unknown) => B | PromiseLike<B>) | null): Promise<A | B>;
|
|
68
|
+
catch<B = never>(onrejected?: ((reason: unknown) => B | PromiseLike<B>) | null): Promise<Page | B>;
|
|
69
|
+
finally(onfinally?: (() => void) | null): Promise<Page>;
|
|
70
|
+
/** Every page, starting with the first. */
|
|
71
|
+
pages(): AsyncGenerator<Page, void, undefined>;
|
|
72
|
+
[Symbol.asyncIterator](): AsyncGenerator<Item, void, undefined>;
|
|
73
|
+
/** Collect items into an array, stopping at `limit` (default 10,000) so a runaway list can't exhaust memory. */
|
|
74
|
+
toArray(opts?: {
|
|
75
|
+
limit?: number;
|
|
76
|
+
}): Promise<Item[]>;
|
|
77
|
+
}
|
package/dist/cjs/core.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ListPromise = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
/**
|
|
6
|
+
* A list call. Await it for the first page, or iterate it with `for await`
|
|
7
|
+
* to get every item, fetching further pages (`starting_after`) as you go.
|
|
8
|
+
* Nothing is requested until you do one or the other.
|
|
9
|
+
*/
|
|
10
|
+
class ListPromise {
|
|
11
|
+
fetchPage;
|
|
12
|
+
first = null;
|
|
13
|
+
constructor(fetchPage) {
|
|
14
|
+
this.fetchPage = fetchPage;
|
|
15
|
+
}
|
|
16
|
+
firstPage() {
|
|
17
|
+
this.first ??= this.fetchPage(undefined).then(checkPage);
|
|
18
|
+
return this.first;
|
|
19
|
+
}
|
|
20
|
+
then(onfulfilled, onrejected) {
|
|
21
|
+
return this.firstPage().then(onfulfilled, onrejected);
|
|
22
|
+
}
|
|
23
|
+
catch(onrejected) {
|
|
24
|
+
return this.firstPage().catch(onrejected);
|
|
25
|
+
}
|
|
26
|
+
finally(onfinally) {
|
|
27
|
+
return this.firstPage().finally(onfinally);
|
|
28
|
+
}
|
|
29
|
+
/** Every page, starting with the first. */
|
|
30
|
+
async *pages() {
|
|
31
|
+
let page = await this.firstPage();
|
|
32
|
+
for (;;) {
|
|
33
|
+
yield page;
|
|
34
|
+
if (!page.has_more || !page.next_cursor)
|
|
35
|
+
return;
|
|
36
|
+
page = checkPage(await this.fetchPage(page.next_cursor));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async *[Symbol.asyncIterator]() {
|
|
40
|
+
for await (const page of this.pages())
|
|
41
|
+
yield* page.data;
|
|
42
|
+
}
|
|
43
|
+
/** Collect items into an array, stopping at `limit` (default 10,000) so a runaway list can't exhaust memory. */
|
|
44
|
+
async toArray(opts = {}) {
|
|
45
|
+
const limit = opts.limit ?? 10_000;
|
|
46
|
+
const out = [];
|
|
47
|
+
if (limit <= 0)
|
|
48
|
+
return out;
|
|
49
|
+
for await (const item of this) {
|
|
50
|
+
out.push(item);
|
|
51
|
+
if (out.length >= limit)
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.ListPromise = ListPromise;
|
|
58
|
+
function checkPage(page) {
|
|
59
|
+
const p = page;
|
|
60
|
+
if (!p || typeof p !== 'object' || !Array.isArray(p.data)) {
|
|
61
|
+
throw new errors_js_1.ReferalliError('the API did not return a list page: send referalli-version 2026-11-01 or later (the SDK default)');
|
|
62
|
+
}
|
|
63
|
+
return page;
|
|
64
|
+
}
|