@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,228 @@
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
+
9
+ // src/session/previewUpsertResponse.ts
10
+ var DEFAULT_EMAIL_OPT_IN_TEXT = "We would like to email you news and promotions. Tick to opt in.";
11
+ 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.";
12
+ var DEFAULT_SMS_OPT_IN_TEXT = "We would like to text you news and promotions. Tick to opt in.";
13
+ 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.";
14
+ var fakeEmailUpsertResponse = {
15
+ consentSessionId: "01HQB3QRZVV0737R0R25BTQBGF",
16
+ consents: [
17
+ {
18
+ channel: "EMAIL",
19
+ consentType: "OPT_IN",
20
+ checked: false,
21
+ widgetConfig: {
22
+ text: DEFAULT_EMAIL_OPT_IN_TEXT,
23
+ consentDescription: DEFAULT_EMAIL_OPT_IN_CONSENT_DESCRIPTION,
24
+ 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',
25
+ policyURL: "https://dataships.io/privacy-centre",
26
+ mobileTermsOfServiceURL: null,
27
+ privacyEmail: "privacy@example.com",
28
+ placeholderValues: null
29
+ }
30
+ }
31
+ ],
32
+ userVerificationRequired: null,
33
+ lastHeartbeat: "2026-06-17T00:00:00Z",
34
+ identifier: null
35
+ };
36
+ var fakePhoneUpsertResponse = {
37
+ consentSessionId: "01HQB3QRZVV0737R0R25BTQBGG",
38
+ consents: [
39
+ {
40
+ channel: "SMS",
41
+ consentType: "OPT_IN",
42
+ checked: false,
43
+ widgetConfig: {
44
+ text: DEFAULT_SMS_OPT_IN_TEXT,
45
+ consentDescription: DEFAULT_SMS_OPT_IN_CONSENT_DESCRIPTION,
46
+ 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',
47
+ policyURL: "https://dataships.io/privacy-centre",
48
+ mobileTermsOfServiceURL: "https://dataships.io/mobile-terms",
49
+ privacyEmail: "privacy@example.com",
50
+ placeholderValues: null
51
+ }
52
+ }
53
+ ],
54
+ userVerificationRequired: false,
55
+ lastHeartbeat: "2026-06-17T00:00:00Z",
56
+ identifier: null
57
+ };
58
+ var MARKETING_MODAL_HREF = "#dataships-marketing-modal";
59
+ var CHECKBOX_LABEL_BOLD_PHRASES = ["consent", "object", "opt in", "opt out", "STOP", "HELP"];
60
+ var CONSENT_DESCRIPTION_BOLD_PHRASES = ["STOP", "HELP"];
61
+ var escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
62
+ var escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
63
+ var wrapPhrase = (html, phrase, wrap) => html.replace(
64
+ new RegExp(`${escapeRegExp(escapeHtml(phrase))}(?![^<]*>)(?![^<]*</a>)`, "gi"),
65
+ wrap
66
+ );
67
+ var toHtmlCopy = (text, widgetConfig, boldPhrases) => {
68
+ let html = escapeHtml(text);
69
+ const links = [
70
+ ["Terms of Service", widgetConfig.mobileTermsOfServiceURL],
71
+ ["Privacy Policy", widgetConfig.policyURL],
72
+ ["Click here", MARKETING_MODAL_HREF]
73
+ ];
74
+ for (const [phrase, href] of links) {
75
+ if (!href) continue;
76
+ html = wrapPhrase(html, phrase, (match) => `<a href="${escapeHtml(href)}">${match}</a>`);
77
+ }
78
+ for (const phrase of boldPhrases) {
79
+ html = wrapPhrase(html, phrase, (match) => `<strong>${match}</strong>`);
80
+ }
81
+ return `<p>${html}</p>`;
82
+ };
83
+ var withHtmlCopy = (response) => ({
84
+ ...response,
85
+ consents: response.consents.map((consent) => {
86
+ const { widgetConfig } = consent;
87
+ return {
88
+ ...consent,
89
+ widgetConfig: {
90
+ ...widgetConfig,
91
+ text: widgetConfig.text === null ? null : toHtmlCopy(widgetConfig.text, widgetConfig, CHECKBOX_LABEL_BOLD_PHRASES),
92
+ consentDescription: widgetConfig.consentDescription === null ? null : toHtmlCopy(
93
+ widgetConfig.consentDescription,
94
+ widgetConfig,
95
+ CONSENT_DESCRIPTION_BOLD_PHRASES
96
+ )
97
+ }
98
+ };
99
+ })
100
+ });
101
+ var previewUpsertResponse = (identifierType, format = "json") => {
102
+ const response = identifierType === "PHONE" ? fakePhoneUpsertResponse : fakeEmailUpsertResponse;
103
+ return format === "html" ? withHtmlCopy(response) : response;
104
+ };
105
+
106
+ // src/types.ts
107
+ var SUPPORTED_LOCALES = [
108
+ "en",
109
+ "es",
110
+ "de",
111
+ "pt",
112
+ "ro",
113
+ "hr",
114
+ "da",
115
+ "fi",
116
+ "fr",
117
+ "hu",
118
+ "it",
119
+ "nb",
120
+ "pl",
121
+ "sk",
122
+ "sv",
123
+ "nl",
124
+ "el",
125
+ "cs",
126
+ "zh",
127
+ "ja",
128
+ "is"
129
+ ];
130
+
131
+ // src/adapters/locale.ts
132
+ var coerceLocale = (raw) => {
133
+ if (!raw) return "en";
134
+ const head = raw.split(/[_-]/)[0]?.toLowerCase() ?? "";
135
+ return SUPPORTED_LOCALES.includes(head) ? head : "en";
136
+ };
137
+
138
+ // src/adapters/shopify-checkout/index.ts
139
+ var SHOPIFY_CHECKOUT_INTEGRATION_TYPE = "SHOPIFY_CHECKOUT";
140
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
141
+ var _datashipsOrderUuid, _collectionStep, _locale, _identifiers, _details;
142
+ var ShopifyCheckoutAdapter = class {
143
+ constructor(opts) {
144
+ this.name = "ShopifyCheckoutAdapter";
145
+ this.sessionApi = "consent-session";
146
+ this.integrationType = SHOPIFY_CHECKOUT_INTEGRATION_TYPE;
147
+ __privateAdd(this, _datashipsOrderUuid);
148
+ __privateAdd(this, _collectionStep);
149
+ __privateAdd(this, _locale);
150
+ __privateAdd(this, _identifiers);
151
+ __privateAdd(this, _details);
152
+ if (!opts || !opts.collectionStep) {
153
+ throw new Error("ShopifyCheckoutAdapter: `collectionStep` is required");
154
+ }
155
+ if (opts.datashipsOrderUuid != null && !UUID.test(opts.datashipsOrderUuid)) {
156
+ throw new Error(
157
+ "ShopifyCheckoutAdapter: `datashipsOrderUuid` must be a UUID"
158
+ );
159
+ }
160
+ __privateSet(this, _collectionStep, opts.collectionStep);
161
+ __privateSet(this, _datashipsOrderUuid, opts.datashipsOrderUuid ?? null);
162
+ __privateSet(this, _locale, coerceLocale(opts.locale));
163
+ __privateSet(this, _identifiers, {
164
+ EMAIL: opts.email ?? null,
165
+ PHONE: opts.phone ?? null
166
+ });
167
+ __privateSet(this, _details, {
168
+ orderId: opts.orderId,
169
+ checkoutToken: opts.checkoutToken,
170
+ isAcceleratedPayment: opts.isAcceleratedPayment,
171
+ wallet: opts.wallet
172
+ });
173
+ this.previewMode = opts.previewMode ?? false;
174
+ }
175
+ /** Synthetic upsert response served in {@link previewMode}, matching the requested identifier type. */
176
+ getPreviewUpsertResponse(identifierType = "EMAIL", format) {
177
+ return previewUpsertResponse(identifierType, format);
178
+ }
179
+ getLocale() {
180
+ return __privateGet(this, _locale);
181
+ }
182
+ setLocale(locale) {
183
+ __privateSet(this, _locale, coerceLocale(locale));
184
+ }
185
+ get collectionStep() {
186
+ return __privateGet(this, _collectionStep);
187
+ }
188
+ setCollectionStep(step) {
189
+ __privateSet(this, _collectionStep, step);
190
+ }
191
+ get datashipsOrderUuid() {
192
+ return __privateGet(this, _datashipsOrderUuid);
193
+ }
194
+ /** Merge checkout facts that changed since construction; an explicit `undefined` clears a field. */
195
+ setCheckoutDetails(details) {
196
+ __privateSet(this, _details, { ...__privateGet(this, _details), ...details });
197
+ }
198
+ /**
199
+ * Remember an identifier the buyer typed so later calls (a refresh, a
200
+ * remount) resolve it without the caller passing it again. An explicit
201
+ * `upsertSession({ identifier })` still takes precedence.
202
+ */
203
+ setIdentifier(identifierType, value) {
204
+ __privateGet(this, _identifiers)[identifierType] = value;
205
+ }
206
+ getIdentifier(identifierType) {
207
+ return { identifier: __privateGet(this, _identifiers)[identifierType], identifierType };
208
+ }
209
+ async getSessionContext() {
210
+ return {
211
+ collectionStep: __privateGet(this, _collectionStep),
212
+ ...__privateGet(this, _datashipsOrderUuid) !== null && { datashipsOrderUuid: __privateGet(this, _datashipsOrderUuid) },
213
+ ...definedOnly(__privateGet(this, _details))
214
+ };
215
+ }
216
+ };
217
+ _datashipsOrderUuid = new WeakMap();
218
+ _collectionStep = new WeakMap();
219
+ _locale = new WeakMap();
220
+ _identifiers = new WeakMap();
221
+ _details = new WeakMap();
222
+ var definedOnly = (details) => Object.fromEntries(
223
+ Object.entries(details).filter(([, value]) => value !== void 0)
224
+ );
225
+
226
+ export { SHOPIFY_CHECKOUT_INTEGRATION_TYPE, ShopifyCheckoutAdapter, coerceLocale };
227
+ //# sourceMappingURL=index.js.map
228
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/session/previewUpsertResponse.ts","../../../src/types.ts","../../../src/adapters/locale.ts","../../../src/adapters/shopify-checkout/index.ts"],"names":[],"mappings":";;;;;;;;;AAeA,IAAM,yBAAA,GACJ,iEAAA;AACF,IAAM,wCAAA,GACJ,6IAAA;AACF,IAAM,uBAAA,GACJ,gEAAA;AACF,IAAM,sCAAA,GACJ,yiBAAA;AAaK,IAAM,uBAAA,GAAiD;AAAA,EAC5D,gBAAA,EAAkB,4BAAA;AAAA,EAClB,QAAA,EAAU;AAAA,IACR;AAAA,MACE,OAAA,EAAS,OAAA;AAAA,MACT,WAAA,EAAa,QAAA;AAAA,MACb,OAAA,EAAS,KAAA;AAAA,MACT,YAAA,EAAc;AAAA,QACZ,IAAA,EAAM,yBAAA;AAAA,QACN,kBAAA,EAAoB,wCAAA;AAAA,QACpB,oBAAA,EACE,kWAAA;AAAA,QACF,SAAA,EAAW,qCAAA;AAAA,QACX,uBAAA,EAAyB,IAAA;AAAA,QACzB,YAAA,EAAc,qBAAA;AAAA,QACd,iBAAA,EAAmB;AAAA;AACrB;AACF,GACF;AAAA,EACA,wBAAA,EAA0B,IAAA;AAAA,EAC1B,aAAA,EAAe,sBAAA;AAAA,EACf,UAAA,EAAY;AACd,CAAA;AAQO,IAAM,uBAAA,GAAiD;AAAA,EAC5D,gBAAA,EAAkB,4BAAA;AAAA,EAClB,QAAA,EAAU;AAAA,IACR;AAAA,MACE,OAAA,EAAS,KAAA;AAAA,MACT,WAAA,EAAa,QAAA;AAAA,MACb,OAAA,EAAS,KAAA;AAAA,MACT,YAAA,EAAc;AAAA,QACZ,IAAA,EAAM,uBAAA;AAAA,QACN,kBA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MACxF,GAAG,WAAA,CAAY,YAAA,CAAA,IAAA,EAAK,QAAA,CAAQ;AAAA,KAC9B;AAAA,EACF;AACF;AAtFW,mBAAA,GAAA,IAAA,OAAA,EAAA;AACT,eAAA,GAAA,IAAA,OAAA,EAAA;AACA,OAAA,GAAA,IAAA,OAAA,EAAA;AACA,YAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AAoFF,IAAM,WAAA,GAAc,CAAC,OAAA,KACnB,MAAA,CAAO,WAAA;AAAA,EACL,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,CAAE,MAAA,CAAO,CAAC,GAAG,KAAK,CAAA,KAAM,KAAA,KAAU,MAAS;AACnE,CAAA","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ /** core-api caps `datashipsSessionId` at 100 characters (`#[Assert\Length(max: 100)]`). */
2
+ declare const DATASHIPS_SESSION_ID_MAX_LENGTH = 100;
3
+
4
+ export { DATASHIPS_SESSION_ID_MAX_LENGTH as D };
@@ -0,0 +1,6 @@
1
+ "use strict";var Dataships=(()=>{var Se=Object.defineProperty;var Tt=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Et=Object.prototype.hasOwnProperty;var xe=t=>{throw TypeError(t)};var Rt=(t,e)=>{for(var o in e)Se(t,o,{get:e[o],enumerable:!0})},bt=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of It(e))!Et.call(t,i)&&i!==o&&Se(t,i,{get:()=>e[i],enumerable:!(s=Tt(e,i))||s.enumerable});return t};var At=t=>bt(Se({},"__esModule",{value:!0}),t);var fe=(t,e,o)=>e.has(t)||xe("Cannot "+o);var n=(t,e,o)=>(fe(t,e,"read from private field"),o?o.call(t):e.get(t)),a=(t,e,o)=>e.has(t)?xe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,o),r=(t,e,o,s)=>(fe(t,e,"write to private field"),s?s.call(t,o):e.set(t,o),o),l=(t,e,o)=>(fe(t,e,"access private method"),o);var po={};Rt(po,{CONSENT_SESSION_ALREADY_PROCESSED:()=>$,CONSENT_SESSION_SUBMIT_PATH:()=>pe,COUNTRY_NOT_FOUND_CODE:()=>ye,CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE:()=>mt,CUSTOM_PLATFORM_SIGNUP_INTEGRATION_TYPE:()=>Ct,CustomPlatformCheckoutAdapter:()=>Pe,CustomPlatformSignupAdapter:()=>we,DATASHIPS_SESSION_ID_MAX_LENGTH:()=>Z,DatashipsClient:()=>ue,DatashipsError:()=>h,DatashipsHttpError:()=>h,SHOPIFY_CHECKOUT_INTEGRATION_TYPE:()=>lt,SUBMIT_VERIFICATION_CODE_ERROR_CODES:()=>Be,SUPPORTED_LOCALES:()=>D,SalesforceAdapter:()=>be,ShopifyCheckoutAdapter:()=>Re,UNSAFE_SERVER_KEY_APP_MARKER:()=>re,UNSAFE_SERVER_KEY_WARNING:()=>he,authHeaders:()=>ie,buildSubmitRequest:()=>ce,coerceLocale:()=>C,defaultRetryPolicy:()=>G,fakeEmailUpsertResponse:()=>Ie,fakePhoneUpsertResponse:()=>Ee,getConfigFromScriptTag:()=>de,noRetryPolicy:()=>W,normaliseSubmitUser:()=>Ce,previewUpsertResponse:()=>m,randomUuid:()=>N,sha256Hex:()=>it,upsertSessionRetryPolicy:()=>ae,verificationErrorCodeFromBody:()=>le,version:()=>ao});var Pt="ds_sk_",Ue=t=>t.startsWith(Pt),_t=t=>"serverKey"in t,k=t=>"unsafeServerKey"in t,se=t=>typeof t.getToken=="function",ke=async t=>{let e=await t.getToken();if(!e)throw new Error("DatashipsClient: auth.getToken() returned an empty token");return{publicKey:t.publicKey,token:e}},re="unsafe-server-key",he="Dataships SDK: the merchant SERVER KEY is being used in the browser (auth.unsafeServerKey). Anyone who views this page's source can act as this merchant until the key is revoked. Mint a short-lived token on your server and pass auth: { publicKey, token } instead.",Ne=t=>{if(k(t)){if(!t.unsafeServerKey||!Ue(t.unsafeServerKey))throw new Error("DatashipsClient: auth.unsafeServerKey must be a server key (ds_sk_\u2026); a public key belongs in auth: { publicKey, token }");wt();return}if(Ue(t.publicKey))throw new Error("DatashipsClient: a server key (ds_sk_\u2026) must never be used in the browser; use the public key with a merchant-signed token, or DatashipsServerClient from '@dataships/sdk/server' on your server");let e="getToken"in t&&t.getToken!==void 0;if(e&&"token"in t&&t.token!==void 0)throw new Error("DatashipsClient: pass either auth.token or auth.getToken, not both");if(e){if(!se(t))throw new Error("DatashipsClient: auth.getToken must be a function");return}if(!t.token)throw new Error("DatashipsClient: auth.token is required with a public key (the merchant's server mints it), or auth.getToken to fetch one per request")};var wt=()=>{globalThis.console?.warn?.(he)},ie=t=>k(t)?{"X-Api-Key":t.unsafeServerKey}:_t(t)?{"X-Api-Key":t.serverKey}:{"X-Api-Key":t.publicKey,Authorization:`Bearer ${t.token}`};var vt="https://api.dataships.io",De=(t="production",e)=>{if(e)return e;if(t==="production")return vt;throw new Error(`Dataships SDK: env "${t}" has no default base URL; pass \`baseUrl\``)};var Ot=new Set([400,401,403,404,417,422,426]),xt=t=>t!==void 0&&Ot.has(t),$="CONSENT_SESSION_ALREADY_PROCESSED",Ut=new Set([$]),kt=t=>t!==void 0&&Ut.has(t),Le=4,Nt=t=>t>=Le?0:t*2e3,G={shouldRetry:(t,e,o)=>!xt(e)&&!kt(o)&&t<Le,delayMs:Nt},ae=G,W={shouldRetry:()=>!1,delayMs:()=>0};var h=class extends Error{constructor(e){super(`Dataships request failed (${e.status||"network"})`),this.name="DatashipsError",this.status=e.status,this.body=e.body,this.challenge=e.challenge??null,this.code=X(e.body),this.reason=Dt(e.body)}get isAuthenticationFailure(){return this.status===401||this.status===403}get isSessionProcessed(){return this.code===$}};var X=t=>{if(typeof t!="object"||t===null)return null;let e=t.errors;if(!Array.isArray(e))return null;let o=e[0]?.code;return typeof o=="string"?o:null},Dt=t=>{if(typeof t!="object"||t===null)return null;let e=t.message;return typeof e=="string"&&e.length>0?e:null};var Ke="/v1/consent-session",Me="/v1/consent-session/consent",Fe="/v1/consent-session/heartbeat",He="/v1/consent-session/trigger-verification-code",Ve="/v1/consent-session/submit-verification-code",pe="/v1/consent-session/submit";var ye="COUNTRY_NOT_FOUND",Be=["CODE_EXPIRED","CODE_INVALID","NUMBER_MAX_ATTEMPTS_EXCEEDED"],le=X,qe=t=>({identifier:t.identifier,identifierType:t.identifierType,locale:t.locale,...t.userIp?{userIp:t.userIp}:{},...t.format?{format:t.format}:{},integration:{...t.context,type:t.integrationType}}),je=t=>t.status===422&&t.code===ye,me=()=>({consentSessionId:null,consents:[],userVerificationRequired:null,lastHeartbeat:null,identifier:null}),Ye=t=>({consentSessionId:t.consentSessionId,channel:t.channel,consent:t.consent}),$e=t=>({consentSessionId:t.consentSessionId}),Ge=t=>({consentSessionId:t.consentSessionId}),We=t=>({consentSessionId:t.consentSessionId,verificationCode:t.verificationCode,referenceId:t.referenceId}),ce=t=>{let e={...t.details};return e.submittedAt instanceof Date&&(e.submittedAt=e.submittedAt.toISOString()),typeof e.billingCountryCode=="string"&&(e.billingCountryCode=e.billingCountryCode.trim().toUpperCase()),{datashipsSessionId:t.datashipsSessionId,user:Ce(t.user),integration:{...e,type:t.integrationType}}},Ce=t=>{let e=t?.firstName?.trim()??"",o=t?.lastName?.trim()??"";if(!e||!o)throw new Error("submitSession: user.firstName and user.lastName are required (core-api refuses a blank name)");return{firstName:e,lastName:o}};var Xe=async t=>{let{adapter:e,input:o}=t,s=o.identifier??(await e.getIdentifier(o.identifierType)).identifier,i=await e.getSessionContext(),p=qe({integrationType:e.integrationType,locale:e.getLocale(),identifier:s,identifierType:o.identifierType,userIp:o.userIp,format:o.format,context:i});try{return await t.post({path:Ke,body:p,retry:t.retry})??me()}catch(c){if(c instanceof h&&je(c))return me();throw c}},Je=t=>t.post({path:Me,body:Ye({consentSessionId:t.consentSessionId,channel:t.channel,consent:t.consent}),retry:t.retry}),Qe=t=>t.post({path:Fe,body:$e({consentSessionId:t.consentSessionId}),retry:t.retry}),Ze=t=>t.post({path:He,body:Ge({consentSessionId:t.consentSessionId}),retry:W}),ze=async t=>{try{return await t.post({path:Ve,body:We({consentSessionId:t.consentSessionId,verificationCode:t.verificationCode,referenceId:t.referenceId}),retry:W}),{verified:!0,errorCode:null}}catch(e){if(e instanceof h&&e.status===400)return{verified:!1,errorCode:le(e.body)};throw e}},et=async t=>{let{adapter:e,input:o}=t,s=o.datashipsSessionId??e.getDatashipsSessionId?.();if(!s)throw new Error("submitSession: datashipsSessionId is required; this adapter holds no beacon of its own");await t.post({path:pe,body:ce({datashipsSessionId:s,integrationType:e.integrationType,user:o.user,details:o.details}),retry:t.retry}),o.datashipsSessionId===void 0&&o.resetBeacon!==!1&&e.resetDatashipsSessionId?.()};var tt=async({url:t,headers:e,body:o,fetch:s,retry:i})=>{let p=0;for(;;){let c,d,y=typeof e=="function"?await e():e;try{c=await s(t,{method:"POST",headers:{"Content-Type":"application/json",...y},body:JSON.stringify(o)})}catch(U){d=U}let E=c?.status;if((c?.ok??!1)&&c){let U=await c.text();return U?JSON.parse(U):void 0}let ve=c?await Kt(c):null,gt=X(ve)??void 0;if(!i.shouldRetry(p,E,gt))throw d||new h({status:E??0,body:ve,challenge:c?.headers.get("WWW-Authenticate")??null});p+=1;let Oe=i.delayMs(p);Oe>0&&await new Promise(U=>setTimeout(U,Oe))}},Kt=async t=>{let e=await t.text();if(!e)return null;try{return JSON.parse(e)}catch{return e}};var Mt=210*1e3,Ft=600*1e3,f,J,Q,b,u,ot,nt,st,ge,rt,R,ue=class{constructor(e){a(this,u);a(this,f);a(this,J);a(this,Q);a(this,b);if(this.adapter=e.adapter,e.auth&&Ne(e.auth),!e.auth&&!e.adapter.previewMode)throw new Error("DatashipsClient: `auth: { publicKey, token }` (or `{ publicKey, getToken }`) is required unless the adapter runs in preview mode");this.publicKey=e.auth&&!k(e.auth)?e.auth.publicKey:null,r(this,f,e.auth??null),this.app=e.app,this.version=e.version,this.baseUrl=De(e.env,e.baseUrl),r(this,J,e.fetch??globalThis.fetch.bind(globalThis)),r(this,Q,e.retry?.upsertSession??ae),r(this,b,e.retry?.default??G)}get auth(){return n(this,f)}get isUnsafeServerKey(){return n(this,f)!==null&&k(n(this,f))}setToken(e){if(!n(this,f))throw new Error("DatashipsClient: setToken() requires a client constructed with `auth`");if(k(n(this,f)))throw new Error("DatashipsClient: setToken() does not apply under auth.unsafeServerKey; there is no token to rotate");if(se(n(this,f)))throw new Error("DatashipsClient: setToken() does not apply under auth.getToken; the provider is called before every request");if(!e)throw new Error("DatashipsClient: token must be a non-empty string");r(this,f,{...n(this,f),token:e})}async upsertSession(e){let o=l(this,u,ot).call(this,e.identifierType,e.format);return o||Xe({adapter:this.adapter,input:e,post:l(this,u,R).bind(this),retry:n(this,Q)})}async saveConsent(e){this.adapter.previewMode||await Je({consentSessionId:l(this,u,ge).call(this,e.session),channel:e.channel,consent:e.consent,post:l(this,u,R).bind(this),retry:n(this,b)})}async triggerVerificationCode(e){return this.adapter.previewMode?{userVerificationTriggered:!1,referenceId:null,codeLength:null,resendAfterSeconds:null}:Ze({consentSessionId:e.consentSessionId,post:l(this,u,R).bind(this)})}async submitVerificationCode(e){return this.adapter.previewMode?{verified:!0,errorCode:null}:ze({...e,post:l(this,u,R).bind(this)})}async submitSession(e){let o=this.adapter;if(o.previewMode){e.datashipsSessionId===void 0&&e.resetBeacon!==!1&&o.resetDatashipsSessionId?.();return}await et({adapter:o,input:e,post:l(this,u,R).bind(this),retry:n(this,b)})}startHeartbeat(e,o={}){if(this.adapter.previewMode)return()=>{};let s=o.intervalMs??Mt,i=o.durationMs??Ft,p=Date.now(),c=!1,d=()=>{c||(c=!0,clearInterval(y))},y=setInterval(()=>{if(Date.now()-p>=i){d();return}l(this,u,rt).call(this,e).catch(E=>{o.onError?.(E),E instanceof h&&(E.isAuthenticationFailure||E.isSessionProcessed)&&d()})},s);return d}};f=new WeakMap,J=new WeakMap,Q=new WeakMap,b=new WeakMap,u=new WeakSet,ot=function(e,o){return this.adapter.previewMode&&this.adapter.getPreviewUpsertResponse?this.adapter.getPreviewUpsertResponse(e,o):null},nt=async function(){let e=l(this,u,st).call(this);return ie(se(e)?await ke(e):e)},st=function(){if(!n(this,f))throw new Error("DatashipsClient: no credentials configured; pass `auth: { publicKey, token }`");return n(this,f)},ge=function(e){if(!e.consentSessionId)throw new Error("DatashipsClient: consentSessionId is required");return e.consentSessionId},rt=async function(e){await Qe({consentSessionId:l(this,u,ge).call(this,e),post:l(this,u,R).bind(this),retry:n(this,b)})},R=async function(e){let o={"X-Dataships-App":`${this.app} (SDK: ${this.adapter.name}${this.isUnsafeServerKey?`; ${re}`:""})`,"X-Dataships-Version":`${this.version} (SDK: 2.0.1)`};return tt({url:`${this.baseUrl}${e.path}`,headers:async()=>({...await l(this,u,nt).call(this),...o}),body:e.body,fetch:n(this,J),retry:e.retry})};var it=async t=>{let e=new TextEncoder().encode(t),o=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(o)).map(s=>s.toString(16).padStart(2,"0")).join("")};var N=(t=globalThis.crypto)=>{if(t&&typeof t.randomUUID=="function")return t.randomUUID();let e=new Uint8Array(16);if(t&&typeof t.getRandomValues=="function")t.getRandomValues(e);else for(let s=0;s<16;s++)e[s]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let o=Array.from(e,s=>s.toString(16).padStart(2,"0"));return o.slice(0,4).join("")+"-"+o.slice(4,6).join("")+"-"+o.slice(6,8).join("")+"-"+o.slice(8,10).join("")+"-"+o.slice(10,16).join("")};var Ht="We would like to email you news and promotions. Tick to opt in.",Vt="Click here for an overview of how your personal data is processed for marketing purposes or see our Privacy Policy for further information.",Bt="We would like to text you news and promotions. Tick to opt in.",qt="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.",Ie={consentSessionId:"01HQB3QRZVV0737R0R25BTQBGF",consents:[{channel:"EMAIL",consentType:"OPT_IN",checked:!1,widgetConfig:{text:Ht,consentDescription:Vt,marketingInformation:`<h1>Marketing Information</h1>
2
+ <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>
3
+ `,policyURL:"https://dataships.io/privacy-centre",mobileTermsOfServiceURL:null,privacyEmail:"privacy@example.com",placeholderValues:null}}],userVerificationRequired:null,lastHeartbeat:"2026-06-17T00:00:00Z",identifier:null},Ee={consentSessionId:"01HQB3QRZVV0737R0R25BTQBGG",consents:[{channel:"SMS",consentType:"OPT_IN",checked:!1,widgetConfig:{text:Bt,consentDescription:qt,marketingInformation:`<h1>Marketing Information</h1>
4
+ <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>
5
+ `,policyURL:"https://dataships.io/privacy-centre",mobileTermsOfServiceURL:"https://dataships.io/mobile-terms",privacyEmail:"privacy@example.com",placeholderValues:null}}],userVerificationRequired:!1,lastHeartbeat:"2026-06-17T00:00:00Z",identifier:null},jt="#dataships-marketing-modal",Yt=["consent","object","opt in","opt out","STOP","HELP"],$t=["STOP","HELP"],Te=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),Gt=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),at=(t,e,o)=>t.replace(new RegExp(`${Gt(Te(e))}(?![^<]*>)(?![^<]*</a>)`,"gi"),o),pt=(t,e,o)=>{let s=Te(t),i=[["Terms of Service",e.mobileTermsOfServiceURL],["Privacy Policy",e.policyURL],["Click here",jt]];for(let[p,c]of i)c&&(s=at(s,p,d=>`<a href="${Te(c)}">${d}</a>`));for(let p of o)s=at(s,p,c=>`<strong>${c}</strong>`);return`<p>${s}</p>`},Wt=t=>({...t,consents:t.consents.map(e=>{let{widgetConfig:o}=e;return{...e,widgetConfig:{...o,text:o.text===null?null:pt(o.text,o,Yt),consentDescription:o.consentDescription===null?null:pt(o.consentDescription,o,$t)}}})}),m=(t,e="json")=>{let o=t==="PHONE"?Ee:Ie;return e==="html"?Wt(o):o};var D=["en","es","de","pt","ro","hr","da","fi","fr","hu","it","nb","pl","sk","sv","nl","el","cs","zh","ja","is"];var C=t=>{if(!t)return"en";let e=t.split(/[_-]/)[0]?.toLowerCase()??"";return D.includes(e)?e:"en"};var lt="SHOPIFY_CHECKOUT";var Xt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,A,P,L,K,_,Re=class{constructor(e){this.name="ShopifyCheckoutAdapter";this.sessionApi="consent-session";this.integrationType=lt;a(this,A);a(this,P);a(this,L);a(this,K);a(this,_);if(!e||!e.collectionStep)throw new Error("ShopifyCheckoutAdapter: `collectionStep` is required");if(e.datashipsOrderUuid!=null&&!Xt.test(e.datashipsOrderUuid))throw new Error("ShopifyCheckoutAdapter: `datashipsOrderUuid` must be a UUID");r(this,P,e.collectionStep),r(this,A,e.datashipsOrderUuid??null),r(this,L,C(e.locale)),r(this,K,{EMAIL:e.email??null,PHONE:e.phone??null}),r(this,_,{orderId:e.orderId,checkoutToken:e.checkoutToken,isAcceleratedPayment:e.isAcceleratedPayment,wallet:e.wallet}),this.previewMode=e.previewMode??!1}getPreviewUpsertResponse(e="EMAIL",o){return m(e,o)}getLocale(){return n(this,L)}setLocale(e){r(this,L,C(e))}get collectionStep(){return n(this,P)}setCollectionStep(e){r(this,P,e)}get datashipsOrderUuid(){return n(this,A)}setCheckoutDetails(e){r(this,_,{...n(this,_),...e})}setIdentifier(e,o){n(this,K)[e]=o}getIdentifier(e){return{identifier:n(this,K)[e],identifierType:e}}async getSessionContext(){return{collectionStep:n(this,P),...n(this,A)!==null&&{datashipsOrderUuid:n(this,A)},...Jt(n(this,_))}}};A=new WeakMap,P=new WeakMap,L=new WeakMap,K=new WeakMap,_=new WeakMap;var Jt=t=>Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0));var Qt="script[data-public-key]",de=(t={})=>{let e=t.document??document,o=t.scriptSelector??Qt,s=e.querySelector(o);if(!s)throw new Error(`Dataships SDK: unable to locate the Dataships script tag using selector ${o}`);let i=d=>{let y=s.getAttribute(d);if(!y)throw new Error(`Dataships SDK: Dataships script tag is missing required attribute ${d}`);return y},p=d=>{let y=s.getAttribute(d);return y&&y.length>0?y:null},c=d=>(p(d)??"").toLowerCase()==="true";return{publicKey:i("data-public-key"),token:p("data-token"),env:p("data-env")??"local",previewMode:c("data-preview-mode"),storeIdentifier:i("data-store-identifier"),locale:Zt(p("data-locale")),basketUuid:p("data-basket-uuid"),email:p("data-email"),phone:p("data-phone"),orderId:p("data-order-id"),orderToken:p("data-order-token")}},Zt=t=>{if(!t)return"en";let e=t.split(/[_-]/)[0]?.toLowerCase()??"";return D.includes(e)?e:"en"};var zt="datashipsOrderUuid:",g,S,ct,ut,dt,St,ft,ht,yt,be=class{constructor(e={}){a(this,S);this.name="SalesforceAdapter";this.sessionApi="consent-session";this.integrationType="SALESFORCE_SNIPPET";a(this,g);r(this,g,e.window??globalThis.window),this.config=e.config??de({document:e.document}),this.previewMode=this.config.previewMode}getPreviewUpsertResponse(e="EMAIL",o){return m(e,o)}getLocale(){return this.config.locale}getIdentifier(e){return{identifier:e==="PHONE"?this.config.phone:this.config.email,identifierType:e}}async getSessionContext(){let e=l(this,S,dt).call(this),o=this.config.orderId??e.get("ID"),s=this.config.orderToken??e.get("token"),i=l(this,S,ct).call(this,o,s),p=i==="THANK_YOU";return{collectionStep:i,datashipsOrderUuid:l(this,S,St).call(this),basketUuid:p?null:this.config.basketUuid,orderId:p?o:null,orderToken:p?s:null}}};g=new WeakMap,S=new WeakSet,ct=function(e,o){return e||o?"THANK_YOU":this.config.basketUuid||l(this,S,ut).call(this)?"CHECKOUT_INFORMATION":"THANK_YOU"},ut=function(){let e=n(this,g).location.pathname.toLowerCase();return e.includes("order-confirm")?!1:e.includes("checkout")},dt=function(){return new URLSearchParams(n(this,g).location.search)},St=function(){let e=l(this,S,yt).call(this),o=l(this,S,ft).call(this),s=this.config.basketUuid,i=e?l(this,S,ht).call(this,e,o):null;if(i&&(s!==null&&i.basketUuid===s||s===null))return i.uuid;let p=N(n(this,g).crypto);if(e&&s!==null)try{e.setItem(o,JSON.stringify({uuid:p,basketUuid:s}))}catch{}return p},ft=function(){return`${zt}${this.config.storeIdentifier}`},ht=function(e,o){let s=e.getItem(o);if(!s)return null;try{let i=JSON.parse(s);if(typeof i?.uuid!="string")return null;let p=typeof i.basketUuid=="string"?i.basketUuid:null;return{uuid:i.uuid,basketUuid:p}}catch{return null}},yt=function(){try{return n(this,g).localStorage}catch{return null}};var Z=100,w,v,M,T,z,Ae,F=class{constructor(e){a(this,z);a(this,w);a(this,v);a(this,M);a(this,T,null);e.explicitId!=null&&eo(e.explicitId),r(this,w,e.explicitId??null),r(this,v,e.storageKey),r(this,M,e.window??globalThis.window)}resolve(e,o){if(n(this,w))return n(this,w);let s=l(this,z,Ae).call(this);if(n(this,T)===null){let i=s?to(s,n(this,v)):null;r(this,T,i&&o(i)?i.id:N(n(this,M)?.crypto))}if(s)try{s.setItem(n(this,v),JSON.stringify({id:n(this,T),lastStep:e}))}catch{}return n(this,T)}reset(){if(n(this,w))return;r(this,T,null);let e=l(this,z,Ae).call(this);if(e)try{e.removeItem(n(this,v))}catch{}}};w=new WeakMap,v=new WeakMap,M=new WeakMap,T=new WeakMap,z=new WeakSet,Ae=function(){try{return n(this,M)?.localStorage??null}catch{return null}};var eo=t=>{if(typeof t!="string"||t.length===0)throw new Error("datashipsSessionId must be a non-empty string");if(t.length>Z)throw new Error(`datashipsSessionId must be at most ${Z} characters`)},to=(t,e)=>{let o;try{o=t.getItem(e)}catch{return null}if(!o)return null;try{let s=JSON.parse(o);return typeof s?.id!="string"||s.id.length===0?null:{id:s.id,lastStep:typeof s.lastStep=="string"?s.lastStep:null}}catch{return null}};var mt="CUSTOM_PLATFORM_CHECKOUT";var oo="datashipsSessionId:",no="default",I,ee,O,H,te,V,oe,_e,Pe=class{constructor(e){a(this,oe);this.name="CustomPlatformCheckoutAdapter";this.sessionApi="consent-session";this.integrationType=mt;a(this,I);a(this,ee);a(this,O);a(this,H);a(this,te);a(this,V);if(!e||!e.collectionStep)throw new Error("CustomPlatformCheckoutAdapter: `collectionStep` is required");r(this,I,e.collectionStep),r(this,ee,C(e.locale)),r(this,O,e.isFastCheckout??!1),r(this,H,{EMAIL:e.email??null,PHONE:e.phone??null}),r(this,te,e.storageScope??no);try{r(this,V,new F({explicitId:e.datashipsSessionId,storageKey:`${oo}${n(this,te)}`,window:e.window}))}catch(o){throw new Error(`CustomPlatformCheckoutAdapter: ${o.message}`)}this.previewMode=e.previewMode??!1}getPreviewUpsertResponse(e="EMAIL",o){return m(e,o)}getLocale(){return n(this,ee)}get collectionStep(){return n(this,I)}setCollectionStep(e){r(this,I,e)}get isFastCheckout(){return n(this,O)}setFastCheckout(e){r(this,O,e)}setIdentifier(e,o){n(this,H)[e]=o}getIdentifier(e){return{identifier:n(this,H)[e],identifierType:e}}getDatashipsSessionId(){return l(this,oe,_e).call(this)}resetDatashipsSessionId(){n(this,V).reset()}async getSessionContext(){return{collectionStep:n(this,I),datashipsSessionId:l(this,oe,_e).call(this),isFastCheckout:n(this,O)}}};I=new WeakMap,ee=new WeakMap,O=new WeakMap,H=new WeakMap,te=new WeakMap,V=new WeakMap,oe=new WeakSet,_e=function(){let e=n(this,I);return n(this,V).resolve(e,o=>{let s=so(o.lastStep)?o.lastStep:"CHECKOUT_INFORMATION";return!(e==="CHECKOUT_INFORMATION"&&s!=="CHECKOUT_INFORMATION")})};var so=t=>t==="CHECKOUT_INFORMATION"||t==="THANK_YOU"||t==="ORDER_STATUS";var Ct="CUSTOM_PLATFORM_SIGNUP";var ro="datashipsSignupSessionId:",io="default",q,x,j,ne,Y,we=class{constructor(e={}){this.name="CustomPlatformSignupAdapter";this.sessionApi="consent-session";this.integrationType=Ct;a(this,q);a(this,x);a(this,j,{});a(this,ne);a(this,Y);r(this,q,C(e.locale)),r(this,x,e.user??{}),r(this,ne,e.storageScope??io);try{r(this,Y,new F({explicitId:e.datashipsSessionId,storageKey:`${ro}${n(this,ne)}`,window:e.window}))}catch(o){throw new Error(`CustomPlatformSignupAdapter: ${o.message}`)}this.previewMode=e.previewMode??!1}getPreviewUpsertResponse(e="EMAIL",o){return m(e,o)}getLocale(){return n(this,q)}setLocale(e){r(this,q,C(e))}setIdentifier(e,o){o===null?delete n(this,j)[e]:n(this,j)[e]=o}async getIdentifier(e){let o=n(this,j)[e];if(o!==void 0)return{identifier:B(o),identifierType:e};let s=await this.getUser(),i=e==="PHONE"?s.phone:s.email;return{identifier:B(i),identifierType:e}}async getUser(){let e=typeof n(this,x)=="function"?await n(this,x).call(this):n(this,x);return{firstName:B(e.firstName),lastName:B(e.lastName),email:B(e.email),phone:B(e.phone)}}getDatashipsSessionId(){return n(this,Y).resolve(null,()=>!0)}resetDatashipsSessionId(){n(this,Y).reset()}async getSessionContext(){return{datashipsSessionId:this.getDatashipsSessionId()}}};q=new WeakMap,x=new WeakMap,j=new WeakMap,ne=new WeakMap,Y=new WeakMap;var B=t=>{let e=t?.trim();return e||null};var ao="2.0.1";return At(po);})();
6
+ //# sourceMappingURL=dataships.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/browser.ts","../src/auth/headers.ts","../src/baseUrl.ts","../src/transport/retry.ts","../src/transport/errors.ts","../src/session/consentSession.ts","../src/session/operations.ts","../src/transport/fetch.ts","../src/client.ts","../src/utils/sha256.ts","../src/utils/uuid.ts","../src/session/previewUpsertResponse.ts","../src/types.ts","../src/adapters/locale.ts","../src/adapters/shopify-checkout/index.ts","../src/adapters/salesforce/bootstrap.ts","../src/adapters/salesforce/index.ts","../src/adapters/beacon.ts","../src/adapters/custom-platform-checkout/index.ts","../src/adapters/custom-platform-signup/index.ts"],"mappings":"20BAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,uCAAAE,EAAA,gCAAAC,GAAA,2BAAAC,GAAA,8CAAAC,GAAA,4CAAAC,GAAA,kCAAAC,GAAA,gCAAAC,GAAA,oCAAAC,EAAA,oBAAAC,GAAA,mBAAAC,EAAA,uBAAAA,EAAA,sCAAAC,GAAA,yCAAAC,GAAA,sBAAAC,EAAA,sBAAAC,GAAA,2BAAAC,GAAA,iCAAAC,GAAA,8BAAAC,GAAA,gBAAAC,GAAA,uBAAAC,GAAA,iBAAAC,EAAA,uBAAAC,EAAA,4BAAAC,GAAA,4BAAAC,GAAA,2BAAAC,GAAA,kBAAAC,EAAA,wBAAAC,GAAA,0BAAAC,EAAA,eAAAC,EAAA,cAAAC,GAAA,6BAAAC,GAAA,kCAAAC,GAAA,YAAAC,KCSA,IAAMC,GAAoB,SAGbC,GAAeC,GAC1BA,EAAI,WAAWF,EAAiB,EAErBG,GAAmBC,GAC9B,cAAeA,EAEJC,EACXD,GACgC,oBAAqBA,EAE1CE,GAAuBF,GAClC,OAAQA,EAAoC,UAAa,WAG9CG,GAA2B,MACtCH,GAC2B,CAC3B,IAAMI,EAAQ,MAAMJ,EAAK,SAAS,EAClC,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,0DAA0D,EAE5E,MAAO,CAAE,UAAWJ,EAAK,UAAW,MAAAI,CAAM,CAC5C,EAGaC,GAA+B,oBAE/BC,GACX,0QAUWC,GAAqBP,GAA4B,CAC5D,GAAIC,EAAsBD,CAAI,EAAG,CAC/B,GAAI,CAACA,EAAK,iBAAmB,CAACH,GAAYG,EAAK,eAAe,EAC5D,MAAM,IAAI,MACR,+HACF,EAEFQ,GAA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EAC/C,GAAIK,IAAW,OAAW,MAAO,CAAE,WAAYC,EAAUD,CAAM,EAAG,eAAAL,CAAe,EACjF,IAAMO,EAAO,MAAM,KAAK,QAAQ,EAC1BC,EAAyBR,IAAZ,QAA6BO,EAAK,MAAQA,EAAK,MAClE,MAAO,CAAE,WAAYD,EAAUE,CAAU,EAAG,eAAAR,CAAe,CAC7D,CAGA,MAAM,SAA6C,CACjD,IAAMS,EAAM,OAAOX,EAAA,KAAKX,IAAU,WAAa,MAAMW,EAAA,KAAKX,GAAL,WAAeW,EAAA,KAAKX,GACzE,MAAO,CACL,UAAWmB,EAAUG,EAAI,SAAS,EAClC,SAAUH,EAAUG,EAAI,QAAQ,EAChC,MAAOH,EAAUG,EAAI,KAAK,EAC1B,MAAOH,EAAUG,EAAI,KAAK,CAC5B,CACF,CAGA,uBAAgC,CAC9B,OAAOX,EAAA,KAAKR,GAAQ,QAAQ,KAAM,IAAM,EAAI,CAC9C,CAQA,yBAAgC,CAC9BQ,EAAA,KAAKR,GAAQ,MAAM,CACrB,CAEA,MAAM,mBAAiE,CACrE,MAAO,CAAE,mBAAoB,KAAK,sBAAsB,CAAE,CAC5D,CACF,EAvFEJ,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,GAAA,YACSC,EAAA,YAsFX,IAAMgB,EAAaF,GAAoD,CACrE,IAAMM,EAAUN,GAAO,KAAK,EAC5B,OAAOM,GAAoB,IAC7B,EnB5KO,IAAMC,GAAkB","names":["browser_exports","__export","CONSENT_SESSION_ALREADY_PROCESSED","CONSENT_SESSION_SUBMIT_PATH","COUNTRY_NOT_FOUND_CODE","CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE","CUSTOM_PLATFORM_SIGNUP_INTEGRATION_TYPE","CustomPlatformCheckoutAdapter","CustomPlatformSignupAdapter","DATASHIPS_SESSION_ID_MAX_LENGTH","DatashipsClient","DatashipsError","SHOPIFY_CHECKOUT_INTEGRATION_TYPE","SUBMIT_VERIFICATION_CODE_ERROR_CODES","SUPPORTED_LOCALES","SalesforceAdapter","ShopifyCheckoutAdapter","UNSAFE_SERVER_KEY_APP_MARKER","UNSAFE_SERVER_KEY_WARNING","authHeaders","buildSubmitRequest","coerceLocale","defaultRetryPolicy","fakeEmailUpsertResponse","fakePhoneUpsertResponse","getConfigFromScriptTag","noRetryPolicy","normaliseSubmitUser","previewUpsertResponse","randomUuid","sha256Hex","upsertSessionRetryPolicy","verificationErrorCodeFromBody","version","SERVER_KEY_PREFIX","isServerKey","key","isServerKeyAuth","auth","isUnsafeServerKeyAuth","isTokenProviderAuth","resolveTokenProviderAuth","token","UNSAFE_SERVER_KEY_APP_MARKER","UNSAFE_SERVER_KEY_WARNING","assertBrowserAuth","warnUnsafeServerKey","hasProvider","warnUnsafeServerKey","UNSAFE_SERVER_KEY_WARNING","authHeaders","auth","isUnsafeServerKeyAuth","isServerKeyAuth","PRODUCTION_BASE_URL","resolveBaseUrl","env","baseUrl","TERMINAL_STATUSES","isTerminalStatus","status","CONSENT_SESSION_ALREADY_PROCESSED","TERMINAL_ERROR_CODES","isTerminalErrorCode","errorCode","MAX_FAILURES","backoffMs","failureCount","defaultRetryPolicy","upsertSessionRetryPolicy","noRetryPolicy","DatashipsError","args","errorCodeFromBody","reasonFromBody","CONSENT_SESSION_ALREADY_PROCESSED","errorCodeFromBody","body","errors","code","reasonFromBody","message","CONSENT_SESSION_START_PATH","CONSENT_SESSION_CONSENT_PATH","CONSENT_SESSION_HEARTBEAT_PATH","CONSENT_SESSION_TRIGGER_VERIFICATION_CODE_PATH","CONSENT_SESSION_SUBMIT_VERIFICATION_CODE_PATH","CONSENT_SESSION_SUBMIT_PATH","COUNTRY_NOT_FOUND_CODE","SUBMIT_VERIFICATION_CODE_ERROR_CODES","verificationErrorCodeFromBody","errorCodeFromBody","buildUpsertRequest","args","isCountryNotFound","error","emptyUpsertResponse","buildSaveConsentRequest","buildHeartbeatRequest","buildTriggerVerificationCodeRequest","buildSubmitVerificationCodeRequest","buildSubmitRequest","details","normaliseSubmitUser","user","firstName","lastName","upsertSession","args","adapter","input","identifier","context","body","buildUpsertRequest","CONSENT_SESSION_START_PATH","emptyUpsertResponse","error","DatashipsError","isCountryNotFound","saveConsent","CONSENT_SESSION_CONSENT_PATH","buildSaveConsentRequest","heartbeat","CONSENT_SESSION_HEARTBEAT_PATH","buildHeartbeatRequest","triggerVerificationCode","CONSENT_SESSION_TRIGGER_VERIFICATION_CODE_PATH","buildTriggerVerificationCodeRequest","noRetryPolicy","submitVerificationCode","CONSENT_SESSION_SUBMIT_VERIFICATION_CODE_PATH","buildSubmitVerificationCodeRequest","verificationErrorCodeFromBody","submitSession","datashipsSessionId","CONSENT_SESSION_SUBMIT_PATH","buildSubmitRequest","postJson","url","headers","body","fetch","retry","attempt","response","networkError","attemptHeaders","err","status","text","errorBody","readBody","errorCode","errorCodeFromBody","DatashipsError","delay","r","DEFAULT_HEARTBEAT_INTERVAL_MS","DEFAULT_HEARTBEAT_DURATION_MS","_auth","_fetch","_upsertSessionRetry","_defaultRetry","_DatashipsClient_instances","previewUpsertResponse_fn","credentialHeaders_fn","requireAuth_fn","requireConsentSessionId_fn","sendHeartbeat_fn","post_fn","DatashipsClient","opts","__privateAdd","assertBrowserAuth","isUnsafeServerKeyAuth","__privateSet","resolveBaseUrl","upsertSessionRetryPolicy","defaultRetryPolicy","__privateGet","token","isTokenProviderAuth","input","preview","__privateMethod","upsertSession","saveConsent","triggerVerificationCode","submitVerificationCode","adapter","submitSession","session","intervalMs","durationMs","startedAt","stopped","stop","handle","error","DatashipsError","identifierType","format","auth","authHeaders","resolveTokenProviderAuth","heartbeat","args","staticHeaders","UNSAFE_SERVER_KEY_APP_MARKER","postJson","sha256Hex","input","buf","digest","b","randomUuid","cryptoObj","bytes","i","hex","b","DEFAULT_EMAIL_OPT_IN_TEXT","DEFAULT_EMAIL_OPT_IN_CONSENT_DESCRIPTION","DEFAULT_SMS_OPT_IN_TEXT","DEFAULT_SMS_OPT_IN_CONSENT_DESCRIPTION","fakeEmailUpsertResponse","fakePhoneUpsertResponse","MARKETING_MODAL_HREF","CHECKBOX_LABEL_BOLD_PHRASES","CONSENT_DESCRIPTION_BOLD_PHRASES","escapeHtml","text","escapeRegExp","wrapPhrase","html","phrase","wrap","toHtmlCopy","widgetConfig","boldPhrases","links","href","match","withHtmlCopy","response","consent","previewUpsertResponse","identifierType","format","SUPPORTED_LOCALES","coerceLocale","raw","head","SUPPORTED_LOCALES","SHOPIFY_CHECKOUT_INTEGRATION_TYPE","UUID","_datashipsOrderUuid","_collectionStep","_locale","_identifiers","_details","ShopifyCheckoutAdapter","opts","SHOPIFY_CHECKOUT_INTEGRATION_TYPE","__privateAdd","__privateSet","coerceLocale","identifierType","format","previewUpsertResponse","__privateGet","locale","step","details","value","definedOnly","DEFAULT_SELECTOR","getConfigFromScriptTag","opts","doc","selector","element","required","name","value","optional","bool","localeFromSfcc","raw","head","SUPPORTED_LOCALES","DATASHIPS_ORDER_UUID_KEY_PREFIX","_window","_SalesforceAdapter_instances","resolveCollectionStep_fn","isCheckoutPath_fn","urlParams_fn","getOrSetOrderUuid_fn","orderUuidKey_fn","readStoredOrderUuid_fn","safeLocalStorage_fn","SalesforceAdapter","opts","__privateAdd","__privateSet","getConfigFromScriptTag","identifierType","format","previewUpsertResponse","params","__privateMethod","orderId","orderToken","collectionStep","isThankYou","path","__privateGet","storage","key","currentBasketUuid","stored","fresh","randomUuid","raw","parsed","basketUuid","DATASHIPS_SESSION_ID_MAX_LENGTH","_explicitId","_storageKey","_window","_id","_SessionBeacon_instances","safeStorage_fn","SessionBeacon","opts","__privateAdd","assertSessionId","__privateSet","step","reusable","__privateGet","storage","__privateMethod","stored","readStored","randomUuid","id","key","raw","parsed","CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE","STORAGE_KEY_PREFIX","DEFAULT_STORAGE_SCOPE","_collectionStep","_locale","_isFastCheckout","_identifiers","_storageScope","_beacon","_CustomPlatformCheckoutAdapter_instances","resolveSessionId_fn","CustomPlatformCheckoutAdapter","opts","__privateAdd","CUSTOM_PLATFORM_CHECKOUT_INTEGRATION_TYPE","__privateSet","coerceLocale","SessionBeacon","__privateGet","e","identifierType","format","previewUpsertResponse","step","isFastCheckout","value","__privateMethod","stored","lastStep","isCollectionStep","CUSTOM_PLATFORM_SIGNUP_INTEGRATION_TYPE","STORAGE_KEY_PREFIX","DEFAULT_STORAGE_SCOPE","_locale","_user","_identifiers","_storageScope","_beacon","CustomPlatformSignupAdapter","opts","CUSTOM_PLATFORM_SIGNUP_INTEGRATION_TYPE","__privateAdd","__privateSet","coerceLocale","SessionBeacon","__privateGet","e","identifierType","format","previewUpsertResponse","locale","value","pinned","normalise","user","identifier","raw","trimmed","version"]}
@@ -0,0 +1,190 @@
1
+ import { U as UpsertSessionResponse, C as ConsentSessionAdapter, B as BrowserAuth, E as Environment, F as FetchLike, c as UpsertSessionInput, d as Channel, e as SessionIds, f as SubmitSessionInput, g as CustomerApiAuth, h as UnsafeServerKeyAuth, I as IdentifierType, a as ConsentCopyFormat } from './types-vPJjFMJw.js';
2
+ export { i as ConsentItem, b as ConsentSessionIdentifier, j as ConsentType, k as ConsentWidgetConfig, l as CustomPlatformCheckoutSubmitDetails, P as PublicKeyAuth, m as SUPPORTED_LOCALES, n as ServerKeyAuth, o as SubmitConsentSessionUser, S as SupportedLocale, T as TokenProviderAuth, W as WidgetCopyPlaceholderValues } from './types-vPJjFMJw.js';
3
+ import { R as RetryPolicy, T as TriggerVerificationCodeResponse, S as SubmitVerificationCodeResult } from './retry-CGwSrbz_.js';
4
+ export { C as CONSENT_SESSION_ALREADY_PROCESSED, a as CONSENT_SESSION_SUBMIT_PATH, b as COUNTRY_NOT_FOUND_CODE, D as DatashipsError, D as DatashipsHttpError, c as SUBMIT_VERIFICATION_CODE_ERROR_CODES, d as SubmitVerificationCodeErrorCode, e as SubmitVerificationCodeRequest, f as TriggerVerificationCodeRequest, g as buildSubmitRequest, h as defaultRetryPolicy, n as noRetryPolicy, i as normaliseSubmitUser, u as upsertSessionRetryPolicy, v as verificationErrorCodeFromBody } from './retry-CGwSrbz_.js';
5
+
6
+ interface DatashipsClientOptions<TContext = unknown> {
7
+ /**
8
+ * The merchant public key (`X-Api-Key`) and the JWT the merchant's server
9
+ * minted for this page (`Authorization: Bearer`). Required unless the adapter
10
+ * runs in preview mode, which makes no network call.
11
+ *
12
+ * `{ publicKey, getToken }` fetches the token before every request (retries
13
+ * and heartbeats included) instead of holding a fixed one; use it where the
14
+ * platform mints short-lived tokens on demand, e.g. a Shopify checkout UI
15
+ * extension: `getToken: () => shopify.sessionToken.get()`.
16
+ *
17
+ * `{ unsafeServerKey }` is the UNSAFE escape hatch for a merchant with no
18
+ * server to mint tokens: the server key alone, exposed to every visitor. See
19
+ * {@link UnsafeServerKeyAuth}.
20
+ */
21
+ auth?: BrowserAuth;
22
+ adapter: ConsentSessionAdapter<TContext>;
23
+ app: string;
24
+ version: string;
25
+ /** Defaults to `production`. Any other env needs an explicit {@link baseUrl}. */
26
+ env?: Environment;
27
+ /** API base URL. Overrides the production default; required for `staging` and `local`. */
28
+ baseUrl?: string;
29
+ /** Inject a fetch implementation (defaults to globalThis.fetch). */
30
+ fetch?: FetchLike;
31
+ retry?: {
32
+ upsertSession?: RetryPolicy;
33
+ default?: RetryPolicy;
34
+ };
35
+ }
36
+ interface HeartbeatOptions {
37
+ intervalMs?: number;
38
+ durationMs?: number;
39
+ /**
40
+ * Called with every heartbeat failure. A refused credential (401 / 403) or an
41
+ * already-processed session (409 `CONSENT_SESSION_ALREADY_PROCESSED`) also
42
+ * stops the scheduler: every later beat would fail the same way.
43
+ */
44
+ onError?: (error: unknown) => void;
45
+ }
46
+ /**
47
+ * Browser client for the `/v1/consent-session` protocol.
48
+ *
49
+ * `_TResponse` is unused: it keeps the two-argument
50
+ * `DatashipsClient<TContext, UpsertSessionResponse>` form existing integrations
51
+ * write compiling.
52
+ */
53
+ declare class DatashipsClient<TContext = unknown, _TResponse extends UpsertSessionResponse = UpsertSessionResponse> {
54
+ #private;
55
+ /** `auth.publicKey`, or null in preview mode or under the unsafe server key. */
56
+ readonly publicKey: string | null;
57
+ readonly adapter: ConsentSessionAdapter<TContext>;
58
+ readonly app: string;
59
+ readonly version: string;
60
+ readonly baseUrl: string;
61
+ constructor(opts: DatashipsClientOptions<TContext>);
62
+ /** The credentials in use, or null for a preview-mode client constructed without them. */
63
+ get auth(): BrowserAuth | null;
64
+ /** Whether this client runs on the unsafe server-key escape hatch. */
65
+ get isUnsafeServerKey(): boolean;
66
+ /**
67
+ * Replace the Bearer token before it expires. The next call and any running
68
+ * heartbeat use it; a missed rotation surfaces as a 401 on the next call.
69
+ * Not applicable under `auth.getToken`, which already fetches one per request.
70
+ */
71
+ setToken(token: string): void;
72
+ /**
73
+ * Open or update the consent session for one identifier type
74
+ * (`POST /v1/consent-session`, contract v2). The client only states which
75
+ * identifier type it holds; the server decides the channels and returns one
76
+ * entry per channel to render. An empty `consents` means render nothing:
77
+ * that also covers a 204 No Content (a surface that never collects, no
78
+ * eligible channel, or a checkout that already asked on an earlier step) and
79
+ * a user IP the API could not geolocate (422 COUNTRY_NOT_FOUND), both of
80
+ * which resolve instead of throwing.
81
+ */
82
+ upsertSession(input: UpsertSessionInput): Promise<UpsertSessionResponse>;
83
+ saveConsent(input: {
84
+ channel: Channel;
85
+ consent: boolean;
86
+ session: SessionIds;
87
+ }): Promise<void>;
88
+ /**
89
+ * Ask the backend to send an OTP verification code to the phone-channel
90
+ * session's number. `referenceId` must be echoed back on
91
+ * {@link submitVerificationCode}. Never retried — a retry could send the
92
+ * buyer duplicate codes.
93
+ *
94
+ * In preview mode no code is sent and `{ userVerificationTriggered: false }` is
95
+ * returned, mirroring a store without verification enabled.
96
+ */
97
+ triggerVerificationCode(input: {
98
+ consentSessionId: string;
99
+ }): Promise<TriggerVerificationCodeResponse>;
100
+ /**
101
+ * Submit the OTP code the buyer received. Resolves
102
+ * `{ verified: true, errorCode: null }` on 2xx. A 400 rejection resolves
103
+ * `{ verified: false, errorCode }` with the body's `errors[0].code` (see
104
+ * `SUBMIT_VERIFICATION_CODE_ERROR_CODES`), or `null` when the body carries
105
+ * none. Any other failure throws. Never retried — a rejection is definitive.
106
+ *
107
+ * In preview mode resolves verified without a network call.
108
+ */
109
+ submitVerificationCode(input: {
110
+ consentSessionId: string;
111
+ verificationCode: string;
112
+ referenceId: string;
113
+ }): Promise<SubmitVerificationCodeResult>;
114
+ /**
115
+ * Complete the sessions opened under a beacon: the placed order (or the
116
+ * flow's equivalent) lands on every sibling session and processing is
117
+ * queued (`POST /v1/consent-session/submit`).
118
+ *
119
+ * `user.firstName` / `lastName` are required (the backend refuses a blank
120
+ * name; the SDK refuses it before sending). The beacon defaults to the
121
+ * adapter's own `datashipsSessionId`, which is then discarded once the
122
+ * submit is accepted. Idempotent on the backend; a
123
+ * beacon that matches no session is accepted silently. Retried on 409 and
124
+ * server errors like any other call.
125
+ *
126
+ * In preview mode nothing is sent; the beacon is still discarded so a
127
+ * styled sandbox behaves like a real checkout.
128
+ */
129
+ submitSession<TDetails extends object>(input: SubmitSessionInput<TDetails>): Promise<void>;
130
+ /**
131
+ * Begin a periodic heartbeat. Returns an idempotent stop function. The
132
+ * scheduler stops itself at the duration limit, when the credential is
133
+ * refused (401 / 403) and when the session has already been processed; every
134
+ * failure is reported through `onError`.
135
+ */
136
+ startHeartbeat(session: SessionIds, opts?: HeartbeatOptions): () => void;
137
+ }
138
+
139
+ /** Marker appended to `X-Dataships-App` so the backend can tell an exposed key from a genuine server call. */
140
+ declare const UNSAFE_SERVER_KEY_APP_MARKER = "unsafe-server-key";
141
+ declare const UNSAFE_SERVER_KEY_WARNING = "Dataships SDK: the merchant SERVER KEY is being used in the browser (auth.unsafeServerKey). Anyone who views this page's source can act as this merchant until the key is revoked. Mint a short-lived token on your server and pass auth: { publicKey, token } instead.";
142
+ /**
143
+ * `X-Api-Key` identifies the merchant. With a public key the Bearer token proves
144
+ * the page was served by them; a server key (server-side, or the unsafe browser
145
+ * escape hatch) needs nothing else.
146
+ */
147
+ declare const authHeaders: (auth: CustomerApiAuth | UnsafeServerKeyAuth) => Record<string, string>;
148
+
149
+ /** Hex-encoded SHA-256 of a UTF-8 string, using the Web Crypto API. */
150
+ declare const sha256Hex: (input: string) => Promise<string>;
151
+
152
+ /**
153
+ * Generate an RFC-4122 v4 UUID.
154
+ *
155
+ * Prefers `crypto.randomUUID`, falls back to `crypto.getRandomValues`, and as a
156
+ * last resort uses `Math.random` so the call never throws in a degraded
157
+ * environment (e.g. non-secure context without a usable crypto implementation).
158
+ *
159
+ * @param cryptoObj crypto source to use; defaults to `globalThis.crypto`. Pass
160
+ * `window.crypto` to keep generation testable / injectable.
161
+ */
162
+ declare const randomUuid: (cryptoObj?: Crypto | undefined) => string;
163
+
164
+ /**
165
+ * Synthetic upsert response served by a consent-session adapter in preview mode
166
+ * (see `ConsentSessionAdapter.previewMode`). Shared by every platform adapter.
167
+ *
168
+ * Lets merchants style a widget on a sandbox storefront without live calls to
169
+ * `/v1/consent-session`. The shape mirrors a real EMAIL response on contract v2
170
+ * so the integration renders exactly as it would in production: the copy is
171
+ * the standard default wording, the rest is fabricated. Values are fixed so the
172
+ * preview is deterministic across reloads. See {@link fakePhoneUpsertResponse}
173
+ * for the PHONE counterpart.
174
+ */
175
+ declare const fakeEmailUpsertResponse: UpsertSessionResponse;
176
+ /**
177
+ * PHONE counterpart of {@link fakeEmailUpsertResponse}: one SMS consent, as a
178
+ * real PHONE upsert returns it. `userVerificationRequired` is false because
179
+ * preview mode never sends a code (`triggerVerificationCode` answers
180
+ * untriggered), so the widget renders its plain opt-in state.
181
+ */
182
+ declare const fakePhoneUpsertResponse: UpsertSessionResponse;
183
+ /**
184
+ * The synthetic upsert response for the identifier type a preview-mode upsert
185
+ * asked for, with the copy in the format it asked for: plain strings for
186
+ * `json` (the default), links and emphasis applied for `html`.
187
+ */
188
+ declare const previewUpsertResponse: (identifierType: IdentifierType, format?: ConsentCopyFormat) => UpsertSessionResponse;
189
+
190
+ export { BrowserAuth, Channel, ConsentCopyFormat, ConsentSessionAdapter, CustomerApiAuth, DatashipsClient, type DatashipsClientOptions, Environment, type HeartbeatOptions, IdentifierType, RetryPolicy, SessionIds, SubmitSessionInput, SubmitVerificationCodeResult, TriggerVerificationCodeResponse, UNSAFE_SERVER_KEY_APP_MARKER, UNSAFE_SERVER_KEY_WARNING, UnsafeServerKeyAuth, UpsertSessionInput, UpsertSessionResponse, authHeaders, fakeEmailUpsertResponse, fakePhoneUpsertResponse, previewUpsertResponse, randomUuid, sha256Hex };