@scayle/storefront-core 8.19.0 → 8.20.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
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 8.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Include additional client information to Auth API requests to improve security.
|
|
8
|
+
- Add `originalIp` to the RPCContext which represents the IP address of the request without considering the `x-forwarded-for` header.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- **\[Basket\]** Pass `campaignKey` to SAPI when updating an basket item using the `updateBasketItem` RPC.
|
|
13
|
+
|
|
14
|
+
## 8.19.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Fix `getCategoriesByPath` RPC to return 404 for non-existing categories.
|
|
19
|
+
|
|
3
20
|
## 8.19.0
|
|
4
21
|
|
|
5
22
|
## 8.18.0
|
package/dist/api/oauth.mjs
CHANGED
|
@@ -25,11 +25,32 @@ export function getOAuthClient(context) {
|
|
|
25
25
|
}
|
|
26
26
|
const { clientId, clientSecret, apiHost } = context.oauth;
|
|
27
27
|
const accessHeader = context.internalAccessHeader;
|
|
28
|
+
const requestHeaders = context.headers;
|
|
29
|
+
const host = requestHeaders.get("host");
|
|
30
|
+
const userAgent = requestHeaders.get("user-agent");
|
|
31
|
+
const contentType = requestHeaders.get("content-type");
|
|
32
|
+
const ip = context.originalIp;
|
|
33
|
+
const additionalHeaders = {};
|
|
34
|
+
if (ip) {
|
|
35
|
+
additionalHeaders["x-original-client-ip"] = ip;
|
|
36
|
+
}
|
|
37
|
+
if (userAgent) {
|
|
38
|
+
additionalHeaders["x-original-user-agent"] = userAgent;
|
|
39
|
+
}
|
|
40
|
+
if (host) {
|
|
41
|
+
additionalHeaders["x-original-host"] = host;
|
|
42
|
+
}
|
|
43
|
+
if (contentType) {
|
|
44
|
+
additionalHeaders["x-original-content-type"] = contentType;
|
|
45
|
+
}
|
|
46
|
+
if (accessHeader) {
|
|
47
|
+
additionalHeaders["x-internal-access"] = accessHeader;
|
|
48
|
+
}
|
|
28
49
|
return new OAuthClient({
|
|
29
50
|
clientId,
|
|
30
51
|
clientSecret,
|
|
31
52
|
apiHost,
|
|
32
|
-
additionalHeaders
|
|
53
|
+
additionalHeaders
|
|
33
54
|
}, context.log);
|
|
34
55
|
}
|
|
35
56
|
export class OAuthClient {
|
|
@@ -241,11 +241,12 @@ export const updateBasketItem = async function updateBasketItem2({ basketItemKey
|
|
|
241
241
|
context
|
|
242
242
|
);
|
|
243
243
|
const { quantity, ...updateParams } = update;
|
|
244
|
+
const campaignKey = update.campaignKey ?? await context.callRpc?.("getCampaignKey");
|
|
244
245
|
const result = await sapiClient.basket.updateItem(
|
|
245
246
|
basketKey,
|
|
246
247
|
basketItemKey,
|
|
247
248
|
quantity,
|
|
248
|
-
{ ...updateParams, with: resolvedWith }
|
|
249
|
+
{ ...updateParams, campaignKey, with: resolvedWith }
|
|
249
250
|
);
|
|
250
251
|
if (result.type === "success") {
|
|
251
252
|
return { basket: result.basket };
|
|
@@ -29,12 +29,18 @@ export const getCategoriesByPath = async function getCategoriesByPath2({ path, c
|
|
|
29
29
|
return getRootCategories({ children, includeHidden, properties }, context);
|
|
30
30
|
}
|
|
31
31
|
const sanitizedPath = splitAndRemoveEmpty(path);
|
|
32
|
-
const result = await cached(
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const result = await cached(
|
|
33
|
+
mapSAPIFetchErrorToResponse(sapiClient.categories.getByPath),
|
|
34
|
+
{
|
|
35
|
+
cacheKeyPrefix: `getByPath-categories-${sanitizedPath}`
|
|
36
|
+
}
|
|
37
|
+
)(sanitizedPath, {
|
|
35
38
|
with: { children, properties },
|
|
36
39
|
includeHidden
|
|
37
40
|
});
|
|
41
|
+
if (result instanceof Response) {
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
38
44
|
const rootPath = await Promise.all(
|
|
39
45
|
(result.rootlineIds || []).map((id) => {
|
|
40
46
|
return cached(sapiClient.categories.getById, {
|
|
@@ -36,7 +36,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload = {}
|
|
|
36
36
|
carrier,
|
|
37
37
|
basketId: context.basketKey,
|
|
38
38
|
campaignKey
|
|
39
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.
|
|
39
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.20.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
40
40
|
return {
|
|
41
41
|
accessToken: refreshedAccessToken,
|
|
42
42
|
checkoutJwt
|