@zqagent/shared 0.3.8 → 0.3.9
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/dist/hub-api.cjs +32 -2
- package/dist/hub-api.cjs.map +1 -1
- package/dist/hub-api.d.cts +24 -2
- package/dist/hub-api.d.ts +24 -2
- package/dist/hub-api.js +28 -1
- package/dist/hub-api.js.map +1 -1
- package/dist/{index-DokiNlGJ.d.cts → index-DulV0GQp.d.cts} +15 -1
- package/dist/{index-DokiNlGJ.d.ts → index-DulV0GQp.d.ts} +15 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/notify/index.cjs +2 -0
- package/dist/notify/index.cjs.map +1 -1
- package/dist/notify/index.d.cts +1 -1
- package/dist/notify/index.d.ts +1 -1
- package/dist/notify/index.js +2 -0
- package/dist/notify/index.js.map +1 -1
- package/package.json +1 -1
package/dist/hub-api.d.cts
CHANGED
|
@@ -342,6 +342,17 @@ interface HubNotificationView {
|
|
|
342
342
|
readAt?: string;
|
|
343
343
|
createdAt: string;
|
|
344
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* 判断某个请求错误是否意味着「当前会话已不可用」(需要重新登录)。
|
|
347
|
+
*
|
|
348
|
+
* 依据 HTTP 状态与错误码,不看文案——文案会随语言与措辞调整。
|
|
349
|
+
*/
|
|
350
|
+
declare function isSessionInvalidError(e: unknown): boolean;
|
|
351
|
+
type HubSessionInvalidHandler = (info: {
|
|
352
|
+
status: number;
|
|
353
|
+
code?: string;
|
|
354
|
+
}) => void;
|
|
355
|
+
declare function setHubSessionInvalidHandler(handler: HubSessionInvalidHandler | null): void;
|
|
345
356
|
declare function hubRegister(baseUrl: string, email: string, password: string): Promise<{
|
|
346
357
|
token: string;
|
|
347
358
|
}>;
|
|
@@ -482,13 +493,19 @@ declare function hubTerminalCredential(baseUrl: string, token: string, fleetId:
|
|
|
482
493
|
* = 本人全部节点,供账号级实时通道一条 WSS 订阅所有节点。
|
|
483
494
|
*/
|
|
484
495
|
declare function hubRealtimeCredential(baseUrl: string, token: string, client?: string): Promise<HubGatewayCredentialView>;
|
|
485
|
-
/**
|
|
496
|
+
/**
|
|
497
|
+
* 修改密码(手机号账号需短信验证码,可附原密码)。
|
|
498
|
+
*
|
|
499
|
+
* 改密后服务端会作废该账号已签发的全部令牌,并返回一个新令牌用于当前设备续期:
|
|
500
|
+
* 调用方必须用 `token` 覆盖本地保存的令牌,否则下一次请求就会被判为未登录。
|
|
501
|
+
*/
|
|
486
502
|
declare function hubChangePassword(baseUrl: string, token: string, input: {
|
|
487
503
|
oldPassword?: string;
|
|
488
504
|
newPassword: string;
|
|
489
505
|
code?: string;
|
|
490
506
|
}): Promise<{
|
|
491
507
|
changed: boolean;
|
|
508
|
+
token?: string;
|
|
492
509
|
}>;
|
|
493
510
|
declare function hubListFleets(baseUrl: string, token: string): Promise<HubFleetSummary[]>;
|
|
494
511
|
declare function hubCreateFleet(baseUrl: string, token: string, name: string): Promise<HubFleetSummary>;
|
|
@@ -920,6 +937,11 @@ declare function hubAdminSetRole(baseUrl: string, token: string, userId: string,
|
|
|
920
937
|
id: string;
|
|
921
938
|
role: string;
|
|
922
939
|
}>;
|
|
940
|
+
/** 管理员重置用户密码(无需原密码):重置后用户可用新密码登录 */
|
|
941
|
+
declare function hubAdminResetPassword(baseUrl: string, token: string, userId: string, newPassword: string): Promise<{
|
|
942
|
+
id: string;
|
|
943
|
+
changed: boolean;
|
|
944
|
+
}>;
|
|
923
945
|
/** 给用户发送站内通知 */
|
|
924
946
|
declare function hubAdminNotifyUser(baseUrl: string, token: string, userId: string, input: {
|
|
925
947
|
title: string;
|
|
@@ -1674,4 +1696,4 @@ declare function hubStatement(baseUrl: string, token: string, range?: {
|
|
|
1674
1696
|
to?: string;
|
|
1675
1697
|
}): Promise<HubStatement>;
|
|
1676
1698
|
|
|
1677
|
-
export { type HubAdminAuditEntry, type HubAdminNode, type HubAdminOrderRow, type HubAdminOverview, type HubAdminRechargeSource, type HubAdminRegisterAttempt, type HubAdminRole, type HubAdminTopupRow, type HubAdminUserDetail, type HubAdminUserRow, type HubAdminUserStatus, type HubAdminWalletView, type HubAlertEventView, type HubApiServiceView, type HubAuthInput, type HubBillingDayPoint, type HubBillingOrderRow, type HubBillingReport, type HubCaptchaView, type HubCommunityQrResponse, type HubCommunityQrView, type HubEnrollmentView, type HubFleetSummary, type HubGatewayCredentialView, type HubGatewayFleet, type HubNodeAccessView, type HubNodeActivityItem, type HubNodeBillingConfigResponse, type HubNodeBillingConfigView, type HubNodeBillingView, type HubNodeDetail, type HubNodeGrantView, type HubNodeSummary, type HubNodeTotals, type HubNotificationView, type HubNotifyChannelAvailability, type HubNotifyChannelType, type HubNotifyChannelView, type HubNotifyDeliveryResult, type HubNotifySettingsResponse, type HubNotifySettingsView, type HubOrderView, type HubOutgoingGrant, type HubPairingView, type HubPins, type HubPlan, type HubProjectPage, type HubProjectRow, type HubProjectTask, type HubSendCodeStatus, type HubSharedNode, type HubSmsPurpose, type HubSmtpResponse, type HubSmtpView, type HubSocialQrItem, type HubSocialQrsResponse, type HubStatement, type HubSubscriptionView, type HubTaskCounts, type HubTaskPage, type HubTaskRow, type HubTerminalCredential, type HubUsageAgg, type HubUsageNodeRow, type HubUsageProjectRow, type HubUsageView, type HubUserView, type HubWalletEntryView, type HubWalletView, type HubWebhookFormat, type HubZqaiApiRequest, type HubZqaiBalance, type HubZqaiRecharge, type HubZqaiRecharges, type HubZqaiUsage, type HubZqaiUsageBucket, type HubZqaiUsageSummary, activityKey, compareByActivity, hubAdminAddSocialQr, hubAdminAudit, hubAdminBillingReport, hubAdminClearCommunity, hubAdminCommunity, hubAdminDeleteFleet, hubAdminDeleteNode, hubAdminDeleteUser, hubAdminDisableUser, hubAdminEnableUser, hubAdminLinkZqai, hubAdminMarkOrder, hubAdminNodeBilling, hubAdminNotifyUser, hubAdminOrders, hubAdminOverview, hubAdminRefund, hubAdminRegisterAttempts, hubAdminRemoveSocialQr, hubAdminSetRole, hubAdminSocialQrs, hubAdminTopup, hubAdminUpdateCommunity, hubAdminUpdateNodeBilling, hubAdminUpdateSocialQr, hubAdminUpdateUser, hubAdminUserDetail, hubAdminUsers, hubAdminWallet, hubApiService, hubApiTopup, hubBillingExportUrl, hubCaptcha, hubChangePassword, hubChannels, hubClearSmtpSettings, hubCreateEnrollment, hubCreateFleet, hubCreateNodeGrant, hubDeleteFleet, hubDeleteNode, hubEnrollByAccount, hubEnrollByCode, hubEnrollByToken, hubEnrollNode, hubFleetPairing, hubGetNode, hubGetNodeById, hubGetUsage, hubLeaveSharedNode, hubListFleets, hubListNodeGrants, hubListNodes, hubListProjects, hubListTasks, hubLogin, hubLoginAccount, hubMarkNotificationsRead, hubMe, hubMoveNode, hubNodeActivity, hubNodeUsageReport, hubNotificationStream, hubNotifications, hubNotifyEvents, hubNotifyPreview, hubNotifySettings, hubOrders, hubOutgoingGrants, hubPins, hubPlans, hubRealtimeCredential, hubRegister, hubRegisterAccount, hubRequestApiService, hubResetPassword, hubRevokeNodeGrant, hubRotateApiKey, hubSaveNotifySettings, hubSavePins, hubSaveSmtpSettings, hubSendCodeStatus, hubSendEmailCode, hubSendSms, hubSharedNodes, hubSmsStatus, hubSmtpSettings, hubStatement, hubSubscription, hubSyncOrder, hubTerminalCredential, hubTestNotify, hubUpdateFleet, hubUpdateNode, hubUpdateNodeLabelSelf, hubUpdateProfile, hubWallet, hubWalletTopup, setHubBaseResolver };
|
|
1699
|
+
export { type HubAdminAuditEntry, type HubAdminNode, type HubAdminOrderRow, type HubAdminOverview, type HubAdminRechargeSource, type HubAdminRegisterAttempt, type HubAdminRole, type HubAdminTopupRow, type HubAdminUserDetail, type HubAdminUserRow, type HubAdminUserStatus, type HubAdminWalletView, type HubAlertEventView, type HubApiServiceView, type HubAuthInput, type HubBillingDayPoint, type HubBillingOrderRow, type HubBillingReport, type HubCaptchaView, type HubCommunityQrResponse, type HubCommunityQrView, type HubEnrollmentView, type HubFleetSummary, type HubGatewayCredentialView, type HubGatewayFleet, type HubNodeAccessView, type HubNodeActivityItem, type HubNodeBillingConfigResponse, type HubNodeBillingConfigView, type HubNodeBillingView, type HubNodeDetail, type HubNodeGrantView, type HubNodeSummary, type HubNodeTotals, type HubNotificationView, type HubNotifyChannelAvailability, type HubNotifyChannelType, type HubNotifyChannelView, type HubNotifyDeliveryResult, type HubNotifySettingsResponse, type HubNotifySettingsView, type HubOrderView, type HubOutgoingGrant, type HubPairingView, type HubPins, type HubPlan, type HubProjectPage, type HubProjectRow, type HubProjectTask, type HubSendCodeStatus, type HubSessionInvalidHandler, type HubSharedNode, type HubSmsPurpose, type HubSmtpResponse, type HubSmtpView, type HubSocialQrItem, type HubSocialQrsResponse, type HubStatement, type HubSubscriptionView, type HubTaskCounts, type HubTaskPage, type HubTaskRow, type HubTerminalCredential, type HubUsageAgg, type HubUsageNodeRow, type HubUsageProjectRow, type HubUsageView, type HubUserView, type HubWalletEntryView, type HubWalletView, type HubWebhookFormat, type HubZqaiApiRequest, type HubZqaiBalance, type HubZqaiRecharge, type HubZqaiRecharges, type HubZqaiUsage, type HubZqaiUsageBucket, type HubZqaiUsageSummary, activityKey, compareByActivity, hubAdminAddSocialQr, hubAdminAudit, hubAdminBillingReport, hubAdminClearCommunity, hubAdminCommunity, hubAdminDeleteFleet, hubAdminDeleteNode, hubAdminDeleteUser, hubAdminDisableUser, hubAdminEnableUser, hubAdminLinkZqai, hubAdminMarkOrder, hubAdminNodeBilling, hubAdminNotifyUser, hubAdminOrders, hubAdminOverview, hubAdminRefund, hubAdminRegisterAttempts, hubAdminRemoveSocialQr, hubAdminResetPassword, hubAdminSetRole, hubAdminSocialQrs, hubAdminTopup, hubAdminUpdateCommunity, hubAdminUpdateNodeBilling, hubAdminUpdateSocialQr, hubAdminUpdateUser, hubAdminUserDetail, hubAdminUsers, hubAdminWallet, hubApiService, hubApiTopup, hubBillingExportUrl, hubCaptcha, hubChangePassword, hubChannels, hubClearSmtpSettings, hubCreateEnrollment, hubCreateFleet, hubCreateNodeGrant, hubDeleteFleet, hubDeleteNode, hubEnrollByAccount, hubEnrollByCode, hubEnrollByToken, hubEnrollNode, hubFleetPairing, hubGetNode, hubGetNodeById, hubGetUsage, hubLeaveSharedNode, hubListFleets, hubListNodeGrants, hubListNodes, hubListProjects, hubListTasks, hubLogin, hubLoginAccount, hubMarkNotificationsRead, hubMe, hubMoveNode, hubNodeActivity, hubNodeUsageReport, hubNotificationStream, hubNotifications, hubNotifyEvents, hubNotifyPreview, hubNotifySettings, hubOrders, hubOutgoingGrants, hubPins, hubPlans, hubRealtimeCredential, hubRegister, hubRegisterAccount, hubRequestApiService, hubResetPassword, hubRevokeNodeGrant, hubRotateApiKey, hubSaveNotifySettings, hubSavePins, hubSaveSmtpSettings, hubSendCodeStatus, hubSendEmailCode, hubSendSms, hubSharedNodes, hubSmsStatus, hubSmtpSettings, hubStatement, hubSubscription, hubSyncOrder, hubTerminalCredential, hubTestNotify, hubUpdateFleet, hubUpdateNode, hubUpdateNodeLabelSelf, hubUpdateProfile, hubWallet, hubWalletTopup, isSessionInvalidError, setHubBaseResolver, setHubSessionInvalidHandler };
|
package/dist/hub-api.d.ts
CHANGED
|
@@ -342,6 +342,17 @@ interface HubNotificationView {
|
|
|
342
342
|
readAt?: string;
|
|
343
343
|
createdAt: string;
|
|
344
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* 判断某个请求错误是否意味着「当前会话已不可用」(需要重新登录)。
|
|
347
|
+
*
|
|
348
|
+
* 依据 HTTP 状态与错误码,不看文案——文案会随语言与措辞调整。
|
|
349
|
+
*/
|
|
350
|
+
declare function isSessionInvalidError(e: unknown): boolean;
|
|
351
|
+
type HubSessionInvalidHandler = (info: {
|
|
352
|
+
status: number;
|
|
353
|
+
code?: string;
|
|
354
|
+
}) => void;
|
|
355
|
+
declare function setHubSessionInvalidHandler(handler: HubSessionInvalidHandler | null): void;
|
|
345
356
|
declare function hubRegister(baseUrl: string, email: string, password: string): Promise<{
|
|
346
357
|
token: string;
|
|
347
358
|
}>;
|
|
@@ -482,13 +493,19 @@ declare function hubTerminalCredential(baseUrl: string, token: string, fleetId:
|
|
|
482
493
|
* = 本人全部节点,供账号级实时通道一条 WSS 订阅所有节点。
|
|
483
494
|
*/
|
|
484
495
|
declare function hubRealtimeCredential(baseUrl: string, token: string, client?: string): Promise<HubGatewayCredentialView>;
|
|
485
|
-
/**
|
|
496
|
+
/**
|
|
497
|
+
* 修改密码(手机号账号需短信验证码,可附原密码)。
|
|
498
|
+
*
|
|
499
|
+
* 改密后服务端会作废该账号已签发的全部令牌,并返回一个新令牌用于当前设备续期:
|
|
500
|
+
* 调用方必须用 `token` 覆盖本地保存的令牌,否则下一次请求就会被判为未登录。
|
|
501
|
+
*/
|
|
486
502
|
declare function hubChangePassword(baseUrl: string, token: string, input: {
|
|
487
503
|
oldPassword?: string;
|
|
488
504
|
newPassword: string;
|
|
489
505
|
code?: string;
|
|
490
506
|
}): Promise<{
|
|
491
507
|
changed: boolean;
|
|
508
|
+
token?: string;
|
|
492
509
|
}>;
|
|
493
510
|
declare function hubListFleets(baseUrl: string, token: string): Promise<HubFleetSummary[]>;
|
|
494
511
|
declare function hubCreateFleet(baseUrl: string, token: string, name: string): Promise<HubFleetSummary>;
|
|
@@ -920,6 +937,11 @@ declare function hubAdminSetRole(baseUrl: string, token: string, userId: string,
|
|
|
920
937
|
id: string;
|
|
921
938
|
role: string;
|
|
922
939
|
}>;
|
|
940
|
+
/** 管理员重置用户密码(无需原密码):重置后用户可用新密码登录 */
|
|
941
|
+
declare function hubAdminResetPassword(baseUrl: string, token: string, userId: string, newPassword: string): Promise<{
|
|
942
|
+
id: string;
|
|
943
|
+
changed: boolean;
|
|
944
|
+
}>;
|
|
923
945
|
/** 给用户发送站内通知 */
|
|
924
946
|
declare function hubAdminNotifyUser(baseUrl: string, token: string, userId: string, input: {
|
|
925
947
|
title: string;
|
|
@@ -1674,4 +1696,4 @@ declare function hubStatement(baseUrl: string, token: string, range?: {
|
|
|
1674
1696
|
to?: string;
|
|
1675
1697
|
}): Promise<HubStatement>;
|
|
1676
1698
|
|
|
1677
|
-
export { type HubAdminAuditEntry, type HubAdminNode, type HubAdminOrderRow, type HubAdminOverview, type HubAdminRechargeSource, type HubAdminRegisterAttempt, type HubAdminRole, type HubAdminTopupRow, type HubAdminUserDetail, type HubAdminUserRow, type HubAdminUserStatus, type HubAdminWalletView, type HubAlertEventView, type HubApiServiceView, type HubAuthInput, type HubBillingDayPoint, type HubBillingOrderRow, type HubBillingReport, type HubCaptchaView, type HubCommunityQrResponse, type HubCommunityQrView, type HubEnrollmentView, type HubFleetSummary, type HubGatewayCredentialView, type HubGatewayFleet, type HubNodeAccessView, type HubNodeActivityItem, type HubNodeBillingConfigResponse, type HubNodeBillingConfigView, type HubNodeBillingView, type HubNodeDetail, type HubNodeGrantView, type HubNodeSummary, type HubNodeTotals, type HubNotificationView, type HubNotifyChannelAvailability, type HubNotifyChannelType, type HubNotifyChannelView, type HubNotifyDeliveryResult, type HubNotifySettingsResponse, type HubNotifySettingsView, type HubOrderView, type HubOutgoingGrant, type HubPairingView, type HubPins, type HubPlan, type HubProjectPage, type HubProjectRow, type HubProjectTask, type HubSendCodeStatus, type HubSharedNode, type HubSmsPurpose, type HubSmtpResponse, type HubSmtpView, type HubSocialQrItem, type HubSocialQrsResponse, type HubStatement, type HubSubscriptionView, type HubTaskCounts, type HubTaskPage, type HubTaskRow, type HubTerminalCredential, type HubUsageAgg, type HubUsageNodeRow, type HubUsageProjectRow, type HubUsageView, type HubUserView, type HubWalletEntryView, type HubWalletView, type HubWebhookFormat, type HubZqaiApiRequest, type HubZqaiBalance, type HubZqaiRecharge, type HubZqaiRecharges, type HubZqaiUsage, type HubZqaiUsageBucket, type HubZqaiUsageSummary, activityKey, compareByActivity, hubAdminAddSocialQr, hubAdminAudit, hubAdminBillingReport, hubAdminClearCommunity, hubAdminCommunity, hubAdminDeleteFleet, hubAdminDeleteNode, hubAdminDeleteUser, hubAdminDisableUser, hubAdminEnableUser, hubAdminLinkZqai, hubAdminMarkOrder, hubAdminNodeBilling, hubAdminNotifyUser, hubAdminOrders, hubAdminOverview, hubAdminRefund, hubAdminRegisterAttempts, hubAdminRemoveSocialQr, hubAdminSetRole, hubAdminSocialQrs, hubAdminTopup, hubAdminUpdateCommunity, hubAdminUpdateNodeBilling, hubAdminUpdateSocialQr, hubAdminUpdateUser, hubAdminUserDetail, hubAdminUsers, hubAdminWallet, hubApiService, hubApiTopup, hubBillingExportUrl, hubCaptcha, hubChangePassword, hubChannels, hubClearSmtpSettings, hubCreateEnrollment, hubCreateFleet, hubCreateNodeGrant, hubDeleteFleet, hubDeleteNode, hubEnrollByAccount, hubEnrollByCode, hubEnrollByToken, hubEnrollNode, hubFleetPairing, hubGetNode, hubGetNodeById, hubGetUsage, hubLeaveSharedNode, hubListFleets, hubListNodeGrants, hubListNodes, hubListProjects, hubListTasks, hubLogin, hubLoginAccount, hubMarkNotificationsRead, hubMe, hubMoveNode, hubNodeActivity, hubNodeUsageReport, hubNotificationStream, hubNotifications, hubNotifyEvents, hubNotifyPreview, hubNotifySettings, hubOrders, hubOutgoingGrants, hubPins, hubPlans, hubRealtimeCredential, hubRegister, hubRegisterAccount, hubRequestApiService, hubResetPassword, hubRevokeNodeGrant, hubRotateApiKey, hubSaveNotifySettings, hubSavePins, hubSaveSmtpSettings, hubSendCodeStatus, hubSendEmailCode, hubSendSms, hubSharedNodes, hubSmsStatus, hubSmtpSettings, hubStatement, hubSubscription, hubSyncOrder, hubTerminalCredential, hubTestNotify, hubUpdateFleet, hubUpdateNode, hubUpdateNodeLabelSelf, hubUpdateProfile, hubWallet, hubWalletTopup, setHubBaseResolver };
|
|
1699
|
+
export { type HubAdminAuditEntry, type HubAdminNode, type HubAdminOrderRow, type HubAdminOverview, type HubAdminRechargeSource, type HubAdminRegisterAttempt, type HubAdminRole, type HubAdminTopupRow, type HubAdminUserDetail, type HubAdminUserRow, type HubAdminUserStatus, type HubAdminWalletView, type HubAlertEventView, type HubApiServiceView, type HubAuthInput, type HubBillingDayPoint, type HubBillingOrderRow, type HubBillingReport, type HubCaptchaView, type HubCommunityQrResponse, type HubCommunityQrView, type HubEnrollmentView, type HubFleetSummary, type HubGatewayCredentialView, type HubGatewayFleet, type HubNodeAccessView, type HubNodeActivityItem, type HubNodeBillingConfigResponse, type HubNodeBillingConfigView, type HubNodeBillingView, type HubNodeDetail, type HubNodeGrantView, type HubNodeSummary, type HubNodeTotals, type HubNotificationView, type HubNotifyChannelAvailability, type HubNotifyChannelType, type HubNotifyChannelView, type HubNotifyDeliveryResult, type HubNotifySettingsResponse, type HubNotifySettingsView, type HubOrderView, type HubOutgoingGrant, type HubPairingView, type HubPins, type HubPlan, type HubProjectPage, type HubProjectRow, type HubProjectTask, type HubSendCodeStatus, type HubSessionInvalidHandler, type HubSharedNode, type HubSmsPurpose, type HubSmtpResponse, type HubSmtpView, type HubSocialQrItem, type HubSocialQrsResponse, type HubStatement, type HubSubscriptionView, type HubTaskCounts, type HubTaskPage, type HubTaskRow, type HubTerminalCredential, type HubUsageAgg, type HubUsageNodeRow, type HubUsageProjectRow, type HubUsageView, type HubUserView, type HubWalletEntryView, type HubWalletView, type HubWebhookFormat, type HubZqaiApiRequest, type HubZqaiBalance, type HubZqaiRecharge, type HubZqaiRecharges, type HubZqaiUsage, type HubZqaiUsageBucket, type HubZqaiUsageSummary, activityKey, compareByActivity, hubAdminAddSocialQr, hubAdminAudit, hubAdminBillingReport, hubAdminClearCommunity, hubAdminCommunity, hubAdminDeleteFleet, hubAdminDeleteNode, hubAdminDeleteUser, hubAdminDisableUser, hubAdminEnableUser, hubAdminLinkZqai, hubAdminMarkOrder, hubAdminNodeBilling, hubAdminNotifyUser, hubAdminOrders, hubAdminOverview, hubAdminRefund, hubAdminRegisterAttempts, hubAdminRemoveSocialQr, hubAdminResetPassword, hubAdminSetRole, hubAdminSocialQrs, hubAdminTopup, hubAdminUpdateCommunity, hubAdminUpdateNodeBilling, hubAdminUpdateSocialQr, hubAdminUpdateUser, hubAdminUserDetail, hubAdminUsers, hubAdminWallet, hubApiService, hubApiTopup, hubBillingExportUrl, hubCaptcha, hubChangePassword, hubChannels, hubClearSmtpSettings, hubCreateEnrollment, hubCreateFleet, hubCreateNodeGrant, hubDeleteFleet, hubDeleteNode, hubEnrollByAccount, hubEnrollByCode, hubEnrollByToken, hubEnrollNode, hubFleetPairing, hubGetNode, hubGetNodeById, hubGetUsage, hubLeaveSharedNode, hubListFleets, hubListNodeGrants, hubListNodes, hubListProjects, hubListTasks, hubLogin, hubLoginAccount, hubMarkNotificationsRead, hubMe, hubMoveNode, hubNodeActivity, hubNodeUsageReport, hubNotificationStream, hubNotifications, hubNotifyEvents, hubNotifyPreview, hubNotifySettings, hubOrders, hubOutgoingGrants, hubPins, hubPlans, hubRealtimeCredential, hubRegister, hubRegisterAccount, hubRequestApiService, hubResetPassword, hubRevokeNodeGrant, hubRotateApiKey, hubSaveNotifySettings, hubSavePins, hubSaveSmtpSettings, hubSendCodeStatus, hubSendEmailCode, hubSendSms, hubSharedNodes, hubSmsStatus, hubSmtpSettings, hubStatement, hubSubscription, hubSyncOrder, hubTerminalCredential, hubTestNotify, hubUpdateFleet, hubUpdateNode, hubUpdateNodeLabelSelf, hubUpdateProfile, hubWallet, hubWalletTopup, isSessionInvalidError, setHubBaseResolver, setHubSessionInvalidHandler };
|
package/dist/hub-api.js
CHANGED
|
@@ -16,6 +16,16 @@ function resolveBase(baseUrl) {
|
|
|
16
16
|
return baseUrlResolver ? baseUrlResolver(baseUrl) : baseUrl;
|
|
17
17
|
}
|
|
18
18
|
var HUB_REQUEST_TIMEOUT_MS = 3e4;
|
|
19
|
+
var SESSION_INVALID_CODES = /* @__PURE__ */ new Set(["unauthorized", "account_disabled", "account_deleted"]);
|
|
20
|
+
function isSessionInvalidError(e) {
|
|
21
|
+
const { status, code } = e ?? {};
|
|
22
|
+
if (status === 401) return true;
|
|
23
|
+
return typeof code === "string" && SESSION_INVALID_CODES.has(code);
|
|
24
|
+
}
|
|
25
|
+
var sessionInvalidHandler = null;
|
|
26
|
+
function setHubSessionInvalidHandler(handler) {
|
|
27
|
+
sessionInvalidHandler = handler;
|
|
28
|
+
}
|
|
19
29
|
async function req(baseUrl, token, path, init = {}) {
|
|
20
30
|
const headers = {
|
|
21
31
|
...init.body ? { "Content-Type": "application/json" } : {},
|
|
@@ -47,6 +57,12 @@ async function req(baseUrl, token, path, init = {}) {
|
|
|
47
57
|
const e = new Error(err?.message ?? `HTTP ${res.status}`);
|
|
48
58
|
e.code = err?.code;
|
|
49
59
|
e.status = res.status;
|
|
60
|
+
if (sessionInvalidHandler && !path.startsWith("/api/hub/auth/") && isSessionInvalidError(e)) {
|
|
61
|
+
try {
|
|
62
|
+
sessionInvalidHandler({ status: res.status, code: e.code });
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
50
66
|
throw e;
|
|
51
67
|
}
|
|
52
68
|
return payload?.data;
|
|
@@ -405,6 +421,14 @@ async function hubAdminSetRole(baseUrl, token, userId, role) {
|
|
|
405
421
|
{ method: "PATCH", body: JSON.stringify({ role }) }
|
|
406
422
|
);
|
|
407
423
|
}
|
|
424
|
+
async function hubAdminResetPassword(baseUrl, token, userId, newPassword) {
|
|
425
|
+
return await req(
|
|
426
|
+
baseUrl,
|
|
427
|
+
token,
|
|
428
|
+
`/api/hub/admin/users/${encodeURIComponent(userId)}/password`,
|
|
429
|
+
{ method: "POST", body: JSON.stringify({ newPassword }) }
|
|
430
|
+
);
|
|
431
|
+
}
|
|
408
432
|
async function hubAdminNotifyUser(baseUrl, token, userId, input) {
|
|
409
433
|
return await req(
|
|
410
434
|
baseUrl,
|
|
@@ -692,6 +716,7 @@ export {
|
|
|
692
716
|
hubAdminRefund,
|
|
693
717
|
hubAdminRegisterAttempts,
|
|
694
718
|
hubAdminRemoveSocialQr,
|
|
719
|
+
hubAdminResetPassword,
|
|
695
720
|
hubAdminSetRole,
|
|
696
721
|
hubAdminSocialQrs,
|
|
697
722
|
hubAdminTopup,
|
|
@@ -771,6 +796,8 @@ export {
|
|
|
771
796
|
hubUpdateProfile,
|
|
772
797
|
hubWallet,
|
|
773
798
|
hubWalletTopup,
|
|
774
|
-
|
|
799
|
+
isSessionInvalidError,
|
|
800
|
+
setHubBaseResolver,
|
|
801
|
+
setHubSessionInvalidHandler
|
|
775
802
|
};
|
|
776
803
|
//# sourceMappingURL=hub-api.js.map
|