@scayle/storefront-core 8.50.0 → 8.51.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,15 @@
1
1
  # @scayle/storefront-core
2
2
 
3
+ ## 8.51.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added an email hash (`emailHash`) property to the user object returned by the `fetchUser` RPC method.
8
+
9
+ The `emailHash` property is automatically included in all user objects returned by the RPCs.
10
+ The email hash is calculated server-side using SHA256 and is automatically included when a user has an email address.
11
+ This can be used e.g., for compliant user tracking and analytics without exposing sensitive email information.
12
+
3
13
  ## 8.50.0
4
14
 
5
15
  ### Patch Changes
@@ -37,7 +37,7 @@ export const getCheckoutToken = defineRpcHandler(async (jwtPayload = {}, context
37
37
  ...customData,
38
38
  ...orderCustomData
39
39
  }
40
- }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.50.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
40
+ }).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"8.51.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
41
41
  return {
42
42
  accessToken: refreshedAccessToken,
43
43
  checkoutJwt
@@ -5,6 +5,7 @@ import { HttpStatusCode, HttpStatusMessage } from "../../constants/index.mjs";
5
5
  import { ErrorResponse } from "../../errors/index.mjs";
6
6
  import { FetchError } from "../../utils/fetch.mjs";
7
7
  import { defineRpcHandler } from "../../utils/rpc.mjs";
8
+ import { sha256 } from "../../utils/index.mjs";
8
9
  const getUser = defineRpcHandler(
9
10
  (context) => {
10
11
  const { user } = context;
@@ -27,6 +28,9 @@ const fetchUser = defineRpcHandler(async ({ accessToken }, context) => {
27
28
  type: "idp"
28
29
  };
29
30
  }
31
+ if (user.email) {
32
+ user.emailHash = await sha256(user.email);
33
+ }
30
34
  user.orderSummary = user.orderSummary?.filter(
31
35
  ({ shopId: shopId2 }) => shopId2 === context.shopId
32
36
  );
@@ -180,6 +180,8 @@ export interface ShopUser {
180
180
  status?: ShopUserStatus;
181
181
  /** The user's title (e.g., Mr., Mrs.). */
182
182
  title?: string;
183
+ /** The user's email as `sha256` hash. */
184
+ emailHash?: string;
183
185
  /** Custom data associated with the user. */
184
186
  customData?: {
185
187
  memberRoles?: MemberRole[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-core",
3
- "version": "8.50.0",
3
+ "version": "8.51.0",
4
4
  "description": "Collection of essential utilities to work with the Storefront API",
5
5
  "author": "SCAYLE Commerce Engine",
6
6
  "license": "MIT",