@commercengine/storefront-sdk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/lib/client.ts
9
2
  import createClient from "openapi-fetch";
10
3
 
@@ -216,115 +209,6 @@ var CookieTokenStorage = class {
216
209
  document.cookie = cookieString;
217
210
  }
218
211
  };
219
- var NextJSTokenStorage = class {
220
- accessTokenKey;
221
- refreshTokenKey;
222
- options;
223
- constructor(options = {}) {
224
- const prefix = options.prefix || "storefront_";
225
- this.accessTokenKey = `${prefix}access_token`;
226
- this.refreshTokenKey = `${prefix}refresh_token`;
227
- this.options = {
228
- maxAge: options.maxAge || 30 * 24 * 60 * 60,
229
- // 30 days default
230
- path: options.path || "/",
231
- domain: options.domain,
232
- secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
233
- sameSite: options.sameSite || "Lax"
234
- };
235
- }
236
- async getAccessToken() {
237
- return this.getCookie(this.accessTokenKey);
238
- }
239
- async setAccessToken(token) {
240
- this.setCookie(this.accessTokenKey, token);
241
- }
242
- async getRefreshToken() {
243
- return this.getCookie(this.refreshTokenKey);
244
- }
245
- async setRefreshToken(token) {
246
- this.setCookie(this.refreshTokenKey, token);
247
- }
248
- async clearTokens() {
249
- this.deleteCookie(this.accessTokenKey);
250
- this.deleteCookie(this.refreshTokenKey);
251
- }
252
- getCookie(name) {
253
- if (typeof window !== "undefined") {
254
- const value = `; ${document.cookie}`;
255
- const parts = value.split(`; ${name}=`);
256
- if (parts.length === 2) {
257
- const cookieValue = parts.pop()?.split(";").shift();
258
- return cookieValue ? decodeURIComponent(cookieValue) : null;
259
- }
260
- return null;
261
- } else {
262
- try {
263
- const { cookies } = __require("next/headers");
264
- const cookieStore = cookies();
265
- return cookieStore.get(name)?.value || null;
266
- } catch {
267
- return null;
268
- }
269
- }
270
- }
271
- setCookie(name, value) {
272
- if (typeof window !== "undefined") {
273
- const encodedValue = encodeURIComponent(value);
274
- let cookieString = `${name}=${encodedValue}`;
275
- if (this.options.maxAge) {
276
- cookieString += `; Max-Age=${this.options.maxAge}`;
277
- }
278
- if (this.options.path) {
279
- cookieString += `; Path=${this.options.path}`;
280
- }
281
- if (this.options.domain) {
282
- cookieString += `; Domain=${this.options.domain}`;
283
- }
284
- if (this.options.secure) {
285
- cookieString += `; Secure`;
286
- }
287
- if (this.options.sameSite) {
288
- cookieString += `; SameSite=${this.options.sameSite}`;
289
- }
290
- document.cookie = cookieString;
291
- } else {
292
- try {
293
- const { cookies } = __require("next/headers");
294
- const cookieStore = cookies();
295
- cookieStore.set(name, value, {
296
- maxAge: this.options.maxAge,
297
- path: this.options.path,
298
- domain: this.options.domain,
299
- secure: this.options.secure,
300
- sameSite: this.options.sameSite?.toLowerCase()
301
- });
302
- } catch {
303
- console.warn(`Could not set cookie ${name} on server side`);
304
- }
305
- }
306
- }
307
- deleteCookie(name) {
308
- if (typeof window !== "undefined") {
309
- let cookieString = `${name}=; Max-Age=0`;
310
- if (this.options.path) {
311
- cookieString += `; Path=${this.options.path}`;
312
- }
313
- if (this.options.domain) {
314
- cookieString += `; Domain=${this.options.domain}`;
315
- }
316
- document.cookie = cookieString;
317
- } else {
318
- try {
319
- const { cookies } = __require("next/headers");
320
- const cookieStore = cookies();
321
- cookieStore.delete(name);
322
- } catch {
323
- console.warn(`Could not remove cookie ${name} on server side`);
324
- }
325
- }
326
- }
327
- };
328
212
  function createAuthMiddleware(config) {
329
213
  let isRefreshing = false;
330
214
  let refreshPromise = null;
@@ -2565,7 +2449,6 @@ export {
2565
2449
  Environment,
2566
2450
  HelpersClient,
2567
2451
  MemoryTokenStorage,
2568
- NextJSTokenStorage,
2569
2452
  OrderClient,
2570
2453
  ResponseUtils,
2571
2454
  ShippingClient,