@stream-io/node-sdk 0.7.1 → 0.7.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/README.md +1 -0
- package/dist/index.cjs.js +47 -18
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.mjs +47 -18
- 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 +15 -21
- 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 +2 -15
- package/src/gen/models/index.ts +21 -31
- package/src/types.ts +2 -1
- package/src/utils/create-token.ts +1 -1
package/dist/index.es.mjs
CHANGED
|
@@ -182,12 +182,6 @@ 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) => {
|
|
191
185
|
const typeMappings = {
|
|
192
186
|
cutoff_time: { type: 'DatetimeType', isSingle: true },
|
|
193
187
|
};
|
|
@@ -1431,10 +1425,7 @@ decoders.FeedGroupResponse = (input) => {
|
|
|
1431
1425
|
const typeMappings = {
|
|
1432
1426
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
1433
1427
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1434
|
-
activity_selectors: {
|
|
1435
|
-
type: 'ActivitySelectorConfigResponse',
|
|
1436
|
-
isSingle: false,
|
|
1437
|
-
},
|
|
1428
|
+
activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
|
|
1438
1429
|
};
|
|
1439
1430
|
return decode(typeMappings, input);
|
|
1440
1431
|
};
|
|
@@ -1498,10 +1489,7 @@ decoders.FeedUpdatedEvent = (input) => {
|
|
|
1498
1489
|
decoders.FeedViewResponse = (input) => {
|
|
1499
1490
|
const typeMappings = {
|
|
1500
1491
|
last_used_at: { type: 'DatetimeType', isSingle: true },
|
|
1501
|
-
activity_selectors: {
|
|
1502
|
-
type: 'ActivitySelectorConfigResponse',
|
|
1503
|
-
isSingle: false,
|
|
1504
|
-
},
|
|
1492
|
+
activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
|
|
1505
1493
|
};
|
|
1506
1494
|
return decode(typeMappings, input);
|
|
1507
1495
|
};
|
|
@@ -4954,8 +4942,11 @@ class CallApi {
|
|
|
4954
4942
|
}
|
|
4955
4943
|
|
|
4956
4944
|
class StreamCall extends CallApi {
|
|
4957
|
-
constructor() {
|
|
4958
|
-
super(
|
|
4945
|
+
constructor(videoApi, type, id, streamClient) {
|
|
4946
|
+
super(videoApi, type, id);
|
|
4947
|
+
this.type = type;
|
|
4948
|
+
this.id = id;
|
|
4949
|
+
this.streamClient = streamClient;
|
|
4959
4950
|
this.create = (request) => this.getOrCreate(request);
|
|
4960
4951
|
this.queryMembers = (request) => {
|
|
4961
4952
|
return this.videoApi.queryCallMembers({
|
|
@@ -4964,6 +4955,33 @@ class StreamCall extends CallApi {
|
|
|
4964
4955
|
...(request ?? {}),
|
|
4965
4956
|
});
|
|
4966
4957
|
};
|
|
4958
|
+
this.getOrCreate = async (request) => {
|
|
4959
|
+
const response = await super.getOrCreate(request);
|
|
4960
|
+
this.data = response.call;
|
|
4961
|
+
return response;
|
|
4962
|
+
};
|
|
4963
|
+
this.get = async () => {
|
|
4964
|
+
const response = await super.get();
|
|
4965
|
+
this.data = response.call;
|
|
4966
|
+
return response;
|
|
4967
|
+
};
|
|
4968
|
+
this.createSRTCredentials = (userID) => {
|
|
4969
|
+
if (!this.data) {
|
|
4970
|
+
throw new Error('Object is not initialized, call get() or getOrCreate() first');
|
|
4971
|
+
}
|
|
4972
|
+
const token = this.streamClient.generatePermanentUserToken({
|
|
4973
|
+
user_id: userID,
|
|
4974
|
+
});
|
|
4975
|
+
const segments = token.split('.');
|
|
4976
|
+
if (segments.length !== 3) {
|
|
4977
|
+
throw new Error('Invalid token format');
|
|
4978
|
+
}
|
|
4979
|
+
return {
|
|
4980
|
+
address: this.data.ingress.srt.address
|
|
4981
|
+
.replace('{passphrase}', segments[2])
|
|
4982
|
+
.replace('{token}', token),
|
|
4983
|
+
};
|
|
4984
|
+
};
|
|
4967
4985
|
}
|
|
4968
4986
|
get cid() {
|
|
4969
4987
|
return `${this.type}:${this.id}`;
|
|
@@ -4974,7 +4992,7 @@ class StreamVideoClient extends VideoApi {
|
|
|
4974
4992
|
constructor({ streamClient, apiClient, }) {
|
|
4975
4993
|
super(apiClient);
|
|
4976
4994
|
this.call = (type, id) => {
|
|
4977
|
-
return new StreamCall(this, type, id);
|
|
4995
|
+
return new StreamCall(this, type, id, this.streamClient);
|
|
4978
4996
|
};
|
|
4979
4997
|
this.connectOpenAi = async (options) => {
|
|
4980
4998
|
let doCreateRealtimeClient;
|
|
@@ -6619,7 +6637,7 @@ class ApiClient {
|
|
|
6619
6637
|
const headers = {
|
|
6620
6638
|
Authorization: this.apiConfig.token,
|
|
6621
6639
|
'stream-auth-type': 'jwt',
|
|
6622
|
-
'X-Stream-Client': 'stream-node-' + "0.7.
|
|
6640
|
+
'X-Stream-Client': 'stream-node-' + "0.7.3",
|
|
6623
6641
|
'Accept-Encoding': 'gzip',
|
|
6624
6642
|
'x-client-request-id': clientRequestId,
|
|
6625
6643
|
};
|
|
@@ -7808,6 +7826,17 @@ class StreamClient extends CommonApi {
|
|
|
7808
7826
|
payload.exp = payload.exp ?? payload.iat + validityInSeconds;
|
|
7809
7827
|
return JWTUserToken(this.secret, payload);
|
|
7810
7828
|
};
|
|
7829
|
+
/**
|
|
7830
|
+
*
|
|
7831
|
+
* @param payload
|
|
7832
|
+
* - user_id - the id of the user the token is for
|
|
7833
|
+
* - iat - issued at date of the token, unix timestamp in seconds, by default it's now
|
|
7834
|
+
*/
|
|
7835
|
+
this.generatePermanentUserToken = (payload) => {
|
|
7836
|
+
const defaultIat = Math.floor((Date.now() - 1000) / 1000);
|
|
7837
|
+
payload.iat = payload.iat ?? defaultIat;
|
|
7838
|
+
return JWTUserToken(this.secret, payload);
|
|
7839
|
+
};
|
|
7811
7840
|
/**
|
|
7812
7841
|
*
|
|
7813
7842
|
* @param payload
|