@djangocfg/api 2.1.87 → 2.1.89

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.
Files changed (59) hide show
  1. package/dist/auth-server.cjs +1963 -4
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.d.cts +35 -1
  4. package/dist/auth-server.d.ts +35 -1
  5. package/dist/auth-server.mjs +1953 -4
  6. package/dist/auth-server.mjs.map +1 -1
  7. package/dist/auth.cjs +692 -497
  8. package/dist/auth.cjs.map +1 -1
  9. package/dist/auth.d.cts +18 -2
  10. package/dist/auth.d.ts +18 -2
  11. package/dist/auth.mjs +655 -460
  12. package/dist/auth.mjs.map +1 -1
  13. package/dist/clients.cjs +460 -383
  14. package/dist/clients.cjs.map +1 -1
  15. package/dist/clients.d.cts +26 -6
  16. package/dist/clients.d.ts +26 -6
  17. package/dist/clients.mjs +460 -383
  18. package/dist/clients.mjs.map +1 -1
  19. package/dist/hooks.cjs +130 -105
  20. package/dist/hooks.cjs.map +1 -1
  21. package/dist/hooks.d.cts +24 -4
  22. package/dist/hooks.d.ts +24 -4
  23. package/dist/hooks.mjs +130 -105
  24. package/dist/hooks.mjs.map +1 -1
  25. package/dist/index.cjs +373 -311
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +54 -8
  28. package/dist/index.d.ts +54 -8
  29. package/dist/index.mjs +373 -311
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +3 -3
  32. package/src/auth/context/AccountsContext.tsx +3 -3
  33. package/src/auth/context/AuthContext.tsx +56 -10
  34. package/src/auth/hooks/index.ts +3 -0
  35. package/src/auth/hooks/useProfileCache.ts +1 -1
  36. package/src/auth/hooks/useTokenRefresh.ts +161 -0
  37. package/src/auth/middlewares/index.ts +8 -1
  38. package/src/auth/middlewares/tokenRefresh.ts +158 -0
  39. package/src/generated/cfg_accounts/CLAUDE.md +2 -9
  40. package/src/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +2 -1
  41. package/src/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +2 -1
  42. package/src/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts +15 -0
  43. package/src/generated/cfg_accounts/_utils/schemas/index.ts +1 -0
  44. package/src/generated/cfg_accounts/accounts/models.ts +0 -1
  45. package/src/generated/cfg_accounts/accounts__user_profile/client.ts +4 -2
  46. package/src/generated/cfg_accounts/accounts__user_profile/models.ts +9 -1
  47. package/src/generated/cfg_accounts/client.ts +18 -0
  48. package/src/generated/cfg_accounts/index.ts +3 -1
  49. package/src/generated/cfg_accounts/schema.json +2 -2
  50. package/src/generated/cfg_centrifugo/CLAUDE.md +1 -8
  51. package/src/generated/cfg_centrifugo/client.ts +18 -0
  52. package/src/generated/cfg_centrifugo/index.ts +3 -1
  53. package/src/generated/cfg_totp/CLAUDE.md +1 -8
  54. package/src/generated/cfg_totp/client.ts +18 -0
  55. package/src/generated/cfg_totp/index.ts +3 -1
  56. package/src/generated/cfg_totp/totp/models.ts +2 -0
  57. package/src/generated/cfg_webpush/CLAUDE.md +1 -8
  58. package/src/generated/cfg_webpush/client.ts +18 -0
  59. package/src/generated/cfg_webpush/index.ts +3 -1
@@ -13,4 +13,38 @@ declare const proxyMiddlewareConfig: {
13
13
  matcher: string[];
14
14
  };
15
15
 
16
- export { proxyMiddleware, proxyMiddlewareConfig };
16
+ /**
17
+ * Token Auto-Refresh Middleware
18
+ *
19
+ * Automatically refreshes access token when receiving 401 responses.
20
+ * Implements request queuing to prevent multiple simultaneous refresh attempts.
21
+ */
22
+ /**
23
+ * Attempt to refresh the access token using the refresh token
24
+ * @returns New access token or null if refresh failed
25
+ */
26
+ declare function refreshAccessToken(): Promise<string | null>;
27
+ /**
28
+ * Check if a response indicates an authentication error
29
+ */
30
+ declare function isAuthenticationError(response: Response): boolean;
31
+ /**
32
+ * Create a fetch wrapper that automatically refreshes tokens on 401
33
+ *
34
+ * @param originalFetch - The original fetch function to wrap
35
+ * @returns Wrapped fetch function with auto-refresh capability
36
+ */
37
+ declare function createAutoRefreshFetch(originalFetch: typeof fetch): typeof fetch;
38
+ /**
39
+ * Check if token is about to expire (within threshold)
40
+ * @param thresholdMs - Time in ms before expiry to consider "expiring soon"
41
+ * @returns true if token expires within threshold
42
+ */
43
+ declare function isTokenExpiringSoon(thresholdMs?: number): boolean;
44
+ /**
45
+ * Proactively refresh token if it's expiring soon
46
+ * Call this periodically or before important operations
47
+ */
48
+ declare function refreshIfExpiringSoon(thresholdMs?: number): Promise<void>;
49
+
50
+ export { createAutoRefreshFetch, isAuthenticationError, isTokenExpiringSoon, proxyMiddleware, proxyMiddlewareConfig, refreshAccessToken, refreshIfExpiringSoon };
@@ -13,4 +13,38 @@ declare const proxyMiddlewareConfig: {
13
13
  matcher: string[];
14
14
  };
15
15
 
16
- export { proxyMiddleware, proxyMiddlewareConfig };
16
+ /**
17
+ * Token Auto-Refresh Middleware
18
+ *
19
+ * Automatically refreshes access token when receiving 401 responses.
20
+ * Implements request queuing to prevent multiple simultaneous refresh attempts.
21
+ */
22
+ /**
23
+ * Attempt to refresh the access token using the refresh token
24
+ * @returns New access token or null if refresh failed
25
+ */
26
+ declare function refreshAccessToken(): Promise<string | null>;
27
+ /**
28
+ * Check if a response indicates an authentication error
29
+ */
30
+ declare function isAuthenticationError(response: Response): boolean;
31
+ /**
32
+ * Create a fetch wrapper that automatically refreshes tokens on 401
33
+ *
34
+ * @param originalFetch - The original fetch function to wrap
35
+ * @returns Wrapped fetch function with auto-refresh capability
36
+ */
37
+ declare function createAutoRefreshFetch(originalFetch: typeof fetch): typeof fetch;
38
+ /**
39
+ * Check if token is about to expire (within threshold)
40
+ * @param thresholdMs - Time in ms before expiry to consider "expiring soon"
41
+ * @returns true if token expires within threshold
42
+ */
43
+ declare function isTokenExpiringSoon(thresholdMs?: number): boolean;
44
+ /**
45
+ * Proactively refresh token if it's expiring soon
46
+ * Call this periodically or before important operations
47
+ */
48
+ declare function refreshIfExpiringSoon(thresholdMs?: number): Promise<void>;
49
+
50
+ export { createAutoRefreshFetch, isAuthenticationError, isTokenExpiringSoon, proxyMiddleware, proxyMiddlewareConfig, refreshAccessToken, refreshIfExpiringSoon };