@stream-io/node-sdk 0.2.1 → 0.2.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.
- package/dist/index.cjs.js +33 -25
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +33 -25
- package/dist/index.es.js.map +1 -1
- package/dist/src/StreamCall.d.ts +2 -1
- package/dist/src/StreamClient.d.ts +4 -1
- package/dist/src/StreamVideoClient.d.ts +2 -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 +5 -0
- package/src/StreamClient.ts +22 -23
- package/src/StreamVideoClient.ts +9 -0
- package/src/types.ts +14 -0
- package/src/utils/create-token.ts +5 -16
package/dist/index.cjs.js
CHANGED
|
@@ -8360,6 +8360,9 @@ class StreamCall {
|
|
|
8360
8360
|
this.getOrCreate = (videoGetOrCreateCallRequest) => {
|
|
8361
8361
|
return this.apiClient.getOrCreateCall(Object.assign(Object.assign({}, this.baseRequest), { videoGetOrCreateCallRequest: videoGetOrCreateCallRequest !== null && videoGetOrCreateCallRequest !== void 0 ? videoGetOrCreateCallRequest : {} }));
|
|
8362
8362
|
};
|
|
8363
|
+
this.getSessionStatistics = (request) => {
|
|
8364
|
+
return this.apiClient.getCallStats(Object.assign(Object.assign({}, this.baseRequest), request));
|
|
8365
|
+
};
|
|
8363
8366
|
this.create = (getOrCreateCallRequest) => {
|
|
8364
8367
|
return this.getOrCreate(getOrCreateCallRequest);
|
|
8365
8368
|
};
|
|
@@ -8445,6 +8448,11 @@ class StreamVideoClient {
|
|
|
8445
8448
|
videoQueryCallsRequest: request !== null && request !== void 0 ? request : {},
|
|
8446
8449
|
});
|
|
8447
8450
|
};
|
|
8451
|
+
this.queryCallStatistics = (videoQueryCallStatsRequest) => {
|
|
8452
|
+
return this.apiClient.queryCallStats({
|
|
8453
|
+
videoQueryCallStatsRequest: videoQueryCallStatsRequest !== null && videoQueryCallStatsRequest !== void 0 ? videoQueryCallStatsRequest : {},
|
|
8454
|
+
});
|
|
8455
|
+
};
|
|
8448
8456
|
this.createCallType = (videoCreateCallTypeRequest) => {
|
|
8449
8457
|
return this.apiClient.createCallType({
|
|
8450
8458
|
videoCreateCallTypeRequest,
|
|
@@ -8490,16 +8498,15 @@ class StreamVideoClient {
|
|
|
8490
8498
|
}
|
|
8491
8499
|
}
|
|
8492
8500
|
|
|
8493
|
-
function JWTUserToken(apiSecret,
|
|
8494
|
-
if (typeof userId !== 'string') {
|
|
8495
|
-
throw new TypeError('userId should be a string');
|
|
8496
|
-
}
|
|
8497
|
-
const payload = Object.assign({ user_id: userId }, extraData);
|
|
8501
|
+
function JWTUserToken(apiSecret, payload) {
|
|
8498
8502
|
// make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
8499
8503
|
if (jwt == null || jwt.sign == null) {
|
|
8500
8504
|
throw Error(`Unable to find jwt crypto, if you are getting this error is probably because you are trying to generate tokens on browser or React Native (or other environment where crypto functions are not available). Please Note: token should only be generated server-side.`);
|
|
8501
8505
|
}
|
|
8502
|
-
const opts = Object.assign({
|
|
8506
|
+
const opts = Object.assign({
|
|
8507
|
+
algorithm: 'HS256',
|
|
8508
|
+
noTimestamp: true,
|
|
8509
|
+
});
|
|
8503
8510
|
if (payload.iat) {
|
|
8504
8511
|
opts.noTimestamp = false;
|
|
8505
8512
|
}
|
|
@@ -8738,7 +8745,7 @@ class StreamClient {
|
|
|
8738
8745
|
? 'https://chat.stream-io-api.com'
|
|
8739
8746
|
: 'https://video.stream-io-api.com'),
|
|
8740
8747
|
headers: {
|
|
8741
|
-
'X-Stream-Client': 'stream-node-' + "0.2.
|
|
8748
|
+
'X-Stream-Client': 'stream-node-' + "0.2.3",
|
|
8742
8749
|
},
|
|
8743
8750
|
middleware: [
|
|
8744
8751
|
{
|
|
@@ -8866,18 +8873,16 @@ class StreamClient {
|
|
|
8866
8873
|
* @returns
|
|
8867
8874
|
*/
|
|
8868
8875
|
createToken(userID, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000), call_cids) {
|
|
8869
|
-
const
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
extra.iat = iat;
|
|
8875
|
-
}
|
|
8876
|
+
const payload = {
|
|
8877
|
+
user_id: userID,
|
|
8878
|
+
exp,
|
|
8879
|
+
iat,
|
|
8880
|
+
};
|
|
8876
8881
|
if (call_cids) {
|
|
8877
8882
|
console.warn(`Use createCallToken method for creating call tokens, the "call_cids" param will be removed from the createToken method with version 0.2.0`);
|
|
8878
|
-
|
|
8883
|
+
payload.call_cids = call_cids;
|
|
8879
8884
|
}
|
|
8880
|
-
return JWTUserToken(this.secret,
|
|
8885
|
+
return JWTUserToken(this.secret, payload);
|
|
8881
8886
|
}
|
|
8882
8887
|
/**
|
|
8883
8888
|
*
|
|
@@ -8887,16 +8892,19 @@ class StreamClient {
|
|
|
8887
8892
|
* @param iat this is deprecated, the current date will be set internally
|
|
8888
8893
|
* @returns
|
|
8889
8894
|
*/
|
|
8890
|
-
createCallToken(
|
|
8891
|
-
const
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8895
|
+
createCallToken(userIdOrObject, call_cids, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000)) {
|
|
8896
|
+
const payload = {
|
|
8897
|
+
exp,
|
|
8898
|
+
iat,
|
|
8899
|
+
call_cids,
|
|
8900
|
+
user_id: typeof userIdOrObject === 'string'
|
|
8901
|
+
? userIdOrObject
|
|
8902
|
+
: userIdOrObject.user_id,
|
|
8903
|
+
};
|
|
8904
|
+
if (typeof userIdOrObject === 'object' && userIdOrObject.role) {
|
|
8905
|
+
payload.role = userIdOrObject.role;
|
|
8897
8906
|
}
|
|
8898
|
-
|
|
8899
|
-
return JWTUserToken(this.secret, userID, extra);
|
|
8907
|
+
return JWTUserToken(this.secret, payload);
|
|
8900
8908
|
}
|
|
8901
8909
|
mapCustomDataAfterReceive(user) {
|
|
8902
8910
|
if (!user) {
|