@stream-io/node-sdk 0.7.0 → 0.7.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/README.md +1 -0
- package/dist/index.cjs.js +59 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.mjs +59 -6
- package/dist/index.es.mjs.map +1 -1
- package/dist/src/StreamCall.d.ts +13 -1
- package/dist/src/StreamClient.d.ts +10 -0
- package/dist/src/gen/models/index.d.ts +9 -2
- package/dist/src/types.d.ts +2 -1
- package/dist/src/utils/create-token.d.ts +1 -1
- package/package.json +1 -1
- package/src/StreamCall.ts +56 -1
- package/src/StreamClient.ts +18 -0
- package/src/StreamVideoClient.ts +1 -1
- package/src/gen/model-decoders/decoders.ts +15 -2
- package/src/gen/models/index.ts +14 -2
- package/src/types.ts +2 -1
- package/src/utils/create-token.ts +1 -1
package/dist/index.es.mjs
CHANGED
|
@@ -182,6 +182,12 @@ decoders.ActivityResponse = (input) => {
|
|
|
182
182
|
return decode(typeMappings, input);
|
|
183
183
|
};
|
|
184
184
|
decoders.ActivitySelectorConfig = (input) => {
|
|
185
|
+
const typeMappings = {
|
|
186
|
+
cutoff_time: { type: 'StringType', isSingle: true },
|
|
187
|
+
};
|
|
188
|
+
return decode(typeMappings, input);
|
|
189
|
+
};
|
|
190
|
+
decoders.ActivitySelectorConfigResponse = (input) => {
|
|
185
191
|
const typeMappings = {
|
|
186
192
|
cutoff_time: { type: 'DatetimeType', isSingle: true },
|
|
187
193
|
};
|
|
@@ -1425,7 +1431,10 @@ decoders.FeedGroupResponse = (input) => {
|
|
|
1425
1431
|
const typeMappings = {
|
|
1426
1432
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
1427
1433
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1428
|
-
activity_selectors: {
|
|
1434
|
+
activity_selectors: {
|
|
1435
|
+
type: 'ActivitySelectorConfigResponse',
|
|
1436
|
+
isSingle: false,
|
|
1437
|
+
},
|
|
1429
1438
|
};
|
|
1430
1439
|
return decode(typeMappings, input);
|
|
1431
1440
|
};
|
|
@@ -1489,7 +1498,10 @@ decoders.FeedUpdatedEvent = (input) => {
|
|
|
1489
1498
|
decoders.FeedViewResponse = (input) => {
|
|
1490
1499
|
const typeMappings = {
|
|
1491
1500
|
last_used_at: { type: 'DatetimeType', isSingle: true },
|
|
1492
|
-
activity_selectors: {
|
|
1501
|
+
activity_selectors: {
|
|
1502
|
+
type: 'ActivitySelectorConfigResponse',
|
|
1503
|
+
isSingle: false,
|
|
1504
|
+
},
|
|
1493
1505
|
};
|
|
1494
1506
|
return decode(typeMappings, input);
|
|
1495
1507
|
};
|
|
@@ -4942,8 +4954,11 @@ class CallApi {
|
|
|
4942
4954
|
}
|
|
4943
4955
|
|
|
4944
4956
|
class StreamCall extends CallApi {
|
|
4945
|
-
constructor() {
|
|
4946
|
-
super(
|
|
4957
|
+
constructor(videoApi, type, id, streamClient) {
|
|
4958
|
+
super(videoApi, type, id);
|
|
4959
|
+
this.type = type;
|
|
4960
|
+
this.id = id;
|
|
4961
|
+
this.streamClient = streamClient;
|
|
4947
4962
|
this.create = (request) => this.getOrCreate(request);
|
|
4948
4963
|
this.queryMembers = (request) => {
|
|
4949
4964
|
return this.videoApi.queryCallMembers({
|
|
@@ -4952,6 +4967,33 @@ class StreamCall extends CallApi {
|
|
|
4952
4967
|
...(request ?? {}),
|
|
4953
4968
|
});
|
|
4954
4969
|
};
|
|
4970
|
+
this.getOrCreate = async (request) => {
|
|
4971
|
+
const response = await super.getOrCreate(request);
|
|
4972
|
+
this.data = response.call;
|
|
4973
|
+
return response;
|
|
4974
|
+
};
|
|
4975
|
+
this.get = async () => {
|
|
4976
|
+
const response = await super.get();
|
|
4977
|
+
this.data = response.call;
|
|
4978
|
+
return response;
|
|
4979
|
+
};
|
|
4980
|
+
this.createSRTCredetials = (userID) => {
|
|
4981
|
+
if (!this.data) {
|
|
4982
|
+
throw new Error('Object is not initialized, call get() or getOrCreate() first');
|
|
4983
|
+
}
|
|
4984
|
+
const token = this.streamClient.generatePermanentUserToken({
|
|
4985
|
+
user_id: userID,
|
|
4986
|
+
});
|
|
4987
|
+
const segments = token.split('.');
|
|
4988
|
+
if (segments.length !== 3) {
|
|
4989
|
+
throw new Error('Invalid token format');
|
|
4990
|
+
}
|
|
4991
|
+
return {
|
|
4992
|
+
address: this.data.ingress.srt.address
|
|
4993
|
+
.replace('{passphrase}', segments[2])
|
|
4994
|
+
.replace('{token}', token),
|
|
4995
|
+
};
|
|
4996
|
+
};
|
|
4955
4997
|
}
|
|
4956
4998
|
get cid() {
|
|
4957
4999
|
return `${this.type}:${this.id}`;
|
|
@@ -4962,7 +5004,7 @@ class StreamVideoClient extends VideoApi {
|
|
|
4962
5004
|
constructor({ streamClient, apiClient, }) {
|
|
4963
5005
|
super(apiClient);
|
|
4964
5006
|
this.call = (type, id) => {
|
|
4965
|
-
return new StreamCall(this, type, id);
|
|
5007
|
+
return new StreamCall(this, type, id, this.streamClient);
|
|
4966
5008
|
};
|
|
4967
5009
|
this.connectOpenAi = async (options) => {
|
|
4968
5010
|
let doCreateRealtimeClient;
|
|
@@ -6607,7 +6649,7 @@ class ApiClient {
|
|
|
6607
6649
|
const headers = {
|
|
6608
6650
|
Authorization: this.apiConfig.token,
|
|
6609
6651
|
'stream-auth-type': 'jwt',
|
|
6610
|
-
'X-Stream-Client': 'stream-node-' + "0.7.
|
|
6652
|
+
'X-Stream-Client': 'stream-node-' + "0.7.2",
|
|
6611
6653
|
'Accept-Encoding': 'gzip',
|
|
6612
6654
|
'x-client-request-id': clientRequestId,
|
|
6613
6655
|
};
|
|
@@ -7796,6 +7838,17 @@ class StreamClient extends CommonApi {
|
|
|
7796
7838
|
payload.exp = payload.exp ?? payload.iat + validityInSeconds;
|
|
7797
7839
|
return JWTUserToken(this.secret, payload);
|
|
7798
7840
|
};
|
|
7841
|
+
/**
|
|
7842
|
+
*
|
|
7843
|
+
* @param payload
|
|
7844
|
+
* - user_id - the id of the user the token is for
|
|
7845
|
+
* - iat - issued at date of the token, unix timestamp in seconds, by default it's now
|
|
7846
|
+
*/
|
|
7847
|
+
this.generatePermanentUserToken = (payload) => {
|
|
7848
|
+
const defaultIat = Math.floor((Date.now() - 1000) / 1000);
|
|
7849
|
+
payload.iat = payload.iat ?? defaultIat;
|
|
7850
|
+
return JWTUserToken(this.secret, payload);
|
|
7851
|
+
};
|
|
7799
7852
|
/**
|
|
7800
7853
|
*
|
|
7801
7854
|
* @param payload
|