@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/README.md CHANGED
@@ -170,18 +170,6 @@ import { MemoryTokenStorage } from "@commercengine/storefront-sdk";
170
170
  const tokenStorage = new MemoryTokenStorage();
171
171
  ```
172
172
 
173
- #### Next.js Universal (recommended for Next.js apps)
174
- ```typescript
175
- import { NextJSTokenStorage } from "@commercengine/storefront-sdk";
176
-
177
- const tokenStorage = new NextJSTokenStorage({
178
- prefix: "myapp_",
179
- maxAge: 30 * 24 * 60 * 60, // 30 days
180
- secure: true, // Auto-detects HTTPS in browser
181
- sameSite: "Lax",
182
- });
183
- ```
184
-
185
173
  #### Custom Storage
186
174
  ```typescript
187
175
  class CustomTokenStorage implements TokenStorage {
@@ -466,8 +454,8 @@ This will prompt you to:
466
454
  #### Available Scripts
467
455
 
468
456
  - `pnpm changeset` - Create a new changeset
469
- - `pnpm version` - Consume changesets and bump version
470
- - `pnpm release` - Build and publish to npm
457
+ - `pnpm run version` - Consume changesets and bump version
458
+ - `pnpm run release` - Build and publish to npm
471
459
 
472
460
  The changeset workflow ensures proper semantic versioning, comprehensive changelogs, and coordinated releases.
473
461
 
package/dist/index.cjs CHANGED
@@ -39,7 +39,6 @@ __export(index_exports, {
39
39
  Environment: () => Environment,
40
40
  HelpersClient: () => HelpersClient,
41
41
  MemoryTokenStorage: () => MemoryTokenStorage,
42
- NextJSTokenStorage: () => NextJSTokenStorage,
43
42
  OrderClient: () => OrderClient,
44
43
  ResponseUtils: () => ResponseUtils,
45
44
  ShippingClient: () => ShippingClient,
@@ -261,115 +260,6 @@ var CookieTokenStorage = class {
261
260
  document.cookie = cookieString;
262
261
  }
263
262
  };
264
- var NextJSTokenStorage = class {
265
- accessTokenKey;
266
- refreshTokenKey;
267
- options;
268
- constructor(options = {}) {
269
- const prefix = options.prefix || "storefront_";
270
- this.accessTokenKey = `${prefix}access_token`;
271
- this.refreshTokenKey = `${prefix}refresh_token`;
272
- this.options = {
273
- maxAge: options.maxAge || 30 * 24 * 60 * 60,
274
- // 30 days default
275
- path: options.path || "/",
276
- domain: options.domain,
277
- secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
278
- sameSite: options.sameSite || "Lax"
279
- };
280
- }
281
- async getAccessToken() {
282
- return this.getCookie(this.accessTokenKey);
283
- }
284
- async setAccessToken(token) {
285
- this.setCookie(this.accessTokenKey, token);
286
- }
287
- async getRefreshToken() {
288
- return this.getCookie(this.refreshTokenKey);
289
- }
290
- async setRefreshToken(token) {
291
- this.setCookie(this.refreshTokenKey, token);
292
- }
293
- async clearTokens() {
294
- this.deleteCookie(this.accessTokenKey);
295
- this.deleteCookie(this.refreshTokenKey);
296
- }
297
- getCookie(name) {
298
- if (typeof window !== "undefined") {
299
- const value = `; ${document.cookie}`;
300
- const parts = value.split(`; ${name}=`);
301
- if (parts.length === 2) {
302
- const cookieValue = parts.pop()?.split(";").shift();
303
- return cookieValue ? decodeURIComponent(cookieValue) : null;
304
- }
305
- return null;
306
- } else {
307
- try {
308
- const { cookies } = require("next/headers");
309
- const cookieStore = cookies();
310
- return cookieStore.get(name)?.value || null;
311
- } catch {
312
- return null;
313
- }
314
- }
315
- }
316
- setCookie(name, value) {
317
- if (typeof window !== "undefined") {
318
- const encodedValue = encodeURIComponent(value);
319
- let cookieString = `${name}=${encodedValue}`;
320
- if (this.options.maxAge) {
321
- cookieString += `; Max-Age=${this.options.maxAge}`;
322
- }
323
- if (this.options.path) {
324
- cookieString += `; Path=${this.options.path}`;
325
- }
326
- if (this.options.domain) {
327
- cookieString += `; Domain=${this.options.domain}`;
328
- }
329
- if (this.options.secure) {
330
- cookieString += `; Secure`;
331
- }
332
- if (this.options.sameSite) {
333
- cookieString += `; SameSite=${this.options.sameSite}`;
334
- }
335
- document.cookie = cookieString;
336
- } else {
337
- try {
338
- const { cookies } = require("next/headers");
339
- const cookieStore = cookies();
340
- cookieStore.set(name, value, {
341
- maxAge: this.options.maxAge,
342
- path: this.options.path,
343
- domain: this.options.domain,
344
- secure: this.options.secure,
345
- sameSite: this.options.sameSite?.toLowerCase()
346
- });
347
- } catch {
348
- console.warn(`Could not set cookie ${name} on server side`);
349
- }
350
- }
351
- }
352
- deleteCookie(name) {
353
- if (typeof window !== "undefined") {
354
- let cookieString = `${name}=; Max-Age=0`;
355
- if (this.options.path) {
356
- cookieString += `; Path=${this.options.path}`;
357
- }
358
- if (this.options.domain) {
359
- cookieString += `; Domain=${this.options.domain}`;
360
- }
361
- document.cookie = cookieString;
362
- } else {
363
- try {
364
- const { cookies } = require("next/headers");
365
- const cookieStore = cookies();
366
- cookieStore.delete(name);
367
- } catch {
368
- console.warn(`Could not remove cookie ${name} on server side`);
369
- }
370
- }
371
- }
372
- };
373
263
  function createAuthMiddleware(config) {
374
264
  let isRefreshing = false;
375
265
  let refreshPromise = null;
@@ -2611,7 +2501,6 @@ var index_default = StorefrontSDK;
2611
2501
  Environment,
2612
2502
  HelpersClient,
2613
2503
  MemoryTokenStorage,
2614
- NextJSTokenStorage,
2615
2504
  OrderClient,
2616
2505
  ResponseUtils,
2617
2506
  ShippingClient,