@scayle/storefront-core 8.37.0 → 8.38.1

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,23 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.38.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Resolved an issue where `Pagination` was not exported correctly as a `type`.
8
+
9
+ **Dependencies**
10
+
11
+ - Updated dependency to @scayle/storefront-api@18.12.0
12
+ - Updated dependency to @scayle/unstorage-scayle-kv-driver@1.0.3
13
+
14
+ ## 8.38.0
15
+
16
+ ### Minor Changes
17
+
18
+ - Refined the `ContextWithoutSession` type to accurately represent actual data: `wishlistKey`, `basketKey`, and `sessionId` are now typed as `string` instead of `undefined`, since even logged-out users have these values set.
19
+ - Made `getCheckoutToken` callable by logged-in and not logged-in users. When called by a not logged-in user, the RPC returns only the `checkoutJWT`. For logged-in users, it continues to return both the `checkoutJWT` and a refreshed `accessToken` as before.
20
+
3
21
  ## 8.37.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -68,4 +68,4 @@ export type RpcMethodParameters<N extends RpcMethodName> = Parameters<RpcMethod<
68
68
  */
69
69
  export type RpcMethodReturnType<N extends RpcMethodName> = ReturnType<RpcMethod<N>>;
70
70
  export type RpcMethodCall = <N extends RpcMethodName, P extends RpcMethodParameters<N>, TResult extends Exclude<Awaited<RpcMethodReturnType<N>>, Response>>(...args: P extends RpcContext ? [N] : [N, P]) => Promise<TResult>;
71
- export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, Pagination, type ProductSortConfig, type ShopCountryCustomData, } from '@scayle/storefront-api';
71
+ export { ExistingItemHandling, AddToBasketFailureKind, UpdateBasketItemFailureKind, AddToWishlistFailureKind, PromotionEffectType, FilterTypes, APISortOption, APISortOrder, type Pagination, type ProductSortConfig, type ShopCountryCustomData, } from '@scayle/storefront-api';
package/dist/index.mjs CHANGED
@@ -14,6 +14,5 @@ export {
14
14
  PromotionEffectType,
15
15
  FilterTypes,
16
16
  APISortOption,
17
- APISortOrder,
18
- Pagination
17
+ APISortOrder
19
18
  } from "@scayle/storefront-api";
@@ -49,7 +49,7 @@ interface CheckoutJwtPayload {
49
49
  * It will return an `ErrorResponse` if no session is found, no access token is present.
50
50
  */
51
51
  export declare const getCheckoutToken: RpcHandler<CheckoutJwtPayload | undefined, {
52
- accessToken: string;
52
+ accessToken: string | undefined;
53
53
  checkoutJwt: string;
54
54
  }>;
55
55
  export {};
@@ -12,19 +12,15 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
12
12
  "No Session found"
13
13
  );
14
14
  }
15
- if (!context.accessToken) {
16
- return new ErrorResponse(
17
- HttpStatusCode.UNAUTHORIZED,
18
- HttpStatusMessage.UNAUTHORIZED,
19
- "No access token present"
15
+ let refreshedAccessToken;
16
+ if (context.accessToken) {
17
+ refreshedAccessToken = await getAccessToken(
18
+ { forceTokenRefresh: true },
19
+ context
20
20
  );
21
- }
22
- const refreshedAccessToken = await getAccessToken(
23
- { forceTokenRefresh: true },
24
- context
25
- );
26
- if (refreshedAccessToken instanceof Response) {
27
- return refreshedAccessToken;
21
+ if (refreshedAccessToken instanceof Response) {
22
+ return refreshedAccessToken;
23
+ }
28
24
  }
29
25
  const secret = new TextEncoder().encode(context.checkout.secret);
30
26
  const now = /* @__PURE__ */ new Date();
@@ -37,7 +33,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
37
33
  carrier,
38
34
  basketId: context.basketKey,
39
35
  campaignKey
40
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.37.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
36
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.38.1"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
41
37
  return {
42
38
  accessToken: refreshedAccessToken,
43
39
  checkoutJwt
@@ -61,9 +61,9 @@ export interface ContextWithSession {
61
61
  * Context interface without session information.
62
62
  */
63
63
  export interface ContextWithoutSession {
64
- wishlistKey: undefined;
65
- basketKey: undefined;
66
- sessionId: undefined;
64
+ wishlistKey: string;
65
+ basketKey: string;
66
+ sessionId: string;
67
67
  user: undefined;
68
68
  accessToken: undefined;
69
69
  refreshToken: undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.37.0",
3
+ "version": "8.38.1",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",
@@ -56,8 +56,8 @@
56
56
  "ufo": "^1.5.3",
57
57
  "uncrypto": "^0.1.3",
58
58
  "utility-types": "^3.11.0",
59
- "@scayle/storefront-api": "18.11.0",
60
- "@scayle/unstorage-scayle-kv-driver": "1.0.2"
59
+ "@scayle/storefront-api": "18.12.0",
60
+ "@scayle/unstorage-scayle-kv-driver": "1.0.3"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/crypto-js": "4.2.2",
@@ -72,9 +72,9 @@
72
72
  "rimraf": "6.0.1",
73
73
  "typescript": "5.8.3",
74
74
  "unbuild": "3.5.0",
75
- "unstorage": "1.16.0",
75
+ "unstorage": "1.16.1",
76
76
  "vitest": "3.2.4",
77
- "@scayle/eslint-config-storefront": "4.6.1"
77
+ "@scayle/eslint-config-storefront": "4.7.0"
78
78
  },
79
79
  "volta": {
80
80
  "node": "22.17.1"