@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/src/StreamCall.d.ts
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VideoApi } from './gen-imports';
|
|
2
|
+
import { CallResponse, GetOrCreateCallRequest, QueryCallMembersRequest } from './gen/models';
|
|
2
3
|
import { CallApi } from './gen/video/CallApi';
|
|
4
|
+
import { StreamClient } from './StreamClient';
|
|
3
5
|
import { OmitTypeId } from './types';
|
|
4
6
|
export declare class StreamCall extends CallApi {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
readonly id: string;
|
|
9
|
+
private readonly streamClient;
|
|
10
|
+
data?: CallResponse;
|
|
11
|
+
constructor(videoApi: VideoApi, type: string, id: string, streamClient: StreamClient);
|
|
5
12
|
get cid(): string;
|
|
6
13
|
create: (request?: GetOrCreateCallRequest) => Promise<import("./types").StreamResponse<import("./gen/models").GetOrCreateCallResponse>>;
|
|
7
14
|
queryMembers: (request?: OmitTypeId<QueryCallMembersRequest>) => Promise<import("./types").StreamResponse<import("./gen/models").QueryCallMembersResponse>>;
|
|
15
|
+
getOrCreate: (request?: GetOrCreateCallRequest) => Promise<import("./types").StreamResponse<import("./gen/models").GetOrCreateCallResponse>>;
|
|
16
|
+
get: () => Promise<import("./types").StreamResponse<import("./gen/models").GetCallResponse>>;
|
|
17
|
+
createSRTCredentials: (userID: string) => {
|
|
18
|
+
address: string;
|
|
19
|
+
};
|
|
8
20
|
}
|
|
@@ -54,6 +54,16 @@ export declare class StreamClient extends CommonApi {
|
|
|
54
54
|
exp?: number;
|
|
55
55
|
iat?: number;
|
|
56
56
|
} & Record<string, unknown>) => string;
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param payload
|
|
60
|
+
* - user_id - the id of the user the token is for
|
|
61
|
+
* - iat - issued at date of the token, unix timestamp in seconds, by default it's now
|
|
62
|
+
*/
|
|
63
|
+
generatePermanentUserToken: (payload: {
|
|
64
|
+
user_id: string;
|
|
65
|
+
iat?: number;
|
|
66
|
+
} & Record<string, unknown>) => string;
|
|
57
67
|
/**
|
|
58
68
|
*
|
|
59
69
|
* @param payload
|
|
@@ -332,13 +332,6 @@ export interface ActivityResponse {
|
|
|
332
332
|
poll?: PollResponseData;
|
|
333
333
|
}
|
|
334
334
|
export interface ActivitySelectorConfig {
|
|
335
|
-
cutoff_time?: string;
|
|
336
|
-
min_popularity?: number;
|
|
337
|
-
type?: string;
|
|
338
|
-
sort?: SortParam[];
|
|
339
|
-
filter?: Record<string, any>;
|
|
340
|
-
}
|
|
341
|
-
export interface ActivitySelectorConfigResponse {
|
|
342
335
|
cutoff_time?: Date;
|
|
343
336
|
min_popularity?: number;
|
|
344
337
|
type?: string;
|
|
@@ -611,11 +604,13 @@ export interface AudioSettings {
|
|
|
611
604
|
opus_dtx_enabled: boolean;
|
|
612
605
|
redundant_coding_enabled: boolean;
|
|
613
606
|
speaker_default_on: boolean;
|
|
607
|
+
hifi_audio_enabled?: boolean;
|
|
614
608
|
noise_cancellation?: NoiseCancellationSettings;
|
|
615
609
|
}
|
|
616
610
|
export interface AudioSettingsRequest {
|
|
617
611
|
default_device: 'speaker' | 'earpiece';
|
|
618
612
|
access_request_enabled?: boolean;
|
|
613
|
+
hifi_audio_enabled?: boolean;
|
|
619
614
|
mic_default_on?: boolean;
|
|
620
615
|
opus_dtx_enabled?: boolean;
|
|
621
616
|
redundant_coding_enabled?: boolean;
|
|
@@ -629,6 +624,7 @@ export interface AudioSettingsResponse {
|
|
|
629
624
|
opus_dtx_enabled: boolean;
|
|
630
625
|
redundant_coding_enabled: boolean;
|
|
631
626
|
speaker_default_on: boolean;
|
|
627
|
+
hifi_audio_enabled?: boolean;
|
|
632
628
|
noise_cancellation?: NoiseCancellationSettings;
|
|
633
629
|
}
|
|
634
630
|
export interface AutomodDetails {
|
|
@@ -2998,7 +2994,7 @@ export interface FeedGroupResponse {
|
|
|
2998
2994
|
updated_at: Date;
|
|
2999
2995
|
default_visibility?: string;
|
|
3000
2996
|
activity_processors?: ActivityProcessorConfig[];
|
|
3001
|
-
activity_selectors?:
|
|
2997
|
+
activity_selectors?: ActivitySelectorConfig[];
|
|
3002
2998
|
aggregation?: AggregationConfig;
|
|
3003
2999
|
custom?: Record<string, any>;
|
|
3004
3000
|
notification?: NotificationConfig;
|
|
@@ -3140,7 +3136,7 @@ export interface FeedViewResponse {
|
|
|
3140
3136
|
id: string;
|
|
3141
3137
|
last_used_at?: Date;
|
|
3142
3138
|
activity_processors?: ActivityProcessorConfig[];
|
|
3143
|
-
activity_selectors?:
|
|
3139
|
+
activity_selectors?: ActivitySelectorConfig[];
|
|
3144
3140
|
aggregation?: AggregationConfig;
|
|
3145
3141
|
ranking?: RankingConfig;
|
|
3146
3142
|
}
|
|
@@ -3209,20 +3205,18 @@ export interface FirebaseConfigFields {
|
|
|
3209
3205
|
}
|
|
3210
3206
|
export interface Flag {
|
|
3211
3207
|
created_at: Date;
|
|
3212
|
-
|
|
3213
|
-
entity_type: string;
|
|
3208
|
+
created_by_automod: boolean;
|
|
3214
3209
|
updated_at: Date;
|
|
3215
|
-
|
|
3216
|
-
entity_creator_id?: string;
|
|
3217
|
-
is_streamed_content?: boolean;
|
|
3218
|
-
moderation_payload_hash?: string;
|
|
3210
|
+
approved_at?: Date;
|
|
3219
3211
|
reason?: string;
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3212
|
+
rejected_at?: Date;
|
|
3213
|
+
reviewed_at?: Date;
|
|
3214
|
+
reviewed_by?: string;
|
|
3215
|
+
target_message_id?: string;
|
|
3223
3216
|
custom?: Record<string, any>;
|
|
3224
|
-
|
|
3225
|
-
|
|
3217
|
+
details?: FlagDetails;
|
|
3218
|
+
target_message?: Message;
|
|
3219
|
+
target_user?: User;
|
|
3226
3220
|
user?: User;
|
|
3227
3221
|
}
|
|
3228
3222
|
export interface FlagDetails {
|
|
@@ -5687,8 +5681,8 @@ export interface RTMPSettingsResponse {
|
|
|
5687
5681
|
layout: LayoutSettingsResponse;
|
|
5688
5682
|
}
|
|
5689
5683
|
export interface RankingConfig {
|
|
5684
|
+
type: 'recency' | 'expression' | 'interest';
|
|
5690
5685
|
score?: string;
|
|
5691
|
-
type?: string;
|
|
5692
5686
|
defaults?: Record<string, any>;
|
|
5693
5687
|
functions?: Record<string, DecayFunctionConfig>;
|
|
5694
5688
|
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface ApiConfig {
|
|
|
7
7
|
/** The timeout for requests in milliseconds. The default is 3000. */
|
|
8
8
|
timeout: number;
|
|
9
9
|
agent?: RequestInit['dispatcher'];
|
|
10
|
+
secret?: string;
|
|
10
11
|
}
|
|
11
12
|
export interface RequestMetadata {
|
|
12
13
|
responseHeaders: Headers;
|
|
@@ -29,7 +30,7 @@ export interface RateLimit {
|
|
|
29
30
|
}
|
|
30
31
|
interface BaseTokenPayload {
|
|
31
32
|
user_id: string;
|
|
32
|
-
exp
|
|
33
|
+
exp?: number;
|
|
33
34
|
iat: number;
|
|
34
35
|
call_cids?: string[];
|
|
35
36
|
}
|
package/package.json
CHANGED
package/src/StreamCall.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VideoApi } from './gen-imports';
|
|
2
|
+
import {
|
|
3
|
+
CallResponse,
|
|
4
|
+
GetOrCreateCallRequest,
|
|
5
|
+
QueryCallMembersRequest,
|
|
6
|
+
} from './gen/models';
|
|
2
7
|
import { CallApi } from './gen/video/CallApi';
|
|
8
|
+
import { StreamClient } from './StreamClient';
|
|
3
9
|
import { OmitTypeId } from './types';
|
|
4
10
|
|
|
5
11
|
export class StreamCall extends CallApi {
|
|
12
|
+
data?: CallResponse;
|
|
13
|
+
|
|
14
|
+
constructor(
|
|
15
|
+
videoApi: VideoApi,
|
|
16
|
+
readonly type: string,
|
|
17
|
+
readonly id: string,
|
|
18
|
+
private readonly streamClient: StreamClient,
|
|
19
|
+
) {
|
|
20
|
+
super(videoApi, type, id);
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
get cid() {
|
|
7
24
|
return `${this.type}:${this.id}`;
|
|
8
25
|
}
|
|
@@ -16,4 +33,42 @@ export class StreamCall extends CallApi {
|
|
|
16
33
|
...(request ?? {}),
|
|
17
34
|
});
|
|
18
35
|
};
|
|
36
|
+
|
|
37
|
+
getOrCreate = async (request?: GetOrCreateCallRequest) => {
|
|
38
|
+
const response = await super.getOrCreate(request);
|
|
39
|
+
this.data = response.call;
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
get = async () => {
|
|
44
|
+
const response = await super.get();
|
|
45
|
+
this.data = response.call;
|
|
46
|
+
return response;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
createSRTCredentials = (
|
|
50
|
+
userID: string,
|
|
51
|
+
): {
|
|
52
|
+
address: string;
|
|
53
|
+
} => {
|
|
54
|
+
if (!this.data) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'Object is not initialized, call get() or getOrCreate() first',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const token = this.streamClient.generatePermanentUserToken({
|
|
61
|
+
user_id: userID,
|
|
62
|
+
});
|
|
63
|
+
const segments = token.split('.');
|
|
64
|
+
if (segments.length !== 3) {
|
|
65
|
+
throw new Error('Invalid token format');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
address: this.data.ingress.srt.address
|
|
70
|
+
.replace('{passphrase}', segments[2])
|
|
71
|
+
.replace('{token}', token),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
19
74
|
}
|
package/src/StreamClient.ts
CHANGED
|
@@ -145,6 +145,24 @@ export class StreamClient extends CommonApi {
|
|
|
145
145
|
return JWTUserToken(this.secret, payload as UserTokenPayload);
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
* @param payload
|
|
151
|
+
* - user_id - the id of the user the token is for
|
|
152
|
+
* - iat - issued at date of the token, unix timestamp in seconds, by default it's now
|
|
153
|
+
*/
|
|
154
|
+
generatePermanentUserToken = (
|
|
155
|
+
payload: {
|
|
156
|
+
user_id: string;
|
|
157
|
+
iat?: number;
|
|
158
|
+
} & Record<string, unknown>,
|
|
159
|
+
) => {
|
|
160
|
+
const defaultIat = Math.floor((Date.now() - 1000) / 1000);
|
|
161
|
+
payload.iat = payload.iat ?? defaultIat;
|
|
162
|
+
|
|
163
|
+
return JWTUserToken(this.secret, payload as UserTokenPayload);
|
|
164
|
+
};
|
|
165
|
+
|
|
148
166
|
/**
|
|
149
167
|
*
|
|
150
168
|
* @param payload
|
package/src/StreamVideoClient.ts
CHANGED
|
@@ -225,13 +225,6 @@ decoders.ActivityResponse = (input?: Record<string, any>) => {
|
|
|
225
225
|
};
|
|
226
226
|
|
|
227
227
|
decoders.ActivitySelectorConfig = (input?: Record<string, any>) => {
|
|
228
|
-
const typeMappings: TypeMapping = {
|
|
229
|
-
cutoff_time: { type: 'StringType', isSingle: true },
|
|
230
|
-
};
|
|
231
|
-
return decode(typeMappings, input);
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
decoders.ActivitySelectorConfigResponse = (input?: Record<string, any>) => {
|
|
235
228
|
const typeMappings: TypeMapping = {
|
|
236
229
|
cutoff_time: { type: 'DatetimeType', isSingle: true },
|
|
237
230
|
};
|
|
@@ -1910,10 +1903,7 @@ decoders.FeedGroupResponse = (input?: Record<string, any>) => {
|
|
|
1910
1903
|
|
|
1911
1904
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1912
1905
|
|
|
1913
|
-
activity_selectors: {
|
|
1914
|
-
type: 'ActivitySelectorConfigResponse',
|
|
1915
|
-
isSingle: false,
|
|
1916
|
-
},
|
|
1906
|
+
activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
|
|
1917
1907
|
};
|
|
1918
1908
|
return decode(typeMappings, input);
|
|
1919
1909
|
};
|
|
@@ -2006,10 +1996,7 @@ decoders.FeedViewResponse = (input?: Record<string, any>) => {
|
|
|
2006
1996
|
const typeMappings: TypeMapping = {
|
|
2007
1997
|
last_used_at: { type: 'DatetimeType', isSingle: true },
|
|
2008
1998
|
|
|
2009
|
-
activity_selectors: {
|
|
2010
|
-
type: 'ActivitySelectorConfigResponse',
|
|
2011
|
-
isSingle: false,
|
|
2012
|
-
},
|
|
1999
|
+
activity_selectors: { type: 'ActivitySelectorConfig', isSingle: false },
|
|
2013
2000
|
};
|
|
2014
2001
|
return decode(typeMappings, input);
|
|
2015
2002
|
};
|
package/src/gen/models/index.ts
CHANGED
|
@@ -595,18 +595,6 @@ export interface ActivityResponse {
|
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
export interface ActivitySelectorConfig {
|
|
598
|
-
cutoff_time?: string;
|
|
599
|
-
|
|
600
|
-
min_popularity?: number;
|
|
601
|
-
|
|
602
|
-
type?: string;
|
|
603
|
-
|
|
604
|
-
sort?: SortParam[];
|
|
605
|
-
|
|
606
|
-
filter?: Record<string, any>;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
export interface ActivitySelectorConfigResponse {
|
|
610
598
|
cutoff_time?: Date;
|
|
611
599
|
|
|
612
600
|
min_popularity?: number;
|
|
@@ -1095,6 +1083,8 @@ export interface AudioSettings {
|
|
|
1095
1083
|
|
|
1096
1084
|
speaker_default_on: boolean;
|
|
1097
1085
|
|
|
1086
|
+
hifi_audio_enabled?: boolean;
|
|
1087
|
+
|
|
1098
1088
|
noise_cancellation?: NoiseCancellationSettings;
|
|
1099
1089
|
}
|
|
1100
1090
|
|
|
@@ -1103,6 +1093,8 @@ export interface AudioSettingsRequest {
|
|
|
1103
1093
|
|
|
1104
1094
|
access_request_enabled?: boolean;
|
|
1105
1095
|
|
|
1096
|
+
hifi_audio_enabled?: boolean;
|
|
1097
|
+
|
|
1106
1098
|
mic_default_on?: boolean;
|
|
1107
1099
|
|
|
1108
1100
|
opus_dtx_enabled?: boolean;
|
|
@@ -1127,6 +1119,8 @@ export interface AudioSettingsResponse {
|
|
|
1127
1119
|
|
|
1128
1120
|
speaker_default_on: boolean;
|
|
1129
1121
|
|
|
1122
|
+
hifi_audio_enabled?: boolean;
|
|
1123
|
+
|
|
1130
1124
|
noise_cancellation?: NoiseCancellationSettings;
|
|
1131
1125
|
}
|
|
1132
1126
|
|
|
@@ -5269,7 +5263,7 @@ export interface FeedGroupResponse {
|
|
|
5269
5263
|
|
|
5270
5264
|
activity_processors?: ActivityProcessorConfig[];
|
|
5271
5265
|
|
|
5272
|
-
activity_selectors?:
|
|
5266
|
+
activity_selectors?: ActivitySelectorConfig[];
|
|
5273
5267
|
|
|
5274
5268
|
aggregation?: AggregationConfig;
|
|
5275
5269
|
|
|
@@ -5505,7 +5499,7 @@ export interface FeedViewResponse {
|
|
|
5505
5499
|
|
|
5506
5500
|
activity_processors?: ActivityProcessorConfig[];
|
|
5507
5501
|
|
|
5508
|
-
activity_selectors?:
|
|
5502
|
+
activity_selectors?: ActivitySelectorConfig[];
|
|
5509
5503
|
|
|
5510
5504
|
aggregation?: AggregationConfig;
|
|
5511
5505
|
|
|
@@ -5621,33 +5615,29 @@ export interface FirebaseConfigFields {
|
|
|
5621
5615
|
export interface Flag {
|
|
5622
5616
|
created_at: Date;
|
|
5623
5617
|
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
entity_type: string;
|
|
5618
|
+
created_by_automod: boolean;
|
|
5627
5619
|
|
|
5628
5620
|
updated_at: Date;
|
|
5629
5621
|
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
entity_creator_id?: string;
|
|
5633
|
-
|
|
5634
|
-
is_streamed_content?: boolean;
|
|
5635
|
-
|
|
5636
|
-
moderation_payload_hash?: string;
|
|
5622
|
+
approved_at?: Date;
|
|
5637
5623
|
|
|
5638
5624
|
reason?: string;
|
|
5639
5625
|
|
|
5640
|
-
|
|
5626
|
+
rejected_at?: Date;
|
|
5641
5627
|
|
|
5642
|
-
|
|
5628
|
+
reviewed_at?: Date;
|
|
5643
5629
|
|
|
5644
|
-
|
|
5630
|
+
reviewed_by?: string;
|
|
5631
|
+
|
|
5632
|
+
target_message_id?: string;
|
|
5645
5633
|
|
|
5646
5634
|
custom?: Record<string, any>;
|
|
5647
5635
|
|
|
5648
|
-
|
|
5636
|
+
details?: FlagDetails;
|
|
5649
5637
|
|
|
5650
|
-
|
|
5638
|
+
target_message?: Message;
|
|
5639
|
+
|
|
5640
|
+
target_user?: User;
|
|
5651
5641
|
|
|
5652
5642
|
user?: User;
|
|
5653
5643
|
}
|
|
@@ -9935,9 +9925,9 @@ export interface RTMPSettingsResponse {
|
|
|
9935
9925
|
}
|
|
9936
9926
|
|
|
9937
9927
|
export interface RankingConfig {
|
|
9938
|
-
|
|
9928
|
+
type: 'recency' | 'expression' | 'interest';
|
|
9939
9929
|
|
|
9940
|
-
|
|
9930
|
+
score?: string;
|
|
9941
9931
|
|
|
9942
9932
|
defaults?: Record<string, any>;
|
|
9943
9933
|
|
package/src/types.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface ApiConfig {
|
|
|
7
7
|
/** The timeout for requests in milliseconds. The default is 3000. */
|
|
8
8
|
timeout: number;
|
|
9
9
|
agent?: RequestInit['dispatcher'];
|
|
10
|
+
secret?: string;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export interface RequestMetadata {
|
|
@@ -39,7 +40,7 @@ export interface RateLimit {
|
|
|
39
40
|
|
|
40
41
|
interface BaseTokenPayload {
|
|
41
42
|
user_id: string;
|
|
42
|
-
exp
|
|
43
|
+
exp?: number;
|
|
43
44
|
iat: number;
|
|
44
45
|
call_cids?: string[];
|
|
45
46
|
}
|