mezon-js 2.13.22 → 2.13.24
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/api.gen.ts +45 -6
- package/client.ts +21 -0
- package/dist/api.gen.d.ts +8 -3
- package/dist/client.d.ts +3 -1
- package/dist/mezon-js.cjs.js +42 -2
- package/dist/mezon-js.esm.mjs +42 -2
- package/package.json +1 -1
- package/session.ts +2 -2
package/api.gen.ts
CHANGED
|
@@ -569,6 +569,12 @@ export interface ApiCategoryDescList {
|
|
|
569
569
|
categorydesc?: Array<ApiCategoryDesc>;
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
+
/** */
|
|
573
|
+
export interface ApiUpdateUsernameRequest {
|
|
574
|
+
//
|
|
575
|
+
username?: string;
|
|
576
|
+
}
|
|
577
|
+
|
|
572
578
|
/** */
|
|
573
579
|
export interface ApiCategoryOrderUpdate {
|
|
574
580
|
//
|
|
@@ -2604,11 +2610,13 @@ export interface ApiUpdateAccountRequest {
|
|
|
2604
2610
|
about_me?: string;
|
|
2605
2611
|
//A URL for an avatar image.
|
|
2606
2612
|
avatar_url?: string;
|
|
2607
|
-
//
|
|
2608
|
-
dob?: string;
|
|
2609
2613
|
//The display name of the user.
|
|
2610
2614
|
display_name?: string;
|
|
2611
2615
|
//
|
|
2616
|
+
dob?: string;
|
|
2617
|
+
//The email of the user's account.
|
|
2618
|
+
email?: string;
|
|
2619
|
+
//
|
|
2612
2620
|
encrypt_private_key?: string;
|
|
2613
2621
|
//The language expected to be a tag which follows the BCP-47 spec.
|
|
2614
2622
|
lang_tag?: string;
|
|
@@ -2620,10 +2628,6 @@ export interface ApiUpdateAccountRequest {
|
|
|
2620
2628
|
splash_screen?: string;
|
|
2621
2629
|
//The timezone set by the user.
|
|
2622
2630
|
timezone?: string;
|
|
2623
|
-
//The username of the user's account.
|
|
2624
|
-
username?: string;
|
|
2625
|
-
//The email of the user's account.
|
|
2626
|
-
email?: string;
|
|
2627
2631
|
}
|
|
2628
2632
|
|
|
2629
2633
|
/** */
|
|
@@ -11523,4 +11527,39 @@ export class MezonApi {
|
|
|
11523
11527
|
]);
|
|
11524
11528
|
}
|
|
11525
11529
|
|
|
11530
|
+
/** Update username */
|
|
11531
|
+
updateUsername(bearerToken: string,
|
|
11532
|
+
body:ApiUpdateUsernameRequest,
|
|
11533
|
+
options: any = {}): Promise<ApiSession> {
|
|
11534
|
+
|
|
11535
|
+
if (body === null || body === undefined) {
|
|
11536
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
|
11537
|
+
}
|
|
11538
|
+
const urlPath = "/v2/username";
|
|
11539
|
+
const queryParams = new Map<string, any>();
|
|
11540
|
+
|
|
11541
|
+
let bodyJson : string = "";
|
|
11542
|
+
bodyJson = JSON.stringify(body || {});
|
|
11543
|
+
|
|
11544
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
11545
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
|
11546
|
+
if (bearerToken) {
|
|
11547
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
|
11548
|
+
}
|
|
11549
|
+
|
|
11550
|
+
return Promise.race([
|
|
11551
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
11552
|
+
if (response.status == 204) {
|
|
11553
|
+
return response;
|
|
11554
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
11555
|
+
return response.json();
|
|
11556
|
+
} else {
|
|
11557
|
+
throw response;
|
|
11558
|
+
}
|
|
11559
|
+
}),
|
|
11560
|
+
new Promise((_, reject) =>
|
|
11561
|
+
setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
11562
|
+
),
|
|
11563
|
+
]);
|
|
11564
|
+
}
|
|
11526
11565
|
}
|
package/client.ts
CHANGED
|
@@ -178,6 +178,7 @@ import {
|
|
|
178
178
|
ApiFriend,
|
|
179
179
|
ApiListClanUnreadMsgIndicatorResponse,
|
|
180
180
|
ApiAddFriendsResponse,
|
|
181
|
+
ApiUpdateUsernameRequest,
|
|
181
182
|
} from "./api.gen";
|
|
182
183
|
|
|
183
184
|
import { Session } from "./session";
|
|
@@ -2100,6 +2101,26 @@ export class Client {
|
|
|
2100
2101
|
});
|
|
2101
2102
|
}
|
|
2102
2103
|
|
|
2104
|
+
/** Update fields in the current user's account. */
|
|
2105
|
+
async updateUsername(
|
|
2106
|
+
session: Session,
|
|
2107
|
+
request: ApiUpdateUsernameRequest
|
|
2108
|
+
): Promise<ApiSession> {
|
|
2109
|
+
if (
|
|
2110
|
+
this.autoRefreshSession &&
|
|
2111
|
+
session.refresh_token &&
|
|
2112
|
+
session.isexpired(Date.now() / 1000)
|
|
2113
|
+
) {
|
|
2114
|
+
await this.sessionRefresh(session);
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
return this.apiClient
|
|
2118
|
+
.updateUsername(session.token, request)
|
|
2119
|
+
.then((response: ApiSession) => {
|
|
2120
|
+
return Promise.resolve(response);
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2103
2124
|
/** Update fields in the current user's account. */
|
|
2104
2125
|
async updateAccount(
|
|
2105
2126
|
session: Session,
|
package/dist/api.gen.d.ts
CHANGED
|
@@ -328,6 +328,10 @@ export interface ApiCategoryDescList {
|
|
|
328
328
|
categorydesc?: Array<ApiCategoryDesc>;
|
|
329
329
|
}
|
|
330
330
|
/** */
|
|
331
|
+
export interface ApiUpdateUsernameRequest {
|
|
332
|
+
username?: string;
|
|
333
|
+
}
|
|
334
|
+
/** */
|
|
331
335
|
export interface ApiCategoryOrderUpdate {
|
|
332
336
|
category_id?: string;
|
|
333
337
|
order?: number;
|
|
@@ -1490,16 +1494,15 @@ export interface ApiTransactionDetail {
|
|
|
1490
1494
|
export interface ApiUpdateAccountRequest {
|
|
1491
1495
|
about_me?: string;
|
|
1492
1496
|
avatar_url?: string;
|
|
1493
|
-
dob?: string;
|
|
1494
1497
|
display_name?: string;
|
|
1498
|
+
dob?: string;
|
|
1499
|
+
email?: string;
|
|
1495
1500
|
encrypt_private_key?: string;
|
|
1496
1501
|
lang_tag?: string;
|
|
1497
1502
|
location?: string;
|
|
1498
1503
|
logo?: string;
|
|
1499
1504
|
splash_screen?: string;
|
|
1500
1505
|
timezone?: string;
|
|
1501
|
-
username?: string;
|
|
1502
|
-
email?: string;
|
|
1503
1506
|
}
|
|
1504
1507
|
/** */
|
|
1505
1508
|
export interface ApiUpdateCategoryDescRequest {
|
|
@@ -2373,4 +2376,6 @@ export declare class MezonApi {
|
|
|
2373
2376
|
isFollower(bearerToken: string, body: ApiIsFollowerRequest, options?: any): Promise<ApiIsFollowerResponse>;
|
|
2374
2377
|
/** */
|
|
2375
2378
|
transferOwnership(bearerToken: string, body: ApiTransferOwnershipRequest, options?: any): Promise<any>;
|
|
2379
|
+
/** Update username */
|
|
2380
|
+
updateUsername(bearerToken: string, body: ApiUpdateUsernameRequest, options?: any): Promise<ApiSession>;
|
|
2376
2381
|
}
|
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, ApiAccountMezon, ApiAccountEmail, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiNotificationList, ApiUpdateAccountRequest, ApiSession, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, 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, ApiChannelCanvasListResponse, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog, ApiTokenSentEvent, MezonDeleteWebhookByIdBody, ApiListOnboardingResponse, ApiCreateOnboardingRequest, MezonUpdateOnboardingBody, ApiOnboardingItem, ApiGenerateClanWebhookRequest, ApiGenerateClanWebhookResponse, ApiListClanWebhookResponse, MezonUpdateClanWebhookByIdBody, MezonUpdateClanDescBody, ApiUserStatusUpdate, ApiUserStatus, ApiListOnboardingStepResponse, MezonUpdateOnboardingStepByClanIdBody, ApiWalletLedgerList, ApiSdTopicList, ApiSdTopicRequest, ApiSdTopic, MezonUpdateEventBody, ApiTransactionDetail, MezonapiCreateRoomChannelApps, ApiGenerateMeetTokenRequest, ApiGenerateMeetTokenResponse, ApiMezonOauthClientList, ApiMezonOauthClient, ApiCreateHashChannelAppsResponse, ApiEmojiRecentList, ApiUserEventRequest, ApiUpdateRoleOrderRequest, ApiGenerateMezonMeetResponse, ApiGenerateMeetTokenExternalResponse, ApiUpdateClanOrderRequest, ApiMessage2InboxRequest, ApiListClanDiscover, ApiClanDiscoverRequest, ApiQuickMenuAccessList, ApiQuickMenuAccessRequest, ApiUnlockedItemRequest, ApiForSaleItemList, ApiUnlockedItemResponse, ApiIsFollowerResponse, ApiIsFollowerRequest, ApiTransferOwnershipRequest, ApiMeetParticipantRequest, ApiStoreWalletKeyRequest, ApiLinkAccountConfirmRequest, ApiLinkAccountMezon, ApiUser, ApiFriend, ApiListClanUnreadMsgIndicatorResponse, ApiAddFriendsResponse } from "./api.gen";
|
|
16
|
+
import { ApiAccount, ApiAccountMezon, ApiAccountEmail, ApiChannelDescList, ApiChannelDescription, ApiCreateChannelDescRequest, ApiDeleteRoleRequest, ApiClanDescList, ApiCreateClanDescRequest, ApiClanDesc, ApiCategoryDesc, ApiCategoryDescList, ApiPermissionList, ApiRoleUserList, ApiRole, ApiCreateRoleRequest, ApiAddRoleChannelDescRequest, ApiCreateCategoryDescRequest, ApiUpdateCategoryDescRequest, ApiEvent, ApiNotificationList, ApiUpdateAccountRequest, ApiSession, ApiClanProfile, ApiChannelUserList, ApiClanUserList, ApiLinkInviteUserRequest, 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, ApiChannelCanvasListResponse, ApiEditChannelCanvasRequest, ApiChannelSettingListResponse, ApiAddFavoriteChannelResponse, ApiRegistFcmDeviceTokenResponse, ApiListUserActivity, ApiCreateActivityRequest, ApiLoginIDResponse, ApiLoginRequest, ApiConfirmLoginRequest, ApiUserActivity, ApiChanEncryptionMethod, ApiGetPubKeysResponse, ApiPubKey, ApiGetKeyServerResp, MezonapiListAuditLog, ApiTokenSentEvent, MezonDeleteWebhookByIdBody, ApiListOnboardingResponse, ApiCreateOnboardingRequest, MezonUpdateOnboardingBody, ApiOnboardingItem, ApiGenerateClanWebhookRequest, ApiGenerateClanWebhookResponse, ApiListClanWebhookResponse, MezonUpdateClanWebhookByIdBody, MezonUpdateClanDescBody, ApiUserStatusUpdate, ApiUserStatus, ApiListOnboardingStepResponse, MezonUpdateOnboardingStepByClanIdBody, ApiWalletLedgerList, ApiSdTopicList, ApiSdTopicRequest, ApiSdTopic, MezonUpdateEventBody, ApiTransactionDetail, MezonapiCreateRoomChannelApps, ApiGenerateMeetTokenRequest, ApiGenerateMeetTokenResponse, ApiMezonOauthClientList, ApiMezonOauthClient, ApiCreateHashChannelAppsResponse, ApiEmojiRecentList, ApiUserEventRequest, ApiUpdateRoleOrderRequest, ApiGenerateMezonMeetResponse, ApiGenerateMeetTokenExternalResponse, ApiUpdateClanOrderRequest, ApiMessage2InboxRequest, ApiListClanDiscover, ApiClanDiscoverRequest, ApiQuickMenuAccessList, ApiQuickMenuAccessRequest, ApiUnlockedItemRequest, ApiForSaleItemList, ApiUnlockedItemResponse, ApiIsFollowerResponse, ApiIsFollowerRequest, ApiTransferOwnershipRequest, ApiMeetParticipantRequest, ApiStoreWalletKeyRequest, ApiLinkAccountConfirmRequest, ApiLinkAccountMezon, ApiUser, ApiFriend, ApiListClanUnreadMsgIndicatorResponse, ApiAddFriendsResponse, ApiUpdateUsernameRequest } from "./api.gen";
|
|
17
17
|
import { Session } from "./session";
|
|
18
18
|
import { Socket } from "./socket";
|
|
19
19
|
import { WebSocketAdapter } from "./web_socket_adapter";
|
|
@@ -355,6 +355,8 @@ export declare class Client {
|
|
|
355
355
|
/** Remove an email+password from the social profiles on the current user's account. */
|
|
356
356
|
unlinkEmail(session: Session, request: ApiAccountEmail): Promise<boolean>;
|
|
357
357
|
/** Update fields in the current user's account. */
|
|
358
|
+
updateUsername(session: Session, request: ApiUpdateUsernameRequest): Promise<ApiSession>;
|
|
359
|
+
/** Update fields in the current user's account. */
|
|
358
360
|
updateAccount(session: Session, request: ApiUpdateAccountRequest): Promise<boolean>;
|
|
359
361
|
/** Update fields in a given channel */
|
|
360
362
|
updateChannelDesc(session: Session, channelId: string, request: ApiUpdateChannelDescRequest): Promise<boolean>;
|
package/dist/mezon-js.cjs.js
CHANGED
|
@@ -7056,6 +7056,35 @@ var MezonApi = class {
|
|
|
7056
7056
|
)
|
|
7057
7057
|
]);
|
|
7058
7058
|
}
|
|
7059
|
+
/** Update username */
|
|
7060
|
+
updateUsername(bearerToken, body, options = {}) {
|
|
7061
|
+
if (body === null || body === void 0) {
|
|
7062
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
|
7063
|
+
}
|
|
7064
|
+
const urlPath = "/v2/username";
|
|
7065
|
+
const queryParams = /* @__PURE__ */ new Map();
|
|
7066
|
+
let bodyJson = "";
|
|
7067
|
+
bodyJson = JSON.stringify(body || {});
|
|
7068
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
7069
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
|
7070
|
+
if (bearerToken) {
|
|
7071
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
|
7072
|
+
}
|
|
7073
|
+
return Promise.race([
|
|
7074
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
7075
|
+
if (response.status == 204) {
|
|
7076
|
+
return response;
|
|
7077
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
7078
|
+
return response.json();
|
|
7079
|
+
} else {
|
|
7080
|
+
throw response;
|
|
7081
|
+
}
|
|
7082
|
+
}),
|
|
7083
|
+
new Promise(
|
|
7084
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
7085
|
+
)
|
|
7086
|
+
]);
|
|
7087
|
+
}
|
|
7059
7088
|
};
|
|
7060
7089
|
|
|
7061
7090
|
// session.ts
|
|
@@ -7070,10 +7099,10 @@ var Session = class _Session {
|
|
|
7070
7099
|
this.update(token, refresh_token, is_remember);
|
|
7071
7100
|
}
|
|
7072
7101
|
isexpired(currenttime) {
|
|
7073
|
-
return this.expires_at - currenttime <=
|
|
7102
|
+
return this.expires_at - currenttime <= 5;
|
|
7074
7103
|
}
|
|
7075
7104
|
isrefreshexpired(currenttime) {
|
|
7076
|
-
return this.refresh_expires_at - currenttime <=
|
|
7105
|
+
return this.refresh_expires_at - currenttime <= 5;
|
|
7077
7106
|
}
|
|
7078
7107
|
update(token, refreshToken, isRemember) {
|
|
7079
7108
|
const tokenParts = token.split(".");
|
|
@@ -9425,6 +9454,17 @@ var Client = class {
|
|
|
9425
9454
|
});
|
|
9426
9455
|
}
|
|
9427
9456
|
/** Update fields in the current user's account. */
|
|
9457
|
+
updateUsername(session, request) {
|
|
9458
|
+
return __async(this, null, function* () {
|
|
9459
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
|
|
9460
|
+
yield this.sessionRefresh(session);
|
|
9461
|
+
}
|
|
9462
|
+
return this.apiClient.updateUsername(session.token, request).then((response) => {
|
|
9463
|
+
return Promise.resolve(response);
|
|
9464
|
+
});
|
|
9465
|
+
});
|
|
9466
|
+
}
|
|
9467
|
+
/** Update fields in the current user's account. */
|
|
9428
9468
|
updateAccount(session, request) {
|
|
9429
9469
|
return __async(this, null, function* () {
|
|
9430
9470
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
|
package/dist/mezon-js.esm.mjs
CHANGED
|
@@ -7022,6 +7022,35 @@ var MezonApi = class {
|
|
|
7022
7022
|
)
|
|
7023
7023
|
]);
|
|
7024
7024
|
}
|
|
7025
|
+
/** Update username */
|
|
7026
|
+
updateUsername(bearerToken, body, options = {}) {
|
|
7027
|
+
if (body === null || body === void 0) {
|
|
7028
|
+
throw new Error("'body' is a required parameter but is null or undefined.");
|
|
7029
|
+
}
|
|
7030
|
+
const urlPath = "/v2/username";
|
|
7031
|
+
const queryParams = /* @__PURE__ */ new Map();
|
|
7032
|
+
let bodyJson = "";
|
|
7033
|
+
bodyJson = JSON.stringify(body || {});
|
|
7034
|
+
const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
|
|
7035
|
+
const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
|
|
7036
|
+
if (bearerToken) {
|
|
7037
|
+
fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
|
|
7038
|
+
}
|
|
7039
|
+
return Promise.race([
|
|
7040
|
+
fetch(fullUrl, fetchOptions).then((response) => {
|
|
7041
|
+
if (response.status == 204) {
|
|
7042
|
+
return response;
|
|
7043
|
+
} else if (response.status >= 200 && response.status < 300) {
|
|
7044
|
+
return response.json();
|
|
7045
|
+
} else {
|
|
7046
|
+
throw response;
|
|
7047
|
+
}
|
|
7048
|
+
}),
|
|
7049
|
+
new Promise(
|
|
7050
|
+
(_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
|
|
7051
|
+
)
|
|
7052
|
+
]);
|
|
7053
|
+
}
|
|
7025
7054
|
};
|
|
7026
7055
|
|
|
7027
7056
|
// session.ts
|
|
@@ -7036,10 +7065,10 @@ var Session = class _Session {
|
|
|
7036
7065
|
this.update(token, refresh_token, is_remember);
|
|
7037
7066
|
}
|
|
7038
7067
|
isexpired(currenttime) {
|
|
7039
|
-
return this.expires_at - currenttime <=
|
|
7068
|
+
return this.expires_at - currenttime <= 5;
|
|
7040
7069
|
}
|
|
7041
7070
|
isrefreshexpired(currenttime) {
|
|
7042
|
-
return this.refresh_expires_at - currenttime <=
|
|
7071
|
+
return this.refresh_expires_at - currenttime <= 5;
|
|
7043
7072
|
}
|
|
7044
7073
|
update(token, refreshToken, isRemember) {
|
|
7045
7074
|
const tokenParts = token.split(".");
|
|
@@ -9391,6 +9420,17 @@ var Client = class {
|
|
|
9391
9420
|
});
|
|
9392
9421
|
}
|
|
9393
9422
|
/** Update fields in the current user's account. */
|
|
9423
|
+
updateUsername(session, request) {
|
|
9424
|
+
return __async(this, null, function* () {
|
|
9425
|
+
if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
|
|
9426
|
+
yield this.sessionRefresh(session);
|
|
9427
|
+
}
|
|
9428
|
+
return this.apiClient.updateUsername(session.token, request).then((response) => {
|
|
9429
|
+
return Promise.resolve(response);
|
|
9430
|
+
});
|
|
9431
|
+
});
|
|
9432
|
+
}
|
|
9433
|
+
/** Update fields in the current user's account. */
|
|
9394
9434
|
updateAccount(session, request) {
|
|
9395
9435
|
return __async(this, null, function* () {
|
|
9396
9436
|
if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
|
package/package.json
CHANGED
package/session.ts
CHANGED
|
@@ -72,11 +72,11 @@ export class Session implements ISession {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
isexpired(currenttime: number): boolean {
|
|
75
|
-
return (this.expires_at! - currenttime) <=
|
|
75
|
+
return (this.expires_at! - currenttime) <= 5; // expire 5s before server expired
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
isrefreshexpired(currenttime: number): boolean {
|
|
79
|
-
return (this.refresh_expires_at! - currenttime) <=
|
|
79
|
+
return (this.refresh_expires_at! - currenttime) <= 5;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
update(token: string, refreshToken: string, isRemember: boolean) {
|