@djangocfg/api 2.1.355 → 2.1.357

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 (112) hide show
  1. package/README.md +53 -632
  2. package/dist/auth-server.cjs +717 -200
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +717 -200
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +843 -783
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.d.cts +58 -37
  9. package/dist/auth.d.ts +58 -37
  10. package/dist/auth.mjs +846 -784
  11. package/dist/auth.mjs.map +1 -1
  12. package/dist/clients.cjs +1427 -0
  13. package/dist/clients.cjs.map +1 -1
  14. package/dist/clients.d.cts +1686 -0
  15. package/dist/clients.d.ts +1686 -0
  16. package/dist/clients.mjs +1427 -0
  17. package/dist/clients.mjs.map +1 -1
  18. package/dist/hooks.cjs +1277 -1924
  19. package/dist/hooks.cjs.map +1 -1
  20. package/dist/hooks.d.cts +18 -1206
  21. package/dist/hooks.d.ts +18 -1206
  22. package/dist/hooks.mjs +1253 -1900
  23. package/dist/hooks.mjs.map +1 -1
  24. package/dist/index.cjs +545 -1232
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1389 -1455
  27. package/dist/index.d.ts +1389 -1455
  28. package/dist/index.mjs +545 -1232
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +7 -2
  31. package/src/_api/generated/_cfg_accounts/api.ts +11 -3
  32. package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
  42. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
  43. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
  44. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
  45. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
  46. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
  47. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
  48. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
  49. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
  50. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
  51. package/src/_api/generated/_cfg_accounts/index.ts +1 -1
  52. package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
  53. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
  54. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
  55. package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
  56. package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
  57. package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
  58. package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
  59. package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
  60. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
  61. package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
  62. package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  63. package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
  64. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
  65. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
  66. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
  67. package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
  68. package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
  69. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
  70. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
  71. package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
  72. package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
  73. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
  74. package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
  75. package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
  76. package/src/_api/generated/_cfg_totp/api.ts +9 -3
  77. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
  78. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
  79. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
  80. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
  81. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
  82. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
  83. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
  84. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
  85. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
  86. package/src/_api/generated/_cfg_totp/index.ts +1 -1
  87. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
  88. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
  89. package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
  90. package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
  91. package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
  92. package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
  93. package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
  94. package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
  95. package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
  97. package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
  98. package/src/_api/generated/index.ts +3 -1
  99. package/src/_api/generated/sdk.gen.ts +80 -813
  100. package/src/_api/generated/types.gen.ts +320 -159
  101. package/src/auth/context/AccountsContext.tsx +18 -6
  102. package/src/auth/context/AuthContext.tsx +11 -3
  103. package/src/auth/hooks/useDeleteAccount.ts +2 -2
  104. package/src/auth/hooks/useGithubAuth.ts +3 -3
  105. package/src/auth/hooks/useTokenRefresh.ts +2 -2
  106. package/src/auth/hooks/useTwoFactor.ts +3 -3
  107. package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
  108. package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
  109. package/src/auth/middlewares/tokenRefresh.ts +2 -2
  110. package/src/hooks/index.ts +1 -0
  111. package/src/hooks/useApiKey.ts +73 -0
  112. package/src/index.ts +12 -16
package/dist/auth.mjs CHANGED
@@ -20,10 +20,11 @@ var isBrowser = typeof window !== "undefined";
20
20
  import { usePathname as usePathname3 } from "next/navigation";
21
21
  import {
22
22
  createContext as createContext2,
23
+ memo as memo2,
23
24
  useCallback as useCallback12,
24
25
  useContext as useContext2,
25
26
  useEffect as useEffect9,
26
- useMemo as useMemo2,
27
+ useMemo as useMemo3,
27
28
  useRef as useRef6,
28
29
  useState as useState12
29
30
  } from "react";
@@ -643,260 +644,6 @@ var APILogger = class {
643
644
  };
644
645
  var defaultLogger = new APILogger();
645
646
 
646
- // src/_api/generated/_cfg_accounts/api.ts
647
- var API = class {
648
- static {
649
- __name(this, "API");
650
- }
651
- logger;
652
- constructor(_baseUrl, opts = {}) {
653
- this.logger = new APILogger(opts.logger);
654
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
655
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
656
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
657
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
658
- }
659
- // ── Base URL ────────────────────────────────────────────────────────────
660
- getBaseUrl() {
661
- return auth.getBaseUrl();
662
- }
663
- setBaseUrl(url) {
664
- auth.setBaseUrl(url);
665
- }
666
- // ── Tokens ──────────────────────────────────────────────────────────────
667
- getToken() {
668
- return auth.getToken();
669
- }
670
- setToken(token) {
671
- auth.setToken(token);
672
- }
673
- getRefreshToken() {
674
- return auth.getRefreshToken();
675
- }
676
- setRefreshToken(token) {
677
- auth.setRefreshToken(token);
678
- }
679
- clearToken() {
680
- auth.clearTokens();
681
- }
682
- isAuthenticated() {
683
- return auth.isAuthenticated();
684
- }
685
- // ── Locale / API key ────────────────────────────────────────────────────
686
- getLocale() {
687
- return auth.getLocale();
688
- }
689
- setLocale(locale) {
690
- auth.setLocale(locale);
691
- }
692
- getApiKey() {
693
- return auth.getApiKey();
694
- }
695
- setApiKey(key) {
696
- auth.setApiKey(key);
697
- }
698
- // ── 401 handling ────────────────────────────────────────────────────────
699
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
700
- onUnauthorized(cb) {
701
- auth.onUnauthorized(cb);
702
- }
703
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
704
- setRefreshHandler(fn) {
705
- auth.setRefreshHandler(fn);
706
- }
707
- };
708
-
709
- // src/_api/generated/helpers/errors.ts
710
- var APIError = class extends Error {
711
- constructor(statusCode, statusText, response, url, message) {
712
- super(message || `HTTP ${statusCode}: ${statusText}`);
713
- this.statusCode = statusCode;
714
- this.statusText = statusText;
715
- this.response = response;
716
- this.url = url;
717
- this.name = "APIError";
718
- }
719
- static {
720
- __name(this, "APIError");
721
- }
722
- get details() {
723
- if (typeof this.response === "object" && this.response !== null) {
724
- return this.response;
725
- }
726
- return null;
727
- }
728
- get fieldErrors() {
729
- const details = this.details;
730
- if (!details) return null;
731
- const fieldErrors = {};
732
- for (const [key, value] of Object.entries(details)) {
733
- if (Array.isArray(value)) fieldErrors[key] = value;
734
- }
735
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
736
- }
737
- get errorMessage() {
738
- const details = this.details;
739
- if (!details) return this.message;
740
- if (details.detail) {
741
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
742
- }
743
- if (details.error) return String(details.error);
744
- if (details.message) return String(details.message);
745
- const fieldErrors = this.fieldErrors;
746
- if (fieldErrors) {
747
- const firstField = Object.keys(fieldErrors)[0];
748
- if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
749
- }
750
- return this.message;
751
- }
752
- get isValidationError() {
753
- return this.statusCode === 400;
754
- }
755
- get isAuthError() {
756
- return this.statusCode === 401;
757
- }
758
- get isPermissionError() {
759
- return this.statusCode === 403;
760
- }
761
- get isNotFoundError() {
762
- return this.statusCode === 404;
763
- }
764
- get isServerError() {
765
- return this.statusCode >= 500 && this.statusCode < 600;
766
- }
767
- };
768
-
769
- // src/_api/generated/_cfg_centrifugo/api.ts
770
- var API2 = class {
771
- static {
772
- __name(this, "API");
773
- }
774
- logger;
775
- constructor(_baseUrl, opts = {}) {
776
- this.logger = new APILogger(opts.logger);
777
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
778
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
779
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
780
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
781
- }
782
- // ── Base URL ────────────────────────────────────────────────────────────
783
- getBaseUrl() {
784
- return auth.getBaseUrl();
785
- }
786
- setBaseUrl(url) {
787
- auth.setBaseUrl(url);
788
- }
789
- // ── Tokens ──────────────────────────────────────────────────────────────
790
- getToken() {
791
- return auth.getToken();
792
- }
793
- setToken(token) {
794
- auth.setToken(token);
795
- }
796
- getRefreshToken() {
797
- return auth.getRefreshToken();
798
- }
799
- setRefreshToken(token) {
800
- auth.setRefreshToken(token);
801
- }
802
- clearToken() {
803
- auth.clearTokens();
804
- }
805
- isAuthenticated() {
806
- return auth.isAuthenticated();
807
- }
808
- // ── Locale / API key ────────────────────────────────────────────────────
809
- getLocale() {
810
- return auth.getLocale();
811
- }
812
- setLocale(locale) {
813
- auth.setLocale(locale);
814
- }
815
- getApiKey() {
816
- return auth.getApiKey();
817
- }
818
- setApiKey(key) {
819
- auth.setApiKey(key);
820
- }
821
- // ── 401 handling ────────────────────────────────────────────────────────
822
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
823
- onUnauthorized(cb) {
824
- auth.onUnauthorized(cb);
825
- }
826
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
827
- setRefreshHandler(fn) {
828
- auth.setRefreshHandler(fn);
829
- }
830
- };
831
-
832
- // src/_api/generated/_cfg_totp/api.ts
833
- var API3 = class {
834
- static {
835
- __name(this, "API");
836
- }
837
- logger;
838
- constructor(_baseUrl, opts = {}) {
839
- this.logger = new APILogger(opts.logger);
840
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
841
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
842
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
843
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
844
- }
845
- // ── Base URL ────────────────────────────────────────────────────────────
846
- getBaseUrl() {
847
- return auth.getBaseUrl();
848
- }
849
- setBaseUrl(url) {
850
- auth.setBaseUrl(url);
851
- }
852
- // ── Tokens ──────────────────────────────────────────────────────────────
853
- getToken() {
854
- return auth.getToken();
855
- }
856
- setToken(token) {
857
- auth.setToken(token);
858
- }
859
- getRefreshToken() {
860
- return auth.getRefreshToken();
861
- }
862
- setRefreshToken(token) {
863
- auth.setRefreshToken(token);
864
- }
865
- clearToken() {
866
- auth.clearTokens();
867
- }
868
- isAuthenticated() {
869
- return auth.isAuthenticated();
870
- }
871
- // ── Locale / API key ────────────────────────────────────────────────────
872
- getLocale() {
873
- return auth.getLocale();
874
- }
875
- setLocale(locale) {
876
- auth.setLocale(locale);
877
- }
878
- getApiKey() {
879
- return auth.getApiKey();
880
- }
881
- setApiKey(key) {
882
- auth.setApiKey(key);
883
- }
884
- // ── 401 handling ────────────────────────────────────────────────────────
885
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
886
- onUnauthorized(cb) {
887
- auth.onUnauthorized(cb);
888
- }
889
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
890
- setRefreshHandler(fn) {
891
- auth.setRefreshHandler(fn);
892
- }
893
- };
894
-
895
- // src/_api/generated/index.ts
896
- var CfgAccountsApi = new API();
897
- var CfgCentrifugoApi = new API2();
898
- var CfgTotpApi = new API3();
899
-
900
647
  // src/_api/generated/core/bodySerializer.gen.ts
