@djangocfg/api 2.1.448 → 2.1.450
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-server.cjs +1 -2272
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.d.cts +1 -35
- package/dist/auth-server.d.ts +1 -35
- package/dist/auth-server.mjs +1 -2272
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +285 -146
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +137 -2
- package/dist/auth.d.ts +137 -2
- package/dist/auth.mjs +294 -155
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +35 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +147 -2
- package/dist/clients.d.ts +147 -2
- package/dist/clients.mjs +35 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +11 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +11 -0
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +35 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +169 -6
- package/dist/index.d.ts +169 -6
- package/dist/index.mjs +35 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -4
- package/src/_api/generated/_cfg_accounts/api.ts +8 -0
- package/src/_api/generated/_cfg_accounts/openapi.json +84 -5
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts +2 -0
- package/src/_api/generated/_cfg_accounts/schemas/WebmailLink.ts +15 -0
- package/src/_api/generated/_cfg_accounts/schemas/WebmailLinkProviderEnum.ts +9 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +2 -0
- package/src/_api/generated/_cfg_centrifugo/api.ts +8 -0
- package/src/_api/generated/_cfg_totp/api.ts +8 -0
- package/src/_api/generated/helpers/auth.ts +12 -0
- package/src/_api/generated/openapi.json +84 -5
- package/src/_api/generated/types.gen.ts +131 -2
- package/src/auth/__tests__/jwt.test.ts +119 -0
- package/src/auth/__tests__/onUnauthorized.test.ts +206 -0
- package/src/auth/__tests__/refreshRotation.test.ts +119 -0
- package/src/auth/__tests__/sessionBootstrap.test.ts +76 -0
- package/src/auth/context/AuthContext.tsx +131 -14
- package/src/auth/hooks/useAuthForm.ts +5 -2
- package/src/auth/hooks/useAuthFormState.ts +4 -1
- package/src/auth/hooks/useTokenRefresh.ts +28 -62
- package/src/auth/middlewares/index.ts +7 -7
- package/src/auth/refreshHandler.ts +79 -0
- package/src/auth/types/form.ts +10 -0
- package/src/auth/types/index.ts +1 -0
- package/src/auth/utils/jwt.ts +66 -0
- package/src/auth/middlewares/tokenRefresh.ts +0 -161
package/dist/clients.cjs
CHANGED
|
@@ -299,6 +299,17 @@ var auth = {
|
|
|
299
299
|
*/
|
|
300
300
|
setRefreshHandler(fn) {
|
|
301
301
|
_refreshHandler = fn;
|
|
302
|
+
},
|
|
303
|
+
/**
|
|
304
|
+
* Proactively run the registered refresh handler right now, reusing the
|
|
305
|
+
* SAME single-flight promise as the 401-recovery interceptor. Callers
|
|
306
|
+
* (e.g. an expiry timer / focus / reconnect) get token rotation,
|
|
307
|
+
* de-duplication and rotated-token persistence for free — they must NOT
|
|
308
|
+
* re-implement any of it. Returns the fresh access token, or null if
|
|
309
|
+
* there is no handler / no refresh token / the refresh failed.
|
|
310
|
+
*/
|
|
311
|
+
refreshNow() {
|
|
312
|
+
return tryRefresh();
|
|
302
313
|
}
|
|
303
314
|
};
|
|
304
315
|
async function tryRefresh() {
|
|
@@ -2022,6 +2033,14 @@ var API = class {
|
|
|
2022
2033
|
setRefreshHandler(fn) {
|
|
2023
2034
|
auth.setRefreshHandler(fn);
|
|
2024
2035
|
}
|
|
2036
|
+
/**
|
|
2037
|
+
* Proactively refresh now via the registered handler, sharing the single
|
|
2038
|
+
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2039
|
+
* See `auth.refreshNow`.
|
|
2040
|
+
*/
|
|
2041
|
+
refreshNow() {
|
|
2042
|
+
return auth.refreshNow();
|
|
2043
|
+
}
|
|
2025
2044
|
};
|
|
2026
2045
|
|
|
2027
2046
|
// src/_api/generated/_cfg_centrifugo/api.ts
|
|
@@ -2086,6 +2105,14 @@ var API2 = class {
|
|
|
2086
2105
|
setRefreshHandler(fn) {
|
|
2087
2106
|
auth.setRefreshHandler(fn);
|
|
2088
2107
|
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Proactively refresh now via the registered handler, sharing the single
|
|
2110
|
+
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2111
|
+
* See `auth.refreshNow`.
|
|
2112
|
+
*/
|
|
2113
|
+
refreshNow() {
|
|
2114
|
+
return auth.refreshNow();
|
|
2115
|
+
}
|
|
2089
2116
|
};
|
|
2090
2117
|
|
|
2091
2118
|
// src/_api/generated/_cfg_totp/api.ts
|
|
@@ -2153,6 +2180,14 @@ var API3 = class {
|
|
|
2153
2180
|
setRefreshHandler(fn) {
|
|
2154
2181
|
auth.setRefreshHandler(fn);
|
|
2155
2182
|
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Proactively refresh now via the registered handler, sharing the single
|
|
2185
|
+
* 401-recovery flight (rotation + dedup + rotated-token persistence).
|
|
2186
|
+
* See `auth.refreshNow`.
|
|
2187
|
+
*/
|
|
2188
|
+
refreshNow() {
|
|
2189
|
+
return auth.refreshNow();
|
|
2190
|
+
}
|
|
2156
2191
|
};
|
|
2157
2192
|
|
|
2158
2193
|
// src/_api/generated/index.ts
|