@scayle/storefront-core 8.38.4 → 8.39.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
CHANGED
package/dist/api/oauth.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface OAuthOptions {
|
|
|
10
10
|
apiHost: string;
|
|
11
11
|
additionalHeaders?: HeadersInit;
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Error thrown when OAuth API request fails.
|
|
15
|
+
*/
|
|
16
|
+
export declare class OAuthRequestError extends Error {
|
|
17
|
+
constructor(message: string, options?: ErrorOptions);
|
|
18
|
+
}
|
|
13
19
|
/**
|
|
14
20
|
* Creates and returns an OAuthClient instance using the provided RPC context.
|
|
15
21
|
*
|
package/dist/api/oauth.mjs
CHANGED
|
@@ -7,10 +7,30 @@ class MissingCredentialsError extends Error {
|
|
|
7
7
|
this.name = "MissingCredentialsError";
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
+
export class OAuthRequestError extends Error {
|
|
11
|
+
constructor(message, options) {
|
|
12
|
+
super(message, options);
|
|
13
|
+
this.name = "OAuthRequestError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function stringifyOAuthError(error) {
|
|
17
|
+
if (error.message) {
|
|
18
|
+
return error.hint ? `${error.error}: ${error.message} (hint: ${error.hint})` : `${error.error}: ${error.message}`;
|
|
19
|
+
} else {
|
|
20
|
+
return error.error;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
async function oauthResponseHandler(response) {
|
|
11
24
|
const data = await response.json();
|
|
12
25
|
if (!response.ok) {
|
|
13
|
-
|
|
26
|
+
const fetchError = new FetchError(response, data);
|
|
27
|
+
if (data) {
|
|
28
|
+
const error = new OAuthRequestError(stringifyOAuthError(data), {
|
|
29
|
+
cause: fetchError
|
|
30
|
+
});
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
throw fetchError;
|
|
14
34
|
}
|
|
15
35
|
return data;
|
|
16
36
|
}
|
|
@@ -140,11 +140,11 @@ export const getVariantCrosssellingValues = (variants) => {
|
|
|
140
140
|
if (!variants?.length) {
|
|
141
141
|
return [];
|
|
142
142
|
}
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
...new Map(
|
|
143
|
+
const crossSellings = variants.map((variant) => variant.advancedAttributes?.variantCrosssellings).filter(Boolean);
|
|
144
|
+
const uniqueCrossSellings = [
|
|
145
|
+
...new Map(crossSellings.map((item) => [item?.id ?? item, item])).values()
|
|
146
146
|
];
|
|
147
|
-
const values =
|
|
147
|
+
const values = uniqueCrossSellings.map((r) => r?.values);
|
|
148
148
|
const fieldSets = flattenDeep(values).map((r) => r?.fieldSet);
|
|
149
149
|
return flattenDeep(fieldSets).map((r) => r?.value).filter((it) => !!it);
|
|
150
150
|
};
|
|
@@ -33,7 +33,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
|
|
|
33
33
|
carrier,
|
|
34
34
|
basketId: context.basketKey,
|
|
35
35
|
campaignKey
|
|
36
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
36
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.39.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
37
37
|
return {
|
|
38
38
|
accessToken: refreshedAccessToken,
|
|
39
39
|
checkoutJwt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.39.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/crypto-js": "4.2.2",
|
|
64
|
-
"@types/node": "22.
|
|
64
|
+
"@types/node": "22.17.0",
|
|
65
65
|
"@types/webpack-env": "1.18.8",
|
|
66
66
|
"@vitest/coverage-v8": "3.2.4",
|
|
67
67
|
"dprint": "0.50.1",
|