mezon-js 2.9.64 → 2.9.66
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +96 -5
- package/client.ts +34 -0
- package/dist/api.gen.d.ts +16 -0
- package/dist/client.d.ts +3 -1
- package/dist/mezon-js.cjs.js +78 -6
- package/dist/mezon-js.esm.mjs +78 -6
- package/dist/socket.d.ts +3 -12
- package/package.json +1 -1
- package/socket.ts +4 -22
package/api.gen.ts
CHANGED
@@ -2148,6 +2148,20 @@ export interface ApiSystemMessagesList {
|
|
2148
2148
|
system_messages_list?: Array<ApiSystemMessage>;
|
2149
2149
|
}
|
2150
2150
|
|
2151
|
+
/** */
|
2152
|
+
export interface ApiTokenSentEvent {
|
2153
|
+
//
|
2154
|
+
amount?: number;
|
2155
|
+
//
|
2156
|
+
note?: string;
|
2157
|
+
//
|
2158
|
+
receiver_id?: string;
|
2159
|
+
//
|
2160
|
+
sender_id?: string;
|
2161
|
+
//
|
2162
|
+
sender_name?: string;
|
2163
|
+
}
|
2164
|
+
|
2151
2165
|
/** Update a user's account details. */
|
2152
2166
|
export interface ApiUpdateAccountRequest {
|
2153
2167
|
//
|
@@ -2375,6 +2389,12 @@ export interface ApiWebhookListResponse {
|
|
2375
2389
|
webhooks?: Array<ApiWebhook>;
|
2376
2390
|
}
|
2377
2391
|
|
2392
|
+
/** */
|
2393
|
+
export interface ApiWithdrawTokenRequest {
|
2394
|
+
//
|
2395
|
+
amount?: number;
|
2396
|
+
}
|
2397
|
+
|
2378
2398
|
/** Represents an event to be passed through the server to registered event handlers. */
|
2379
2399
|
export interface MezonapiEvent {
|
2380
2400
|
//True if the event came directly from a client call, false otherwise.
|
@@ -8280,12 +8300,47 @@ pushPubKey(bearerToken: string,
|
|
8280
8300
|
|
8281
8301
|
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
8282
8302
|
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
8283
|
-
|
8284
|
-
|
8303
|
+
if (bearerToken) {
|
8304
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
8305
|
+
}
|
8306
|
+
if (basicAuthUsername) {
|
8307
|
+
fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
|
8308
|
+
}
|
8309
|
+
|
8310
|
+
return Promise.race([
|
8311
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
8312
|
+
if (response.status == 204) {
|
8313
|
+
return response;
|
8314
|
+
} else if (response.status >= 200 && response.status < 300) {
|
8315
|
+
return response.json();
|
8316
|
+
} else {
|
8317
|
+
throw response;
|
8318
|
+
}
|
8319
|
+
}),
|
8320
|
+
new Promise((_, reject) =>
|
8321
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
8322
|
+
),
|
8323
|
+
]);
|
8324
|
+
}
|
8325
|
+
|
8326
|
+
/** UpdateWallets */
|
8327
|
+
sendToken(bearerToken: string,
|
8328
|
+
body:ApiTokenSentEvent,
|
8329
|
+
options: any = {}): Promise<any> {
|
8330
|
+
|
8331
|
+
if (body === null || body === undefined) {
|
8332
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
8285
8333
|
}
|
8286
|
-
|
8287
|
-
|
8288
|
-
|
8334
|
+
const urlPath = "/v2/sendtoken";
|
8335
|
+
const queryParams = new Map<string, any>();
|
8336
|
+
|
8337
|
+
let bodyJson : string = "";
|
8338
|
+
bodyJson = JSON.stringify(body || {});
|
8339
|
+
|
8340
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
8341
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
8342
|
+
if (bearerToken) {
|
8343
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
8289
8344
|
}
|
8290
8345
|
|
8291
8346
|
return Promise.race([
|
@@ -9412,6 +9467,42 @@ pushPubKey(bearerToken: string,
|
|
9412
9467
|
]);
|
9413
9468
|
}
|
9414
9469
|
|
9470
|
+
/** WithdrawToken */
|
9471
|
+
withdrawToken(bearerToken: string,
|
9472
|
+
body:ApiWithdrawTokenRequest,
|
9473
|
+
options: any = {}): Promise<any> {
|
9474
|
+
|
9475
|
+
if (body === null || body === undefined) {
|
9476
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
9477
|
+
}
|
9478
|
+
const urlPath = "/v2/withdrawtoken";
|
9479
|
+
const queryParams = new Map<string, any>();
|
9480
|
+
|
9481
|
+
let bodyJson : string = "";
|
9482
|
+
bodyJson = JSON.stringify(body || {});
|
9483
|
+
|
9484
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
9485
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
9486
|
+
if (bearerToken) {
|
9487
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
9488
|
+
}
|
9489
|
+
|
9490
|
+
return Promise.race([
|
9491
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
9492
|
+
if (response.status == 204) {
|
9493
|
+
return response;
|
9494
|
+
} else if (response.status >= 200 && response.status < 300) {
|
9495
|
+
return response.json();
|
9496
|
+
} else {
|
9497
|
+
throw response;
|
9498
|
+
}
|
9499
|
+
}),
|
9500
|
+
new Promise((_, reject) =>
|
9501
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
9502
|
+
),
|
9503
|
+
]);
|
9504
|
+
}
|
9505
|
+
|
9415
9506
|
/** */
|
9416
9507
|
getChannelCanvasDetail(
|
9417
9508
|
bearerToken: string,
|
package/client.ts
CHANGED
@@ -137,6 +137,8 @@ import {
|
|
137
137
|
ApiPubKey,
|
138
138
|
ApiGetKeyServerResp,
|
139
139
|
MezonapiListAuditLog,
|
140
|
+
ApiTokenSentEvent,
|
141
|
+
ApiWithdrawTokenRequest,
|
140
142
|
} from "./api.gen";
|
141
143
|
|
142
144
|
import { Session } from "./session";
|
@@ -3516,6 +3518,38 @@ export class Client {
|
|
3516
3518
|
});
|
3517
3519
|
}
|
3518
3520
|
|
3521
|
+
async updateWallets(session: Session, request: ApiTokenSentEvent) {
|
3522
|
+
if (
|
3523
|
+
this.autoRefreshSession &&
|
3524
|
+
session.refresh_token &&
|
3525
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3526
|
+
) {
|
3527
|
+
await this.sessionRefresh(session);
|
3528
|
+
}
|
3529
|
+
|
3530
|
+
return this.apiClient
|
3531
|
+
.sendToken(session.token, request)
|
3532
|
+
.then((response: ApiTokenSentEvent) => {
|
3533
|
+
return Promise.resolve(response);
|
3534
|
+
});
|
3535
|
+
}
|
3536
|
+
|
3537
|
+
async withdrawToken(session: Session, request: ApiWithdrawTokenRequest) {
|
3538
|
+
if (
|
3539
|
+
this.autoRefreshSession &&
|
3540
|
+
session.refresh_token &&
|
3541
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3542
|
+
) {
|
3543
|
+
await this.sessionRefresh(session);
|
3544
|
+
}
|
3545
|
+
|
3546
|
+
return this.apiClient
|
3547
|
+
.withdrawToken(session.token, request)
|
3548
|
+
.then((response: ApiTokenSentEvent) => {
|
3549
|
+
return Promise.resolve(response);
|
3550
|
+
});
|
3551
|
+
}
|
3552
|
+
|
3519
3553
|
async listStreamingChannels(
|
3520
3554
|
session: Session,
|
3521
3555
|
clanId: string
|
package/dist/api.gen.d.ts
CHANGED
@@ -1252,6 +1252,14 @@ export interface ApiSystemMessageRequest {
|
|
1252
1252
|
export interface ApiSystemMessagesList {
|
1253
1253
|
system_messages_list?: Array<ApiSystemMessage>;
|
1254
1254
|
}
|
1255
|
+
/** */
|
1256
|
+
export interface ApiTokenSentEvent {
|
1257
|
+
amount?: number;
|
1258
|
+
note?: string;
|
1259
|
+
receiver_id?: string;
|
1260
|
+
sender_id?: string;
|
1261
|
+
sender_name?: string;
|
1262
|
+
}
|
1255
1263
|
/** Update a user's account details. */
|
1256
1264
|
export interface ApiUpdateAccountRequest {
|
1257
1265
|
about_me?: string;
|
@@ -1383,6 +1391,10 @@ export interface ApiWebhookGenerateResponse {
|
|
1383
1391
|
export interface ApiWebhookListResponse {
|
1384
1392
|
webhooks?: Array<ApiWebhook>;
|
1385
1393
|
}
|
1394
|
+
/** */
|
1395
|
+
export interface ApiWithdrawTokenRequest {
|
1396
|
+
amount?: number;
|
1397
|
+
}
|
1386
1398
|
/** Represents an event to be passed through the server to registered event handlers. */
|
1387
1399
|
export interface MezonapiEvent {
|
1388
1400
|
external?: boolean;
|
@@ -1709,6 +1721,8 @@ export declare class MezonApi {
|
|
1709
1721
|
rpcFunc2(bearerToken: string, basicAuthUsername: string, basicAuthPassword: string, id: string, payload?: string, httpKey?: string, options?: any): Promise<ApiRpc>;
|
1710
1722
|
/** Execute a Lua function on the server. */
|
1711
1723
|
rpcFunc(bearerToken: string, basicAuthUsername: string, basicAuthPassword: string, id: string, payload: string, httpKey?: string, options?: any): Promise<ApiRpc>;
|
1724
|
+
/** UpdateWallets */
|
1725
|
+
sendToken(bearerToken: string, body: ApiTokenSentEvent, options?: any): Promise<any>;
|
1712
1726
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
1713
1727
|
sessionLogout(bearerToken: string, body: ApiSessionLogoutRequest, options?: any): Promise<any>;
|
1714
1728
|
/** Add a new sticker */
|
@@ -1764,6 +1778,8 @@ export declare class MezonApi {
|
|
1764
1778
|
buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>): string;
|
1765
1779
|
/** Channel canvas editor */
|
1766
1780
|
editChannelCanvases(bearerToken: string, body: ApiEditChannelCanvasRequest, options?: any): Promise<ApiEditChannelCanvasResponse>;
|
1781
|
+
/** WithdrawToken */
|
1782
|
+
withdrawToken(bearerToken: string, body: ApiWithdrawTokenRequest, options?: any): Promise<any>;
|
1767
1783
|
/** */
|
1768
1784
|
getChannelCanvasDetail(bearerToken: string, id: string, clanId?: string, channelId?: string, options?: any): Promise<ApiChannelCanvasDetailResponse>;
|
1769
1785
|
/** */
|
package/dist/client.d.ts
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog } from "./api.gen";
|
16
|
+
import { ApiAccount, ApiAccountCustom, ApiAccountDevice, ApiAccountEmail, ApiAccountFacebook, ApiAccountFacebookInstantGame, ApiAccountGoogle, ApiAccountGameCenter, ApiAccountSteam, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiUpdateAccountRequest, ApiAccountApple, ApiLinkSteamRequest, ApiClanDescProfile, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, ApiUpdateEventRequest, ApiLinkInviteUser, ApiInviteUserRes, ApiUploadAttachmentRequest, ApiUploadAttachment, ApiMessageReaction, ApiMessageMention, ApiMessageAttachment, ApiMessageRef, ApiChannelMessageHeader, ApiVoiceChannelUserList, ApiChannelAttachmentList, ApiCreateEventRequest, ApiEventManagement, ApiEventList, ApiDeleteEventRequest, ApiSetDefaultNotificationRequest, ApiSetNotificationRequest, ApiSetMuteNotificationRequest, ApiSearchMessageRequest, ApiSearchMessageResponse, ApiPinMessageRequest, ApiPinMessagesList, ApiDeleteChannelDescRequest, ApiChangeChannelPrivateRequest, ApiClanEmojiCreateRequest, MezonUpdateClanEmojiByIdBody, ApiWebhookCreateRequest, ApiWebhookListResponse, MezonUpdateWebhookByIdBody, ApiWebhookGenerateResponse, ApiCheckDuplicateClanNameResponse, ApiClanStickerAddRequest, MezonUpdateClanStickerByIdBody, MezonChangeChannelCategoryBody, ApiUpdateRoleChannelRequest, ApiAddAppRequest, ApiAppList, ApiApp, MezonUpdateAppBody, ApiSystemMessagesList, ApiSystemMessage, ApiSystemMessageRequest, MezonUpdateSystemMessageBody, ApiUpdateCategoryOrderRequest, ApiGiveCoffeeEvent, ApiListStreamingChannelsResponse, ApiStreamingChannelUserList, ApiRegisterStreamingChannelRequest, ApiRoleList, ApiListChannelAppsResponse, ApiNotificationChannelCategorySettingList, ApiNotificationUserChannel, ApiNotificationSetting, ApiNotifiReactMessage, ApiHashtagDmList, ApiEmojiListedResponse, ApiStickerListedResponse, ApiAllUsersAddChannelResponse, ApiRoleListEventResponse, ApiAllUserClans, ApiUserPermissionInChannelListResponse, ApiPermissionRoleChannelListEventResponse, ApiMarkAsReadRequest, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog, ApiTokenSentEvent, ApiWithdrawTokenRequest } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { Socket } from "./socket";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -559,6 +559,8 @@ export declare class Client {
|
|
559
559
|
updateCategoryOrder(session: Session, request: ApiUpdateCategoryOrderRequest): Promise<any>;
|
560
560
|
deleteCategoryOrder(session: Session, clanId: string): Promise<any>;
|
561
561
|
givecoffee(session: Session, request: ApiGiveCoffeeEvent): Promise<boolean>;
|
562
|
+
updateWallets(session: Session, request: ApiTokenSentEvent): Promise<ApiTokenSentEvent>;
|
563
|
+
withdrawToken(session: Session, request: ApiWithdrawTokenRequest): Promise<ApiTokenSentEvent>;
|
562
564
|
listStreamingChannels(session: Session, clanId: string): Promise<ApiListStreamingChannelsResponse>;
|
563
565
|
/** List a channel's users. */
|
564
566
|
listStreamingChannelUsers(session: Session, clanId: string, channelId: string, channelType: number, state?: number, limit?: number, cursor?: string): Promise<ApiStreamingChannelUserList>;
|
package/dist/mezon-js.cjs.js
CHANGED
@@ -5287,6 +5287,35 @@ var MezonApi = class {
|
|
5287
5287
|
)
|
5288
5288
|
]);
|
5289
5289
|
}
|
5290
|
+
/** UpdateWallets */
|
5291
|
+
sendToken(bearerToken, body, options = {}) {
|
5292
|
+
if (body === null || body === void 0) {
|
5293
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
5294
|
+
}
|
5295
|
+
const urlPath = "/v2/sendtoken";
|
5296
|
+
const queryParams = /* @__PURE__ */ new Map();
|
5297
|
+
let bodyJson = "";
|
5298
|
+
bodyJson = JSON.stringify(body || {});
|
5299
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
5300
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
5301
|
+
if (bearerToken) {
|
5302
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
5303
|
+
}
|
5304
|
+
return Promise.race([
|
5305
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
5306
|
+
if (response.status == 204) {
|
5307
|
+
return response;
|
5308
|
+
} else if (response.status >= 200 && response.status < 300) {
|
5309
|
+
return response.json();
|
5310
|
+
} else {
|
5311
|
+
throw response;
|
5312
|
+
}
|
5313
|
+
}),
|
5314
|
+
new Promise(
|
5315
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5316
|
+
)
|
5317
|
+
]);
|
5318
|
+
}
|
5290
5319
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
5291
5320
|
sessionLogout(bearerToken, body, options = {}) {
|
5292
5321
|
if (body === null || body === void 0) {
|
@@ -6154,6 +6183,35 @@ var MezonApi = class {
|
|
6154
6183
|
)
|
6155
6184
|
]);
|
6156
6185
|
}
|
6186
|
+
/** WithdrawToken */
|
6187
|
+
withdrawToken(bearerToken, body, options = {}) {
|
6188
|
+
if (body === null || body === void 0) {
|
6189
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
6190
|
+
}
|
6191
|
+
const urlPath = "/v2/withdrawtoken";
|
6192
|
+
const queryParams = /* @__PURE__ */ new Map();
|
6193
|
+
let bodyJson = "";
|
6194
|
+
bodyJson = JSON.stringify(body || {});
|
6195
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6196
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
6197
|
+
if (bearerToken) {
|
6198
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6199
|
+
}
|
6200
|
+
return Promise.race([
|
6201
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
6202
|
+
if (response.status == 204) {
|
6203
|
+
return response;
|
6204
|
+
} else if (response.status >= 200 && response.status < 300) {
|
6205
|
+
return response.json();
|
6206
|
+
} else {
|
6207
|
+
throw response;
|
6208
|
+
}
|
6209
|
+
}),
|
6210
|
+
new Promise(
|
6211
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6212
|
+
)
|
6213
|
+
]);
|
6214
|
+
}
|
6157
6215
|
/** */
|
6158
6216
|
getChannelCanvasDetail(bearerToken, id, clanId, channelId, options = {}) {
|
6159
6217
|
if (id === null || id === void 0) {
|
@@ -6992,12 +7050,6 @@ var _DefaultSocket = class _DefaultSocket {
|
|
6992
7050
|
return response.check_name_existed_event;
|
6993
7051
|
});
|
6994
7052
|
}
|
6995
|
-
sendToken(receiver_id, amount) {
|
6996
|
-
return __async(this, null, function* () {
|
6997
|
-
const response = yield this.send({ token_sent_event: { receiver_id, amount } });
|
6998
|
-
return response.token_sent_event;
|
6999
|
-
});
|
7000
|
-
}
|
7001
7053
|
pingPong() {
|
7002
7054
|
return __async(this, null, function* () {
|
7003
7055
|
if (!this.adapter.isOpen()) {
|
@@ -8865,6 +8917,26 @@ var Client = class {
|
|
8865
8917
|
});
|
8866
8918
|
});
|
8867
8919
|
}
|
8920
|
+
updateWallets(session, request) {
|
8921
|
+
return __async(this, null, function* () {
|
8922
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
8923
|
+
yield this.sessionRefresh(session);
|
8924
|
+
}
|
8925
|
+
return this.apiClient.sendToken(session.token, request).then((response) => {
|
8926
|
+
return Promise.resolve(response);
|
8927
|
+
});
|
8928
|
+
});
|
8929
|
+
}
|
8930
|
+
withdrawToken(session, request) {
|
8931
|
+
return __async(this, null, function* () {
|
8932
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
8933
|
+
yield this.sessionRefresh(session);
|
8934
|
+
}
|
8935
|
+
return this.apiClient.withdrawToken(session.token, request).then((response) => {
|
8936
|
+
return Promise.resolve(response);
|
8937
|
+
});
|
8938
|
+
});
|
8939
|
+
}
|
8868
8940
|
listStreamingChannels(session, clanId) {
|
8869
8941
|
return __async(this, null, function* () {
|
8870
8942
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
package/dist/mezon-js.esm.mjs
CHANGED
@@ -5258,6 +5258,35 @@ var MezonApi = class {
|
|
5258
5258
|
)
|
5259
5259
|
]);
|
5260
5260
|
}
|
5261
|
+
/** UpdateWallets */
|
5262
|
+
sendToken(bearerToken, body, options = {}) {
|
5263
|
+
if (body === null || body === void 0) {
|
5264
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
5265
|
+
}
|
5266
|
+
const urlPath = "/v2/sendtoken";
|
5267
|
+
const queryParams = /* @__PURE__ */ new Map();
|
5268
|
+
let bodyJson = "";
|
5269
|
+
bodyJson = JSON.stringify(body || {});
|
5270
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
5271
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
5272
|
+
if (bearerToken) {
|
5273
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
5274
|
+
}
|
5275
|
+
return Promise.race([
|
5276
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
5277
|
+
if (response.status == 204) {
|
5278
|
+
return response;
|
5279
|
+
} else if (response.status >= 200 && response.status < 300) {
|
5280
|
+
return response.json();
|
5281
|
+
} else {
|
5282
|
+
throw response;
|
5283
|
+
}
|
5284
|
+
}),
|
5285
|
+
new Promise(
|
5286
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
5287
|
+
)
|
5288
|
+
]);
|
5289
|
+
}
|
5261
5290
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
5262
5291
|
sessionLogout(bearerToken, body, options = {}) {
|
5263
5292
|
if (body === null || body === void 0) {
|
@@ -6125,6 +6154,35 @@ var MezonApi = class {
|
|
6125
6154
|
)
|
6126
6155
|
]);
|
6127
6156
|
}
|
6157
|
+
/** WithdrawToken */
|
6158
|
+
withdrawToken(bearerToken, body, options = {}) {
|
6159
|
+
if (body === null || body === void 0) {
|
6160
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
6161
|
+
}
|
6162
|
+
const urlPath = "/v2/withdrawtoken";
|
6163
|
+
const queryParams = /* @__PURE__ */ new Map();
|
6164
|
+
let bodyJson = "";
|
6165
|
+
bodyJson = JSON.stringify(body || {});
|
6166
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
6167
|
+
const fetchOptions = buildFetchOptions("POST", options, bodyJson);
|
6168
|
+
if (bearerToken) {
|
6169
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
6170
|
+
}
|
6171
|
+
return Promise.race([
|
6172
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
6173
|
+
if (response.status == 204) {
|
6174
|
+
return response;
|
6175
|
+
} else if (response.status >= 200 && response.status < 300) {
|
6176
|
+
return response.json();
|
6177
|
+
} else {
|
6178
|
+
throw response;
|
6179
|
+
}
|
6180
|
+
}),
|
6181
|
+
new Promise(
|
6182
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
6183
|
+
)
|
6184
|
+
]);
|
6185
|
+
}
|
6128
6186
|
/** */
|
6129
6187
|
getChannelCanvasDetail(bearerToken, id, clanId, channelId, options = {}) {
|
6130
6188
|
if (id === null || id === void 0) {
|
@@ -6963,12 +7021,6 @@ var _DefaultSocket = class _DefaultSocket {
|
|
6963
7021
|
return response.check_name_existed_event;
|
6964
7022
|
});
|
6965
7023
|
}
|
6966
|
-
sendToken(receiver_id, amount) {
|
6967
|
-
return __async(this, null, function* () {
|
6968
|
-
const response = yield this.send({ token_sent_event: { receiver_id, amount } });
|
6969
|
-
return response.token_sent_event;
|
6970
|
-
});
|
6971
|
-
}
|
6972
7024
|
pingPong() {
|
6973
7025
|
return __async(this, null, function* () {
|
6974
7026
|
if (!this.adapter.isOpen()) {
|
@@ -8836,6 +8888,26 @@ var Client = class {
|
|
8836
8888
|
});
|
8837
8889
|
});
|
8838
8890
|
}
|
8891
|
+
updateWallets(session, request) {
|
8892
|
+
return __async(this, null, function* () {
|
8893
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
8894
|
+
yield this.sessionRefresh(session);
|
8895
|
+
}
|
8896
|
+
return this.apiClient.sendToken(session.token, request).then((response) => {
|
8897
|
+
return Promise.resolve(response);
|
8898
|
+
});
|
8899
|
+
});
|
8900
|
+
}
|
8901
|
+
withdrawToken(session, request) {
|
8902
|
+
return __async(this, null, function* () {
|
8903
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
8904
|
+
yield this.sessionRefresh(session);
|
8905
|
+
}
|
8906
|
+
return this.apiClient.withdrawToken(session.token, request).then((response) => {
|
8907
|
+
return Promise.resolve(response);
|
8908
|
+
});
|
8909
|
+
});
|
8910
|
+
}
|
8839
8911
|
listStreamingChannels(session, clanId) {
|
8840
8912
|
return __async(this, null, function* () {
|
8841
8913
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired((Date.now() + this.expiredTimespanMs) / 1e3)) {
|
package/dist/socket.d.ts
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiPermissionUpdate, ApiRole, ApiRpc } from "./api.gen";
|
16
|
+
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiPermissionUpdate, ApiRole, ApiRpc, ApiTokenSentEvent } from "./api.gen";
|
17
17
|
import { Session } from "./session";
|
18
18
|
import { ChannelMessage, Notification } from "./client";
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
@@ -577,12 +577,6 @@ export interface PermissionChangedEvent {
|
|
577
577
|
user_id: string;
|
578
578
|
channel_id: string;
|
579
579
|
}
|
580
|
-
export interface TokenSentEvent {
|
581
|
-
sender_id: string;
|
582
|
-
sender_name: string;
|
583
|
-
receiver_id: string;
|
584
|
-
amount: number;
|
585
|
-
}
|
586
580
|
export interface MessageButtonClicked {
|
587
581
|
message_id: string;
|
588
582
|
channel_id: string;
|
@@ -632,8 +626,6 @@ export interface Socket {
|
|
632
626
|
writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
|
633
627
|
/** send voice leaved */
|
634
628
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
635
|
-
/** send token */
|
636
|
-
sendToken(receiver_id: string, amount: number): Promise<TokenSentEvent>;
|
637
629
|
/** Handle disconnect events received from the socket. */
|
638
630
|
ondisconnect: (evt: Event) => void;
|
639
631
|
/** Handle error events received from the socket. */
|
@@ -704,7 +696,7 @@ export interface Socket {
|
|
704
696
|
onpermissionset: (permission_set_event: PermissionSet) => void;
|
705
697
|
onpermissionchanged: (permission_changed_event: PermissionChangedEvent) => void;
|
706
698
|
onunmuteevent: (unmute_event: UnmuteEvent) => void;
|
707
|
-
ontokensent: (token:
|
699
|
+
ontokensent: (token: ApiTokenSentEvent) => void;
|
708
700
|
}
|
709
701
|
/** Reports an error received from a socket message. */
|
710
702
|
export interface SocketError {
|
@@ -778,7 +770,7 @@ export declare class DefaultSocket implements Socket {
|
|
778
770
|
onpermissionset(permission_set_event: PermissionSet): void;
|
779
771
|
onpermissionchanged(permission_changed_event: PermissionChangedEvent): void;
|
780
772
|
onunmuteevent(unmute_event: UnmuteEvent): void;
|
781
|
-
ontokensent(tokenSentEvent:
|
773
|
+
ontokensent(tokenSentEvent: ApiTokenSentEvent): void;
|
782
774
|
handleMessageButtonClick(messageButtonClicked: MessageButtonClicked): void;
|
783
775
|
send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | CustomStatusEvent | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
|
784
776
|
followUsers(userIds: string[]): Promise<Status>;
|
@@ -799,7 +791,6 @@ export declare class DefaultSocket implements Socket {
|
|
799
791
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
|
800
792
|
writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent>;
|
801
793
|
checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
|
802
|
-
sendToken(receiver_id: string, amount: number): Promise<TokenSentEvent>;
|
803
794
|
private pingPong;
|
804
795
|
}
|
805
796
|
export {};
|
package/package.json
CHANGED
package/socket.ts
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
16
|
|
17
|
-
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiPermissionUpdate, ApiRole, ApiRpc } from "./api.gen";
|
17
|
+
import { ApiChannelMessageHeader, ApiCreateEventRequest, ApiGiveCoffeeEvent, ApiMessageAttachment, ApiMessageMention, ApiMessageReaction, ApiMessageRef, ApiNotification, ApiPermissionUpdate, ApiRole, ApiRpc, ApiTokenSentEvent } from "./api.gen";
|
18
18
|
import { Session } from "./session";
|
19
19
|
import { ChannelMessage, Notification } from "./client";
|
20
20
|
import { WebSocketAdapter, WebSocketAdapterText } from "./web_socket_adapter";
|
@@ -808,16 +808,6 @@ export interface PermissionChangedEvent{
|
|
808
808
|
channel_id: string;
|
809
809
|
}
|
810
810
|
|
811
|
-
export interface TokenSentEvent {
|
812
|
-
// sender id
|
813
|
-
sender_id: string;
|
814
|
-
// sender name
|
815
|
-
sender_name: string;
|
816
|
-
// receiver
|
817
|
-
receiver_id: string;
|
818
|
-
// amount of token
|
819
|
-
amount: number;
|
820
|
-
}
|
821
811
|
export interface MessageButtonClicked {
|
822
812
|
message_id: string;
|
823
813
|
channel_id: string;
|
@@ -888,9 +878,6 @@ export interface Socket {
|
|
888
878
|
/** send voice leaved */
|
889
879
|
writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string) : Promise<VoiceLeavedEvent>;
|
890
880
|
|
891
|
-
/** send token */
|
892
|
-
sendToken(receiver_id: string, amount: number) : Promise<TokenSentEvent>;
|
893
|
-
|
894
881
|
/** Handle disconnect events received from the socket. */
|
895
882
|
ondisconnect: (evt: Event) => void;
|
896
883
|
|
@@ -1025,7 +1012,7 @@ export interface Socket {
|
|
1025
1012
|
|
1026
1013
|
onunmuteevent: (unmute_event: UnmuteEvent) => void;
|
1027
1014
|
|
1028
|
-
ontokensent: (token:
|
1015
|
+
ontokensent: (token: ApiTokenSentEvent) => void;
|
1029
1016
|
}
|
1030
1017
|
|
1031
1018
|
/** Reports an error received from a socket message. */
|
@@ -1232,7 +1219,7 @@ export class DefaultSocket implements Socket {
|
|
1232
1219
|
} else if(message.unmute_event){
|
1233
1220
|
this.onunmuteevent(<UnmuteEvent>message.unmute_event);
|
1234
1221
|
} else if (message.token_sent_event) {
|
1235
|
-
this.ontokensent(<
|
1222
|
+
this.ontokensent(<ApiTokenSentEvent>message.token_sent_event);
|
1236
1223
|
} else if (message.message_button_clicked){
|
1237
1224
|
this.handleMessageButtonClick(<MessageButtonClicked>message.message_button_clicked)
|
1238
1225
|
} else {
|
@@ -1561,7 +1548,7 @@ export class DefaultSocket implements Socket {
|
|
1561
1548
|
}
|
1562
1549
|
}
|
1563
1550
|
|
1564
|
-
ontokensent(tokenSentEvent:
|
1551
|
+
ontokensent(tokenSentEvent: ApiTokenSentEvent) {
|
1565
1552
|
if (this.verbose && window && window.console) {
|
1566
1553
|
console.log(tokenSentEvent);
|
1567
1554
|
}
|
@@ -1723,11 +1710,6 @@ export class DefaultSocket implements Socket {
|
|
1723
1710
|
return response.check_name_existed_event;
|
1724
1711
|
}
|
1725
1712
|
|
1726
|
-
async sendToken(receiver_id: string, amount: number) : Promise<TokenSentEvent> {
|
1727
|
-
const response = await this.send({token_sent_event: {receiver_id: receiver_id, amount: amount}});
|
1728
|
-
return response.token_sent_event;
|
1729
|
-
}
|
1730
|
-
|
1731
1713
|
private async pingPong(): Promise<void> {
|
1732
1714
|
if (!this.adapter.isOpen()) {
|
1733
1715
|
return;
|