@djangocfg/api 2.1.541 → 2.1.543
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 +1 -2
- package/dist/auth-server.cjs +1 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth.cjs +156 -170
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +134 -29
- package/dist/auth.d.ts +134 -29
- package/dist/auth.mjs +168 -183
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +4 -99
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +4 -136
- package/dist/clients.d.ts +4 -136
- package/dist/clients.mjs +3 -99
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +1 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -4
- package/dist/hooks.d.ts +2 -4
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +4 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -340
- package/dist/index.d.ts +10 -340
- package/dist/index.mjs +3 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -4
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpConsentPolicyRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_accounts/openapi.json +0 -45
- package/src/_api/generated/_cfg_accounts/schemas/User.ts +0 -2
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +0 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +8 -2
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +8 -2
- package/src/_api/generated/index.ts +1 -5
- package/src/_api/generated/openapi.json +0 -135
- package/src/_api/generated/sdk.gen.ts +1 -20
- package/src/_api/generated/types.gen.ts +0 -79
- package/src/_api/index.ts +1 -1
- package/src/auth/__tests__/useTwoFactorStatus.test.ts +2 -2
- package/src/auth/context/AccountsContext.tsx +15 -11
- package/src/auth/hooks/useAuthForm.ts +0 -1
- package/src/auth/hooks/useCfgRouter.ts +1 -4
- package/src/auth/hooks/useGithubAuth.ts +25 -3
- package/src/auth/hooks/useLocalStorage.ts +7 -30
- package/src/auth/hooks/useSessionStorage.ts +6 -29
- package/src/auth/hooks/useTwoFactorVerify.ts +5 -9
- package/src/auth/utils/analytics.ts +22 -2
- package/src/auth/utils/errors.ts +22 -11
- package/src/auth/utils/storage.ts +64 -0
- package/src/clients.ts +2 -4
- package/src/index.ts +0 -2
- package/src/log-control.ts +1 -1
- package/src/server.ts +0 -4
- package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +0 -14
- package/src/_api/generated/_cfg_centrifugo/api.ts +0 -87
- package/src/_api/generated/_cfg_centrifugo/hooks/index.ts +0 -4
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +0 -74
- package/src/_api/generated/_cfg_centrifugo/index.ts +0 -29
- package/src/_api/generated/_cfg_centrifugo/openapi.json +0 -136
- package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +0 -14
- package/src/_api/generated/_cfg_centrifugo/schemas/index.ts +0 -4
- package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +0 -5
- package/src/_api/generated/_cfg_centrifugo/types.gen.ts +0 -5
package/dist/clients.d.cts
CHANGED
|
@@ -513,27 +513,6 @@ type BackupCodesStatus = {
|
|
|
513
513
|
*/
|
|
514
514
|
warning?: string | null;
|
|
515
515
|
};
|
|
516
|
-
/**
|
|
517
|
-
* Nested serializer for Centrifugo WebSocket connection token.
|
|
518
|
-
*/
|
|
519
|
-
type CentrifugoToken = {
|
|
520
|
-
/**
|
|
521
|
-
* JWT token for Centrifugo WebSocket connection
|
|
522
|
-
*/
|
|
523
|
-
token: string;
|
|
524
|
-
/**
|
|
525
|
-
* Centrifugo WebSocket URL
|
|
526
|
-
*/
|
|
527
|
-
centrifugo_url: string;
|
|
528
|
-
/**
|
|
529
|
-
* Token expiration time (ISO 8601)
|
|
530
|
-
*/
|
|
531
|
-
expires_at: string;
|
|
532
|
-
/**
|
|
533
|
-
* List of allowed channels for this user
|
|
534
|
-
*/
|
|
535
|
-
channels: Array<string>;
|
|
536
|
-
};
|
|
537
516
|
/**
|
|
538
517
|
* Serializer for updating user profile.
|
|
539
518
|
*/
|
|
@@ -576,37 +555,6 @@ type ConfirmSetupResponse = {
|
|
|
576
555
|
*/
|
|
577
556
|
backup_codes_warning: string;
|
|
578
557
|
};
|
|
579
|
-
/**
|
|
580
|
-
* ConnectionTokenResponse
|
|
581
|
-
*
|
|
582
|
-
* Response model for Centrifugo connection token.
|
|
583
|
-
*/
|
|
584
|
-
type ConnectionTokenResponse = {
|
|
585
|
-
/**
|
|
586
|
-
* Token
|
|
587
|
-
*
|
|
588
|
-
* JWT token for Centrifugo connection
|
|
589
|
-
*/
|
|
590
|
-
token: string;
|
|
591
|
-
/**
|
|
592
|
-
* Centrifugo Url
|
|
593
|
-
*
|
|
594
|
-
* Centrifugo WebSocket URL
|
|
595
|
-
*/
|
|
596
|
-
centrifugo_url: string;
|
|
597
|
-
/**
|
|
598
|
-
* Expires At
|
|
599
|
-
*
|
|
600
|
-
* Token expiration time (ISO 8601)
|
|
601
|
-
*/
|
|
602
|
-
expires_at: string;
|
|
603
|
-
/**
|
|
604
|
-
* Channels
|
|
605
|
-
*
|
|
606
|
-
* List of allowed channels
|
|
607
|
-
*/
|
|
608
|
-
channels: Array<string>;
|
|
609
|
-
};
|
|
610
558
|
/**
|
|
611
559
|
* Marketing-consent UI policy derived from the request's geo context.
|
|
612
560
|
*/
|
|
@@ -1120,7 +1068,6 @@ type User = {
|
|
|
1120
1068
|
readonly date_joined: string;
|
|
1121
1069
|
readonly last_login: string | null;
|
|
1122
1070
|
readonly unanswered_messages_count: number;
|
|
1123
|
-
readonly centrifugo: CentrifugoToken | null;
|
|
1124
1071
|
readonly api_key: string | null;
|
|
1125
1072
|
};
|
|
1126
1073
|
/**
|
|
@@ -1610,25 +1557,6 @@ type CfgAccountsTokenRefreshCreateData = {
|
|
|
1610
1557
|
type CfgAccountsTokenRefreshCreateResponses = {
|
|
1611
1558
|
200: TokenRefresh;
|
|
1612
1559
|
};
|
|
1613
|
-
type CfgCentrifugoAuthTokenRetrieveData = {
|
|
1614
|
-
body?: never;
|
|
1615
|
-
path?: never;
|
|
1616
|
-
query?: never;
|
|
1617
|
-
url: '/cfg/centrifugo/auth/token/';
|
|
1618
|
-
};
|
|
1619
|
-
type CfgCentrifugoAuthTokenRetrieveErrors = {
|
|
1620
|
-
/**
|
|
1621
|
-
* Unauthorized - authentication required
|
|
1622
|
-
*/
|
|
1623
|
-
401: unknown;
|
|
1624
|
-
/**
|
|
1625
|
-
* Server error
|
|
1626
|
-
*/
|
|
1627
|
-
500: unknown;
|
|
1628
|
-
};
|
|
1629
|
-
type CfgCentrifugoAuthTokenRetrieveResponses = {
|
|
1630
|
-
200: ConnectionTokenResponse;
|
|
1631
|
-
};
|
|
1632
1560
|
type CfgTotpBackupCodesRetrieveData = {
|
|
1633
1561
|
body?: never;
|
|
1634
1562
|
path?: never;
|
|
@@ -1926,14 +1854,6 @@ declare class CfgAccountsAuth {
|
|
|
1926
1854
|
*/
|
|
1927
1855
|
static cfgAccountsTokenRefreshCreate<ThrowOnError extends boolean = false>(options: Options<CfgAccountsTokenRefreshCreateData, ThrowOnError>): RequestResult<CfgAccountsTokenRefreshCreateResponses, unknown, ThrowOnError>;
|
|
1928
1856
|
}
|
|
1929
|
-
declare class CfgCentrifugo {
|
|
1930
|
-
/**
|
|
1931
|
-
* Get Centrifugo connection token
|
|
1932
|
-
*
|
|
1933
|
-
* Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
|
|
1934
|
-
*/
|
|
1935
|
-
static cfgCentrifugoAuthTokenRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgCentrifugoAuthTokenRetrieveData, ThrowOnError>): RequestResult<CfgCentrifugoAuthTokenRetrieveResponses, CfgCentrifugoAuthTokenRetrieveErrors, ThrowOnError>;
|
|
1936
|
-
}
|
|
1937
1857
|
declare class CfgTotpBackupCodes {
|
|
1938
1858
|
/**
|
|
1939
1859
|
* Get backup codes status for user.
|
|
@@ -1994,7 +1914,7 @@ declare class CfgTotpVerify {
|
|
|
1994
1914
|
static cfgTotpVerifyBackupCreate<ThrowOnError extends boolean = false>(options: Options<CfgTotpVerifyBackupCreateData, ThrowOnError>): RequestResult<CfgTotpVerifyBackupCreateResponses, CfgTotpVerifyBackupCreateErrors, ThrowOnError>;
|
|
1995
1915
|
}
|
|
1996
1916
|
|
|
1997
|
-
interface APIOptions$
|
|
1917
|
+
interface APIOptions$1 {
|
|
1998
1918
|
/** Logger config (defaults to dev-only). */
|
|
1999
1919
|
logger?: Partial<LoggerConfig>;
|
|
2000
1920
|
/** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
|
|
@@ -2014,64 +1934,13 @@ interface APIOptions$2 {
|
|
|
2014
1934
|
* Use the global `auth` object directly when you don't need a group
|
|
2015
1935
|
* facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
|
|
2016
1936
|
*/
|
|
2017
|
-
declare class API$
|
|
1937
|
+
declare class API$1 {
|
|
2018
1938
|
readonly logger: APILogger;
|
|
2019
1939
|
readonly cfgAccountsApiKey: typeof CfgAccountsApiKey;
|
|
2020
1940
|
readonly cfgAccountsOauth: typeof CfgAccountsOauth;
|
|
2021
1941
|
readonly cfgAccountsOtp: typeof CfgAccountsOtp;
|
|
2022
1942
|
readonly cfgAccountsProfile: typeof CfgAccountsProfile;
|
|
2023
1943
|
readonly cfgAccountsAuth: typeof CfgAccountsAuth;
|
|
2024
|
-
constructor(_baseUrl?: string, opts?: APIOptions$2);
|
|
2025
|
-
getBaseUrl(): string;
|
|
2026
|
-
setBaseUrl(url: string): void;
|
|
2027
|
-
getToken(): string | null;
|
|
2028
|
-
setToken(token: string | null): void;
|
|
2029
|
-
getRefreshToken(): string | null;
|
|
2030
|
-
setRefreshToken(token: string | null): void;
|
|
2031
|
-
clearToken(): void;
|
|
2032
|
-
isAuthenticated(): boolean;
|
|
2033
|
-
getLocale(): string | null;
|
|
2034
|
-
setLocale(locale: string | null): void;
|
|
2035
|
-
getApiKey(): string | null;
|
|
2036
|
-
setApiKey(key: string | null): void;
|
|
2037
|
-
/** Fired only on terminal 401 (after refresh+retry path is exhausted). */
|
|
2038
|
-
onUnauthorized(cb: ((response: Response) => void) | null): void;
|
|
2039
|
-
/** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
|
|
2040
|
-
setRefreshHandler(fn: ((refreshToken: string) => Promise<{
|
|
2041
|
-
access: string;
|
|
2042
|
-
refresh?: string;
|
|
2043
|
-
} | null>) | null): void;
|
|
2044
|
-
/**
|
|
2045
|
-
* Proactively refresh now via the registered handler, sharing the single
|
|
2046
|
-
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2047
|
-
* See `auth.refreshNow`.
|
|
2048
|
-
*/
|
|
2049
|
-
refreshNow(): Promise<string | null>;
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
interface APIOptions$1 {
|
|
2053
|
-
/** Logger config (defaults to dev-only). */
|
|
2054
|
-
logger?: Partial<LoggerConfig>;
|
|
2055
|
-
/** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
|
|
2056
|
-
locale?: string;
|
|
2057
|
-
/** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
|
|
2058
|
-
apiKey?: string;
|
|
2059
|
-
/** Send Django session/CSRF cookies cross-origin. Defaults to true. */
|
|
2060
|
-
withCredentials?: boolean;
|
|
2061
|
-
}
|
|
2062
|
-
/**
|
|
2063
|
-
* Per-group ergonomic facade.
|
|
2064
|
-
*
|
|
2065
|
-
* Calling `setToken/setApiKey/setLocale/setBaseUrl` proxies to the
|
|
2066
|
-
* global `auth` store — the change applies to **every** group's API
|
|
2067
|
-
* instance because they share the same HTTP client and interceptor.
|
|
2068
|
-
*
|
|
2069
|
-
* Use the global `auth` object directly when you don't need a group
|
|
2070
|
-
* facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
|
|
2071
|
-
*/
|
|
2072
|
-
declare class API$1 {
|
|
2073
|
-
readonly logger: APILogger;
|
|
2074
|
-
readonly cfgCentrifugo: typeof CfgCentrifugo;
|
|
2075
1944
|
constructor(_baseUrl?: string, opts?: APIOptions$1);
|
|
2076
1945
|
getBaseUrl(): string;
|
|
2077
1946
|
setBaseUrl(url: string): void;
|
|
@@ -2154,8 +2023,7 @@ declare class API {
|
|
|
2154
2023
|
refreshNow(): Promise<string | null>;
|
|
2155
2024
|
}
|
|
2156
2025
|
|
|
2157
|
-
declare const CfgAccountsApi: API$
|
|
2158
|
-
declare const CfgCentrifugoApi: API$1;
|
|
2026
|
+
declare const CfgAccountsApi: API$1;
|
|
2159
2027
|
declare const CfgTotpApi: API;
|
|
2160
2028
|
|
|
2161
|
-
export { API$
|
|
2029
|
+
export { API$1 as AccountsAPI, API as TotpAPI, CfgAccountsApi as apiAccounts, CfgTotpApi as apiTotp };
|
package/dist/clients.d.ts
CHANGED
|
@@ -513,27 +513,6 @@ type BackupCodesStatus = {
|
|
|
513
513
|
*/
|
|
514
514
|
warning?: string | null;
|
|
515
515
|
};
|
|
516
|
-
/**
|
|
517
|
-
* Nested serializer for Centrifugo WebSocket connection token.
|
|
518
|
-
*/
|
|
519
|
-
type CentrifugoToken = {
|
|
520
|
-
/**
|
|
521
|
-
* JWT token for Centrifugo WebSocket connection
|
|
522
|
-
*/
|
|
523
|
-
token: string;
|
|
524
|
-
/**
|
|
525
|
-
* Centrifugo WebSocket URL
|
|
526
|
-
*/
|
|
527
|
-
centrifugo_url: string;
|
|
528
|
-
/**
|
|
529
|
-
* Token expiration time (ISO 8601)
|
|
530
|
-
*/
|
|
531
|
-
expires_at: string;
|
|
532
|
-
/**
|
|
533
|
-
* List of allowed channels for this user
|
|
534
|
-
*/
|
|
535
|
-
channels: Array<string>;
|
|
536
|
-
};
|
|
537
516
|
/**
|
|
538
517
|
* Serializer for updating user profile.
|
|
539
518
|
*/
|
|
@@ -576,37 +555,6 @@ type ConfirmSetupResponse = {
|
|
|
576
555
|
*/
|
|
577
556
|
backup_codes_warning: string;
|
|
578
557
|
};
|
|
579
|
-
/**
|
|
580
|
-
* ConnectionTokenResponse
|
|
581
|
-
*
|
|
582
|
-
* Response model for Centrifugo connection token.
|
|
583
|
-
*/
|
|
584
|
-
type ConnectionTokenResponse = {
|
|
585
|
-
/**
|
|
586
|
-
* Token
|
|
587
|
-
*
|
|
588
|
-
* JWT token for Centrifugo connection
|
|
589
|
-
*/
|
|
590
|
-
token: string;
|
|
591
|
-
/**
|
|
592
|
-
* Centrifugo Url
|
|
593
|
-
*
|
|
594
|
-
* Centrifugo WebSocket URL
|
|
595
|
-
*/
|
|
596
|
-
centrifugo_url: string;
|
|
597
|
-
/**
|
|
598
|
-
* Expires At
|
|
599
|
-
*
|
|
600
|
-
* Token expiration time (ISO 8601)
|
|
601
|
-
*/
|
|
602
|
-
expires_at: string;
|
|
603
|
-
/**
|
|
604
|
-
* Channels
|
|
605
|
-
*
|
|
606
|
-
* List of allowed channels
|
|
607
|
-
*/
|
|
608
|
-
channels: Array<string>;
|
|
609
|
-
};
|
|
610
558
|
/**
|
|
611
559
|
* Marketing-consent UI policy derived from the request's geo context.
|
|
612
560
|
*/
|
|
@@ -1120,7 +1068,6 @@ type User = {
|
|
|
1120
1068
|
readonly date_joined: string;
|
|
1121
1069
|
readonly last_login: string | null;
|
|
1122
1070
|
readonly unanswered_messages_count: number;
|
|
1123
|
-
readonly centrifugo: CentrifugoToken | null;
|
|
1124
1071
|
readonly api_key: string | null;
|
|
1125
1072
|
};
|
|
1126
1073
|
/**
|
|
@@ -1610,25 +1557,6 @@ type CfgAccountsTokenRefreshCreateData = {
|
|
|
1610
1557
|
type CfgAccountsTokenRefreshCreateResponses = {
|
|
1611
1558
|
200: TokenRefresh;
|
|
1612
1559
|
};
|
|
1613
|
-
type CfgCentrifugoAuthTokenRetrieveData = {
|
|
1614
|
-
body?: never;
|
|
1615
|
-
path?: never;
|
|
1616
|
-
query?: never;
|
|
1617
|
-
url: '/cfg/centrifugo/auth/token/';
|
|
1618
|
-
};
|
|
1619
|
-
type CfgCentrifugoAuthTokenRetrieveErrors = {
|
|
1620
|
-
/**
|
|
1621
|
-
* Unauthorized - authentication required
|
|
1622
|
-
*/
|
|
1623
|
-
401: unknown;
|
|
1624
|
-
/**
|
|
1625
|
-
* Server error
|
|
1626
|
-
*/
|
|
1627
|
-
500: unknown;
|
|
1628
|
-
};
|
|
1629
|
-
type CfgCentrifugoAuthTokenRetrieveResponses = {
|
|
1630
|
-
200: ConnectionTokenResponse;
|
|
1631
|
-
};
|
|
1632
1560
|
type CfgTotpBackupCodesRetrieveData = {
|
|
1633
1561
|
body?: never;
|
|
1634
1562
|
path?: never;
|
|
@@ -1926,14 +1854,6 @@ declare class CfgAccountsAuth {
|
|
|
1926
1854
|
*/
|
|
1927
1855
|
static cfgAccountsTokenRefreshCreate<ThrowOnError extends boolean = false>(options: Options<CfgAccountsTokenRefreshCreateData, ThrowOnError>): RequestResult<CfgAccountsTokenRefreshCreateResponses, unknown, ThrowOnError>;
|
|
1928
1856
|
}
|
|
1929
|
-
declare class CfgCentrifugo {
|
|
1930
|
-
/**
|
|
1931
|
-
* Get Centrifugo connection token
|
|
1932
|
-
*
|
|
1933
|
-
* Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
|
|
1934
|
-
*/
|
|
1935
|
-
static cfgCentrifugoAuthTokenRetrieve<ThrowOnError extends boolean = false>(options?: Options<CfgCentrifugoAuthTokenRetrieveData, ThrowOnError>): RequestResult<CfgCentrifugoAuthTokenRetrieveResponses, CfgCentrifugoAuthTokenRetrieveErrors, ThrowOnError>;
|
|
1936
|
-
}
|
|
1937
1857
|
declare class CfgTotpBackupCodes {
|
|
1938
1858
|
/**
|
|
1939
1859
|
* Get backup codes status for user.
|
|
@@ -1994,7 +1914,7 @@ declare class CfgTotpVerify {
|
|
|
1994
1914
|
static cfgTotpVerifyBackupCreate<ThrowOnError extends boolean = false>(options: Options<CfgTotpVerifyBackupCreateData, ThrowOnError>): RequestResult<CfgTotpVerifyBackupCreateResponses, CfgTotpVerifyBackupCreateErrors, ThrowOnError>;
|
|
1995
1915
|
}
|
|
1996
1916
|
|
|
1997
|
-
interface APIOptions$
|
|
1917
|
+
interface APIOptions$1 {
|
|
1998
1918
|
/** Logger config (defaults to dev-only). */
|
|
1999
1919
|
logger?: Partial<LoggerConfig>;
|
|
2000
1920
|
/** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
|
|
@@ -2014,64 +1934,13 @@ interface APIOptions$2 {
|
|
|
2014
1934
|
* Use the global `auth` object directly when you don't need a group
|
|
2015
1935
|
* facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
|
|
2016
1936
|
*/
|
|
2017
|
-
declare class API$
|
|
1937
|
+
declare class API$1 {
|
|
2018
1938
|
readonly logger: APILogger;
|
|
2019
1939
|
readonly cfgAccountsApiKey: typeof CfgAccountsApiKey;
|
|
2020
1940
|
readonly cfgAccountsOauth: typeof CfgAccountsOauth;
|
|
2021
1941
|
readonly cfgAccountsOtp: typeof CfgAccountsOtp;
|
|
2022
1942
|
readonly cfgAccountsProfile: typeof CfgAccountsProfile;
|
|
2023
1943
|
readonly cfgAccountsAuth: typeof CfgAccountsAuth;
|
|
2024
|
-
constructor(_baseUrl?: string, opts?: APIOptions$2);
|
|
2025
|
-
getBaseUrl(): string;
|
|
2026
|
-
setBaseUrl(url: string): void;
|
|
2027
|
-
getToken(): string | null;
|
|
2028
|
-
setToken(token: string | null): void;
|
|
2029
|
-
getRefreshToken(): string | null;
|
|
2030
|
-
setRefreshToken(token: string | null): void;
|
|
2031
|
-
clearToken(): void;
|
|
2032
|
-
isAuthenticated(): boolean;
|
|
2033
|
-
getLocale(): string | null;
|
|
2034
|
-
setLocale(locale: string | null): void;
|
|
2035
|
-
getApiKey(): string | null;
|
|
2036
|
-
setApiKey(key: string | null): void;
|
|
2037
|
-
/** Fired only on terminal 401 (after refresh+retry path is exhausted). */
|
|
2038
|
-
onUnauthorized(cb: ((response: Response) => void) | null): void;
|
|
2039
|
-
/** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
|
|
2040
|
-
setRefreshHandler(fn: ((refreshToken: string) => Promise<{
|
|
2041
|
-
access: string;
|
|
2042
|
-
refresh?: string;
|
|
2043
|
-
} | null>) | null): void;
|
|
2044
|
-
/**
|
|
2045
|
-
* Proactively refresh now via the registered handler, sharing the single
|
|
2046
|
-
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2047
|
-
* See `auth.refreshNow`.
|
|
2048
|
-
*/
|
|
2049
|
-
refreshNow(): Promise<string | null>;
|
|
2050
|
-
}
|
|
2051
|
-
|
|
2052
|
-
interface APIOptions$1 {
|
|
2053
|
-
/** Logger config (defaults to dev-only). */
|
|
2054
|
-
logger?: Partial<LoggerConfig>;
|
|
2055
|
-
/** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
|
|
2056
|
-
locale?: string;
|
|
2057
|
-
/** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
|
|
2058
|
-
apiKey?: string;
|
|
2059
|
-
/** Send Django session/CSRF cookies cross-origin. Defaults to true. */
|
|
2060
|
-
withCredentials?: boolean;
|
|
2061
|
-
}
|
|
2062
|
-
/**
|
|
2063
|
-
* Per-group ergonomic facade.
|
|
2064
|
-
*
|
|
2065
|
-
* Calling `setToken/setApiKey/setLocale/setBaseUrl` proxies to the
|
|
2066
|
-
* global `auth` store — the change applies to **every** group's API
|
|
2067
|
-
* instance because they share the same HTTP client and interceptor.
|
|
2068
|
-
*
|
|
2069
|
-
* Use the global `auth` object directly when you don't need a group
|
|
2070
|
-
* facade: `import { auth } from '@your/api'; auth.setToken(jwt);`
|
|
2071
|
-
*/
|
|
2072
|
-
declare class API$1 {
|
|
2073
|
-
readonly logger: APILogger;
|
|
2074
|
-
readonly cfgCentrifugo: typeof CfgCentrifugo;
|
|
2075
1944
|
constructor(_baseUrl?: string, opts?: APIOptions$1);
|
|
2076
1945
|
getBaseUrl(): string;
|
|
2077
1946
|
setBaseUrl(url: string): void;
|
|
@@ -2154,8 +2023,7 @@ declare class API {
|
|
|
2154
2023
|
refreshNow(): Promise<string | null>;
|
|
2155
2024
|
}
|
|
2156
2025
|
|
|
2157
|
-
declare const CfgAccountsApi: API$
|
|
2158
|
-
declare const CfgCentrifugoApi: API$1;
|
|
2026
|
+
declare const CfgAccountsApi: API$1;
|
|
2159
2027
|
declare const CfgTotpApi: API;
|
|
2160
2028
|
|
|
2161
|
-
export { API$
|
|
2029
|
+
export { API$1 as AccountsAPI, API as TotpAPI, CfgAccountsApi as apiAccounts, CfgTotpApi as apiTotp };
|
package/dist/clients.mjs
CHANGED
|
@@ -2029,27 +2029,6 @@ var CfgAccountsAuth = class {
|
|
|
2029
2029
|
});
|
|
2030
2030
|
}
|
|
2031
2031
|
};
|
|
2032
|
-
var CfgCentrifugo = class {
|
|
2033
|
-
static {
|
|
2034
|
-
__name(this, "CfgCentrifugo");
|
|
2035
|
-
}
|
|
2036
|
-
/**
|
|
2037
|
-
* Get Centrifugo connection token
|
|
2038
|
-
*
|
|
2039
|
-
* Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
|
|
2040
|
-
*/
|
|
2041
|
-
static cfgCentrifugoAuthTokenRetrieve(options) {
|
|
2042
|
-
return (options?.client ?? client).get({
|
|
2043
|
-
security: [
|
|
2044
|
-
{ name: "X-API-Key", type: "apiKey" },
|
|
2045
|
-
{ scheme: "bearer", type: "http" },
|
|
2046
|
-
{ name: "Authorization", type: "apiKey" }
|
|
2047
|
-
],
|
|
2048
|
-
url: "/cfg/centrifugo/auth/token/",
|
|
2049
|
-
...options
|
|
2050
|
-
});
|
|
2051
|
-
}
|
|
2052
|
-
};
|
|
2053
2032
|
var CfgTotpBackupCodes = class {
|
|
2054
2033
|
static {
|
|
2055
2034
|
__name(this, "CfgTotpBackupCodes");
|
|
@@ -2312,80 +2291,8 @@ var API = class {
|
|
|
2312
2291
|
}
|
|
2313
2292
|
};
|
|
2314
2293
|
|
|
2315
|
-
// src/_api/generated/_cfg_centrifugo/api.ts
|
|
2316
|
-
var API2 = class {
|
|
2317
|
-
static {
|
|
2318
|
-
__name(this, "API");
|
|
2319
|
-
}
|
|
2320
|
-
logger;
|
|
2321
|
-
cfgCentrifugo = CfgCentrifugo;
|
|
2322
|
-
constructor(_baseUrl, opts = {}) {
|
|
2323
|
-
this.logger = new APILogger(opts.logger);
|
|
2324
|
-
if (_baseUrl) auth.setBaseUrl(_baseUrl);
|
|
2325
|
-
if (opts.locale !== void 0) auth.setLocale(opts.locale);
|
|
2326
|
-
if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
|
|
2327
|
-
if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
|
|
2328
|
-
}
|
|
2329
|
-
// ── Base URL ────────────────────────────────────────────────────────────
|
|
2330
|
-
getBaseUrl() {
|
|
2331
|
-
return auth.getBaseUrl();
|
|
2332
|
-
}
|
|
2333
|
-
setBaseUrl(url) {
|
|
2334
|
-
auth.setBaseUrl(url);
|
|
2335
|
-
}
|
|
2336
|
-
// ── Tokens ──────────────────────────────────────────────────────────────
|
|
2337
|
-
getToken() {
|
|
2338
|
-
return auth.getToken();
|
|
2339
|
-
}
|
|
2340
|
-
setToken(token) {
|
|
2341
|
-
auth.setToken(token);
|
|
2342
|
-
}
|
|
2343
|
-
getRefreshToken() {
|
|
2344
|
-
return auth.getRefreshToken();
|
|
2345
|
-
}
|
|
2346
|
-
setRefreshToken(token) {
|
|
2347
|
-
auth.setRefreshToken(token);
|
|
2348
|
-
}
|
|
2349
|
-
clearToken() {
|
|
2350
|
-
auth.clearTokens();
|
|
2351
|
-
}
|
|
2352
|
-
isAuthenticated() {
|
|
2353
|
-
return auth.isAuthenticated();
|
|
2354
|
-
}
|
|
2355
|
-
// ── Locale / API key ────────────────────────────────────────────────────
|
|
2356
|
-
getLocale() {
|
|
2357
|
-
return auth.getLocale();
|
|
2358
|
-
}
|
|
2359
|
-
setLocale(locale) {
|
|
2360
|
-
auth.setLocale(locale);
|
|
2361
|
-
}
|
|
2362
|
-
getApiKey() {
|
|
2363
|
-
return auth.getApiKey();
|
|
2364
|
-
}
|
|
2365
|
-
setApiKey(key) {
|
|
2366
|
-
auth.setApiKey(key);
|
|
2367
|
-
}
|
|
2368
|
-
// ── 401 handling ────────────────────────────────────────────────────────
|
|
2369
|
-
/** Fired only on terminal 401 (after refresh+retry path is exhausted). */
|
|
2370
|
-
onUnauthorized(cb) {
|
|
2371
|
-
auth.onUnauthorized(cb);
|
|
2372
|
-
}
|
|
2373
|
-
/** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
|
|
2374
|
-
setRefreshHandler(fn) {
|
|
2375
|
-
auth.setRefreshHandler(fn);
|
|
2376
|
-
}
|
|
2377
|
-
/**
|
|
2378
|
-
* Proactively refresh now via the registered handler, sharing the single
|
|
2379
|
-
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2380
|
-
* See `auth.refreshNow`.
|
|
2381
|
-
*/
|
|
2382
|
-
refreshNow() {
|
|
2383
|
-
return auth.refreshNow();
|
|
2384
|
-
}
|
|
2385
|
-
};
|
|
2386
|
-
|
|
2387
2294
|
// src/_api/generated/_cfg_totp/api.ts
|
|
2388
|
-
var
|
|
2295
|
+
var API2 = class {
|
|
2389
2296
|
static {
|
|
2390
2297
|
__name(this, "API");
|
|
2391
2298
|
}
|
|
@@ -2461,14 +2368,11 @@ var API3 = class {
|
|
|
2461
2368
|
|
|
2462
2369
|
// src/_api/generated/index.ts
|
|
2463
2370
|
var CfgAccountsApi = new API();
|
|
2464
|
-
var
|
|
2465
|
-
var CfgTotpApi = new API3();
|
|
2371
|
+
var CfgTotpApi = new API2();
|
|
2466
2372
|
export {
|
|
2467
2373
|
API as AccountsAPI,
|
|
2468
|
-
API2 as
|
|
2469
|
-
API3 as TotpAPI,
|
|
2374
|
+
API2 as TotpAPI,
|
|
2470
2375
|
CfgAccountsApi as apiAccounts,
|
|
2471
|
-
CfgCentrifugoApi as apiCentrifugo,
|
|
2472
2376
|
CfgTotpApi as apiTotp
|
|
2473
2377
|
};
|
|
2474
2378
|
//# sourceMappingURL=clients.mjs.map
|