@doswiftly/storefront-sdk 4.7.2 → 7.0.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/CHANGELOG.md +791 -0
- package/README.md +10 -10
- package/dist/core/auth/auth-client.d.ts +14 -8
- package/dist/core/auth/auth-client.d.ts.map +1 -1
- package/dist/core/auth/auth-client.js +26 -20
- package/dist/core/auth/handlers.d.ts +31 -0
- package/dist/core/auth/handlers.d.ts.map +1 -1
- package/dist/core/auth/handlers.js +69 -0
- package/dist/core/auth/types.d.ts +5 -5
- package/dist/core/auth/types.d.ts.map +1 -1
- package/dist/core/cache.d.ts +1 -1
- package/dist/core/cache.js +1 -1
- package/dist/core/cart/cart-client.d.ts +1 -1
- package/dist/core/cart/cart-client.js +1 -1
- package/dist/core/cart/types.d.ts +65 -45
- package/dist/core/cart/types.d.ts.map +1 -1
- package/dist/core/client/compose.d.ts +1 -1
- package/dist/core/client/compose.js +1 -1
- package/dist/core/client/create-client.d.ts +2 -2
- package/dist/core/client/create-client.js +2 -2
- package/dist/core/client/execute.d.ts.map +1 -1
- package/dist/core/client/execute.js +6 -0
- package/dist/core/client/types.js +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/language/cookie-config.d.ts +7 -2
- package/dist/core/language/cookie-config.d.ts.map +1 -1
- package/dist/core/language/cookie-config.js +7 -2
- package/dist/core/operations/auth.d.ts +11 -5
- package/dist/core/operations/auth.d.ts.map +1 -1
- package/dist/core/operations/auth.js +22 -16
- package/dist/core/operations/cart.d.ts +8 -8
- package/dist/core/operations/cart.d.ts.map +1 -1
- package/dist/core/operations/cart.js +58 -42
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react/hooks/use-auth.d.ts +4 -4
- package/dist/react/hooks/use-auth.d.ts.map +1 -1
- package/dist/react/hooks/use-auth.js +11 -18
- package/dist/react/hooks/use-cart-manager.d.ts +1 -1
- package/dist/react/hooks/use-cart-manager.js +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/stores/auth.store.d.ts +0 -2
- package/dist/react/stores/auth.store.d.ts.map +1 -1
- package/dist/react/stores/auth.store.js +10 -7
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ const logMiddleware: Middleware = async (req, next) => {
|
|
|
147
147
|
const cartClient = new CartClient(client);
|
|
148
148
|
|
|
149
149
|
const cart = await cartClient.create();
|
|
150
|
-
const updated = await cartClient.addItems(cartId, [{
|
|
150
|
+
const updated = await cartClient.addItems(cartId, [{ variantId: 'v-123', quantity: 1 }]);
|
|
151
151
|
await cartClient.updateItems(cartId, [{ id: 'line-1', quantity: 3 }]);
|
|
152
152
|
await cartClient.removeItems(cartId, ['line-1']);
|
|
153
153
|
await cartClient.updateDiscountCodes(cartId, ['SAVE10']);
|
|
@@ -164,10 +164,10 @@ Auto-throws `StorefrontError` with code `USER_ERROR` on validation failures.
|
|
|
164
164
|
const authClient = new AuthClient(client);
|
|
165
165
|
|
|
166
166
|
const { accessToken, expiresAt } = await authClient.login('user@example.com', 'pass');
|
|
167
|
-
await authClient.logout(
|
|
168
|
-
const renewed = await authClient.
|
|
169
|
-
const { accessToken, customer } = await authClient.register({ email, password, firstName });
|
|
170
|
-
const
|
|
167
|
+
await authClient.logout();
|
|
168
|
+
const renewed = await authClient.refreshToken();
|
|
169
|
+
const { accessToken: regToken, customer } = await authClient.register({ email, password, firstName });
|
|
170
|
+
const me = await authClient.getCustomer();
|
|
171
171
|
```
|
|
172
172
|
|
|
173
173
|
### StorefrontError
|
|
@@ -312,10 +312,10 @@ cacheCustom({ maxAge: 300, swr: 600 }) // 5min + 10min swr
|
|
|
312
312
|
|
|
313
313
|
```typescript
|
|
314
314
|
const {
|
|
315
|
-
login,
|
|
316
|
-
logout,
|
|
317
|
-
|
|
318
|
-
isLoggingIn, isLoggingOut,
|
|
315
|
+
login, // (email, password) => Promise<LoginResult>
|
|
316
|
+
logout, // () => Promise<LogoutResult>
|
|
317
|
+
refreshToken, // () => Promise<TokenRefreshResult>
|
|
318
|
+
isLoggingIn, isLoggingOut, isRefreshingToken, isLoading,
|
|
319
319
|
error,
|
|
320
320
|
} = useAuth({
|
|
321
321
|
onSetToken: async (token) => { /* set httpOnly cookie via server route */ },
|
|
@@ -418,7 +418,7 @@ const authHydrated = useAuthHydrated(); // true after localStorage rehydration
|
|
|
418
418
|
// Currency
|
|
419
419
|
const { currency, baseCurrency, supportedCurrencies, setCurrency, isLoaded } = useCurrencyStore();
|
|
420
420
|
|
|
421
|
-
// For .getState() in callbacks (e.g. logout,
|
|
421
|
+
// For .getState() in callbacks (e.g. logout, refreshToken)
|
|
422
422
|
import { useAuthStoreApi, useCurrencyStoreApi } from '@doswiftly/storefront-sdk/react';
|
|
423
423
|
const authStore = useAuthStoreApi();
|
|
424
424
|
const token = authStore.getState().accessToken;
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* const authClient = new AuthClient(storefrontClient);
|
|
10
10
|
*
|
|
11
11
|
* const result = await authClient.login('user@example.com', 'password');
|
|
12
|
-
* console.log(result.accessToken); // JWT
|
|
12
|
+
* console.log(result.accessToken); // JWT (also set as httpOnly cookie by API)
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* // Auth context resolved server-side from cookie/Bearer — no token argument.
|
|
15
|
+
* const customer = await authClient.getCustomer();
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
18
|
import type { StorefrontClient } from '../client/types';
|
|
@@ -25,22 +26,27 @@ export declare class AuthClient {
|
|
|
25
26
|
*/
|
|
26
27
|
login(email: string, password: string): Promise<AuthResult>;
|
|
27
28
|
/**
|
|
28
|
-
* Logout —
|
|
29
|
+
* Logout — invalidates auth cookie on backend (server clears Set-Cookie via Apollo plugin).
|
|
30
|
+
* Auth context czytany przez backend `StorefrontShopGuard` z httpOnly cookie lub
|
|
31
|
+
* `Authorization: Bearer` header (gdy ustawione przez SDK auth middleware).
|
|
29
32
|
* Does not throw on failure (token may already be expired).
|
|
30
33
|
*/
|
|
31
|
-
logout(
|
|
34
|
+
logout(): Promise<void>;
|
|
32
35
|
/**
|
|
33
|
-
*
|
|
36
|
+
* Refresh access token — extends expiry. Auth context czytany przez backend
|
|
37
|
+
* z cookie / Authorization Bearer (jak inne authenticated mutations).
|
|
34
38
|
*/
|
|
35
|
-
|
|
39
|
+
refreshToken(): Promise<AuthResult>;
|
|
36
40
|
/**
|
|
37
41
|
* Register new customer account.
|
|
38
42
|
* Returns access token + customer data.
|
|
39
43
|
*/
|
|
40
44
|
register(input: CustomerCreateInput): Promise<AuthResult>;
|
|
41
45
|
/**
|
|
42
|
-
* Fetch customer data
|
|
46
|
+
* Fetch customer data — auth context z cookie / Authorization Bearer.
|
|
47
|
+
* Browser uses cookie auto-sent; non-browser klient passes Bearer header
|
|
48
|
+
* via SDK auth middleware (`setAuthToken`).
|
|
43
49
|
*/
|
|
44
|
-
getCustomer(
|
|
50
|
+
getCustomer(): Promise<Customer | null>;
|
|
45
51
|
}
|
|
46
52
|
//# sourceMappingURL=auth-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../../src/core/auth/auth-client.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auth-client.d.ts","sourceRoot":"","sources":["../../../src/core/auth/auth-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAUzE,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,gBAAgB;IAErD;;;OAGG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAiBjE;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAa7B;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC;IAiBzC;;;OAGG;IACG,QAAQ,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB/D;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAO9C"}
|
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
* const authClient = new AuthClient(storefrontClient);
|
|
10
10
|
*
|
|
11
11
|
* const result = await authClient.login('user@example.com', 'password');
|
|
12
|
-
* console.log(result.accessToken); // JWT
|
|
12
|
+
* console.log(result.accessToken); // JWT (also set as httpOnly cookie by API)
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* // Auth context resolved server-side from cookie/Bearer — no token argument.
|
|
15
|
+
* const customer = await authClient.getCustomer();
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
18
|
import { assertNoUserErrors } from '../helpers/assert-no-user-errors';
|
|
18
|
-
import { CUSTOMER_LOGIN, CUSTOMER_LOGOUT,
|
|
19
|
+
import { CUSTOMER_LOGIN, CUSTOMER_LOGOUT, CUSTOMER_REFRESH_TOKEN, CUSTOMER_SIGNUP, CUSTOMER_QUERY, } from '../operations/auth';
|
|
19
20
|
export class AuthClient {
|
|
20
21
|
client;
|
|
21
22
|
constructor(client) {
|
|
@@ -27,32 +28,35 @@ export class AuthClient {
|
|
|
27
28
|
*/
|
|
28
29
|
async login(email, password) {
|
|
29
30
|
const data = await this.client.mutate(CUSTOMER_LOGIN, { input: { email, password } });
|
|
30
|
-
assertNoUserErrors(data.
|
|
31
|
-
const token = data.
|
|
31
|
+
assertNoUserErrors(data.customerLogin);
|
|
32
|
+
const token = data.customerLogin.customerAccessToken;
|
|
32
33
|
return {
|
|
33
34
|
accessToken: token.accessToken,
|
|
34
35
|
expiresAt: token.expiresAt,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
|
-
* Logout —
|
|
39
|
+
* Logout — invalidates auth cookie on backend (server clears Set-Cookie via Apollo plugin).
|
|
40
|
+
* Auth context czytany przez backend `StorefrontShopGuard` z httpOnly cookie lub
|
|
41
|
+
* `Authorization: Bearer` header (gdy ustawione przez SDK auth middleware).
|
|
39
42
|
* Does not throw on failure (token may already be expired).
|
|
40
43
|
*/
|
|
41
|
-
async logout(
|
|
44
|
+
async logout() {
|
|
42
45
|
try {
|
|
43
|
-
await this.client.mutate(CUSTOMER_LOGOUT
|
|
46
|
+
await this.client.mutate(CUSTOMER_LOGOUT);
|
|
44
47
|
}
|
|
45
48
|
catch {
|
|
46
49
|
// Silently ignore — token may already be expired
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
/**
|
|
50
|
-
*
|
|
53
|
+
* Refresh access token — extends expiry. Auth context czytany przez backend
|
|
54
|
+
* z cookie / Authorization Bearer (jak inne authenticated mutations).
|
|
51
55
|
*/
|
|
52
|
-
async
|
|
53
|
-
const data = await this.client.mutate(
|
|
54
|
-
assertNoUserErrors(data.
|
|
55
|
-
const renewed = data.
|
|
56
|
+
async refreshToken() {
|
|
57
|
+
const data = await this.client.mutate(CUSTOMER_REFRESH_TOKEN);
|
|
58
|
+
assertNoUserErrors(data.customerRefreshToken);
|
|
59
|
+
const renewed = data.customerRefreshToken.customerAccessToken;
|
|
56
60
|
return {
|
|
57
61
|
accessToken: renewed.accessToken,
|
|
58
62
|
expiresAt: renewed.expiresAt,
|
|
@@ -63,20 +67,22 @@ export class AuthClient {
|
|
|
63
67
|
* Returns access token + customer data.
|
|
64
68
|
*/
|
|
65
69
|
async register(input) {
|
|
66
|
-
const data = await this.client.mutate(
|
|
67
|
-
assertNoUserErrors(data.
|
|
68
|
-
const token = data.
|
|
70
|
+
const data = await this.client.mutate(CUSTOMER_SIGNUP, { input });
|
|
71
|
+
assertNoUserErrors(data.customerSignup);
|
|
72
|
+
const token = data.customerSignup.customerAccessToken;
|
|
69
73
|
return {
|
|
70
74
|
accessToken: token.accessToken,
|
|
71
75
|
expiresAt: token.expiresAt,
|
|
72
|
-
customer: data.
|
|
76
|
+
customer: data.customerSignup.customer ?? undefined,
|
|
73
77
|
};
|
|
74
78
|
}
|
|
75
79
|
/**
|
|
76
|
-
* Fetch customer data
|
|
80
|
+
* Fetch customer data — auth context z cookie / Authorization Bearer.
|
|
81
|
+
* Browser uses cookie auto-sent; non-browser klient passes Bearer header
|
|
82
|
+
* via SDK auth middleware (`setAuthToken`).
|
|
77
83
|
*/
|
|
78
|
-
async getCustomer(
|
|
79
|
-
const data = await this.client.query(CUSTOMER_QUERY
|
|
84
|
+
async getCustomer() {
|
|
85
|
+
const data = await this.client.query(CUSTOMER_QUERY);
|
|
80
86
|
return data.customer;
|
|
81
87
|
}
|
|
82
88
|
}
|
|
@@ -22,6 +22,37 @@ interface SetTokenHandlerOptions {
|
|
|
22
22
|
* httpOnly (XSS protection), Secure in production.
|
|
23
23
|
*/
|
|
24
24
|
export declare function createSetTokenHandler(overrides?: SetTokenHandlerOptions): (request: Request) => Promise<Response>;
|
|
25
|
+
interface WhoamiHandlerOptions {
|
|
26
|
+
/** Backend GraphQL endpoint (default: `${apiUrl}/storefront/graphql`). */
|
|
27
|
+
apiUrl?: string;
|
|
28
|
+
/** Shop slug header value (X-Shop-Slug). */
|
|
29
|
+
shopSlug?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a GET handler that hydrates customer state z httpOnly cookie.
|
|
33
|
+
*
|
|
34
|
+
* Browser-based storefront po hydration mountuje React app z czystym auth store
|
|
35
|
+
* (XSS fix — `accessToken` nie persistuje w localStorage). Aby pokazać "logged in"
|
|
36
|
+
* UI bez round-trip do login, klient wywołuje GET `/api/auth/whoami`:
|
|
37
|
+
*
|
|
38
|
+
* 1. Endpoint reads httpOnly cookie `customerAccessToken` (server-side, JS-inaccessible)
|
|
39
|
+
* 2. Forward jako `Authorization: Bearer` header do backend GraphQL `customer` query
|
|
40
|
+
* 3. Return `{ isAuthenticated, customer | null }` do klienta
|
|
41
|
+
* 4. Klient setAuth(customer, '') — token NIE w body (cookie kontynuuje per-request auth)
|
|
42
|
+
*
|
|
43
|
+
* Security: origin validation, fetch via Bearer (cookie nie crossuje API boundary).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* // app/api/auth/whoami/route.ts
|
|
48
|
+
* import { createWhoamiHandler } from '@doswiftly/storefront-sdk';
|
|
49
|
+
* export const GET = createWhoamiHandler({
|
|
50
|
+
* apiUrl: process.env.NEXT_PUBLIC_API_URL!,
|
|
51
|
+
* shopSlug: process.env.NEXT_PUBLIC_SHOP_SLUG!,
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function createWhoamiHandler(options?: WhoamiHandlerOptions): (request: Request) => Promise<Response>;
|
|
25
56
|
/**
|
|
26
57
|
* Create a POST handler that clears the auth token cookie.
|
|
27
58
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/core/auth/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,UAAU,sBAAsB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmCD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,CAAC,EAAE,sBAAsB,GACjC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAgEzC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkCjF"}
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/core/auth/handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,UAAU,sBAAsB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAmCD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,CAAC,EAAE,sBAAsB,GACjC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAgEzC;AAED,UAAU,oBAAoB;IAC5B,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,oBAAyB,GACjC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CA6DzC;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,IAAI,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAkCjF"}
|
|
@@ -91,6 +91,75 @@ export function createSetTokenHandler(overrides) {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Create a GET handler that hydrates customer state z httpOnly cookie.
|
|
96
|
+
*
|
|
97
|
+
* Browser-based storefront po hydration mountuje React app z czystym auth store
|
|
98
|
+
* (XSS fix — `accessToken` nie persistuje w localStorage). Aby pokazać "logged in"
|
|
99
|
+
* UI bez round-trip do login, klient wywołuje GET `/api/auth/whoami`:
|
|
100
|
+
*
|
|
101
|
+
* 1. Endpoint reads httpOnly cookie `customerAccessToken` (server-side, JS-inaccessible)
|
|
102
|
+
* 2. Forward jako `Authorization: Bearer` header do backend GraphQL `customer` query
|
|
103
|
+
* 3. Return `{ isAuthenticated, customer | null }` do klienta
|
|
104
|
+
* 4. Klient setAuth(customer, '') — token NIE w body (cookie kontynuuje per-request auth)
|
|
105
|
+
*
|
|
106
|
+
* Security: origin validation, fetch via Bearer (cookie nie crossuje API boundary).
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* // app/api/auth/whoami/route.ts
|
|
111
|
+
* import { createWhoamiHandler } from '@doswiftly/storefront-sdk';
|
|
112
|
+
* export const GET = createWhoamiHandler({
|
|
113
|
+
* apiUrl: process.env.NEXT_PUBLIC_API_URL!,
|
|
114
|
+
* shopSlug: process.env.NEXT_PUBLIC_SHOP_SLUG!,
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export function createWhoamiHandler(options = {}) {
|
|
119
|
+
return async (request) => {
|
|
120
|
+
try {
|
|
121
|
+
const originError = validateOrigin(request);
|
|
122
|
+
if (originError)
|
|
123
|
+
return originError;
|
|
124
|
+
const cookieHeader = request.headers.get('cookie') ?? '';
|
|
125
|
+
const tokenMatch = cookieHeader.match(new RegExp(`(?:^|; )${AUTH_COOKIE_NAME}=([^;]+)`));
|
|
126
|
+
const token = tokenMatch ? decodeURIComponent(tokenMatch[1]) : null;
|
|
127
|
+
if (!token) {
|
|
128
|
+
return new Response(JSON.stringify({ isAuthenticated: false, customer: null }), { status: 200, headers: { 'Content-Type': 'application/json' } });
|
|
129
|
+
}
|
|
130
|
+
const apiUrl = options.apiUrl ?? process.env.NEXT_PUBLIC_API_URL ?? '';
|
|
131
|
+
const shopSlug = options.shopSlug ?? process.env.NEXT_PUBLIC_SHOP_SLUG ?? '';
|
|
132
|
+
const endpoint = `${apiUrl.replace(/\/$/, '')}/storefront/graphql`;
|
|
133
|
+
const gqlResponse = await fetch(endpoint, {
|
|
134
|
+
method: 'POST',
|
|
135
|
+
headers: {
|
|
136
|
+
'Content-Type': 'application/json',
|
|
137
|
+
Accept: 'application/json',
|
|
138
|
+
Authorization: `Bearer ${token}`,
|
|
139
|
+
...(shopSlug ? { 'X-Shop-Slug': shopSlug } : {}),
|
|
140
|
+
},
|
|
141
|
+
body: JSON.stringify({
|
|
142
|
+
query: `query Whoami {
|
|
143
|
+
customer {
|
|
144
|
+
id
|
|
145
|
+
email
|
|
146
|
+
firstName
|
|
147
|
+
lastName
|
|
148
|
+
phone
|
|
149
|
+
}
|
|
150
|
+
}`,
|
|
151
|
+
}),
|
|
152
|
+
});
|
|
153
|
+
const json = (await gqlResponse.json());
|
|
154
|
+
const customer = json.data?.customer ?? null;
|
|
155
|
+
return new Response(JSON.stringify({ isAuthenticated: !!customer, customer }), { status: 200, headers: { 'Content-Type': 'application/json' } });
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error('Error in whoami handler:', error);
|
|
159
|
+
return new Response(JSON.stringify({ isAuthenticated: false, customer: null, error: 'Internal server error' }), { status: 500, headers: { 'Content-Type': 'application/json' } });
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
94
163
|
/**
|
|
95
164
|
* Create a POST handler that clears the auth token cookie.
|
|
96
165
|
*
|
|
@@ -25,8 +25,8 @@ export interface Customer {
|
|
|
25
25
|
}
|
|
26
26
|
export interface MailingAddress {
|
|
27
27
|
id: string;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
streetLine1: string | null;
|
|
29
|
+
streetLine2: string | null;
|
|
30
30
|
city: string | null;
|
|
31
31
|
company: string | null;
|
|
32
32
|
country: string | null;
|
|
@@ -34,9 +34,9 @@ export interface MailingAddress {
|
|
|
34
34
|
firstName: string | null;
|
|
35
35
|
lastName: string | null;
|
|
36
36
|
phone: string | null;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
state: string | null;
|
|
38
|
+
stateCode: string | null;
|
|
39
|
+
postalCode: string | null;
|
|
40
40
|
isDefault: boolean;
|
|
41
41
|
}
|
|
42
42
|
export interface AuthResult {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/auth/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,mBAAmB;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ode: string;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
rateTimestamp: string | null;
|
|
27
|
-
isConverted: boolean;
|
|
13
|
+
export interface ImageThumbnail {
|
|
14
|
+
id: string | null;
|
|
15
|
+
url: string;
|
|
16
|
+
altText: string | null;
|
|
17
|
+
width: number | null;
|
|
18
|
+
height: number | null;
|
|
19
|
+
thumbhash: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface PageInfo {
|
|
22
|
+
hasNextPage: boolean;
|
|
23
|
+
hasPreviousPage: boolean;
|
|
24
|
+
startCursor: string | null;
|
|
25
|
+
endCursor: string | null;
|
|
28
26
|
}
|
|
29
27
|
export interface CartCost {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
total: Money;
|
|
29
|
+
subtotal: Money;
|
|
30
|
+
totalTax: Money | null;
|
|
31
|
+
totalDuty: Money | null;
|
|
32
|
+
checkoutCharge: Money | null;
|
|
34
33
|
}
|
|
35
34
|
export interface CartLineCost {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
pricePerUnit: Money;
|
|
36
|
+
subtotal: Money;
|
|
37
|
+
total: Money;
|
|
38
|
+
compareAtPricePerUnit: Money | null;
|
|
40
39
|
}
|
|
41
40
|
export interface SelectedOption {
|
|
42
41
|
name: string;
|
|
43
42
|
value: string;
|
|
44
43
|
}
|
|
45
|
-
export interface
|
|
44
|
+
export interface ProductVariantWeight {
|
|
45
|
+
value: number;
|
|
46
|
+
unit: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ProductVariant {
|
|
46
49
|
id: string;
|
|
47
50
|
title: string;
|
|
48
51
|
sku: string | null;
|
|
49
|
-
price:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
quantityAvailable: number | null;
|
|
55
|
-
image: {
|
|
56
|
-
id: string | null;
|
|
57
|
-
url: string;
|
|
58
|
-
altText: string | null;
|
|
59
|
-
width: number | null;
|
|
60
|
-
height: number | null;
|
|
61
|
-
thumbhash: string | null;
|
|
62
|
-
} | null;
|
|
52
|
+
price: Money;
|
|
53
|
+
compareAtPrice: Money | null;
|
|
54
|
+
isAvailable: boolean;
|
|
55
|
+
availableStock: number | null;
|
|
56
|
+
image: ImageThumbnail | null;
|
|
63
57
|
selectedOptions: SelectedOption[];
|
|
64
58
|
barcode: string | null;
|
|
65
|
-
weight:
|
|
66
|
-
|
|
59
|
+
weight: ProductVariantWeight | null;
|
|
60
|
+
sortOrder: number | null;
|
|
61
|
+
}
|
|
62
|
+
export interface AttributeSelection {
|
|
63
|
+
attributeDefinitionId: string;
|
|
64
|
+
attributeName: string;
|
|
65
|
+
type: string;
|
|
66
|
+
fillingMode: string;
|
|
67
|
+
billingMode: string | null;
|
|
68
|
+
optionId: string | null;
|
|
69
|
+
optionLabel: string | null;
|
|
70
|
+
optionIds: string[] | null;
|
|
71
|
+
textValue: string | null;
|
|
72
|
+
surchargeAmount: number;
|
|
73
|
+
surchargeType: string | null;
|
|
74
|
+
taxClassId: string | null;
|
|
75
|
+
linkedVariantId: string | null;
|
|
67
76
|
}
|
|
68
77
|
export interface CartLine {
|
|
69
78
|
id: string;
|
|
70
79
|
quantity: number;
|
|
71
|
-
|
|
80
|
+
variant: ProductVariant;
|
|
72
81
|
cost: CartLineCost;
|
|
73
82
|
attributes: Array<{
|
|
74
83
|
key: string;
|
|
75
84
|
value: string | null;
|
|
76
85
|
}>;
|
|
86
|
+
attributeSelections: AttributeSelection[];
|
|
77
87
|
productId: string | null;
|
|
78
88
|
productTitle: string | null;
|
|
79
89
|
productHandle: string | null;
|
|
80
90
|
productType: string | null;
|
|
81
91
|
}
|
|
92
|
+
export interface CartLineEdge {
|
|
93
|
+
cursor: string;
|
|
94
|
+
node: CartLine;
|
|
95
|
+
}
|
|
96
|
+
export interface CartLineConnection {
|
|
97
|
+
edges: CartLineEdge[];
|
|
98
|
+
nodes: CartLine[];
|
|
99
|
+
pageInfo: PageInfo;
|
|
100
|
+
totalCount: number;
|
|
101
|
+
}
|
|
82
102
|
export interface CartDiscountCode {
|
|
83
103
|
code: string;
|
|
84
|
-
|
|
104
|
+
isApplicable: boolean;
|
|
85
105
|
}
|
|
86
106
|
export interface CartDiscountAllocation {
|
|
87
107
|
discountCode: string;
|
|
@@ -100,7 +120,7 @@ export interface Cart {
|
|
|
100
120
|
createdAt: string;
|
|
101
121
|
updatedAt: string;
|
|
102
122
|
cost: CartCost;
|
|
103
|
-
lines:
|
|
123
|
+
lines: CartLineConnection;
|
|
104
124
|
buyerIdentity: CartBuyerIdentity | null;
|
|
105
125
|
discountCodes: CartDiscountCode[];
|
|
106
126
|
discountAllocations: CartDiscountAllocation[];
|
|
@@ -126,9 +146,9 @@ export interface CartAttributeSelectionInput {
|
|
|
126
146
|
textValue?: string | null;
|
|
127
147
|
}
|
|
128
148
|
export interface CartLineInput {
|
|
129
|
-
|
|
149
|
+
variantId: string;
|
|
130
150
|
quantity?: number;
|
|
131
|
-
/**
|
|
151
|
+
/** Raw Line Item Properties (gift messages, engraving notes, etc.). */
|
|
132
152
|
attributes?: Array<{
|
|
133
153
|
key: string;
|
|
134
154
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/cart/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,M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AAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compose middleware chain using reduceRight (
|
|
2
|
+
* Compose middleware chain using reduceRight (industry-standard pattern).
|
|
3
3
|
*
|
|
4
4
|
* Middleware execute in order: first registered runs first.
|
|
5
5
|
* Each can modify request, modify response, retry, or short-circuit.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compose middleware chain using reduceRight (
|
|
2
|
+
* Compose middleware chain using reduceRight (industry-standard pattern).
|
|
3
3
|
*
|
|
4
4
|
* Middleware execute in order: first registered runs first.
|
|
5
5
|
* Each can modify request, modify response, retry, or short-circuit.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createStorefrontClient — transport factory (
|
|
2
|
+
* createStorefrontClient — transport factory (agnostic-core pattern).
|
|
3
3
|
*
|
|
4
4
|
* Creates a framework-agnostic GraphQL client with:
|
|
5
5
|
* - Middleware pipeline (composable, lazy)
|
|
6
6
|
* - Request deduplication (same-tick queries)
|
|
7
|
-
* - TypedDocumentString support (
|
|
7
|
+
* - TypedDocumentString support (graphql client-preset)
|
|
8
8
|
* - Plain string queries (for custom operations)
|
|
9
9
|
* - Debug mode
|
|
10
10
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* createStorefrontClient — transport factory (
|
|
2
|
+
* createStorefrontClient — transport factory (agnostic-core pattern).
|
|
3
3
|
*
|
|
4
4
|
* Creates a framework-agnostic GraphQL client with:
|
|
5
5
|
* - Middleware pipeline (composable, lazy)
|
|
6
6
|
* - Request deduplication (same-tick queries)
|
|
7
|
-
* - TypedDocumentString support (
|
|
7
|
+
* - TypedDocumentString support (graphql client-preset)
|
|
8
8
|
* - Plain string queries (for custom operations)
|
|
9
9
|
* - Debug mode
|
|
10
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/core/client/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAEjF,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,IAGnB,SAAS,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../../src/core/client/execute.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAoB,MAAM,SAAS,CAAC;AAEjF,MAAM,WAAW,aAAa;IAC5B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,KAAK,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC/B,2BAA2B;IAC3B,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,IAGnB,SAAS,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC,CAmDjF"}
|
|
@@ -30,6 +30,12 @@ export function createExecute(config) {
|
|
|
30
30
|
},
|
|
31
31
|
body: JSON.stringify(body),
|
|
32
32
|
signal,
|
|
33
|
+
// Include httpOnly cookies (e.g. customerAccessToken auth) on cross-origin
|
|
34
|
+
// requests. Required when the storefront runs on a domain different from the
|
|
35
|
+
// backend GraphQL endpoint — same-origin browsers send cookies regardless,
|
|
36
|
+
// but cross-origin needs `credentials: 'include'` paired with the backend's
|
|
37
|
+
// `Access-Control-Allow-Credentials: true` (already configured).
|
|
38
|
+
credentials: 'include',
|
|
33
39
|
});
|
|
34
40
|
const json = await response.json();
|
|
35
41
|
if (debug) {
|