@streamlayer/sdk-web-core 0.19.0 → 0.20.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/bypass/index.d.ts +2 -2
- package/lib/auth/bypass/index.js +2 -1
- package/lib/deepLink/index.d.ts +10 -5
- package/lib/deepLink/index.js +15 -8
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +6 -6
|
@@ -13,7 +13,7 @@ export declare class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
13
13
|
private readonly transport;
|
|
14
14
|
private readonly bypassLogin;
|
|
15
15
|
constructor(store: CoreStore, transport: Transport, deepLink: DeepLinkContext);
|
|
16
|
-
me: () => Promise<
|
|
16
|
+
me: () => Promise<import("@streamlayer/sl-eslib/users/users_common_pb").User | undefined>;
|
|
17
17
|
/**
|
|
18
18
|
* Login user by token and schema.
|
|
19
19
|
* On success, save the user and update the token to the Transport, UserStore and cache.
|
|
@@ -21,7 +21,7 @@ export declare class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
21
21
|
* @param userKey - user token received from the host app.
|
|
22
22
|
*/
|
|
23
23
|
login: (schema: string, userKey: string) => Promise<string>;
|
|
24
|
-
isAuthenticated: () => Promise<
|
|
24
|
+
isAuthenticated: () => Promise<import("@streamlayer/sl-eslib/users/users_common_pb").User | undefined>;
|
|
25
25
|
/**
|
|
26
26
|
* Logout user. Clears the all user data from the store.
|
|
27
27
|
*/
|
package/lib/auth/bypass/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AbstractAuthenticationProvider } from '@streamlayer/sdk-web-interfaces';
|
|
2
2
|
import { queries } from '@streamlayer/sdk-web-api';
|
|
3
|
+
import { DEEP_LINK_USER_ID } from '../../deepLink';
|
|
3
4
|
import { UserStorage } from '../../storage';
|
|
4
5
|
/**
|
|
5
6
|
* An authorization service manages user access by providing login, logout,
|
|
@@ -32,7 +33,7 @@ export class BypassAuth extends AbstractAuthenticationProvider {
|
|
|
32
33
|
*/
|
|
33
34
|
login = async (schema, userKey) => {
|
|
34
35
|
this.$coreStore.getValues().userKey.setValue(userKey);
|
|
35
|
-
const inviterKey = this.deepLink.getDeepLinkData()?.
|
|
36
|
+
const inviterKey = this.deepLink.getDeepLinkData()?.[DEEP_LINK_USER_ID];
|
|
36
37
|
console.log('inviterKey', inviterKey);
|
|
37
38
|
const user = await this.bypassLogin({
|
|
38
39
|
schema,
|
package/lib/deepLink/index.d.ts
CHANGED
|
@@ -5,15 +5,14 @@ type DeepLinkContextData = {
|
|
|
5
5
|
hash?: string;
|
|
6
6
|
search?: string;
|
|
7
7
|
sessionId?: string;
|
|
8
|
-
data?:
|
|
9
|
-
friendId?: string;
|
|
10
|
-
};
|
|
8
|
+
data?: DeepLinkUrlParams;
|
|
11
9
|
};
|
|
10
|
+
export type DeepLinkCallback = (deepLinkData: DeepLinkContextData['data']) => void;
|
|
12
11
|
export interface DeepLinkContext {
|
|
13
12
|
$store: DeepLinkContextStore;
|
|
14
13
|
getDeepLinkData: () => DeepLinkContextData['data'];
|
|
15
14
|
deepLinkUsed: (inviterId: string) => void;
|
|
16
|
-
onDeepLinkHandlers: Set<
|
|
15
|
+
onDeepLinkHandlers: Set<DeepLinkCallback>;
|
|
17
16
|
}
|
|
18
17
|
export type DeepLinkContextStore = MapStore<DeepLinkContextData>;
|
|
19
18
|
declare module '@streamlayer/sdk-web-interfaces' {
|
|
@@ -21,7 +20,7 @@ declare module '@streamlayer/sdk-web-interfaces' {
|
|
|
21
20
|
deepLink: DeepLinkContext;
|
|
22
21
|
}
|
|
23
22
|
interface StreamLayerSDK {
|
|
24
|
-
onDeepLinkHandled: (cb:
|
|
23
|
+
onDeepLinkHandled: (cb: DeepLinkCallback) => void;
|
|
25
24
|
deepLinkHandled: () => void;
|
|
26
25
|
getInviterId: () => string | undefined;
|
|
27
26
|
}
|
|
@@ -29,6 +28,12 @@ declare module '@streamlayer/sdk-web-interfaces' {
|
|
|
29
28
|
export declare const DEEP_LINK_PREFIX = "sldl";
|
|
30
29
|
export declare const DEEP_LINK_USER_ID = "sldl_uid";
|
|
31
30
|
export declare const DEEP_LINK_EVENT_ID = "sldl_eid";
|
|
31
|
+
export declare const DEEP_LINK_EXTERNAL_EVENT_ID = "sldl_e_eid";
|
|
32
|
+
export type DeepLinkUrlParams = {
|
|
33
|
+
[DEEP_LINK_USER_ID]?: string;
|
|
34
|
+
[DEEP_LINK_EVENT_ID]?: string;
|
|
35
|
+
[DEEP_LINK_EXTERNAL_EVENT_ID]?: string;
|
|
36
|
+
};
|
|
32
37
|
/**
|
|
33
38
|
* Bypass authorization, used for login with external token.
|
|
34
39
|
* Automatically login user if SDK initialized and READY.
|
package/lib/deepLink/index.js
CHANGED
|
@@ -11,19 +11,25 @@ class DeepLinkContextStorage extends Storage {
|
|
|
11
11
|
export const DEEP_LINK_PREFIX = 'sldl';
|
|
12
12
|
export const DEEP_LINK_USER_ID = 'sldl_uid';
|
|
13
13
|
export const DEEP_LINK_EVENT_ID = 'sldl_eid';
|
|
14
|
+
export const DEEP_LINK_EXTERNAL_EVENT_ID = 'sldl_e_eid';
|
|
15
|
+
const ALLOWED_PARAMS = new Set([DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID, DEEP_LINK_EXTERNAL_EVENT_ID]);
|
|
16
|
+
const pickOnlyAllowedParams = (params) => {
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const [key, value] of params) {
|
|
19
|
+
if (ALLOWED_PARAMS.has(key)) {
|
|
20
|
+
result[key] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
14
25
|
const parseDeepLinkData = ({ hash, search }) => {
|
|
15
26
|
if (hash && hash.includes(DEEP_LINK_PREFIX)) {
|
|
16
27
|
const params = new URLSearchParams(hash.substr(1));
|
|
17
|
-
|
|
18
|
-
if (key === DEEP_LINK_USER_ID) {
|
|
19
|
-
return { friendId: value };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
28
|
+
return pickOnlyAllowedParams(params);
|
|
23
29
|
}
|
|
24
30
|
if (search && search.includes(DEEP_LINK_PREFIX)) {
|
|
25
31
|
const params = new URLSearchParams(search);
|
|
26
|
-
return
|
|
32
|
+
return pickOnlyAllowedParams(params);
|
|
27
33
|
}
|
|
28
34
|
return null;
|
|
29
35
|
};
|
|
@@ -81,9 +87,10 @@ export const deepLink = (instance, opts, done) => {
|
|
|
81
87
|
instance.sdk.deepLinkHandled = () => {
|
|
82
88
|
storage.del('sl-inviter-id');
|
|
83
89
|
instance.deepLink.$store.setValue('processed', true);
|
|
90
|
+
const { data } = instance.deepLink.$store.getValues();
|
|
84
91
|
for (const handler of instance.deepLink.onDeepLinkHandlers) {
|
|
85
92
|
try {
|
|
86
|
-
handler();
|
|
93
|
+
handler(data);
|
|
87
94
|
}
|
|
88
95
|
catch (err) {
|
|
89
96
|
console.error(err);
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StreamLayerContext } from '@streamlayer/sdk-web-interfaces';
|
|
2
2
|
export { bypass, storage } from './auth';
|
|
3
3
|
export { store } from './store';
|
|
4
|
-
export { deepLink, DEEP_LINK_PREFIX, DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID } from './deepLink';
|
|
4
|
+
export { deepLink, type DeepLinkUrlParams, type DeepLinkCallback, DEEP_LINK_PREFIX, DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID, DEEP_LINK_EXTERNAL_EVENT_ID, } from './deepLink';
|
|
5
5
|
import './store';
|
|
6
6
|
import './auth';
|
|
7
7
|
declare module '@streamlayer/sdk-web-interfaces' {
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CoreStatus } from './store/store';
|
|
2
2
|
export { bypass, storage } from './auth';
|
|
3
3
|
export { store } from './store';
|
|
4
|
-
export { deepLink, DEEP_LINK_PREFIX, DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID } from './deepLink';
|
|
4
|
+
export { deepLink, DEEP_LINK_PREFIX, DEEP_LINK_USER_ID, DEEP_LINK_EVENT_ID, DEEP_LINK_EXTERNAL_EVENT_ID, } from './deepLink';
|
|
5
5
|
import './store';
|
|
6
6
|
import './auth';
|
|
7
7
|
/**
|
package/package.json
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
},
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@nanostores/query": "^0.2.8",
|
|
8
|
-
"@streamlayer/sl-eslib": "^5.
|
|
8
|
+
"@streamlayer/sl-eslib": "^5.67.0",
|
|
9
9
|
"nanostores": "^0.9.5",
|
|
10
|
-
"@streamlayer/sdk-web-api": "^0.21.
|
|
11
|
-
"@streamlayer/sdk-web-interfaces": "^0.20.
|
|
12
|
-
"@streamlayer/sdk-web-storage": "^0.4.
|
|
13
|
-
"@streamlayer/sdk-web-types": "^0.22.
|
|
10
|
+
"@streamlayer/sdk-web-api": "^0.21.1",
|
|
11
|
+
"@streamlayer/sdk-web-interfaces": "^0.20.3",
|
|
12
|
+
"@streamlayer/sdk-web-storage": "^0.4.1",
|
|
13
|
+
"@streamlayer/sdk-web-types": "^0.22.1"
|
|
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.
|
|
42
|
+
"version": "0.20.0",
|
|
43
43
|
"type": "module",
|
|
44
44
|
"main": "./lib/index.js",
|
|
45
45
|
"module": "./lib/index.js",
|