@streamlayer/sdk-web-api 0.21.2 → 0.22.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/grpc/queries/user.js +1 -1
- package/lib/grpc/transport.js +12 -1
- package/package.json +3 -2
package/lib/grpc/queries/user.js
CHANGED
|
@@ -14,7 +14,7 @@ export const $user = ($userToken, transport) => {
|
|
|
14
14
|
};
|
|
15
15
|
export const bypassLogin = (transport) => {
|
|
16
16
|
const { client } = transport.createPromiseClient(Users, { method: 'bypassAuth' });
|
|
17
|
-
// inviterKey to do add to payload
|
|
17
|
+
// inviterKey to do add to payload, ONLY after implement it on backend!
|
|
18
18
|
return async ({ userKey, schema, init, inviterKey }) => {
|
|
19
19
|
const res = await client.bypassAuth({ userKey, schema, init });
|
|
20
20
|
if (res.meta) {
|
package/lib/grpc/transport.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { MapStore, createMapStore } from '@streamlayer/sdk-web-interfaces';
|
|
2
|
+
import { nanoid } from 'nanoid';
|
|
2
3
|
import { createRouterTransport, createPromiseClient, } from '@connectrpc/connect';
|
|
3
4
|
import { createGrpcWebTransport } from '@connectrpc/connect-web';
|
|
4
5
|
import { nanoquery } from '@nanostores/query';
|
|
5
6
|
import { __GRPC_DEVTOOLS_EXTENSION__ } from '../utils/devtools';
|
|
6
7
|
import { ServerStreamSubscription } from './subscription';
|
|
8
|
+
// generate random device id and store it in local storage
|
|
9
|
+
const getDeviceId = () => {
|
|
10
|
+
const deviceId = localStorage.getItem('sl-device-id');
|
|
11
|
+
if (deviceId) {
|
|
12
|
+
return deviceId;
|
|
13
|
+
}
|
|
14
|
+
const newDeviceId = nanoid();
|
|
15
|
+
localStorage.setItem('sl-device-id', newDeviceId);
|
|
16
|
+
return newDeviceId;
|
|
17
|
+
};
|
|
7
18
|
/**
|
|
8
19
|
* transport wrapper, initialize grpc transport, store headers and connect interceptors
|
|
9
20
|
*/
|
|
@@ -27,7 +38,7 @@ export class Transport {
|
|
|
27
38
|
constructor(host) {
|
|
28
39
|
this.host = host;
|
|
29
40
|
this.$headers = new MapStore(createMapStore({
|
|
30
|
-
['sl-device-id']:
|
|
41
|
+
['sl-device-id']: getDeviceId(),
|
|
31
42
|
}), 'transport:headers');
|
|
32
43
|
this.initInterceptors();
|
|
33
44
|
this.clients = new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamlayer/sdk-web-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@streamlayer/sdk-web-interfaces": "^0.20.
|
|
24
|
+
"@streamlayer/sdk-web-interfaces": "^0.20.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@bufbuild/protobuf": "^1.6.0",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@nanostores/query": "^0.2.9",
|
|
31
31
|
"@streamlayer/sl-eslib": "^5.67.0",
|
|
32
32
|
"@swc/helpers": "^0.5.3",
|
|
33
|
+
"nanoid": "3.3.7",
|
|
33
34
|
"nanostores": "^0.9.5",
|
|
34
35
|
"tslib": "^2.6.2"
|
|
35
36
|
}
|