openxiangda 1.0.149 → 1.0.151

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.
@@ -2170,6 +2170,12 @@ interface RuntimeRequestState<T> {
2170
2170
  loading: boolean;
2171
2171
  error: RuntimeRequestError | null;
2172
2172
  }
2173
+ type RuntimeAuthStatus = "unknown" | "authenticated" | "refreshing" | "unauthenticated";
2174
+ interface RuntimeAuthState {
2175
+ status: RuntimeAuthStatus;
2176
+ error?: RuntimeRequestError | null;
2177
+ refreshedAt?: number;
2178
+ }
2173
2179
  interface RuntimeReloadOptions {
2174
2180
  accessToken?: string | null;
2175
2181
  accessTokenOptions?: RuntimeAccessTokenOptions;
@@ -2178,6 +2184,7 @@ interface RuntimeAccessTokenOptions {
2178
2184
  scope?: "default" | "public";
2179
2185
  path?: string | null;
2180
2186
  clearIfToken?: string;
2187
+ expiresAt?: number;
2181
2188
  }
2182
2189
  interface OpenXiangdaProviderProps {
2183
2190
  appType?: string;
@@ -2199,6 +2206,7 @@ interface OpenXiangdaRuntimeStore extends RuntimeRequestState<RuntimeBootstrap>
2199
2206
  servicePrefix: string;
2200
2207
  fetchImpl: typeof fetch;
2201
2208
  baseFetchImpl: typeof fetch;
2209
+ authState: RuntimeAuthState;
2202
2210
  getAuthHeaders: () => HeadersInit;
2203
2211
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
2204
2212
  setAccessToken: (accessToken?: string | null, options?: RuntimeAccessTokenOptions) => void;
@@ -2213,6 +2221,7 @@ declare const useAppMenus: () => {
2213
2221
  servicePrefix: string;
2214
2222
  fetchImpl: typeof fetch;
2215
2223
  baseFetchImpl: typeof fetch;
2224
+ authState: RuntimeAuthState;
2216
2225
  getAuthHeaders: () => HeadersInit;
2217
2226
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
2218
2227
  setAccessToken: (accessToken?: string | null, options?: RuntimeAccessTokenOptions) => void;
@@ -2225,6 +2234,7 @@ declare const usePermission: () => {
2225
2234
  servicePrefix: string;
2226
2235
  fetchImpl: typeof fetch;
2227
2236
  baseFetchImpl: typeof fetch;
2237
+ authState: RuntimeAuthState;
2228
2238
  getAuthHeaders: () => HeadersInit;
2229
2239
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
2230
2240
  setAccessToken: (accessToken?: string | null, options?: RuntimeAccessTokenOptions) => void;
@@ -2275,6 +2285,13 @@ declare const useRuntimeAuth: () => {
2275
2285
  redirectToLogin: (options?: RuntimeRedirectLoginOptions) => Promise<string>;
2276
2286
  resolveLoginUrl: (options?: RuntimeResolveLoginOptions) => Promise<string>;
2277
2287
  };
2288
+ interface RuntimeAuthGuardProps extends RuntimeRedirectLoginOptions {
2289
+ children: React__default.ReactNode;
2290
+ fallback?: React__default.ReactNode;
2291
+ disabled?: boolean;
2292
+ excludedPaths?: string[];
2293
+ }
2294
+ declare const RuntimeAuthGuard: React__default.FC<RuntimeAuthGuardProps>;
2278
2295
 
2279
2296
  interface UsePublicAccessOptions extends PublicAccessSessionInput {
2280
2297
  appType?: string;
@@ -2297,4 +2314,4 @@ interface PublicAccessGateProps extends UsePublicAccessOptions {
2297
2314
  }
2298
2315
  declare const PublicAccessGate: React__default.FC<PublicAccessGateProps>;
2299
2316
 
2300
- export { type ApiEnvelope, type ApiPermissionListParams, type AppAuthClient, type AppFunctionConnectorApi, type AppFunctionContext, type AppFunctionDataViewApi, type AppFunctionFormApi, type AppFunctionFormGetByIdParams, type AppFunctionFormQueryParams, type AppFunctionFormWriteParams, type AppFunctionNotificationApi, type AppFunctionOperatorInfo, type AppFunctionOrganizationApi, type AppFunctionPermissionContext, type AppFunctionRuntimeContext, type ApproveTaskParams, type AssignPermissionsParams, type AssignRolesParams, type AuthChallengePayload, AuthClientError, type AuthClientErrorOptions, type AuthClientOptions, type AuthErrorExtra, type AuthLogoutRedirectOptions, type AuthMethod, type AuthMethodType, type AuthTokenData, type AuthUser, type BatchAddUsersToRoleParams, type BatchSendNotificationByTypeParams, type ChangeOrganizationAccountPasswordParams, type ChangeUserRoleParams, type ConnectorCallParams, type ConnectorInvokeParams, type ConnectorInvokeResult, type ConnectorRequestBodyType, type ConnectorResponseType, type CreateApiPermissionParams, type CreateFileAccessTicketOptions, type CreateFormPermissionGroupDto, type CreateOrganizationAccountParams, type CreateOrganizationDepartmentParams, type CreatePagePermissionGroupDto, type CreateRoleParams, type CreateUiPermissionParams, type CreateUserParams, type CurrentUserDepartmentParents, type CustomPageEntryConfig, type CustomPageEntryMode, type DataManagementConfigParams, type DataManagementFilterState, type DataPermissionConditionDto, type DataPermissionDto, type DataPermissionRuleDto, type DataViewQueryParams, type DataViewQueryResult, type DataViewStatsParams, type DingTalkLoginInput, type DingTalkNotificationCapabilities, type DingTalkNotificationCardConfig, type DingTalkNotificationCardField, type DingTalkNotificationCardMode, type DingTalkNotificationCardPreview, type DingTalkNotificationChannelConfig, type DingTalkNotificationDeliveryMode, type DingTalkNotificationPreviewResult, type ExecuteProcessOperationInput, type FieldAccessLevel, type FieldAccessPolicyDto, type FieldAccessPolicyItemDto, type FieldOptionValue, type FieldPermissionDto, type FileAccessTicketAction, type FileAccessTicketResult, type FindNotificationConfigParams, type FormAdvancedSearchParams, type FormChangeRecordParams, type FormCreateParams, type FormCreateResult, type FormDetailResult, type FormExportParams, type FormFieldValue, type FormGetDetailParams, type FormImportParams, type FormInstanceIdentifierResult, type FormPermissionGroup, type FormRemoveParams, type FormSearchParams, type FormUpdateParams, type FormUpdateResult, type FunctionInvokeParams, type FunctionInvokeResult, type GetParentDepartmentsOptions, type GetProcessInstanceParams, type GetUserRolesParams, type GuestLoginInput, type ImportExportRecordDownloadParams, type ImportExportRecordQuery, InitiatorApproverSelector, type InstanceStatus, type ListNotificationInboxParams, type ListWorkCenterItemsParams, type LoginLogGetParams, type LoginLogListParams, type LoginLogRecord, type LoginLogStats, type LoginLogStatsParams, type LoginLogStatus, type LoginMethodsResult, LoginPage, type LoginPageProps, type MarkAllNotificationReadResult, type NotificationChannel, type NotificationChannelConfig, type NotificationChannelsConfig, type NotificationConfigLevel, type NotificationInboxListResult, type NotificationInboxMessage, type NotificationInboxReadStatus, type NotificationMessageRecord, type NotificationTemplate, type NotificationTemplatePreview, type NotificationTypeConfig, type NotificationUnreadCountResult, OpenXiangdaPageProvider, type OpenXiangdaPageProviderProps, OpenXiangdaProvider, type OpenXiangdaProviderProps, type OrganizationAccountListParams, type OrganizationCapabilities, type OrganizationListResult, type PageApiPermissionRecord, type PageApiResponse, type PageAppInfo, type PageBinaryResponse, type PageBridgeApi, type PageContext, type PageDataManagementConfig, type PageDataSourceDescriptor, type PageDepartmentInfo, type PageDepartmentRecord, type PageHttpMethod, type PageInfo, type PageListResult, type PageMessageApi, type PageModalApi, type PageNavigationApi, type PageOffsetListResult, type PagePermissionGroup, type PagePermissionInfo, PageProvider, type PageQueryValue, type PageRequestOptions, type PageRoleRecord, type PageRouteInfo, type PageScope, type PageSdk, type PageSdkError, type PageSdkMeta, type PageTransportDownloadPayload, type PageTransportRequestPayload, type PageUiPermissionRecord, type PageUiPermissionType, type PageUserInfo, type PageUserRecord, type PageUserType, type PasswordLoginInput, PermissionBoundary, type PermissionBoundaryFallback, type PermissionBoundaryFallbackState, type PermissionBoundaryProps, type PhoneCodeInput, type PhoneCodeLoginInput, type PhoneCodeRegisterInput, type PhoneCodeSendResult, type PreviewDingTalkNotificationParams, type PreviewNotificationTemplateParams, ProcessActionBar, type ProcessActionBarProps, type ProcessApproveAction, type ProcessCapabilities, type ProcessCapabilityOperation, type ProcessInstanceLookupParams, ProcessPreviewPanel, type ProcessPreviewPanelProps, ProcessTimeline, type ProcessTimelineProps, type PublicAccessClaim, type PublicAccessClient, PublicAccessClientError, type PublicAccessClientOptions, PublicAccessGate, type PublicAccessGateProps, type PublicAccessSessionData, type PublicAccessSessionInput, type PublicStorageAction, type PublicStorageGrant, type QueryFormPermissionGroupDto, type QueryPagePermissionGroupDto, type RefreshInput, type ResetOrganizationAccountPasswordParams, type ResolveLoginUrlInput, type ResolveProcessCapabilitiesParams, type RoleListParams, type RoleUsersParams, type RouteAccessResult, type RuntimeBootstrap, type RuntimeErrorSnapshot, type RuntimeErrorType, type RuntimeLogoutOptions, type RuntimeMenuItem, type RuntimePagePermissions, type RuntimeRedirectLoginOptions, type RuntimeRequestError, type RuntimeRequestState, type RuntimeResolveLoginOptions, type SaveDataManagementConfigParams, type SearchComponentName, type SearchExpression, type SearchFieldKey, type SearchGroup, type SearchLogic, type SearchOperator, type SearchRule, type SearchSortItem, type SearchSystemField, type SendNotificationByTypeParams, type SendNotificationResult, type SsoLoginUrlInput, type SsoLoginUrlResult, type SubFormRule, type SwitchAppRoleParams, type SwitchPlatformRoleParams, type TerminateProcessInstanceParams, type TriggerCallbackTaskParams, type UiPermissionListParams, type UpdateApiPermissionParams, type UpdateFormPermissionGroupDto, type UpdateOrganizationAccountParams, type UpdateOrganizationDepartmentParams, type UpdatePagePermissionGroupDto, type UpdateRoleParams, type UpdateUiPermissionParams, type UpdateUserParams, type UseAuthOptions, type UseCanAccessRouteInput, type UseLoginMethodsState, type UseProcessActionsOptions, type UseProcessActionsReturn, type UseProcessCapabilitiesOptions, type UseProcessCapabilitiesReturn, type UsePublicAccessOptions, type UsePublicAccessState, type UserListParams, type UserMenuPermissionsResponse, type ValidateUserParams, type ViewFieldPermissionValue, type ViewOperationPermission, type ViewPermissionSummary, type WorkCenterBoxType, type WorkCenterGroupedStat, type WorkCenterItem, type WorkCenterListResult, type WorkCenterStats, type WorkCenterStatsParams, type WorkflowApproveParams, type WorkflowCapabilityActionKey, type WorkflowDefinitionByFormParams, type WorkflowInitiatorSelectCandidatesParams, type WorkflowInitiatorSelectRequirementsParams, type WorkflowPreviewParams, type WorkflowResubmitInitiatorSelectRequirementsParams, type WorkflowResubmitParams, type WorkflowReturnParams, type WorkflowSaveTaskParams, type WorkflowStartFromExistingInstanceParams, type WorkflowTaskParams, type WorkflowTransferParams, type WorkflowWithdrawParams, createAuthClient, createPageSdk, createPublicAccessClient, createReactPage, getAuthErrorExtra, getAuthErrorReason, isAuthChallengeRequired, isAuthClientError, useAppMenus, useAuth, useCanAccessRoute, useCurrentUser, useDataSource, useFormViewPermissions, useLoginMethods, useMessage, useModal, useNavigation, useOpenXiangda, usePageContext, usePageProps, usePageRoute, usePageSdk, usePermission, useProcessActions, useProcessCapabilities, usePublicAccess, useRuntimeAuth, useRuntimeBootstrap };
2317
+ export { type ApiEnvelope, type ApiPermissionListParams, type AppAuthClient, type AppFunctionConnectorApi, type AppFunctionContext, type AppFunctionDataViewApi, type AppFunctionFormApi, type AppFunctionFormGetByIdParams, type AppFunctionFormQueryParams, type AppFunctionFormWriteParams, type AppFunctionNotificationApi, type AppFunctionOperatorInfo, type AppFunctionOrganizationApi, type AppFunctionPermissionContext, type AppFunctionRuntimeContext, type ApproveTaskParams, type AssignPermissionsParams, type AssignRolesParams, type AuthChallengePayload, AuthClientError, type AuthClientErrorOptions, type AuthClientOptions, type AuthErrorExtra, type AuthLogoutRedirectOptions, type AuthMethod, type AuthMethodType, type AuthTokenData, type AuthUser, type BatchAddUsersToRoleParams, type BatchSendNotificationByTypeParams, type ChangeOrganizationAccountPasswordParams, type ChangeUserRoleParams, type ConnectorCallParams, type ConnectorInvokeParams, type ConnectorInvokeResult, type ConnectorRequestBodyType, type ConnectorResponseType, type CreateApiPermissionParams, type CreateFileAccessTicketOptions, type CreateFormPermissionGroupDto, type CreateOrganizationAccountParams, type CreateOrganizationDepartmentParams, type CreatePagePermissionGroupDto, type CreateRoleParams, type CreateUiPermissionParams, type CreateUserParams, type CurrentUserDepartmentParents, type CustomPageEntryConfig, type CustomPageEntryMode, type DataManagementConfigParams, type DataManagementFilterState, type DataPermissionConditionDto, type DataPermissionDto, type DataPermissionRuleDto, type DataViewQueryParams, type DataViewQueryResult, type DataViewStatsParams, type DingTalkLoginInput, type DingTalkNotificationCapabilities, type DingTalkNotificationCardConfig, type DingTalkNotificationCardField, type DingTalkNotificationCardMode, type DingTalkNotificationCardPreview, type DingTalkNotificationChannelConfig, type DingTalkNotificationDeliveryMode, type DingTalkNotificationPreviewResult, type ExecuteProcessOperationInput, type FieldAccessLevel, type FieldAccessPolicyDto, type FieldAccessPolicyItemDto, type FieldOptionValue, type FieldPermissionDto, type FileAccessTicketAction, type FileAccessTicketResult, type FindNotificationConfigParams, type FormAdvancedSearchParams, type FormChangeRecordParams, type FormCreateParams, type FormCreateResult, type FormDetailResult, type FormExportParams, type FormFieldValue, type FormGetDetailParams, type FormImportParams, type FormInstanceIdentifierResult, type FormPermissionGroup, type FormRemoveParams, type FormSearchParams, type FormUpdateParams, type FormUpdateResult, type FunctionInvokeParams, type FunctionInvokeResult, type GetParentDepartmentsOptions, type GetProcessInstanceParams, type GetUserRolesParams, type GuestLoginInput, type ImportExportRecordDownloadParams, type ImportExportRecordQuery, InitiatorApproverSelector, type InstanceStatus, type ListNotificationInboxParams, type ListWorkCenterItemsParams, type LoginLogGetParams, type LoginLogListParams, type LoginLogRecord, type LoginLogStats, type LoginLogStatsParams, type LoginLogStatus, type LoginMethodsResult, LoginPage, type LoginPageProps, type MarkAllNotificationReadResult, type NotificationChannel, type NotificationChannelConfig, type NotificationChannelsConfig, type NotificationConfigLevel, type NotificationInboxListResult, type NotificationInboxMessage, type NotificationInboxReadStatus, type NotificationMessageRecord, type NotificationTemplate, type NotificationTemplatePreview, type NotificationTypeConfig, type NotificationUnreadCountResult, OpenXiangdaPageProvider, type OpenXiangdaPageProviderProps, OpenXiangdaProvider, type OpenXiangdaProviderProps, type OrganizationAccountListParams, type OrganizationCapabilities, type OrganizationListResult, type PageApiPermissionRecord, type PageApiResponse, type PageAppInfo, type PageBinaryResponse, type PageBridgeApi, type PageContext, type PageDataManagementConfig, type PageDataSourceDescriptor, type PageDepartmentInfo, type PageDepartmentRecord, type PageHttpMethod, type PageInfo, type PageListResult, type PageMessageApi, type PageModalApi, type PageNavigationApi, type PageOffsetListResult, type PagePermissionGroup, type PagePermissionInfo, PageProvider, type PageQueryValue, type PageRequestOptions, type PageRoleRecord, type PageRouteInfo, type PageScope, type PageSdk, type PageSdkError, type PageSdkMeta, type PageTransportDownloadPayload, type PageTransportRequestPayload, type PageUiPermissionRecord, type PageUiPermissionType, type PageUserInfo, type PageUserRecord, type PageUserType, type PasswordLoginInput, PermissionBoundary, type PermissionBoundaryFallback, type PermissionBoundaryFallbackState, type PermissionBoundaryProps, type PhoneCodeInput, type PhoneCodeLoginInput, type PhoneCodeRegisterInput, type PhoneCodeSendResult, type PreviewDingTalkNotificationParams, type PreviewNotificationTemplateParams, ProcessActionBar, type ProcessActionBarProps, type ProcessApproveAction, type ProcessCapabilities, type ProcessCapabilityOperation, type ProcessInstanceLookupParams, ProcessPreviewPanel, type ProcessPreviewPanelProps, ProcessTimeline, type ProcessTimelineProps, type PublicAccessClaim, type PublicAccessClient, PublicAccessClientError, type PublicAccessClientOptions, PublicAccessGate, type PublicAccessGateProps, type PublicAccessSessionData, type PublicAccessSessionInput, type PublicStorageAction, type PublicStorageGrant, type QueryFormPermissionGroupDto, type QueryPagePermissionGroupDto, type RefreshInput, type ResetOrganizationAccountPasswordParams, type ResolveLoginUrlInput, type ResolveProcessCapabilitiesParams, type RoleListParams, type RoleUsersParams, type RouteAccessResult, RuntimeAuthGuard, type RuntimeAuthGuardProps, type RuntimeAuthState, type RuntimeAuthStatus, type RuntimeBootstrap, type RuntimeErrorSnapshot, type RuntimeErrorType, type RuntimeLogoutOptions, type RuntimeMenuItem, type RuntimePagePermissions, type RuntimeRedirectLoginOptions, type RuntimeRequestError, type RuntimeRequestState, type RuntimeResolveLoginOptions, type SaveDataManagementConfigParams, type SearchComponentName, type SearchExpression, type SearchFieldKey, type SearchGroup, type SearchLogic, type SearchOperator, type SearchRule, type SearchSortItem, type SearchSystemField, type SendNotificationByTypeParams, type SendNotificationResult, type SsoLoginUrlInput, type SsoLoginUrlResult, type SubFormRule, type SwitchAppRoleParams, type SwitchPlatformRoleParams, type TerminateProcessInstanceParams, type TriggerCallbackTaskParams, type UiPermissionListParams, type UpdateApiPermissionParams, type UpdateFormPermissionGroupDto, type UpdateOrganizationAccountParams, type UpdateOrganizationDepartmentParams, type UpdatePagePermissionGroupDto, type UpdateRoleParams, type UpdateUiPermissionParams, type UpdateUserParams, type UseAuthOptions, type UseCanAccessRouteInput, type UseLoginMethodsState, type UseProcessActionsOptions, type UseProcessActionsReturn, type UseProcessCapabilitiesOptions, type UseProcessCapabilitiesReturn, type UsePublicAccessOptions, type UsePublicAccessState, type UserListParams, type UserMenuPermissionsResponse, type ValidateUserParams, type ViewFieldPermissionValue, type ViewOperationPermission, type ViewPermissionSummary, type WorkCenterBoxType, type WorkCenterGroupedStat, type WorkCenterItem, type WorkCenterListResult, type WorkCenterStats, type WorkCenterStatsParams, type WorkflowApproveParams, type WorkflowCapabilityActionKey, type WorkflowDefinitionByFormParams, type WorkflowInitiatorSelectCandidatesParams, type WorkflowInitiatorSelectRequirementsParams, type WorkflowPreviewParams, type WorkflowResubmitInitiatorSelectRequirementsParams, type WorkflowResubmitParams, type WorkflowReturnParams, type WorkflowSaveTaskParams, type WorkflowStartFromExistingInstanceParams, type WorkflowTaskParams, type WorkflowTransferParams, type WorkflowWithdrawParams, createAuthClient, createPageSdk, createPublicAccessClient, createReactPage, getAuthErrorExtra, getAuthErrorReason, isAuthChallengeRequired, isAuthClientError, useAppMenus, useAuth, useCanAccessRoute, useCurrentUser, useDataSource, useFormViewPermissions, useLoginMethods, useMessage, useModal, useNavigation, useOpenXiangda, usePageContext, usePageProps, usePageRoute, usePageSdk, usePermission, useProcessActions, useProcessCapabilities, usePublicAccess, useRuntimeAuth, useRuntimeBootstrap };
@@ -2170,6 +2170,12 @@ interface RuntimeRequestState<T> {
2170
2170
  loading: boolean;
2171
2171
  error: RuntimeRequestError | null;
2172
2172
  }
2173
+ type RuntimeAuthStatus = "unknown" | "authenticated" | "refreshing" | "unauthenticated";
2174
+ interface RuntimeAuthState {
2175
+ status: RuntimeAuthStatus;
2176
+ error?: RuntimeRequestError | null;
2177
+ refreshedAt?: number;
2178
+ }
2173
2179
  interface RuntimeReloadOptions {
2174
2180
  accessToken?: string | null;
2175
2181
  accessTokenOptions?: RuntimeAccessTokenOptions;
@@ -2178,6 +2184,7 @@ interface RuntimeAccessTokenOptions {
2178
2184
  scope?: "default" | "public";
2179
2185
  path?: string | null;
2180
2186
  clearIfToken?: string;
2187
+ expiresAt?: number;
2181
2188
  }
2182
2189
  interface OpenXiangdaProviderProps {
2183
2190
  appType?: string;
@@ -2199,6 +2206,7 @@ interface OpenXiangdaRuntimeStore extends RuntimeRequestState<RuntimeBootstrap>
2199
2206
  servicePrefix: string;
2200
2207
  fetchImpl: typeof fetch;
2201
2208
  baseFetchImpl: typeof fetch;
2209
+ authState: RuntimeAuthState;
2202
2210
  getAuthHeaders: () => HeadersInit;
2203
2211
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
2204
2212
  setAccessToken: (accessToken?: string | null, options?: RuntimeAccessTokenOptions) => void;
@@ -2213,6 +2221,7 @@ declare const useAppMenus: () => {
2213
2221
  servicePrefix: string;
2214
2222
  fetchImpl: typeof fetch;
2215
2223
  baseFetchImpl: typeof fetch;
2224
+ authState: RuntimeAuthState;
2216
2225
  getAuthHeaders: () => HeadersInit;
2217
2226
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
2218
2227
  setAccessToken: (accessToken?: string | null, options?: RuntimeAccessTokenOptions) => void;
@@ -2225,6 +2234,7 @@ declare const usePermission: () => {
2225
2234
  servicePrefix: string;
2226
2235
  fetchImpl: typeof fetch;
2227
2236
  baseFetchImpl: typeof fetch;
2237
+ authState: RuntimeAuthState;
2228
2238
  getAuthHeaders: () => HeadersInit;
2229
2239
  reload: (options?: RuntimeReloadOptions) => Promise<void>;
2230
2240
  setAccessToken: (accessToken?: string | null, options?: RuntimeAccessTokenOptions) => void;
@@ -2275,6 +2285,13 @@ declare const useRuntimeAuth: () => {
2275
2285
  redirectToLogin: (options?: RuntimeRedirectLoginOptions) => Promise<string>;
2276
2286
  resolveLoginUrl: (options?: RuntimeResolveLoginOptions) => Promise<string>;
2277
2287
  };
2288
+ interface RuntimeAuthGuardProps extends RuntimeRedirectLoginOptions {
2289
+ children: React__default.ReactNode;
2290
+ fallback?: React__default.ReactNode;
2291
+ disabled?: boolean;
2292
+ excludedPaths?: string[];
2293
+ }
2294
+ declare const RuntimeAuthGuard: React__default.FC<RuntimeAuthGuardProps>;
2278
2295
 
2279
2296
  interface UsePublicAccessOptions extends PublicAccessSessionInput {
2280
2297
  appType?: string;
@@ -2297,4 +2314,4 @@ interface PublicAccessGateProps extends UsePublicAccessOptions {
2297
2314
  }
2298
2315
  declare const PublicAccessGate: React__default.FC<PublicAccessGateProps>;
2299
2316
 
2300
- export { type ApiEnvelope, type ApiPermissionListParams, type AppAuthClient, type AppFunctionConnectorApi, type AppFunctionContext, type AppFunctionDataViewApi, type AppFunctionFormApi, type AppFunctionFormGetByIdParams, type AppFunctionFormQueryParams, type AppFunctionFormWriteParams, type AppFunctionNotificationApi, type AppFunctionOperatorInfo, type AppFunctionOrganizationApi, type AppFunctionPermissionContext, type AppFunctionRuntimeContext, type ApproveTaskParams, type AssignPermissionsParams, type AssignRolesParams, type AuthChallengePayload, AuthClientError, type AuthClientErrorOptions, type AuthClientOptions, type AuthErrorExtra, type AuthLogoutRedirectOptions, type AuthMethod, type AuthMethodType, type AuthTokenData, type AuthUser, type BatchAddUsersToRoleParams, type BatchSendNotificationByTypeParams, type ChangeOrganizationAccountPasswordParams, type ChangeUserRoleParams, type ConnectorCallParams, type ConnectorInvokeParams, type ConnectorInvokeResult, type ConnectorRequestBodyType, type ConnectorResponseType, type CreateApiPermissionParams, type CreateFileAccessTicketOptions, type CreateFormPermissionGroupDto, type CreateOrganizationAccountParams, type CreateOrganizationDepartmentParams, type CreatePagePermissionGroupDto, type CreateRoleParams, type CreateUiPermissionParams, type CreateUserParams, type CurrentUserDepartmentParents, type CustomPageEntryConfig, type CustomPageEntryMode, type DataManagementConfigParams, type DataManagementFilterState, type DataPermissionConditionDto, type DataPermissionDto, type DataPermissionRuleDto, type DataViewQueryParams, type DataViewQueryResult, type DataViewStatsParams, type DingTalkLoginInput, type DingTalkNotificationCapabilities, type DingTalkNotificationCardConfig, type DingTalkNotificationCardField, type DingTalkNotificationCardMode, type DingTalkNotificationCardPreview, type DingTalkNotificationChannelConfig, type DingTalkNotificationDeliveryMode, type DingTalkNotificationPreviewResult, type ExecuteProcessOperationInput, type FieldAccessLevel, type FieldAccessPolicyDto, type FieldAccessPolicyItemDto, type FieldOptionValue, type FieldPermissionDto, type FileAccessTicketAction, type FileAccessTicketResult, type FindNotificationConfigParams, type FormAdvancedSearchParams, type FormChangeRecordParams, type FormCreateParams, type FormCreateResult, type FormDetailResult, type FormExportParams, type FormFieldValue, type FormGetDetailParams, type FormImportParams, type FormInstanceIdentifierResult, type FormPermissionGroup, type FormRemoveParams, type FormSearchParams, type FormUpdateParams, type FormUpdateResult, type FunctionInvokeParams, type FunctionInvokeResult, type GetParentDepartmentsOptions, type GetProcessInstanceParams, type GetUserRolesParams, type GuestLoginInput, type ImportExportRecordDownloadParams, type ImportExportRecordQuery, InitiatorApproverSelector, type InstanceStatus, type ListNotificationInboxParams, type ListWorkCenterItemsParams, type LoginLogGetParams, type LoginLogListParams, type LoginLogRecord, type LoginLogStats, type LoginLogStatsParams, type LoginLogStatus, type LoginMethodsResult, LoginPage, type LoginPageProps, type MarkAllNotificationReadResult, type NotificationChannel, type NotificationChannelConfig, type NotificationChannelsConfig, type NotificationConfigLevel, type NotificationInboxListResult, type NotificationInboxMessage, type NotificationInboxReadStatus, type NotificationMessageRecord, type NotificationTemplate, type NotificationTemplatePreview, type NotificationTypeConfig, type NotificationUnreadCountResult, OpenXiangdaPageProvider, type OpenXiangdaPageProviderProps, OpenXiangdaProvider, type OpenXiangdaProviderProps, type OrganizationAccountListParams, type OrganizationCapabilities, type OrganizationListResult, type PageApiPermissionRecord, type PageApiResponse, type PageAppInfo, type PageBinaryResponse, type PageBridgeApi, type PageContext, type PageDataManagementConfig, type PageDataSourceDescriptor, type PageDepartmentInfo, type PageDepartmentRecord, type PageHttpMethod, type PageInfo, type PageListResult, type PageMessageApi, type PageModalApi, type PageNavigationApi, type PageOffsetListResult, type PagePermissionGroup, type PagePermissionInfo, PageProvider, type PageQueryValue, type PageRequestOptions, type PageRoleRecord, type PageRouteInfo, type PageScope, type PageSdk, type PageSdkError, type PageSdkMeta, type PageTransportDownloadPayload, type PageTransportRequestPayload, type PageUiPermissionRecord, type PageUiPermissionType, type PageUserInfo, type PageUserRecord, type PageUserType, type PasswordLoginInput, PermissionBoundary, type PermissionBoundaryFallback, type PermissionBoundaryFallbackState, type PermissionBoundaryProps, type PhoneCodeInput, type PhoneCodeLoginInput, type PhoneCodeRegisterInput, type PhoneCodeSendResult, type PreviewDingTalkNotificationParams, type PreviewNotificationTemplateParams, ProcessActionBar, type ProcessActionBarProps, type ProcessApproveAction, type ProcessCapabilities, type ProcessCapabilityOperation, type ProcessInstanceLookupParams, ProcessPreviewPanel, type ProcessPreviewPanelProps, ProcessTimeline, type ProcessTimelineProps, type PublicAccessClaim, type PublicAccessClient, PublicAccessClientError, type PublicAccessClientOptions, PublicAccessGate, type PublicAccessGateProps, type PublicAccessSessionData, type PublicAccessSessionInput, type PublicStorageAction, type PublicStorageGrant, type QueryFormPermissionGroupDto, type QueryPagePermissionGroupDto, type RefreshInput, type ResetOrganizationAccountPasswordParams, type ResolveLoginUrlInput, type ResolveProcessCapabilitiesParams, type RoleListParams, type RoleUsersParams, type RouteAccessResult, type RuntimeBootstrap, type RuntimeErrorSnapshot, type RuntimeErrorType, type RuntimeLogoutOptions, type RuntimeMenuItem, type RuntimePagePermissions, type RuntimeRedirectLoginOptions, type RuntimeRequestError, type RuntimeRequestState, type RuntimeResolveLoginOptions, type SaveDataManagementConfigParams, type SearchComponentName, type SearchExpression, type SearchFieldKey, type SearchGroup, type SearchLogic, type SearchOperator, type SearchRule, type SearchSortItem, type SearchSystemField, type SendNotificationByTypeParams, type SendNotificationResult, type SsoLoginUrlInput, type SsoLoginUrlResult, type SubFormRule, type SwitchAppRoleParams, type SwitchPlatformRoleParams, type TerminateProcessInstanceParams, type TriggerCallbackTaskParams, type UiPermissionListParams, type UpdateApiPermissionParams, type UpdateFormPermissionGroupDto, type UpdateOrganizationAccountParams, type UpdateOrganizationDepartmentParams, type UpdatePagePermissionGroupDto, type UpdateRoleParams, type UpdateUiPermissionParams, type UpdateUserParams, type UseAuthOptions, type UseCanAccessRouteInput, type UseLoginMethodsState, type UseProcessActionsOptions, type UseProcessActionsReturn, type UseProcessCapabilitiesOptions, type UseProcessCapabilitiesReturn, type UsePublicAccessOptions, type UsePublicAccessState, type UserListParams, type UserMenuPermissionsResponse, type ValidateUserParams, type ViewFieldPermissionValue, type ViewOperationPermission, type ViewPermissionSummary, type WorkCenterBoxType, type WorkCenterGroupedStat, type WorkCenterItem, type WorkCenterListResult, type WorkCenterStats, type WorkCenterStatsParams, type WorkflowApproveParams, type WorkflowCapabilityActionKey, type WorkflowDefinitionByFormParams, type WorkflowInitiatorSelectCandidatesParams, type WorkflowInitiatorSelectRequirementsParams, type WorkflowPreviewParams, type WorkflowResubmitInitiatorSelectRequirementsParams, type WorkflowResubmitParams, type WorkflowReturnParams, type WorkflowSaveTaskParams, type WorkflowStartFromExistingInstanceParams, type WorkflowTaskParams, type WorkflowTransferParams, type WorkflowWithdrawParams, createAuthClient, createPageSdk, createPublicAccessClient, createReactPage, getAuthErrorExtra, getAuthErrorReason, isAuthChallengeRequired, isAuthClientError, useAppMenus, useAuth, useCanAccessRoute, useCurrentUser, useDataSource, useFormViewPermissions, useLoginMethods, useMessage, useModal, useNavigation, useOpenXiangda, usePageContext, usePageProps, usePageRoute, usePageSdk, usePermission, useProcessActions, useProcessCapabilities, usePublicAccess, useRuntimeAuth, useRuntimeBootstrap };
2317
+ export { type ApiEnvelope, type ApiPermissionListParams, type AppAuthClient, type AppFunctionConnectorApi, type AppFunctionContext, type AppFunctionDataViewApi, type AppFunctionFormApi, type AppFunctionFormGetByIdParams, type AppFunctionFormQueryParams, type AppFunctionFormWriteParams, type AppFunctionNotificationApi, type AppFunctionOperatorInfo, type AppFunctionOrganizationApi, type AppFunctionPermissionContext, type AppFunctionRuntimeContext, type ApproveTaskParams, type AssignPermissionsParams, type AssignRolesParams, type AuthChallengePayload, AuthClientError, type AuthClientErrorOptions, type AuthClientOptions, type AuthErrorExtra, type AuthLogoutRedirectOptions, type AuthMethod, type AuthMethodType, type AuthTokenData, type AuthUser, type BatchAddUsersToRoleParams, type BatchSendNotificationByTypeParams, type ChangeOrganizationAccountPasswordParams, type ChangeUserRoleParams, type ConnectorCallParams, type ConnectorInvokeParams, type ConnectorInvokeResult, type ConnectorRequestBodyType, type ConnectorResponseType, type CreateApiPermissionParams, type CreateFileAccessTicketOptions, type CreateFormPermissionGroupDto, type CreateOrganizationAccountParams, type CreateOrganizationDepartmentParams, type CreatePagePermissionGroupDto, type CreateRoleParams, type CreateUiPermissionParams, type CreateUserParams, type CurrentUserDepartmentParents, type CustomPageEntryConfig, type CustomPageEntryMode, type DataManagementConfigParams, type DataManagementFilterState, type DataPermissionConditionDto, type DataPermissionDto, type DataPermissionRuleDto, type DataViewQueryParams, type DataViewQueryResult, type DataViewStatsParams, type DingTalkLoginInput, type DingTalkNotificationCapabilities, type DingTalkNotificationCardConfig, type DingTalkNotificationCardField, type DingTalkNotificationCardMode, type DingTalkNotificationCardPreview, type DingTalkNotificationChannelConfig, type DingTalkNotificationDeliveryMode, type DingTalkNotificationPreviewResult, type ExecuteProcessOperationInput, type FieldAccessLevel, type FieldAccessPolicyDto, type FieldAccessPolicyItemDto, type FieldOptionValue, type FieldPermissionDto, type FileAccessTicketAction, type FileAccessTicketResult, type FindNotificationConfigParams, type FormAdvancedSearchParams, type FormChangeRecordParams, type FormCreateParams, type FormCreateResult, type FormDetailResult, type FormExportParams, type FormFieldValue, type FormGetDetailParams, type FormImportParams, type FormInstanceIdentifierResult, type FormPermissionGroup, type FormRemoveParams, type FormSearchParams, type FormUpdateParams, type FormUpdateResult, type FunctionInvokeParams, type FunctionInvokeResult, type GetParentDepartmentsOptions, type GetProcessInstanceParams, type GetUserRolesParams, type GuestLoginInput, type ImportExportRecordDownloadParams, type ImportExportRecordQuery, InitiatorApproverSelector, type InstanceStatus, type ListNotificationInboxParams, type ListWorkCenterItemsParams, type LoginLogGetParams, type LoginLogListParams, type LoginLogRecord, type LoginLogStats, type LoginLogStatsParams, type LoginLogStatus, type LoginMethodsResult, LoginPage, type LoginPageProps, type MarkAllNotificationReadResult, type NotificationChannel, type NotificationChannelConfig, type NotificationChannelsConfig, type NotificationConfigLevel, type NotificationInboxListResult, type NotificationInboxMessage, type NotificationInboxReadStatus, type NotificationMessageRecord, type NotificationTemplate, type NotificationTemplatePreview, type NotificationTypeConfig, type NotificationUnreadCountResult, OpenXiangdaPageProvider, type OpenXiangdaPageProviderProps, OpenXiangdaProvider, type OpenXiangdaProviderProps, type OrganizationAccountListParams, type OrganizationCapabilities, type OrganizationListResult, type PageApiPermissionRecord, type PageApiResponse, type PageAppInfo, type PageBinaryResponse, type PageBridgeApi, type PageContext, type PageDataManagementConfig, type PageDataSourceDescriptor, type PageDepartmentInfo, type PageDepartmentRecord, type PageHttpMethod, type PageInfo, type PageListResult, type PageMessageApi, type PageModalApi, type PageNavigationApi, type PageOffsetListResult, type PagePermissionGroup, type PagePermissionInfo, PageProvider, type PageQueryValue, type PageRequestOptions, type PageRoleRecord, type PageRouteInfo, type PageScope, type PageSdk, type PageSdkError, type PageSdkMeta, type PageTransportDownloadPayload, type PageTransportRequestPayload, type PageUiPermissionRecord, type PageUiPermissionType, type PageUserInfo, type PageUserRecord, type PageUserType, type PasswordLoginInput, PermissionBoundary, type PermissionBoundaryFallback, type PermissionBoundaryFallbackState, type PermissionBoundaryProps, type PhoneCodeInput, type PhoneCodeLoginInput, type PhoneCodeRegisterInput, type PhoneCodeSendResult, type PreviewDingTalkNotificationParams, type PreviewNotificationTemplateParams, ProcessActionBar, type ProcessActionBarProps, type ProcessApproveAction, type ProcessCapabilities, type ProcessCapabilityOperation, type ProcessInstanceLookupParams, ProcessPreviewPanel, type ProcessPreviewPanelProps, ProcessTimeline, type ProcessTimelineProps, type PublicAccessClaim, type PublicAccessClient, PublicAccessClientError, type PublicAccessClientOptions, PublicAccessGate, type PublicAccessGateProps, type PublicAccessSessionData, type PublicAccessSessionInput, type PublicStorageAction, type PublicStorageGrant, type QueryFormPermissionGroupDto, type QueryPagePermissionGroupDto, type RefreshInput, type ResetOrganizationAccountPasswordParams, type ResolveLoginUrlInput, type ResolveProcessCapabilitiesParams, type RoleListParams, type RoleUsersParams, type RouteAccessResult, RuntimeAuthGuard, type RuntimeAuthGuardProps, type RuntimeAuthState, type RuntimeAuthStatus, type RuntimeBootstrap, type RuntimeErrorSnapshot, type RuntimeErrorType, type RuntimeLogoutOptions, type RuntimeMenuItem, type RuntimePagePermissions, type RuntimeRedirectLoginOptions, type RuntimeRequestError, type RuntimeRequestState, type RuntimeResolveLoginOptions, type SaveDataManagementConfigParams, type SearchComponentName, type SearchExpression, type SearchFieldKey, type SearchGroup, type SearchLogic, type SearchOperator, type SearchRule, type SearchSortItem, type SearchSystemField, type SendNotificationByTypeParams, type SendNotificationResult, type SsoLoginUrlInput, type SsoLoginUrlResult, type SubFormRule, type SwitchAppRoleParams, type SwitchPlatformRoleParams, type TerminateProcessInstanceParams, type TriggerCallbackTaskParams, type UiPermissionListParams, type UpdateApiPermissionParams, type UpdateFormPermissionGroupDto, type UpdateOrganizationAccountParams, type UpdateOrganizationDepartmentParams, type UpdatePagePermissionGroupDto, type UpdateRoleParams, type UpdateUiPermissionParams, type UpdateUserParams, type UseAuthOptions, type UseCanAccessRouteInput, type UseLoginMethodsState, type UseProcessActionsOptions, type UseProcessActionsReturn, type UseProcessCapabilitiesOptions, type UseProcessCapabilitiesReturn, type UsePublicAccessOptions, type UsePublicAccessState, type UserListParams, type UserMenuPermissionsResponse, type ValidateUserParams, type ViewFieldPermissionValue, type ViewOperationPermission, type ViewPermissionSummary, type WorkCenterBoxType, type WorkCenterGroupedStat, type WorkCenterItem, type WorkCenterListResult, type WorkCenterStats, type WorkCenterStatsParams, type WorkflowApproveParams, type WorkflowCapabilityActionKey, type WorkflowDefinitionByFormParams, type WorkflowInitiatorSelectCandidatesParams, type WorkflowInitiatorSelectRequirementsParams, type WorkflowPreviewParams, type WorkflowResubmitInitiatorSelectRequirementsParams, type WorkflowResubmitParams, type WorkflowReturnParams, type WorkflowSaveTaskParams, type WorkflowStartFromExistingInstanceParams, type WorkflowTaskParams, type WorkflowTransferParams, type WorkflowWithdrawParams, createAuthClient, createPageSdk, createPublicAccessClient, createReactPage, getAuthErrorExtra, getAuthErrorReason, isAuthChallengeRequired, isAuthClientError, useAppMenus, useAuth, useCanAccessRoute, useCurrentUser, useDataSource, useFormViewPermissions, useLoginMethods, useMessage, useModal, useNavigation, useOpenXiangda, usePageContext, usePageProps, usePageRoute, usePageSdk, usePermission, useProcessActions, useProcessCapabilities, usePublicAccess, useRuntimeAuth, useRuntimeBootstrap };
@@ -4784,14 +4784,14 @@ var useAuth = (options = {}) => {
4784
4784
  () => createAuthClient({
4785
4785
  appType: options.appType || runtime.appType,
4786
4786
  servicePrefix: options.servicePrefix || runtime.servicePrefix,
4787
- fetchImpl: options.fetchImpl || runtime.fetchImpl
4787
+ fetchImpl: options.fetchImpl || runtime.baseFetchImpl
4788
4788
  }),
4789
4789
  [
4790
4790
  options.appType,
4791
4791
  options.fetchImpl,
4792
4792
  options.servicePrefix,
4793
4793
  runtime.appType,
4794
- runtime.fetchImpl,
4794
+ runtime.baseFetchImpl,
4795
4795
  runtime.servicePrefix
4796
4796
  ]
4797
4797
  );
@@ -5070,7 +5070,19 @@ var LoginPage = ({
5070
5070
  };
5071
5071
  async function handleSuccess(data) {
5072
5072
  await onSuccess?.(data);
5073
- await runtime.reload();
5073
+ const accessToken = data.accessToken || data.token;
5074
+ const accessTokenOptions = {
5075
+ expiresAt: data.accessTokenExpiresAt
5076
+ };
5077
+ if (accessToken) {
5078
+ runtime.setAccessToken(accessToken, accessTokenOptions);
5079
+ }
5080
+ await runtime.reload(
5081
+ accessToken ? {
5082
+ accessToken,
5083
+ accessTokenOptions
5084
+ } : void 0
5085
+ );
5074
5086
  if (redirectOnSuccess && typeof window !== "undefined") {
5075
5087
  window.location.replace(
5076
5088
  redirectUrl || getCallbackUrl() || `/view/${auth.client.appType}`
@@ -5354,27 +5366,125 @@ var OpenXiangdaProvider = ({
5354
5366
  () => appType || resolveAppTypeFromLocation(),
5355
5367
  [appType]
5356
5368
  );
5357
- const [accessToken, setAccessTokenState] = useState9(null);
5369
+ const [, setAccessTokenState] = useState9(null);
5370
+ const [authState, setAuthState] = useState9({
5371
+ status: "unknown",
5372
+ error: null
5373
+ });
5358
5374
  const accessTokenRef = useRef5(null);
5359
- const setAccessToken = useCallback8(
5375
+ const refreshRequestRef = useRef5(null);
5376
+ const applyAccessToken = useCallback8(
5360
5377
  (nextAccessToken, options = {}) => {
5361
5378
  if (!nextAccessToken && options.clearIfToken && accessTokenRef.current?.token !== options.clearIfToken) {
5362
- return;
5379
+ return accessTokenRef.current;
5363
5380
  }
5364
5381
  const normalizedAccessToken = nextAccessToken || null;
5365
5382
  const nextState = normalizedAccessToken ? {
5366
5383
  token: normalizedAccessToken,
5367
5384
  scope: options.scope || "default",
5368
- path: options.path || null
5385
+ path: options.path || null,
5386
+ expiresAt: options.expiresAt
5369
5387
  } : null;
5370
5388
  accessTokenRef.current = nextState;
5371
5389
  setAccessTokenState(nextState);
5390
+ return nextState;
5372
5391
  },
5373
5392
  []
5374
5393
  );
5394
+ const setAccessToken = useCallback8(
5395
+ (nextAccessToken, options = {}) => {
5396
+ const previousState = accessTokenRef.current;
5397
+ const nextState = applyAccessToken(nextAccessToken, options);
5398
+ if (nextState) {
5399
+ if (nextState.scope === "public") return;
5400
+ setAuthState({
5401
+ status: "authenticated",
5402
+ error: null
5403
+ });
5404
+ } else if (previousState?.scope !== "public") {
5405
+ setAuthState({ status: "unauthenticated", error: null });
5406
+ }
5407
+ },
5408
+ [applyAccessToken]
5409
+ );
5410
+ const markUnauthenticated = useCallback8(
5411
+ (error) => {
5412
+ const runtimeError = normalizeRuntimeError(error);
5413
+ applyAccessToken(null);
5414
+ setAuthState({ status: "unauthenticated", error: runtimeError });
5415
+ },
5416
+ [applyAccessToken]
5417
+ );
5418
+ const refreshAccessToken = useCallback8(async () => {
5419
+ if (!resolvedAppType) return null;
5420
+ if (!refreshRequestRef.current) {
5421
+ setAuthState((prev) => ({ ...prev, status: "refreshing", error: null }));
5422
+ refreshRequestRef.current = (async () => {
5423
+ const response = await resolvedFetch(
5424
+ buildServiceUrl2(
5425
+ servicePrefix,
5426
+ `/openxiangda-api/v1/apps/${encodeURIComponent(
5427
+ resolvedAppType
5428
+ )}/auth/refresh`
5429
+ ),
5430
+ {
5431
+ method: "POST",
5432
+ credentials: "include",
5433
+ headers: {
5434
+ accept: "application/json",
5435
+ "content-type": "application/json"
5436
+ },
5437
+ body: "{}"
5438
+ }
5439
+ );
5440
+ const payload = await readJsonPayload(response);
5441
+ if (isRuntimeEnvelopeFailure(response, payload)) {
5442
+ throw createRuntimeHttpError(
5443
+ response,
5444
+ payload,
5445
+ payload?.message || `Token refresh failed: ${response.status}`
5446
+ );
5447
+ }
5448
+ const data = unwrapRuntimePayload(payload);
5449
+ const nextAccessToken = getRecordString(data, "accessToken") || getRecordString(data, "token");
5450
+ if (!nextAccessToken) {
5451
+ throw createRuntimeError({
5452
+ type: "unauthenticated",
5453
+ status: response.status,
5454
+ code: getRecordValue2(payload, "code"),
5455
+ message: "Token refresh response missing accessToken",
5456
+ payload
5457
+ });
5458
+ }
5459
+ const nextState = applyAccessToken(nextAccessToken, {
5460
+ expiresAt: getRecordNumber(data, "accessTokenExpiresAt")
5461
+ });
5462
+ setAuthState({
5463
+ status: "authenticated",
5464
+ error: null,
5465
+ refreshedAt: Date.now()
5466
+ });
5467
+ return nextState;
5468
+ })().catch((error) => {
5469
+ const runtimeError = normalizeRuntimeError(error);
5470
+ applyAccessToken(null);
5471
+ setAuthState({ status: "unauthenticated", error: runtimeError });
5472
+ throw runtimeError;
5473
+ }).finally(() => {
5474
+ refreshRequestRef.current = null;
5475
+ });
5476
+ }
5477
+ return refreshRequestRef.current;
5478
+ }, [applyAccessToken, resolvedAppType, resolvedFetch, servicePrefix]);
5375
5479
  const authorizedFetch = useMemo11(
5376
- () => createAuthorizedFetch(resolvedFetch, accessToken),
5377
- [accessToken, resolvedFetch]
5480
+ () => createAuthorizedFetch({
5481
+ appType: resolvedAppType,
5482
+ baseFetch: resolvedFetch,
5483
+ accessTokenRef,
5484
+ markUnauthenticated,
5485
+ refreshAccessToken
5486
+ }),
5487
+ [markUnauthenticated, refreshAccessToken, resolvedAppType, resolvedFetch]
5378
5488
  );
5379
5489
  const getAuthHeaders = useCallback8(() => {
5380
5490
  const state2 = accessTokenRef.current;
@@ -5400,13 +5510,13 @@ var OpenXiangdaProvider = ({
5400
5510
  return;
5401
5511
  }
5402
5512
  setState((prev) => ({ ...prev, loading: true, error: null }));
5403
- const requestFetch = options.accessToken !== void 0 ? createAuthorizedFetch(
5513
+ const requestFetch = options.accessToken !== void 0 ? createAccessTokenFetch(
5404
5514
  resolvedFetch,
5405
5515
  createAccessTokenState(
5406
5516
  options.accessToken || null,
5407
5517
  options.accessTokenOptions
5408
5518
  )
5409
- ) : createAuthorizedFetch(resolvedFetch, accessTokenRef.current);
5519
+ ) : authorizedFetch;
5410
5520
  try {
5411
5521
  const response = await requestFetch(
5412
5522
  buildServiceUrl2(
@@ -5428,19 +5538,29 @@ var OpenXiangdaProvider = ({
5428
5538
  payload?.message || `Runtime bootstrap failed: ${response.status}`
5429
5539
  );
5430
5540
  }
5541
+ const nextData = payload?.data || null;
5431
5542
  setState({
5432
- data: payload?.data || null,
5543
+ data: nextData,
5433
5544
  loading: false,
5434
5545
  error: null
5435
5546
  });
5547
+ if (isAuthenticatedBootstrap(nextData)) {
5548
+ setAuthState(
5549
+ (prev) => prev.status === "authenticated" ? prev : { status: "authenticated", error: null }
5550
+ );
5551
+ }
5436
5552
  } catch (error) {
5553
+ const runtimeError = normalizeRuntimeError(error);
5437
5554
  setState({
5438
5555
  data: null,
5439
5556
  loading: false,
5440
- error: normalizeRuntimeError(error)
5557
+ error: runtimeError
5441
5558
  });
5559
+ if (runtimeError.type === "unauthenticated") {
5560
+ setAuthState({ status: "unauthenticated", error: runtimeError });
5561
+ }
5442
5562
  }
5443
- }, [resolvedAppType, resolvedFetch, servicePrefix]);
5563
+ }, [authorizedFetch, resolvedAppType, resolvedFetch, servicePrefix]);
5444
5564
  useEffect9(() => {
5445
5565
  void reload();
5446
5566
  }, [reload]);
@@ -5451,6 +5571,7 @@ var OpenXiangdaProvider = ({
5451
5571
  servicePrefix,
5452
5572
  fetchImpl: authorizedFetch,
5453
5573
  baseFetchImpl: resolvedFetch,
5574
+ authState,
5454
5575
  getAuthHeaders,
5455
5576
  reload,
5456
5577
  setAccessToken
@@ -5462,7 +5583,8 @@ var OpenXiangdaProvider = ({
5462
5583
  resolvedAppType,
5463
5584
  resolvedFetch,
5464
5585
  servicePrefix,
5465
- state
5586
+ state,
5587
+ authState
5466
5588
  ]
5467
5589
  );
5468
5590
  return /* @__PURE__ */ jsx10(OpenXiangdaRuntimeContext.Provider, { value, children });
@@ -5729,7 +5851,7 @@ var useRuntimeAuth = () => {
5729
5851
  buildServiceUrl2(runtime.servicePrefix, "/api/sso/status"),
5730
5852
  { domain }
5731
5853
  );
5732
- const statusResponse = await runtime.fetchImpl(statusUrl, {
5854
+ const statusResponse = await runtime.baseFetchImpl(statusUrl, {
5733
5855
  credentials: "include",
5734
5856
  headers: { accept: "application/json" }
5735
5857
  });
@@ -5740,7 +5862,7 @@ var useRuntimeAuth = () => {
5740
5862
  enabled && (sso.forceLogin ?? sso.autoRedirect ?? true)
5741
5863
  );
5742
5864
  if (shouldUseSso) {
5743
- const loginUrlResponse = await runtime.fetchImpl(
5865
+ const loginUrlResponse = await runtime.baseFetchImpl(
5744
5866
  withQuery(buildServiceUrl2(runtime.servicePrefix, "/api/sso/login-url"), {
5745
5867
  domain,
5746
5868
  redirectUri,
@@ -5764,7 +5886,7 @@ var useRuntimeAuth = () => {
5764
5886
  }
5765
5887
  return attachCallback("/platform/login", redirectUri);
5766
5888
  },
5767
- [runtime.data?.app, runtime.fetchImpl, runtime.servicePrefix]
5889
+ [runtime.baseFetchImpl, runtime.data?.app, runtime.servicePrefix]
5768
5890
  );
5769
5891
  const redirectToLogin = useCallback8(
5770
5892
  async (options = {}) => {
@@ -5781,7 +5903,7 @@ var useRuntimeAuth = () => {
5781
5903
  [resolveLoginUrl2]
5782
5904
  );
5783
5905
  const logout = useCallback8(async () => {
5784
- const response = await runtime.fetchImpl(
5906
+ const response = await runtime.baseFetchImpl(
5785
5907
  buildServiceUrl2(runtime.servicePrefix, "/api/auth/logout"),
5786
5908
  {
5787
5909
  method: "POST",
@@ -5797,8 +5919,9 @@ var useRuntimeAuth = () => {
5797
5919
  payload?.message || `Logout failed: ${response.status}`
5798
5920
  );
5799
5921
  }
5922
+ runtime.setAccessToken(null);
5800
5923
  return payload;
5801
- }, [runtime.fetchImpl, runtime.servicePrefix]);
5924
+ }, [runtime.baseFetchImpl, runtime.servicePrefix, runtime.setAccessToken]);
5802
5925
  const logoutAndRedirect = useCallback8(
5803
5926
  async (options = {}) => {
5804
5927
  try {
@@ -5810,19 +5933,93 @@ var useRuntimeAuth = () => {
5810
5933
  },
5811
5934
  [logout, redirectToLogin]
5812
5935
  );
5813
- return {
5814
- logout,
5815
- logoutAndRedirect,
5816
- redirectToLogin,
5817
- resolveLoginUrl: resolveLoginUrl2
5818
- };
5936
+ return useMemo11(
5937
+ () => ({
5938
+ logout,
5939
+ logoutAndRedirect,
5940
+ redirectToLogin,
5941
+ resolveLoginUrl: resolveLoginUrl2
5942
+ }),
5943
+ [logout, logoutAndRedirect, redirectToLogin, resolveLoginUrl2]
5944
+ );
5945
+ };
5946
+ var RuntimeAuthGuard = ({
5947
+ children,
5948
+ fallback = null,
5949
+ disabled = false,
5950
+ excludedPaths = [],
5951
+ ...redirectOptions
5952
+ }) => {
5953
+ const runtime = useOpenXiangda();
5954
+ const auth = useRuntimeAuth();
5955
+ const redirectedRef = useRef5(false);
5956
+ const currentPath = getCurrentPathname();
5957
+ const excluded = isRuntimeAuthGuardExcluded(
5958
+ currentPath,
5959
+ runtime.appType,
5960
+ excludedPaths
5961
+ );
5962
+ const shouldRedirect = !disabled && !excluded && !runtime.loading && (runtime.authState.status === "unauthenticated" || runtime.error?.type === "unauthenticated");
5963
+ useEffect9(() => {
5964
+ if (!shouldRedirect || redirectedRef.current) return;
5965
+ redirectedRef.current = true;
5966
+ void auth.redirectToLogin({
5967
+ ...redirectOptions,
5968
+ redirectUri: redirectOptions.redirectUri || getCurrentHref4()
5969
+ }).catch(() => {
5970
+ redirectedRef.current = false;
5971
+ });
5972
+ }, [
5973
+ auth,
5974
+ redirectOptions.domain,
5975
+ redirectOptions.loginUrl,
5976
+ redirectOptions.redirectUri,
5977
+ redirectOptions.replace,
5978
+ shouldRedirect
5979
+ ]);
5980
+ if (excluded) return /* @__PURE__ */ jsx10(Fragment5, { children });
5981
+ if (shouldRedirect) return /* @__PURE__ */ jsx10(Fragment5, { children: fallback });
5982
+ return /* @__PURE__ */ jsx10(Fragment5, { children });
5819
5983
  };
5820
5984
  var buildServiceUrl2 = (servicePrefix, path) => {
5821
5985
  const prefix = servicePrefix.endsWith("/") ? servicePrefix.slice(0, -1) : servicePrefix;
5822
5986
  const suffix = path.startsWith("/") ? path : `/${path}`;
5823
5987
  return `${prefix}${suffix}`;
5824
5988
  };
5825
- var createAuthorizedFetch = (baseFetch, accessToken) => {
5989
+ var createAuthorizedFetch = ({
5990
+ appType,
5991
+ baseFetch,
5992
+ accessTokenRef,
5993
+ refreshAccessToken,
5994
+ markUnauthenticated
5995
+ }) => (async (input, init = {}) => {
5996
+ const currentTokenState = accessTokenRef.current;
5997
+ const response = await createAccessTokenFetch(
5998
+ baseFetch,
5999
+ currentTokenState
6000
+ )(input, init);
6001
+ if (!shouldAttemptAuthRefresh({
6002
+ appType,
6003
+ input,
6004
+ init,
6005
+ tokenState: currentTokenState
6006
+ })) {
6007
+ return response;
6008
+ }
6009
+ if (!await isUnauthenticatedResponse(response)) return response;
6010
+ try {
6011
+ const refreshedTokenState = await refreshAccessToken();
6012
+ if (!refreshedTokenState) return response;
6013
+ return await createAccessTokenFetch(
6014
+ baseFetch,
6015
+ refreshedTokenState
6016
+ )(input, init);
6017
+ } catch (error) {
6018
+ markUnauthenticated(error);
6019
+ return response;
6020
+ }
6021
+ });
6022
+ var createAccessTokenFetch = (baseFetch, accessToken) => {
5826
6023
  if (!accessToken) return baseFetch;
5827
6024
  return ((input, init = {}) => {
5828
6025
  const token = resolveAccessTokenForCurrentRoute(accessToken);
@@ -5840,8 +6037,53 @@ var createAuthorizedFetch = (baseFetch, accessToken) => {
5840
6037
  var createAccessTokenState = (accessToken, options = {}) => accessToken ? {
5841
6038
  token: accessToken,
5842
6039
  scope: options.scope || "default",
5843
- path: options.path || null
6040
+ path: options.path || null,
6041
+ expiresAt: options.expiresAt
5844
6042
  } : null;
6043
+ var shouldAttemptAuthRefresh = ({
6044
+ appType,
6045
+ input,
6046
+ init,
6047
+ tokenState
6048
+ }) => {
6049
+ if (!appType) return false;
6050
+ if (tokenState?.scope === "public") return false;
6051
+ if (isPublicRoutePath(normalizeRoutePath(getCurrentPathname()))) return false;
6052
+ if (hasAuthorizationHeader(init?.headers)) return false;
6053
+ const pathname = getFetchInputPathname(input);
6054
+ if (!pathname) return false;
6055
+ if (/\/openxiangda-api\/v1\/apps\/[^/]+\/auth(?:\/|$)/.test(pathname)) {
6056
+ return false;
6057
+ }
6058
+ if (/\/openxiangda-api\/v1\/apps\/[^/]+\/public\/session(?:\/|$)/.test(pathname)) {
6059
+ return false;
6060
+ }
6061
+ if (/\/openxiangda-api\/v1\/auth(?:\/|$)/.test(pathname)) return false;
6062
+ if (/\/api\/auth\/logout(?:\/|$)/.test(pathname)) return false;
6063
+ if (/\/api\/sso(?:\/|$)/.test(pathname)) return false;
6064
+ return true;
6065
+ };
6066
+ var isUnauthenticatedResponse = async (response) => {
6067
+ if (response.status === 401) return true;
6068
+ const payload = await readJsonPayload(response.clone());
6069
+ const code = getRecordValue2(payload, "code");
6070
+ return classifyRuntimeError(response.status, code) === "unauthenticated";
6071
+ };
6072
+ var hasAuthorizationHeader = (headers) => {
6073
+ if (!headers) return false;
6074
+ const normalized = new Headers(headers);
6075
+ return normalized.has("authorization");
6076
+ };
6077
+ var getFetchInputPathname = (input) => {
6078
+ const text = typeof input === "string" ? input : input instanceof URL ? input.toString() : typeof Request !== "undefined" && input instanceof Request ? input.url : String(input || "");
6079
+ if (!text) return "";
6080
+ try {
6081
+ const base = typeof window !== "undefined" ? window.location.origin : "http://localhost";
6082
+ return new URL(text, base).pathname;
6083
+ } catch {
6084
+ return text.split(/[?#]/, 1)[0] || "";
6085
+ }
6086
+ };
5845
6087
  var resolveAccessTokenForCurrentRoute = (accessToken) => {
5846
6088
  if (accessToken.scope !== "public") return accessToken.token;
5847
6089
  const scopedPath = normalizeRoutePath(accessToken.path);
@@ -6026,6 +6268,31 @@ var getRecordString = (value, key) => {
6026
6268
  const result = getRecordValue2(value, key);
6027
6269
  return typeof result === "string" ? result : void 0;
6028
6270
  };
6271
+ var getRecordNumber = (value, key) => {
6272
+ const result = getRecordValue2(value, key);
6273
+ const numberValue = Number(result);
6274
+ return Number.isFinite(numberValue) ? numberValue : void 0;
6275
+ };
6276
+ var unwrapRuntimePayload = (payload) => {
6277
+ if (!payload || typeof payload !== "object") return payload;
6278
+ const record = payload;
6279
+ return "data" in record ? record.data : payload;
6280
+ };
6281
+ var isAuthenticatedBootstrap = (value) => {
6282
+ if (!value || typeof value !== "object") return false;
6283
+ const user = toRuntimeRecord(getRecordValue2(value, "user"));
6284
+ if (!getRecordValue2(user, "id") && !getRecordValue2(user, "username")) {
6285
+ return false;
6286
+ }
6287
+ return !getRecordValue2(user, "publicAccess");
6288
+ };
6289
+ var isRuntimeAuthGuardExcluded = (path, appType, excludedPaths) => {
6290
+ const normalizedPath = normalizeRoutePath(path);
6291
+ if (isPublicRoutePath(normalizedPath)) return true;
6292
+ const loginPath = normalizeRoutePath(`/view/${encodeURIComponent(appType)}/login`);
6293
+ if (appType && normalizedPath === loginPath) return true;
6294
+ return excludedPaths.map((item) => normalizeRoutePath(item)).some((item) => item && normalizedPath === item);
6295
+ };
6029
6296
  var resolveAppTypeFromLocation = () => {
6030
6297
  if (typeof window === "undefined") return "";
6031
6298
  const segments = window.location.pathname.split("/").filter(Boolean);
@@ -6287,6 +6554,7 @@ export {
6287
6554
  ProcessTimeline,
6288
6555
  PublicAccessClientError,
6289
6556
  PublicAccessGate,
6557
+ RuntimeAuthGuard,
6290
6558
  createAuthClient,
6291
6559
  createPageSdk,
6292
6560
  createPublicAccessClient,