901
648
  var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
902
649
  if (typeof value === "string" || value instanceof Blob) {
@@ -1723,18 +1470,79 @@ var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1723
1470
  installAuthOnClient(client);
1724
1471
 
1725
1472
  // src/_api/generated/sdk.gen.ts
1726
- var Cfg = class {
1473
+ var CfgAccountsApiKey = class {
1727
1474
  static {
1728
- __name(this, "Cfg");
1475
+ __name(this, "CfgAccountsApiKey");
1729
1476
  }
1730
1477
  /**
1731
- * List OAuth connections
1478
+ * Get API key details
1479
+ *
1480
+ * Retrieve the current user's API key (masked) and metadata.
1481
+ */
1482
+ static cfgAccountsApiKeyRetrieve(options) {
1483
+ return (options?.client ?? client).get({
1484
+ security: [{ scheme: "bearer", type: "http" }, {
1485
+ in: "cookie",
1486
+ name: "sessionid",
1487
+ type: "apiKey"
1488
+ }],
1489
+ url: "/cfg/accounts/api-key/",
1490
+ ...options
1491
+ });
1492
+ }
1493
+ /**
1494
+ * Regenerate API key
1495
+ *
1496
+ * Generate a new API key. The full key is returned only once.
1497
+ */
1498
+ static cfgAccountsApiKeyRegenerateCreate(options) {
1499
+ return (options.client ?? client).post({
1500
+ security: [{ scheme: "bearer", type: "http" }, {
1501
+ in: "cookie",
1502
+ name: "sessionid",
1503
+ type: "apiKey"
1504
+ }],
1505
+ url: "/cfg/accounts/api-key/regenerate/",
1506
+ ...options,
1507
+ headers: {
1508
+ "Content-Type": "application/json",
1509
+ ...options.headers
1510
+ }
1511
+ });
1512
+ }
1513
+ /**
1514
+ * Test API key
1515
+ *
1516
+ * Test whether an API key is valid without consuming it.
1517
+ */
1518
+ static cfgAccountsApiKeyTestCreate(options) {
1519
+ return (options.client ?? client).post({
1520
+ security: [{ scheme: "bearer", type: "http" }, {
1521
+ in: "cookie",
1522
+ name: "sessionid",
1523
+ type: "apiKey"
1524
+ }],
1525
+ url: "/cfg/accounts/api-key/test/",
1526
+ ...options,
1527
+ headers: {
1528
+ "Content-Type": "application/json",
1529
+ ...options.headers
1530
+ }
1531
+ });
1532
+ }
1533
+ };
1534
+ var CfgAccountsOauth = class {
1535
+ static {
1536
+ __name(this, "CfgAccountsOauth");
1537
+ }
1538
+ /**
1539
+ * List OAuth connections
1732
1540
  *
1733
1541
  * Get all OAuth connections for the current user.
1734
1542
  */
1735
1543
  static cfgAccountsOauthConnectionsList(options) {
1736
1544
  return (options?.client ?? client).get({
1737
- security: [{ scheme: "bearer", type: "http" }],
1545
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1738
1546
  url: "/cfg/accounts/oauth/connections/",
1739
1547
  ...options
1740
1548
  });
@@ -1746,7 +1554,7 @@ var Cfg = class {
1746
1554
  */
1747
1555
  static cfgAccountsOauthDisconnectCreate(options) {
1748
1556
  return (options.client ?? client).post({
1749
- security: [{ scheme: "bearer", type: "http" }],
1557
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1750
1558
  url: "/cfg/accounts/oauth/disconnect/",
1751
1559
  ...options,
1752
1560
  headers: {
@@ -1793,12 +1601,17 @@ var Cfg = class {
1793
1601
  static cfgAccountsOauthProvidersRetrieve(options) {
1794
1602
  return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1795
1603
  }
1604
+ };
1605
+ var CfgAccounts = class {
1606
+ static {
1607
+ __name(this, "CfgAccounts");
1608
+ }
1796
1609
  /**
1797
1610
  * Request OTP code to email.
1798
1611
  */
1799
1612
  static cfgAccountsOtpRequestCreate(options) {
1800
1613
  return (options.client ?? client).post({
1801
- security: [{ scheme: "bearer", type: "http" }],
1614
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1802
1615
  url: "/cfg/accounts/otp/request/",
1803
1616
  ...options,
1804
1617
  headers: {
@@ -1819,7 +1632,7 @@ var Cfg = class {
1819
1632
  */
1820
1633
  static cfgAccountsOtpVerifyCreate(options) {
1821
1634
  return (options.client ?? client).post({
1822
- security: [{ scheme: "bearer", type: "http" }],
1635
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1823
1636
  url: "/cfg/accounts/otp/verify/",
1824
1637
  ...options,
1825
1638
  headers: {
@@ -1828,6 +1641,11 @@ var Cfg = class {
1828
1641
  }
1829
1642
  });
1830
1643
  }
1644
+ };
1645
+ var CfgAccountsProfile = class {
1646
+ static {
1647
+ __name(this, "CfgAccountsProfile");
1648
+ }
1831
1649
  /**
1832
1650
  * Get current user profile
1833
1651
  *
@@ -1852,7 +1670,7 @@ var Cfg = class {
1852
1670
  static cfgAccountsProfileAvatarCreate(options) {
1853
1671
  return (options?.client ?? client).post({
1854
1672
  ...formDataBodySerializer,
1855
- security: [{ scheme: "bearer", type: "http" }],
1673
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1856
1674
  url: "/cfg/accounts/profile/avatar/",
1857
1675
  ...options,
1858
1676
  headers: {
@@ -1967,6 +1785,11 @@ var Cfg = class {
1967
1785
  }
1968
1786
  });
1969
1787
  }
1788
+ };
1789
+ var CfgAccountsAuth = class {
1790
+ static {
1791
+ __name(this, "CfgAccountsAuth");
1792
+ }
1970
1793
  /**
1971
1794
  * Refresh JWT token.
1972
1795
  */
@@ -1980,6 +1803,11 @@ var Cfg = class {
1980
1803
  }
1981
1804
  });
1982
1805
  }
1806
+ };
1807
+ var CfgCentrifugo = class {
1808
+ static {
1809
+ __name(this, "CfgCentrifugo");
1810
+ }
1983
1811
  /**
1984
1812
  * Get Centrifugo connection token
1985
1813
  *
@@ -1987,17 +1815,22 @@ var Cfg = class {
1987
1815
  */
1988
1816
  static cfgCentrifugoAuthTokenRetrieve(options) {
1989
1817
  return (options?.client ?? client).get({
1990
- security: [{ scheme: "bearer", type: "http" }],
1818
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1991
1819
  url: "/cfg/centrifugo/auth/token/",
1992
1820
  ...options
1993
1821
  });
1994
1822
  }
1823
+ };
1824
+ var CfgTotpBackupCodes = class {
1825
+ static {
1826
+ __name(this, "CfgTotpBackupCodes");
1827
+ }
1995
1828
  /**
1996
1829
  * Get backup codes status for user.
1997
1830
  */
1998
1831
  static cfgTotpBackupCodesRetrieve(options) {
1999
1832
  return (options?.client ?? client).get({
2000
- security: [{ scheme: "bearer", type: "http" }],
1833
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2001
1834
  url: "/cfg/totp/backup-codes/",
2002
1835
  ...options
2003
1836
  });
@@ -2010,7 +1843,7 @@ var Cfg = class {
2010
1843
  */
2011
1844
  static cfgTotpBackupCodesRegenerateCreate(options) {
2012
1845
  return (options.client ?? client).post({
2013
- security: [{ scheme: "bearer", type: "http" }],
1846
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2014
1847
  url: "/cfg/totp/backup-codes/regenerate/",
2015
1848
  ...options,
2016
1849
  headers: {
@@ -2019,12 +1852,17 @@ var Cfg = class {
2019
1852
  }
2020
1853
  });
2021
1854
  }
1855
+ };
1856
+ var CfgTotp = class {
1857
+ static {
1858
+ __name(this, "CfgTotp");
1859
+ }
2022
1860
  /**
2023
1861
  * List all TOTP devices for user.
2024
1862
  */
2025
1863
  static cfgTotpDevicesRetrieve(options) {
2026
1864
  return (options?.client ?? client).get({
2027
- security: [{ scheme: "bearer", type: "http" }],
1865
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2028
1866
  url: "/cfg/totp/devices/",
2029
1867
  ...options
2030
1868
  });
@@ -2036,7 +1874,7 @@ var Cfg = class {
2036
1874
  */
2037
1875
  static cfgTotpDevicesDestroy(options) {
2038
1876
  return (options.client ?? client).delete({
2039
- security: [{ scheme: "bearer", type: "http" }],
1877
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2040
1878
  url: "/cfg/totp/devices/{id}/",
2041
1879
  ...options
2042
1880
  });
@@ -2048,7 +1886,7 @@ var Cfg = class {
2048
1886
  */
2049
1887
  static cfgTotpDisableCreate(options) {
2050
1888
  return (options.client ?? client).post({
2051
- security: [{ scheme: "bearer", type: "http" }],
1889
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2052
1890
  url: "/cfg/totp/disable/",
2053
1891
  ...options,
2054
1892
  headers: {
@@ -2057,6 +1895,11 @@ var Cfg = class {
2057
1895
  }
2058
1896
  });
2059
1897
  }
1898
+ };
1899
+ var CfgTotpSetup = class {
1900
+ static {
1901
+ __name(this, "CfgTotpSetup");
1902
+ }
2060
1903
  /**
2061
1904
  * Start 2FA setup process.
2062
1905
  *
@@ -2064,7 +1907,7 @@ var Cfg = class {
2064
1907
  */
2065
1908
  static cfgTotpSetupCreate(options) {
2066
1909
  return (options?.client ?? client).post({
2067
- security: [{ scheme: "bearer", type: "http" }],
1910
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2068
1911
  url: "/cfg/totp/setup/",
2069
1912
  ...options,
2070
1913
  headers: {
@@ -2080,7 +1923,7 @@ var Cfg = class {
2080
1923
  */
2081
1924
  static cfgTotpSetupConfirmCreate(options) {
2082
1925
  return (options.client ?? client).post({
2083
- security: [{ scheme: "bearer", type: "http" }],
1926
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2084
1927
  url: "/cfg/totp/setup/confirm/",
2085
1928
  ...options,
2086
1929
  headers: {
@@ -2089,6 +1932,11 @@ var Cfg = class {
2089
1932
  }
2090
1933
  });
2091
1934
  }
1935
+ };
1936
+ var CfgTotpVerify = class {
1937
+ static {
1938
+ __name(this, "CfgTotpVerify");
1939
+ }
2092
1940
  /**
2093
1941
  * Verify TOTP code for 2FA session.
2094
1942
  *
@@ -2096,7 +1944,7 @@ var Cfg = class {
2096
1944
  */
2097
1945
  static cfgTotpVerifyCreate(options) {
2098
1946
  return (options.client ?? client).post({
2099
- security: [{ scheme: "bearer", type: "http" }],
1947
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2100
1948
  url: "/cfg/totp/verify/",
2101
1949
  ...options,
2102
1950
  headers: {
@@ -2112,7 +1960,7 @@ var Cfg = class {
2112
1960
  */
2113
1961
  static cfgTotpVerifyBackupCreate(options) {
2114
1962
  return (options.client ?? client).post({
2115
- security: [{ scheme: "bearer", type: "http" }],
1963
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2116
1964
  url: "/cfg/totp/verify/backup/",
2117
1965
  ...options,
2118
1966
  headers: {
@@ -2122,345 +1970,271 @@ var Cfg = class {
2122
1970
  });
2123
1971
  }
2124
1972
  };
2125
- var OAuth = class {
1973
+
1974
+ // src/_api/generated/_cfg_accounts/api.ts
1975
+ var API = class {
2126
1976
  static {
2127
- __name(this, "OAuth");
1977
+ __name(this, "API");
2128
1978
  }
2129
- /**
2130
- * List OAuth connections
2131
- *
2132
- * Get all OAuth connections for the current user.
2133
- */
2134
- static cfgAccountsOauthConnectionsList(options) {
2135
- return (options?.client ?? client).get({
2136
- security: [{ scheme: "bearer", type: "http" }],
2137
- url: "/cfg/accounts/oauth/connections/",
2138
- ...options
2139
- });
1979
+ logger;
1980
+ cfgAccountsApiKey = CfgAccountsApiKey;
1981
+ cfgAccountsOauth = CfgAccountsOauth;
1982
+ cfgAccounts = CfgAccounts;
1983
+ cfgAccountsProfile = CfgAccountsProfile;
1984
+ cfgAccountsAuth = CfgAccountsAuth;
1985
+ constructor(_baseUrl, opts = {}) {
1986
+ this.logger = new APILogger(opts.logger);
1987
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1988
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1989
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1990
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
2140
1991
  }
2141
- /**
2142
- * Disconnect OAuth provider
2143
- *
2144
- * Remove OAuth connection for the specified provider.
2145
- */
2146
- static cfgAccountsOauthDisconnectCreate(options) {
2147
- return (options.client ?? client).post({
2148
- security: [{ scheme: "bearer", type: "http" }],
2149
- url: "/cfg/accounts/oauth/disconnect/",
2150
- ...options,
2151
- headers: {
2152
- "Content-Type": "application/json",
2153
- ...options.headers
2154
- }
2155
- });
1992
+ // ── Base URL ────────────────────────────────────────────────────────────
1993
+ getBaseUrl() {
1994
+ return auth.getBaseUrl();
2156
1995
  }
2157
- /**
2158
- * Start GitHub OAuth
2159
- *
2160
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
2161
- */
2162
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
2163
- return (options?.client ?? client).post({
2164
- url: "/cfg/accounts/oauth/github/authorize/",
2165
- ...options,
2166
- headers: {
2167
- "Content-Type": "application/json",
2168
- ...options?.headers
2169
- }
2170
- });
1996
+ setBaseUrl(url) {
1997
+ auth.setBaseUrl(url);
2171
1998
  }
2172
- /**
2173
- * Complete GitHub OAuth
2174
- *
2175
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
2176
- */
2177
- static cfgAccountsOauthGithubCallbackCreate(options) {
2178
- return (options.client ?? client).post({
2179
- url: "/cfg/accounts/oauth/github/callback/",
2180
- ...options,
2181
- headers: {
2182
- "Content-Type": "application/json",
2183
- ...options.headers
2184
- }
2185
- });
1999
+ // ── Tokens ──────────────────────────────────────────────────────────────
2000
+ getToken() {
2001
+ return auth.getToken();
2186
2002
  }
2187
- /**
2188
- * List OAuth providers
2189
- *
2190
- * Get list of available OAuth providers for authentication.
2191
- */
2192
- static cfgAccountsOauthProvidersRetrieve(options) {
2193
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
2003
+ setToken(token) {
2004
+ auth.setToken(token);
2194
2005
  }
2195
- };
2196
- var UserProfile = class {
2197
- static {
2198
- __name(this, "UserProfile");
2006
+ getRefreshToken() {
2007
+ return auth.getRefreshToken();
2199
2008
  }
2200
- /**
2201
- * Get current user profile
2202
- *
2203
- * Retrieve the current authenticated user's profile information.
2204
- */
2205
- static cfgAccountsProfileRetrieve(options) {
2206
- return (options?.client ?? client).get({
2207
- security: [{ scheme: "bearer", type: "http" }, {
2208
- in: "cookie",
2209
- name: "sessionid",
2210
- type: "apiKey"
2211
- }],
2212
- url: "/cfg/accounts/profile/",
2213
- ...options
2214
- });
2009
+ setRefreshToken(token) {
2010
+ auth.setRefreshToken(token);
2215
2011
  }
2216
- /**
2217
- * Upload user avatar
2218
- *
2219
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
2220
- */
2221
- static cfgAccountsProfileAvatarCreate(options) {
2222
- return (options?.client ?? client).post({
2223
- ...formDataBodySerializer,
2224
- security: [{ scheme: "bearer", type: "http" }],
2225
- url: "/cfg/accounts/profile/avatar/",
2226
- ...options,
2227
- headers: {
2228
- "Content-Type": null,
2229
- ...options?.headers
2230
- }
2231
- });
2012
+ clearToken() {
2013
+ auth.clearTokens();
2232
2014
  }
2233
- /**
2234
- * Delete user account
2235
- *
2236
- *
2237
- * Permanently delete the current user's account.
2238
- *
2239
- * This operation:
2240
- * - Deactivates the account (user cannot log in)
2241
- * - Anonymizes personal data (GDPR compliance)
2242
- * - Frees up the email address for re-registration
2243
- * - Preserves audit trail
2244
- *
2245
- * The account can be restored by an administrator if needed.
2246
- *
2247
- */
2248
- static cfgAccountsProfileDeleteCreate(options) {
2249
- return (options?.client ?? client).post({
2250
- security: [{ scheme: "bearer", type: "http" }, {
2251
- in: "cookie",
2252
- name: "sessionid",
2253
- type: "apiKey"
2254
- }],
2255
- url: "/cfg/accounts/profile/delete/",
2256
- ...options
2257
- });
2015
+ isAuthenticated() {
2016
+ return auth.isAuthenticated();
2258
2017
  }
2259
- /**
2260
- * Partial update user profile
2261
- *
2262
- * Partially update the current authenticated user's profile information. Supports avatar upload.
2263
- */
2264
- static cfgAccountsProfilePartialPartialUpdate(options) {
2265
- return (options?.client ?? client).patch({
2266
- security: [{ scheme: "bearer", type: "http" }, {
2267
- in: "cookie",
2268
- name: "sessionid",
2269
- type: "apiKey"
2270
- }],
2271
- url: "/cfg/accounts/profile/partial/",
2272
- ...options,
2273
- headers: {
2274
- "Content-Type": "application/json",
2275
- ...options?.headers
2276
- }
2277
- });
2018
+ // ── Locale / API key ────────────────────────────────────────────────────
2019
+ getLocale() {
2020
+ return auth.getLocale();
2278
2021
  }
2279
- /**
2280
- * Partial update user profile
2281
- *
2282
- * Partially update the current authenticated user's profile information. Supports avatar upload.
2283
- */
2284
- static cfgAccountsProfilePartialUpdate(options) {
2285
- return (options?.client ?? client).put({
2286
- security: [{ scheme: "bearer", type: "http" }, {
2287
- in: "cookie",
2288
- name: "sessionid",
2289
- type: "apiKey"
2290
- }],
2291
- url: "/cfg/accounts/profile/partial/",
2292
- ...options,
2293
- headers: {
2294
- "Content-Type": "application/json",
2295
- ...options?.headers
2296
- }
2297
- });
2022
+ setLocale(locale) {
2023
+ auth.setLocale(locale);
2298
2024
  }
2299
- /**
2300
- * Update user profile
2301
- *
2302
- * Update the current authenticated user's profile information.
2303
- */
2304
- static cfgAccountsProfileUpdatePartialUpdate(options) {
2305
- return (options?.client ?? client).patch({
2306
- security: [{ scheme: "bearer", type: "http" }, {
2307
- in: "cookie",
2308
- name: "sessionid",
2309
- type: "apiKey"
2310
- }],
2311
- url: "/cfg/accounts/profile/update/",
2312
- ...options,
2313
- headers: {
2314
- "Content-Type": "application/json",
2315
- ...options?.headers
2316
- }
2317
- });
2025
+ getApiKey() {
2026
+ return auth.getApiKey();
2318
2027
  }
2319
- /**
2320
- * Update user profile
2321
- *
2322
- * Update the current authenticated user's profile information.
2323
- */
2324
- static cfgAccountsProfileUpdateUpdate(options) {
2325
- return (options?.client ?? client).put({
2326
- security: [{ scheme: "bearer", type: "http" }, {
2327
- in: "cookie",
2328
- name: "sessionid",
2329
- type: "apiKey"
2330
- }],
2331
- url: "/cfg/accounts/profile/update/",
2332
- ...options,
2333
- headers: {
2334
- "Content-Type": "application/json",
2335
- ...options?.headers
2336
- }
2337
- });
2028
+ setApiKey(key) {
2029
+ auth.setApiKey(key);
2338
2030
  }
2339
- };
2340
- var Auth = class {
2341
- static {
2342
- __name(this, "Auth");
2031
+ // ── 401 handling ────────────────────────────────────────────────────────
2032
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
2033
+ onUnauthorized(cb) {
2034
+ auth.onUnauthorized(cb);
2343
2035
  }
2344
- /**
2345
- * Refresh JWT token.
2346
- */
2347
- static cfgAccountsTokenRefreshCreate(options) {
2348
- return (options.client ?? client).post({
2349
- url: "/cfg/accounts/token/refresh/",
2350
- ...options,
2351
- headers: {
2352
- "Content-Type": "application/json",
2353
- ...options.headers
2354
- }
2355
- });
2036
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
2037
+ setRefreshHandler(fn) {
2038
+ auth.setRefreshHandler(fn);
2356
2039
  }
2357
2040
  };
2358
- var TotpManagement = class {
2041
+
2042
+ // src/_api/generated/helpers/errors.ts
2043
+ var APIError = class extends Error {
2044
+ constructor(statusCode, statusText, response, url, message) {
2045
+ super(message || `HTTP ${statusCode}: ${statusText}`);
2046
+ this.statusCode = statusCode;
2047
+ this.statusText = statusText;
2048
+ this.response = response;
2049
+ this.url = url;
2050
+ this.name = "APIError";
2051
+ }
2359
2052
  static {
2360
- __name(this, "TotpManagement");
2053
+ __name(this, "APIError");
2361
2054
  }
2362
- /**
2363
- * List all TOTP devices for user.
2364
- */
2365
- static cfgTotpDevicesRetrieve(options) {
2366
- return (options?.client ?? client).get({
2367
- security: [{ scheme: "bearer", type: "http" }],
2368
- url: "/cfg/totp/devices/",
2369
- ...options
2370
- });
2055
+ get details() {
2056
+ if (typeof this.response === "object" && this.response !== null) {
2057
+ return this.response;
2058
+ }
2059
+ return null;
2371
2060
  }
2372
- /**
2373
- * Completely disable 2FA for account.
2374
- *
2375
- * Requires verification code.
2376
- */
2377
- static cfgTotpDisableCreate(options) {
2378
- return (options.client ?? client).post({
2379
- security: [{ scheme: "bearer", type: "http" }],
2380
- url: "/cfg/totp/disable/",
2381
- ...options,
2382
- headers: {
2383
- "Content-Type": "application/json",
2384
- ...options.headers
2385
- }
2386
- });
2061
+ get fieldErrors() {
2062
+ const details = this.details;
2063
+ if (!details) return null;
2064
+ const fieldErrors = {};
2065
+ for (const [key, value] of Object.entries(details)) {
2066
+ if (Array.isArray(value)) fieldErrors[key] = value;
2067
+ }
2068
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
2069
+ }
2070
+ get errorMessage() {
2071
+ const details = this.details;
2072
+ if (!details) return this.message;
2073
+ if (details.detail) {
2074
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2075
+ }
2076
+ if (details.error) return String(details.error);
2077
+ if (details.message) return String(details.message);
2078
+ const fieldErrors = this.fieldErrors;
2079
+ if (fieldErrors) {
2080
+ const firstField = Object.keys(fieldErrors)[0];
2081
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
2082
+ }
2083
+ return this.message;
2084
+ }
2085
+ get isValidationError() {
2086
+ return this.statusCode === 400;
2087
+ }
2088
+ get isAuthError() {
2089
+ return this.statusCode === 401;
2090
+ }
2091
+ get isPermissionError() {
2092
+ return this.statusCode === 403;
2093
+ }
2094
+ get isNotFoundError() {
2095
+ return this.statusCode === 404;
2096
+ }
2097
+ get isServerError() {
2098
+ return this.statusCode >= 500 && this.statusCode < 600;
2387
2099
  }
2388
2100
  };
2389
- var TotpSetup = class {
2101
+
2102
+ // src/_api/generated/_cfg_centrifugo/api.ts
2103
+ var API2 = class {
2390
2104
  static {
2391
- __name(this, "TotpSetup");
2105
+ __name(this, "API");
2392
2106
  }
2393
- /**
2394
- * Start 2FA setup process.
2395
- *
2396
- * Creates a new TOTP device and returns QR code for scanning.
2397
- */
2398
- static cfgTotpSetupCreate(options) {
2399
- return (options?.client ?? client).post({
2400
- security: [{ scheme: "bearer", type: "http" }],
2401
- url: "/cfg/totp/setup/",
2402
- ...options,
2403
- headers: {
2404
- "Content-Type": "application/json",
2405
- ...options?.headers
2406
- }
2407
- });
2107
+ logger;
2108
+ cfgCentrifugo = CfgCentrifugo;
2109
+ constructor(_baseUrl, opts = {}) {
2110
+ this.logger = new APILogger(opts.logger);
2111
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
2112
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
2113
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
2114
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
2408
2115
  }
2409
- /**
2410
- * Confirm 2FA setup with first valid code.
2411
- *
2412
- * Activates the device and generates backup codes.
2413
- */
2414
- static cfgTotpSetupConfirmCreate(options) {
2415
- return (options.client ?? client).post({
2416
- security: [{ scheme: "bearer", type: "http" }],
2417
- url: "/cfg/totp/setup/confirm/",
2418
- ...options,
2419
- headers: {
2420
- "Content-Type": "application/json",
2421
- ...options.headers
2422
- }
2423
- });
2116
+ // ── Base URL ────────────────────────────────────────────────────────────
2117
+ getBaseUrl() {
2118
+ return auth.getBaseUrl();
2119
+ }
2120
+ setBaseUrl(url) {
2121
+ auth.setBaseUrl(url);
2122
+ }
2123
+ // ── Tokens ──────────────────────────────────────────────────────────────
2124
+ getToken() {
2125
+ return auth.getToken();
2126
+ }
2127
+ setToken(token) {
2128
+ auth.setToken(token);
2129
+ }
2130
+ getRefreshToken() {
2131
+ return auth.getRefreshToken();
2132
+ }
2133
+ setRefreshToken(token) {
2134
+ auth.setRefreshToken(token);
2135
+ }
2136
+ clearToken() {
2137
+ auth.clearTokens();
2138
+ }
2139
+ isAuthenticated() {
2140
+ return auth.isAuthenticated();
2141
+ }
2142
+ // ── Locale / API key ────────────────────────────────────────────────────
2143
+ getLocale() {
2144
+ return auth.getLocale();
2145
+ }
2146
+ setLocale(locale) {
2147
+ auth.setLocale(locale);
2148
+ }
2149
+ getApiKey() {
2150
+ return auth.getApiKey();
2151
+ }
2152
+ setApiKey(key) {
2153
+ auth.setApiKey(key);
2154
+ }
2155
+ // ── 401 handling ────────────────────────────────────────────────────────
2156
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
2157
+ onUnauthorized(cb) {
2158
+ auth.onUnauthorized(cb);
2159
+ }
2160
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
2161
+ setRefreshHandler(fn) {
2162
+ auth.setRefreshHandler(fn);
2424
2163
  }
2425
2164
  };
2426
- var TotpVerification = class {
2165
+
2166
+ // src/_api/generated/_cfg_totp/api.ts
2167
+ var API3 = class {
2427
2168
  static {
2428
- __name(this, "TotpVerification");
2169
+ __name(this, "API");
2429
2170
  }
2430
- /**
2431
- * Verify TOTP code for 2FA session.
2432
- *
2433
- * Completes authentication and returns JWT tokens on success.
2434
- */
2435
- static cfgTotpVerifyCreate(options) {
2436
- return (options.client ?? client).post({
2437
- security: [{ scheme: "bearer", type: "http" }],
2438
- url: "/cfg/totp/verify/",
2439
- ...options,
2440
- headers: {
2441
- "Content-Type": "application/json",
2442
- ...options.headers
2443
- }
2444
- });
2171
+ logger;
2172
+ cfgTotpBackupCodes = CfgTotpBackupCodes;
2173
+ cfgTotp = CfgTotp;
2174
+ cfgTotpSetup = CfgTotpSetup;
2175
+ cfgTotpVerify = CfgTotpVerify;
2176
+ constructor(_baseUrl, opts = {}) {
2177
+ this.logger = new APILogger(opts.logger);
2178
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
2179
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
2180
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
2181
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
2182
+ }
2183
+ // ── Base URL ────────────────────────────────────────────────────────────
2184
+ getBaseUrl() {
2185
+ return auth.getBaseUrl();
2186
+ }
2187
+ setBaseUrl(url) {
2188
+ auth.setBaseUrl(url);
2189
+ }
2190
+ // ── Tokens ──────────────────────────────────────────────────────────────
2191
+ getToken() {
2192
+ return auth.getToken();
2193
+ }
2194
+ setToken(token) {
2195
+ auth.setToken(token);
2196
+ }
2197
+ getRefreshToken() {
2198
+ return auth.getRefreshToken();
2199
+ }
2200
+ setRefreshToken(token) {
2201
+ auth.setRefreshToken(token);
2202
+ }
2203
+ clearToken() {
2204
+ auth.clearTokens();
2205
+ }
2206
+ isAuthenticated() {
2207
+ return auth.isAuthenticated();
2208
+ }
2209
+ // ── Locale / API key ────────────────────────────────────────────────────
2210
+ getLocale() {
2211
+ return auth.getLocale();
2212
+ }
2213
+ setLocale(locale) {
2214
+ auth.setLocale(locale);
2215
+ }
2216
+ getApiKey() {
2217
+ return auth.getApiKey();
2218
+ }
2219
+ setApiKey(key) {
2220
+ auth.setApiKey(key);
2221
+ }
2222
+ // ── 401 handling ────────────────────────────────────────────────────────
2223
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
2224
+ onUnauthorized(cb) {
2225
+ auth.onUnauthorized(cb);
2445
2226
  }
2446
- /**
2447
- * Verify backup recovery code for 2FA session.
2448
- *
2449
- * Alternative verification method when TOTP device unavailable.
2450
- */
2451
- static cfgTotpVerifyBackupCreate(options) {
2452
- return (options.client ?? client).post({
2453
- security: [{ scheme: "bearer", type: "http" }],
2454
- url: "/cfg/totp/verify/backup/",
2455
- ...options,
2456
- headers: {
2457
- "Content-Type": "application/json",
2458
- ...options.headers
2459
- }
2460
- });
2227
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
2228
+ setRefreshHandler(fn) {
2229
+ auth.setRefreshHandler(fn);
2461
2230
  }
2462
2231
  };
2463
2232
 
2233
+ // src/_api/generated/index.ts
2234
+ var CfgAccountsApi = new API();
2235
+ var CfgCentrifugoApi = new API2();
2236
+ var CfgTotpApi = new API3();
2237
+
2464
2238
  // src/auth/utils/analytics.ts
2465
2239
  var AnalyticsEvent = /* @__PURE__ */ ((AnalyticsEvent2) => {
2466
2240
  AnalyticsEvent2["AUTH_OTP_REQUEST"] = "auth_otp_request";
@@ -2549,7 +2323,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
2549
2323
  setError(null);
2550
2324
  try {
2551
2325
  authLogger.info("Verifying TOTP code...");
2552
- const result = await TotpVerification.cfgTotpVerifyCreate({
2326
+ const result = await CfgTotpVerify.cfgTotpVerifyCreate({
2553
2327
  body: { session_id: sessionId, code },
2554
2328
  throwOnError: true
2555
2329
  });
@@ -2593,7 +2367,7 @@ var useTwoFactor = /* @__PURE__ */ __name((options = {}) => {
2593
2367
  setError(null);
2594
2368
  try {
2595
2369
  authLogger.info("Verifying backup code...");
2596
- const result = await TotpVerification.cfgTotpVerifyBackupCreate({
2370
+ const result = await CfgTotpVerify.cfgTotpVerifyBackupCreate({
2597
2371
  body: {
2598
2372
  session_id: sessionId,
2599
2373
  backup_code: backupCode.replace(/\s+/g, "")
@@ -2937,7 +2711,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
2937
2711
  category: "auth" /* AUTH */,
2938
2712
  label: "github"
2939
2713
  });
2940
- const result = await OAuth.cfgAccountsOauthGithubAuthorizeCreate({
2714
+ const result = await CfgAccountsOauth.cfgAccountsOauthGithubAuthorizeCreate({
2941
2715
  body: {
2942
2716
  source_url: sourceUrl || (typeof window !== "undefined" ? window.location.href : "")
2943
2717
  },
@@ -2979,7 +2753,7 @@ var useGithubAuth = /* @__PURE__ */ __name((options = {}) => {
2979
2753
  sessionStorage.removeItem("oauth_state");
2980
2754
  sessionStorage.removeItem("oauth_provider");
2981
2755
  }
2982
- const result = await OAuth.cfgAccountsOauthGithubCallbackCreate({
2756
+ const result = await CfgAccountsOauth.cfgAccountsOauthGithubCallbackCreate({
2983
2757
  body: { code, state },
2984
2758
  throwOnError: true
2985
2759
  });
@@ -3058,7 +2832,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
3058
2832
  setSetupStep("scanning");
3059
2833
  try {
3060
2834
  authLogger.info("Starting 2FA setup...");
3061
- const result = await TotpSetup.cfgTotpSetupCreate({
2835
+ const result = await CfgTotpSetup.cfgTotpSetupCreate({
3062
2836
  body: { device_name: deviceName },
3063
2837
  throwOnError: true
3064
2838
  });
@@ -3102,7 +2876,7 @@ var useTwoFactorSetup = /* @__PURE__ */ __name((options = {}) => {
3102
2876
  setSetupStep("confirming");
3103
2877
  try {
3104
2878
  authLogger.info("Confirming 2FA setup...");
3105
- const result = await TotpSetup.cfgTotpSetupConfirmCreate({
2879
+ const result = await CfgTotpSetup.cfgTotpSetupConfirmCreate({
3106
2880
  body: { device_id: setupData.deviceId, code },
3107
2881
  throwOnError: true
3108
2882
  });
@@ -3165,7 +2939,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
3165
2939
  setError(null);
3166
2940
  try {
3167
2941
  authLogger.info("Fetching 2FA status...");
3168
- const result = await TotpManagement.cfgTotpDevicesRetrieve({ throwOnError: true });
2942
+ const result = await CfgTotp.cfgTotpDevicesRetrieve({ throwOnError: true });
3169
2943
  const response = result.data;
3170
2944
  const mappedDevices = response.devices.map((device) => ({
3171
2945
  id: device.id,
@@ -3194,7 +2968,7 @@ var useTwoFactorStatus = /* @__PURE__ */ __name(() => {
3194
2968
  setError(null);
3195
2969
  try {
3196
2970
  authLogger.info("Disabling 2FA...");
3197
- await TotpManagement.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
2971
+ await CfgTotp.cfgTotpDisableCreate({ body: { code }, throwOnError: true });
3198
2972
  setHas2FAEnabled(false);
3199
2973
  setDevices([]);
3200
2974
  authLogger.info("2FA disabled successfully");
@@ -3773,7 +3547,7 @@ function useTokenRefresh(options = {}) {
3773
3547
  isRefreshingRef.current = true;
3774
3548
  authLogger.info("Refreshing token...");
3775
3549
  try {
3776
- const result = await Auth.cfgAccountsTokenRefreshCreate({
3550
+ const result = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({
3777
3551
  body: { refresh: refreshTokenValue },
3778
3552
  throwOnError: true
3779
3553
  });
@@ -3847,7 +3621,7 @@ var useDeleteAccount = /* @__PURE__ */ __name(() => {
3847
3621
  setError(null);
3848
3622
  try {
3849
3623
  authLogger.info("Deleting account...");
3850
- const result = await UserProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
3624
+ const result = await CfgAccountsProfile.cfgAccountsProfileDeleteCreate({ throwOnError: true });
3851
3625
  const response = result.data;
3852
3626
  if (!response.success) {
3853
3627
  authLogger.error("Failed to delete account:", response.message);
@@ -3877,33 +3651,164 @@ import {
3877
3651
  useCallback as useCallback11,
3878
3652
  useContext,
3879
3653
  useEffect as useEffect8,
3654
+ useMemo as useMemo2,
3880
3655
  useRef as useRef5,
3881
3656
  useState as useState11
3882
3657
  } from "react";
3883
3658
 
3884
- // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts
3659
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts
3660
+ import useSWRMutation from "swr/mutation";
3661
+
3662
+ // src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts
3663
+ import { z } from "zod";
3664
+ var APIKeyRegenerateSchema = z.object({
3665
+ key: z.string(),
3666
+ reissued_at: z.string().datetime({ offset: true })
3667
+ });
3668
+
3669
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts
3885
3670
  import useSWR from "swr";
3886
3671
 
3672
+ // src/_api/generated/_cfg_accounts/schemas/APIKey.ts
3673
+ import { z as z2 } from "zod";
3674
+ var APIKeySchema = z2.object({
3675
+ key: z2.string(),
3676
+ reissued_at: z2.string().datetime({ offset: true }).nullable(),
3677
+ created_at: z2.string().datetime({ offset: true })
3678
+ });
3679
+
3680
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
3681
+ import useSWRMutation2 from "swr/mutation";
3682
+
3683
+ // src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts
3684
+ import { z as z3 } from "zod";
3685
+ var APIKeyTestResultSchema = z3.object({
3686
+ valid: z3.boolean(),
3687
+ user_id: z3.string().nullable()
3688
+ });
3689
+
3690
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts
3691
+ import useSWR2 from "swr";
3692
+
3693
+ // src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts
3694
+ import { z as z6 } from "zod";
3695
+
3696
+ // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
3697
+ import { z as z5 } from "zod";
3698
+
3699
+ // src/_api/generated/_cfg_accounts/schemas/OAuthProviderEnum.ts
3700
+ import { z as z4 } from "zod";
3701
+ var OAuthProviderEnumSchema = z4.enum(["github"]);
3702
+
3703
+ // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
3704
+ var OAuthConnectionSchema = z5.object({
3705
+ id: z5.number().int(),
3706
+ provider: OAuthProviderEnumSchema,
3707
+ provider_display: z5.string(),
3708
+ provider_username: z5.string(),
3709
+ provider_email: z5.email(),
3710
+ provider_avatar_url: z5.string(),
3711
+ connected_at: z5.string().datetime({ offset: true }),
3712
+ last_login_at: z5.string().datetime({ offset: true })
3713
+ });
3714
+
3715
+ // src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts
3716
+ var cfg_accounts_oauth_connections_response_200_AutoRefSchema = z6.array(OAuthConnectionSchema);
3717
+
3887
3718
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts
3888
- import useSWRMutation from "swr/mutation";
3719
+ import useSWRMutation3 from "swr/mutation";
3720
+
3721
+ // src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts
3722
+ import { z as z7 } from "zod";
3723
+ var cfg_accounts_oauth_disconnect_response_200_AutoRefSchema = z7.object({
3724
+ message: z7.string().optional()
3725
+ });
3889
3726
 
3890
3727
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts
3891
- import useSWRMutation2 from "swr/mutation";
3728
+ import useSWRMutation4 from "swr/mutation";
3729
+
3730
+ // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts
3731
+ import { z as z8 } from "zod";
3732
+ var OAuthAuthorizeResponseSchema = z8.object({
3733
+ authorization_url: z8.string(),
3734
+ state: z8.string()
3735
+ });
3892
3736
 
3893
3737
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts
3894
- import useSWRMutation3 from "swr/mutation";
3738
+ import useSWRMutation5 from "swr/mutation";
3739
+
3740
+ // src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts
3741
+ import { z as z9 } from "zod";
3742
+ var OAuthTokenResponseSchema = z9.object({
3743
+ requires_2fa: z9.boolean().default(false).optional(),
3744
+ session_id: z9.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
3745
+ access: z9.string().nullable().optional(),
3746
+ refresh: z9.string().nullable().optional(),
3747
+ user: z9.object({}).passthrough().nullable().optional(),
3748
+ is_new_user: z9.boolean(),
3749
+ is_new_connection: z9.boolean(),
3750
+ should_prompt_2fa: z9.boolean().optional()
3751
+ });
3895
3752
 
3896
3753
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts
3897
- import useSWR2 from "swr";
3754
+ import useSWR3 from "swr";
3755
+
3756
+ // src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts
3757
+ import { z as z10 } from "zod";
3758
+ var OAuthProvidersResponseSchema = z10.object({
3759
+ providers: z10.array(z10.object({}).passthrough())
3760
+ });
3761
+
3762
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
3763
+ import useSWRMutation6 from "swr/mutation";
3764
+
3765
+ // src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
3766
+ import { z as z11 } from "zod";
3767
+ var OTPRequestResponseSchema = z11.object({
3768
+ message: z11.string()
3769
+ });
3898
3770
 
3899
3771
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts
3900
- import useSWRMutation4 from "swr/mutation";
3901
3772
  function useCfgAccountsOtpRequestCreate(config) {
3902
- return useSWRMutation4(
3773
+ return useSWRMutation6(
3903
3774
  ["cfg_accounts_otp_request_create"],
3904
3775
  async (_key, { arg }) => {
3905
- const res = await Cfg.cfgAccountsOtpRequestCreate({ ...arg, throwOnError: true });
3906
- return res.data;
3776
+ const res = await CfgAccounts.cfgAccountsOtpRequestCreate({ ...arg, throwOnError: true });
3777
+ const data = res.data;
3778
+ const parsed = OTPRequestResponseSchema.safeParse(data);
3779
+ if (!parsed.success) {
3780
+ console.warn(
3781
+ "[zod] response did not match schema",
3782
+ {
3783
+ operation: "cfg_accounts_otp_request_create",
3784
+ method: "POST",
3785
+ path: "/cfg/accounts/otp/request/",
3786
+ issues: parsed.error.issues,
3787
+ data
3788
+ }
3789
+ );
3790
+ if (typeof window !== "undefined") {
3791
+ try {
3792
+ window.dispatchEvent(
3793
+ new CustomEvent("zod-validation-error", {
3794
+ detail: {
3795
+ operation: "cfg_accounts_otp_request_create",
3796
+ method: "POST",
3797
+ path: "/cfg/accounts/otp/request/",
3798
+ issues: parsed.error.issues,
3799
+ data,
3800
+ timestamp: /* @__PURE__ */ new Date()
3801
+ },
3802
+ bubbles: true,
3803
+ cancelable: false
3804
+ })
3805
+ );
3806
+ } catch {
3807
+ }
3808
+ }
3809
+ return data;
3810
+ }
3811
+ return parsed.data;
3907
3812
  },
3908
3813
  config
3909
3814
  );
@@ -3911,13 +3816,98 @@ function useCfgAccountsOtpRequestCreate(config) {
3911
3816
  __name(useCfgAccountsOtpRequestCreate, "useCfgAccountsOtpRequestCreate");
3912
3817
 
3913
3818
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
3914
- import useSWRMutation5 from "swr/mutation";
3819
+ import useSWRMutation7 from "swr/mutation";
3820
+
3821
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
3822
+ import { z as z14 } from "zod";
3823
+
3824
+ // src/_api/generated/_cfg_accounts/schemas/User.ts
3825
+ import { z as z13 } from "zod";
3826
+
3827
+ // src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
3828
+ import { z as z12 } from "zod";
3829
+ var CentrifugoTokenSchema = z12.object({
3830
+ token: z12.string(),
3831
+ centrifugo_url: z12.string(),
3832
+ expires_at: z12.string().datetime({ offset: true }),
3833
+ channels: z12.array(z12.string())
3834
+ });
3835
+
3836
+ // src/_api/generated/_cfg_accounts/schemas/User.ts
3837
+ var UserSchema = z13.object({
3838
+ id: z13.number().int(),
3839
+ email: z13.email(),
3840
+ first_name: z13.string().max(50).optional(),
3841
+ last_name: z13.string().max(50).optional(),
3842
+ full_name: z13.string(),
3843
+ initials: z13.string(),
3844
+ display_username: z13.string(),
3845
+ company: z13.string().max(100).optional(),
3846
+ phone: z13.string().max(20).optional(),
3847
+ position: z13.string().max(100).optional(),
3848
+ language: z13.string().max(10).optional(),
3849
+ timezone: z13.string().max(64).optional(),
3850
+ avatar: z13.string().nullable(),
3851
+ is_staff: z13.boolean(),
3852
+ is_superuser: z13.boolean(),
3853
+ date_joined: z13.string().datetime({ offset: true }),
3854
+ last_login: z13.string().datetime({ offset: true }).nullable(),
3855
+ unanswered_messages_count: z13.number().int().default(0),
3856
+ centrifugo: CentrifugoTokenSchema.nullable(),
3857
+ api_key: z13.string().nullable()
3858
+ });
3859
+
3860
+ // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
3861
+ var OTPVerifyResponseSchema = z14.object({
3862
+ requires_2fa: z14.boolean().default(false).optional(),
3863
+ session_id: z14.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
3864
+ refresh: z14.string().nullable().optional(),
3865
+ access: z14.string().nullable().optional(),
3866
+ user: UserSchema.nullable().optional(),
3867
+ should_prompt_2fa: z14.boolean().optional()
3868
+ });
3869
+
3870
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts
3915
3871
  function useCfgAccountsOtpVerifyCreate(config) {
3916
- return useSWRMutation5(
3872
+ return useSWRMutation7(
3917
3873
  ["cfg_accounts_otp_verify_create"],
3918
3874
  async (_key, { arg }) => {
3919
- const res = await Cfg.cfgAccountsOtpVerifyCreate({ ...arg, throwOnError: true });
3920
- return res.data;
3875
+ const res = await CfgAccounts.cfgAccountsOtpVerifyCreate({ ...arg, throwOnError: true });
3876
+ const data = res.data;
3877
+ const parsed = OTPVerifyResponseSchema.safeParse(data);
3878
+ if (!parsed.success) {
3879
+ console.warn(
3880
+ "[zod] response did not match schema",
3881
+ {
3882
+ operation: "cfg_accounts_otp_verify_create",
3883
+ method: "POST",
3884
+ path: "/cfg/accounts/otp/verify/",
3885
+ issues: parsed.error.issues,
3886
+ data
3887
+ }
3888
+ );
3889
+ if (typeof window !== "undefined") {
3890
+ try {
3891
+ window.dispatchEvent(
3892
+ new CustomEvent("zod-validation-error", {
3893
+ detail: {
3894
+ operation: "cfg_accounts_otp_verify_create",
3895
+ method: "POST",
3896
+ path: "/cfg/accounts/otp/verify/",
3897
+ issues: parsed.error.issues,
3898
+ data,
3899
+ timestamp: /* @__PURE__ */ new Date()
3900
+ },
3901
+ bubbles: true,
3902
+ cancelable: false
3903
+ })
3904
+ );
3905
+ } catch {
3906
+ }
3907
+ }
3908
+ return data;
3909
+ }
3910
+ return parsed.data;
3921
3911
  },
3922
3912
  config
3923
3913
  );
@@ -3925,13 +3915,47 @@ function useCfgAccountsOtpVerifyCreate(config) {
3925
3915
  __name(useCfgAccountsOtpVerifyCreate, "useCfgAccountsOtpVerifyCreate");
3926
3916
 
3927
3917
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts
3928
- import useSWRMutation6 from "swr/mutation";
3918
+ import useSWRMutation8 from "swr/mutation";
3929
3919
  function useCfgAccountsProfileAvatarCreate(config) {
3930
- return useSWRMutation6(
3920
+ return useSWRMutation8(
3931
3921
  ["cfg_accounts_profile_avatar_create"],
3932
3922
  async (_key, { arg }) => {
3933
- const res = await Cfg.cfgAccountsProfileAvatarCreate({ ...arg, throwOnError: true });
3934
- return res.data;
3923
+ const res = await CfgAccountsProfile.cfgAccountsProfileAvatarCreate({ ...arg, throwOnError: true });
3924
+ const data = res.data;
3925
+ const parsed = UserSchema.safeParse(data);
3926
+ if (!parsed.success) {
3927
+ console.warn(
3928
+ "[zod] response did not match schema",
3929
+ {
3930
+ operation: "cfg_accounts_profile_avatar_create",
3931
+ method: "POST",
3932
+ path: "/cfg/accounts/profile/avatar/",
3933
+ issues: parsed.error.issues,
3934
+ data
3935
+ }
3936
+ );
3937
+ if (typeof window !== "undefined") {
3938
+ try {
3939
+ window.dispatchEvent(
3940
+ new CustomEvent("zod-validation-error", {
3941
+ detail: {
3942
+ operation: "cfg_accounts_profile_avatar_create",
3943
+ method: "POST",
3944
+ path: "/cfg/accounts/profile/avatar/",
3945
+ issues: parsed.error.issues,
3946
+ data,
3947
+ timestamp: /* @__PURE__ */ new Date()
3948
+ },
3949
+ bubbles: true,
3950
+ cancelable: false
3951
+ })
3952
+ );
3953
+ } catch {
3954
+ }
3955
+ }
3956
+ return data;
3957
+ }
3958
+ return parsed.data;
3935
3959
  },
3936
3960
  config
3937
3961
  );
@@ -3939,19 +3963,60 @@ function useCfgAccountsProfileAvatarCreate(config) {
3939
3963
  __name(useCfgAccountsProfileAvatarCreate, "useCfgAccountsProfileAvatarCreate");
3940
3964
 
3941
3965
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts
3942
- import useSWRMutation7 from "swr/mutation";
3966
+ import useSWRMutation9 from "swr/mutation";
3967
+
3968
+ // src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
3969
+ import { z as z15 } from "zod";
3970
+ var AccountDeleteResponseSchema = z15.object({
3971
+ success: z15.boolean(),
3972
+ message: z15.string()
3973
+ });
3943
3974
 
3944
3975
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts
3945
- import useSWRMutation8 from "swr/mutation";
3976
+ import useSWRMutation10 from "swr/mutation";
3946
3977
 
3947
3978
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts
3948
- import useSWRMutation9 from "swr/mutation";
3979
+ import useSWRMutation11 from "swr/mutation";
3949
3980
  function useCfgAccountsProfilePartialUpdate(config) {
3950
- return useSWRMutation9(
3981
+ return useSWRMutation11(
3951
3982
  ["cfg_accounts_profile_partial_update"],
3952
3983
  async (_key, { arg }) => {
3953
- const res = await Cfg.cfgAccountsProfilePartialUpdate({ ...arg, throwOnError: true });
3954
- return res.data;
3984
+ const res = await CfgAccountsProfile.cfgAccountsProfilePartialUpdate({ ...arg, throwOnError: true });
3985
+ const data = res.data;
3986
+ const parsed = UserSchema.safeParse(data);
3987
+ if (!parsed.success) {
3988
+ console.warn(
3989
+ "[zod] response did not match schema",
3990
+ {
3991
+ operation: "cfg_accounts_profile_partial_update",
3992
+ method: "PUT",
3993
+ path: "/cfg/accounts/profile/partial/",
3994
+ issues: parsed.error.issues,
3995
+ data
3996
+ }
3997
+ );
3998
+ if (typeof window !== "undefined") {
3999
+ try {
4000
+ window.dispatchEvent(
4001
+ new CustomEvent("zod-validation-error", {
4002
+ detail: {
4003
+ operation: "cfg_accounts_profile_partial_update",
4004
+ method: "PUT",
4005
+ path: "/cfg/accounts/profile/partial/",
4006
+ issues: parsed.error.issues,
4007
+ data,
4008
+ timestamp: /* @__PURE__ */ new Date()
4009
+ },
4010
+ bubbles: true,
4011
+ cancelable: false
4012
+ })
4013
+ );
4014
+ } catch {
4015
+ }
4016
+ }
4017
+ return data;
4018
+ }
4019
+ return parsed.data;
3955
4020
  },
3956
4021
  config
3957
4022
  );
@@ -3959,19 +4024,53 @@ function useCfgAccountsProfilePartialUpdate(config) {
3959
4024
  __name(useCfgAccountsProfilePartialUpdate, "useCfgAccountsProfilePartialUpdate");
3960
4025
 
3961
4026
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts
3962
- import useSWR3 from "swr";
4027
+ import useSWR4 from "swr";
3963
4028
 
3964
4029
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts
3965
- import useSWRMutation10 from "swr/mutation";
4030
+ import useSWRMutation12 from "swr/mutation";
3966
4031
 
3967
4032
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts
3968
- import useSWRMutation11 from "swr/mutation";
4033
+ import useSWRMutation13 from "swr/mutation";
3969
4034
  function useCfgAccountsProfileUpdateUpdate(config) {
3970
- return useSWRMutation11(
4035
+ return useSWRMutation13(
3971
4036
  ["cfg_accounts_profile_update_update"],
3972
4037
  async (_key, { arg }) => {
3973
- const res = await Cfg.cfgAccountsProfileUpdateUpdate({ ...arg, throwOnError: true });
3974
- return res.data;
4038
+ const res = await CfgAccountsProfile.cfgAccountsProfileUpdateUpdate({ ...arg, throwOnError: true });
4039
+ const data = res.data;
4040
+ const parsed = UserSchema.safeParse(data);
4041
+ if (!parsed.success) {
4042
+ console.warn(
4043
+ "[zod] response did not match schema",
4044
+ {
4045
+ operation: "cfg_accounts_profile_update_update",
4046
+ method: "PUT",
4047
+ path: "/cfg/accounts/profile/update/",
4048
+ issues: parsed.error.issues,
4049
+ data
4050
+ }
4051
+ );
4052
+ if (typeof window !== "undefined") {
4053
+ try {
4054
+ window.dispatchEvent(
4055
+ new CustomEvent("zod-validation-error", {
4056
+ detail: {
4057
+ operation: "cfg_accounts_profile_update_update",
4058
+ method: "PUT",
4059
+ path: "/cfg/accounts/profile/update/",
4060
+ issues: parsed.error.issues,
4061
+ data,
4062
+ timestamp: /* @__PURE__ */ new Date()
4063
+ },
4064
+ bubbles: true,
4065
+ cancelable: false
4066
+ })
4067
+ );
4068
+ } catch {
4069
+ }
4070
+ }
4071
+ return data;
4072
+ }
4073
+ return parsed.data;
3975
4074
  },
3976
4075
  config
3977
4076
  );
@@ -3979,206 +4078,155 @@ function useCfgAccountsProfileUpdateUpdate(config) {
3979
4078
  __name(useCfgAccountsProfileUpdateUpdate, "useCfgAccountsProfileUpdateUpdate");
3980
4079
 
3981
4080
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
3982
- import useSWRMutation12 from "swr/mutation";
4081
+ import useSWRMutation14 from "swr/mutation";
4082
+
4083
+ // src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
4084
+ import { z as z16 } from "zod";
4085
+ var TokenRefreshSchema = z16.object({
4086
+ access: z16.string(),
4087
+ refresh: z16.string()
4088
+ });
4089
+
4090
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts
3983
4091
  function useCfgAccountsTokenRefreshCreate(config) {
3984
- return useSWRMutation12(
4092
+ return useSWRMutation14(
3985
4093
  ["cfg_accounts_token_refresh_create"],
3986
4094
  async (_key, { arg }) => {
3987
- const res = await Cfg.cfgAccountsTokenRefreshCreate({ ...arg, throwOnError: true });
3988
- return res.data;
4095
+ const res = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({ ...arg, throwOnError: true });
4096
+ const data = res.data;
4097
+ const parsed = TokenRefreshSchema.safeParse(data);
4098
+ if (!parsed.success) {
4099
+ console.warn(
4100
+ "[zod] response did not match schema",
4101
+ {
4102
+ operation: "cfg_accounts_token_refresh_create",
4103
+ method: "POST",
4104
+ path: "/cfg/accounts/token/refresh/",
4105
+ issues: parsed.error.issues,
4106
+ data
4107
+ }
4108
+ );
4109
+ if (typeof window !== "undefined") {
4110
+ try {
4111
+ window.dispatchEvent(
4112
+ new CustomEvent("zod-validation-error", {
4113
+ detail: {
4114
+ operation: "cfg_accounts_token_refresh_create",
4115
+ method: "POST",
4116
+ path: "/cfg/accounts/token/refresh/",
4117
+ issues: parsed.error.issues,
4118
+ data,
4119
+ timestamp: /* @__PURE__ */ new Date()
4120
+ },
4121
+ bubbles: true,
4122
+ cancelable: false
4123
+ })
4124
+ );
4125
+ } catch {
4126
+ }
4127
+ }
4128
+ return data;
4129
+ }
4130
+ return parsed.data;
3989
4131
  },
3990
4132
  config
3991
4133
  );
3992
4134
  }
3993
4135
  __name(useCfgAccountsTokenRefreshCreate, "useCfgAccountsTokenRefreshCreate");
3994
4136
 
3995
- // src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts
3996
- import { z } from "zod";
3997
- var AccountDeleteResponseSchema = z.object({
3998
- message: z.string(),
3999
- success: z.boolean()
4137
+ // src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts
4138
+ import { z as z17 } from "zod";
4139
+ var APIKeyRequestSchema = z17.object({
4140
+ key: z17.string().min(1),
4141
+ reissued_at: z17.string().datetime({ offset: true }).nullable(),
4142
+ created_at: z17.string().datetime({ offset: true })
4000
4143
  });
4001
4144
 
4002
- // src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts
4003
- import { z as z2 } from "zod";
4004
- var CentrifugoTokenSchema = z2.object({
4005
- centrifugo_url: z2.string(),
4006
- channels: z2.array(z2.string()),
4007
- expires_at: z2.string().datetime({ offset: true }),
4008
- token: z2.string()
4145
+ // src/_api/generated/_cfg_accounts/schemas/APIKeyTestRequest.ts
4146
+ import { z as z18 } from "zod";
4147
+ var APIKeyTestRequestSchema = z18.object({
4148
+ key: z18.string().min(1)
4009
4149
  });
4010
4150
 
4011
4151
  // src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts
4012
- import { z as z3 } from "zod";
4013
- var CfgUserUpdateRequestSchema = z3.object({
4014
- company: z3.string().max(100).optional(),
4015
- first_name: z3.string().max(50).optional(),
4016
- language: z3.string().max(10).optional(),
4017
- last_name: z3.string().max(50).optional(),
4018
- phone: z3.string().max(20).optional(),
4019
- position: z3.string().max(100).optional()
4152
+ import { z as z19 } from "zod";
4153
+ var CfgUserUpdateRequestSchema = z19.object({
4154
+ first_name: z19.string().max(50).optional(),
4155
+ last_name: z19.string().max(50).optional(),
4156
+ company: z19.string().max(100).optional(),
4157
+ phone: z19.string().max(20).optional(),
4158
+ position: z19.string().max(100).optional(),
4159
+ language: z19.string().max(10).optional(),
4160
+ timezone: z19.string().max(64).optional()
4020
4161
  });
4021
4162
 
4022
4163
  // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
4023
- import { z as z4 } from "zod";
4024
- var OAuthAuthorizeRequestRequestSchema = z4.object({
4025
- redirect_uri: z4.string().optional(),
4026
- source_url: z4.string().optional()
4027
- });
4028
-
4029
- // src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts
4030
- import { z as z5 } from "zod";
4031
- var OAuthAuthorizeResponseSchema = z5.object({
4032
- authorization_url: z5.string(),
4033
- state: z5.string()
4164
+ import { z as z20 } from "zod";
4165
+ var OAuthAuthorizeRequestRequestSchema = z20.object({
4166
+ redirect_uri: z20.string().optional(),
4167
+ source_url: z20.string().optional()
4034
4168
  });
4035
4169
 
4036
4170
  // src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
4037
- import { z as z6 } from "zod";
4038
- var OAuthCallbackRequestRequestSchema = z6.object({
4039
- code: z6.string().min(10).max(500),
4040
- redirect_uri: z6.string().optional(),
4041
- state: z6.string().min(20).max(100)
4042
- });
4043
-
4044
- // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
4045
- import { z as z8 } from "zod";
4046
-
4047
- // src/_api/generated/_cfg_accounts/schemas/ProviderEnum.ts
4048
- import { z as z7 } from "zod";
4049
- var ProviderEnumSchema = z7.enum(["github"]);
4050
-
4051
- // src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts
4052
- var OAuthConnectionSchema = z8.object({
4053
- connected_at: z8.string().datetime({ offset: true }),
4054
- id: z8.number().int(),
4055
- last_login_at: z8.string().datetime({ offset: true }),
4056
- provider: ProviderEnumSchema,
4057
- provider_avatar_url: z8.string(),
4058
- provider_display: z8.string(),
4059
- provider_email: z8.email(),
4060
- provider_username: z8.string()
4171
+ import { z as z21 } from "zod";
4172
+ var OAuthCallbackRequestRequestSchema = z21.object({
4173
+ code: z21.string().min(10).max(500),
4174
+ state: z21.string().min(20).max(100),
4175
+ redirect_uri: z21.string().optional()
4061
4176
  });
4062
4177
 
4063
4178
  // src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
4064
- import { z as z9 } from "zod";
4065
- var OAuthDisconnectRequestRequestSchema = z9.object({
4066
- provider: ProviderEnumSchema
4179
+ import { z as z22 } from "zod";
4180
+ var OAuthDisconnectRequestRequestSchema = z22.object({
4181
+ provider: OAuthProviderEnumSchema
4067
4182
  });
4068
4183
 
4069
4184
  // src/_api/generated/_cfg_accounts/schemas/OAuthError.ts
4070
- import { z as z10 } from "zod";
4071
- var OAuthErrorSchema = z10.object({
4072
- error: z10.string(),
4073
- error_description: z10.string().optional()
4074
- });
4075
-
4076
- // src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts
4077
- import { z as z11 } from "zod";
4078
- var OAuthProvidersResponseSchema = z11.object({
4079
- providers: z11.array(z11.object({}).passthrough())
4080
- });
4081
-
4082
- // src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts
4083
- import { z as z12 } from "zod";
4084
- var OAuthTokenResponseSchema = z12.object({
4085
- access: z12.string().nullable().optional(),
4086
- is_new_connection: z12.boolean(),
4087
- is_new_user: z12.boolean(),
4088
- refresh: z12.string().nullable().optional(),
4089
- requires_2fa: z12.boolean().default(false).optional(),
4090
- session_id: z12.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
4091
- should_prompt_2fa: z12.boolean().optional(),
4092
- user: z12.object({}).passthrough().nullable().optional()
4185
+ import { z as z23 } from "zod";
4186
+ var OAuthErrorSchema = z23.object({
4187
+ error: z23.string(),
4188
+ error_description: z23.string().optional()
4093
4189
  });
4094
4190
 
4095
4191
  // src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts
4096
- import { z as z13 } from "zod";
4097
- var OTPErrorResponseSchema = z13.object({
4098
- error: z13.string(),
4099
- error_code: z13.string().nullable().optional(),
4100
- retry_after: z13.number().int().nullable().optional()
4192
+ import { z as z24 } from "zod";
4193
+ var OTPErrorResponseSchema = z24.object({
4194
+ error: z24.string(),
4195
+ error_code: z24.string().nullable().optional(),
4196
+ retry_after: z24.number().int().nullable().optional()
4101
4197
  });
4102
4198
 
4103
4199
  // src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts
4104
- import { z as z14 } from "zod";
4105
- var OTPRequestRequestSchema = z14.object({
4106
- identifier: z14.string().min(1),
4107
- source_url: z14.string().optional()
4108
- });
4109
-
4110
- // src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts
4111
- import { z as z15 } from "zod";
4112
- var OTPRequestResponseSchema = z15.object({
4113
- message: z15.string()
4200
+ import { z as z25 } from "zod";
4201
+ var OTPRequestRequestSchema = z25.object({
4202
+ identifier: z25.string().min(1),
4203
+ source_url: z25.string().optional()
4114
4204
  });
4115
4205
 
4116
4206
  // src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts
4117
- import { z as z16 } from "zod";
4118
- var OTPVerifyRequestSchema = z16.object({
4119
- identifier: z16.string().min(1),
4120
- otp: z16.string().min(6).max(6),
4121
- source_url: z16.string().optional()
4122
- });
4123
-
4124
- // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
4125
- import { z as z18 } from "zod";
4126
-
4127
- // src/_api/generated/_cfg_accounts/schemas/User.ts
4128
- import { z as z17 } from "zod";
4129
- var UserSchema = z17.object({
4130
- avatar: z17.string().nullable(),
4131
- centrifugo: CentrifugoTokenSchema.nullable(),
4132
- company: z17.string().max(100).optional(),
4133
- date_joined: z17.string().datetime({ offset: true }),
4134
- display_username: z17.string(),
4135
- email: z17.email(),
4136
- first_name: z17.string().max(50).optional(),
4137
- full_name: z17.string(),
4138
- id: z17.number().int(),
4139
- initials: z17.string(),
4140
- is_staff: z17.boolean(),
4141
- is_superuser: z17.boolean(),
4142
- language: z17.string().max(10).optional(),
4143
- last_login: z17.string().datetime({ offset: true }).nullable(),
4144
- last_name: z17.string().max(50).optional(),
4145
- phone: z17.string().max(20).optional(),
4146
- position: z17.string().max(100).optional(),
4147
- unanswered_messages_count: z17.number().int().default(0)
4148
- });
4149
-
4150
- // src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts
4151
- var OTPVerifyResponseSchema = z18.object({
4152
- access: z18.string().nullable().optional(),
4153
- refresh: z18.string().nullable().optional(),
4154
- requires_2fa: z18.boolean().default(false).optional(),
4155
- session_id: z18.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
4156
- should_prompt_2fa: z18.boolean().optional(),
4157
- user: UserSchema.nullable().optional()
4207
+ import { z as z26 } from "zod";
4208
+ var OTPVerifyRequestSchema = z26.object({
4209
+ identifier: z26.string().min(1),
4210
+ otp: z26.string().min(4).max(4),
4211
+ source_url: z26.string().optional()
4158
4212
  });
4159
4213
 
4160
4214
  // src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
4161
- import { z as z19 } from "zod";
4162
- var PatchedCfgUserUpdateRequestSchema = z19.object({
4163
- company: z19.string().max(100).optional(),
4164
- first_name: z19.string().max(50).optional(),
4165
- language: z19.string().max(10).optional(),
4166
- last_name: z19.string().max(50).optional(),
4167
- phone: z19.string().max(20).optional(),
4168
- position: z19.string().max(100).optional()
4169
- });
4170
-
4171
- // src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts
4172
- import { z as z20 } from "zod";
4173
- var TokenRefreshSchema = z20.object({
4174
- access: z20.string(),
4175
- refresh: z20.string()
4215
+ import { z as z27 } from "zod";
4216
+ var PatchedCfgUserUpdateRequestSchema = z27.object({
4217
+ first_name: z27.string().max(50).optional(),
4218
+ last_name: z27.string().max(50).optional(),
4219
+ company: z27.string().max(100).optional(),
4220
+ phone: z27.string().max(20).optional(),
4221
+ position: z27.string().max(100).optional(),
4222
+ language: z27.string().max(10).optional(),
4223
+ timezone: z27.string().max(64).optional()
4176
4224
  });
4177
4225
 
4178
4226
  // src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts
4179
- import { z as z21 } from "zod";
4180
- var TokenRefreshRequestSchema = z21.object({
4181
- refresh: z21.string().min(1)
4227
+ import { z as z28 } from "zod";
4228
+ var TokenRefreshRequestSchema = z28.object({
4229
+ refresh: z28.string().min(1)
4182
4230
  });
4183
4231
 
4184
4232
  // src/auth/context/AccountsContext.tsx
@@ -4216,7 +4264,7 @@ function AccountsProvider({ children }) {
4216
4264
  setProfileError(null);
4217
4265
  try {
4218
4266
  authLogger.debug(`Fetching profile from API (caller: ${callerId}, force: ${force})`);
4219
- const res = await UserProfile.cfgAccountsProfileRetrieve({ throwOnError: true });
4267
+ const res = await CfgAccountsProfile.cfgAccountsProfileRetrieve({ throwOnError: true });
4220
4268
  const result = res.data;
4221
4269
  setProfile(result);
4222
4270
  profileRef.current = result;
@@ -4282,7 +4330,7 @@ function AccountsProvider({ children }) {
4282
4330
  setProfileError(null);
4283
4331
  clearProfileCache();
4284
4332
  }, []);
4285
- const value = {
4333
+ const value = useMemo2(() => ({
4286
4334
  profile,
4287
4335
  isLoadingProfile,
4288
4336
  profileError,
@@ -4294,7 +4342,19 @@ function AccountsProvider({ children }) {
4294
4342
  verifyOTP,
4295
4343
  refreshToken,
4296
4344
  logout
4297
- };
4345
+ }), [
4346
+ profile,
4347
+ isLoadingProfile,
4348
+ profileError,
4349
+ updateProfile,
4350
+ partialUpdateProfile,
4351
+ uploadAvatar,
4352
+ refreshProfile,
4353
+ requestOTP,
4354
+ verifyOTP,
4355
+ refreshToken,
4356
+ logout
4357
+ ]);
4298
4358
  return /* @__PURE__ */ jsx(AccountsContext.Provider, { value, children });
4299
4359
  }
4300
4360
  __name(AccountsProvider, "AccountsProvider");
@@ -4387,7 +4447,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4387
4447
  router.hardReplace(authCallbackUrl);
4388
4448
  }
4389
4449
  }, [clearAuthState, router]);
4390
- const swrConfig = useMemo2(() => ({ onError: swrOnError }), [swrOnError]);
4450
+ const swrConfig = useMemo3(() => ({ onError: swrOnError }), [swrOnError]);
4391
4451
  const loadCurrentProfile = useCallback12(async (callerId) => {
4392
4452
  const finalCallerId = callerId || "AuthContext.loadCurrentProfile";
4393
4453
  if (isLoadingProfileRef.current) {
@@ -4671,7 +4731,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4671
4731
  const authCallbackUrl = config?.routes?.defaultAuthCallback || defaultRoutes.defaultAuthCallback;
4672
4732
  router.hardReplace(authCallbackUrl);
4673
4733
  }, [accounts, config?.routes?.defaultAuthCallback, router]);
4674
- const isAdminUser = useMemo2(() => {
4734
+ const isAdminUser = useMemo3(() => {
4675
4735
  return Boolean(user?.is_staff || user?.is_superuser);
4676
4736
  }, [user]);
4677
4737
  const updateProfile = useCallback12(
@@ -4688,7 +4748,7 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4688
4748
  },
4689
4749
  [accounts]
4690
4750
  );
4691
- const value = useMemo2(
4751
+ const value = useMemo3(
4692
4752
  () => ({
4693
4753
  user,
4694
4754
  isLoading,
@@ -4735,9 +4795,11 @@ var AuthProviderInternal = /* @__PURE__ */ __name(({ children, config }) => {
4735
4795
  );
4736
4796
  return /* @__PURE__ */ jsx2(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx2(SWRConfig, { value: swrConfig, children }) });
4737
4797
  }, "AuthProviderInternal");
4738
- var AuthProvider = /* @__PURE__ */ __name(({ children, config }) => {
4798
+ function AuthProviderRaw({ children, config }) {
4739
4799
  return /* @__PURE__ */ jsx2(AccountsProvider, { children: /* @__PURE__ */ jsx2(AuthProviderInternal, { config, children }) });
4740
- }, "AuthProvider");
4800
+ }
4801
+ __name(AuthProviderRaw, "AuthProviderRaw");
4802
+ var AuthProvider = memo2(AuthProviderRaw);
4741
4803
  var defaultAuthState = {
4742
4804
  user: null,
4743
4805
  isLoading: false,