@commercengine/storefront-sdk-nextjs 0.1.0 → 0.1.2
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/client.d.ts +1 -2
- package/dist/client.js +2 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -3
- package/dist/sdk-manager-B9xDQQuv.d.ts +1 -2
- package/dist/{sdk-manager-CdgrfSVp.js → sdk-manager-Bj21OVWT.js} +10 -4
- package/dist/server.js +1 -1
- package/package.json +9 -7
- package/dist/client.cjs +0 -136
- package/dist/client.d.cts +0 -17
- package/dist/client.d.cts.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/index.cjs +0 -146
- package/dist/index.d.cts +0 -43
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/sdk-manager-B9xDQQuv.d.ts.map +0 -1
- package/dist/sdk-manager-CdgrfSVp.js.map +0 -1
- package/dist/sdk-manager-D2ktqPrp.d.cts +0 -141
- package/dist/sdk-manager-D2ktqPrp.d.cts.map +0 -1
- package/dist/sdk-manager-NWADjRFW.cjs +0 -400
- package/dist/server.cjs +0 -102
- package/dist/server.d.cts +0 -4
package/dist/client.d.ts
CHANGED
|
@@ -13,5 +13,4 @@ declare function StorefrontSDKInitializer({
|
|
|
13
13
|
runtimeConfig
|
|
14
14
|
}?: StorefrontSDKInitializerProps): null;
|
|
15
15
|
//#endregion
|
|
16
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, type StorefrontSDKOptions, type TokenStorage, getStorefrontSDK, initializeStorefrontSDK };
|
|
17
|
-
//# sourceMappingURL=client.d.ts.map
|
|
16
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, type StorefrontSDKOptions, type TokenStorage, getStorefrontSDK, initializeStorefrontSDK };
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
import { ClientTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-
|
|
4
|
+
import { ClientTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-Bj21OVWT.js";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
6
|
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
7
7
|
|
|
@@ -40,5 +40,4 @@ function StorefrontSDKInitializer({ runtimeConfig } = {}) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
//#endregion
|
|
43
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, getStorefrontSDK, initializeStorefrontSDK };
|
|
44
|
-
//# sourceMappingURL=client.js.map
|
|
43
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, getStorefrontSDK, initializeStorefrontSDK };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,5 +39,4 @@ declare function createStorefront(config?: StorefrontRuntimeConfig): {
|
|
|
39
39
|
}): StorefrontSDK$1;
|
|
40
40
|
};
|
|
41
41
|
//#endregion
|
|
42
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, type StorefrontRuntimeConfig, StorefrontSDK, createStorefront };
|
|
43
|
-
//# sourceMappingURL=index.d.ts.map
|
|
42
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, type StorefrontRuntimeConfig, StorefrontSDK, createStorefront };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getStorefrontSDK, setGlobalStorefrontConfig } from "./sdk-manager-
|
|
1
|
+
import { getStorefrontSDK, setGlobalStorefrontConfig } from "./sdk-manager-Bj21OVWT.js";
|
|
2
2
|
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
3
|
|
|
4
4
|
//#region src/create-storefront.ts
|
|
@@ -53,5 +53,4 @@ function createStorefront(config) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, createStorefront };
|
|
57
|
-
//# sourceMappingURL=index.js.map
|
|
56
|
+
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, createStorefront };
|
|
@@ -137,5 +137,4 @@ declare function getStorefrontSDK(cookieStore: NextCookieStore): StorefrontSDK;
|
|
|
137
137
|
*/
|
|
138
138
|
declare function initializeStorefrontSDK(): void;
|
|
139
139
|
//#endregion
|
|
140
|
-
export { ClientTokenStorage, NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, StorefrontRuntimeConfig, getStorefrontSDK, initializeStorefrontSDK };
|
|
141
|
-
//# sourceMappingURL=sdk-manager-B9xDQQuv.d.ts.map
|
|
140
|
+
export { ClientTokenStorage, NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, StorefrontRuntimeConfig, getStorefrontSDK, initializeStorefrontSDK };
|
|
@@ -6,6 +6,9 @@ import { Environment, MemoryTokenStorage, StorefrontSDK } from "@commercengine/s
|
|
|
6
6
|
* Client-side token storage that uses document.cookie
|
|
7
7
|
*/
|
|
8
8
|
var ClientTokenStorage = class {
|
|
9
|
+
accessTokenKey;
|
|
10
|
+
refreshTokenKey;
|
|
11
|
+
options;
|
|
9
12
|
constructor(options = {}) {
|
|
10
13
|
const prefix = options.prefix || "ce_";
|
|
11
14
|
this.accessTokenKey = `${prefix}access_token`;
|
|
@@ -67,6 +70,10 @@ var ClientTokenStorage = class {
|
|
|
67
70
|
* Server-side token storage that uses Next.js cookies API
|
|
68
71
|
*/
|
|
69
72
|
var ServerTokenStorage = class {
|
|
73
|
+
accessTokenKey;
|
|
74
|
+
refreshTokenKey;
|
|
75
|
+
options;
|
|
76
|
+
cookieStore;
|
|
70
77
|
constructor(cookieStore, options = {}) {
|
|
71
78
|
const prefix = options.prefix || "ce_";
|
|
72
79
|
this.accessTokenKey = `${prefix}access_token`;
|
|
@@ -166,11 +173,11 @@ const DEFAULT_TTL_SECONDS = 300;
|
|
|
166
173
|
* via an in-process cache. Only used during SSG/ISR builds.
|
|
167
174
|
*/
|
|
168
175
|
var BuildCachingMemoryTokenStorage = class {
|
|
176
|
+
access = null;
|
|
177
|
+
refresh = null;
|
|
169
178
|
constructor(cacheKey, ttlSeconds = DEFAULT_TTL_SECONDS) {
|
|
170
179
|
this.cacheKey = cacheKey;
|
|
171
180
|
this.ttlSeconds = ttlSeconds;
|
|
172
|
-
this.access = null;
|
|
173
|
-
this.refresh = null;
|
|
174
181
|
}
|
|
175
182
|
async getAccessToken() {
|
|
176
183
|
if (this.access) return this.access;
|
|
@@ -339,5 +346,4 @@ function initializeStorefrontSDK() {
|
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
//#endregion
|
|
342
|
-
export { ClientTokenStorage, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK, setGlobalStorefrontConfig };
|
|
343
|
-
//# sourceMappingURL=sdk-manager-CdgrfSVp.js.map
|
|
349
|
+
export { ClientTokenStorage, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK, setGlobalStorefrontConfig };
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-
|
|
1
|
+
import { ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-Bj21OVWT.js";
|
|
2
2
|
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
3
|
|
|
4
4
|
export * from "@commercengine/storefront-sdk"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercengine/storefront-sdk-nextjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Next.js wrapper for the Commerce Engine Storefront SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -9,18 +9,19 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js",
|
|
12
|
-
"
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
13
|
},
|
|
14
14
|
"./server": {
|
|
15
15
|
"types": "./dist/server.d.ts",
|
|
16
16
|
"import": "./dist/server.js",
|
|
17
|
-
"
|
|
17
|
+
"default": "./dist/server.js"
|
|
18
18
|
},
|
|
19
19
|
"./client": {
|
|
20
20
|
"types": "./dist/client.d.ts",
|
|
21
21
|
"import": "./dist/client.js",
|
|
22
|
-
"
|
|
23
|
-
}
|
|
22
|
+
"default": "./dist/client.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"dist",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"react-dom": ">=19.0.0"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"@commercengine/storefront-sdk": "0.
|
|
46
|
+
"@commercengine/storefront-sdk": "0.9.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@types/node": "^24.3.0",
|
|
@@ -59,6 +60,7 @@
|
|
|
59
60
|
},
|
|
60
61
|
"scripts": {
|
|
61
62
|
"build": "tsdown",
|
|
62
|
-
"clean": "rimraf dist"
|
|
63
|
+
"clean": "rimraf dist",
|
|
64
|
+
"check-exports": "attw --pack ."
|
|
63
65
|
}
|
|
64
66
|
}
|
package/dist/client.cjs
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const require_sdk_manager = require('./sdk-manager-NWADjRFW.cjs');
|
|
5
|
-
const react = require_sdk_manager.__toESM(require("react"));
|
|
6
|
-
const __commercengine_storefront_sdk = require_sdk_manager.__toESM(require("@commercengine/storefront-sdk"));
|
|
7
|
-
|
|
8
|
-
//#region src/init-client.ts
|
|
9
|
-
/**
|
|
10
|
-
* Client-side initialization component
|
|
11
|
-
* Use this in your root layout to initialize the SDK once
|
|
12
|
-
*
|
|
13
|
-
* Configuration is handled via environment variables:
|
|
14
|
-
* - NEXT_PUBLIC_STORE_ID
|
|
15
|
-
* - NEXT_PUBLIC_API_KEY
|
|
16
|
-
* - NEXT_PUBLIC_ENVIRONMENT (optional, defaults to staging)
|
|
17
|
-
*
|
|
18
|
-
* The core SDK middleware automatically handles everything:
|
|
19
|
-
* - Creates anonymous tokens automatically on first API request (if no tokens exist)
|
|
20
|
-
* - Token state assessment and cleanup on first request per page load
|
|
21
|
-
* - Expired token refresh with automatic anonymous fallback
|
|
22
|
-
* - Graceful handling of partial token states
|
|
23
|
-
*
|
|
24
|
-
* No manual token creation needed - just make API calls and everything works!
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Bootstrap tokens by checking if access token exists and creating anonymous token if needed
|
|
28
|
-
*/
|
|
29
|
-
async function bootstrapTokens() {
|
|
30
|
-
const sdk = require_sdk_manager.getStorefrontSDK();
|
|
31
|
-
const accessToken = await sdk.getAccessToken();
|
|
32
|
-
if (!accessToken) await sdk.auth.getAnonymousToken();
|
|
33
|
-
}
|
|
34
|
-
function StorefrontSDKInitializer({ runtimeConfig } = {}) {
|
|
35
|
-
(0, react.useEffect)(() => {
|
|
36
|
-
require_sdk_manager.initializeStorefrontSDK();
|
|
37
|
-
bootstrapTokens().catch(console.error);
|
|
38
|
-
}, [runtimeConfig]);
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
//#endregion
|
|
43
|
-
Object.defineProperty(exports, 'AuthClient', {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return __commercengine_storefront_sdk.AuthClient;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
Object.defineProperty(exports, 'BrowserTokenStorage', {
|
|
50
|
-
enumerable: true,
|
|
51
|
-
get: function () {
|
|
52
|
-
return __commercengine_storefront_sdk.BrowserTokenStorage;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, 'CartClient', {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: function () {
|
|
58
|
-
return __commercengine_storefront_sdk.CartClient;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(exports, 'CatalogClient', {
|
|
62
|
-
enumerable: true,
|
|
63
|
-
get: function () {
|
|
64
|
-
return __commercengine_storefront_sdk.CatalogClient;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
exports.ClientTokenStorage = require_sdk_manager.ClientTokenStorage;
|
|
68
|
-
Object.defineProperty(exports, 'CookieTokenStorage', {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function () {
|
|
71
|
-
return __commercengine_storefront_sdk.CookieTokenStorage;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, 'CustomerClient', {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return __commercengine_storefront_sdk.CustomerClient;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, 'Environment', {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function () {
|
|
83
|
-
return __commercengine_storefront_sdk.Environment;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, 'HelpersClient', {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function () {
|
|
89
|
-
return __commercengine_storefront_sdk.HelpersClient;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, 'MemoryTokenStorage', {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () {
|
|
95
|
-
return __commercengine_storefront_sdk.MemoryTokenStorage;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, 'OrderClient', {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return __commercengine_storefront_sdk.OrderClient;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(exports, 'ResponseUtils', {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function () {
|
|
107
|
-
return __commercengine_storefront_sdk.ResponseUtils;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(exports, 'ShippingClient', {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
get: function () {
|
|
113
|
-
return __commercengine_storefront_sdk.ShippingClient;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(exports, 'StoreConfigClient', {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function () {
|
|
119
|
-
return __commercengine_storefront_sdk.StoreConfigClient;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
Object.defineProperty(exports, 'StorefrontAPIClient', {
|
|
123
|
-
enumerable: true,
|
|
124
|
-
get: function () {
|
|
125
|
-
return __commercengine_storefront_sdk.StorefrontAPIClient;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(exports, 'StorefrontSDK', {
|
|
129
|
-
enumerable: true,
|
|
130
|
-
get: function () {
|
|
131
|
-
return __commercengine_storefront_sdk.StorefrontSDK;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
exports.StorefrontSDKInitializer = StorefrontSDKInitializer;
|
|
135
|
-
exports.getStorefrontSDK = require_sdk_manager.getStorefrontSDK;
|
|
136
|
-
exports.initializeStorefrontSDK = require_sdk_manager.initializeStorefrontSDK;
|
package/dist/client.d.cts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ClientTokenStorage, NextJSSDKConfig, NextJSTokenStorageOptions, StorefrontRuntimeConfig, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-D2ktqPrp.cjs";
|
|
2
|
-
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKOptions, TokenStorage } from "@commercengine/storefront-sdk";
|
|
3
|
-
|
|
4
|
-
//#region src/init-client.d.ts
|
|
5
|
-
interface StorefrontSDKInitializerProps {
|
|
6
|
-
/**
|
|
7
|
-
* Optional runtime configuration overrides for client-side API calls
|
|
8
|
-
* These settings will apply to all client-side storefront() calls
|
|
9
|
-
*/
|
|
10
|
-
runtimeConfig?: StorefrontRuntimeConfig;
|
|
11
|
-
}
|
|
12
|
-
declare function StorefrontSDKInitializer({
|
|
13
|
-
runtimeConfig
|
|
14
|
-
}?: StorefrontSDKInitializerProps): null;
|
|
15
|
-
//#endregion
|
|
16
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, ClientTokenStorage, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDKInitializer, type StorefrontSDKOptions, type TokenStorage, getStorefrontSDK, initializeStorefrontSDK };
|
|
17
|
-
//# sourceMappingURL=client.d.cts.map
|
package/dist/client.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","names":[],"sources":["../src/init-client.ts"],"sourcesContent":[],"mappings":";;;;UAuCU,6BAAA;;;AAhCa;AAwCvB;EAAwC,aAAA,CAAA,EAHtB,uBAGsB;;AAAoB,iBAA5C,wBAAA,CAA4C;EAAA;AAAA,CAAA,CAAA,EAAA,6BAAA,CAAA,EAAA,IAAA"}
|
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","names":[],"sources":["../src/init-client.ts"],"sourcesContent":[],"mappings":";;;;UAuCU,6BAAA;;;AAhCa;AAwCvB;EAAwC,aAAA,CAAA,EAHtB,uBAGsB;;AAAoB,iBAA5C,wBAAA,CAA4C;EAAA;AAAA,CAAA,CAAA,EAAA,6BAAA,CAAA,EAAA,IAAA"}
|
package/dist/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../src/init-client.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { \n initializeStorefrontSDK, \n getStorefrontSDK,\n type StorefrontRuntimeConfig \n} from \"./sdk-manager\";\n\n/**\n * Client-side initialization component\n * Use this in your root layout to initialize the SDK once\n *\n * Configuration is handled via environment variables:\n * - NEXT_PUBLIC_STORE_ID\n * - NEXT_PUBLIC_API_KEY\n * - NEXT_PUBLIC_ENVIRONMENT (optional, defaults to staging)\n *\n * The core SDK middleware automatically handles everything:\n * - Creates anonymous tokens automatically on first API request (if no tokens exist)\n * - Token state assessment and cleanup on first request per page load\n * - Expired token refresh with automatic anonymous fallback\n * - Graceful handling of partial token states\n *\n * No manual token creation needed - just make API calls and everything works!\n */\n\n/**\n * Bootstrap tokens by checking if access token exists and creating anonymous token if needed\n */\nasync function bootstrapTokens() {\n const sdk = getStorefrontSDK();\n const accessToken = await sdk.getAccessToken();\n\n if (!accessToken) {\n await sdk.auth.getAnonymousToken();\n }\n}\n\ninterface StorefrontSDKInitializerProps {\n /**\n * Optional runtime configuration overrides for client-side API calls\n * These settings will apply to all client-side storefront() calls\n */\n runtimeConfig?: StorefrontRuntimeConfig;\n}\n\nexport function StorefrontSDKInitializer({ runtimeConfig }: StorefrontSDKInitializerProps = {}) {\n useEffect(() => {\n // Initialize SDK - configuration comes from environment variables\n // Middleware handles all token management automatically\n initializeStorefrontSDK();\n\n // Bootstrap tokens if they don't exist\n // Note: per-request config will be handled through storefront() function calls\n bootstrapTokens().catch(console.error);\n }, [runtimeConfig]);\n\n return null; // No UI needed\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,eAAe,kBAAkB;CAC/B,MAAM,MAAM;CACZ,MAAM,cAAc,MAAM,IAAI;AAE9B,KAAI,CAAC,YACH,OAAM,IAAI,KAAK;;AAYnB,SAAgB,yBAAyB,EAAE,kBAAiD,IAAI;AAC9F,iBAAgB;AAGd;AAIA,oBAAkB,MAAM,QAAQ;IAC/B,CAAC;AAEJ,QAAO"}
|
package/dist/index.cjs
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const require_sdk_manager = require('./sdk-manager-NWADjRFW.cjs');
|
|
2
|
-
const __commercengine_storefront_sdk = require_sdk_manager.__toESM(require("@commercengine/storefront-sdk"));
|
|
3
|
-
|
|
4
|
-
//#region src/create-storefront.ts
|
|
5
|
-
/**
|
|
6
|
-
* Creates a configured storefront function that works universally across all Next.js contexts
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* ```typescript
|
|
10
|
-
* // lib/storefront.ts
|
|
11
|
-
* import { createStorefront } from "@commercengine/storefront-sdk-nextjs";
|
|
12
|
-
*
|
|
13
|
-
* export const storefront = createStorefront({
|
|
14
|
-
* debug: true,
|
|
15
|
-
* logger: (msg, ...args) => console.log('[DEBUG]', msg, ...args)
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param config Optional configuration for advanced options (defaults to empty if not provided)
|
|
20
|
-
* @returns A storefront function that works in all Next.js contexts
|
|
21
|
-
*/
|
|
22
|
-
function createStorefront(config) {
|
|
23
|
-
if (config) require_sdk_manager.setGlobalStorefrontConfig(config);
|
|
24
|
-
function storefront(cookieStoreOrOptions, options) {
|
|
25
|
-
if (typeof window !== "undefined") return require_sdk_manager.getStorefrontSDK();
|
|
26
|
-
let cookieStore;
|
|
27
|
-
let isRootLayout = false;
|
|
28
|
-
if (cookieStoreOrOptions) if ("isRootLayout" in cookieStoreOrOptions) isRootLayout = cookieStoreOrOptions.isRootLayout;
|
|
29
|
-
else {
|
|
30
|
-
cookieStore = cookieStoreOrOptions;
|
|
31
|
-
isRootLayout = options?.isRootLayout || false;
|
|
32
|
-
}
|
|
33
|
-
if (cookieStore) return require_sdk_manager.getStorefrontSDK(cookieStore);
|
|
34
|
-
if (process.env.NEXT_IS_BUILD === "true" || process.env.NEXT_BUILD_CACHE_TOKENS === "true") return require_sdk_manager.getStorefrontSDK();
|
|
35
|
-
if (isRootLayout) return require_sdk_manager.getStorefrontSDK();
|
|
36
|
-
throw new Error([
|
|
37
|
-
"🚨 Server context requires cookies for user continuity!",
|
|
38
|
-
"",
|
|
39
|
-
"You're calling storefront() on the server without cookies.",
|
|
40
|
-
"This breaks user session continuity and analytics tracking.",
|
|
41
|
-
"",
|
|
42
|
-
"✅ Correct usage:",
|
|
43
|
-
" import { cookies } from 'next/headers'",
|
|
44
|
-
" const sdk = storefront(cookies())",
|
|
45
|
-
"",
|
|
46
|
-
"📍 Root Layout exception:",
|
|
47
|
-
" const sdk = storefront({ isRootLayout: true })",
|
|
48
|
-
"",
|
|
49
|
-
"This is required to maintain consistent user identity across requests."
|
|
50
|
-
].join("\n"));
|
|
51
|
-
}
|
|
52
|
-
return storefront;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//#endregion
|
|
56
|
-
Object.defineProperty(exports, 'AuthClient', {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function () {
|
|
59
|
-
return __commercengine_storefront_sdk.AuthClient;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, 'BrowserTokenStorage', {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function () {
|
|
65
|
-
return __commercengine_storefront_sdk.BrowserTokenStorage;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, 'CartClient', {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function () {
|
|
71
|
-
return __commercengine_storefront_sdk.CartClient;
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, 'CatalogClient', {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: function () {
|
|
77
|
-
return __commercengine_storefront_sdk.CatalogClient;
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(exports, 'CookieTokenStorage', {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
get: function () {
|
|
83
|
-
return __commercengine_storefront_sdk.CookieTokenStorage;
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, 'CustomerClient', {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: function () {
|
|
89
|
-
return __commercengine_storefront_sdk.CustomerClient;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(exports, 'Environment', {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () {
|
|
95
|
-
return __commercengine_storefront_sdk.Environment;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, 'HelpersClient', {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () {
|
|
101
|
-
return __commercengine_storefront_sdk.HelpersClient;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(exports, 'MemoryTokenStorage', {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
get: function () {
|
|
107
|
-
return __commercengine_storefront_sdk.MemoryTokenStorage;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(exports, 'OrderClient', {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
get: function () {
|
|
113
|
-
return __commercengine_storefront_sdk.OrderClient;
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(exports, 'ResponseUtils', {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function () {
|
|
119
|
-
return __commercengine_storefront_sdk.ResponseUtils;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
Object.defineProperty(exports, 'ShippingClient', {
|
|
123
|
-
enumerable: true,
|
|
124
|
-
get: function () {
|
|
125
|
-
return __commercengine_storefront_sdk.ShippingClient;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(exports, 'StoreConfigClient', {
|
|
129
|
-
enumerable: true,
|
|
130
|
-
get: function () {
|
|
131
|
-
return __commercengine_storefront_sdk.StoreConfigClient;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
Object.defineProperty(exports, 'StorefrontAPIClient', {
|
|
135
|
-
enumerable: true,
|
|
136
|
-
get: function () {
|
|
137
|
-
return __commercengine_storefront_sdk.StorefrontAPIClient;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
Object.defineProperty(exports, 'StorefrontSDK', {
|
|
141
|
-
enumerable: true,
|
|
142
|
-
get: function () {
|
|
143
|
-
return __commercengine_storefront_sdk.StorefrontSDK;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
exports.createStorefront = createStorefront;
|
package/dist/index.d.cts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { StorefrontRuntimeConfig } from "./sdk-manager-D2ktqPrp.cjs";
|
|
2
|
-
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, StorefrontSDK as StorefrontSDK$1 } from "@commercengine/storefront-sdk";
|
|
3
|
-
export * from "@commercengine/storefront-sdk";
|
|
4
|
-
|
|
5
|
-
//#region src/create-storefront.d.ts
|
|
6
|
-
type NextCookieStore = {
|
|
7
|
-
get: (name: string) => {
|
|
8
|
-
name: string;
|
|
9
|
-
value: string;
|
|
10
|
-
} | undefined;
|
|
11
|
-
set: (name: string, value: string, opts?: Record<string, unknown>) => void;
|
|
12
|
-
delete: (name: string) => void;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Creates a configured storefront function that works universally across all Next.js contexts
|
|
16
|
-
*
|
|
17
|
-
* Usage:
|
|
18
|
-
* ```typescript
|
|
19
|
-
* // lib/storefront.ts
|
|
20
|
-
* import { createStorefront } from "@commercengine/storefront-sdk-nextjs";
|
|
21
|
-
*
|
|
22
|
-
* export const storefront = createStorefront({
|
|
23
|
-
* debug: true,
|
|
24
|
-
* logger: (msg, ...args) => console.log('[DEBUG]', msg, ...args)
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @param config Optional configuration for advanced options (defaults to empty if not provided)
|
|
29
|
-
* @returns A storefront function that works in all Next.js contexts
|
|
30
|
-
*/
|
|
31
|
-
declare function createStorefront(config?: StorefrontRuntimeConfig): {
|
|
32
|
-
(): StorefrontSDK$1;
|
|
33
|
-
(cookieStore: NextCookieStore): StorefrontSDK$1;
|
|
34
|
-
(options: {
|
|
35
|
-
isRootLayout: true;
|
|
36
|
-
}): StorefrontSDK$1;
|
|
37
|
-
(cookieStore: NextCookieStore, options: {
|
|
38
|
-
isRootLayout?: boolean;
|
|
39
|
-
}): StorefrontSDK$1;
|
|
40
|
-
};
|
|
41
|
-
//#endregion
|
|
42
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, type StorefrontRuntimeConfig, StorefrontSDK, createStorefront };
|
|
43
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/create-storefront.ts"],"sourcesContent":[],"mappings":";;;;;KAQK,eAAA;;;;EAAA,CAAA,GAAA,SAAA;EAwBW,GAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAgB,KAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAtBY,MAsBZ,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,IAAA;EAAA,MAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;;;;;;;;;;;;;;;;;;iBAAhB,gBAAA,UAA0B;MAKjB;gBACU,kBAAkB;;;MACG;gBACrB;;MAAuD"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/create-storefront.ts"],"sourcesContent":[],"mappings":";;;;;KAQK,eAAA;;;;EAAA,CAAA,GAAA,SAAA;EAwBW,GAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAgB,KAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAtBY,MAsBZ,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GAAA,IAAA;EAAA,MAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;;;;;;;;;;;;;;;;;;iBAAhB,gBAAA,UAA0B;MAKjB;gBACU,kBAAkB;;;MACG;gBACrB;;MAAuD"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cookieStore: NextCookieStore | undefined"],"sources":["../src/create-storefront.ts"],"sourcesContent":["import {\n getStorefrontSDK,\n setGlobalStorefrontConfig,\n type StorefrontRuntimeConfig,\n} from \"./sdk-manager\";\nimport type { StorefrontSDK } from \"@commercengine/storefront-sdk\";\n\n// Structural type so we don't import next/headers at module scope\ntype NextCookieStore = {\n get: (name: string) => { name: string; value: string } | undefined;\n set: (name: string, value: string, opts?: Record<string, unknown>) => void;\n delete: (name: string) => void;\n};\n\n\n/**\n * Creates a configured storefront function that works universally across all Next.js contexts\n *\n * Usage:\n * ```typescript\n * // lib/storefront.ts\n * import { createStorefront } from \"@commercengine/storefront-sdk-nextjs\";\n *\n * export const storefront = createStorefront({\n * debug: true,\n * logger: (msg, ...args) => console.log('[DEBUG]', msg, ...args)\n * });\n * ```\n *\n * @param config Optional configuration for advanced options (defaults to empty if not provided)\n * @returns A storefront function that works in all Next.js contexts\n */\nexport function createStorefront(config?: StorefrontRuntimeConfig) {\n if (config) {\n setGlobalStorefrontConfig(config);\n }\n\n function storefront(): StorefrontSDK;\n function storefront(cookieStore: NextCookieStore): StorefrontSDK;\n function storefront(options: { isRootLayout: true }): StorefrontSDK;\n function storefront(cookieStore: NextCookieStore, options: { isRootLayout?: boolean }): StorefrontSDK;\n function storefront(\n cookieStoreOrOptions?: NextCookieStore | { isRootLayout: true }, \n options?: { isRootLayout?: boolean }\n ): StorefrontSDK {\n // Client path\n if (typeof window !== \"undefined\") {\n return getStorefrontSDK();\n }\n\n // Parse parameters to handle different overloads\n let cookieStore: NextCookieStore | undefined;\n let isRootLayout = false;\n\n if (cookieStoreOrOptions) {\n if ('isRootLayout' in cookieStoreOrOptions) {\n // First parameter is options object\n isRootLayout = cookieStoreOrOptions.isRootLayout;\n } else {\n // First parameter is cookie store\n cookieStore = cookieStoreOrOptions;\n isRootLayout = options?.isRootLayout || false;\n }\n }\n\n // Server path with explicit cookies\n if (cookieStore) {\n return getStorefrontSDK(cookieStore);\n }\n\n // Server path without cookies:\n // 1. Always allow build contexts (no request context available)\n if (\n process.env.NEXT_IS_BUILD === \"true\" ||\n process.env.NEXT_BUILD_CACHE_TOKENS === \"true\"\n ) {\n return getStorefrontSDK();\n }\n\n // 2. Allow root layout with explicit flag\n if (isRootLayout) {\n return getStorefrontSDK();\n }\n\n // 3. All other server contexts must pass cookies - throw helpful error\n throw new Error(\n [\n \"🚨 Server context requires cookies for user continuity!\",\n \"\",\n \"You're calling storefront() on the server without cookies.\",\n \"This breaks user session continuity and analytics tracking.\",\n \"\",\n \"✅ Correct usage:\",\n \" import { cookies } from 'next/headers'\",\n \" const sdk = storefront(cookies())\",\n \"\",\n \"📍 Root Layout exception:\",\n \" const sdk = storefront({ isRootLayout: true })\",\n \"\",\n \"This is required to maintain consistent user identity across requests.\",\n ].join(\"\\n\")\n );\n }\n\n return storefront;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,iBAAiB,QAAkC;AACjE,KAAI,OACF,2BAA0B;CAO5B,SAAS,WACP,sBACA,SACe;AAEf,MAAI,OAAO,WAAW,YACpB,QAAO;EAIT,IAAIA;EACJ,IAAI,eAAe;AAEnB,MAAI,qBACF,KAAI,kBAAkB,qBAEpB,gBAAe,qBAAqB;OAC/B;AAEL,iBAAc;AACd,kBAAe,SAAS,gBAAgB;;AAK5C,MAAI,YACF,QAAO,iBAAiB;AAK1B,MACE,QAAQ,IAAI,kBAAkB,UAC9B,QAAQ,IAAI,4BAA4B,OAExC,QAAO;AAIT,MAAI,aACF,QAAO;AAIT,QAAM,IAAI,MACR;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;IACA,KAAK;;AAIX,QAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-manager-B9xDQQuv.d.ts","names":[],"sources":["../src/token-storage.ts","../src/sdk-manager.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AA8Ca,UA9CI,yBAAA,CA8Ce;EAAA;;;QAuBO,CAAA,EAAA,MAAA;;;;QAvBI,CAAA,EAAA,MAAA;;AAkG1C;AAYD;EAAgC,IAAA,CAAA,EAAA,MAAA;;;;QA8BO,CAAA,EAAA,MAAA;;;;QA9BI,CAAA,EAAA,OAAA;;;;;AC9I3C;;;;AACU,cD+BG,kBAAA,YAA8B,YC/BjC,CAAA;;EAWO,QAAA,eAAA;EAAuB,QAAA,OAAA;aAMxB,CAAA,OAAA,CAAA,EDmBO,yBCnBP;gBAUG,CAAA,CAAA,EDuBO,OCvBP,CAAA,MAAA,GAAA,IAAA,CAAA;gBACR,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gB,EAAA,GAAA,IAAA;CAAA;;;;AA+DhC;;;;;iBAhEgB,gBAAA,CAAA,GAAoB;iBACpB,gBAAA,cAA8B,kBAAkB;;;;;;;;;;iBA+DhD,uBAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-manager-CdgrfSVp.js","names":["cacheKey: string","envDefaultHeaders: SupportedDefaultHeaders","defaultHeaders: SupportedDefaultHeaders","config: NextJSSDKConfig","globalStorefrontConfig: StorefrontRuntimeConfig | null","clientSDK: StorefrontSDK | null","buildTimeSDK: StorefrontSDK | null"],"sources":["../src/token-storage.ts","../src/build-token-cache.ts","../src/build-caching-memory-storage.ts","../src/sdk-manager.ts"],"sourcesContent":["import type { TokenStorage } from '@commercengine/storefront-sdk';\n\n/**\n * Configuration options for NextJSTokenStorage\n */\nexport interface NextJSTokenStorageOptions {\n /**\n * Prefix for cookie names (default: \"ce_\")\n */\n prefix?: string;\n\n /**\n * Maximum age of cookies in seconds (default: 30 days)\n */\n maxAge?: number;\n\n /**\n * Cookie path (default: \"/\")\n */\n path?: string;\n\n /**\n * Cookie domain (default: current domain)\n */\n domain?: string;\n\n /**\n * Whether cookies should be secure (default: auto-detect based on environment)\n */\n secure?: boolean;\n\n /**\n * SameSite cookie attribute (default: \"Lax\")\n */\n sameSite?: \"Strict\" | \"Lax\" | \"None\";\n}\n\n/**\n * Internal cookie options interface\n */\ninterface CookieOptions {\n maxAge?: number;\n path?: string;\n domain?: string;\n secure?: boolean;\n sameSite?: \"Strict\" | \"Lax\" | \"None\";\n}\n\n/**\n * Client-side token storage that uses document.cookie\n */\nexport class ClientTokenStorage implements TokenStorage {\n private accessTokenKey: string;\n private refreshTokenKey: string;\n private options: CookieOptions;\n\n constructor(options: NextJSTokenStorageOptions = {}) {\n const prefix = options.prefix || \"ce_\";\n this.accessTokenKey = `${prefix}access_token`;\n this.refreshTokenKey = `${prefix}refresh_token`;\n\n this.options = {\n maxAge: options.maxAge || 30 * 24 * 60 * 60, // 30 days default\n path: options.path || \"/\",\n domain: options.domain,\n secure: options.secure ?? (typeof window !== \"undefined\" && window.location?.protocol === \"https:\"),\n sameSite: options.sameSite || \"Lax\",\n };\n }\n\n async getAccessToken(): Promise<string | null> {\n return this.getCookie(this.accessTokenKey);\n }\n\n async setAccessToken(token: string): Promise<void> {\n this.setCookie(this.accessTokenKey, token);\n }\n\n async getRefreshToken(): Promise<string | null> {\n return this.getCookie(this.refreshTokenKey);\n }\n\n async setRefreshToken(token: string): Promise<void> {\n this.setCookie(this.refreshTokenKey, token);\n }\n\n async clearTokens(): Promise<void> {\n this.deleteCookie(this.accessTokenKey);\n this.deleteCookie(this.refreshTokenKey);\n }\n\n private getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n\n const value = `; ${document.cookie}`;\n const parts = value.split(`; ${name}=`);\n\n if (parts.length === 2) {\n const cookieValue = parts.pop()?.split(\";\").shift();\n return cookieValue ? decodeURIComponent(cookieValue) : null;\n }\n\n return null;\n }\n\n private setCookie(name: string, value: string): void {\n if (typeof document === \"undefined\") return;\n\n const encodedValue = encodeURIComponent(value);\n let cookieString = `${name}=${encodedValue}`;\n\n if (this.options.maxAge) {\n cookieString += `; Max-Age=${this.options.maxAge}`;\n }\n\n if (this.options.path) {\n cookieString += `; Path=${this.options.path}`;\n }\n\n if (this.options.domain) {\n cookieString += `; Domain=${this.options.domain}`;\n }\n\n if (this.options.secure) {\n cookieString += `; Secure`;\n }\n\n if (this.options.sameSite) {\n cookieString += `; SameSite=${this.options.sameSite}`;\n }\n\n document.cookie = cookieString;\n }\n\n private deleteCookie(name: string): void {\n if (typeof document === \"undefined\") return;\n\n let cookieString = `${name}=; Max-Age=0`;\n\n if (this.options.path) {\n cookieString += `; Path=${this.options.path}`;\n }\n\n if (this.options.domain) {\n cookieString += `; Domain=${this.options.domain}`;\n }\n\n document.cookie = cookieString;\n }\n}\n\n// Type for Next.js cookies\ntype NextCookieStore = {\n get: (name: string) => { value: string } | undefined;\n set: (name: string, value: string, options?: any) => void;\n delete: (name: string) => void;\n};\n\n/**\n * Server-side token storage that uses Next.js cookies API\n */\nexport class ServerTokenStorage implements TokenStorage {\n private accessTokenKey: string;\n private refreshTokenKey: string;\n private options: CookieOptions;\n private cookieStore: NextCookieStore;\n\n constructor(cookieStore: NextCookieStore, options: NextJSTokenStorageOptions = {}) {\n const prefix = options.prefix || \"ce_\";\n this.accessTokenKey = `${prefix}access_token`;\n this.refreshTokenKey = `${prefix}refresh_token`;\n this.cookieStore = cookieStore;\n\n this.options = {\n maxAge: options.maxAge || 30 * 24 * 60 * 60, // 30 days default\n path: options.path || \"/\",\n domain: options.domain,\n secure: options.secure ?? process.env.NODE_ENV === \"production\",\n sameSite: options.sameSite || \"Lax\",\n };\n }\n\n async getAccessToken(): Promise<string | null> {\n try {\n return this.cookieStore.get(this.accessTokenKey)?.value || null;\n } catch (error) {\n console.warn(`Could not get access token from server cookies:`, error);\n return null;\n }\n }\n\n async setAccessToken(token: string): Promise<void> {\n try {\n this.cookieStore.set(this.accessTokenKey, token, {\n maxAge: this.options.maxAge,\n path: this.options.path,\n domain: this.options.domain,\n secure: this.options.secure,\n sameSite: this.options.sameSite?.toLowerCase() as \"strict\" | \"lax\" | \"none\",\n httpOnly: false, // Allow client-side access for SDK flexibility\n });\n } catch (error) {\n console.warn(`Could not set access token on server:`, error);\n }\n }\n\n async getRefreshToken(): Promise<string | null> {\n try {\n return this.cookieStore.get(this.refreshTokenKey)?.value || null;\n } catch (error) {\n console.warn(`Could not get refresh token from server cookies:`, error);\n return null;\n }\n }\n\n async setRefreshToken(token: string): Promise<void> {\n try {\n this.cookieStore.set(this.refreshTokenKey, token, {\n maxAge: this.options.maxAge,\n path: this.options.path,\n domain: this.options.domain,\n secure: this.options.secure,\n sameSite: this.options.sameSite?.toLowerCase() as \"strict\" | \"lax\" | \"none\",\n httpOnly: false, // Allow client-side access for SDK flexibility\n });\n } catch (error) {\n console.warn(`Could not set refresh token on server:`, error);\n }\n }\n\n async clearTokens(): Promise<void> {\n try {\n this.cookieStore.delete(this.accessTokenKey);\n this.cookieStore.delete(this.refreshTokenKey);\n } catch (error) {\n console.warn(`Could not clear tokens on server:`, error);\n }\n }\n}","/**\n * In-process token cache for build-time optimization\n * Only active during SSG/ISR when no request context exists\n */\n\ntype CachedToken = {\n accessToken: string;\n refreshToken?: string | null;\n expiresAt?: number; // epoch ms\n};\n\nconst store = new Map<string, CachedToken>();\n\nfunction isExpired(token: CachedToken | undefined): boolean {\n if (!token) return true;\n if (!token.expiresAt) return false; // No expiration info, assume valid\n return Date.now() > token.expiresAt - 30_000; // Refresh 30s early\n}\n\nexport function getCachedToken(key: string): CachedToken | null {\n const token = store.get(key);\n return isExpired(token) ? null : (token as CachedToken);\n}\n\nexport function setCachedToken(\n key: string, \n token: Omit<CachedToken, 'expiresAt'> & { ttlSeconds?: number }\n): void {\n const expiresAt = token.ttlSeconds != null \n ? Date.now() + token.ttlSeconds * 1000 \n : undefined;\n \n store.set(key, {\n accessToken: token.accessToken,\n refreshToken: token.refreshToken ?? null,\n expiresAt,\n });\n}\n\nexport function clearCachedToken(key: string): void {\n store.delete(key);\n}\n\nexport function getCacheStats() {\n return {\n size: store.size,\n keys: Array.from(store.keys()),\n };\n}","import type { TokenStorage } from \"@commercengine/storefront-sdk\";\nimport { getCachedToken, setCachedToken, clearCachedToken } from \"./build-token-cache\";\n\n// Fallback TTL if the SDK doesn't expose expires_in; keep it short to avoid staleness\nconst DEFAULT_TTL_SECONDS = 5 * 60; // 5 minutes\n\n/**\n * Memory token storage that reuses tokens across the build process\n * via an in-process cache. Only used during SSG/ISR builds.\n */\nexport class BuildCachingMemoryTokenStorage implements TokenStorage {\n private access: string | null = null;\n private refresh: string | null = null;\n\n constructor(\n private cacheKey: string, \n private ttlSeconds = DEFAULT_TTL_SECONDS\n ) {}\n\n async getAccessToken(): Promise<string | null> {\n if (this.access) {\n return this.access;\n }\n \n const cached = getCachedToken(this.cacheKey);\n if (cached?.accessToken) {\n this.access = cached.accessToken;\n this.refresh = cached.refreshToken ?? null;\n return this.access;\n }\n \n return null;\n }\n\n async setAccessToken(token: string): Promise<void> {\n this.access = token;\n setCachedToken(this.cacheKey, {\n accessToken: token,\n refreshToken: this.refresh,\n ttlSeconds: this.ttlSeconds,\n });\n }\n\n async getRefreshToken(): Promise<string | null> {\n return this.refresh;\n }\n\n async setRefreshToken(token: string): Promise<void> {\n this.refresh = token;\n setCachedToken(this.cacheKey, {\n accessToken: this.access ?? \"\",\n refreshToken: token,\n ttlSeconds: this.ttlSeconds,\n });\n }\n\n async clearTokens(): Promise<void> {\n this.access = null;\n this.refresh = null;\n clearCachedToken(this.cacheKey);\n }\n}","import { cache } from \"react\";\nimport {\n StorefrontSDK,\n type StorefrontSDKOptions,\n type SupportedDefaultHeaders,\n MemoryTokenStorage,\n Environment,\n type DebugLoggerFn,\n} from \"@commercengine/storefront-sdk\";\nimport {\n ClientTokenStorage,\n ServerTokenStorage,\n type NextJSTokenStorageOptions,\n} from \"./token-storage\";\nimport { BuildCachingMemoryTokenStorage } from \"./build-caching-memory-storage\";\n\n/**\n * Configuration for the NextJS SDK wrapper\n */\nexport interface NextJSSDKConfig\n extends Omit<StorefrontSDKOptions, \"tokenStorage\"> {\n /**\n * Token storage configuration options\n */\n tokenStorageOptions?: NextJSTokenStorageOptions;\n}\n\n/**\n * Runtime configuration overrides that can be passed to storefront() function\n * These override environment variables for that specific request\n */\nexport interface StorefrontRuntimeConfig {\n /**\n * Override environment variables\n */\n storeId?: string;\n apiKey?: string;\n environment?: Environment;\n baseUrl?: string;\n timeout?: number;\n debug?: boolean;\n \n /**\n * Advanced options not available via environment variables\n */\n accessToken?: string;\n refreshToken?: string;\n defaultHeaders?: SupportedDefaultHeaders;\n logger?: DebugLoggerFn;\n onTokensUpdated?: (accessToken: string, refreshToken: string) => void;\n onTokensCleared?: () => void;\n \n /**\n * Token storage configuration\n */\n tokenStorageOptions?: NextJSTokenStorageOptions;\n}\n\n\n/**\n * Get configuration from environment variables merged with global config\n * Precedence order: environment variables < global config\n */\nfunction getConfig(): NextJSSDKConfig {\n // Get environment variables\n const envStoreId = process.env.NEXT_PUBLIC_STORE_ID;\n const envApiKey = process.env.NEXT_PUBLIC_API_KEY;\n const envEnvironment = process.env.NEXT_PUBLIC_ENVIRONMENT;\n const envBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;\n const envTimeout = process.env.NEXT_PUBLIC_API_TIMEOUT ? parseInt(process.env.NEXT_PUBLIC_API_TIMEOUT, 10) : undefined;\n const envDebug = process.env.NEXT_PUBLIC_DEBUG_MODE === \"true\";\n \n // Environment-based default headers\n const envDefaultHeaders: SupportedDefaultHeaders = {};\n if (process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_GROUP_ID) {\n envDefaultHeaders.customer_group_id = process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_GROUP_ID;\n }\n\n // Merge in order: env vars < global config\n const storeId = globalStorefrontConfig?.storeId || envStoreId;\n const apiKey = globalStorefrontConfig?.apiKey || envApiKey;\n const environment = globalStorefrontConfig?.environment || (envEnvironment === \"production\" ? Environment.Production : Environment.Staging);\n const baseUrl = globalStorefrontConfig?.baseUrl || envBaseUrl;\n const timeout = globalStorefrontConfig?.timeout || envTimeout;\n const debug = globalStorefrontConfig?.debug !== undefined ? globalStorefrontConfig.debug : envDebug;\n \n // Merge default headers (global config takes precedence over env vars)\n const defaultHeaders: SupportedDefaultHeaders = {\n ...envDefaultHeaders,\n ...globalStorefrontConfig?.defaultHeaders,\n };\n\n // Validate required fields\n if (!storeId || !apiKey) {\n throw new Error(\n `StorefrontSDK configuration missing! Please set the following environment variables:\n\nNEXT_PUBLIC_STORE_ID=your-store-id\nNEXT_PUBLIC_API_KEY=your-api-key\nNEXT_PUBLIC_ENVIRONMENT=staging (or production)\n\nThese variables are required for both client and server contexts to work.`\n );\n }\n\n const config: NextJSSDKConfig = {\n storeId,\n apiKey,\n environment,\n };\n\n // Add optional configurations only if they're provided (per-instance takes precedence over global)\n if (baseUrl) config.baseUrl = baseUrl;\n if (timeout) config.timeout = timeout;\n if (debug) config.debug = debug;\n \n // Advanced options from global config only\n const logger = globalStorefrontConfig?.logger;\n const accessToken = globalStorefrontConfig?.accessToken;\n const refreshToken = globalStorefrontConfig?.refreshToken;\n const onTokensUpdated = globalStorefrontConfig?.onTokensUpdated;\n const onTokensCleared = globalStorefrontConfig?.onTokensCleared;\n const tokenStorageOptions = globalStorefrontConfig?.tokenStorageOptions;\n \n if (logger) config.logger = logger;\n if (accessToken) config.accessToken = accessToken;\n if (refreshToken) config.refreshToken = refreshToken;\n if (onTokensUpdated) config.onTokensUpdated = onTokensUpdated;\n if (onTokensCleared) config.onTokensCleared = onTokensCleared;\n if (Object.keys(defaultHeaders).length > 0) config.defaultHeaders = defaultHeaders;\n if (tokenStorageOptions) config.tokenStorageOptions = tokenStorageOptions;\n\n return config;\n}\n\n/**\n * Global runtime configuration storage\n * This gets bundled into both client and server bundles\n */\nlet globalStorefrontConfig: StorefrontRuntimeConfig | null = null;\n\n/**\n * Client-side SDK singleton (only lives in browser)\n */\nlet clientSDK: StorefrontSDK | null = null;\n\n\n/**\n * Create appropriate token storage based on environment\n */\nfunction createTokenStorage(\n cookieStore?: NextCookieStore,\n options?: NextJSTokenStorageOptions,\n config?: NextJSSDKConfig\n) {\n if (typeof window !== \"undefined\") {\n // Client-side: use document.cookie\n return new ClientTokenStorage(options);\n }\n\n if (cookieStore) {\n // Server-side with request context: use Next.js cookies\n return new ServerTokenStorage(cookieStore, options);\n }\n\n // Server-side without request context (SSG/ISR): use memory storage with optional caching\n const shouldCache = process.env.NEXT_BUILD_CACHE_TOKENS === \"true\";\n\n if (shouldCache && config) {\n // Create cache key from store ID and environment\n const cacheKey = `${config.storeId}:${config.environment || \"production\"}`;\n return new BuildCachingMemoryTokenStorage(cacheKey);\n }\n\n return new MemoryTokenStorage();\n}\n\n/**\n * Request-scoped server SDK factory using React cache\n */\nconst getServerSDKCached = cache((cookieStore: NextCookieStore) => {\n const config = getConfig();\n\n return new StorefrontSDK({\n ...config,\n tokenStorage: createTokenStorage(\n cookieStore,\n config.tokenStorageOptions,\n config\n ),\n });\n});\n\n/**\n * Memory-based SDK for SSG/build contexts (no request isolation needed)\n */\nlet buildTimeSDK: StorefrontSDK | null = null;\n\nfunction getBuildTimeSDK(): StorefrontSDK {\n const config = getConfig();\n\n // Use the cached instance\n if (!buildTimeSDK) {\n buildTimeSDK = new StorefrontSDK({\n ...config,\n tokenStorage: createTokenStorage(\n undefined,\n config.tokenStorageOptions,\n config\n ),\n });\n }\n\n return buildTimeSDK;\n}\n\n// Type for Next.js cookies (more specific than 'any')\ntype NextCookieStore = {\n get: (name: string) => { value: string } | undefined;\n set: (name: string, value: string, options?: any) => void;\n delete: (name: string) => void;\n};\n\n/**\n * Smart SDK getter that automatically detects environment\n *\n * Usage:\n * - Client-side: getStorefrontSDK()\n * - Server-side with request context: getStorefrontSDK(await cookies())\n * - SSG/ISR (no request context): getStorefrontSDK() (uses memory storage)\n */\nexport function getStorefrontSDK(): StorefrontSDK;\nexport function getStorefrontSDK(cookieStore: NextCookieStore): StorefrontSDK;\nexport function getStorefrontSDK(cookieStore?: NextCookieStore): StorefrontSDK {\n // Client-side: return client SDK singleton or per-request instance\n if (typeof window !== \"undefined\") {\n if (cookieStore) {\n console.warn(\n \"Cookie store passed in client environment - this will be ignored\"\n );\n }\n\n const config = getConfig();\n\n // Use the singleton\n if (!clientSDK) {\n clientSDK = new StorefrontSDK({\n ...config,\n tokenStorage: createTokenStorage(\n undefined,\n config.tokenStorageOptions,\n config\n ),\n });\n }\n\n return clientSDK;\n }\n\n // Server-side with explicit cookie store: use request-scoped instance\n if (cookieStore) {\n return getServerSDKCached(cookieStore);\n }\n\n // Server-side without cookies: Use build-time SDK\n // Note: We removed auto-detection to prevent Next.js static analysis issues\n\n // Server-side without request context (SSG/ISR): use build-time SDK\n return getBuildTimeSDK();\n}\n\n\n/**\n * Set global storefront configuration that applies to all SDK instances\n * This gets bundled into both client and server contexts automatically\n */\nexport function setGlobalStorefrontConfig(config: StorefrontRuntimeConfig | null): void {\n globalStorefrontConfig = config;\n \n // Reset existing instances to pick up new configuration\n clientSDK = null;\n buildTimeSDK = null;\n}\n\n/**\n * Get the current global storefront configuration\n */\nexport function getGlobalStorefrontConfig(): StorefrontRuntimeConfig | null {\n return globalStorefrontConfig;\n}\n\n/**\n * Initialize the SDK (internal use)\n * This should be called once in your app via StorefrontSDKInitializer\n */\nexport function initializeStorefrontSDK(): void {\n // Reset existing instances when reinitializing\n clientSDK = null;\n buildTimeSDK = null;\n}\n"],"mappings":";;;;;;;AAmDA,IAAa,qBAAb,MAAwD;CAKtD,YAAY,UAAqC,IAAI;EACnD,MAAM,SAAS,QAAQ,UAAU;AACjC,OAAK,iBAAiB,GAAG,OAAO;AAChC,OAAK,kBAAkB,GAAG,OAAO;AAEjC,OAAK,UAAU;GACb,QAAQ,QAAQ,UAAU,MAAU,KAAK;GACzC,MAAM,QAAQ,QAAQ;GACtB,QAAQ,QAAQ;GAChB,QAAQ,QAAQ,WAAW,OAAO,WAAW,eAAe,OAAO,UAAU,aAAa;GAC1F,UAAU,QAAQ,YAAY;;;CAIlC,MAAM,iBAAyC;AAC7C,SAAO,KAAK,UAAU,KAAK;;CAG7B,MAAM,eAAe,OAA8B;AACjD,OAAK,UAAU,KAAK,gBAAgB;;CAGtC,MAAM,kBAA0C;AAC9C,SAAO,KAAK,UAAU,KAAK;;CAG7B,MAAM,gBAAgB,OAA8B;AAClD,OAAK,UAAU,KAAK,iBAAiB;;CAGvC,MAAM,cAA6B;AACjC,OAAK,aAAa,KAAK;AACvB,OAAK,aAAa,KAAK;;CAGzB,AAAQ,UAAU,MAA6B;AAC7C,MAAI,OAAO,aAAa,YAAa,QAAO;EAE5C,MAAM,QAAQ,KAAK,SAAS;EAC5B,MAAM,QAAQ,MAAM,MAAM,KAAK,KAAK;AAEpC,MAAI,MAAM,WAAW,GAAG;GACtB,MAAM,cAAc,MAAM,OAAO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AAI,cAAc;EACvB,GAAG;EACH,cAAc,mBACZ,aACA,OAAO,qBACP;;;;;;AAQN,IAAIC,eAAqC;AAEzC,SAAS,kBAAiC;CACxC,MAAM,SAAS;AAGf,KAAI,CAAC,aACH,gBAAe,IAAI,cAAc;EAC/B,GAAG;EACH,cAAc,mBACZ,QACA,OAAO,qBACP;;AAKN,QAAO;;AAoBT,SAAgB,iBAAiB,aAA8C;AAE7E,KAAI,OAAO,WAAW,aAAa;AACjC,MAAI,YACF,SAAQ,KACN;EAIJ,MAAM,SAAS;AAGf,MAAI,CAAC,UACH,aAAY,IAAI,cAAc;GAC5B,GAAG;GACH,cAAc,mBACZ,QACA,OAAO,qBACP;;AAKN,SAAO;;AAIT,KAAI,YACF,QAAO,mBAAmB;AAO5B,QAAO;;;;;;AAQT,SAAgB,0BAA0B,QAA8C;AACtF,0BAAyB;AAGzB,aAAY;AACZ,gBAAe;;;;;;AAcjB,SAAgB,0BAAgC;AAE9C,aAAY;AACZ,gBAAe"}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { DebugLoggerFn, Environment, StorefrontSDK, StorefrontSDKOptions, SupportedDefaultHeaders, TokenStorage } from "@commercengine/storefront-sdk";
|
|
2
|
-
|
|
3
|
-
//#region src/token-storage.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration options for NextJSTokenStorage
|
|
7
|
-
*/
|
|
8
|
-
interface NextJSTokenStorageOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Prefix for cookie names (default: "ce_")
|
|
11
|
-
*/
|
|
12
|
-
prefix?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Maximum age of cookies in seconds (default: 30 days)
|
|
15
|
-
*/
|
|
16
|
-
maxAge?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Cookie path (default: "/")
|
|
19
|
-
*/
|
|
20
|
-
path?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Cookie domain (default: current domain)
|
|
23
|
-
*/
|
|
24
|
-
domain?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Whether cookies should be secure (default: auto-detect based on environment)
|
|
27
|
-
*/
|
|
28
|
-
secure?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* SameSite cookie attribute (default: "Lax")
|
|
31
|
-
*/
|
|
32
|
-
sameSite?: "Strict" | "Lax" | "None";
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Client-side token storage that uses document.cookie
|
|
36
|
-
*/
|
|
37
|
-
declare class ClientTokenStorage implements TokenStorage {
|
|
38
|
-
private accessTokenKey;
|
|
39
|
-
private refreshTokenKey;
|
|
40
|
-
private options;
|
|
41
|
-
constructor(options?: NextJSTokenStorageOptions);
|
|
42
|
-
getAccessToken(): Promise<string | null>;
|
|
43
|
-
setAccessToken(token: string): Promise<void>;
|
|
44
|
-
getRefreshToken(): Promise<string | null>;
|
|
45
|
-
setRefreshToken(token: string): Promise<void>;
|
|
46
|
-
clearTokens(): Promise<void>;
|
|
47
|
-
private getCookie;
|
|
48
|
-
private setCookie;
|
|
49
|
-
private deleteCookie;
|
|
50
|
-
}
|
|
51
|
-
type NextCookieStore$1 = {
|
|
52
|
-
get: (name: string) => {
|
|
53
|
-
value: string;
|
|
54
|
-
} | undefined;
|
|
55
|
-
set: (name: string, value: string, options?: any) => void;
|
|
56
|
-
delete: (name: string) => void;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Server-side token storage that uses Next.js cookies API
|
|
60
|
-
*/
|
|
61
|
-
declare class ServerTokenStorage implements TokenStorage {
|
|
62
|
-
private accessTokenKey;
|
|
63
|
-
private refreshTokenKey;
|
|
64
|
-
private options;
|
|
65
|
-
private cookieStore;
|
|
66
|
-
constructor(cookieStore: NextCookieStore$1, options?: NextJSTokenStorageOptions);
|
|
67
|
-
getAccessToken(): Promise<string | null>;
|
|
68
|
-
setAccessToken(token: string): Promise<void>;
|
|
69
|
-
getRefreshToken(): Promise<string | null>;
|
|
70
|
-
setRefreshToken(token: string): Promise<void>;
|
|
71
|
-
clearTokens(): Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
//#endregion
|
|
74
|
-
//#region src/sdk-manager.d.ts
|
|
75
|
-
/**
|
|
76
|
-
* Configuration for the NextJS SDK wrapper
|
|
77
|
-
*/
|
|
78
|
-
interface NextJSSDKConfig extends Omit<StorefrontSDKOptions, "tokenStorage"> {
|
|
79
|
-
/**
|
|
80
|
-
* Token storage configuration options
|
|
81
|
-
*/
|
|
82
|
-
tokenStorageOptions?: NextJSTokenStorageOptions;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Runtime configuration overrides that can be passed to storefront() function
|
|
86
|
-
* These override environment variables for that specific request
|
|
87
|
-
*/
|
|
88
|
-
interface StorefrontRuntimeConfig {
|
|
89
|
-
/**
|
|
90
|
-
* Override environment variables
|
|
91
|
-
*/
|
|
92
|
-
storeId?: string;
|
|
93
|
-
apiKey?: string;
|
|
94
|
-
environment?: Environment;
|
|
95
|
-
baseUrl?: string;
|
|
96
|
-
timeout?: number;
|
|
97
|
-
debug?: boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Advanced options not available via environment variables
|
|
100
|
-
*/
|
|
101
|
-
accessToken?: string;
|
|
102
|
-
refreshToken?: string;
|
|
103
|
-
defaultHeaders?: SupportedDefaultHeaders;
|
|
104
|
-
logger?: DebugLoggerFn;
|
|
105
|
-
onTokensUpdated?: (accessToken: string, refreshToken: string) => void;
|
|
106
|
-
onTokensCleared?: () => void;
|
|
107
|
-
/**
|
|
108
|
-
* Token storage configuration
|
|
109
|
-
*/
|
|
110
|
-
tokenStorageOptions?: NextJSTokenStorageOptions;
|
|
111
|
-
}
|
|
112
|
-
type NextCookieStore = {
|
|
113
|
-
get: (name: string) => {
|
|
114
|
-
value: string;
|
|
115
|
-
} | undefined;
|
|
116
|
-
set: (name: string, value: string, options?: any) => void;
|
|
117
|
-
delete: (name: string) => void;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Smart SDK getter that automatically detects environment
|
|
121
|
-
*
|
|
122
|
-
* Usage:
|
|
123
|
-
* - Client-side: getStorefrontSDK()
|
|
124
|
-
* - Server-side with request context: getStorefrontSDK(await cookies())
|
|
125
|
-
* - SSG/ISR (no request context): getStorefrontSDK() (uses memory storage)
|
|
126
|
-
*/
|
|
127
|
-
declare function getStorefrontSDK(): StorefrontSDK;
|
|
128
|
-
declare function getStorefrontSDK(cookieStore: NextCookieStore): StorefrontSDK;
|
|
129
|
-
/**
|
|
130
|
-
* Set global storefront configuration that applies to all SDK instances
|
|
131
|
-
* This gets bundled into both client and server contexts automatically
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Initialize the SDK (internal use)
|
|
136
|
-
* This should be called once in your app via StorefrontSDKInitializer
|
|
137
|
-
*/
|
|
138
|
-
declare function initializeStorefrontSDK(): void;
|
|
139
|
-
//#endregion
|
|
140
|
-
export { ClientTokenStorage, NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, StorefrontRuntimeConfig, getStorefrontSDK, initializeStorefrontSDK };
|
|
141
|
-
//# sourceMappingURL=sdk-manager-D2ktqPrp.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-manager-D2ktqPrp.d.cts","names":[],"sources":["../src/token-storage.ts","../src/sdk-manager.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AA8Ca,UA9CI,yBAAA,CA8Ce;EAAA;;;QAuBO,CAAA,EAAA,MAAA;;;;QAvBI,CAAA,EAAA,MAAA;;AAkG1C;AAYD;EAAgC,IAAA,CAAA,EAAA,MAAA;;;;QA8BO,CAAA,EAAA,MAAA;;;;QA9BI,CAAA,EAAA,OAAA;;;;;AC9I3C;;;;AACU,cD+BG,kBAAA,YAA8B,YC/BjC,CAAA;;EAWO,QAAA,eAAA;EAAuB,QAAA,OAAA;aAMxB,CAAA,OAAA,CAAA,EDmBO,yBCnBP;gBAUG,CAAA,CAAA,EDuBO,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AA;EACpB,MAAA,EAAA,CAAA,IAAA,EAAA,MAAgB,EAAA,GAAA,IAAA;CAAA;;;;AA+DhC;;;;;iBAhEgB,gBAAA,CAAA,GAAoB;iBACpB,gBAAA,cAA8B,kBAAkB;;;;;;;;;;iBA+DhD,uBAAA,CAAA"}
|
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const react = __toESM(require("react"));
|
|
25
|
-
const __commercengine_storefront_sdk = __toESM(require("@commercengine/storefront-sdk"));
|
|
26
|
-
|
|
27
|
-
//#region src/token-storage.ts
|
|
28
|
-
/**
|
|
29
|
-
* Client-side token storage that uses document.cookie
|
|
30
|
-
*/
|
|
31
|
-
var ClientTokenStorage = class {
|
|
32
|
-
constructor(options = {}) {
|
|
33
|
-
const prefix = options.prefix || "ce_";
|
|
34
|
-
this.accessTokenKey = `${prefix}access_token`;
|
|
35
|
-
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
36
|
-
this.options = {
|
|
37
|
-
maxAge: options.maxAge || 720 * 60 * 60,
|
|
38
|
-
path: options.path || "/",
|
|
39
|
-
domain: options.domain,
|
|
40
|
-
secure: options.secure ?? (typeof window !== "undefined" && window.location?.protocol === "https:"),
|
|
41
|
-
sameSite: options.sameSite || "Lax"
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
async getAccessToken() {
|
|
45
|
-
return this.getCookie(this.accessTokenKey);
|
|
46
|
-
}
|
|
47
|
-
async setAccessToken(token) {
|
|
48
|
-
this.setCookie(this.accessTokenKey, token);
|
|
49
|
-
}
|
|
50
|
-
async getRefreshToken() {
|
|
51
|
-
return this.getCookie(this.refreshTokenKey);
|
|
52
|
-
}
|
|
53
|
-
async setRefreshToken(token) {
|
|
54
|
-
this.setCookie(this.refreshTokenKey, token);
|
|
55
|
-
}
|
|
56
|
-
async clearTokens() {
|
|
57
|
-
this.deleteCookie(this.accessTokenKey);
|
|
58
|
-
this.deleteCookie(this.refreshTokenKey);
|
|
59
|
-
}
|
|
60
|
-
getCookie(name) {
|
|
61
|
-
if (typeof document === "undefined") return null;
|
|
62
|
-
const value = `; ${document.cookie}`;
|
|
63
|
-
const parts = value.split(`; ${name}=`);
|
|
64
|
-
if (parts.length === 2) {
|
|
65
|
-
const cookieValue = parts.pop()?.split(";").shift();
|
|
66
|
-
return cookieValue ? decodeURIComponent(cookieValue) : null;
|
|
67
|
-
}
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
setCookie(name, value) {
|
|
71
|
-
if (typeof document === "undefined") return;
|
|
72
|
-
const encodedValue = encodeURIComponent(value);
|
|
73
|
-
let cookieString = `${name}=${encodedValue}`;
|
|
74
|
-
if (this.options.maxAge) cookieString += `; Max-Age=${this.options.maxAge}`;
|
|
75
|
-
if (this.options.path) cookieString += `; Path=${this.options.path}`;
|
|
76
|
-
if (this.options.domain) cookieString += `; Domain=${this.options.domain}`;
|
|
77
|
-
if (this.options.secure) cookieString += `; Secure`;
|
|
78
|
-
if (this.options.sameSite) cookieString += `; SameSite=${this.options.sameSite}`;
|
|
79
|
-
document.cookie = cookieString;
|
|
80
|
-
}
|
|
81
|
-
deleteCookie(name) {
|
|
82
|
-
if (typeof document === "undefined") return;
|
|
83
|
-
let cookieString = `${name}=; Max-Age=0`;
|
|
84
|
-
if (this.options.path) cookieString += `; Path=${this.options.path}`;
|
|
85
|
-
if (this.options.domain) cookieString += `; Domain=${this.options.domain}`;
|
|
86
|
-
document.cookie = cookieString;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Server-side token storage that uses Next.js cookies API
|
|
91
|
-
*/
|
|
92
|
-
var ServerTokenStorage = class {
|
|
93
|
-
constructor(cookieStore, options = {}) {
|
|
94
|
-
const prefix = options.prefix || "ce_";
|
|
95
|
-
this.accessTokenKey = `${prefix}access_token`;
|
|
96
|
-
this.refreshTokenKey = `${prefix}refresh_token`;
|
|
97
|
-
this.cookieStore = cookieStore;
|
|
98
|
-
this.options = {
|
|
99
|
-
maxAge: options.maxAge || 720 * 60 * 60,
|
|
100
|
-
path: options.path || "/",
|
|
101
|
-
domain: options.domain,
|
|
102
|
-
secure: options.secure ?? process.env.NODE_ENV === "production",
|
|
103
|
-
sameSite: options.sameSite || "Lax"
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
async getAccessToken() {
|
|
107
|
-
try {
|
|
108
|
-
return this.cookieStore.get(this.accessTokenKey)?.value || null;
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.warn(`Could not get access token from server cookies:`, error);
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async setAccessToken(token) {
|
|
115
|
-
try {
|
|
116
|
-
this.cookieStore.set(this.accessTokenKey, token, {
|
|
117
|
-
maxAge: this.options.maxAge,
|
|
118
|
-
path: this.options.path,
|
|
119
|
-
domain: this.options.domain,
|
|
120
|
-
secure: this.options.secure,
|
|
121
|
-
sameSite: this.options.sameSite?.toLowerCase(),
|
|
122
|
-
httpOnly: false
|
|
123
|
-
});
|
|
124
|
-
} catch (error) {
|
|
125
|
-
console.warn(`Could not set access token on server:`, error);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async getRefreshToken() {
|
|
129
|
-
try {
|
|
130
|
-
return this.cookieStore.get(this.refreshTokenKey)?.value || null;
|
|
131
|
-
} catch (error) {
|
|
132
|
-
console.warn(`Could not get refresh token from server cookies:`, error);
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async setRefreshToken(token) {
|
|
137
|
-
try {
|
|
138
|
-
this.cookieStore.set(this.refreshTokenKey, token, {
|
|
139
|
-
maxAge: this.options.maxAge,
|
|
140
|
-
path: this.options.path,
|
|
141
|
-
domain: this.options.domain,
|
|
142
|
-
secure: this.options.secure,
|
|
143
|
-
sameSite: this.options.sameSite?.toLowerCase(),
|
|
144
|
-
httpOnly: false
|
|
145
|
-
});
|
|
146
|
-
} catch (error) {
|
|
147
|
-
console.warn(`Could not set refresh token on server:`, error);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
async clearTokens() {
|
|
151
|
-
try {
|
|
152
|
-
this.cookieStore.delete(this.accessTokenKey);
|
|
153
|
-
this.cookieStore.delete(this.refreshTokenKey);
|
|
154
|
-
} catch (error) {
|
|
155
|
-
console.warn(`Could not clear tokens on server:`, error);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
//#endregion
|
|
161
|
-
//#region src/build-token-cache.ts
|
|
162
|
-
const store = /* @__PURE__ */ new Map();
|
|
163
|
-
function isExpired(token) {
|
|
164
|
-
if (!token) return true;
|
|
165
|
-
if (!token.expiresAt) return false;
|
|
166
|
-
return Date.now() > token.expiresAt - 3e4;
|
|
167
|
-
}
|
|
168
|
-
function getCachedToken(key) {
|
|
169
|
-
const token = store.get(key);
|
|
170
|
-
return isExpired(token) ? null : token;
|
|
171
|
-
}
|
|
172
|
-
function setCachedToken(key, token) {
|
|
173
|
-
const expiresAt = token.ttlSeconds != null ? Date.now() + token.ttlSeconds * 1e3 : void 0;
|
|
174
|
-
store.set(key, {
|
|
175
|
-
accessToken: token.accessToken,
|
|
176
|
-
refreshToken: token.refreshToken ?? null,
|
|
177
|
-
expiresAt
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
function clearCachedToken(key) {
|
|
181
|
-
store.delete(key);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/build-caching-memory-storage.ts
|
|
186
|
-
const DEFAULT_TTL_SECONDS = 300;
|
|
187
|
-
/**
|
|
188
|
-
* Memory token storage that reuses tokens across the build process
|
|
189
|
-
* via an in-process cache. Only used during SSG/ISR builds.
|
|
190
|
-
*/
|
|
191
|
-
var BuildCachingMemoryTokenStorage = class {
|
|
192
|
-
constructor(cacheKey, ttlSeconds = DEFAULT_TTL_SECONDS) {
|
|
193
|
-
this.cacheKey = cacheKey;
|
|
194
|
-
this.ttlSeconds = ttlSeconds;
|
|
195
|
-
this.access = null;
|
|
196
|
-
this.refresh = null;
|
|
197
|
-
}
|
|
198
|
-
async getAccessToken() {
|
|
199
|
-
if (this.access) return this.access;
|
|
200
|
-
const cached = getCachedToken(this.cacheKey);
|
|
201
|
-
if (cached?.accessToken) {
|
|
202
|
-
this.access = cached.accessToken;
|
|
203
|
-
this.refresh = cached.refreshToken ?? null;
|
|
204
|
-
return this.access;
|
|
205
|
-
}
|
|
206
|
-
return null;
|
|
207
|
-
}
|
|
208
|
-
async setAccessToken(token) {
|
|
209
|
-
this.access = token;
|
|
210
|
-
setCachedToken(this.cacheKey, {
|
|
211
|
-
accessToken: token,
|
|
212
|
-
refreshToken: this.refresh,
|
|
213
|
-
ttlSeconds: this.ttlSeconds
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
async getRefreshToken() {
|
|
217
|
-
return this.refresh;
|
|
218
|
-
}
|
|
219
|
-
async setRefreshToken(token) {
|
|
220
|
-
this.refresh = token;
|
|
221
|
-
setCachedToken(this.cacheKey, {
|
|
222
|
-
accessToken: this.access ?? "",
|
|
223
|
-
refreshToken: token,
|
|
224
|
-
ttlSeconds: this.ttlSeconds
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
async clearTokens() {
|
|
228
|
-
this.access = null;
|
|
229
|
-
this.refresh = null;
|
|
230
|
-
clearCachedToken(this.cacheKey);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/sdk-manager.ts
|
|
236
|
-
/**
|
|
237
|
-
* Get configuration from environment variables merged with global config
|
|
238
|
-
* Precedence order: environment variables < global config
|
|
239
|
-
*/
|
|
240
|
-
function getConfig() {
|
|
241
|
-
const envStoreId = process.env.NEXT_PUBLIC_STORE_ID;
|
|
242
|
-
const envApiKey = process.env.NEXT_PUBLIC_API_KEY;
|
|
243
|
-
const envEnvironment = process.env.NEXT_PUBLIC_ENVIRONMENT;
|
|
244
|
-
const envBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL;
|
|
245
|
-
const envTimeout = process.env.NEXT_PUBLIC_API_TIMEOUT ? parseInt(process.env.NEXT_PUBLIC_API_TIMEOUT, 10) : void 0;
|
|
246
|
-
const envDebug = process.env.NEXT_PUBLIC_DEBUG_MODE === "true";
|
|
247
|
-
const envDefaultHeaders = {};
|
|
248
|
-
if (process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_GROUP_ID) envDefaultHeaders.customer_group_id = process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_GROUP_ID;
|
|
249
|
-
const storeId = globalStorefrontConfig?.storeId || envStoreId;
|
|
250
|
-
const apiKey = globalStorefrontConfig?.apiKey || envApiKey;
|
|
251
|
-
const environment = globalStorefrontConfig?.environment || (envEnvironment === "production" ? __commercengine_storefront_sdk.Environment.Production : __commercengine_storefront_sdk.Environment.Staging);
|
|
252
|
-
const baseUrl = globalStorefrontConfig?.baseUrl || envBaseUrl;
|
|
253
|
-
const timeout = globalStorefrontConfig?.timeout || envTimeout;
|
|
254
|
-
const debug = globalStorefrontConfig?.debug !== void 0 ? globalStorefrontConfig.debug : envDebug;
|
|
255
|
-
const defaultHeaders = {
|
|
256
|
-
...envDefaultHeaders,
|
|
257
|
-
...globalStorefrontConfig?.defaultHeaders
|
|
258
|
-
};
|
|
259
|
-
if (!storeId || !apiKey) throw new Error(`StorefrontSDK configuration missing! Please set the following environment variables:
|
|
260
|
-
|
|
261
|
-
NEXT_PUBLIC_STORE_ID=your-store-id
|
|
262
|
-
NEXT_PUBLIC_API_KEY=your-api-key
|
|
263
|
-
NEXT_PUBLIC_ENVIRONMENT=staging (or production)
|
|
264
|
-
|
|
265
|
-
These variables are required for both client and server contexts to work.`);
|
|
266
|
-
const config = {
|
|
267
|
-
storeId,
|
|
268
|
-
apiKey,
|
|
269
|
-
environment
|
|
270
|
-
};
|
|
271
|
-
if (baseUrl) config.baseUrl = baseUrl;
|
|
272
|
-
if (timeout) config.timeout = timeout;
|
|
273
|
-
if (debug) config.debug = debug;
|
|
274
|
-
const logger = globalStorefrontConfig?.logger;
|
|
275
|
-
const accessToken = globalStorefrontConfig?.accessToken;
|
|
276
|
-
const refreshToken = globalStorefrontConfig?.refreshToken;
|
|
277
|
-
const onTokensUpdated = globalStorefrontConfig?.onTokensUpdated;
|
|
278
|
-
const onTokensCleared = globalStorefrontConfig?.onTokensCleared;
|
|
279
|
-
const tokenStorageOptions = globalStorefrontConfig?.tokenStorageOptions;
|
|
280
|
-
if (logger) config.logger = logger;
|
|
281
|
-
if (accessToken) config.accessToken = accessToken;
|
|
282
|
-
if (refreshToken) config.refreshToken = refreshToken;
|
|
283
|
-
if (onTokensUpdated) config.onTokensUpdated = onTokensUpdated;
|
|
284
|
-
if (onTokensCleared) config.onTokensCleared = onTokensCleared;
|
|
285
|
-
if (Object.keys(defaultHeaders).length > 0) config.defaultHeaders = defaultHeaders;
|
|
286
|
-
if (tokenStorageOptions) config.tokenStorageOptions = tokenStorageOptions;
|
|
287
|
-
return config;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Global runtime configuration storage
|
|
291
|
-
* This gets bundled into both client and server bundles
|
|
292
|
-
*/
|
|
293
|
-
let globalStorefrontConfig = null;
|
|
294
|
-
/**
|
|
295
|
-
* Client-side SDK singleton (only lives in browser)
|
|
296
|
-
*/
|
|
297
|
-
let clientSDK = null;
|
|
298
|
-
/**
|
|
299
|
-
* Create appropriate token storage based on environment
|
|
300
|
-
*/
|
|
301
|
-
function createTokenStorage(cookieStore, options, config) {
|
|
302
|
-
if (typeof window !== "undefined") return new ClientTokenStorage(options);
|
|
303
|
-
if (cookieStore) return new ServerTokenStorage(cookieStore, options);
|
|
304
|
-
const shouldCache = process.env.NEXT_BUILD_CACHE_TOKENS === "true";
|
|
305
|
-
if (shouldCache && config) {
|
|
306
|
-
const cacheKey = `${config.storeId}:${config.environment || "production"}`;
|
|
307
|
-
return new BuildCachingMemoryTokenStorage(cacheKey);
|
|
308
|
-
}
|
|
309
|
-
return new __commercengine_storefront_sdk.MemoryTokenStorage();
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Request-scoped server SDK factory using React cache
|
|
313
|
-
*/
|
|
314
|
-
const getServerSDKCached = (0, react.cache)((cookieStore) => {
|
|
315
|
-
const config = getConfig();
|
|
316
|
-
return new __commercengine_storefront_sdk.StorefrontSDK({
|
|
317
|
-
...config,
|
|
318
|
-
tokenStorage: createTokenStorage(cookieStore, config.tokenStorageOptions, config)
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
/**
|
|
322
|
-
* Memory-based SDK for SSG/build contexts (no request isolation needed)
|
|
323
|
-
*/
|
|
324
|
-
let buildTimeSDK = null;
|
|
325
|
-
function getBuildTimeSDK() {
|
|
326
|
-
const config = getConfig();
|
|
327
|
-
if (!buildTimeSDK) buildTimeSDK = new __commercengine_storefront_sdk.StorefrontSDK({
|
|
328
|
-
...config,
|
|
329
|
-
tokenStorage: createTokenStorage(void 0, config.tokenStorageOptions, config)
|
|
330
|
-
});
|
|
331
|
-
return buildTimeSDK;
|
|
332
|
-
}
|
|
333
|
-
function getStorefrontSDK(cookieStore) {
|
|
334
|
-
if (typeof window !== "undefined") {
|
|
335
|
-
if (cookieStore) console.warn("Cookie store passed in client environment - this will be ignored");
|
|
336
|
-
const config = getConfig();
|
|
337
|
-
if (!clientSDK) clientSDK = new __commercengine_storefront_sdk.StorefrontSDK({
|
|
338
|
-
...config,
|
|
339
|
-
tokenStorage: createTokenStorage(void 0, config.tokenStorageOptions, config)
|
|
340
|
-
});
|
|
341
|
-
return clientSDK;
|
|
342
|
-
}
|
|
343
|
-
if (cookieStore) return getServerSDKCached(cookieStore);
|
|
344
|
-
return getBuildTimeSDK();
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Set global storefront configuration that applies to all SDK instances
|
|
348
|
-
* This gets bundled into both client and server contexts automatically
|
|
349
|
-
*/
|
|
350
|
-
function setGlobalStorefrontConfig(config) {
|
|
351
|
-
globalStorefrontConfig = config;
|
|
352
|
-
clientSDK = null;
|
|
353
|
-
buildTimeSDK = null;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Initialize the SDK (internal use)
|
|
357
|
-
* This should be called once in your app via StorefrontSDKInitializer
|
|
358
|
-
*/
|
|
359
|
-
function initializeStorefrontSDK() {
|
|
360
|
-
clientSDK = null;
|
|
361
|
-
buildTimeSDK = null;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
//#endregion
|
|
365
|
-
Object.defineProperty(exports, 'ClientTokenStorage', {
|
|
366
|
-
enumerable: true,
|
|
367
|
-
get: function () {
|
|
368
|
-
return ClientTokenStorage;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
Object.defineProperty(exports, 'ServerTokenStorage', {
|
|
372
|
-
enumerable: true,
|
|
373
|
-
get: function () {
|
|
374
|
-
return ServerTokenStorage;
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
Object.defineProperty(exports, '__toESM', {
|
|
378
|
-
enumerable: true,
|
|
379
|
-
get: function () {
|
|
380
|
-
return __toESM;
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
Object.defineProperty(exports, 'getStorefrontSDK', {
|
|
384
|
-
enumerable: true,
|
|
385
|
-
get: function () {
|
|
386
|
-
return getStorefrontSDK;
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
Object.defineProperty(exports, 'initializeStorefrontSDK', {
|
|
390
|
-
enumerable: true,
|
|
391
|
-
get: function () {
|
|
392
|
-
return initializeStorefrontSDK;
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
Object.defineProperty(exports, 'setGlobalStorefrontConfig', {
|
|
396
|
-
enumerable: true,
|
|
397
|
-
get: function () {
|
|
398
|
-
return setGlobalStorefrontConfig;
|
|
399
|
-
}
|
|
400
|
-
});
|
package/dist/server.cjs
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
const require_sdk_manager = require('./sdk-manager-NWADjRFW.cjs');
|
|
2
|
-
const __commercengine_storefront_sdk = require_sdk_manager.__toESM(require("@commercengine/storefront-sdk"));
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, 'AuthClient', {
|
|
5
|
-
enumerable: true,
|
|
6
|
-
get: function () {
|
|
7
|
-
return __commercengine_storefront_sdk.AuthClient;
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
Object.defineProperty(exports, 'BrowserTokenStorage', {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return __commercengine_storefront_sdk.BrowserTokenStorage;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
Object.defineProperty(exports, 'CartClient', {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return __commercengine_storefront_sdk.CartClient;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(exports, 'CatalogClient', {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return __commercengine_storefront_sdk.CatalogClient;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports, 'CookieTokenStorage', {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return __commercengine_storefront_sdk.CookieTokenStorage;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, 'CustomerClient', {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () {
|
|
37
|
-
return __commercengine_storefront_sdk.CustomerClient;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(exports, 'Environment', {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function () {
|
|
43
|
-
return __commercengine_storefront_sdk.Environment;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(exports, 'HelpersClient', {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function () {
|
|
49
|
-
return __commercengine_storefront_sdk.HelpersClient;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(exports, 'MemoryTokenStorage', {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return __commercengine_storefront_sdk.MemoryTokenStorage;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(exports, 'OrderClient', {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function () {
|
|
61
|
-
return __commercengine_storefront_sdk.OrderClient;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
Object.defineProperty(exports, 'ResponseUtils', {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: function () {
|
|
67
|
-
return __commercengine_storefront_sdk.ResponseUtils;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
exports.ServerTokenStorage = require_sdk_manager.ServerTokenStorage;
|
|
71
|
-
Object.defineProperty(exports, 'ShippingClient', {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function () {
|
|
74
|
-
return __commercengine_storefront_sdk.ShippingClient;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(exports, 'StoreConfigClient', {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return __commercengine_storefront_sdk.StoreConfigClient;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(exports, 'StorefrontAPIClient', {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
get: function () {
|
|
86
|
-
return __commercengine_storefront_sdk.StorefrontAPIClient;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(exports, 'StorefrontSDK', {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
get: function () {
|
|
92
|
-
return __commercengine_storefront_sdk.StorefrontSDK;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
exports.getStorefrontSDK = require_sdk_manager.getStorefrontSDK;
|
|
96
|
-
exports.initializeStorefrontSDK = require_sdk_manager.initializeStorefrontSDK;
|
|
97
|
-
Object.keys(__commercengine_storefront_sdk).forEach(function (k) {
|
|
98
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function () { return __commercengine_storefront_sdk[k]; }
|
|
101
|
-
});
|
|
102
|
-
});
|
package/dist/server.d.cts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { NextJSSDKConfig, NextJSTokenStorageOptions, ServerTokenStorage, getStorefrontSDK, initializeStorefrontSDK } from "./sdk-manager-D2ktqPrp.cjs";
|
|
2
|
-
import { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, OrderClient, ResponseUtils, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK } from "@commercengine/storefront-sdk";
|
|
3
|
-
export * from "@commercengine/storefront-sdk";
|
|
4
|
-
export { AuthClient, BrowserTokenStorage, CartClient, CatalogClient, CookieTokenStorage, CustomerClient, Environment, HelpersClient, MemoryTokenStorage, type NextJSSDKConfig, type NextJSTokenStorageOptions, OrderClient, ResponseUtils, ServerTokenStorage, ShippingClient, StoreConfigClient, StorefrontAPIClient, StorefrontSDK, getStorefrontSDK, initializeStorefrontSDK };
|