@referalli/sdk 0.0.0-stage → 0.3.21
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 +132 -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 +15151 -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 +15151 -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 +14545 -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,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one consent state machine, shared by `referalli/browser` (snippet.ts)
|
|
3
|
+
* and the served `aff.js` (served.ts inlines this function's source text, so
|
|
4
|
+
* it must stay self-contained: parameters and browser globals only).
|
|
5
|
+
*
|
|
6
|
+
* `change(state, evidence)` is called on every transition (never for the
|
|
7
|
+
* initial `unknown`). `auto` polls every 100 ms for up to `waitMs` for a CMP
|
|
8
|
+
* to appear; if the page is being left before then with none found, the
|
|
9
|
+
* no-CMP rule applies at once so a quick click-through still keeps its referral.
|
|
10
|
+
*/
|
|
11
|
+
export function consentGate(w, cfg, adapters, order, change) {
|
|
12
|
+
let reader = null;
|
|
13
|
+
let readerId = null;
|
|
14
|
+
let current = 'unknown';
|
|
15
|
+
let pushed = null;
|
|
16
|
+
let fallback = false;
|
|
17
|
+
let finished = false;
|
|
18
|
+
let timer = null;
|
|
19
|
+
let unsub = null;
|
|
20
|
+
let started = false;
|
|
21
|
+
const wait = typeof cfg.waitMs === 'number' ? cfg.waitMs : 3000;
|
|
22
|
+
let deadline = 0;
|
|
23
|
+
function read() {
|
|
24
|
+
if (pushed !== null)
|
|
25
|
+
return pushed ? 'granted' : 'denied';
|
|
26
|
+
if (cfg.mode === 'none')
|
|
27
|
+
return 'granted';
|
|
28
|
+
if (reader) {
|
|
29
|
+
try {
|
|
30
|
+
const s = reader.state(cfg);
|
|
31
|
+
return s === 'granted' || s === 'denied' ? s : 'unknown';
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return 'unknown';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (fallback && cfg.noCmp === 'persist')
|
|
38
|
+
return 'granted';
|
|
39
|
+
return 'unknown';
|
|
40
|
+
}
|
|
41
|
+
function provider() {
|
|
42
|
+
if (pushed !== null)
|
|
43
|
+
return 'custom';
|
|
44
|
+
if (readerId)
|
|
45
|
+
return readerId;
|
|
46
|
+
if (cfg.mode === 'none')
|
|
47
|
+
return 'none';
|
|
48
|
+
if (fallback)
|
|
49
|
+
return 'no-cmp';
|
|
50
|
+
return String(cfg.mode);
|
|
51
|
+
}
|
|
52
|
+
function evidence(s) {
|
|
53
|
+
const ev = { provider: provider(), state: s, at: new Date().toISOString() };
|
|
54
|
+
if (reader && pushed === null) {
|
|
55
|
+
try {
|
|
56
|
+
const x = reader.evidence(cfg);
|
|
57
|
+
if (x) {
|
|
58
|
+
if (typeof x.stamp === 'string' && x.stamp)
|
|
59
|
+
ev.stamp = x.stamp.slice(0, 200);
|
|
60
|
+
if (typeof x.tcString === 'string' && x.tcString)
|
|
61
|
+
ev.tcString = x.tcString.slice(0, 4000);
|
|
62
|
+
if (typeof x.gppString === 'string' && x.gppString)
|
|
63
|
+
ev.gppString = x.gppString.slice(0, 4000);
|
|
64
|
+
if (x.purposes && x.purposes.length)
|
|
65
|
+
ev.purposes = x.purposes.slice(0, 40).map(String);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
/* evidence is best-effort */
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return ev;
|
|
73
|
+
}
|
|
74
|
+
function emit() {
|
|
75
|
+
if (!started)
|
|
76
|
+
return;
|
|
77
|
+
const s = read();
|
|
78
|
+
if (s === current)
|
|
79
|
+
return;
|
|
80
|
+
current = s;
|
|
81
|
+
change(s, s === 'unknown' ? null : evidence(s));
|
|
82
|
+
}
|
|
83
|
+
function onCmp() {
|
|
84
|
+
pushed = null;
|
|
85
|
+
emit();
|
|
86
|
+
}
|
|
87
|
+
function attach() {
|
|
88
|
+
const ids = cfg.mode === 'auto' ? order : [String(cfg.mode)];
|
|
89
|
+
for (let i = 0; i < ids.length; i++) {
|
|
90
|
+
const id = ids[i];
|
|
91
|
+
const factory = adapters[id];
|
|
92
|
+
if (!factory)
|
|
93
|
+
continue;
|
|
94
|
+
let r;
|
|
95
|
+
try {
|
|
96
|
+
r = factory(w);
|
|
97
|
+
if (!r.detect())
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
reader = r;
|
|
104
|
+
readerId = id;
|
|
105
|
+
try {
|
|
106
|
+
unsub = r.subscribe(cfg, onCmp);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
unsub = null;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
function settle() {
|
|
116
|
+
finished = true;
|
|
117
|
+
if (timer !== null) {
|
|
118
|
+
try {
|
|
119
|
+
w.clearTimeout(timer);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
/* ignore */
|
|
123
|
+
}
|
|
124
|
+
timer = null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function poll() {
|
|
128
|
+
timer = null;
|
|
129
|
+
if (finished)
|
|
130
|
+
return;
|
|
131
|
+
if (attach()) {
|
|
132
|
+
settle();
|
|
133
|
+
emit();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (Date.now() >= deadline) {
|
|
137
|
+
settle();
|
|
138
|
+
if (cfg.mode === 'auto')
|
|
139
|
+
fallback = true;
|
|
140
|
+
emit();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
try {
|
|
144
|
+
timer = w.setTimeout(poll, 100);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
settle();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Leaving the page before a CMP showed up: apply the no-CMP rule now.
|
|
151
|
+
function onHide(e) {
|
|
152
|
+
if (finished || cfg.mode !== 'auto')
|
|
153
|
+
return;
|
|
154
|
+
if (e && e.type === 'visibilitychange' && w.document && w.document.visibilityState !== 'hidden')
|
|
155
|
+
return;
|
|
156
|
+
if (attach()) {
|
|
157
|
+
settle();
|
|
158
|
+
emit();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
settle();
|
|
162
|
+
fallback = true;
|
|
163
|
+
emit();
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
start() {
|
|
167
|
+
if (started)
|
|
168
|
+
return;
|
|
169
|
+
started = true;
|
|
170
|
+
deadline = Date.now() + wait;
|
|
171
|
+
if (cfg.mode === 'none' || cfg.mode === 'pending') {
|
|
172
|
+
finished = true;
|
|
173
|
+
emit();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
w.addEventListener('pagehide', onHide);
|
|
178
|
+
w.addEventListener('visibilitychange', onHide);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
/* no events: rely on the timer */
|
|
182
|
+
}
|
|
183
|
+
poll();
|
|
184
|
+
},
|
|
185
|
+
state: () => current,
|
|
186
|
+
mode() {
|
|
187
|
+
if (readerId)
|
|
188
|
+
return readerId;
|
|
189
|
+
if (cfg.mode === 'auto')
|
|
190
|
+
return fallback ? 'no-cmp' : 'auto';
|
|
191
|
+
return String(cfg.mode);
|
|
192
|
+
},
|
|
193
|
+
push(granted) {
|
|
194
|
+
pushed = granted === true;
|
|
195
|
+
emit();
|
|
196
|
+
},
|
|
197
|
+
evidence: () => (current === 'unknown' ? null : evidence(current)),
|
|
198
|
+
stop() {
|
|
199
|
+
settle();
|
|
200
|
+
if (unsub) {
|
|
201
|
+
try {
|
|
202
|
+
unsub();
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
/* ignore */
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
w.removeEventListener('pagehide', onHide);
|
|
210
|
+
w.removeEventListener('visibilitychange', onHide);
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
/* ignore */
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
@@ -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,67 @@
|
|
|
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
|
+
/**
|
|
22
|
+
* Adapters `auto` tries, in this order. The merchant's own `referalliConsent`
|
|
23
|
+
* hook wins, then vendor CMPs (their own category model), then the IAB
|
|
24
|
+
* frameworks and Google Consent Mode, which many CMPs also feed.
|
|
25
|
+
*/
|
|
26
|
+
export const AUTO_ORDER = [
|
|
27
|
+
'custom',
|
|
28
|
+
'cookiemunch',
|
|
29
|
+
'onetrust',
|
|
30
|
+
'cookiebot',
|
|
31
|
+
'usercentrics',
|
|
32
|
+
'didomi',
|
|
33
|
+
'osano',
|
|
34
|
+
'termly',
|
|
35
|
+
'tcf',
|
|
36
|
+
'gpp',
|
|
37
|
+
'gcm',
|
|
38
|
+
];
|
|
39
|
+
export const CONSENT_ADAPTER_IDS = [...AUTO_ORDER, 'none'];
|
|
40
|
+
export const CONSENT_MODES = ['auto', 'pending', ...CONSENT_ADAPTER_IDS];
|
|
41
|
+
/**
|
|
42
|
+
* Every consent adapter's `check()`. The CMP lives in the visitor's browser,
|
|
43
|
+
* so there is nothing to probe from a server: the health signal is the
|
|
44
|
+
* consent evidence each visit carries (its `provider` and `state`). This says
|
|
45
|
+
* what the adapter will read with the given config.
|
|
46
|
+
*/
|
|
47
|
+
export async function browserCheck(source, cfg) {
|
|
48
|
+
const what = cfg?.category ?? source.defaultCategory;
|
|
49
|
+
return {
|
|
50
|
+
ok: true,
|
|
51
|
+
detail: `${source.name} is read in the visitor's browser${what ? ` (${what})` : ''}; each visit's consent evidence shows its answer.`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Normalise merchant options into a full config (mode `none` when absent: the pre-consent behaviour). */
|
|
55
|
+
export function consentConfig(opts) {
|
|
56
|
+
const o = typeof opts === 'string' ? { mode: opts } : (opts ?? {});
|
|
57
|
+
const mode = o.mode && CONSENT_MODES.includes(o.mode) ? o.mode : 'none';
|
|
58
|
+
const waitMs = typeof o.waitMs === 'number' && o.waitMs >= 0 ? Math.min(10_000, Math.round(o.waitMs)) : 3000;
|
|
59
|
+
return {
|
|
60
|
+
mode,
|
|
61
|
+
...(typeof o.category === 'string' && o.category ? { category: o.category.slice(0, 80) } : {}),
|
|
62
|
+
...(typeof o.tcfVendorId === 'number' && o.tcfVendorId > 0 ? { tcfVendorId: Math.round(o.tcfVendorId) } : {}),
|
|
63
|
+
...(o.gcmSignal === 'analytics_storage' || o.gcmSignal === 'ad_storage' ? { gcmSignal: o.gcmSignal } : {}),
|
|
64
|
+
noCmp: o.noCmp === 'memory' ? 'memory' : 'persist',
|
|
65
|
+
waitMs,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -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,55 @@
|
|
|
1
|
+
import { cookiebot } from './adapters/cookiebot.js';
|
|
2
|
+
import { cookiemunch } from './adapters/cookiemunch.js';
|
|
3
|
+
import { custom } from './adapters/custom.js';
|
|
4
|
+
import { didomi } from './adapters/didomi.js';
|
|
5
|
+
import { gcm } from './adapters/gcm.js';
|
|
6
|
+
import { gpp } from './adapters/gpp.js';
|
|
7
|
+
import { none } from './adapters/none.js';
|
|
8
|
+
import { onetrust } from './adapters/onetrust.js';
|
|
9
|
+
import { osano } from './adapters/osano.js';
|
|
10
|
+
import { tcf } from './adapters/tcf.js';
|
|
11
|
+
import { termly } from './adapters/termly.js';
|
|
12
|
+
import { usercentrics } from './adapters/usercentrics.js';
|
|
13
|
+
import { AUTO_ORDER } from './port.js';
|
|
14
|
+
/**
|
|
15
|
+
* Every consent adapter, `auto`'s detection order first, then `none`.
|
|
16
|
+
* (`fd-consent`, the suite's `window.__fdConsent`, joins when Cookie Munch
|
|
17
|
+
* ships that contract: CMU-X16.)
|
|
18
|
+
*/
|
|
19
|
+
export const CONSENT_SOURCES = [
|
|
20
|
+
custom,
|
|
21
|
+
cookiemunch,
|
|
22
|
+
onetrust,
|
|
23
|
+
cookiebot,
|
|
24
|
+
usercentrics,
|
|
25
|
+
didomi,
|
|
26
|
+
osano,
|
|
27
|
+
termly,
|
|
28
|
+
tcf,
|
|
29
|
+
gpp,
|
|
30
|
+
gcm,
|
|
31
|
+
none,
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* The consent port's adapters (docs/PORTS.md): every CMP reader, `custom`
|
|
35
|
+
* first. `none` is left out: it reads nothing (it is the "always store" mode,
|
|
36
|
+
* like `auto` and `pending`), so it has no vendor, fixtures or conformance run.
|
|
37
|
+
*/
|
|
38
|
+
export const ADAPTERS = CONSENT_SOURCES.filter((s) => s.id !== 'none');
|
|
39
|
+
const BY_ID = new Map(CONSENT_SOURCES.map((s) => [s.id, s]));
|
|
40
|
+
export function adapterOf(id) {
|
|
41
|
+
return BY_ID.get(id);
|
|
42
|
+
}
|
|
43
|
+
/** `{ id: factory }` for the gate, limited to `ids` (default: every adapter). */
|
|
44
|
+
export function adapterFactories(ids = AUTO_ORDER) {
|
|
45
|
+
const out = {};
|
|
46
|
+
for (const id of ids) {
|
|
47
|
+
const s = BY_ID.get(id);
|
|
48
|
+
if (s)
|
|
49
|
+
out[id] = s.factory;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
export function isConsentAdapterId(id) {
|
|
54
|
+
return typeof id === 'string' && BY_ID.has(id);
|
|
55
|
+
}
|
|
@@ -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,22 @@
|
|
|
1
|
+
import { consentGate } from './gate.js';
|
|
2
|
+
import { AUTO_ORDER } from './port.js';
|
|
3
|
+
import { adapterOf } from './registry.js';
|
|
4
|
+
/**
|
|
5
|
+
* The consent gate and adapters as JavaScript source, for the served aff.js.
|
|
6
|
+
* Built from the same functions the module build runs (their source text), so
|
|
7
|
+
* there is one implementation. `__name` is a no-op stand-in for the helper
|
|
8
|
+
* esbuild (tsx, vitest) inserts into function bodies under keepNames.
|
|
9
|
+
*
|
|
10
|
+
* `ids`: the adapters to inline (default: all of `auto`'s, in order).
|
|
11
|
+
*/
|
|
12
|
+
export function consentSource(ids = AUTO_ORDER) {
|
|
13
|
+
const list = AUTO_ORDER.filter((id) => ids.includes(id));
|
|
14
|
+
const adapters = list.map((id) => `${JSON.stringify(id)}:(${String(adapterOf(id).factory)})`).join(',\n');
|
|
15
|
+
return {
|
|
16
|
+
gate: `(${String(consentGate)})`,
|
|
17
|
+
adapters: `{${adapters}}`,
|
|
18
|
+
order: JSON.stringify(list),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** The no-op `__name` shim (see consentSource). */
|
|
22
|
+
export const 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/esm/core.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ReferalliError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* A list call. Await it for the first page, or iterate it with `for await`
|
|
4
|
+
* to get every item, fetching further pages (`starting_after`) as you go.
|
|
5
|
+
* Nothing is requested until you do one or the other.
|
|
6
|
+
*/
|
|
7
|
+
export class ListPromise {
|
|
8
|
+
fetchPage;
|
|
9
|
+
first = null;
|
|
10
|
+
constructor(fetchPage) {
|
|
11
|
+
this.fetchPage = fetchPage;
|
|
12
|
+
}
|
|
13
|
+
firstPage() {
|
|
14
|
+
this.first ??= this.fetchPage(undefined).then(checkPage);
|
|
15
|
+
return this.first;
|
|
16
|
+
}
|
|
17
|
+
then(onfulfilled, onrejected) {
|
|
18
|
+
return this.firstPage().then(onfulfilled, onrejected);
|
|
19
|
+
}
|
|
20
|
+
catch(onrejected) {
|
|
21
|
+
return this.firstPage().catch(onrejected);
|
|
22
|
+
}
|
|
23
|
+
finally(onfinally) {
|
|
24
|
+
return this.firstPage().finally(onfinally);
|
|
25
|
+
}
|
|
26
|
+
/** Every page, starting with the first. */
|
|
27
|
+
async *pages() {
|
|
28
|
+
let page = await this.firstPage();
|
|
29
|
+
for (;;) {
|
|
30
|
+
yield page;
|
|
31
|
+
if (!page.has_more || !page.next_cursor)
|
|
32
|
+
return;
|
|
33
|
+
page = checkPage(await this.fetchPage(page.next_cursor));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async *[Symbol.asyncIterator]() {
|
|
37
|
+
for await (const page of this.pages())
|
|
38
|
+
yield* page.data;
|
|
39
|
+
}
|
|
40
|
+
/** Collect items into an array, stopping at `limit` (default 10,000) so a runaway list can't exhaust memory. */
|
|
41
|
+
async toArray(opts = {}) {
|
|
42
|
+
const limit = opts.limit ?? 10_000;
|
|
43
|
+
const out = [];
|
|
44
|
+
if (limit <= 0)
|
|
45
|
+
return out;
|
|
46
|
+
for await (const item of this) {
|
|
47
|
+
out.push(item);
|
|
48
|
+
if (out.length >= limit)
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function checkPage(page) {
|
|
55
|
+
const p = page;
|
|
56
|
+
if (!p || typeof p !== 'object' || !Array.isArray(p.data)) {
|
|
57
|
+
throw new ReferalliError('the API did not return a list page: send referalli-version 2026-11-01 or later (the SDK default)');
|
|
58
|
+
}
|
|
59
|
+
return page;
|
|
60
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Base class for every error this SDK throws. */
|
|
2
|
+
export declare class ReferalliError extends Error {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
}
|
|
5
|
+
/** The API could not be reached (network failure), after any retries. */
|
|
6
|
+
export declare class ApiConnectionError extends ReferalliError {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
constructor(message: string, options?: {
|
|
9
|
+
cause?: unknown;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** The request took longer than `timeout`, after any retries. */
|
|
13
|
+
export declare class ApiTimeoutError extends ApiConnectionError {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ApiErrorInit {
|
|
17
|
+
status: number;
|
|
18
|
+
code: string;
|
|
19
|
+
message: string;
|
|
20
|
+
requestId?: string | null;
|
|
21
|
+
docsUrl?: string | null;
|
|
22
|
+
details?: unknown;
|
|
23
|
+
/** Seconds the API asked us to wait (`Retry-After`), if it said. */
|
|
24
|
+
retryAfter?: number | null;
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The API answered with an error. `code` is stable (see
|
|
29
|
+
* https://referalli.com/docs/errors-and-limits); each code has its own
|
|
30
|
+
* subclass (`NotFoundError`, `RateLimitedError`, …) so you can `instanceof`.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ApiError extends ReferalliError {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly status: number;
|
|
35
|
+
readonly code: string;
|
|
36
|
+
readonly requestId: string | null;
|
|
37
|
+
readonly docsUrl: string | null;
|
|
38
|
+
readonly details: unknown;
|
|
39
|
+
readonly retryAfter: number | null;
|
|
40
|
+
readonly headers: Record<string, string>;
|
|
41
|
+
constructor(init: ApiErrorInit);
|
|
42
|
+
}
|