@streamlayer/sdk-web-core 0.17.1 → 0.17.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.
|
@@ -36,11 +36,11 @@ export declare class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
36
36
|
* -
|
|
37
37
|
* - If no one of the above is true, then logout.
|
|
38
38
|
*/
|
|
39
|
-
reLogin: () => Promise<
|
|
39
|
+
reLogin: () => Promise<void> | undefined;
|
|
40
40
|
/**
|
|
41
41
|
* Write token to the Transport and UserStore
|
|
42
42
|
*/
|
|
43
|
-
private
|
|
43
|
+
private saveUser;
|
|
44
44
|
/**
|
|
45
45
|
* Add interceptor to the Transport to handle 401 and 403 errors.
|
|
46
46
|
* If the user is logged in (auth header is set), then make a soft logout.
|
package/lib/auth/bypass/index.js
CHANGED
|
@@ -32,11 +32,12 @@ export class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
32
32
|
this.$coreStore.getValues().userKey.setValue(userKey);
|
|
33
33
|
const user = await this.bypassLogin({ schema, userKey, init: false });
|
|
34
34
|
const token = user.meta?.jwt;
|
|
35
|
-
|
|
35
|
+
const userId = user.data?.id;
|
|
36
|
+
if (!token || !userId) {
|
|
36
37
|
throw new Error('internal: token missing');
|
|
37
38
|
}
|
|
38
39
|
this.$coreStore.getValues().user.getStore().mutate(user);
|
|
39
|
-
this.
|
|
40
|
+
this.saveUser(token, userId);
|
|
40
41
|
return token;
|
|
41
42
|
};
|
|
42
43
|
isAuthenticated = () => {
|
|
@@ -49,7 +50,7 @@ export class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
49
50
|
this.$coreStore.getValues().user.setValue();
|
|
50
51
|
this.$coreStore.getValues().userKey.setValue();
|
|
51
52
|
this.$coreStore.getValues().userToken.setValue();
|
|
52
|
-
this.transport.setAuth('');
|
|
53
|
+
this.transport.setAuth('', '');
|
|
53
54
|
const storage = new UserStorage();
|
|
54
55
|
storage.clear();
|
|
55
56
|
};
|
|
@@ -61,7 +62,7 @@ export class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
61
62
|
const storage = new UserStorage();
|
|
62
63
|
this.$coreStore.getValues().user.setValue();
|
|
63
64
|
this.$coreStore.getValues().userToken.setValue();
|
|
64
|
-
this.transport.setAuth('');
|
|
65
|
+
this.transport.setAuth('', '');
|
|
65
66
|
storage.setToken('');
|
|
66
67
|
void this.reLogin();
|
|
67
68
|
};
|
|
@@ -79,8 +80,14 @@ export class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
79
80
|
this.$coreStore.getValues().userKey.setValue(prevUserExternalToken);
|
|
80
81
|
this.$coreStore.getValues().userToken.setValue(prevUserToken);
|
|
81
82
|
if (prevUserToken) {
|
|
82
|
-
this.
|
|
83
|
-
return this.me()
|
|
83
|
+
this.saveUser(prevUserToken, '');
|
|
84
|
+
return this.me().then((user) => {
|
|
85
|
+
console.log('user', user);
|
|
86
|
+
if (user?.id) {
|
|
87
|
+
const userId = user.id;
|
|
88
|
+
this.saveUser(prevUserToken, userId);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
84
91
|
}
|
|
85
92
|
if (prevUserExternalToken && !prevUserToken) {
|
|
86
93
|
const prevUserSchema = storage.getSchema();
|
|
@@ -95,8 +102,8 @@ export class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
95
102
|
/**
|
|
96
103
|
* Write token to the Transport and UserStore
|
|
97
104
|
*/
|
|
98
|
-
|
|
99
|
-
this.transport.setAuth(token);
|
|
105
|
+
saveUser = (token, userId) => {
|
|
106
|
+
this.transport.setAuth(token, userId);
|
|
100
107
|
this.$coreStore.getValues().userToken.setValue(token);
|
|
101
108
|
const storage = new UserStorage();
|
|
102
109
|
storage.setToken(token);
|
package/package.json
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
"@nanostores/query": "^0.2.8",
|
|
8
8
|
"nanostores": "^0.9.5",
|
|
9
9
|
"@streamlayer/sl-eslib": "^5.53.5",
|
|
10
|
-
"@streamlayer/sdk-web-interfaces": "^0.18.
|
|
10
|
+
"@streamlayer/sdk-web-interfaces": "^0.18.10",
|
|
11
11
|
"@streamlayer/sdk-web-storage": "^0.3.10",
|
|
12
12
|
"@streamlayer/sdk-web-api": "^0.0.1",
|
|
13
|
-
"@streamlayer/sdk-web-types": "^0.
|
|
13
|
+
"@streamlayer/sdk-web-types": "^0.18.0"
|
|
14
14
|
},
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"default": "./lib/auth/index.js"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
|
-
"version": "0.17.
|
|
42
|
+
"version": "0.17.3",
|
|
43
43
|
"type": "module",
|
|
44
44
|
"main": "./lib/index.js",
|
|
45
45
|
"module": "./lib/index.js",
|