@stream-io/node-sdk 0.2.0 → 0.2.2
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/dist/index.cjs.js +32 -32
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +32 -32
- package/dist/index.es.js.map +1 -1
- package/dist/src/StreamCall.d.ts +2 -2
- package/dist/src/StreamClient.d.ts +4 -1
- package/dist/src/gen/video/apis/ProductvideoApi.d.ts +5 -5
- package/dist/src/gen/video/models/index.d.ts +91 -6
- package/dist/src/gen/video/runtime.d.ts +1 -1
- package/dist/src/types.d.ts +12 -0
- package/dist/src/utils/create-token.d.ts +6 -1
- package/package.json +1 -1
- package/src/StreamCall.ts +3 -2
- package/src/StreamClient.ts +22 -23
- package/src/gen/video/apis/ProductvideoApi.ts +9 -9
- package/src/gen/video/models/index.ts +91 -6
- package/src/gen/video/runtime.ts +1 -1
- package/src/types.ts +14 -0
- package/src/utils/create-token.ts +5 -16
|
@@ -2,19 +2,8 @@ import jwt, { Secret, SignOptions } from 'jsonwebtoken';
|
|
|
2
2
|
|
|
3
3
|
export function JWTUserToken(
|
|
4
4
|
apiSecret: Secret,
|
|
5
|
-
|
|
6
|
-
extraData = {},
|
|
7
|
-
jwtOptions: SignOptions = {},
|
|
5
|
+
payload: { user_id: string; exp: number; iat: number; call_cids?: string[] },
|
|
8
6
|
) {
|
|
9
|
-
if (typeof userId !== 'string') {
|
|
10
|
-
throw new TypeError('userId should be a string');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const payload: { user_id: string } & any = {
|
|
14
|
-
user_id: userId,
|
|
15
|
-
...extraData,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
7
|
// make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
19
8
|
if (jwt == null || jwt.sign == null) {
|
|
20
9
|
throw Error(
|
|
@@ -22,10 +11,10 @@ export function JWTUserToken(
|
|
|
22
11
|
);
|
|
23
12
|
}
|
|
24
13
|
|
|
25
|
-
const opts: SignOptions = Object.assign(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
14
|
+
const opts: SignOptions = Object.assign({
|
|
15
|
+
algorithm: 'HS256',
|
|
16
|
+
noTimestamp: true,
|
|
17
|
+
});
|
|
29
18
|
|
|
30
19
|
if (payload.iat) {
|
|
31
20
|
opts.noTimestamp = false;
|