@streamlayer/sdk-web-core 0.14.2 → 0.15.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/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +11 -7
- package/package.json +1 -1
package/lib/auth/index.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ declare module '@streamlayer/sdk-web-interfaces' {
|
|
|
12
12
|
auth: BypassAuth;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
export declare const bypass: (instance: StreamLayerContext, opts: unknown, done: () => void) =>
|
|
15
|
+
export declare const bypass: (instance: StreamLayerContext, opts: unknown, done: () => void) => void;
|
package/lib/auth/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import { CoreStatus } from '../store/store';
|
|
1
2
|
import { UserStorage } from '../storage';
|
|
2
3
|
import { BypassAuth } from './bypass';
|
|
3
|
-
export const bypass =
|
|
4
|
+
export const bypass = (instance, opts, done) => {
|
|
4
5
|
instance.auth = new BypassAuth(instance.store, instance.transport);
|
|
5
6
|
const storage = new UserStorage();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
instance.stores.status.listen(async (status) => {
|
|
8
|
+
if (status === CoreStatus.READY) {
|
|
9
|
+
const prevUserSchema = storage.getSchema();
|
|
10
|
+
const prevUserToken = storage.getToken();
|
|
11
|
+
if (prevUserSchema && prevUserToken) {
|
|
12
|
+
await instance.auth.login(prevUserSchema, prevUserToken);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
12
16
|
instance.sdk.authorizationBypass = async (schema, userKey) => {
|
|
13
17
|
await instance.auth.login(schema, userKey);
|
|
14
18
|
// ToDo: implement right cache user keys
|