mezon-js 2.13.78 → 2.13.80
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/client.ts +3279 -2482
- package/dist/client.d.ts +163 -349
- package/dist/gateway.api.d.ts +33 -0
- package/dist/index.d.ts +2 -4
- package/dist/{api.gen.d.ts → mezon-js/api.gen.d.ts} +1 -0
- package/dist/mezon-js/client.d.ts +347 -0
- package/dist/mezon-js/gateway.api.d.ts +33 -0
- package/dist/mezon-js/index.d.ts +23 -0
- package/dist/mezon-js/session.d.ts +61 -0
- package/dist/mezon-js/socket.d.ts +1212 -0
- package/dist/mezon-js/types/index.d.ts +2212 -0
- package/dist/mezon-js/utils.d.ts +6 -0
- package/dist/mezon-js/web_socket_adapter.d.ts +83 -0
- package/dist/mezon-js.cjs.js +9038 -21145
- package/dist/mezon-js.esm.mjs +9038 -21145
- package/dist/mezon-js.esm.mjs.map +1 -0
- package/dist/session.d.ts +11 -11
- package/dist/socket.d.ts +385 -386
- package/dist/types/index.d.ts +2212 -0
- package/dist/utils.d.ts +2 -0
- package/dist/webrpc/index.d.ts +3 -0
- package/gateway.api.ts +577 -0
- package/index.ts +2 -5
- package/package.json +3 -2
- package/rollup.config.js +64 -30
- package/session.ts +22 -22
- package/socket.ts +921 -846
- package/types/index.ts +3883 -0
- package/utils.ts +107 -47
- package/api/api.ts +0 -39185
- package/api.gen.ts +0 -11777
- package/google/protobuf/struct.ts +0 -554
- package/google/protobuf/timestamp.ts +0 -223
- package/google/protobuf/wrappers.ts +0 -670
- /package/dist/{api → mezon-js/api}/api.d.ts +0 -0
- /package/dist/{google → mezon-js/google}/protobuf/struct.d.ts +0 -0
- /package/dist/{google → mezon-js/google}/protobuf/timestamp.d.ts +0 -0
- /package/dist/{google → mezon-js/google}/protobuf/wrappers.d.ts +0 -0
package/dist/utils.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export declare function buildFetchOptions(method: string, options: any, bodyJson
|
|
|
2
2
|
export declare function b64EncodeUnicode(str: string): string;
|
|
3
3
|
export declare function b64DecodeUnicode(str: string): string;
|
|
4
4
|
export declare function safeJSONParse(jsonStr: string): any;
|
|
5
|
+
export declare function mapToSnakeCase(obj: any): any;
|
|
6
|
+
export declare function mapToCamelCase(obj: any): any;
|
package/gateway.api.ts
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import { buildFetchOptions } from "./utils";
|
|
2
|
+
import { encode } from "js-base64";
|
|
3
|
+
import {
|
|
4
|
+
ApiAccountMezon,
|
|
5
|
+
ApiAuthenticateEmailRequest,
|
|
6
|
+
ApiAuthenticateSMSRequest,
|
|
7
|
+
ApiConfirmLoginRequest,
|
|
8
|
+
ApiGenerateMeetTokenExternalResponse,
|
|
9
|
+
ApiInviteUserRes,
|
|
10
|
+
ApiLinkAccountConfirmRequest,
|
|
11
|
+
ApiListClanDiscover,
|
|
12
|
+
ApiLoginIDResponse,
|
|
13
|
+
ApiLoginRequest,
|
|
14
|
+
ApiSession,
|
|
15
|
+
ApiClanDiscoverRequest,
|
|
16
|
+
Session,
|
|
17
|
+
} from "./types";
|
|
18
|
+
|
|
19
|
+
export class GatewayMezonApi {
|
|
20
|
+
basePath: string;
|
|
21
|
+
constructor(
|
|
22
|
+
readonly serverKey: string,
|
|
23
|
+
readonly timeoutMs: number,
|
|
24
|
+
basePath: string
|
|
25
|
+
) {
|
|
26
|
+
this.basePath = basePath;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setBasePath(basePath: string) {
|
|
30
|
+
this.basePath = basePath;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A healthcheck which load balancers can use to check the service. */
|
|
34
|
+
healthcheck(bearerToken: string, options: any = {}): Promise<any> {
|
|
35
|
+
const urlPath = "/healthcheck";
|
|
36
|
+
const queryParams = new Map<string, any>();
|
|
37
|
+
|
|
38
|
+
let bodyJson: string = "";
|
|
39
|
+
|
|
40
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
41
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
|
42
|
+
if (bearerToken) {
|
|
43
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return Promise.race([
|
|
47
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
48
|
+
if (response.status == 204) {
|
|
49
|
+
return response;
|
|
50
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
51
|
+
return response.json();
|
|
52
|
+
} else {
|
|
53
|
+
throw response;
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
new Promise((_, reject) =>
|
|
57
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
58
|
+
),
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Authenticate a user with Mezon against the server. */
|
|
63
|
+
authenticateMezon(
|
|
64
|
+
basicAuthUsername: string,
|
|
65
|
+
basicAuthPassword: string,
|
|
66
|
+
account: ApiAccountMezon,
|
|
67
|
+
create?: boolean,
|
|
68
|
+
username?: string,
|
|
69
|
+
isRemember?: boolean,
|
|
70
|
+
options: any = {}
|
|
71
|
+
): Promise<ApiSession> {
|
|
72
|
+
if (account === null || account === undefined) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"'account' is a required parameter but is null or undefined."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const urlPath = "/v2/account/authenticate/mezon";
|
|
78
|
+
const queryParams = new Map<string, any>();
|
|
79
|
+
queryParams.set("create", create);
|
|
80
|
+
queryParams.set("username", username);
|
|
81
|
+
queryParams.set("isRemember", isRemember);
|
|
82
|
+
|
|
83
|
+
let bodyJson: string = "";
|
|
84
|
+
bodyJson = JSON.stringify(account || {});
|
|
85
|
+
|
|
86
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
87
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
88
|
+
if (basicAuthUsername) {
|
|
89
|
+
fetchOptions.headers["Authorization"] =
|
|
90
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
91
|
+
}
|
|
92
|
+
fetchOptions.headers["Accept"] = "application/x-protobuf";
|
|
93
|
+
|
|
94
|
+
return Promise.race([
|
|
95
|
+
fetch(fullUrl, fetchOptions).then(async (response) => {
|
|
96
|
+
if (response.status == 204) {
|
|
97
|
+
return {} as ApiSession;
|
|
98
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
99
|
+
const buffer = await response.arrayBuffer();
|
|
100
|
+
return Session.decode(
|
|
101
|
+
new Uint8Array(buffer)
|
|
102
|
+
) as unknown as ApiSession;
|
|
103
|
+
} else {
|
|
104
|
+
throw response;
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
new Promise<never>((_, reject) =>
|
|
108
|
+
setTimeout(
|
|
109
|
+
() => reject(new Error("Request timed out.")),
|
|
110
|
+
this.timeoutMs
|
|
111
|
+
)
|
|
112
|
+
),
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Authenticate a user with an SMS against the server. */
|
|
117
|
+
AuthenticateSMSOTPRequest(
|
|
118
|
+
basicAuthUsername: string,
|
|
119
|
+
basicAuthPassword: string,
|
|
120
|
+
body: ApiAuthenticateSMSRequest,
|
|
121
|
+
options: any = {}
|
|
122
|
+
): Promise<ApiLinkAccountConfirmRequest> {
|
|
123
|
+
if (body === null || body === undefined) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
"'body' is a required parameter but is null or undefined."
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
const urlPath = "/v2/account/authenticate/smsotp";
|
|
129
|
+
const queryParams = new Map<string, any>();
|
|
130
|
+
|
|
131
|
+
let bodyJson: string = "";
|
|
132
|
+
bodyJson = JSON.stringify(body || {});
|
|
133
|
+
|
|
134
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
135
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
136
|
+
if (basicAuthUsername) {
|
|
137
|
+
fetchOptions.headers["Authorization"] =
|
|
138
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return Promise.race([
|
|
142
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
143
|
+
if (response.status == 204) {
|
|
144
|
+
return response;
|
|
145
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
146
|
+
return response.json();
|
|
147
|
+
} else {
|
|
148
|
+
throw response;
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
new Promise((_, reject) =>
|
|
152
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
153
|
+
),
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Authenticate a user with an email+password against the server. */
|
|
158
|
+
AuthenticateEmailOTPRequest(
|
|
159
|
+
basicAuthUsername: string,
|
|
160
|
+
basicAuthPassword: string,
|
|
161
|
+
body: ApiAuthenticateEmailRequest,
|
|
162
|
+
options: any = {}
|
|
163
|
+
): Promise<ApiLinkAccountConfirmRequest> {
|
|
164
|
+
if (body === null || body === undefined) {
|
|
165
|
+
throw new Error(
|
|
166
|
+
"'body' is a required parameter but is null or undefined."
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
const urlPath = "/v2/account/authenticate/emailotp";
|
|
170
|
+
const queryParams = new Map<string, any>();
|
|
171
|
+
|
|
172
|
+
let bodyJson: string = "";
|
|
173
|
+
bodyJson = JSON.stringify(body || {});
|
|
174
|
+
|
|
175
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
176
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
177
|
+
if (basicAuthUsername) {
|
|
178
|
+
fetchOptions.headers["Authorization"] =
|
|
179
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return Promise.race([
|
|
183
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
184
|
+
if (response.status == 204) {
|
|
185
|
+
return response;
|
|
186
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
187
|
+
return response.json();
|
|
188
|
+
} else {
|
|
189
|
+
throw response;
|
|
190
|
+
}
|
|
191
|
+
}),
|
|
192
|
+
new Promise((_, reject) =>
|
|
193
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
194
|
+
),
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** */
|
|
199
|
+
confirmAuthenticateOTP(
|
|
200
|
+
basicAuthUsername: string,
|
|
201
|
+
basicAuthPassword: string,
|
|
202
|
+
body: ApiLinkAccountConfirmRequest,
|
|
203
|
+
options: any = {}
|
|
204
|
+
): Promise<ApiSession> {
|
|
205
|
+
if (body === null || body === undefined) {
|
|
206
|
+
throw new Error(
|
|
207
|
+
"'body' is a required parameter but is null or undefined."
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
const urlPath = "/v2/account/authenticate/confirmotp";
|
|
211
|
+
const queryParams = new Map<string, any>();
|
|
212
|
+
|
|
213
|
+
let bodyJson: string = "";
|
|
214
|
+
bodyJson = JSON.stringify(body || {});
|
|
215
|
+
|
|
216
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
217
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
218
|
+
if (basicAuthUsername) {
|
|
219
|
+
fetchOptions.headers["Authorization"] =
|
|
220
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
221
|
+
}
|
|
222
|
+
fetchOptions.headers["Accept"] = "application/x-protobuf";
|
|
223
|
+
|
|
224
|
+
return Promise.race([
|
|
225
|
+
fetch(fullUrl, fetchOptions).then(async (response) => {
|
|
226
|
+
if (response.status == 204) {
|
|
227
|
+
return {} as ApiSession;
|
|
228
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
229
|
+
const buffer = await response.arrayBuffer();
|
|
230
|
+
return Session.decode(
|
|
231
|
+
new Uint8Array(buffer)
|
|
232
|
+
) as unknown as ApiSession;
|
|
233
|
+
} else {
|
|
234
|
+
throw response;
|
|
235
|
+
}
|
|
236
|
+
}),
|
|
237
|
+
new Promise<never>((_, reject) =>
|
|
238
|
+
setTimeout(
|
|
239
|
+
() => reject(new Error("Request timed out.")),
|
|
240
|
+
this.timeoutMs
|
|
241
|
+
)
|
|
242
|
+
),
|
|
243
|
+
]);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Authenticate a user with an email+password against the server. */
|
|
247
|
+
authenticateEmail(
|
|
248
|
+
basicAuthUsername: string,
|
|
249
|
+
basicAuthPassword: string,
|
|
250
|
+
body: ApiAuthenticateEmailRequest,
|
|
251
|
+
options: any = {}
|
|
252
|
+
): Promise<ApiSession> {
|
|
253
|
+
if (body === null || body === undefined) {
|
|
254
|
+
throw new Error(
|
|
255
|
+
"'body' is a required parameter but is null or undefined."
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
const urlPath = "/v2/account/authenticate/email";
|
|
259
|
+
const queryParams = new Map<string, any>();
|
|
260
|
+
|
|
261
|
+
let bodyJson: string = "";
|
|
262
|
+
bodyJson = JSON.stringify(body || {});
|
|
263
|
+
|
|
264
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
265
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
266
|
+
if (basicAuthUsername) {
|
|
267
|
+
fetchOptions.headers["Authorization"] =
|
|
268
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
269
|
+
}
|
|
270
|
+
fetchOptions.headers["Accept"] = "application/x-protobuf";
|
|
271
|
+
|
|
272
|
+
return Promise.race([
|
|
273
|
+
fetch(fullUrl, fetchOptions).then(async (response) => {
|
|
274
|
+
if (response.status == 204) {
|
|
275
|
+
return {} as ApiSession;
|
|
276
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
277
|
+
const buffer = await response.arrayBuffer();
|
|
278
|
+
return Session.decode(
|
|
279
|
+
new Uint8Array(buffer)
|
|
280
|
+
) as unknown as ApiSession;
|
|
281
|
+
} else {
|
|
282
|
+
throw response;
|
|
283
|
+
}
|
|
284
|
+
}),
|
|
285
|
+
new Promise<never>((_, reject) =>
|
|
286
|
+
setTimeout(
|
|
287
|
+
() => reject(new Error("Request timed out.")),
|
|
288
|
+
this.timeoutMs
|
|
289
|
+
)
|
|
290
|
+
),
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** Add users to a channel. */
|
|
295
|
+
getLinkInvite(
|
|
296
|
+
basicAuthUsername: string,
|
|
297
|
+
basicAuthPassword: string,
|
|
298
|
+
inviteId: string,
|
|
299
|
+
options: any = {}
|
|
300
|
+
): Promise<ApiInviteUserRes> {
|
|
301
|
+
if (inviteId === null || inviteId === undefined) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
"'inviteId' is a required parameter but is null or undefined."
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
const urlPath = "/v2/invite/{inviteId}".replace(
|
|
307
|
+
"{inviteId}",
|
|
308
|
+
encodeURIComponent(String(inviteId))
|
|
309
|
+
);
|
|
310
|
+
const queryParams = new Map<string, any>();
|
|
311
|
+
|
|
312
|
+
let bodyJson: string = "";
|
|
313
|
+
|
|
314
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
315
|
+
const fetchOptions = buildFetchOptions("GET", options, bodyJson);
|
|
316
|
+
if (basicAuthUsername) {
|
|
317
|
+
fetchOptions.headers["Authorization"] =
|
|
318
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
return Promise.race([
|
|
322
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
323
|
+
if (response.status == 204) {
|
|
324
|
+
return response;
|
|
325
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
326
|
+
return response.json();
|
|
327
|
+
} else {
|
|
328
|
+
throw response;
|
|
329
|
+
}
|
|
330
|
+
}),
|
|
331
|
+
new Promise((_, reject) =>
|
|
332
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
333
|
+
),
|
|
334
|
+
]);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** */
|
|
338
|
+
createQRLogin(
|
|
339
|
+
basicAuthUsername: string,
|
|
340
|
+
basicAuthPassword: string,
|
|
341
|
+
body: ApiLoginRequest,
|
|
342
|
+
options: any = {}
|
|
343
|
+
): Promise<ApiLoginIDResponse> {
|
|
344
|
+
if (body === null || body === undefined) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
"'body' is a required parameter but is null or undefined."
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
const urlPath = "/v2/account/authenticate/createqrlogin";
|
|
350
|
+
const queryParams = new Map<string, any>();
|
|
351
|
+
|
|
352
|
+
let bodyJson: string = "";
|
|
353
|
+
bodyJson = JSON.stringify(body || {});
|
|
354
|
+
|
|
355
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
356
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
357
|
+
if (basicAuthUsername) {
|
|
358
|
+
fetchOptions.headers["Authorization"] =
|
|
359
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return Promise.race([
|
|
363
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
364
|
+
if (response.status == 204) {
|
|
365
|
+
return response;
|
|
366
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
367
|
+
return response.json();
|
|
368
|
+
} else {
|
|
369
|
+
throw response;
|
|
370
|
+
}
|
|
371
|
+
}),
|
|
372
|
+
new Promise((_, reject) =>
|
|
373
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
374
|
+
),
|
|
375
|
+
]);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/** */
|
|
379
|
+
checkLoginRequest(
|
|
380
|
+
basicAuthUsername: string,
|
|
381
|
+
basicAuthPassword: string,
|
|
382
|
+
body: ApiConfirmLoginRequest,
|
|
383
|
+
options: any = {}
|
|
384
|
+
): Promise<ApiSession> {
|
|
385
|
+
if (body === null || body === undefined) {
|
|
386
|
+
throw new Error(
|
|
387
|
+
"'body' is a required parameter but is null or undefined."
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
const urlPath = "/v2/account/authenticate/checklogin";
|
|
391
|
+
const queryParams = new Map<string, any>();
|
|
392
|
+
|
|
393
|
+
let bodyJson: string = "";
|
|
394
|
+
bodyJson = JSON.stringify(body || {});
|
|
395
|
+
|
|
396
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
397
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
398
|
+
if (basicAuthUsername) {
|
|
399
|
+
fetchOptions.headers["Authorization"] =
|
|
400
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
401
|
+
}
|
|
402
|
+
fetchOptions.headers["Accept"] = "application/x-protobuf";
|
|
403
|
+
|
|
404
|
+
return Promise.race([
|
|
405
|
+
fetch(fullUrl, fetchOptions).then(async (response) => {
|
|
406
|
+
if (response.status == 204) {
|
|
407
|
+
return {} as ApiSession;
|
|
408
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
409
|
+
const buffer = await response.arrayBuffer();
|
|
410
|
+
return Session.decode(
|
|
411
|
+
new Uint8Array(buffer)
|
|
412
|
+
) as unknown as ApiSession;
|
|
413
|
+
} else {
|
|
414
|
+
throw response;
|
|
415
|
+
}
|
|
416
|
+
}),
|
|
417
|
+
new Promise<never>((_, reject) =>
|
|
418
|
+
setTimeout(
|
|
419
|
+
() => reject(new Error("Request timed out.")),
|
|
420
|
+
this.timeoutMs
|
|
421
|
+
)
|
|
422
|
+
),
|
|
423
|
+
]);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** */
|
|
427
|
+
confirmLogin(
|
|
428
|
+
bearerToken: string,
|
|
429
|
+
basePath: string,
|
|
430
|
+
body: ApiConfirmLoginRequest,
|
|
431
|
+
options: any = {}
|
|
432
|
+
): Promise<any> {
|
|
433
|
+
if (body === null || body === undefined) {
|
|
434
|
+
throw new Error(
|
|
435
|
+
"'body' is a required parameter but is null or undefined."
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
const urlPath = "/v2/account/authenticate/confirmlogin";
|
|
439
|
+
const queryParams = new Map<string, any>();
|
|
440
|
+
|
|
441
|
+
let bodyJson: string = "";
|
|
442
|
+
bodyJson = JSON.stringify(body || {});
|
|
443
|
+
|
|
444
|
+
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
|
445
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
446
|
+
if (bearerToken) {
|
|
447
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return Promise.race([
|
|
451
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
452
|
+
if (response.status == 204) {
|
|
453
|
+
return response;
|
|
454
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
455
|
+
return response.json();
|
|
456
|
+
} else {
|
|
457
|
+
throw response;
|
|
458
|
+
}
|
|
459
|
+
}),
|
|
460
|
+
new Promise((_, reject) =>
|
|
461
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
462
|
+
),
|
|
463
|
+
]);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** handler external mezon meet */
|
|
467
|
+
generateMeetTokenExternal(
|
|
468
|
+
bearerToken: string,
|
|
469
|
+
basePath: string,
|
|
470
|
+
token: string,
|
|
471
|
+
displayName?: string,
|
|
472
|
+
isGuest?: boolean,
|
|
473
|
+
options: any = {}
|
|
474
|
+
): Promise<ApiGenerateMeetTokenExternalResponse> {
|
|
475
|
+
if (token === null || token === undefined) {
|
|
476
|
+
throw new Error(
|
|
477
|
+
"'token' is a required parameter but is null or undefined."
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
const urlPath = "/v2/meet/external/{token}".replace(
|
|
481
|
+
"{token}",
|
|
482
|
+
encodeURIComponent(String(token))
|
|
483
|
+
);
|
|
484
|
+
const queryParams = new Map<string, any>();
|
|
485
|
+
queryParams.set("displayName", displayName);
|
|
486
|
+
queryParams.set("is_guest", isGuest);
|
|
487
|
+
|
|
488
|
+
let bodyJson: string = "";
|
|
489
|
+
|
|
490
|
+
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
|
491
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
492
|
+
if (bearerToken) {
|
|
493
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return Promise.race([
|
|
497
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
498
|
+
if (response.status == 204) {
|
|
499
|
+
return response;
|
|
500
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
501
|
+
return response.json();
|
|
502
|
+
} else {
|
|
503
|
+
throw response;
|
|
504
|
+
}
|
|
505
|
+
}),
|
|
506
|
+
new Promise((_, reject) =>
|
|
507
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
508
|
+
),
|
|
509
|
+
]);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/** Discover mezon clan. */
|
|
513
|
+
clanDiscover(
|
|
514
|
+
basicAuthUsername: string,
|
|
515
|
+
basicAuthPassword: string,
|
|
516
|
+
basePath: string,
|
|
517
|
+
body: ApiClanDiscoverRequest,
|
|
518
|
+
options: any = {}
|
|
519
|
+
): Promise<ApiListClanDiscover> {
|
|
520
|
+
if (body === null || body === undefined) {
|
|
521
|
+
throw new Error(
|
|
522
|
+
"'body' is a required parameter but is null or undefined."
|
|
523
|
+
);
|
|
524
|
+
}
|
|
525
|
+
const urlPath = "/v2/clan/discover";
|
|
526
|
+
const queryParams = new Map<string, any>();
|
|
527
|
+
|
|
528
|
+
let bodyJson: string = "";
|
|
529
|
+
bodyJson = JSON.stringify(body || {});
|
|
530
|
+
|
|
531
|
+
const fullUrl = this.buildFullUrl(basePath, urlPath, queryParams);
|
|
532
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
|
533
|
+
if (basicAuthUsername) {
|
|
534
|
+
fetchOptions.headers["Authorization"] =
|
|
535
|
+
"Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
return Promise.race([
|
|
539
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
540
|
+
if (response.status == 204) {
|
|
541
|
+
return response;
|
|
542
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
543
|
+
return response.json();
|
|
544
|
+
} else {
|
|
545
|
+
throw response;
|
|
546
|
+
}
|
|
547
|
+
}),
|
|
548
|
+
new Promise((_, reject) =>
|
|
549
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
550
|
+
),
|
|
551
|
+
]);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
buildFullUrl(
|
|
555
|
+
basePath: string,
|
|
556
|
+
fragment: string,
|
|
557
|
+
queryParams: Map<string, any>
|
|
558
|
+
) {
|
|
559
|
+
let fullPath = basePath + fragment + "?";
|
|
560
|
+
|
|
561
|
+
for (let [k, v] of queryParams) {
|
|
562
|
+
if (v instanceof Array) {
|
|
563
|
+
fullPath += v.reduce((prev: any, curr: any) => {
|
|
564
|
+
return (
|
|
565
|
+
prev + encodeURIComponent(k) + "=" + encodeURIComponent(curr) + "&"
|
|
566
|
+
);
|
|
567
|
+
}, "");
|
|
568
|
+
} else {
|
|
569
|
+
if (v != null) {
|
|
570
|
+
fullPath += encodeURIComponent(k) + "=" + encodeURIComponent(v) + "&";
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
return fullPath;
|
|
576
|
+
}
|
|
577
|
+
}
|
package/index.ts
CHANGED
|
@@ -21,8 +21,5 @@ export * from "./session";
|
|
|
21
21
|
export * from "./socket";
|
|
22
22
|
export * from "./web_socket_adapter";
|
|
23
23
|
export * from "./utils"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* Reexported due to duplicate definition of ChannelMessage in [Client]{@link ./client.ts} and [Session]{@link ./session.ts}
|
|
27
|
-
*/
|
|
28
|
-
export { ChannelMessage } from "./client";
|
|
24
|
+
export * from "./types";
|
|
25
|
+
export { Session } from "./session";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mezon-js",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.80",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
|
|
6
6
|
},
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"base64-arraybuffer": "^1.0.2",
|
|
39
39
|
"esbuild": "^0.25.5",
|
|
40
40
|
"js-base64": "^3.7.4",
|
|
41
|
-
"whatwg-fetch": "^3.6.2"
|
|
41
|
+
"whatwg-fetch": "^3.6.2",
|
|
42
|
+
"webrpc": "file:../webrpc"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@rollup/plugin-commonjs": "^29.0.0",
|