@dataships/sdk 0.0.0-stage → 2.0.1

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.
@@ -0,0 +1,354 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
8
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
9
+
10
+ // src/session/previewUpsertResponse.ts
11
+ var DEFAULT_EMAIL_OPT_IN_TEXT = "We would like to email you news and promotions. Tick to opt in.";
12
+ var DEFAULT_EMAIL_OPT_IN_CONSENT_DESCRIPTION = "Click here for an overview of how your personal data is processed for marketing purposes or see our Privacy Policy for further information.";
13
+ var DEFAULT_SMS_OPT_IN_TEXT = "We would like to text you news and promotions. Tick to opt in.";
14
+ var DEFAULT_SMS_OPT_IN_CONSENT_DESCRIPTION = "Based on the channel preferences set above, you agree to receive recurring automated marketing messages (e.g. AI content, cart reminders) from {{COMPANY_NAME}} at the number you provide. Consent is not a condition of purchase. We may share info with service providers per our Privacy Policy. Reply STOP to cancel or click the unsubscribe link (where available). For help reply HELP or email {{PRIVACY_EMAIL}}. Msg frequency varies. Msg & data rates may apply. By proceeding, you also agree to our Terms of Service (incl. arbitration) & Privacy Policy.";
15
+ var fakeEmailUpsertResponse = {
16
+ consentSessionId: "01HQB3QRZVV0737R0R25BTQBGF",
17
+ consents: [
18
+ {
19
+ channel: "EMAIL",
20
+ consentType: "OPT_IN",
21
+ checked: false,
22
+ widgetConfig: {
23
+ text: DEFAULT_EMAIL_OPT_IN_TEXT,
24
+ consentDescription: DEFAULT_EMAIL_OPT_IN_CONSENT_DESCRIPTION,
25
+ marketingInformation: '<h1>Marketing Information</h1>\n<p>We may send you direct marketing communications, product information and promotional offers. You can withdraw your consent at any time. See our <a href="https://dataships.io/privacy-centre">Privacy Policy</a> or contact us at <a href="mailto:privacy@example.com">privacy@example.com</a> for further information.</p>\n',
26
+ policyURL: "https://dataships.io/privacy-centre",
27
+ mobileTermsOfServiceURL: null,
28
+ privacyEmail: "privacy@example.com",
29
+ placeholderValues: null
30
+ }
31
+ }
32
+ ],
33
+ userVerificationRequired: null,
34
+ lastHeartbeat: "2026-06-17T00:00:00Z",
35
+ identifier: null
36
+ };
37
+ var fakePhoneUpsertResponse = {
38
+ consentSessionId: "01HQB3QRZVV0737R0R25BTQBGG",
39
+ consents: [
40
+ {
41
+ channel: "SMS",
42
+ consentType: "OPT_IN",
43
+ checked: false,
44
+ widgetConfig: {
45
+ text: DEFAULT_SMS_OPT_IN_TEXT,
46
+ consentDescription: DEFAULT_SMS_OPT_IN_CONSENT_DESCRIPTION,
47
+ marketingInformation: '<h1>Marketing Information</h1>\n<p>We may send you marketing text messages about products and promotional offers. Message frequency varies. You can withdraw your consent at any time by replying STOP. See our <a href="https://dataships.io/privacy-centre">Privacy Policy</a> or contact us at <a href="mailto:privacy@example.com">privacy@example.com</a> for further information.</p>\n',
48
+ policyURL: "https://dataships.io/privacy-centre",
49
+ mobileTermsOfServiceURL: "https://dataships.io/mobile-terms",
50
+ privacyEmail: "privacy@example.com",
51
+ placeholderValues: null
52
+ }
53
+ }
54
+ ],
55
+ userVerificationRequired: false,
56
+ lastHeartbeat: "2026-06-17T00:00:00Z",
57
+ identifier: null
58
+ };
59
+ var MARKETING_MODAL_HREF = "#dataships-marketing-modal";
60
+ var CHECKBOX_LABEL_BOLD_PHRASES = ["consent", "object", "opt in", "opt out", "STOP", "HELP"];
61
+ var CONSENT_DESCRIPTION_BOLD_PHRASES = ["STOP", "HELP"];
62
+ var escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
63
+ var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
64
+ var wrapPhrase = (html, phrase, wrap) => html.replace(
65
+ new RegExp(`${escapeRegExp(escapeHtml(phrase))}(?![^<]*>)(?![^<]*</a>)`, "gi"),
66
+ wrap
67
+ );
68
+ var toHtmlCopy = (text, widgetConfig, boldPhrases) => {
69
+ let html = escapeHtml(text);
70
+ const links = [
71
+ ["Terms of Service", widgetConfig.mobileTermsOfServiceURL],
72
+ ["Privacy Policy", widgetConfig.policyURL],
73
+ ["Click here", MARKETING_MODAL_HREF]
74
+ ];
75
+ for (const [phrase, href] of links) {
76
+ if (!href) continue;
77
+ html = wrapPhrase(html, phrase, (match) => `<a href="${escapeHtml(href)}">${match}</a>`);
78
+ }
79
+ for (const phrase of boldPhrases) {
80
+ html = wrapPhrase(html, phrase, (match) => `<strong>${match}</strong>`);
81
+ }
82
+ return `<p>${html}</p>`;
83
+ };
84
+ var withHtmlCopy = (response) => ({
85
+ ...response,
86
+ consents: response.consents.map((consent) => {
87
+ const { widgetConfig } = consent;
88
+ return {
89
+ ...consent,
90
+ widgetConfig: {
91
+ ...widgetConfig,
92
+ text: widgetConfig.text === null ? null : toHtmlCopy(widgetConfig.text, widgetConfig, CHECKBOX_LABEL_BOLD_PHRASES),
93
+ consentDescription: widgetConfig.consentDescription === null ? null : toHtmlCopy(
94
+ widgetConfig.consentDescription,
95
+ widgetConfig,
96
+ CONSENT_DESCRIPTION_BOLD_PHRASES
97
+ )
98
+ }
99
+ };
100
+ })
101
+ });
102
+ var previewUpsertResponse = (identifierType, format = "json") => {
103
+ const response = identifierType === "PHONE" ? fakePhoneUpsertResponse : fakeEmailUpsertResponse;
104
+ return format === "html" ? withHtmlCopy(response) : response;
105
+ };
106
+
107
+ // src/utils/uuid.ts
108
+ var randomUuid = (cryptoObj = globalThis.crypto) => {
109
+ if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
110
+ return cryptoObj.randomUUID();
111
+ }
112
+ const bytes = new Uint8Array(16);
113
+ if (cryptoObj && typeof cryptoObj.getRandomValues === "function") {
114
+ cryptoObj.getRandomValues(bytes);
115
+ } else {
116
+ for (let i = 0; i < 16; i++) bytes[i] = Math.floor(Math.random() * 256);
117
+ }
118
+ bytes[6] = bytes[6] & 15 | 64;
119
+ bytes[8] = bytes[8] & 63 | 128;
120
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0"));
121
+ return hex.slice(0, 4).join("") + "-" + hex.slice(4, 6).join("") + "-" + hex.slice(6, 8).join("") + "-" + hex.slice(8, 10).join("") + "-" + hex.slice(10, 16).join("");
122
+ };
123
+
124
+ // src/adapters/beacon.ts
125
+ var DATASHIPS_SESSION_ID_MAX_LENGTH = 100;
126
+ var _explicitId, _storageKey, _window, _id, _SessionBeacon_instances, safeStorage_fn;
127
+ var SessionBeacon = class {
128
+ constructor(opts) {
129
+ __privateAdd(this, _SessionBeacon_instances);
130
+ __privateAdd(this, _explicitId);
131
+ __privateAdd(this, _storageKey);
132
+ __privateAdd(this, _window);
133
+ __privateAdd(this, _id, null);
134
+ if (opts.explicitId != null) assertSessionId(opts.explicitId);
135
+ __privateSet(this, _explicitId, opts.explicitId ?? null);
136
+ __privateSet(this, _storageKey, opts.storageKey);
137
+ __privateSet(this, _window, opts.window ?? globalThis.window);
138
+ }
139
+ /**
140
+ * The beacon for this page. On first use a stored id is reused when
141
+ * `reusable(stored)` says so, otherwise a fresh UUID is minted; the record is
142
+ * rewritten with `step` every time so the next page knows where it was last
143
+ * used. Later calls return the same id for the adapter's lifetime.
144
+ */
145
+ resolve(step, reusable) {
146
+ if (__privateGet(this, _explicitId)) return __privateGet(this, _explicitId);
147
+ const storage = __privateMethod(this, _SessionBeacon_instances, safeStorage_fn).call(this);
148
+ if (null === __privateGet(this, _id)) {
149
+ const stored = storage ? readStored(storage, __privateGet(this, _storageKey)) : null;
150
+ __privateSet(this, _id, stored && reusable(stored) ? stored.id : randomUuid(__privateGet(this, _window)?.crypto));
151
+ }
152
+ if (storage) {
153
+ try {
154
+ storage.setItem(__privateGet(this, _storageKey), JSON.stringify({ id: __privateGet(this, _id), lastStep: step }));
155
+ } catch {
156
+ }
157
+ }
158
+ return __privateGet(this, _id);
159
+ }
160
+ /** Discard the beacon so the next {@link resolve} mints a fresh one. No-op for an integrator-owned id. */
161
+ reset() {
162
+ if (__privateGet(this, _explicitId)) return;
163
+ __privateSet(this, _id, null);
164
+ const storage = __privateMethod(this, _SessionBeacon_instances, safeStorage_fn).call(this);
165
+ if (!storage) return;
166
+ try {
167
+ storage.removeItem(__privateGet(this, _storageKey));
168
+ } catch {
169
+ }
170
+ }
171
+ };
172
+ _explicitId = new WeakMap();
173
+ _storageKey = new WeakMap();
174
+ _window = new WeakMap();
175
+ _id = new WeakMap();
176
+ _SessionBeacon_instances = new WeakSet();
177
+ safeStorage_fn = function() {
178
+ try {
179
+ return __privateGet(this, _window)?.localStorage ?? null;
180
+ } catch {
181
+ return null;
182
+ }
183
+ };
184
+ var assertSessionId = (id) => {
185
+ if (typeof id !== "string" || id.length === 0) {
186
+ throw new Error("datashipsSessionId must be a non-empty string");
187
+ }
188
+ if (id.length > DATASHIPS_SESSION_ID_MAX_LENGTH) {
189
+ throw new Error(
190
+ `datashipsSessionId must be at most ${DATASHIPS_SESSION_ID_MAX_LENGTH} characters`
191
+ );
192
+ }
193
+ };
194
+ var readStored = (storage, key) => {
195
+ let raw;
196
+ try {
197
+ raw = storage.getItem(key);
198
+ } catch {
199
+ return null;
200
+ }
201
+ if (!raw) return null;
202
+ try {
203
+ const parsed = JSON.parse(raw);
204
+ if (typeof parsed?.id !== "string" || parsed.id.length === 0) return null;
205
+ return { id: parsed.id, lastStep: typeof parsed.lastStep === "string" ? parsed.lastStep : null };
206
+ } catch {
207
+ return null;
208
+ }
209
+ };
210
+
211
+ // src/types.ts
212
+ var SUPPORTED_LOCALES = [
213
+ "en",
214
+ "es",
215
+ "de",
216
+ "pt",
217
+ "ro",
218
+ "hr",
219
+ "da",
220
+ "fi",
221
+ "fr",
222
+ "hu",
223
+ "it",
224
+ "nb",
225
+ "pl",
226
+ "sk",
227
+ "sv",
228
+ "nl",
229
+ "el",
230
+ "cs",
231
+ "zh",
232
+ "ja",
233
+ "is"
234
+ ];
235
+
236
+ // src/adapters/locale.ts
237
+ var coerceLocale = (raw) => {
238
+ if (!raw) return "en";
239
+ const head = raw.split(/[_-]/)[0]?.toLowerCase() ?? "";
240
+ return SUPPORTED_LOCALES.includes(head) ? head : "en";
241
+ };
242
+
243
+ // src/adapters/custom-platform-checkout/index.ts
244
+ var CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE = "CUSTOM_PLATFORM_CHECKOUT";
245
+ var STORAGE_KEY_PREFIX = "datashipsSessionId:";
246
+ var DEFAULT_STORAGE_SCOPE = "default";
247
+ var _collectionStep, _locale, _isFastCheckout, _identifiers, _storageScope, _beacon, _CustomPlatformCheckoutAdapter_instances, resolveSessionId_fn;
248
+ var CustomPlatformCheckoutAdapter = class {
249
+ constructor(opts) {
250
+ __privateAdd(this, _CustomPlatformCheckoutAdapter_instances);
251
+ this.name = "CustomPlatformCheckoutAdapter";
252
+ this.sessionApi = "consent-session";
253
+ this.integrationType = CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE;
254
+ __privateAdd(this, _collectionStep);
255
+ __privateAdd(this, _locale);
256
+ __privateAdd(this, _isFastCheckout);
257
+ __privateAdd(this, _identifiers);
258
+ __privateAdd(this, _storageScope);
259
+ __privateAdd(this, _beacon);
260
+ if (!opts || !opts.collectionStep) {
261
+ throw new Error(
262
+ "CustomPlatformCheckoutAdapter: `collectionStep` is required"
263
+ );
264
+ }
265
+ __privateSet(this, _collectionStep, opts.collectionStep);
266
+ __privateSet(this, _locale, coerceLocale(opts.locale));
267
+ __privateSet(this, _isFastCheckout, opts.isFastCheckout ?? false);
268
+ __privateSet(this, _identifiers, {
269
+ EMAIL: opts.email ?? null,
270
+ PHONE: opts.phone ?? null
271
+ });
272
+ __privateSet(this, _storageScope, opts.storageScope ?? DEFAULT_STORAGE_SCOPE);
273
+ try {
274
+ __privateSet(this, _beacon, new SessionBeacon({
275
+ explicitId: opts.datashipsSessionId,
276
+ storageKey: `${STORAGE_KEY_PREFIX}${__privateGet(this, _storageScope)}`,
277
+ window: opts.window
278
+ }));
279
+ } catch (e) {
280
+ throw new Error(`CustomPlatformCheckoutAdapter: ${e.message}`);
281
+ }
282
+ this.previewMode = opts.previewMode ?? false;
283
+ }
284
+ /** Synthetic upsert response served in {@link previewMode}, matching the requested identifier type. */
285
+ getPreviewUpsertResponse(identifierType = "EMAIL", format) {
286
+ return previewUpsertResponse(identifierType, format);
287
+ }
288
+ getLocale() {
289
+ return __privateGet(this, _locale);
290
+ }
291
+ get collectionStep() {
292
+ return __privateGet(this, _collectionStep);
293
+ }
294
+ /** Move the same adapter to another step, e.g. a single-page checkout reaching its confirmation view. */
295
+ setCollectionStep(step) {
296
+ __privateSet(this, _collectionStep, step);
297
+ }
298
+ get isFastCheckout() {
299
+ return __privateGet(this, _isFastCheckout);
300
+ }
301
+ setFastCheckout(isFastCheckout) {
302
+ __privateSet(this, _isFastCheckout, isFastCheckout);
303
+ }
304
+ /**
305
+ * Remember an identifier the shopper typed so later calls (a refresh, a
306
+ * remount) resolve it without the caller passing it again. An explicit
307
+ * `upsertSession({ identifier })` still takes precedence.
308
+ */
309
+ setIdentifier(identifierType, value) {
310
+ __privateGet(this, _identifiers)[identifierType] = value;
311
+ }
312
+ getIdentifier(identifierType) {
313
+ return { identifier: __privateGet(this, _identifiers)[identifierType], identifierType };
314
+ }
315
+ /** The beacon this checkout is known by; resolved (and persisted) on first use. */
316
+ getDatashipsSessionId() {
317
+ return __privateMethod(this, _CustomPlatformCheckoutAdapter_instances, resolveSessionId_fn).call(this);
318
+ }
319
+ /**
320
+ * Discard the current beacon so the next call mints a fresh one. Call it once
321
+ * the order has been submitted, so the next checkout on this browser opens a
322
+ * new session instead of touching the processed one. No-op for an
323
+ * integrator-owned id.
324
+ */
325
+ resetDatashipsSessionId() {
326
+ __privateGet(this, _beacon).reset();
327
+ }
328
+ async getSessionContext() {
329
+ return {
330
+ collectionStep: __privateGet(this, _collectionStep),
331
+ datashipsSessionId: __privateMethod(this, _CustomPlatformCheckoutAdapter_instances, resolveSessionId_fn).call(this),
332
+ isFastCheckout: __privateGet(this, _isFastCheckout)
333
+ };
334
+ }
335
+ };
336
+ _collectionStep = new WeakMap();
337
+ _locale = new WeakMap();
338
+ _isFastCheckout = new WeakMap();
339
+ _identifiers = new WeakMap();
340
+ _storageScope = new WeakMap();
341
+ _beacon = new WeakMap();
342
+ _CustomPlatformCheckoutAdapter_instances = new WeakSet();
343
+ resolveSessionId_fn = function() {
344
+ const step = __privateGet(this, _collectionStep);
345
+ return __privateGet(this, _beacon).resolve(step, (stored) => {
346
+ const lastStep = isCollectionStep(stored.lastStep) ? stored.lastStep : "CHECKOUT_INFORMATION";
347
+ return !(step === "CHECKOUT_INFORMATION" && lastStep !== "CHECKOUT_INFORMATION");
348
+ });
349
+ };
350
+ var isCollectionStep = (value) => value === "CHECKOUT_INFORMATION" || value === "THANK_YOU" || value === "ORDER_STATUS";
351
+
352
+ export { CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE, CustomPlatformCheckoutAdapter, DATASHIPS_SESSION_ID_MAX_LENGTH, coerceLocale };
353
+ //# sourceMappingURL=index.js.map
354
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/session/previewUpsertResponse.ts","../../../src/utils/uuid.ts","../../../src/adapters/beacon.ts","../../../src/types.ts","../../../src/adapters/locale.ts","../../../src/adapters/custom-platform-checkout/index.ts"],"names":[],"mappings":";;;;;;;;;;AAeA,IAAM,yBAAA,GACJ,iEAAA;AACF,IAAM,wCAAA,GACJ,6IAAA;AACF,IAAM,uBAA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AAA,EAAA;AACA,OAAA,GAAA,IAAA,OAAA,EAAA;AACA,eAAA,GAAA,IAAA,OAAA,EAAA;AACA,YAAA,GAAA,IAAA,OAAA,EAAA;AACA,aAAA,GAAA,IAAA,OAAA,EAAA;AACS,OAAA,GAAA,IAAA,OAAA,EAAA;AAbJ,wCAAA,GAAA,IAAA,OAAA,EAAA;AA4GL,mBAAA,GAAiB,WAAW;AAC1B,EAAA,MAAM,OAAO,YAAA,CAAA,IAAA,EAAK,eAAA,CAAA;AAIlB,EAAA,OAAO,YAAA,CAAA,IAAA,EAAK,OAAA,CAAA,CAAQ,OAAA,CAAQ,IAAA,EAAM,CAAC,MAAA,KAAyB;AAC1D,IAAA,MAAM,WAAW,gBAAA,CAAiB,MAAA,CAAO,QAAQ,CAAA,GAAI,OAAO,QAAA,GAAW,sBAAA;AACvE,IAAA,OAAO,EAAE,IAAA,KAAS,sBAAA,IAA0B,QAAA,KAAa,sBAAA,CAAA;AAAA,EAC3D,CAAC,CAAA;AACH,CAAA;AAGF,IAAM,mBAAmB,CACvB,KAAA,KAEA,UAAU,sBAAA,IACV,KAAA,KAAU,eACV,KAAA,KAAU,cAAA","file":"index.js"}
@@ -0,0 +1,119 @@
1
+ import { C as ConsentSessionAdapter, I as IdentifierType, a as ConsentCopyFormat, U as UpsertSessionResponse, S as SupportedLocale, b as ConsentSessionIdentifier } from '../../types-vPJjFMJw.js';
2
+ export { D as DATASHIPS_SESSION_ID_MAX_LENGTH } from '../../beacon-B8v41O8P.js';
3
+ export { c as coerceLocale } from '../../locale-B1o0kX7n.js';
4
+
5
+ /**
6
+ * Integration-specific fields the custom-platform signup adapter contributes to
7
+ * the consent-session envelope, merged under `integration`. The client injects
8
+ * `type: "CUSTOM_PLATFORM_SIGNUP"`; the identifier and `locale` travel at the
9
+ * top level; the merchant is identified by the `X-Api-Key` header.
10
+ *
11
+ * `datashipsSessionId` is the SDK-generated beacon for one form fill: sent on
12
+ * every upsert and echoed on submit, which is how the signup is mapped back
13
+ * onto the EMAIL / PHONE sibling sessions. Nothing else travels on the upsert;
14
+ * the user's name goes with the submission.
15
+ */
16
+ interface CustomPlatformSignupSessionContext {
17
+ datashipsSessionId: string;
18
+ }
19
+ /** The person signing up, as the merchant's own form or backend knows them. */
20
+ interface CustomPlatformSignupUser {
21
+ firstName?: string | null;
22
+ lastName?: string | null;
23
+ email?: string | null;
24
+ phone?: string | null;
25
+ }
26
+
27
+ /** `integration.type` discriminator core-api routes to the custom-platform signup lifecycle. */
28
+ declare const CUSTOM_PLATFORM_SIGNUP_INTEGRATION_TYPE = "CUSTOM_PLATFORM_SIGNUP";
29
+
30
+ /**
31
+ * Where the adapter reads the user from: a literal, or a function invoked
32
+ * on every call so the latest form values are used (e.g. read the inputs as
33
+ * the user types). May be async, e.g. fetch from the merchant's own backend.
34
+ */
35
+ type CustomPlatformSignupUserSource = CustomPlatformSignupUser | (() => CustomPlatformSignupUser | Promise<CustomPlatformSignupUser>);
36
+ interface CustomPlatformSignupAdapterOptions {
37
+ /**
38
+ * The visitor's language. Any BCP 47 / POSIX style string is accepted
39
+ * (`en`, `en-US`, `fr_CA`); the first segment is used when it maps to a
40
+ * {@link SupportedLocale}, otherwise `"en"`. Travels at the top level of
41
+ * the envelope as `locale`.
42
+ */
43
+ locale?: string;
44
+ /**
45
+ * The user signing up, or a resolver called on every upsert. Supplies the
46
+ * EMAIL / PHONE identifiers (an explicit `upsertSession({ identifier })` or
47
+ * {@link CustomPlatformSignupAdapter.setIdentifier} wins) and the name for
48
+ * the submission. Defaults to nobody known yet.
49
+ */
50
+ user?: CustomPlatformSignupUserSource;
51
+ /**
52
+ * Bring your own form-fill beacon. When set the adapter never touches
53
+ * `localStorage`; the integrator owns the lifecycle (one id per form fill,
54
+ * echoed on submit). At most 100 characters.
55
+ */
56
+ datashipsSessionId?: string;
57
+ /**
58
+ * Scopes the `localStorage` entry that keeps the beacon stable across a
59
+ * reload of the form, so two merchants (or two stores) on one origin do not
60
+ * share a signup. Typically the merchant's public key.
61
+ */
62
+ storageScope?: string;
63
+ /**
64
+ * When true the client never calls the API and serves synthetic email data
65
+ * instead, so the widget can be styled without credentials. Defaults to
66
+ * false.
67
+ */
68
+ previewMode?: boolean;
69
+ /** Override the window for tests. Defaults to `globalThis.window`. */
70
+ window?: Window;
71
+ }
72
+ /**
73
+ * Consent-session adapter for a merchant-built signup form (newsletter,
74
+ * account creation) on a platform Dataships has no native integration with.
75
+ * Drives the `CUSTOM_PLATFORM_SIGNUP` upsert type on `POST /v1/consent-session`.
76
+ *
77
+ * The integration context is only the `datashipsSessionId` beacon: one id per
78
+ * form fill, minted on first use, kept in `localStorage` so a reload of the
79
+ * form continues the same session, and echoed on submit so core-api maps the
80
+ * signup onto the session. Call {@link resetDatashipsSessionId} once the form
81
+ * has been submitted so the next visitor on this browser gets a fresh id.
82
+ *
83
+ * The user's name is not part of the upsert; it is kept on the adapter
84
+ * ({@link getUser}) for the submission.
85
+ */
86
+ declare class CustomPlatformSignupAdapter implements ConsentSessionAdapter<CustomPlatformSignupSessionContext> {
87
+ #private;
88
+ readonly name: string;
89
+ readonly sessionApi: "consent-session";
90
+ readonly integrationType = "CUSTOM_PLATFORM_SIGNUP";
91
+ readonly previewMode: boolean;
92
+ constructor(opts?: CustomPlatformSignupAdapterOptions);
93
+ /** Synthetic upsert response served in {@link previewMode}, matching the requested identifier type. */
94
+ getPreviewUpsertResponse(identifierType?: IdentifierType, format?: ConsentCopyFormat): UpsertSessionResponse;
95
+ getLocale(): SupportedLocale;
96
+ /** Change the envelope locale, e.g. when the visitor switches language on the form. */
97
+ setLocale(locale: string): void;
98
+ /**
99
+ * Remember an identifier the visitor typed so later calls resolve it without
100
+ * the user resolver. Pass null to fall back to the resolver again. An
101
+ * explicit `upsertSession({ identifier })` still takes precedence.
102
+ */
103
+ setIdentifier(identifierType: IdentifierType, value: string | null): void;
104
+ getIdentifier(identifierType: IdentifierType): Promise<ConsentSessionIdentifier>;
105
+ /** The user as the merchant's form or backend knows them right now, names and contacts trimmed. */
106
+ getUser(): Promise<CustomPlatformSignupUser>;
107
+ /** The beacon this form fill is known by; resolved (and persisted) on first use. */
108
+ getDatashipsSessionId(): string;
109
+ /**
110
+ * Discard the current beacon so the next call mints a fresh one. Call it once
111
+ * the form has been submitted, so a second signup on this browser opens a new
112
+ * session instead of touching the completed one. No-op for an
113
+ * integrator-owned id.
114
+ */
115
+ resetDatashipsSessionId(): void;
116
+ getSessionContext(): Promise<CustomPlatformSignupSessionContext>;
117
+ }
118
+
119
+ export { CUSTOM_PLATFORM_SIGNUP_INTEGRATION_TYPE, CustomPlatformSignupAdapter, type CustomPlatformSignupAdapterOptions, type CustomPlatformSignupSessionContext, type CustomPlatformSignupUser, type CustomPlatformSignupUserSource };