@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.es.js
CHANGED
|
@@ -8358,6 +8358,9 @@ class StreamCall {
|
|
|
8358
8358
|
this.getOrCreate = (videoGetOrCreateCallRequest) => {
|
|
8359
8359
|
return this.apiClient.getOrCreateCall(Object.assign(Object.assign({}, this.baseRequest), { videoGetOrCreateCallRequest: videoGetOrCreateCallRequest !== null && videoGetOrCreateCallRequest !== void 0 ? videoGetOrCreateCallRequest : {} }));
|
|
8360
8360
|
};
|
|
8361
|
+
this.getSessionStatistics = (request) => {
|
|
8362
|
+
return this.apiClient.getCallStats(Object.assign(Object.assign({}, this.baseRequest), request));
|
|
8363
|
+
};
|
|
8361
8364
|
this.create = (getOrCreateCallRequest) => {
|
|
8362
8365
|
return this.getOrCreate(getOrCreateCallRequest);
|
|
8363
8366
|
};
|
|
@@ -8443,6 +8446,11 @@ class StreamVideoClient {
|
|
|
8443
8446
|
videoQueryCallsRequest: request !== null && request !== void 0 ? request : {},
|
|
8444
8447
|
});
|
|
8445
8448
|
};
|
|
8449
|
+
this.queryCallStatistics = (videoQueryCallStatsRequest) => {
|
|
8450
|
+
return this.apiClient.queryCallStats({
|
|
8451
|
+
videoQueryCallStatsRequest: videoQueryCallStatsRequest !== null && videoQueryCallStatsRequest !== void 0 ? videoQueryCallStatsRequest : {},
|
|
8452
|
+
});
|
|
8453
|
+
};
|
|
8446
8454
|
this.createCallType = (videoCreateCallTypeRequest) => {
|
|
8447
8455
|
return this.apiClient.createCallType({
|
|
8448
8456
|
videoCreateCallTypeRequest,
|
|
@@ -8488,16 +8496,15 @@ class StreamVideoClient {
|
|
|
8488
8496
|
}
|
|
8489
8497
|
}
|
|
8490
8498
|
|
|
8491
|
-
function JWTUserToken(apiSecret,
|
|
8492
|
-
if (typeof userId !== 'string') {
|
|
8493
|
-
throw new TypeError('userId should be a string');
|
|
8494
|
-
}
|
|
8495
|
-
const payload = Object.assign({ user_id: userId }, extraData);
|
|
8499
|
+
function JWTUserToken(apiSecret, payload) {
|
|
8496
8500
|
// make sure we return a clear error when jwt is shimmed (ie. browser build)
|
|
8497
8501
|
if (jwt == null || jwt.sign == null) {
|
|
8498
8502
|
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.`);
|
|
8499
8503
|
}
|
|
8500
|
-
const opts = Object.assign({
|
|
8504
|
+
const opts = Object.assign({
|
|
8505
|
+
algorithm: 'HS256',
|
|
8506
|
+
noTimestamp: true,
|
|
8507
|
+
});
|
|
8501
8508
|
if (payload.iat) {
|
|
8502
8509
|
opts.noTimestamp = false;
|
|
8503
8510
|
}
|
|
@@ -8736,7 +8743,7 @@ class StreamClient {
|
|
|
8736
8743
|
? 'https://chat.stream-io-api.com'
|
|
8737
8744
|
: 'https://video.stream-io-api.com'),
|
|
8738
8745
|
headers: {
|
|
8739
|
-
'X-Stream-Client': 'stream-node-' + "0.2.
|
|
8746
|
+
'X-Stream-Client': 'stream-node-' + "0.2.3",
|
|
8740
8747
|
},
|
|
8741
8748
|
middleware: [
|
|
8742
8749
|
{
|
|
@@ -8864,18 +8871,16 @@ class StreamClient {
|
|
|
8864
8871
|
* @returns
|
|
8865
8872
|
*/
|
|
8866
8873
|
createToken(userID, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000), call_cids) {
|
|
8867
|
-
const
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
extra.iat = iat;
|
|
8873
|
-
}
|
|
8874
|
+
const payload = {
|
|
8875
|
+
user_id: userID,
|
|
8876
|
+
exp,
|
|
8877
|
+
iat,
|
|
8878
|
+
};
|
|
8874
8879
|
if (call_cids) {
|
|
8875
8880
|
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`);
|
|
8876
|
-
|
|
8881
|
+
payload.call_cids = call_cids;
|
|
8877
8882
|
}
|
|
8878
|
-
return JWTUserToken(this.secret,
|
|
8883
|
+
return JWTUserToken(this.secret, payload);
|
|
8879
8884
|
}
|
|
8880
8885
|
/**
|
|
8881
8886
|
*
|
|
@@ -8885,16 +8890,19 @@ class StreamClient {
|
|
|
8885
8890
|
* @param iat this is deprecated, the current date will be set internally
|
|
8886
8891
|
* @returns
|
|
8887
8892
|
*/
|
|
8888
|
-
createCallToken(
|
|
8889
|
-
const
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
8893
|
-
|
|
8894
|
-
|
|
8893
|
+
createCallToken(userIdOrObject, call_cids, exp = Math.round(new Date().getTime() / 1000) + 60 * 60, iat = Math.round(Date.now() / 1000)) {
|
|
8894
|
+
const payload = {
|
|
8895
|
+
exp,
|
|
8896
|
+
iat,
|
|
8897
|
+
call_cids,
|
|
8898
|
+
user_id: typeof userIdOrObject === 'string'
|
|
8899
|
+
? userIdOrObject
|
|
8900
|
+
: userIdOrObject.user_id,
|
|
8901
|
+
};
|
|
8902
|
+
if (typeof userIdOrObject === 'object' && userIdOrObject.role) {
|
|
8903
|
+
payload.role = userIdOrObject.role;
|
|
8895
8904
|
}
|
|
8896
|
-
|
|
8897
|
-
return JWTUserToken(this.secret, userID, extra);
|
|
8905
|
+
return JWTUserToken(this.secret, payload);
|
|
8898
8906
|
}
|
|
8899
8907
|
mapCustomDataAfterReceive(user) {
|
|
8900
8908
|
if (!user) {
|