@djangocfg/api 2.1.581 → 2.1.583
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/README.md +18 -0
- package/dist/auth.cjs +272 -80
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +272 -80
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +243 -54
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.mjs +243 -54
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +243 -54
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +243 -54
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +248 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.mjs +248 -54
- package/dist/index.mjs.map +1 -1
- package/dist/storage.cjs +269 -0
- package/dist/storage.cjs.map +1 -0
- package/dist/storage.d.cts +85 -0
- package/dist/storage.d.ts +85 -0
- package/dist/storage.mjs +248 -0
- package/dist/storage.mjs.map +1 -0
- package/package.json +8 -2
- package/src/__tests__/noStorageLiterals.test.ts +27 -0
- package/src/__tests__/storage.test.ts +134 -0
- package/src/__tests__/storageSsr.test.ts +14 -0
- package/src/_api/generated/helpers/auth.ts +27 -64
- package/src/_api/generated/helpers/index.ts +12 -0
- package/src/_api/generated/helpers/keys.ts +328 -0
- package/src/auth/__tests__/authRedirect.test.ts +1 -1
- package/src/auth/__tests__/profileCache.test.ts +1 -1
- package/src/auth/context/AuthContext.tsx +2 -1
- package/src/auth/hooks/useAuthRedirect.ts +3 -2
- package/src/auth/hooks/useGithubAuth.ts +13 -8
- package/src/auth/hooks/useLocalStorage.ts +7 -7
- package/src/auth/hooks/useProfileCache.ts +2 -1
- package/src/auth/hooks/useSessionStorage.ts +7 -7
- package/src/storage.ts +21 -0
package/dist/index.d.cts
CHANGED
|
@@ -2473,6 +2473,90 @@ declare class NetworkError extends Error {
|
|
|
2473
2473
|
constructor(message: string, url: string, originalError?: Error | undefined);
|
|
2474
2474
|
}
|
|
2475
2475
|
|
|
2476
|
+
type KeyStore = 'local' | 'session' | 'cookie';
|
|
2477
|
+
interface KeySpec {
|
|
2478
|
+
/** The canonical key. */
|
|
2479
|
+
readonly key: string;
|
|
2480
|
+
readonly store: KeyStore;
|
|
2481
|
+
/** Removed by `clearAll()` (sign-out). Preferences are kept. */
|
|
2482
|
+
readonly personal: boolean;
|
|
2483
|
+
}
|
|
2484
|
+
interface FamilySpec {
|
|
2485
|
+
/** Canonical prefix ending in a dot; the id is appended in normalised form. */
|
|
2486
|
+
readonly prefix: string;
|
|
2487
|
+
readonly store: 'local' | 'session';
|
|
2488
|
+
readonly personal: boolean;
|
|
2489
|
+
}
|
|
2490
|
+
/** Every key the framework writes. No legacy spellings are read: old keys are simply ignored. */
|
|
2491
|
+
declare const CFG_KEYS: {
|
|
2492
|
+
readonly accessToken: KeySpec;
|
|
2493
|
+
readonly refreshToken: KeySpec;
|
|
2494
|
+
readonly apiKey: KeySpec;
|
|
2495
|
+
readonly email: KeySpec;
|
|
2496
|
+
readonly emailTs: KeySpec;
|
|
2497
|
+
readonly redirectUrl: KeySpec;
|
|
2498
|
+
readonly redirectUrlTs: KeySpec;
|
|
2499
|
+
readonly oauthState: KeySpec;
|
|
2500
|
+
readonly oauthProvider: KeySpec;
|
|
2501
|
+
readonly oauthRememberMe: KeySpec;
|
|
2502
|
+
readonly profileCache: KeySpec;
|
|
2503
|
+
readonly monitorSessionId: KeySpec;
|
|
2504
|
+
readonly monitorSessionCookie: KeySpec;
|
|
2505
|
+
readonly monitorDebug: KeySpec;
|
|
2506
|
+
readonly uiTabId: KeySpec;
|
|
2507
|
+
readonly uiRouterSerial: KeySpec;
|
|
2508
|
+
readonly uiState: KeySpec;
|
|
2509
|
+
readonly chatSpeechLanguage: KeySpec;
|
|
2510
|
+
readonly chatRecentTools: KeySpec;
|
|
2511
|
+
readonly formsSpeechDebug: KeySpec;
|
|
2512
|
+
readonly formsSpeechPrefs: KeySpec;
|
|
2513
|
+
readonly agentPlaygroundApiKeyId: KeySpec;
|
|
2514
|
+
readonly agentPlaygroundBearer: KeySpec;
|
|
2515
|
+
readonly agentEndpointDoc: KeySpec;
|
|
2516
|
+
};
|
|
2517
|
+
/** Keys with a caller-supplied id part: one per room, tree, endpoint. */
|
|
2518
|
+
declare const CFG_FAMILIES: {
|
|
2519
|
+
readonly chatDraft: FamilySpec;
|
|
2520
|
+
readonly dataTree: FamilySpec;
|
|
2521
|
+
readonly agentEndpointDraft: FamilySpec;
|
|
2522
|
+
};
|
|
2523
|
+
/** One segment of a key: lower case, `[a-z0-9_]`, anything else folded to `_`. */
|
|
2524
|
+
declare function normalizeSegment(raw: string): string;
|
|
2525
|
+
interface StorageOptions {
|
|
2526
|
+
/** Named keys of this owner. */
|
|
2527
|
+
readonly keys?: Readonly<Record<string, KeySpec>>;
|
|
2528
|
+
readonly families?: Readonly<Record<string, FamilySpec>>;
|
|
2529
|
+
/** Cookie lifetime for the `cookie` store. Default 30 days. */
|
|
2530
|
+
readonly cookieMaxAgeSeconds?: number;
|
|
2531
|
+
}
|
|
2532
|
+
interface GuardedStorage {
|
|
2533
|
+
readonly owner: string;
|
|
2534
|
+
/** Builds `<owner>.<part>.<part>` from free-form parts; throws if a part is empty. */
|
|
2535
|
+
key(...parts: string[]): string;
|
|
2536
|
+
/** Builds a family member key: the prefix plus the normalised id. */
|
|
2537
|
+
familyKey(family: FamilySpec, id: string): string;
|
|
2538
|
+
/** `^(cfg|<owner>)(\.[a-z0-9_]+)+$`. */
|
|
2539
|
+
isValid(key: string): boolean;
|
|
2540
|
+
read(key: string, store?: KeyStore): string | null;
|
|
2541
|
+
/** True when the value reached the browser's storage; false means it is held in memory for this page only. */
|
|
2542
|
+
write(key: string, value: string, store?: KeyStore): boolean;
|
|
2543
|
+
/** Removes the key. */
|
|
2544
|
+
remove(key: string, store?: KeyStore): void;
|
|
2545
|
+
readJSON<T>(key: string, store?: KeyStore): T | null;
|
|
2546
|
+
writeJSON(key: string, value: unknown, store?: KeyStore): boolean;
|
|
2547
|
+
/** Keys this owner holds in `store`. */
|
|
2548
|
+
keys(store?: Exclude<KeyStore, 'cookie'>): string[];
|
|
2549
|
+
/** Sign-out: removes the `personal` keys. `{ all: true }` removes everything under this owner. */
|
|
2550
|
+
clearAll(options?: {
|
|
2551
|
+
all?: boolean;
|
|
2552
|
+
}): void;
|
|
2553
|
+
/** Cross-tab: calls `listener` with the new value when ANOTHER tab changes `key`. Cookies fire no events. */
|
|
2554
|
+
onChange(key: string, listener: (value: string | null) => void, store?: Exclude<KeyStore, 'cookie'>): () => void;
|
|
2555
|
+
}
|
|
2556
|
+
declare function createStorage(owner: string, options?: StorageOptions): GuardedStorage;
|
|
2557
|
+
/** The framework's own storage: every `cfg.*` key. */
|
|
2558
|
+
declare const cfgStorage: GuardedStorage;
|
|
2559
|
+
|
|
2476
2560
|
interface ValidationErrorDetail {
|
|
2477
2561
|
operation: string;
|
|
2478
2562
|
path: string;
|
|
@@ -2983,4 +3067,4 @@ declare const isStaticBuild: boolean;
|
|
|
2983
3067
|
*/
|
|
2984
3068
|
declare const dpopEnabled: boolean;
|
|
2985
3069
|
|
|
2986
|
-
export { APIError, APILogger, type AccountDeleteResponse, types_gen$1 as AccountsTypes, type ApiKey, type ApiKeyRegenerate, type ApiKeyRequest, type ApiKeyReveal, type ApiKeyTestRequest, type ApiKeyTestResult, type Auth$1 as Auth, type BackupCodesRegenerateRequest, type BackupCodesRegenerateResponse, type BackupCodesStatus, CfgAccountsOtp as CfgAccounts, API$1 as CfgAccountsAPI, CfgAccountsApi, CfgAccountsApiKey, type CfgAccountsApiKeyRegenerateCreateData, type CfgAccountsApiKeyRegenerateCreateErrors, type CfgAccountsApiKeyRegenerateCreateResponse, type CfgAccountsApiKeyRegenerateCreateResponses, type CfgAccountsApiKeyRetrieveData, type CfgAccountsApiKeyRetrieveErrors, type CfgAccountsApiKeyRetrieveResponse, type CfgAccountsApiKeyRetrieveResponses, type CfgAccountsApiKeyRevealCreateData, type CfgAccountsApiKeyRevealCreateErrors, type CfgAccountsApiKeyRevealCreateResponse, type CfgAccountsApiKeyRevealCreateResponses, type CfgAccountsApiKeyTestCreateData, type CfgAccountsApiKeyTestCreateResponse, type CfgAccountsApiKeyTestCreateResponses, CfgAccountsAuth, CfgAccountsOauth, type CfgAccountsOauthConnectionsListData, type CfgAccountsOauthConnectionsListResponse, type CfgAccountsOauthConnectionsListResponses, type CfgAccountsOauthConnectionsResponse200AutoRef, type CfgAccountsOauthDisconnectCreateData, type CfgAccountsOauthDisconnectCreateError, type CfgAccountsOauthDisconnectCreateErrors, type CfgAccountsOauthDisconnectCreateResponse, type CfgAccountsOauthDisconnectCreateResponses, type CfgAccountsOauthDisconnectResponse200AutoRef, type CfgAccountsOauthGithubAuthorizeCreateData, type CfgAccountsOauthGithubAuthorizeCreateError, type CfgAccountsOauthGithubAuthorizeCreateErrors, type CfgAccountsOauthGithubAuthorizeCreateResponse, type CfgAccountsOauthGithubAuthorizeCreateResponses, type CfgAccountsOauthGithubCallbackCreateData, type CfgAccountsOauthGithubCallbackCreateError, type CfgAccountsOauthGithubCallbackCreateErrors, type CfgAccountsOauthGithubCallbackCreateResponse, type CfgAccountsOauthGithubCallbackCreateResponses, type CfgAccountsOauthProvidersRetrieveData, type CfgAccountsOauthProvidersRetrieveResponse, type CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtp, type CfgAccountsOtpConsentPolicyRetrieveData, type CfgAccountsOtpConsentPolicyRetrieveResponse, type CfgAccountsOtpConsentPolicyRetrieveResponses, type CfgAccountsOtpRequestCreateData, type CfgAccountsOtpRequestCreateError, type CfgAccountsOtpRequestCreateErrors, type CfgAccountsOtpRequestCreateResponse, type CfgAccountsOtpRequestCreateResponses, type CfgAccountsOtpVerifyCreateData, type CfgAccountsOtpVerifyCreateError, type CfgAccountsOtpVerifyCreateErrors, type CfgAccountsOtpVerifyCreateResponse, type CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfile, type CfgAccountsProfileAvatarCreateData, type CfgAccountsProfileAvatarCreateErrors, type CfgAccountsProfileAvatarCreateResponse, type CfgAccountsProfileAvatarCreateResponses, type CfgAccountsProfileDeleteCreateData, type CfgAccountsProfileDeleteCreateErrors, type CfgAccountsProfileDeleteCreateResponse, type CfgAccountsProfileDeleteCreateResponses, type CfgAccountsProfilePartialPartialUpdateData, type CfgAccountsProfilePartialPartialUpdateErrors, type CfgAccountsProfilePartialPartialUpdateResponse, type CfgAccountsProfilePartialPartialUpdateResponses, type CfgAccountsProfilePartialUpdateData, type CfgAccountsProfilePartialUpdateErrors, type CfgAccountsProfilePartialUpdateResponse, type CfgAccountsProfilePartialUpdateResponses, type CfgAccountsProfileRetrieveData, type CfgAccountsProfileRetrieveErrors, type CfgAccountsProfileRetrieveResponse, type CfgAccountsProfileRetrieveResponses, type CfgAccountsProfileUpdatePartialUpdateData, type CfgAccountsProfileUpdatePartialUpdateErrors, type CfgAccountsProfileUpdatePartialUpdateResponse, type CfgAccountsProfileUpdatePartialUpdateResponses, type CfgAccountsProfileUpdateUpdateData, type CfgAccountsProfileUpdateUpdateErrors, type CfgAccountsProfileUpdateUpdateResponse, type CfgAccountsProfileUpdateUpdateResponses, type CfgAccountsTokenBlacklistCreateData, type CfgAccountsTokenBlacklistCreateResponses, type CfgAccountsTokenCreateData, type CfgAccountsTokenCreateError, type CfgAccountsTokenCreateErrors, type CfgAccountsTokenCreateResponse, type CfgAccountsTokenCreateResponses, type CfgAccountsTokenRefreshCreateData, type CfgAccountsTokenRefreshCreateResponse, type CfgAccountsTokenRefreshCreateResponses, CfgTotp, API as CfgTotpAPI, CfgTotpApi, CfgTotpBackupCodes, type CfgTotpBackupCodesRegenerateCreateData, type CfgTotpBackupCodesRegenerateCreateErrors, type CfgTotpBackupCodesRegenerateCreateResponse, type CfgTotpBackupCodesRegenerateCreateResponses, type CfgTotpBackupCodesRetrieveData, type CfgTotpBackupCodesRetrieveResponse, type CfgTotpBackupCodesRetrieveResponses, type CfgTotpDevicesDestroyData, type CfgTotpDevicesDestroyResponse, type CfgTotpDevicesDestroyResponses, type CfgTotpDevicesRetrieveData, type CfgTotpDevicesRetrieveResponse, type CfgTotpDevicesRetrieveResponses, type CfgTotpDisableCreateData, type CfgTotpDisableCreateErrors, type CfgTotpDisableCreateResponse, type CfgTotpDisableCreateResponses, type CfgTotpDisableResponse200AutoRef, CfgTotpSetup, type CfgTotpSetupConfirmCreateData, type CfgTotpSetupConfirmCreateErrors, type CfgTotpSetupConfirmCreateResponse, type CfgTotpSetupConfirmCreateResponses, type CfgTotpSetupCreateData, type CfgTotpSetupCreateErrors, type CfgTotpSetupCreateResponse, type CfgTotpSetupCreateResponses, CfgTotpVerify, type CfgTotpVerifyBackupCreateData, type CfgTotpVerifyBackupCreateErrors, type CfgTotpVerifyBackupCreateResponse, type CfgTotpVerifyBackupCreateResponses, type CfgTotpVerifyCreateData, type CfgTotpVerifyCreateErrors, type CfgTotpVerifyCreateResponse, type CfgTotpVerifyCreateResponses, type CfgUserUpdateRequest, type ClientOptions, type ConfirmSetupRequest, type ConfirmSetupResponse, type ConsentPolicy, type ConsolaLevel, CookieStorageAdapter, type DeviceList, type DeviceListResponse, type DeviceListResponseWritable, DeviceStatusEnum, type DisableRequest, type ErrorLog, LocalStorageAdapter, type LoggerConfig, MarketingConsentDefaultEnum, MemoryStorageAdapter, NetworkError, type OAuthAuthorizeRequestRequest, type OAuthAuthorizeResponse, type OAuthCallbackRequestRequest, type OAuthConnection, type OAuthDisconnectRequestRequest, type OAuthError, OAuthProviderEnum, type OAuthProvidersResponse, type OAuthTokenResponse, type OtpErrorResponse, type OtpRequestRequest, type OtpRequestResponse, type OtpVerifyRequest, type OtpVerifyResponse, type OtpVerifyResponseWritable, type PasswordLoginError, type PasswordLoginRequest, type PasswordLoginRequestWritable, type PasswordLoginResponse, type PasswordLoginResponseWritable, type PatchedCfgUserUpdateRequest, type RequestLog, type ResponseLog, type SetupRequest, type SetupResponse, type StorageAdapter, type TokenBlacklistRequest, type TokenRefresh, type TokenRefreshRequest, type TokenRefreshWritable, types_gen as TotpTypes, type TotpVerifyUser, type TotpVerifyUserWritable, type User, type UserWritable, type ValidationErrorDetail, type ValidationErrorEvent, type VerifyBackupRequest, type VerifyRequest, type VerifyResponse, type VerifyResponseWritable, type WebmailLink, WebmailLinkProviderEnum, CfgAccountsApi as api, applyRoleLogPolicy, auth, defaultLogger, dispatchValidationError, dpopEnabled, formatZodError, getLogLevel, isBrowser, isDev, isProd, isStaticBuild, onLogLevelChange, onValidationError, setLogLevel };
|
|
3070
|
+
export { APIError, APILogger, type AccountDeleteResponse, types_gen$1 as AccountsTypes, type ApiKey, type ApiKeyRegenerate, type ApiKeyRequest, type ApiKeyReveal, type ApiKeyTestRequest, type ApiKeyTestResult, type Auth$1 as Auth, type BackupCodesRegenerateRequest, type BackupCodesRegenerateResponse, type BackupCodesStatus, CFG_FAMILIES, CFG_KEYS, CfgAccountsOtp as CfgAccounts, API$1 as CfgAccountsAPI, CfgAccountsApi, CfgAccountsApiKey, type CfgAccountsApiKeyRegenerateCreateData, type CfgAccountsApiKeyRegenerateCreateErrors, type CfgAccountsApiKeyRegenerateCreateResponse, type CfgAccountsApiKeyRegenerateCreateResponses, type CfgAccountsApiKeyRetrieveData, type CfgAccountsApiKeyRetrieveErrors, type CfgAccountsApiKeyRetrieveResponse, type CfgAccountsApiKeyRetrieveResponses, type CfgAccountsApiKeyRevealCreateData, type CfgAccountsApiKeyRevealCreateErrors, type CfgAccountsApiKeyRevealCreateResponse, type CfgAccountsApiKeyRevealCreateResponses, type CfgAccountsApiKeyTestCreateData, type CfgAccountsApiKeyTestCreateResponse, type CfgAccountsApiKeyTestCreateResponses, CfgAccountsAuth, CfgAccountsOauth, type CfgAccountsOauthConnectionsListData, type CfgAccountsOauthConnectionsListResponse, type CfgAccountsOauthConnectionsListResponses, type CfgAccountsOauthConnectionsResponse200AutoRef, type CfgAccountsOauthDisconnectCreateData, type CfgAccountsOauthDisconnectCreateError, type CfgAccountsOauthDisconnectCreateErrors, type CfgAccountsOauthDisconnectCreateResponse, type CfgAccountsOauthDisconnectCreateResponses, type CfgAccountsOauthDisconnectResponse200AutoRef, type CfgAccountsOauthGithubAuthorizeCreateData, type CfgAccountsOauthGithubAuthorizeCreateError, type CfgAccountsOauthGithubAuthorizeCreateErrors, type CfgAccountsOauthGithubAuthorizeCreateResponse, type CfgAccountsOauthGithubAuthorizeCreateResponses, type CfgAccountsOauthGithubCallbackCreateData, type CfgAccountsOauthGithubCallbackCreateError, type CfgAccountsOauthGithubCallbackCreateErrors, type CfgAccountsOauthGithubCallbackCreateResponse, type CfgAccountsOauthGithubCallbackCreateResponses, type CfgAccountsOauthProvidersRetrieveData, type CfgAccountsOauthProvidersRetrieveResponse, type CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtp, type CfgAccountsOtpConsentPolicyRetrieveData, type CfgAccountsOtpConsentPolicyRetrieveResponse, type CfgAccountsOtpConsentPolicyRetrieveResponses, type CfgAccountsOtpRequestCreateData, type CfgAccountsOtpRequestCreateError, type CfgAccountsOtpRequestCreateErrors, type CfgAccountsOtpRequestCreateResponse, type CfgAccountsOtpRequestCreateResponses, type CfgAccountsOtpVerifyCreateData, type CfgAccountsOtpVerifyCreateError, type CfgAccountsOtpVerifyCreateErrors, type CfgAccountsOtpVerifyCreateResponse, type CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfile, type CfgAccountsProfileAvatarCreateData, type CfgAccountsProfileAvatarCreateErrors, type CfgAccountsProfileAvatarCreateResponse, type CfgAccountsProfileAvatarCreateResponses, type CfgAccountsProfileDeleteCreateData, type CfgAccountsProfileDeleteCreateErrors, type CfgAccountsProfileDeleteCreateResponse, type CfgAccountsProfileDeleteCreateResponses, type CfgAccountsProfilePartialPartialUpdateData, type CfgAccountsProfilePartialPartialUpdateErrors, type CfgAccountsProfilePartialPartialUpdateResponse, type CfgAccountsProfilePartialPartialUpdateResponses, type CfgAccountsProfilePartialUpdateData, type CfgAccountsProfilePartialUpdateErrors, type CfgAccountsProfilePartialUpdateResponse, type CfgAccountsProfilePartialUpdateResponses, type CfgAccountsProfileRetrieveData, type CfgAccountsProfileRetrieveErrors, type CfgAccountsProfileRetrieveResponse, type CfgAccountsProfileRetrieveResponses, type CfgAccountsProfileUpdatePartialUpdateData, type CfgAccountsProfileUpdatePartialUpdateErrors, type CfgAccountsProfileUpdatePartialUpdateResponse, type CfgAccountsProfileUpdatePartialUpdateResponses, type CfgAccountsProfileUpdateUpdateData, type CfgAccountsProfileUpdateUpdateErrors, type CfgAccountsProfileUpdateUpdateResponse, type CfgAccountsProfileUpdateUpdateResponses, type CfgAccountsTokenBlacklistCreateData, type CfgAccountsTokenBlacklistCreateResponses, type CfgAccountsTokenCreateData, type CfgAccountsTokenCreateError, type CfgAccountsTokenCreateErrors, type CfgAccountsTokenCreateResponse, type CfgAccountsTokenCreateResponses, type CfgAccountsTokenRefreshCreateData, type CfgAccountsTokenRefreshCreateResponse, type CfgAccountsTokenRefreshCreateResponses, CfgTotp, API as CfgTotpAPI, CfgTotpApi, CfgTotpBackupCodes, type CfgTotpBackupCodesRegenerateCreateData, type CfgTotpBackupCodesRegenerateCreateErrors, type CfgTotpBackupCodesRegenerateCreateResponse, type CfgTotpBackupCodesRegenerateCreateResponses, type CfgTotpBackupCodesRetrieveData, type CfgTotpBackupCodesRetrieveResponse, type CfgTotpBackupCodesRetrieveResponses, type CfgTotpDevicesDestroyData, type CfgTotpDevicesDestroyResponse, type CfgTotpDevicesDestroyResponses, type CfgTotpDevicesRetrieveData, type CfgTotpDevicesRetrieveResponse, type CfgTotpDevicesRetrieveResponses, type CfgTotpDisableCreateData, type CfgTotpDisableCreateErrors, type CfgTotpDisableCreateResponse, type CfgTotpDisableCreateResponses, type CfgTotpDisableResponse200AutoRef, CfgTotpSetup, type CfgTotpSetupConfirmCreateData, type CfgTotpSetupConfirmCreateErrors, type CfgTotpSetupConfirmCreateResponse, type CfgTotpSetupConfirmCreateResponses, type CfgTotpSetupCreateData, type CfgTotpSetupCreateErrors, type CfgTotpSetupCreateResponse, type CfgTotpSetupCreateResponses, CfgTotpVerify, type CfgTotpVerifyBackupCreateData, type CfgTotpVerifyBackupCreateErrors, type CfgTotpVerifyBackupCreateResponse, type CfgTotpVerifyBackupCreateResponses, type CfgTotpVerifyCreateData, type CfgTotpVerifyCreateErrors, type CfgTotpVerifyCreateResponse, type CfgTotpVerifyCreateResponses, type CfgUserUpdateRequest, type ClientOptions, type ConfirmSetupRequest, type ConfirmSetupResponse, type ConsentPolicy, type ConsolaLevel, CookieStorageAdapter, type DeviceList, type DeviceListResponse, type DeviceListResponseWritable, DeviceStatusEnum, type DisableRequest, type ErrorLog, type FamilySpec, type GuardedStorage, type KeySpec, type KeyStore, LocalStorageAdapter, type LoggerConfig, MarketingConsentDefaultEnum, MemoryStorageAdapter, NetworkError, type OAuthAuthorizeRequestRequest, type OAuthAuthorizeResponse, type OAuthCallbackRequestRequest, type OAuthConnection, type OAuthDisconnectRequestRequest, type OAuthError, OAuthProviderEnum, type OAuthProvidersResponse, type OAuthTokenResponse, type OtpErrorResponse, type OtpRequestRequest, type OtpRequestResponse, type OtpVerifyRequest, type OtpVerifyResponse, type OtpVerifyResponseWritable, type PasswordLoginError, type PasswordLoginRequest, type PasswordLoginRequestWritable, type PasswordLoginResponse, type PasswordLoginResponseWritable, type PatchedCfgUserUpdateRequest, type RequestLog, type ResponseLog, type SetupRequest, type SetupResponse, type StorageAdapter, type StorageOptions, type TokenBlacklistRequest, type TokenRefresh, type TokenRefreshRequest, type TokenRefreshWritable, types_gen as TotpTypes, type TotpVerifyUser, type TotpVerifyUserWritable, type User, type UserWritable, type ValidationErrorDetail, type ValidationErrorEvent, type VerifyBackupRequest, type VerifyRequest, type VerifyResponse, type VerifyResponseWritable, type WebmailLink, WebmailLinkProviderEnum, CfgAccountsApi as api, applyRoleLogPolicy, auth, cfgStorage, createStorage, defaultLogger, dispatchValidationError, dpopEnabled, formatZodError, getLogLevel, isBrowser, isDev, isProd, isStaticBuild, normalizeSegment, onLogLevelChange, onValidationError, setLogLevel };
|
package/dist/index.d.ts
CHANGED
|
@@ -2473,6 +2473,90 @@ declare class NetworkError extends Error {
|
|
|
2473
2473
|
constructor(message: string, url: string, originalError?: Error | undefined);
|
|
2474
2474
|
}
|
|
2475
2475
|
|
|
2476
|
+
type KeyStore = 'local' | 'session' | 'cookie';
|
|
2477
|
+
interface KeySpec {
|
|
2478
|
+
/** The canonical key. */
|
|
2479
|
+
readonly key: string;
|
|
2480
|
+
readonly store: KeyStore;
|
|
2481
|
+
/** Removed by `clearAll()` (sign-out). Preferences are kept. */
|
|
2482
|
+
readonly personal: boolean;
|
|
2483
|
+
}
|
|
2484
|
+
interface FamilySpec {
|
|
2485
|
+
/** Canonical prefix ending in a dot; the id is appended in normalised form. */
|
|
2486
|
+
readonly prefix: string;
|
|
2487
|
+
readonly store: 'local' | 'session';
|
|
2488
|
+
readonly personal: boolean;
|
|
2489
|
+
}
|
|
2490
|
+
/** Every key the framework writes. No legacy spellings are read: old keys are simply ignored. */
|
|
2491
|
+
declare const CFG_KEYS: {
|
|
2492
|
+
readonly accessToken: KeySpec;
|
|
2493
|
+
readonly refreshToken: KeySpec;
|
|
2494
|
+
readonly apiKey: KeySpec;
|
|
2495
|
+
readonly email: KeySpec;
|
|
2496
|
+
readonly emailTs: KeySpec;
|
|
2497
|
+
readonly redirectUrl: KeySpec;
|
|
2498
|
+
readonly redirectUrlTs: KeySpec;
|
|
2499
|
+
readonly oauthState: KeySpec;
|
|
2500
|
+
readonly oauthProvider: KeySpec;
|
|
2501
|
+
readonly oauthRememberMe: KeySpec;
|
|
2502
|
+
readonly profileCache: KeySpec;
|
|
2503
|
+
readonly monitorSessionId: KeySpec;
|
|
2504
|
+
readonly monitorSessionCookie: KeySpec;
|
|
2505
|
+
readonly monitorDebug: KeySpec;
|
|
2506
|
+
readonly uiTabId: KeySpec;
|
|
2507
|
+
readonly uiRouterSerial: KeySpec;
|
|
2508
|
+
readonly uiState: KeySpec;
|
|
2509
|
+
readonly chatSpeechLanguage: KeySpec;
|
|
2510
|
+
readonly chatRecentTools: KeySpec;
|
|
2511
|
+
readonly formsSpeechDebug: KeySpec;
|
|
2512
|
+
readonly formsSpeechPrefs: KeySpec;
|
|
2513
|
+
readonly agentPlaygroundApiKeyId: KeySpec;
|
|
2514
|
+
readonly agentPlaygroundBearer: KeySpec;
|
|
2515
|
+
readonly agentEndpointDoc: KeySpec;
|
|
2516
|
+
};
|
|
2517
|
+
/** Keys with a caller-supplied id part: one per room, tree, endpoint. */
|
|
2518
|
+
declare const CFG_FAMILIES: {
|
|
2519
|
+
readonly chatDraft: FamilySpec;
|
|
2520
|
+
readonly dataTree: FamilySpec;
|
|
2521
|
+
readonly agentEndpointDraft: FamilySpec;
|
|
2522
|
+
};
|
|
2523
|
+
/** One segment of a key: lower case, `[a-z0-9_]`, anything else folded to `_`. */
|
|
2524
|
+
declare function normalizeSegment(raw: string): string;
|
|
2525
|
+
interface StorageOptions {
|
|
2526
|
+
/** Named keys of this owner. */
|
|
2527
|
+
readonly keys?: Readonly<Record<string, KeySpec>>;
|
|
2528
|
+
readonly families?: Readonly<Record<string, FamilySpec>>;
|
|
2529
|
+
/** Cookie lifetime for the `cookie` store. Default 30 days. */
|
|
2530
|
+
readonly cookieMaxAgeSeconds?: number;
|
|
2531
|
+
}
|
|
2532
|
+
interface GuardedStorage {
|
|
2533
|
+
readonly owner: string;
|
|
2534
|
+
/** Builds `<owner>.<part>.<part>` from free-form parts; throws if a part is empty. */
|
|
2535
|
+
key(...parts: string[]): string;
|
|
2536
|
+
/** Builds a family member key: the prefix plus the normalised id. */
|
|
2537
|
+
familyKey(family: FamilySpec, id: string): string;
|
|
2538
|
+
/** `^(cfg|<owner>)(\.[a-z0-9_]+)+$`. */
|
|
2539
|
+
isValid(key: string): boolean;
|
|
2540
|
+
read(key: string, store?: KeyStore): string | null;
|
|
2541
|
+
/** True when the value reached the browser's storage; false means it is held in memory for this page only. */
|
|
2542
|
+
write(key: string, value: string, store?: KeyStore): boolean;
|
|
2543
|
+
/** Removes the key. */
|
|
2544
|
+
remove(key: string, store?: KeyStore): void;
|
|
2545
|
+
readJSON<T>(key: string, store?: KeyStore): T | null;
|
|
2546
|
+
writeJSON(key: string, value: unknown, store?: KeyStore): boolean;
|
|
2547
|
+
/** Keys this owner holds in `store`. */
|
|
2548
|
+
keys(store?: Exclude<KeyStore, 'cookie'>): string[];
|
|
2549
|
+
/** Sign-out: removes the `personal` keys. `{ all: true }` removes everything under this owner. */
|
|
2550
|
+
clearAll(options?: {
|
|
2551
|
+
all?: boolean;
|
|
2552
|
+
}): void;
|
|
2553
|
+
/** Cross-tab: calls `listener` with the new value when ANOTHER tab changes `key`. Cookies fire no events. */
|
|
2554
|
+
onChange(key: string, listener: (value: string | null) => void, store?: Exclude<KeyStore, 'cookie'>): () => void;
|
|
2555
|
+
}
|
|
2556
|
+
declare function createStorage(owner: string, options?: StorageOptions): GuardedStorage;
|
|
2557
|
+
/** The framework's own storage: every `cfg.*` key. */
|
|
2558
|
+
declare const cfgStorage: GuardedStorage;
|
|
2559
|
+
|
|
2476
2560
|
interface ValidationErrorDetail {
|
|
2477
2561
|
operation: string;
|
|
2478
2562
|
path: string;
|
|
@@ -2983,4 +3067,4 @@ declare const isStaticBuild: boolean;
|
|
|
2983
3067
|
*/
|
|
2984
3068
|
declare const dpopEnabled: boolean;
|
|
2985
3069
|
|
|
2986
|
-
export { APIError, APILogger, type AccountDeleteResponse, types_gen$1 as AccountsTypes, type ApiKey, type ApiKeyRegenerate, type ApiKeyRequest, type ApiKeyReveal, type ApiKeyTestRequest, type ApiKeyTestResult, type Auth$1 as Auth, type BackupCodesRegenerateRequest, type BackupCodesRegenerateResponse, type BackupCodesStatus, CfgAccountsOtp as CfgAccounts, API$1 as CfgAccountsAPI, CfgAccountsApi, CfgAccountsApiKey, type CfgAccountsApiKeyRegenerateCreateData, type CfgAccountsApiKeyRegenerateCreateErrors, type CfgAccountsApiKeyRegenerateCreateResponse, type CfgAccountsApiKeyRegenerateCreateResponses, type CfgAccountsApiKeyRetrieveData, type CfgAccountsApiKeyRetrieveErrors, type CfgAccountsApiKeyRetrieveResponse, type CfgAccountsApiKeyRetrieveResponses, type CfgAccountsApiKeyRevealCreateData, type CfgAccountsApiKeyRevealCreateErrors, type CfgAccountsApiKeyRevealCreateResponse, type CfgAccountsApiKeyRevealCreateResponses, type CfgAccountsApiKeyTestCreateData, type CfgAccountsApiKeyTestCreateResponse, type CfgAccountsApiKeyTestCreateResponses, CfgAccountsAuth, CfgAccountsOauth, type CfgAccountsOauthConnectionsListData, type CfgAccountsOauthConnectionsListResponse, type CfgAccountsOauthConnectionsListResponses, type CfgAccountsOauthConnectionsResponse200AutoRef, type CfgAccountsOauthDisconnectCreateData, type CfgAccountsOauthDisconnectCreateError, type CfgAccountsOauthDisconnectCreateErrors, type CfgAccountsOauthDisconnectCreateResponse, type CfgAccountsOauthDisconnectCreateResponses, type CfgAccountsOauthDisconnectResponse200AutoRef, type CfgAccountsOauthGithubAuthorizeCreateData, type CfgAccountsOauthGithubAuthorizeCreateError, type CfgAccountsOauthGithubAuthorizeCreateErrors, type CfgAccountsOauthGithubAuthorizeCreateResponse, type CfgAccountsOauthGithubAuthorizeCreateResponses, type CfgAccountsOauthGithubCallbackCreateData, type CfgAccountsOauthGithubCallbackCreateError, type CfgAccountsOauthGithubCallbackCreateErrors, type CfgAccountsOauthGithubCallbackCreateResponse, type CfgAccountsOauthGithubCallbackCreateResponses, type CfgAccountsOauthProvidersRetrieveData, type CfgAccountsOauthProvidersRetrieveResponse, type CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtp, type CfgAccountsOtpConsentPolicyRetrieveData, type CfgAccountsOtpConsentPolicyRetrieveResponse, type CfgAccountsOtpConsentPolicyRetrieveResponses, type CfgAccountsOtpRequestCreateData, type CfgAccountsOtpRequestCreateError, type CfgAccountsOtpRequestCreateErrors, type CfgAccountsOtpRequestCreateResponse, type CfgAccountsOtpRequestCreateResponses, type CfgAccountsOtpVerifyCreateData, type CfgAccountsOtpVerifyCreateError, type CfgAccountsOtpVerifyCreateErrors, type CfgAccountsOtpVerifyCreateResponse, type CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfile, type CfgAccountsProfileAvatarCreateData, type CfgAccountsProfileAvatarCreateErrors, type CfgAccountsProfileAvatarCreateResponse, type CfgAccountsProfileAvatarCreateResponses, type CfgAccountsProfileDeleteCreateData, type CfgAccountsProfileDeleteCreateErrors, type CfgAccountsProfileDeleteCreateResponse, type CfgAccountsProfileDeleteCreateResponses, type CfgAccountsProfilePartialPartialUpdateData, type CfgAccountsProfilePartialPartialUpdateErrors, type CfgAccountsProfilePartialPartialUpdateResponse, type CfgAccountsProfilePartialPartialUpdateResponses, type CfgAccountsProfilePartialUpdateData, type CfgAccountsProfilePartialUpdateErrors, type CfgAccountsProfilePartialUpdateResponse, type CfgAccountsProfilePartialUpdateResponses, type CfgAccountsProfileRetrieveData, type CfgAccountsProfileRetrieveErrors, type CfgAccountsProfileRetrieveResponse, type CfgAccountsProfileRetrieveResponses, type CfgAccountsProfileUpdatePartialUpdateData, type CfgAccountsProfileUpdatePartialUpdateErrors, type CfgAccountsProfileUpdatePartialUpdateResponse, type CfgAccountsProfileUpdatePartialUpdateResponses, type CfgAccountsProfileUpdateUpdateData, type CfgAccountsProfileUpdateUpdateErrors, type CfgAccountsProfileUpdateUpdateResponse, type CfgAccountsProfileUpdateUpdateResponses, type CfgAccountsTokenBlacklistCreateData, type CfgAccountsTokenBlacklistCreateResponses, type CfgAccountsTokenCreateData, type CfgAccountsTokenCreateError, type CfgAccountsTokenCreateErrors, type CfgAccountsTokenCreateResponse, type CfgAccountsTokenCreateResponses, type CfgAccountsTokenRefreshCreateData, type CfgAccountsTokenRefreshCreateResponse, type CfgAccountsTokenRefreshCreateResponses, CfgTotp, API as CfgTotpAPI, CfgTotpApi, CfgTotpBackupCodes, type CfgTotpBackupCodesRegenerateCreateData, type CfgTotpBackupCodesRegenerateCreateErrors, type CfgTotpBackupCodesRegenerateCreateResponse, type CfgTotpBackupCodesRegenerateCreateResponses, type CfgTotpBackupCodesRetrieveData, type CfgTotpBackupCodesRetrieveResponse, type CfgTotpBackupCodesRetrieveResponses, type CfgTotpDevicesDestroyData, type CfgTotpDevicesDestroyResponse, type CfgTotpDevicesDestroyResponses, type CfgTotpDevicesRetrieveData, type CfgTotpDevicesRetrieveResponse, type CfgTotpDevicesRetrieveResponses, type CfgTotpDisableCreateData, type CfgTotpDisableCreateErrors, type CfgTotpDisableCreateResponse, type CfgTotpDisableCreateResponses, type CfgTotpDisableResponse200AutoRef, CfgTotpSetup, type CfgTotpSetupConfirmCreateData, type CfgTotpSetupConfirmCreateErrors, type CfgTotpSetupConfirmCreateResponse, type CfgTotpSetupConfirmCreateResponses, type CfgTotpSetupCreateData, type CfgTotpSetupCreateErrors, type CfgTotpSetupCreateResponse, type CfgTotpSetupCreateResponses, CfgTotpVerify, type CfgTotpVerifyBackupCreateData, type CfgTotpVerifyBackupCreateErrors, type CfgTotpVerifyBackupCreateResponse, type CfgTotpVerifyBackupCreateResponses, type CfgTotpVerifyCreateData, type CfgTotpVerifyCreateErrors, type CfgTotpVerifyCreateResponse, type CfgTotpVerifyCreateResponses, type CfgUserUpdateRequest, type ClientOptions, type ConfirmSetupRequest, type ConfirmSetupResponse, type ConsentPolicy, type ConsolaLevel, CookieStorageAdapter, type DeviceList, type DeviceListResponse, type DeviceListResponseWritable, DeviceStatusEnum, type DisableRequest, type ErrorLog, LocalStorageAdapter, type LoggerConfig, MarketingConsentDefaultEnum, MemoryStorageAdapter, NetworkError, type OAuthAuthorizeRequestRequest, type OAuthAuthorizeResponse, type OAuthCallbackRequestRequest, type OAuthConnection, type OAuthDisconnectRequestRequest, type OAuthError, OAuthProviderEnum, type OAuthProvidersResponse, type OAuthTokenResponse, type OtpErrorResponse, type OtpRequestRequest, type OtpRequestResponse, type OtpVerifyRequest, type OtpVerifyResponse, type OtpVerifyResponseWritable, type PasswordLoginError, type PasswordLoginRequest, type PasswordLoginRequestWritable, type PasswordLoginResponse, type PasswordLoginResponseWritable, type PatchedCfgUserUpdateRequest, type RequestLog, type ResponseLog, type SetupRequest, type SetupResponse, type StorageAdapter, type TokenBlacklistRequest, type TokenRefresh, type TokenRefreshRequest, type TokenRefreshWritable, types_gen as TotpTypes, type TotpVerifyUser, type TotpVerifyUserWritable, type User, type UserWritable, type ValidationErrorDetail, type ValidationErrorEvent, type VerifyBackupRequest, type VerifyRequest, type VerifyResponse, type VerifyResponseWritable, type WebmailLink, WebmailLinkProviderEnum, CfgAccountsApi as api, applyRoleLogPolicy, auth, defaultLogger, dispatchValidationError, dpopEnabled, formatZodError, getLogLevel, isBrowser, isDev, isProd, isStaticBuild, onLogLevelChange, onValidationError, setLogLevel };
|
|
3070
|
+
export { APIError, APILogger, type AccountDeleteResponse, types_gen$1 as AccountsTypes, type ApiKey, type ApiKeyRegenerate, type ApiKeyRequest, type ApiKeyReveal, type ApiKeyTestRequest, type ApiKeyTestResult, type Auth$1 as Auth, type BackupCodesRegenerateRequest, type BackupCodesRegenerateResponse, type BackupCodesStatus, CFG_FAMILIES, CFG_KEYS, CfgAccountsOtp as CfgAccounts, API$1 as CfgAccountsAPI, CfgAccountsApi, CfgAccountsApiKey, type CfgAccountsApiKeyRegenerateCreateData, type CfgAccountsApiKeyRegenerateCreateErrors, type CfgAccountsApiKeyRegenerateCreateResponse, type CfgAccountsApiKeyRegenerateCreateResponses, type CfgAccountsApiKeyRetrieveData, type CfgAccountsApiKeyRetrieveErrors, type CfgAccountsApiKeyRetrieveResponse, type CfgAccountsApiKeyRetrieveResponses, type CfgAccountsApiKeyRevealCreateData, type CfgAccountsApiKeyRevealCreateErrors, type CfgAccountsApiKeyRevealCreateResponse, type CfgAccountsApiKeyRevealCreateResponses, type CfgAccountsApiKeyTestCreateData, type CfgAccountsApiKeyTestCreateResponse, type CfgAccountsApiKeyTestCreateResponses, CfgAccountsAuth, CfgAccountsOauth, type CfgAccountsOauthConnectionsListData, type CfgAccountsOauthConnectionsListResponse, type CfgAccountsOauthConnectionsListResponses, type CfgAccountsOauthConnectionsResponse200AutoRef, type CfgAccountsOauthDisconnectCreateData, type CfgAccountsOauthDisconnectCreateError, type CfgAccountsOauthDisconnectCreateErrors, type CfgAccountsOauthDisconnectCreateResponse, type CfgAccountsOauthDisconnectCreateResponses, type CfgAccountsOauthDisconnectResponse200AutoRef, type CfgAccountsOauthGithubAuthorizeCreateData, type CfgAccountsOauthGithubAuthorizeCreateError, type CfgAccountsOauthGithubAuthorizeCreateErrors, type CfgAccountsOauthGithubAuthorizeCreateResponse, type CfgAccountsOauthGithubAuthorizeCreateResponses, type CfgAccountsOauthGithubCallbackCreateData, type CfgAccountsOauthGithubCallbackCreateError, type CfgAccountsOauthGithubCallbackCreateErrors, type CfgAccountsOauthGithubCallbackCreateResponse, type CfgAccountsOauthGithubCallbackCreateResponses, type CfgAccountsOauthProvidersRetrieveData, type CfgAccountsOauthProvidersRetrieveResponse, type CfgAccountsOauthProvidersRetrieveResponses, CfgAccountsOtp, type CfgAccountsOtpConsentPolicyRetrieveData, type CfgAccountsOtpConsentPolicyRetrieveResponse, type CfgAccountsOtpConsentPolicyRetrieveResponses, type CfgAccountsOtpRequestCreateData, type CfgAccountsOtpRequestCreateError, type CfgAccountsOtpRequestCreateErrors, type CfgAccountsOtpRequestCreateResponse, type CfgAccountsOtpRequestCreateResponses, type CfgAccountsOtpVerifyCreateData, type CfgAccountsOtpVerifyCreateError, type CfgAccountsOtpVerifyCreateErrors, type CfgAccountsOtpVerifyCreateResponse, type CfgAccountsOtpVerifyCreateResponses, CfgAccountsProfile, type CfgAccountsProfileAvatarCreateData, type CfgAccountsProfileAvatarCreateErrors, type CfgAccountsProfileAvatarCreateResponse, type CfgAccountsProfileAvatarCreateResponses, type CfgAccountsProfileDeleteCreateData, type CfgAccountsProfileDeleteCreateErrors, type CfgAccountsProfileDeleteCreateResponse, type CfgAccountsProfileDeleteCreateResponses, type CfgAccountsProfilePartialPartialUpdateData, type CfgAccountsProfilePartialPartialUpdateErrors, type CfgAccountsProfilePartialPartialUpdateResponse, type CfgAccountsProfilePartialPartialUpdateResponses, type CfgAccountsProfilePartialUpdateData, type CfgAccountsProfilePartialUpdateErrors, type CfgAccountsProfilePartialUpdateResponse, type CfgAccountsProfilePartialUpdateResponses, type CfgAccountsProfileRetrieveData, type CfgAccountsProfileRetrieveErrors, type CfgAccountsProfileRetrieveResponse, type CfgAccountsProfileRetrieveResponses, type CfgAccountsProfileUpdatePartialUpdateData, type CfgAccountsProfileUpdatePartialUpdateErrors, type CfgAccountsProfileUpdatePartialUpdateResponse, type CfgAccountsProfileUpdatePartialUpdateResponses, type CfgAccountsProfileUpdateUpdateData, type CfgAccountsProfileUpdateUpdateErrors, type CfgAccountsProfileUpdateUpdateResponse, type CfgAccountsProfileUpdateUpdateResponses, type CfgAccountsTokenBlacklistCreateData, type CfgAccountsTokenBlacklistCreateResponses, type CfgAccountsTokenCreateData, type CfgAccountsTokenCreateError, type CfgAccountsTokenCreateErrors, type CfgAccountsTokenCreateResponse, type CfgAccountsTokenCreateResponses, type CfgAccountsTokenRefreshCreateData, type CfgAccountsTokenRefreshCreateResponse, type CfgAccountsTokenRefreshCreateResponses, CfgTotp, API as CfgTotpAPI, CfgTotpApi, CfgTotpBackupCodes, type CfgTotpBackupCodesRegenerateCreateData, type CfgTotpBackupCodesRegenerateCreateErrors, type CfgTotpBackupCodesRegenerateCreateResponse, type CfgTotpBackupCodesRegenerateCreateResponses, type CfgTotpBackupCodesRetrieveData, type CfgTotpBackupCodesRetrieveResponse, type CfgTotpBackupCodesRetrieveResponses, type CfgTotpDevicesDestroyData, type CfgTotpDevicesDestroyResponse, type CfgTotpDevicesDestroyResponses, type CfgTotpDevicesRetrieveData, type CfgTotpDevicesRetrieveResponse, type CfgTotpDevicesRetrieveResponses, type CfgTotpDisableCreateData, type CfgTotpDisableCreateErrors, type CfgTotpDisableCreateResponse, type CfgTotpDisableCreateResponses, type CfgTotpDisableResponse200AutoRef, CfgTotpSetup, type CfgTotpSetupConfirmCreateData, type CfgTotpSetupConfirmCreateErrors, type CfgTotpSetupConfirmCreateResponse, type CfgTotpSetupConfirmCreateResponses, type CfgTotpSetupCreateData, type CfgTotpSetupCreateErrors, type CfgTotpSetupCreateResponse, type CfgTotpSetupCreateResponses, CfgTotpVerify, type CfgTotpVerifyBackupCreateData, type CfgTotpVerifyBackupCreateErrors, type CfgTotpVerifyBackupCreateResponse, type CfgTotpVerifyBackupCreateResponses, type CfgTotpVerifyCreateData, type CfgTotpVerifyCreateErrors, type CfgTotpVerifyCreateResponse, type CfgTotpVerifyCreateResponses, type CfgUserUpdateRequest, type ClientOptions, type ConfirmSetupRequest, type ConfirmSetupResponse, type ConsentPolicy, type ConsolaLevel, CookieStorageAdapter, type DeviceList, type DeviceListResponse, type DeviceListResponseWritable, DeviceStatusEnum, type DisableRequest, type ErrorLog, type FamilySpec, type GuardedStorage, type KeySpec, type KeyStore, LocalStorageAdapter, type LoggerConfig, MarketingConsentDefaultEnum, MemoryStorageAdapter, NetworkError, type OAuthAuthorizeRequestRequest, type OAuthAuthorizeResponse, type OAuthCallbackRequestRequest, type OAuthConnection, type OAuthDisconnectRequestRequest, type OAuthError, OAuthProviderEnum, type OAuthProvidersResponse, type OAuthTokenResponse, type OtpErrorResponse, type OtpRequestRequest, type OtpRequestResponse, type OtpVerifyRequest, type OtpVerifyResponse, type OtpVerifyResponseWritable, type PasswordLoginError, type PasswordLoginRequest, type PasswordLoginRequestWritable, type PasswordLoginResponse, type PasswordLoginResponseWritable, type PatchedCfgUserUpdateRequest, type RequestLog, type ResponseLog, type SetupRequest, type SetupResponse, type StorageAdapter, type StorageOptions, type TokenBlacklistRequest, type TokenRefresh, type TokenRefreshRequest, type TokenRefreshWritable, types_gen as TotpTypes, type TotpVerifyUser, type TotpVerifyUserWritable, type User, type UserWritable, type ValidationErrorDetail, type ValidationErrorEvent, type VerifyBackupRequest, type VerifyRequest, type VerifyResponse, type VerifyResponseWritable, type WebmailLink, WebmailLinkProviderEnum, CfgAccountsApi as api, applyRoleLogPolicy, auth, cfgStorage, createStorage, defaultLogger, dispatchValidationError, dpopEnabled, formatZodError, getLogLevel, isBrowser, isDev, isProd, isStaticBuild, normalizeSegment, onLogLevelChange, onValidationError, setLogLevel };
|
package/dist/index.mjs
CHANGED
|
@@ -78,77 +78,264 @@ var NetworkError = class extends Error {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
// src/_api/generated/helpers/
|
|
82
|
-
var
|
|
83
|
-
var
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
// src/_api/generated/helpers/keys.ts
|
|
82
|
+
var k = /* @__PURE__ */ __name((key, store, personal) => ({ key, store, personal }), "k");
|
|
83
|
+
var f = /* @__PURE__ */ __name((prefix, store, personal) => ({ prefix, store, personal }), "f");
|
|
84
|
+
var CFG_KEYS = {
|
|
85
|
+
accessToken: k("cfg.auth.access_token", "local", true),
|
|
86
|
+
refreshToken: k("cfg.auth.refresh_token", "local", true),
|
|
87
|
+
apiKey: k("cfg.auth.api_key", "local", true),
|
|
88
|
+
email: k("cfg.auth.email", "local", false),
|
|
89
|
+
emailTs: k("cfg.auth.email_ts", "local", false),
|
|
90
|
+
redirectUrl: k("cfg.auth.redirect_url", "session", true),
|
|
91
|
+
redirectUrlTs: k("cfg.auth.redirect_url_ts", "session", true),
|
|
92
|
+
oauthState: k("cfg.auth.oauth_state", "session", true),
|
|
93
|
+
oauthProvider: k("cfg.auth.oauth_provider", "session", true),
|
|
94
|
+
oauthRememberMe: k("cfg.auth.oauth_remember_me", "session", true),
|
|
95
|
+
profileCache: k("cfg.profile.cache", "local", true),
|
|
96
|
+
monitorSessionId: k("cfg.monitor.session_id", "local", false),
|
|
97
|
+
monitorSessionCookie: k("cfg.monitor.session_id", "cookie", false),
|
|
98
|
+
monitorDebug: k("cfg.monitor.debug", "local", false),
|
|
99
|
+
uiTabId: k("cfg.ui.tab_id", "session", false),
|
|
100
|
+
uiRouterSerial: k("cfg.ui.router_serial", "session", false),
|
|
101
|
+
uiState: k("cfg.ui.state", "local", false),
|
|
102
|
+
chatSpeechLanguage: k("cfg.chat.speech_language", "local", false),
|
|
103
|
+
chatRecentTools: k("cfg.chat.recent_tools", "local", false),
|
|
104
|
+
formsSpeechDebug: k("cfg.forms.speech_debug", "local", false),
|
|
105
|
+
formsSpeechPrefs: k("cfg.forms.speech_prefs", "local", false),
|
|
106
|
+
agentPlaygroundApiKeyId: k("cfg.agent.playground_api_key_id", "session", true),
|
|
107
|
+
agentPlaygroundBearer: k("cfg.agent.playground_bearer", "session", true),
|
|
108
|
+
agentEndpointDoc: k("cfg.agent.endpoint_doc", "session", false)
|
|
109
|
+
};
|
|
110
|
+
var CFG_FAMILIES = {
|
|
111
|
+
chatDraft: f("cfg.chat.draft.", "session", true),
|
|
112
|
+
dataTree: f("cfg.data.tree.", "local", false),
|
|
113
|
+
agentEndpointDraft: f("cfg.agent.endpoint_draft.", "local", false)
|
|
114
|
+
};
|
|
115
|
+
var OWNER_RE = /^[a-z][a-z0-9_]*$/;
|
|
116
|
+
function normalizeSegment(raw) {
|
|
117
|
+
return raw.trim().toLowerCase().replace(/[^a-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
118
|
+
}
|
|
119
|
+
__name(normalizeSegment, "normalizeSegment");
|
|
120
|
+
var hasWindow = /* @__PURE__ */ __name(() => typeof window !== "undefined", "hasWindow");
|
|
121
|
+
function nativeStorage(store) {
|
|
122
|
+
if (!hasWindow()) return null;
|
|
123
|
+
try {
|
|
124
|
+
return store === "session" ? window.sessionStorage : window.localStorage;
|
|
125
|
+
} catch {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
__name(nativeStorage, "nativeStorage");
|
|
130
|
+
function cookieNames() {
|
|
131
|
+
if (!hasWindow()) return [];
|
|
132
|
+
try {
|
|
133
|
+
return document.cookie.split("; ").map((part) => decodeURIComponent(part.split("=")[0] ?? "")).filter(Boolean);
|
|
134
|
+
} catch {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
__name(cookieNames, "cookieNames");
|
|
139
|
+
function createStorage(owner, options = {}) {
|
|
140
|
+
if (!OWNER_RE.test(owner)) {
|
|
141
|
+
throw new TypeError(`createStorage: owner "${owner}" must match ${OWNER_RE}`);
|
|
142
|
+
}
|
|
143
|
+
const prefix = `${owner}.`;
|
|
144
|
+
const pattern = owner === "cfg" ? /^cfg(\.[a-z0-9_]+)+$/ : new RegExp(`^(cfg|${owner})(\\.[a-z0-9_]+)+$`);
|
|
145
|
+
const cookieMaxAge = options.cookieMaxAgeSeconds ?? 60 * 60 * 24 * 30;
|
|
146
|
+
const specs = Object.values(options.keys ?? {});
|
|
147
|
+
const families = Object.values(options.families ?? {});
|
|
148
|
+
const specByKey = /* @__PURE__ */ new Map();
|
|
149
|
+
for (const spec of specs) specByKey.set(spec.key, [...specByKey.get(spec.key) ?? [], spec]);
|
|
150
|
+
const memory = {
|
|
151
|
+
local: /* @__PURE__ */ new Map(),
|
|
152
|
+
session: /* @__PURE__ */ new Map(),
|
|
153
|
+
cookie: /* @__PURE__ */ new Map()
|
|
154
|
+
};
|
|
155
|
+
const isValid = /* @__PURE__ */ __name((key) => pattern.test(key), "isValid");
|
|
156
|
+
const assertValid = /* @__PURE__ */ __name((key) => {
|
|
157
|
+
if (!isValid(key)) throw new TypeError(`storage key "${key}" must match ${pattern}`);
|
|
158
|
+
}, "assertValid");
|
|
159
|
+
const assertOwned = /* @__PURE__ */ __name((key) => {
|
|
160
|
+
assertValid(key);
|
|
161
|
+
if (!key.startsWith(prefix)) throw new TypeError(`storage key "${key}" is not owned by "${owner}"`);
|
|
162
|
+
}, "assertOwned");
|
|
163
|
+
function rawGet(store, key) {
|
|
164
|
+
if (!hasWindow()) return null;
|
|
165
|
+
if (store === "cookie") {
|
|
166
|
+
try {
|
|
167
|
+
const escaped = encodeURIComponent(key).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
168
|
+
const match = document.cookie.match(new RegExp(`(?:^|;\\s*)${escaped}=([^;]*)`));
|
|
169
|
+
if (match?.[1] !== void 0) return decodeURIComponent(match[1]);
|
|
170
|
+
} catch {
|
|
171
|
+
}
|
|
172
|
+
return memory.cookie.get(key) ?? null;
|
|
93
173
|
}
|
|
94
|
-
},
|
|
95
|
-
set(key, value) {
|
|
96
|
-
if (!isBrowser) return;
|
|
97
174
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
175
|
+
const value = nativeStorage(store)?.getItem(key) ?? null;
|
|
176
|
+
if (value !== null) return value;
|
|
100
177
|
} catch {
|
|
101
178
|
}
|
|
179
|
+
return memory[store].get(key) ?? null;
|
|
102
180
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (!isBrowser) return null;
|
|
181
|
+
__name(rawGet, "rawGet");
|
|
182
|
+
function rawSet(store, key, value) {
|
|
183
|
+
if (!hasWindow()) return false;
|
|
107
184
|
try {
|
|
108
|
-
|
|
185
|
+
if (store === "cookie") {
|
|
186
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
187
|
+
document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}; Path=/; Max-Age=${cookieMaxAge}; SameSite=Lax${secure}`;
|
|
188
|
+
if (rawGet("cookie", key) === value && !memory.cookie.has(key)) return true;
|
|
189
|
+
memory.cookie.set(key, value);
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
const native = nativeStorage(store);
|
|
193
|
+
if (!native) throw new Error("storage unavailable");
|
|
194
|
+
native.setItem(key, value);
|
|
195
|
+
memory[store].delete(key);
|
|
196
|
+
return true;
|
|
109
197
|
} catch {
|
|
110
|
-
|
|
198
|
+
memory[store].set(key, value);
|
|
199
|
+
return false;
|
|
111
200
|
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
201
|
+
}
|
|
202
|
+
__name(rawSet, "rawSet");
|
|
203
|
+
function rawRemove(store, key) {
|
|
204
|
+
memory[store].delete(key);
|
|
205
|
+
if (!hasWindow()) return;
|
|
115
206
|
try {
|
|
116
|
-
if (
|
|
117
|
-
|
|
207
|
+
if (store === "cookie") {
|
|
208
|
+
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
|
209
|
+
document.cookie = `${encodeURIComponent(key)}=; Path=/; Max-Age=0; SameSite=Lax${secure}`;
|
|
210
|
+
} else {
|
|
211
|
+
nativeStorage(store)?.removeItem(key);
|
|
212
|
+
}
|
|
118
213
|
} catch {
|
|
119
214
|
}
|
|
120
215
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
216
|
+
__name(rawRemove, "rawRemove");
|
|
217
|
+
function resolveStore(key, store) {
|
|
218
|
+
return store ?? specByKey.get(key)?.[0]?.store ?? "local";
|
|
219
|
+
}
|
|
220
|
+
__name(resolveStore, "resolveStore");
|
|
221
|
+
function listKeys(store, startsWith) {
|
|
222
|
+
const out = [];
|
|
126
223
|
try {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
224
|
+
const native = nativeStorage(store);
|
|
225
|
+
if (native) {
|
|
226
|
+
for (let i = 0; i < native.length; i += 1) {
|
|
227
|
+
const name = native.key(i);
|
|
228
|
+
if (name?.startsWith(startsWith)) out.push(name);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
131
231
|
} catch {
|
|
132
|
-
return null;
|
|
133
232
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
233
|
+
for (const name of memory[store].keys()) if (name.startsWith(startsWith) && !out.includes(name)) out.push(name);
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
__name(listKeys, "listKeys");
|
|
237
|
+
const familyKey = /* @__PURE__ */ __name((family, id) => {
|
|
238
|
+
const part = normalizeSegment(id);
|
|
239
|
+
if (!part) throw new TypeError("storage family id is empty after normalisation");
|
|
240
|
+
return family.prefix + part;
|
|
241
|
+
}, "familyKey");
|
|
242
|
+
const api = {
|
|
243
|
+
owner,
|
|
244
|
+
key(...parts) {
|
|
245
|
+
const segments = parts.map(normalizeSegment);
|
|
246
|
+
if (segments.length === 0 || segments.some((segment) => !segment)) {
|
|
247
|
+
throw new TypeError(`storage key parts must be non-empty: ${JSON.stringify(parts)}`);
|
|
145
248
|
}
|
|
146
|
-
|
|
249
|
+
return `${prefix}${segments.join(".")}`;
|
|
250
|
+
},
|
|
251
|
+
familyKey,
|
|
252
|
+
isValid,
|
|
253
|
+
read(key, store) {
|
|
254
|
+
assertValid(key);
|
|
255
|
+
const target = resolveStore(key, store);
|
|
256
|
+
return rawGet(target, key);
|
|
257
|
+
},
|
|
258
|
+
write(key, value, store) {
|
|
259
|
+
assertOwned(key);
|
|
260
|
+
const target = resolveStore(key, store);
|
|
261
|
+
return rawSet(target, key, value);
|
|
262
|
+
},
|
|
263
|
+
remove(key, store) {
|
|
264
|
+
assertOwned(key);
|
|
265
|
+
const target = resolveStore(key, store);
|
|
266
|
+
rawRemove(target, key);
|
|
267
|
+
},
|
|
268
|
+
readJSON(key, store) {
|
|
269
|
+
const raw = api.read(key, store);
|
|
270
|
+
if (raw === null) return null;
|
|
271
|
+
try {
|
|
272
|
+
return JSON.parse(raw);
|
|
273
|
+
} catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
writeJSON(key, value, store) {
|
|
278
|
+
return api.write(key, JSON.stringify(value), store);
|
|
279
|
+
},
|
|
280
|
+
keys(store = "local") {
|
|
281
|
+
return listKeys(store, prefix);
|
|
282
|
+
},
|
|
283
|
+
clearAll({ all = false } = {}) {
|
|
284
|
+
for (const spec of specs) {
|
|
285
|
+
if (!all && !spec.personal) continue;
|
|
286
|
+
rawRemove(spec.store, spec.key);
|
|
287
|
+
}
|
|
288
|
+
for (const family of families) {
|
|
289
|
+
if (!all && !family.personal) continue;
|
|
290
|
+
for (const name of listKeys(family.store, family.prefix)) rawRemove(family.store, name);
|
|
291
|
+
}
|
|
292
|
+
if (all) {
|
|
293
|
+
for (const store of ["local", "session"]) {
|
|
294
|
+
for (const name of listKeys(store, prefix)) rawRemove(store, name);
|
|
295
|
+
}
|
|
296
|
+
for (const name of cookieNames()) if (name.startsWith(prefix)) rawRemove("cookie", name);
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
onChange(key, listener, store = "local") {
|
|
300
|
+
assertValid(key);
|
|
301
|
+
if (!hasWindow()) return () => {
|
|
302
|
+
};
|
|
303
|
+
const handler = /* @__PURE__ */ __name((event) => {
|
|
304
|
+
if (event.storageArea !== nativeStorage(store)) return;
|
|
305
|
+
if (event.key === null || event.key === key) listener(event.key === null ? null : event.newValue);
|
|
306
|
+
}, "handler");
|
|
307
|
+
window.addEventListener("storage", handler);
|
|
308
|
+
return () => window.removeEventListener("storage", handler);
|
|
147
309
|
}
|
|
148
|
-
}
|
|
310
|
+
};
|
|
311
|
+
return api;
|
|
312
|
+
}
|
|
313
|
+
__name(createStorage, "createStorage");
|
|
314
|
+
var cfgStorage = createStorage("cfg", {
|
|
315
|
+
keys: CFG_KEYS,
|
|
316
|
+
families: CFG_FAMILIES
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
// src/_api/generated/helpers/auth.ts
|
|
320
|
+
var ACCESS_KEY = "cfg.auth.access_token";
|
|
321
|
+
var REFRESH_KEY = "cfg.auth.refresh_token";
|
|
322
|
+
var API_KEY_KEY = "cfg.auth.api_key";
|
|
323
|
+
var storage = true ? cfgStorage : createStorage2("cfg");
|
|
324
|
+
var isBrowser = typeof window !== "undefined";
|
|
325
|
+
var STORE_OF = {
|
|
326
|
+
localStorage: "local",
|
|
327
|
+
sessionStorage: "session",
|
|
328
|
+
cookie: "cookie"
|
|
149
329
|
};
|
|
150
330
|
function backendFor(mode) {
|
|
151
|
-
|
|
331
|
+
const store = STORE_OF[mode];
|
|
332
|
+
return {
|
|
333
|
+
get: /* @__PURE__ */ __name((key) => storage.read(key, store), "get"),
|
|
334
|
+
set(key, value) {
|
|
335
|
+
if (value === null) storage.remove(key, store);
|
|
336
|
+
else storage.write(key, value, store);
|
|
337
|
+
}
|
|
338
|
+
};
|
|
152
339
|
}
|
|
153
340
|
__name(backendFor, "backendFor");
|
|
154
341
|
var _storageMode = "localStorage";
|
|
@@ -337,10 +524,12 @@ var auth = {
|
|
|
337
524
|
notifySessionChanged();
|
|
338
525
|
},
|
|
339
526
|
clearTokens() {
|
|
340
|
-
for (const
|
|
527
|
+
for (const mode of ["localStorage", "sessionStorage", "cookie"]) {
|
|
528
|
+
const backend = backendFor(mode);
|
|
341
529
|
backend.set(ACCESS_KEY, null);
|
|
342
530
|
backend.set(REFRESH_KEY, null);
|
|
343
531
|
}
|
|
532
|
+
storage.clearAll();
|
|
344
533
|
notifySessionChanged();
|
|
345
534
|
},
|
|
346
535
|
/** Session-aware: token PRESENT and not past its `exp` (or a live refresh
|
|
@@ -532,7 +721,7 @@ function dpopEnabled() {
|
|
|
532
721
|
}
|
|
533
722
|
}
|
|
534
723
|
__name(dpopEnabled, "dpopEnabled");
|
|
535
|
-
var _DPOP_DB = "cfg
|
|
724
|
+
var _DPOP_DB = "cfg.auth.dpop";
|
|
536
725
|
var _DPOP_STORE = "keys";
|
|
537
726
|
var _DPOP_KEY_ID = "dpop-ec-p256";
|
|
538
727
|
function _idbOpen() {
|
|
@@ -2582,6 +2771,8 @@ __name(applyRoleLogPolicy, "applyRoleLogPolicy");
|
|
|
2582
2771
|
export {
|
|
2583
2772
|
APIError,
|
|
2584
2773
|
APILogger,
|
|
2774
|
+
CFG_FAMILIES,
|
|
2775
|
+
CFG_KEYS,
|
|
2585
2776
|
CfgAccountsOtp as CfgAccounts,
|
|
2586
2777
|
API as CfgAccountsAPI,
|
|
2587
2778
|
CfgAccountsApi,
|
|
@@ -2603,6 +2794,8 @@ export {
|
|
|
2603
2794
|
CfgAccountsApi as api,
|
|
2604
2795
|
applyRoleLogPolicy,
|
|
2605
2796
|
auth,
|
|
2797
|
+
cfgStorage,
|
|
2798
|
+
createStorage,
|
|
2606
2799
|
defaultLogger,
|
|
2607
2800
|
dispatchValidationError,
|
|
2608
2801
|
dpopEnabled2 as dpopEnabled,
|
|
@@ -2612,6 +2805,7 @@ export {
|
|
|
2612
2805
|
isDev,
|
|
2613
2806
|
isProd,
|
|
2614
2807
|
isStaticBuild,
|
|
2808
|
+
normalizeSegment,
|
|
2615
2809
|
onLogLevelChange,
|
|
2616
2810
|
onValidationError,
|
|
2617
2811
|
setLogLevel
|