@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/README.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -201,12 +201,6 @@ decoders.ActivityResponse = (input) => {
|
|
|
201
201
|
return decode(typeMappings, input);
|
|
202
202
|
};
|
|
203
203
|
decoders.ActivitySelectorConfig = (input) => {
|
|
204
|
-
const typeMappings = {
|
|
205
|
-
cutoff_time: { type: 'StringType', isSingle: true },
|
|
206
|
-
};
|
|
207
|
-
return decode(typeMappings, input);
|
|
208
|
-
};
|
|
209
|
-
decoders.ActivitySelectorConfigResponse = (input) => {
|
|
210
204
|
const typeMappings = {
|
|
211
205
|
cutoff_time: { type: 'DatetimeType', isSingle: true },
|
|
212
206
|
};
|
|
@@ -1450,10 +1444,7 @@ decoders.FeedGroupResponse = (input) => {
|
|
|
1450
1444
|
const typeMappings = {
|
|
1451
1445
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
1452
1446
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1453
|
-
activity_selectors: {
|
|
1454
|
-
type: 'ActivitySelectorConfigResponse',
|
|
1455
|
-
isSingle: false,
|
|
1456
|
-
},
|
|
1447
|
+
activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
|
|
1457
1448
|
};
|
|
1458
1449
|
return decode(typeMappings, input);
|
|
1459
1450
|
};
|
|
@@ -1517,10 +1508,7 @@ decoders.FeedUpdatedEvent = (input) => {
|
|
|
1517
1508
|
decoders.FeedViewResponse = (input) => {
|
|
1518
1509
|
const typeMappings = {
|
|
1519
1510
|
last_used_at: { type: 'DatetimeType', isSingle: true },
|
|
1520
|
-
activity_selectors: {
|
|
1521
|
-
type: 'ActivitySelectorConfigResponse',
|
|
1522
|
-
isSingle: false,
|
|
1523
|
-
},
|
|
1511
|
+
activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
|
|
1524
1512
|
};
|
|
1525
1513
|
return decode(typeMappings, input);
|
|
1526
1514
|
};
|
|
@@ -4973,8 +4961,11 @@ class CallApi {
|
|
|
4973
4961
|
}
|
|
4974
4962
|
|
|
4975
4963
|
class StreamCall extends CallApi {
|
|
4976
|
-
constructor() {
|
|
4977
|
-
super(
|
|
4964
|
+
constructor(videoApi, type, id, streamClient) {
|
|
4965
|
+
super(videoApi, type, id);
|
|
4966
|
+
this.type = type;
|
|
4967
|
+
this.id = id;
|
|
4968
|
+
this.streamClient = streamClient;
|
|
4978
4969
|
this.create = (request) => this.getOrCreate(request);
|
|
4979
4970
|
this.queryMembers = (request) => {
|
|
4980
4971
|
return this.videoApi.queryCallMembers({
|
|
@@ -4983,6 +4974,33 @@ class StreamCall extends CallApi {
|
|
|
4983
4974
|
...(request ?? {}),
|
|
4984
4975
|
});
|
|
4985
4976
|
};
|
|
4977
|
+
this.getOrCreate = async (request) => {
|
|
4978
|
+
const response = await super.getOrCreate(request);
|
|
4979
|
+
this.data = response.call;
|
|
4980
|
+
return response;
|
|
4981
|
+
};
|
|
4982
|
+
this.get = async () => {
|
|
4983
|
+
const response = await super.get();
|
|
4984
|
+
this.data = response.call;
|
|
4985
|
+
return response;
|
|
4986
|
+
};
|
|
4987
|
+
this.createSRTCredentials = (userID) => {
|
|
4988
|
+
if (!this.data) {
|
|
4989
|
+
throw new Error('Object is not initialized, call get() or getOrCreate() first');
|
|
4990
|
+
}
|
|
4991
|
+
const token = this.streamClient.generatePermanentUserToken({
|
|
4992
|
+
user_id: userID,
|
|
4993
|
+
});
|
|
4994
|
+
const segments = token.split('.');
|
|
4995
|
+
if (segments.length !== 3) {
|
|
4996
|
+
throw new Error('Invalid token format');
|
|
4997
|
+
}
|
|
4998
|
+
return {
|
|
4999
|
+
address: this.data.ingress.srt.address
|
|
5000
|
+
.replace('{passphrase}', segments[2])
|
|
5001
|
+
.replace('{token}', token),
|
|
5002
|
+
};
|
|
5003
|
+
};
|
|
4986
5004
|
}
|
|
4987
5005
|
get cid() {
|
|
4988
5006
|
return `${this.type}:${this.id}`;
|
|
@@ -4993,7 +5011,7 @@ class StreamVideoClient extends VideoApi {
|
|
|
4993
5011
|
constructor({ streamClient, apiClient, }) {
|
|
4994
5012
|
super(apiClient);
|
|
4995
5013
|
this.call = (type, id) => {
|
|
4996
|
-
return new StreamCall(this, type, id);
|
|
5014
|
+
return new StreamCall(this, type, id, this.streamClient);
|
|
4997
5015
|
};
|
|
4998
5016
|
this.connectOpenAi = async (options) => {
|
|
4999
5017
|
let doCreateRealtimeClient;
|
|
@@ -6638,7 +6656,7 @@ class ApiClient {
|
|
|
6638
6656
|
const headers = {
|
|
6639
6657
|
Authorization: this.apiConfig.token,
|
|
6640
6658
|
'stream-auth-type': 'jwt',
|
|
6641
|
-
'X-Stream-Client': 'stream-node-' + "0.7.
|
|
6659
|
+
'X-Stream-Client': 'stream-node-' + "0.7.3",
|
|
6642
6660
|
'Accept-Encoding': 'gzip',
|
|
6643
6661
|
'x-client-request-id': clientRequestId,
|
|
6644
6662
|
};
|
|
@@ -7827,6 +7845,17 @@ class StreamClient extends CommonApi {
|
|
|
7827
7845
|
payload.exp = payload.exp ?? payload.iat + validityInSeconds;
|
|
7828
7846
|
return JWTUserToken(this.secret, payload);
|
|
7829
7847
|
};
|
|
7848
|
+
/**
|
|
7849
|
+
*
|
|
7850
|
+
* @param payload
|
|
7851
|
+
* - user_id - the id of the user the token is for
|
|
7852
|
+
* - iat - issued at date of the token, unix timestamp in seconds, by default it's now
|
|
7853
|
+
*/
|
|
7854
|
+
this.generatePermanentUserToken = (payload) => {
|
|
7855
|
+
const defaultIat = Math.floor((Date.now() - 1000) / 1000);
|
|
7856
|
+
payload.iat = payload.iat ?? defaultIat;
|
|
7857
|
+
return JWTUserToken(this.secret, payload);
|
|
7858
|
+
};
|
|
7830
7859
|
/**
|
|
7831
7860
|
*
|
|
7832
7861
|
* @param payload
|