@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 CHANGED
@@ -14,6 +14,7 @@ The package is tested against these environments:
14
14
  - Node.js@18
15
15
  - Node.js@20
16
16
  - Node.js@22
17
+ - Node.js@24
17
18
  - Bun@1
18
19
 
19
20
  ## What is Stream?
package/dist/index.cjs.js CHANGED
@@ -201,6 +201,12 @@ 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) => {
204
210
  const typeMappings = {
205
211
  cutoff_time: { type: 'DatetimeType', isSingle: true },
206
212
  };
@@ -1444,7 +1450,10 @@ decoders.FeedGroupResponse = (input) => {
1444
1450
  const typeMappings = {
1445
1451
  created_at: { type: 'DatetimeType', isSingle: true },
1446
1452
  updated_at: { type: 'DatetimeType', isSingle: true },
1447
- activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
1453
+ activity_selectors: {
1454
+ type: 'ActivitySelectorConfigResponse',
1455
+ isSingle: false,
1456
+ },
1448
1457
  };
1449
1458
  return decode(typeMappings, input);
1450
1459
  };
@@ -1508,7 +1517,10 @@ decoders.FeedUpdatedEvent = (input) => {
1508
1517
  decoders.FeedViewResponse = (input) => {
1509
1518
  const typeMappings = {
1510
1519
  last_used_at: { type: 'DatetimeType', isSingle: true },
1511
- activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
1520
+ activity_selectors: {
1521
+ type: 'ActivitySelectorConfigResponse',
1522
+ isSingle: false,
1523
+ },
1512
1524
  };
1513
1525
  return decode(typeMappings, input);
1514
1526
  };
@@ -4961,8 +4973,11 @@ class CallApi {
4961
4973
  }
4962
4974
 
4963
4975
  class StreamCall extends CallApi {
4964
- constructor() {
4965
- super(...arguments);
4976
+ constructor(videoApi, type, id, streamClient) {
4977
+ super(videoApi, type, id);
4978
+ this.type = type;
4979
+ this.id = id;
4980
+ this.streamClient = streamClient;
4966
4981
  this.create = (request) => this.getOrCreate(request);
4967
4982
  this.queryMembers = (request) => {
4968
4983
  return this.videoApi.queryCallMembers({
@@ -4971,6 +4986,33 @@ class StreamCall extends CallApi {
4971
4986
  ...(request ?? {}),
4972
4987
  });
4973
4988
  };
4989
+ this.getOrCreate = async (request) => {
4990
+ const response = await super.getOrCreate(request);
4991
+ this.data = response.call;
4992
+ return response;
4993
+ };
4994
+ this.get = async () => {
4995
+ const response = await super.get();
4996
+ this.data = response.call;
4997
+ return response;
4998
+ };
4999
+ this.createSRTCredetials = (userID) => {
5000
+ if (!this.data) {
5001
+ throw new Error('Object is not initialized, call get() or getOrCreate() first');
5002
+ }
5003
+ const token = this.streamClient.generatePermanentUserToken({
5004
+ user_id: userID,
5005
+ });
5006
+ const segments = token.split('.');
5007
+ if (segments.length !== 3) {
5008
+ throw new Error('Invalid token format');
5009
+ }
5010
+ return {
5011
+ address: this.data.ingress.srt.address
5012
+ .replace('{passphrase}', segments[2])
5013
+ .replace('{token}', token),
5014
+ };
5015
+ };
4974
5016
  }
4975
5017
  get cid() {
4976
5018
  return `${this.type}:${this.id}`;
@@ -4981,7 +5023,7 @@ class StreamVideoClient extends VideoApi {
4981
5023
  constructor({ streamClient, apiClient, }) {
4982
5024
  super(apiClient);
4983
5025
  this.call = (type, id) => {
4984
- return new StreamCall(this, type, id);
5026
+ return new StreamCall(this, type, id, this.streamClient);
4985
5027
  };
4986
5028
  this.connectOpenAi = async (options) => {
4987
5029
  let doCreateRealtimeClient;
@@ -6626,7 +6668,7 @@ class ApiClient {
6626
6668
  const headers = {
6627
6669
  Authorization: this.apiConfig.token,
6628
6670
  'stream-auth-type': 'jwt',
6629
- 'X-Stream-Client': 'stream-node-' + "0.7.0",
6671
+ 'X-Stream-Client': 'stream-node-' + "0.7.2",
6630
6672
  'Accept-Encoding': 'gzip',
6631
6673
  'x-client-request-id': clientRequestId,
6632
6674
  };
@@ -7815,6 +7857,17 @@ class StreamClient extends CommonApi {
7815
7857
  payload.exp = payload.exp ?? payload.iat + validityInSeconds;
7816
7858
  return JWTUserToken(this.secret, payload);
7817
7859
  };
7860
+ /**
7861
+ *
7862
+ * @param payload
7863
+ * - user_id - the id of the user the token is for
7864
+ * - iat - issued at date of the token, unix timestamp in seconds, by default it's now
7865
+ */
7866
+ this.generatePermanentUserToken = (payload) => {
7867
+ const defaultIat = Math.floor((Date.now() - 1000) / 1000);
7868
+ payload.iat = payload.iat ?? defaultIat;
7869
+ return JWTUserToken(this.secret, payload);
7870
+ };
7818
7871
  /**
7819
7872
  *
7820
7873
  * @param payload