@scayle/storefront-core 7.41.1 → 7.41.3
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 +13 -0
- package/dist/rpc/methods/user.cjs +18 -9
- package/dist/rpc/methods/user.mjs +15 -9
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 7.41.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix lost session if user refresh is called while not logged in
|
|
8
|
+
|
|
9
|
+
## 7.41.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @aboutyou/backbone@16.1.2
|
|
15
|
+
|
|
3
16
|
## 7.41.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -33,24 +33,33 @@ const refreshUser = exports.refreshUser = async function refreshUser2(context) {
|
|
|
33
33
|
(0, _types.assertSession)(context);
|
|
34
34
|
const {
|
|
35
35
|
accessToken,
|
|
36
|
-
shopId
|
|
36
|
+
shopId,
|
|
37
|
+
user
|
|
37
38
|
} = context;
|
|
39
|
+
if (!accessToken) {
|
|
40
|
+
return {
|
|
41
|
+
user: void 0
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const isLoggedIn = !!user;
|
|
38
45
|
const client = new _customer.CustomerAPIClient(context);
|
|
39
46
|
try {
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
|
|
47
|
+
const user2 = await client.getMe(shopId);
|
|
48
|
+
if (!user2.authentication) {
|
|
49
|
+
user2.authentication = {
|
|
43
50
|
type: "idp"
|
|
44
51
|
};
|
|
45
52
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
context.updateUser(
|
|
53
|
+
user2.authentication.storefrontAccessToken = accessToken;
|
|
54
|
+
user2.loginShopId = shopId;
|
|
55
|
+
context.updateUser(user2);
|
|
49
56
|
return {
|
|
50
|
-
user
|
|
57
|
+
user: user2
|
|
51
58
|
};
|
|
52
59
|
} catch {
|
|
53
|
-
|
|
60
|
+
if (isLoggedIn) {
|
|
61
|
+
await context.destroySession();
|
|
62
|
+
}
|
|
54
63
|
return {
|
|
55
64
|
user: void 0
|
|
56
65
|
};
|
|
@@ -21,21 +21,27 @@ const fetchUser = async function fetchUser2(payload, context) {
|
|
|
21
21
|
};
|
|
22
22
|
const refreshUser = async function refreshUser2(context) {
|
|
23
23
|
assertSession(context);
|
|
24
|
-
const { accessToken, shopId } = context;
|
|
24
|
+
const { accessToken, shopId, user } = context;
|
|
25
|
+
if (!accessToken) {
|
|
26
|
+
return { user: void 0 };
|
|
27
|
+
}
|
|
28
|
+
const isLoggedIn = !!user;
|
|
25
29
|
const client = new CustomerAPIClient(context);
|
|
26
30
|
try {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
|
|
31
|
+
const user2 = await client.getMe(shopId);
|
|
32
|
+
if (!user2.authentication) {
|
|
33
|
+
user2.authentication = {
|
|
30
34
|
type: "idp"
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
context.updateUser(
|
|
36
|
-
return { user };
|
|
37
|
+
user2.authentication.storefrontAccessToken = accessToken;
|
|
38
|
+
user2.loginShopId = shopId;
|
|
39
|
+
context.updateUser(user2);
|
|
40
|
+
return { user: user2 };
|
|
37
41
|
} catch {
|
|
38
|
-
|
|
42
|
+
if (isLoggedIn) {
|
|
43
|
+
await context.destroySession();
|
|
44
|
+
}
|
|
39
45
|
return { user: void 0 };
|
|
40
46
|
}
|
|
41
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "7.41.
|
|
3
|
+
"version": "7.41.3",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@aboutyou/backbone": "16.1.
|
|
62
|
+
"@aboutyou/backbone": "16.1.2",
|
|
63
63
|
"crypto-js": "4.2.0",
|
|
64
64
|
"jose": "5.2.2",
|
|
65
65
|
"radash": "11.0.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@types/crypto-js": "4.2.2",
|
|
74
74
|
"@types/node": "20.11.19",
|
|
75
75
|
"@types/webpack-env": "1.18.4",
|
|
76
|
-
"@vitest/coverage-v8": "1.
|
|
76
|
+
"@vitest/coverage-v8": "1.3.0",
|
|
77
77
|
"dprint": "0.45.0",
|
|
78
78
|
"eslint": "8.56.0",
|
|
79
79
|
"eslint-formatter-gitlab": "5.1.0",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"typescript": "5.3.3",
|
|
84
84
|
"unbuild": "2.0.0",
|
|
85
85
|
"unstorage": "1.10.1",
|
|
86
|
-
"vitest": "1.
|
|
86
|
+
"vitest": "1.3.0"
|
|
87
87
|
},
|
|
88
88
|
"optionalDependencies": {
|
|
89
89
|
"redis": "4"
|