@djangocfg/api 2.1.356 → 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/index.cjs CHANGED
@@ -22,28 +22,26 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  APIError: () => APIError,
24
24
  APILogger: () => APILogger,
25
- Accounts: () => Accounts,
26
- Auth: () => Auth,
27
- BackupCodes: () => BackupCodes,
28
- Centrifugo: () => Centrifugo,
29
- CentrifugoAuth: () => CentrifugoAuth,
30
- Cfg: () => Cfg,
25
+ CfgAccounts: () => CfgAccounts,
31
26
  CfgAccountsAPI: () => API,
32
27
  CfgAccountsApi: () => CfgAccountsApi,
28
+ CfgAccountsApiKey: () => CfgAccountsApiKey,
29
+ CfgAccountsAuth: () => CfgAccountsAuth,
30
+ CfgAccountsOauth: () => CfgAccountsOauth,
31
+ CfgAccountsProfile: () => CfgAccountsProfile,
32
+ CfgCentrifugo: () => CfgCentrifugo,
33
33
  CfgCentrifugoAPI: () => API2,
34
34
  CfgCentrifugoApi: () => CfgCentrifugoApi,
35
+ CfgTotp: () => CfgTotp,
35
36
  CfgTotpAPI: () => API3,
36
37
  CfgTotpApi: () => CfgTotpApi,
38
+ CfgTotpBackupCodes: () => CfgTotpBackupCodes,
39
+ CfgTotpSetup: () => CfgTotpSetup,
40
+ CfgTotpVerify: () => CfgTotpVerify,
37
41
  CookieStorageAdapter: () => CookieStorageAdapter,
38
42
  LocalStorageAdapter: () => LocalStorageAdapter,
39
43
  MemoryStorageAdapter: () => MemoryStorageAdapter,
40
44
  NetworkError: () => NetworkError,
41
- OAuth: () => OAuth,
42
- Totp: () => Totp,
43
- TotpManagement: () => TotpManagement,
44
- TotpSetup: () => TotpSetup,
45
- TotpVerification: () => TotpVerification,
46
- UserProfile: () => UserProfile,
47
45
  api: () => CfgAccountsApi,
48
46
  auth: () => auth,
49
47
  defaultLogger: () => defaultLogger,
@@ -435,398 +433,6 @@ var APILogger = class {
435
433
  };
436
434
  var defaultLogger = new APILogger();
437
435
 
438
- // src/_api/generated/_cfg_accounts/api.ts
439
- var API = class {
440
- static {
441
- __name(this, "API");
442
- }
443
- logger;
444
- constructor(_baseUrl, opts = {}) {
445
- this.logger = new APILogger(opts.logger);
446
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
447
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
448
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
449
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
450
- }
451
- // ── Base URL ────────────────────────────────────────────────────────────
452
- getBaseUrl() {
453
- return auth.getBaseUrl();
454
- }
455
- setBaseUrl(url) {
456
- auth.setBaseUrl(url);
457
- }
458
- // ── Tokens ──────────────────────────────────────────────────────────────
459
- getToken() {
460
- return auth.getToken();
461
- }
462
- setToken(token) {
463
- auth.setToken(token);
464
- }
465
- getRefreshToken() {
466
- return auth.getRefreshToken();
467
- }
468
- setRefreshToken(token) {
469
- auth.setRefreshToken(token);
470
- }
471
- clearToken() {
472
- auth.clearTokens();
473
- }
474
- isAuthenticated() {
475
- return auth.isAuthenticated();
476
- }
477
- // ── Locale / API key ────────────────────────────────────────────────────
478
- getLocale() {
479
- return auth.getLocale();
480
- }
481
- setLocale(locale) {
482
- auth.setLocale(locale);
483
- }
484
- getApiKey() {
485
- return auth.getApiKey();
486
- }
487
- setApiKey(key) {
488
- auth.setApiKey(key);
489
- }
490
- // ── 401 handling ────────────────────────────────────────────────────────
491
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
492
- onUnauthorized(cb) {
493
- auth.onUnauthorized(cb);
494
- }
495
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
496
- setRefreshHandler(fn) {
497
- auth.setRefreshHandler(fn);
498
- }
499
- };
500
-
501
- // src/_api/generated/helpers/storage.ts
502
- var LocalStorageAdapter = class {
503
- static {
504
- __name(this, "LocalStorageAdapter");
505
- }
506
- getItem(key) {
507
- if (typeof window === "undefined") return null;
508
- try {
509
- return window.localStorage.getItem(key);
510
- } catch {
511
- return null;
512
- }
513
- }
514
- setItem(key, value) {
515
- if (typeof window === "undefined") return;
516
- try {
517
- window.localStorage.setItem(key, value);
518
- } catch {
519
- }
520
- }
521
- removeItem(key) {
522
- if (typeof window === "undefined") return;
523
- try {
524
- window.localStorage.removeItem(key);
525
- } catch {
526
- }
527
- }
528
- clear() {
529
- if (typeof window === "undefined") return;
530
- try {
531
- window.localStorage.clear();
532
- } catch {
533
- }
534
- }
535
- };
536
- var MemoryStorageAdapter = class {
537
- static {
538
- __name(this, "MemoryStorageAdapter");
539
- }
540
- store = /* @__PURE__ */ new Map();
541
- getItem(key) {
542
- return this.store.get(key) ?? null;
543
- }
544
- setItem(key, value) {
545
- this.store.set(key, value);
546
- }
547
- removeItem(key) {
548
- this.store.delete(key);
549
- }
550
- clear() {
551
- this.store.clear();
552
- }
553
- };
554
- var CookieStorageAdapter = class {
555
- constructor(opts = {}) {
556
- this.opts = opts;
557
- }
558
- static {
559
- __name(this, "CookieStorageAdapter");
560
- }
561
- getItem(key) {
562
- if (typeof document === "undefined") return null;
563
- const prefix = `${encodeURIComponent(key)}=`;
564
- for (const part of document.cookie.split("; ")) {
565
- if (part.startsWith(prefix)) {
566
- return decodeURIComponent(part.slice(prefix.length));
567
- }
568
- }
569
- return null;
570
- }
571
- setItem(key, value) {
572
- if (typeof document === "undefined") return;
573
- const parts = [
574
- `${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
575
- `Path=${this.opts.path ?? "/"}`
576
- ];
577
- if (this.opts.domain) parts.push(`Domain=${this.opts.domain}`);
578
- if (this.opts.secure) parts.push("Secure");
579
- if (this.opts.sameSite) parts.push(`SameSite=${this.opts.sameSite}`);
580
- if (this.opts.maxAgeSeconds != null) {
581
- parts.push(`Max-Age=${this.opts.maxAgeSeconds}`);
582
- }
583
- document.cookie = parts.join("; ");
584
- }
585
- removeItem(key) {
586
- if (typeof document === "undefined") return;
587
- document.cookie = `${encodeURIComponent(key)}=; Max-Age=0; Path=${this.opts.path ?? "/"}`;
588
- }
589
- };
590
-
591
- // src/_api/generated/helpers/errors.ts
592
- var APIError = class extends Error {
593
- constructor(statusCode, statusText, response, url, message) {
594
- super(message || `HTTP ${statusCode}: ${statusText}`);
595
- this.statusCode = statusCode;
596
- this.statusText = statusText;
597
- this.response = response;
598
- this.url = url;
599
- this.name = "APIError";
600
- }
601
- static {
602
- __name(this, "APIError");
603
- }
604
- get details() {
605
- if (typeof this.response === "object" && this.response !== null) {
606
- return this.response;
607
- }
608
- return null;
609
- }
610
- get fieldErrors() {
611
- const details = this.details;
612
- if (!details) return null;
613
- const fieldErrors = {};
614
- for (const [key, value] of Object.entries(details)) {
615
- if (Array.isArray(value)) fieldErrors[key] = value;
616
- }
617
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
618
- }
619
- get errorMessage() {
620
- const details = this.details;
621
- if (!details) return this.message;
622
- if (details.detail) {
623
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
624
- }
625
- if (details.error) return String(details.error);
626
- if (details.message) return String(details.message);
627
- const fieldErrors = this.fieldErrors;
628
- if (fieldErrors) {
629
- const firstField = Object.keys(fieldErrors)[0];
630
- if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
631
- }
632
- return this.message;
633
- }
634
- get isValidationError() {
635
- return this.statusCode === 400;
636
- }
637
- get isAuthError() {
638
- return this.statusCode === 401;
639
- }
640
- get isPermissionError() {
641
- return this.statusCode === 403;
642
- }
643
- get isNotFoundError() {
644
- return this.statusCode === 404;
645
- }
646
- get isServerError() {
647
- return this.statusCode >= 500 && this.statusCode < 600;
648
- }
649
- };
650
- var NetworkError = class extends Error {
651
- constructor(message, url, originalError) {
652
- super(message);
653
- this.url = url;
654
- this.originalError = originalError;
655
- this.name = "NetworkError";
656
- }
657
- static {
658
- __name(this, "NetworkError");
659
- }
660
- };
661
-
662
- // src/_api/generated/helpers/validation-events.ts
663
- function dispatchValidationError(detail) {
664
- if (typeof window === "undefined") return;
665
- try {
666
- const event = new CustomEvent("zod-validation-error", {
667
- detail,
668
- bubbles: true,
669
- cancelable: false
670
- });
671
- window.dispatchEvent(event);
672
- } catch (error) {
673
- console.warn("Failed to dispatch validation error event:", error);
674
- }
675
- }
676
- __name(dispatchValidationError, "dispatchValidationError");
677
- function onValidationError(callback) {
678
- if (typeof window === "undefined") return () => {
679
- };
680
- const handler = /* @__PURE__ */ __name((event) => {
681
- if (event instanceof CustomEvent) callback(event.detail);
682
- }, "handler");
683
- window.addEventListener("zod-validation-error", handler);
684
- return () => window.removeEventListener("zod-validation-error", handler);
685
- }
686
- __name(onValidationError, "onValidationError");
687
- function formatZodError(error) {
688
- const issues = error.issues.map((issue, index) => {
689
- const path = issue.path.join(".") || "root";
690
- const parts = [`${index + 1}. ${path}: ${issue.message}`];
691
- if ("expected" in issue && issue.expected) parts.push(` Expected: ${issue.expected}`);
692
- if ("received" in issue && issue.received) parts.push(` Received: ${issue.received}`);
693
- return parts.join("\n");
694
- });
695
- return issues.join("\n");
696
- }
697
- __name(formatZodError, "formatZodError");
698
-
699
- // src/_api/generated/_cfg_centrifugo/api.ts
700
- var API2 = class {
701
- static {
702
- __name(this, "API");
703
- }
704
- logger;
705
- constructor(_baseUrl, opts = {}) {
706
- this.logger = new APILogger(opts.logger);
707
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
708
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
709
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
710
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
711
- }
712
- // ── Base URL ────────────────────────────────────────────────────────────
713
- getBaseUrl() {
714
- return auth.getBaseUrl();
715
- }
716
- setBaseUrl(url) {
717
- auth.setBaseUrl(url);
718
- }
719
- // ── Tokens ──────────────────────────────────────────────────────────────
720
- getToken() {
721
- return auth.getToken();
722
- }
723
- setToken(token) {
724
- auth.setToken(token);
725
- }
726
- getRefreshToken() {
727
- return auth.getRefreshToken();
728
- }
729
- setRefreshToken(token) {
730
- auth.setRefreshToken(token);
731
- }
732
- clearToken() {
733
- auth.clearTokens();
734
- }
735
- isAuthenticated() {
736
- return auth.isAuthenticated();
737
- }
738
- // ── Locale / API key ────────────────────────────────────────────────────
739
- getLocale() {
740
- return auth.getLocale();
741
- }
742
- setLocale(locale) {
743
- auth.setLocale(locale);
744
- }
745
- getApiKey() {
746
- return auth.getApiKey();
747
- }
748
- setApiKey(key) {
749
- auth.setApiKey(key);
750
- }
751
- // ── 401 handling ────────────────────────────────────────────────────────
752
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
753
- onUnauthorized(cb) {
754
- auth.onUnauthorized(cb);
755
- }
756
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
757
- setRefreshHandler(fn) {
758
- auth.setRefreshHandler(fn);
759
- }
760
- };
761
-
762
- // src/_api/generated/_cfg_totp/api.ts
763
- var API3 = class {
764
- static {
765
- __name(this, "API");
766
- }
767
- logger;
768
- constructor(_baseUrl, opts = {}) {
769
- this.logger = new APILogger(opts.logger);
770
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
771
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
772
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
773
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
774
- }
775
- // ── Base URL ────────────────────────────────────────────────────────────
776
- getBaseUrl() {
777
- return auth.getBaseUrl();
778
- }
779
- setBaseUrl(url) {
780
- auth.setBaseUrl(url);
781
- }
782
- // ── Tokens ──────────────────────────────────────────────────────────────
783
- getToken() {
784
- return auth.getToken();
785
- }
786
- setToken(token) {
787
- auth.setToken(token);
788
- }
789
- getRefreshToken() {
790
- return auth.getRefreshToken();
791
- }
792
- setRefreshToken(token) {
793
- auth.setRefreshToken(token);
794
- }
795
- clearToken() {
796
- auth.clearTokens();
797
- }
798
- isAuthenticated() {
799
- return auth.isAuthenticated();
800
- }
801
- // ── Locale / API key ────────────────────────────────────────────────────
802
- getLocale() {
803
- return auth.getLocale();
804
- }
805
- setLocale(locale) {
806
- auth.setLocale(locale);
807
- }
808
- getApiKey() {
809
- return auth.getApiKey();
810
- }
811
- setApiKey(key) {
812
- auth.setApiKey(key);
813
- }
814
- // ── 401 handling ────────────────────────────────────────────────────────
815
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
816
- onUnauthorized(cb) {
817
- auth.onUnauthorized(cb);
818
- }
819
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
820
- setRefreshHandler(fn) {
821
- auth.setRefreshHandler(fn);
822
- }
823
- };
824
-
825
- // src/_api/generated/index.ts
826
- var CfgAccountsApi = new API();
827
- var CfgCentrifugoApi = new API2();
828
- var CfgTotpApi = new API3();
829
-
830
436
  // src/_api/generated/core/bodySerializer.gen.ts
831
437
  var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
832
438
  if (typeof value === "string" || value instanceof Blob) {
@@ -1612,438 +1218,100 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
1612
1218
  request2 = await fn(request2, opts);
1613
1219
  }
1614
1220
  }
1615
- return request2;
1616
- }, "onRequest"),
1617
- serializedBody: getValidRequestBody(opts),
1618
- url
1619
- });
1620
- }, "makeSseFn");
1621
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
1622
- return {
1623
- buildUrl: _buildUrl,
1624
- connect: makeMethodFn("CONNECT"),
1625
- delete: makeMethodFn("DELETE"),
1626
- get: makeMethodFn("GET"),
1627
- getConfig,
1628
- head: makeMethodFn("HEAD"),
1629
- interceptors,
1630
- options: makeMethodFn("OPTIONS"),
1631
- patch: makeMethodFn("PATCH"),
1632
- post: makeMethodFn("POST"),
1633
- put: makeMethodFn("PUT"),
1634
- request,
1635
- setConfig,
1636
- sse: {
1637
- connect: makeSseFn("CONNECT"),
1638
- delete: makeSseFn("DELETE"),
1639
- get: makeSseFn("GET"),
1640
- head: makeSseFn("HEAD"),
1641
- options: makeSseFn("OPTIONS"),
1642
- patch: makeSseFn("PATCH"),
1643
- post: makeSseFn("POST"),
1644
- put: makeSseFn("PUT"),
1645
- trace: makeSseFn("TRACE")
1646
- },
1647
- trace: makeMethodFn("TRACE")
1648
- };
1649
- }, "createClient");
1650
-
1651
- // src/_api/generated/client.gen.ts
1652
- var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1653
- installAuthOnClient(client);
1654
-
1655
- // src/_api/generated/sdk.gen.ts
1656
- var Cfg = class {
1657
- static {
1658
- __name(this, "Cfg");
1659
- }
1660
- /**
1661
- * List OAuth connections
1662
- *
1663
- * Get all OAuth connections for the current user.
1664
- */
1665
- static cfgAccountsOauthConnectionsList(options) {
1666
- return (options?.client ?? client).get({
1667
- security: [{ scheme: "bearer", type: "http" }],
1668
- url: "/cfg/accounts/oauth/connections/",
1669
- ...options
1670
- });
1671
- }
1672
- /**
1673
- * Disconnect OAuth provider
1674
- *
1675
- * Remove OAuth connection for the specified provider.
1676
- */
1677
- static cfgAccountsOauthDisconnectCreate(options) {
1678
- return (options.client ?? client).post({
1679
- security: [{ scheme: "bearer", type: "http" }],
1680
- url: "/cfg/accounts/oauth/disconnect/",
1681
- ...options,
1682
- headers: {
1683
- "Content-Type": "application/json",
1684
- ...options.headers
1685
- }
1686
- });
1687
- }
1688
- /**
1689
- * Start GitHub OAuth
1690
- *
1691
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1692
- */
1693
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1694
- return (options?.client ?? client).post({
1695
- url: "/cfg/accounts/oauth/github/authorize/",
1696
- ...options,
1697
- headers: {
1698
- "Content-Type": "application/json",
1699
- ...options?.headers
1700
- }
1701
- });
1702
- }
1703
- /**
1704
- * Complete GitHub OAuth
1705
- *
1706
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1707
- */
1708
- static cfgAccountsOauthGithubCallbackCreate(options) {
1709
- return (options.client ?? client).post({
1710
- url: "/cfg/accounts/oauth/github/callback/",
1711
- ...options,
1712
- headers: {
1713
- "Content-Type": "application/json",
1714
- ...options.headers
1715
- }
1716
- });
1717
- }
1718
- /**
1719
- * List OAuth providers
1720
- *
1721
- * Get list of available OAuth providers for authentication.
1722
- */
1723
- static cfgAccountsOauthProvidersRetrieve(options) {
1724
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1725
- }
1726
- /**
1727
- * Request OTP code to email.
1728
- */
1729
- static cfgAccountsOtpRequestCreate(options) {
1730
- return (options.client ?? client).post({
1731
- security: [{ scheme: "bearer", type: "http" }],
1732
- url: "/cfg/accounts/otp/request/",
1733
- ...options,
1734
- headers: {
1735
- "Content-Type": "application/json",
1736
- ...options.headers
1737
- }
1738
- });
1739
- }
1740
- /**
1741
- * Verify OTP code and return JWT tokens or 2FA session.
1742
- *
1743
- * If user has 2FA enabled:
1744
- * - Returns requires_2fa=True with session_id
1745
- * - Client must complete 2FA verification at /cfg/totp/verify/
1746
- *
1747
- * If user has no 2FA:
1748
- * - Returns JWT tokens and user data directly
1749
- */
1750
- static cfgAccountsOtpVerifyCreate(options) {
1751
- return (options.client ?? client).post({
1752
- security: [{ scheme: "bearer", type: "http" }],
1753
- url: "/cfg/accounts/otp/verify/",
1754
- ...options,
1755
- headers: {
1756
- "Content-Type": "application/json",
1757
- ...options.headers
1758
- }
1759
- });
1760
- }
1761
- /**
1762
- * Get current user profile
1763
- *
1764
- * Retrieve the current authenticated user's profile information.
1765
- */
1766
- static cfgAccountsProfileRetrieve(options) {
1767
- return (options?.client ?? client).get({
1768
- security: [{ scheme: "bearer", type: "http" }, {
1769
- in: "cookie",
1770
- name: "sessionid",
1771
- type: "apiKey"
1772
- }],
1773
- url: "/cfg/accounts/profile/",
1774
- ...options
1775
- });
1776
- }
1777
- /**
1778
- * Upload user avatar
1779
- *
1780
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1781
- */
1782
- static cfgAccountsProfileAvatarCreate(options) {
1783
- return (options?.client ?? client).post({
1784
- ...formDataBodySerializer,
1785
- security: [{ scheme: "bearer", type: "http" }],
1786
- url: "/cfg/accounts/profile/avatar/",
1787
- ...options,
1788
- headers: {
1789
- "Content-Type": null,
1790
- ...options?.headers
1791
- }
1792
- });
1793
- }
1794
- /**
1795
- * Delete user account
1796
- *
1797
- *
1798
- * Permanently delete the current user's account.
1799
- *
1800
- * This operation:
1801
- * - Deactivates the account (user cannot log in)
1802
- * - Anonymizes personal data (GDPR compliance)
1803
- * - Frees up the email address for re-registration
1804
- * - Preserves audit trail
1805
- *
1806
- * The account can be restored by an administrator if needed.
1807
- *
1808
- */
1809
- static cfgAccountsProfileDeleteCreate(options) {
1810
- return (options?.client ?? client).post({
1811
- security: [{ scheme: "bearer", type: "http" }, {
1812
- in: "cookie",
1813
- name: "sessionid",
1814
- type: "apiKey"
1815
- }],
1816
- url: "/cfg/accounts/profile/delete/",
1817
- ...options
1818
- });
1819
- }
1820
- /**
1821
- * Partial update user profile
1822
- *
1823
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1824
- */
1825
- static cfgAccountsProfilePartialPartialUpdate(options) {
1826
- return (options?.client ?? client).patch({
1827
- security: [{ scheme: "bearer", type: "http" }, {
1828
- in: "cookie",
1829
- name: "sessionid",
1830
- type: "apiKey"
1831
- }],
1832
- url: "/cfg/accounts/profile/partial/",
1833
- ...options,
1834
- headers: {
1835
- "Content-Type": "application/json",
1836
- ...options?.headers
1837
- }
1221
+ return request2;
1222
+ }, "onRequest"),
1223
+ serializedBody: getValidRequestBody(opts),
1224
+ url
1838
1225
  });
1226
+ }, "makeSseFn");
1227
+ const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
1228
+ return {
1229
+ buildUrl: _buildUrl,
1230
+ connect: makeMethodFn("CONNECT"),
1231
+ delete: makeMethodFn("DELETE"),
1232
+ get: makeMethodFn("GET"),
1233
+ getConfig,
1234
+ head: makeMethodFn("HEAD"),
1235
+ interceptors,
1236
+ options: makeMethodFn("OPTIONS"),
1237
+ patch: makeMethodFn("PATCH"),
1238
+ post: makeMethodFn("POST"),
1239
+ put: makeMethodFn("PUT"),
1240
+ request,
1241
+ setConfig,
1242
+ sse: {
1243
+ connect: makeSseFn("CONNECT"),
1244
+ delete: makeSseFn("DELETE"),
1245
+ get: makeSseFn("GET"),
1246
+ head: makeSseFn("HEAD"),
1247
+ options: makeSseFn("OPTIONS"),
1248
+ patch: makeSseFn("PATCH"),
1249
+ post: makeSseFn("POST"),
1250
+ put: makeSseFn("PUT"),
1251
+ trace: makeSseFn("TRACE")
1252
+ },
1253
+ trace: makeMethodFn("TRACE")
1254
+ };
1255
+ }, "createClient");
1256
+
1257
+ // src/_api/generated/client.gen.ts
1258
+ var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1259
+ installAuthOnClient(client);
1260
+
1261
+ // src/_api/generated/sdk.gen.ts
1262
+ var CfgAccountsApiKey = class {
1263
+ static {
1264
+ __name(this, "CfgAccountsApiKey");
1839
1265
  }
1840
1266
  /**
1841
- * Partial update user profile
1267
+ * Get API key details
1842
1268
  *
1843
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1269
+ * Retrieve the current user's API key (masked) and metadata.
1844
1270
  */
1845
- static cfgAccountsProfilePartialUpdate(options) {
1846
- return (options?.client ?? client).put({
1271
+ static cfgAccountsApiKeyRetrieve(options) {
1272
+ return (options?.client ?? client).get({
1847
1273
  security: [{ scheme: "bearer", type: "http" }, {
1848
1274
  in: "cookie",
1849
1275
  name: "sessionid",
1850
1276
  type: "apiKey"
1851
1277
  }],
1852
- url: "/cfg/accounts/profile/partial/",
1853
- ...options,
1854
- headers: {
1855
- "Content-Type": "application/json",
1856
- ...options?.headers
1857
- }
1278
+ url: "/cfg/accounts/api-key/",
1279
+ ...options
1858
1280
  });
1859
1281
  }
1860
1282
  /**
1861
- * Update user profile
1283
+ * Regenerate API key
1862
1284
  *
1863
- * Update the current authenticated user's profile information.
1285
+ * Generate a new API key. The full key is returned only once.
1864
1286
  */
1865
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1866
- return (options?.client ?? client).patch({
1287
+ static cfgAccountsApiKeyRegenerateCreate(options) {
1288
+ return (options.client ?? client).post({
1867
1289
  security: [{ scheme: "bearer", type: "http" }, {
1868
1290
  in: "cookie",
1869
1291
  name: "sessionid",
1870
1292
  type: "apiKey"
1871
1293
  }],
1872
- url: "/cfg/accounts/profile/update/",
1294
+ url: "/cfg/accounts/api-key/regenerate/",
1873
1295
  ...options,
1874
1296
  headers: {
1875
1297
  "Content-Type": "application/json",
1876
- ...options?.headers
1298
+ ...options.headers
1877
1299
  }
1878
1300
  });
1879
1301
  }
1880
1302
  /**
1881
- * Update user profile
1303
+ * Test API key
1882
1304
  *
1883
- * Update the current authenticated user's profile information.
1305
+ * Test whether an API key is valid without consuming it.
1884
1306
  */
1885
- static cfgAccountsProfileUpdateUpdate(options) {
1886
- return (options?.client ?? client).put({
1307
+ static cfgAccountsApiKeyTestCreate(options) {
1308
+ return (options.client ?? client).post({
1887
1309
  security: [{ scheme: "bearer", type: "http" }, {
1888
1310
  in: "cookie",
1889
1311
  name: "sessionid",
1890
1312
  type: "apiKey"
1891
1313
  }],
1892
- url: "/cfg/accounts/profile/update/",
1893
- ...options,
1894
- headers: {
1895
- "Content-Type": "application/json",
1896
- ...options?.headers
1897
- }
1898
- });
1899
- }
1900
- /**
1901
- * Refresh JWT token.
1902
- */
1903
- static cfgAccountsTokenRefreshCreate(options) {
1904
- return (options.client ?? client).post({
1905
- url: "/cfg/accounts/token/refresh/",
1906
- ...options,
1907
- headers: {
1908
- "Content-Type": "application/json",
1909
- ...options.headers
1910
- }
1911
- });
1912
- }
1913
- /**
1914
- * Get Centrifugo connection token
1915
- *
1916
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
1917
- */
1918
- static cfgCentrifugoAuthTokenRetrieve(options) {
1919
- return (options?.client ?? client).get({
1920
- security: [{ scheme: "bearer", type: "http" }],
1921
- url: "/cfg/centrifugo/auth/token/",
1922
- ...options
1923
- });
1924
- }
1925
- /**
1926
- * Get backup codes status for user.
1927
- */
1928
- static cfgTotpBackupCodesRetrieve(options) {
1929
- return (options?.client ?? client).get({
1930
- security: [{ scheme: "bearer", type: "http" }],
1931
- url: "/cfg/totp/backup-codes/",
1932
- ...options
1933
- });
1934
- }
1935
- /**
1936
- * Regenerate backup codes.
1937
- *
1938
- * Requires TOTP code for verification.
1939
- * Invalidates all existing codes.
1940
- */
1941
- static cfgTotpBackupCodesRegenerateCreate(options) {
1942
- return (options.client ?? client).post({
1943
- security: [{ scheme: "bearer", type: "http" }],
1944
- url: "/cfg/totp/backup-codes/regenerate/",
1945
- ...options,
1946
- headers: {
1947
- "Content-Type": "application/json",
1948
- ...options.headers
1949
- }
1950
- });
1951
- }
1952
- /**
1953
- * List all TOTP devices for user.
1954
- */
1955
- static cfgTotpDevicesRetrieve(options) {
1956
- return (options?.client ?? client).get({
1957
- security: [{ scheme: "bearer", type: "http" }],
1958
- url: "/cfg/totp/devices/",
1959
- ...options
1960
- });
1961
- }
1962
- /**
1963
- * Delete a TOTP device.
1964
- *
1965
- * Requires verification code if removing the last/primary device.
1966
- */
1967
- static cfgTotpDevicesDestroy(options) {
1968
- return (options.client ?? client).delete({
1969
- security: [{ scheme: "bearer", type: "http" }],
1970
- url: "/cfg/totp/devices/{id}/",
1971
- ...options
1972
- });
1973
- }
1974
- /**
1975
- * Completely disable 2FA for account.
1976
- *
1977
- * Requires verification code.
1978
- */
1979
- static cfgTotpDisableCreate(options) {
1980
- return (options.client ?? client).post({
1981
- security: [{ scheme: "bearer", type: "http" }],
1982
- url: "/cfg/totp/disable/",
1983
- ...options,
1984
- headers: {
1985
- "Content-Type": "application/json",
1986
- ...options.headers
1987
- }
1988
- });
1989
- }
1990
- /**
1991
- * Start 2FA setup process.
1992
- *
1993
- * Creates a new TOTP device and returns QR code for scanning.
1994
- */
1995
- static cfgTotpSetupCreate(options) {
1996
- return (options?.client ?? client).post({
1997
- security: [{ scheme: "bearer", type: "http" }],
1998
- url: "/cfg/totp/setup/",
1999
- ...options,
2000
- headers: {
2001
- "Content-Type": "application/json",
2002
- ...options?.headers
2003
- }
2004
- });
2005
- }
2006
- /**
2007
- * Confirm 2FA setup with first valid code.
2008
- *
2009
- * Activates the device and generates backup codes.
2010
- */
2011
- static cfgTotpSetupConfirmCreate(options) {
2012
- return (options.client ?? client).post({
2013
- security: [{ scheme: "bearer", type: "http" }],
2014
- url: "/cfg/totp/setup/confirm/",
2015
- ...options,
2016
- headers: {
2017
- "Content-Type": "application/json",
2018
- ...options.headers
2019
- }
2020
- });
2021
- }
2022
- /**
2023
- * Verify TOTP code for 2FA session.
2024
- *
2025
- * Completes authentication and returns JWT tokens on success.
2026
- */
2027
- static cfgTotpVerifyCreate(options) {
2028
- return (options.client ?? client).post({
2029
- security: [{ scheme: "bearer", type: "http" }],
2030
- url: "/cfg/totp/verify/",
2031
- ...options,
2032
- headers: {
2033
- "Content-Type": "application/json",
2034
- ...options.headers
2035
- }
2036
- });
2037
- }
2038
- /**
2039
- * Verify backup recovery code for 2FA session.
2040
- *
2041
- * Alternative verification method when TOTP device unavailable.
2042
- */
2043
- static cfgTotpVerifyBackupCreate(options) {
2044
- return (options.client ?? client).post({
2045
- security: [{ scheme: "bearer", type: "http" }],
2046
- url: "/cfg/totp/verify/backup/",
1314
+ url: "/cfg/accounts/api-key/test/",
2047
1315
  ...options,
2048
1316
  headers: {
2049
1317
  "Content-Type": "application/json",
@@ -2052,9 +1320,9 @@ var Cfg = class {
2052
1320
  });
2053
1321
  }
2054
1322
  };
2055
- var Accounts = class {
1323
+ var CfgAccountsOauth = class {
2056
1324
  static {
2057
- __name(this, "Accounts");
1325
+ __name(this, "CfgAccountsOauth");
2058
1326
  }
2059
1327
  /**
2060
1328
  * List OAuth connections
@@ -2063,7 +1331,7 @@ var Accounts = class {
2063
1331
  */
2064
1332
  static cfgAccountsOauthConnectionsList(options) {
2065
1333
  return (options?.client ?? client).get({
2066
- security: [{ scheme: "bearer", type: "http" }],
1334
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2067
1335
  url: "/cfg/accounts/oauth/connections/",
2068
1336
  ...options
2069
1337
  });
@@ -2075,7 +1343,7 @@ var Accounts = class {
2075
1343
  */
2076
1344
  static cfgAccountsOauthDisconnectCreate(options) {
2077
1345
  return (options.client ?? client).post({
2078
- security: [{ scheme: "bearer", type: "http" }],
1346
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2079
1347
  url: "/cfg/accounts/oauth/disconnect/",
2080
1348
  ...options,
2081
1349
  headers: {
@@ -2122,12 +1390,17 @@ var Accounts = class {
2122
1390
  static cfgAccountsOauthProvidersRetrieve(options) {
2123
1391
  return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
2124
1392
  }
1393
+ };
1394
+ var CfgAccounts = class {
1395
+ static {
1396
+ __name(this, "CfgAccounts");
1397
+ }
2125
1398
  /**
2126
1399
  * Request OTP code to email.
2127
1400
  */
2128
1401
  static cfgAccountsOtpRequestCreate(options) {
2129
1402
  return (options.client ?? client).post({
2130
- security: [{ scheme: "bearer", type: "http" }],
1403
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2131
1404
  url: "/cfg/accounts/otp/request/",
2132
1405
  ...options,
2133
1406
  headers: {
@@ -2148,7 +1421,7 @@ var Accounts = class {
2148
1421
  */
2149
1422
  static cfgAccountsOtpVerifyCreate(options) {
2150
1423
  return (options.client ?? client).post({
2151
- security: [{ scheme: "bearer", type: "http" }],
1424
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2152
1425
  url: "/cfg/accounts/otp/verify/",
2153
1426
  ...options,
2154
1427
  headers: {
@@ -2157,6 +1430,11 @@ var Accounts = class {
2157
1430
  }
2158
1431
  });
2159
1432
  }
1433
+ };
1434
+ var CfgAccountsProfile = class {
1435
+ static {
1436
+ __name(this, "CfgAccountsProfile");
1437
+ }
2160
1438
  /**
2161
1439
  * Get current user profile
2162
1440
  *
@@ -2181,7 +1459,7 @@ var Accounts = class {
2181
1459
  static cfgAccountsProfileAvatarCreate(options) {
2182
1460
  return (options?.client ?? client).post({
2183
1461
  ...formDataBodySerializer,
2184
- security: [{ scheme: "bearer", type: "http" }],
1462
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2185
1463
  url: "/cfg/accounts/profile/avatar/",
2186
1464
  ...options,
2187
1465
  headers: {
@@ -2296,6 +1574,11 @@ var Accounts = class {
2296
1574
  }
2297
1575
  });
2298
1576
  }
1577
+ };
1578
+ var CfgAccountsAuth = class {
1579
+ static {
1580
+ __name(this, "CfgAccountsAuth");
1581
+ }
2299
1582
  /**
2300
1583
  * Refresh JWT token.
2301
1584
  */
@@ -2310,61 +1593,47 @@ var Accounts = class {
2310
1593
  });
2311
1594
  }
2312
1595
  };
2313
- var OAuth = class {
1596
+ var CfgCentrifugo = class {
2314
1597
  static {
2315
- __name(this, "OAuth");
1598
+ __name(this, "CfgCentrifugo");
2316
1599
  }
2317
1600
  /**
2318
- * List OAuth connections
1601
+ * Get Centrifugo connection token
2319
1602
  *
2320
- * Get all OAuth connections for the current user.
1603
+ * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2321
1604
  */
2322
- static cfgAccountsOauthConnectionsList(options) {
1605
+ static cfgCentrifugoAuthTokenRetrieve(options) {
2323
1606
  return (options?.client ?? client).get({
2324
- security: [{ scheme: "bearer", type: "http" }],
2325
- url: "/cfg/accounts/oauth/connections/",
1607
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1608
+ url: "/cfg/centrifugo/auth/token/",
2326
1609
  ...options
2327
1610
  });
2328
1611
  }
2329
- /**
2330
- * Disconnect OAuth provider
2331
- *
2332
- * Remove OAuth connection for the specified provider.
2333
- */
2334
- static cfgAccountsOauthDisconnectCreate(options) {
2335
- return (options.client ?? client).post({
2336
- security: [{ scheme: "bearer", type: "http" }],
2337
- url: "/cfg/accounts/oauth/disconnect/",
2338
- ...options,
2339
- headers: {
2340
- "Content-Type": "application/json",
2341
- ...options.headers
2342
- }
2343
- });
1612
+ };
1613
+ var CfgTotpBackupCodes = class {
1614
+ static {
1615
+ __name(this, "CfgTotpBackupCodes");
2344
1616
  }
2345
1617
  /**
2346
- * Start GitHub OAuth
2347
- *
2348
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
2349
- */
2350
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
2351
- return (options?.client ?? client).post({
2352
- url: "/cfg/accounts/oauth/github/authorize/",
2353
- ...options,
2354
- headers: {
2355
- "Content-Type": "application/json",
2356
- ...options?.headers
2357
- }
1618
+ * Get backup codes status for user.
1619
+ */
1620
+ static cfgTotpBackupCodesRetrieve(options) {
1621
+ return (options?.client ?? client).get({
1622
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1623
+ url: "/cfg/totp/backup-codes/",
1624
+ ...options
2358
1625
  });
2359
1626
  }
2360
1627
  /**
2361
- * Complete GitHub OAuth
1628
+ * Regenerate backup codes.
2362
1629
  *
2363
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1630
+ * Requires TOTP code for verification.
1631
+ * Invalidates all existing codes.
2364
1632
  */
2365
- static cfgAccountsOauthGithubCallbackCreate(options) {
1633
+ static cfgTotpBackupCodesRegenerateCreate(options) {
2366
1634
  return (options.client ?? client).post({
2367
- url: "/cfg/accounts/oauth/github/callback/",
1635
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1636
+ url: "/cfg/totp/backup-codes/regenerate/",
2368
1637
  ...options,
2369
1638
  headers: {
2370
1639
  "Content-Type": "application/json",
@@ -2372,480 +1641,524 @@ var OAuth = class {
2372
1641
  }
2373
1642
  });
2374
1643
  }
2375
- /**
2376
- * List OAuth providers
2377
- *
2378
- * Get list of available OAuth providers for authentication.
2379
- */
2380
- static cfgAccountsOauthProvidersRetrieve(options) {
2381
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
2382
- }
2383
1644
  };
2384
- var UserProfile = class {
1645
+ var CfgTotp = class {
2385
1646
  static {
2386
- __name(this, "UserProfile");
1647
+ __name(this, "CfgTotp");
2387
1648
  }
2388
1649
  /**
2389
- * Get current user profile
2390
- *
2391
- * Retrieve the current authenticated user's profile information.
1650
+ * List all TOTP devices for user.
2392
1651
  */
2393
- static cfgAccountsProfileRetrieve(options) {
1652
+ static cfgTotpDevicesRetrieve(options) {
2394
1653
  return (options?.client ?? client).get({
2395
- security: [{ scheme: "bearer", type: "http" }, {
2396
- in: "cookie",
2397
- name: "sessionid",
2398
- type: "apiKey"
2399
- }],
2400
- url: "/cfg/accounts/profile/",
1654
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1655
+ url: "/cfg/totp/devices/",
2401
1656
  ...options
2402
1657
  });
2403
1658
  }
2404
1659
  /**
2405
- * Upload user avatar
1660
+ * Delete a TOTP device.
2406
1661
  *
2407
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1662
+ * Requires verification code if removing the last/primary device.
2408
1663
  */
2409
- static cfgAccountsProfileAvatarCreate(options) {
2410
- return (options?.client ?? client).post({
2411
- ...formDataBodySerializer,
2412
- security: [{ scheme: "bearer", type: "http" }],
2413
- url: "/cfg/accounts/profile/avatar/",
1664
+ static cfgTotpDevicesDestroy(options) {
1665
+ return (options.client ?? client).delete({
1666
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1667
+ url: "/cfg/totp/devices/{id}/",
1668
+ ...options
1669
+ });
1670
+ }
1671
+ /**
1672
+ * Completely disable 2FA for account.
1673
+ *
1674
+ * Requires verification code.
1675
+ */
1676
+ static cfgTotpDisableCreate(options) {
1677
+ return (options.client ?? client).post({
1678
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1679
+ url: "/cfg/totp/disable/",
2414
1680
  ...options,
2415
1681
  headers: {
2416
- "Content-Type": null,
2417
- ...options?.headers
1682
+ "Content-Type": "application/json",
1683
+ ...options.headers
2418
1684
  }
2419
1685
  });
2420
1686
  }
1687
+ };
1688
+ var CfgTotpSetup = class {
1689
+ static {
1690
+ __name(this, "CfgTotpSetup");
1691
+ }
2421
1692
  /**
2422
- * Delete user account
2423
- *
2424
- *
2425
- * Permanently delete the current user's account.
2426
- *
2427
- * This operation:
2428
- * - Deactivates the account (user cannot log in)
2429
- * - Anonymizes personal data (GDPR compliance)
2430
- * - Frees up the email address for re-registration
2431
- * - Preserves audit trail
2432
- *
2433
- * The account can be restored by an administrator if needed.
1693
+ * Start 2FA setup process.
2434
1694
  *
1695
+ * Creates a new TOTP device and returns QR code for scanning.
2435
1696
  */
2436
- static cfgAccountsProfileDeleteCreate(options) {
1697
+ static cfgTotpSetupCreate(options) {
2437
1698
  return (options?.client ?? client).post({
2438
- security: [{ scheme: "bearer", type: "http" }, {
2439
- in: "cookie",
2440
- name: "sessionid",
2441
- type: "apiKey"
2442
- }],
2443
- url: "/cfg/accounts/profile/delete/",
2444
- ...options
1699
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1700
+ url: "/cfg/totp/setup/",
1701
+ ...options,
1702
+ headers: {
1703
+ "Content-Type": "application/json",
1704
+ ...options?.headers
1705
+ }
2445
1706
  });
2446
1707
  }
2447
1708
  /**
2448
- * Partial update user profile
1709
+ * Confirm 2FA setup with first valid code.
2449
1710
  *
2450
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1711
+ * Activates the device and generates backup codes.
2451
1712
  */
2452
- static cfgAccountsProfilePartialPartialUpdate(options) {
2453
- return (options?.client ?? client).patch({
2454
- security: [{ scheme: "bearer", type: "http" }, {
2455
- in: "cookie",
2456
- name: "sessionid",
2457
- type: "apiKey"
2458
- }],
2459
- url: "/cfg/accounts/profile/partial/",
1713
+ static cfgTotpSetupConfirmCreate(options) {
1714
+ return (options.client ?? client).post({
1715
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1716
+ url: "/cfg/totp/setup/confirm/",
2460
1717
  ...options,
2461
1718
  headers: {
2462
1719
  "Content-Type": "application/json",
2463
- ...options?.headers
1720
+ ...options.headers
2464
1721
  }
2465
1722
  });
2466
1723
  }
1724
+ };
1725
+ var CfgTotpVerify = class {
1726
+ static {
1727
+ __name(this, "CfgTotpVerify");
1728
+ }
2467
1729
  /**
2468
- * Partial update user profile
1730
+ * Verify TOTP code for 2FA session.
2469
1731
  *
2470
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1732
+ * Completes authentication and returns JWT tokens on success.
2471
1733
  */
2472
- static cfgAccountsProfilePartialUpdate(options) {
2473
- return (options?.client ?? client).put({
2474
- security: [{ scheme: "bearer", type: "http" }, {
2475
- in: "cookie",
2476
- name: "sessionid",
2477
- type: "apiKey"
2478
- }],
2479
- url: "/cfg/accounts/profile/partial/",
1734
+ static cfgTotpVerifyCreate(options) {
1735
+ return (options.client ?? client).post({
1736
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1737
+ url: "/cfg/totp/verify/",
2480
1738
  ...options,
2481
1739
  headers: {
2482
1740
  "Content-Type": "application/json",
2483
- ...options?.headers
1741
+ ...options.headers
2484
1742
  }
2485
1743
  });
2486
1744
  }
2487
1745
  /**
2488
- * Update user profile
1746
+ * Verify backup recovery code for 2FA session.
2489
1747
  *
2490
- * Update the current authenticated user's profile information.
1748
+ * Alternative verification method when TOTP device unavailable.
2491
1749
  */
2492
- static cfgAccountsProfileUpdatePartialUpdate(options) {
2493
- return (options?.client ?? client).patch({
2494
- security: [{ scheme: "bearer", type: "http" }, {
2495
- in: "cookie",
2496
- name: "sessionid",
2497
- type: "apiKey"
2498
- }],
2499
- url: "/cfg/accounts/profile/update/",
1750
+ static cfgTotpVerifyBackupCreate(options) {
1751
+ return (options.client ?? client).post({
1752
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1753
+ url: "/cfg/totp/verify/backup/",
2500
1754
  ...options,
2501
1755
  headers: {
2502
1756
  "Content-Type": "application/json",
2503
- ...options?.headers
1757
+ ...options.headers
2504
1758
  }
2505
1759
  });
2506
1760
  }
2507
- /**
2508
- * Update user profile
2509
- *
2510
- * Update the current authenticated user's profile information.
2511
- */
2512
- static cfgAccountsProfileUpdateUpdate(options) {
2513
- return (options?.client ?? client).put({
2514
- security: [{ scheme: "bearer", type: "http" }, {
2515
- in: "cookie",
2516
- name: "sessionid",
2517
- type: "apiKey"
2518
- }],
2519
- url: "/cfg/accounts/profile/update/",
2520
- ...options,
2521
- headers: {
2522
- "Content-Type": "application/json",
2523
- ...options?.headers
2524
- }
2525
- });
1761
+ };
1762
+
1763
+ // src/_api/generated/_cfg_accounts/api.ts
1764
+ var API = class {
1765
+ static {
1766
+ __name(this, "API");
1767
+ }
1768
+ logger;
1769
+ cfgAccountsApiKey = CfgAccountsApiKey;
1770
+ cfgAccountsOauth = CfgAccountsOauth;
1771
+ cfgAccounts = CfgAccounts;
1772
+ cfgAccountsProfile = CfgAccountsProfile;
1773
+ cfgAccountsAuth = CfgAccountsAuth;
1774
+ constructor(_baseUrl, opts = {}) {
1775
+ this.logger = new APILogger(opts.logger);
1776
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1777
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1778
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1779
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1780
+ }
1781
+ // ── Base URL ────────────────────────────────────────────────────────────
1782
+ getBaseUrl() {
1783
+ return auth.getBaseUrl();
1784
+ }
1785
+ setBaseUrl(url) {
1786
+ auth.setBaseUrl(url);
1787
+ }
1788
+ // ── Tokens ──────────────────────────────────────────────────────────────
1789
+ getToken() {
1790
+ return auth.getToken();
1791
+ }
1792
+ setToken(token) {
1793
+ auth.setToken(token);
1794
+ }
1795
+ getRefreshToken() {
1796
+ return auth.getRefreshToken();
1797
+ }
1798
+ setRefreshToken(token) {
1799
+ auth.setRefreshToken(token);
1800
+ }
1801
+ clearToken() {
1802
+ auth.clearTokens();
1803
+ }
1804
+ isAuthenticated() {
1805
+ return auth.isAuthenticated();
1806
+ }
1807
+ // ── Locale / API key ────────────────────────────────────────────────────
1808
+ getLocale() {
1809
+ return auth.getLocale();
1810
+ }
1811
+ setLocale(locale) {
1812
+ auth.setLocale(locale);
1813
+ }
1814
+ getApiKey() {
1815
+ return auth.getApiKey();
1816
+ }
1817
+ setApiKey(key) {
1818
+ auth.setApiKey(key);
1819
+ }
1820
+ // ── 401 handling ────────────────────────────────────────────────────────
1821
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
1822
+ onUnauthorized(cb) {
1823
+ auth.onUnauthorized(cb);
1824
+ }
1825
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
1826
+ setRefreshHandler(fn) {
1827
+ auth.setRefreshHandler(fn);
1828
+ }
1829
+ };
1830
+
1831
+ // src/_api/generated/helpers/storage.ts
1832
+ var LocalStorageAdapter = class {
1833
+ static {
1834
+ __name(this, "LocalStorageAdapter");
1835
+ }
1836
+ getItem(key) {
1837
+ if (typeof window === "undefined") return null;
1838
+ try {
1839
+ return window.localStorage.getItem(key);
1840
+ } catch {
1841
+ return null;
1842
+ }
1843
+ }
1844
+ setItem(key, value) {
1845
+ if (typeof window === "undefined") return;
1846
+ try {
1847
+ window.localStorage.setItem(key, value);
1848
+ } catch {
1849
+ }
1850
+ }
1851
+ removeItem(key) {
1852
+ if (typeof window === "undefined") return;
1853
+ try {
1854
+ window.localStorage.removeItem(key);
1855
+ } catch {
1856
+ }
1857
+ }
1858
+ clear() {
1859
+ if (typeof window === "undefined") return;
1860
+ try {
1861
+ window.localStorage.clear();
1862
+ } catch {
1863
+ }
1864
+ }
1865
+ };
1866
+ var MemoryStorageAdapter = class {
1867
+ static {
1868
+ __name(this, "MemoryStorageAdapter");
1869
+ }
1870
+ store = /* @__PURE__ */ new Map();
1871
+ getItem(key) {
1872
+ return this.store.get(key) ?? null;
1873
+ }
1874
+ setItem(key, value) {
1875
+ this.store.set(key, value);
1876
+ }
1877
+ removeItem(key) {
1878
+ this.store.delete(key);
1879
+ }
1880
+ clear() {
1881
+ this.store.clear();
2526
1882
  }
2527
1883
  };
2528
- var Auth = class {
1884
+ var CookieStorageAdapter = class {
1885
+ constructor(opts = {}) {
1886
+ this.opts = opts;
1887
+ }
2529
1888
  static {
2530
- __name(this, "Auth");
1889
+ __name(this, "CookieStorageAdapter");
2531
1890
  }
2532
- /**
2533
- * Refresh JWT token.
2534
- */
2535
- static cfgAccountsTokenRefreshCreate(options) {
2536
- return (options.client ?? client).post({
2537
- url: "/cfg/accounts/token/refresh/",
2538
- ...options,
2539
- headers: {
2540
- "Content-Type": "application/json",
2541
- ...options.headers
1891
+ getItem(key) {
1892
+ if (typeof document === "undefined") return null;
1893
+ const prefix = `${encodeURIComponent(key)}=`;
1894
+ for (const part of document.cookie.split("; ")) {
1895
+ if (part.startsWith(prefix)) {
1896
+ return decodeURIComponent(part.slice(prefix.length));
2542
1897
  }
2543
- });
1898
+ }
1899
+ return null;
1900
+ }
1901
+ setItem(key, value) {
1902
+ if (typeof document === "undefined") return;
1903
+ const parts = [
1904
+ `${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
1905
+ `Path=${this.opts.path ?? "/"}`
1906
+ ];
1907
+ if (this.opts.domain) parts.push(`Domain=${this.opts.domain}`);
1908
+ if (this.opts.secure) parts.push("Secure");
1909
+ if (this.opts.sameSite) parts.push(`SameSite=${this.opts.sameSite}`);
1910
+ if (this.opts.maxAgeSeconds != null) {
1911
+ parts.push(`Max-Age=${this.opts.maxAgeSeconds}`);
1912
+ }
1913
+ document.cookie = parts.join("; ");
1914
+ }
1915
+ removeItem(key) {
1916
+ if (typeof document === "undefined") return;
1917
+ document.cookie = `${encodeURIComponent(key)}=; Max-Age=0; Path=${this.opts.path ?? "/"}`;
2544
1918
  }
2545
1919
  };
2546
- var Centrifugo = class {
1920
+
1921
+ // src/_api/generated/helpers/errors.ts
1922
+ var APIError = class extends Error {
1923
+ constructor(statusCode, statusText, response, url, message) {
1924
+ super(message || `HTTP ${statusCode}: ${statusText}`);
1925
+ this.statusCode = statusCode;
1926
+ this.statusText = statusText;
1927
+ this.response = response;
1928
+ this.url = url;
1929
+ this.name = "APIError";
1930
+ }
2547
1931
  static {
2548
- __name(this, "Centrifugo");
1932
+ __name(this, "APIError");
2549
1933
  }
2550
- /**
2551
- * Get Centrifugo connection token
2552
- *
2553
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2554
- */
2555
- static cfgCentrifugoAuthTokenRetrieve(options) {
2556
- return (options?.client ?? client).get({
2557
- security: [{ scheme: "bearer", type: "http" }],
2558
- url: "/cfg/centrifugo/auth/token/",
2559
- ...options
2560
- });
1934
+ get details() {
1935
+ if (typeof this.response === "object" && this.response !== null) {
1936
+ return this.response;
1937
+ }
1938
+ return null;
1939
+ }
1940
+ get fieldErrors() {
1941
+ const details = this.details;
1942
+ if (!details) return null;
1943
+ const fieldErrors = {};
1944
+ for (const [key, value] of Object.entries(details)) {
1945
+ if (Array.isArray(value)) fieldErrors[key] = value;
1946
+ }
1947
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
1948
+ }
1949
+ get errorMessage() {
1950
+ const details = this.details;
1951
+ if (!details) return this.message;
1952
+ if (details.detail) {
1953
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
1954
+ }
1955
+ if (details.error) return String(details.error);
1956
+ if (details.message) return String(details.message);
1957
+ const fieldErrors = this.fieldErrors;
1958
+ if (fieldErrors) {
1959
+ const firstField = Object.keys(fieldErrors)[0];
1960
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
1961
+ }
1962
+ return this.message;
1963
+ }
1964
+ get isValidationError() {
1965
+ return this.statusCode === 400;
1966
+ }
1967
+ get isAuthError() {
1968
+ return this.statusCode === 401;
1969
+ }
1970
+ get isPermissionError() {
1971
+ return this.statusCode === 403;
1972
+ }
1973
+ get isNotFoundError() {
1974
+ return this.statusCode === 404;
1975
+ }
1976
+ get isServerError() {
1977
+ return this.statusCode >= 500 && this.statusCode < 600;
2561
1978
  }
2562
1979
  };
2563
- var CentrifugoAuth = class {
1980
+ var NetworkError = class extends Error {
1981
+ constructor(message, url, originalError) {
1982
+ super(message);
1983
+ this.url = url;
1984
+ this.originalError = originalError;
1985
+ this.name = "NetworkError";
1986
+ }
2564
1987
  static {
2565
- __name(this, "CentrifugoAuth");
1988
+ __name(this, "NetworkError");
2566
1989
  }
2567
- /**
2568
- * Get Centrifugo connection token
2569
- *
2570
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2571
- */
2572
- static cfgCentrifugoAuthTokenRetrieve(options) {
2573
- return (options?.client ?? client).get({
2574
- security: [{ scheme: "bearer", type: "http" }],
2575
- url: "/cfg/centrifugo/auth/token/",
2576
- ...options
1990
+ };
1991
+
1992
+ // src/_api/generated/helpers/validation-events.ts
1993
+ function dispatchValidationError(detail) {
1994
+ if (typeof window === "undefined") return;
1995
+ try {
1996
+ const event = new CustomEvent("zod-validation-error", {
1997
+ detail,
1998
+ bubbles: true,
1999
+ cancelable: false
2577
2000
  });
2001
+ window.dispatchEvent(event);
2002
+ } catch (error) {
2003
+ console.warn("Failed to dispatch validation error event:", error);
2578
2004
  }
2579
- };
2580
- var Totp = class {
2005
+ }
2006
+ __name(dispatchValidationError, "dispatchValidationError");
2007
+ function onValidationError(callback) {
2008
+ if (typeof window === "undefined") return () => {
2009
+ };
2010
+ const handler = /* @__PURE__ */ __name((event) => {
2011
+ if (event instanceof CustomEvent) callback(event.detail);
2012
+ }, "handler");
2013
+ window.addEventListener("zod-validation-error", handler);
2014
+ return () => window.removeEventListener("zod-validation-error", handler);
2015
+ }
2016
+ __name(onValidationError, "onValidationError");
2017
+ function formatZodError(error) {
2018
+ const issues = error.issues.map((issue, index) => {
2019
+ const path = issue.path.join(".") || "root";
2020
+ const parts = [`${index + 1}. ${path}: ${issue.message}`];
2021
+ if ("expected" in issue && issue.expected) parts.push(` Expected: ${issue.expected}`);
2022
+ if ("received" in issue && issue.received) parts.push(` Received: ${issue.received}`);
2023
+ return parts.join("\n");
2024
+ });
2025
+ return issues.join("\n");
2026
+ }
2027
+ __name(formatZodError, "formatZodError");
2028
+
2029
+ // src/_api/generated/_cfg_centrifugo/api.ts
2030
+ var API2 = class {
2581
2031
  static {
2582
- __name(this, "Totp");
2032
+ __name(this, "API");
2583
2033
  }
2584
- /**
2585
- * Get backup codes status for user.
2586
- */
2587
- static cfgTotpBackupCodesRetrieve(options) {
2588
- return (options?.client ?? client).get({
2589
- security: [{ scheme: "bearer", type: "http" }],
2590
- url: "/cfg/totp/backup-codes/",
2591
- ...options
2592
- });
2034
+ logger;
2035
+ cfgCentrifugo = CfgCentrifugo;
2036
+ constructor(_baseUrl, opts = {}) {
2037
+ this.logger = new APILogger(opts.logger);
2038
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
2039
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
2040
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
2041
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
2593
2042
  }
2594
- /**
2595
- * Regenerate backup codes.
2596
- *
2597
- * Requires TOTP code for verification.
2598
- * Invalidates all existing codes.
2599
- */
2600
- static cfgTotpBackupCodesRegenerateCreate(options) {
2601
- return (options.client ?? client).post({
2602
- security: [{ scheme: "bearer", type: "http" }],
2603
- url: "/cfg/totp/backup-codes/regenerate/",
2604
- ...options,
2605
- headers: {
2606
- "Content-Type": "application/json",
2607
- ...options.headers
2608
- }
2609
- });
2043
+ // ── Base URL ────────────────────────────────────────────────────────────
2044
+ getBaseUrl() {
2045
+ return auth.getBaseUrl();
2610
2046
  }
2611
- /**
2612
- * List all TOTP devices for user.
2613
- */
2614
- static cfgTotpDevicesRetrieve(options) {
2615
- return (options?.client ?? client).get({
2616
- security: [{ scheme: "bearer", type: "http" }],
2617
- url: "/cfg/totp/devices/",
2618
- ...options
2619
- });
2047
+ setBaseUrl(url) {
2048
+ auth.setBaseUrl(url);
2620
2049
  }
2621
- /**
2622
- * Delete a TOTP device.
2623
- *
2624
- * Requires verification code if removing the last/primary device.
2625
- */
2626
- static cfgTotpDevicesDestroy(options) {
2627
- return (options.client ?? client).delete({
2628
- security: [{ scheme: "bearer", type: "http" }],
2629
- url: "/cfg/totp/devices/{id}/",
2630
- ...options
2631
- });
2050
+ // ── Tokens ──────────────────────────────────────────────────────────────
2051
+ getToken() {
2052
+ return auth.getToken();
2053
+ }
2054
+ setToken(token) {
2055
+ auth.setToken(token);
2056
+ }
2057
+ getRefreshToken() {
2058
+ return auth.getRefreshToken();
2059
+ }
2060
+ setRefreshToken(token) {
2061
+ auth.setRefreshToken(token);
2632
2062
  }
2633
- /**
2634
- * Completely disable 2FA for account.
2635
- *
2636
- * Requires verification code.
2637
- */
2638
- static cfgTotpDisableCreate(options) {
2639
- return (options.client ?? client).post({
2640
- security: [{ scheme: "bearer", type: "http" }],
2641
- url: "/cfg/totp/disable/",
2642
- ...options,
2643
- headers: {
2644
- "Content-Type": "application/json",
2645
- ...options.headers
2646
- }
2647
- });
2063
+ clearToken() {
2064
+ auth.clearTokens();
2648
2065
  }
2649
- /**
2650
- * Start 2FA setup process.
2651
- *
2652
- * Creates a new TOTP device and returns QR code for scanning.
2653
- */
2654
- static cfgTotpSetupCreate(options) {
2655
- return (options?.client ?? client).post({
2656
- security: [{ scheme: "bearer", type: "http" }],
2657
- url: "/cfg/totp/setup/",
2658
- ...options,
2659
- headers: {
2660
- "Content-Type": "application/json",
2661
- ...options?.headers
2662
- }
2663
- });
2066
+ isAuthenticated() {
2067
+ return auth.isAuthenticated();
2664
2068
  }
2665
- /**
2666
- * Confirm 2FA setup with first valid code.
2667
- *
2668
- * Activates the device and generates backup codes.
2669
- */
2670
- static cfgTotpSetupConfirmCreate(options) {
2671
- return (options.client ?? client).post({
2672
- security: [{ scheme: "bearer", type: "http" }],
2673
- url: "/cfg/totp/setup/confirm/",
2674
- ...options,
2675
- headers: {
2676
- "Content-Type": "application/json",
2677
- ...options.headers
2678
- }
2679
- });
2069
+ // ── Locale / API key ────────────────────────────────────────────────────
2070
+ getLocale() {
2071
+ return auth.getLocale();
2680
2072
  }
2681
- /**
2682
- * Verify TOTP code for 2FA session.
2683
- *
2684
- * Completes authentication and returns JWT tokens on success.
2685
- */
2686
- static cfgTotpVerifyCreate(options) {
2687
- return (options.client ?? client).post({
2688
- security: [{ scheme: "bearer", type: "http" }],
2689
- url: "/cfg/totp/verify/",
2690
- ...options,
2691
- headers: {
2692
- "Content-Type": "application/json",
2693
- ...options.headers
2694
- }
2695
- });
2073
+ setLocale(locale) {
2074
+ auth.setLocale(locale);
2696
2075
  }
2697
- /**
2698
- * Verify backup recovery code for 2FA session.
2699
- *
2700
- * Alternative verification method when TOTP device unavailable.
2701
- */
2702
- static cfgTotpVerifyBackupCreate(options) {
2703
- return (options.client ?? client).post({
2704
- security: [{ scheme: "bearer", type: "http" }],
2705
- url: "/cfg/totp/verify/backup/",
2706
- ...options,
2707
- headers: {
2708
- "Content-Type": "application/json",
2709
- ...options.headers
2710
- }
2711
- });
2076
+ getApiKey() {
2077
+ return auth.getApiKey();
2712
2078
  }
2713
- };
2714
- var BackupCodes = class {
2715
- static {
2716
- __name(this, "BackupCodes");
2079
+ setApiKey(key) {
2080
+ auth.setApiKey(key);
2717
2081
  }
2718
- /**
2719
- * Get backup codes status for user.
2720
- */
2721
- static cfgTotpBackupCodesRetrieve(options) {
2722
- return (options?.client ?? client).get({
2723
- security: [{ scheme: "bearer", type: "http" }],
2724
- url: "/cfg/totp/backup-codes/",
2725
- ...options
2726
- });
2082
+ // ── 401 handling ────────────────────────────────────────────────────────
2083
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
2084
+ onUnauthorized(cb) {
2085
+ auth.onUnauthorized(cb);
2727
2086
  }
2728
- /**
2729
- * Regenerate backup codes.
2730
- *
2731
- * Requires TOTP code for verification.
2732
- * Invalidates all existing codes.
2733
- */
2734
- static cfgTotpBackupCodesRegenerateCreate(options) {
2735
- return (options.client ?? client).post({
2736
- security: [{ scheme: "bearer", type: "http" }],
2737
- url: "/cfg/totp/backup-codes/regenerate/",
2738
- ...options,
2739
- headers: {
2740
- "Content-Type": "application/json",
2741
- ...options.headers
2742
- }
2743
- });
2087
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
2088
+ setRefreshHandler(fn) {
2089
+ auth.setRefreshHandler(fn);
2744
2090
  }
2745
2091
  };
2746
- var TotpManagement = class {
2092
+
2093
+ // src/_api/generated/_cfg_totp/api.ts
2094
+ var API3 = class {
2747
2095
  static {
2748
- __name(this, "TotpManagement");
2096
+ __name(this, "API");
2749
2097
  }
2750
- /**
2751
- * List all TOTP devices for user.
2752
- */
2753
- static cfgTotpDevicesRetrieve(options) {
2754
- return (options?.client ?? client).get({
2755
- security: [{ scheme: "bearer", type: "http" }],
2756
- url: "/cfg/totp/devices/",
2757
- ...options
2758
- });
2098
+ logger;
2099
+ cfgTotpBackupCodes = CfgTotpBackupCodes;
2100
+ cfgTotp = CfgTotp;
2101
+ cfgTotpSetup = CfgTotpSetup;
2102
+ cfgTotpVerify = CfgTotpVerify;
2103
+ constructor(_baseUrl, opts = {}) {
2104
+ this.logger = new APILogger(opts.logger);
2105
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
2106
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
2107
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
2108
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
2759
2109
  }
2760
- /**
2761
- * Completely disable 2FA for account.
2762
- *
2763
- * Requires verification code.
2764
- */
2765
- static cfgTotpDisableCreate(options) {
2766
- return (options.client ?? client).post({
2767
- security: [{ scheme: "bearer", type: "http" }],
2768
- url: "/cfg/totp/disable/",
2769
- ...options,
2770
- headers: {
2771
- "Content-Type": "application/json",
2772
- ...options.headers
2773
- }
2774
- });
2110
+ // ── Base URL ────────────────────────────────────────────────────────────
2111
+ getBaseUrl() {
2112
+ return auth.getBaseUrl();
2775
2113
  }
2776
- };
2777
- var TotpSetup = class {
2778
- static {
2779
- __name(this, "TotpSetup");
2114
+ setBaseUrl(url) {
2115
+ auth.setBaseUrl(url);
2780
2116
  }
2781
- /**
2782
- * Start 2FA setup process.
2783
- *
2784
- * Creates a new TOTP device and returns QR code for scanning.
2785
- */
2786
- static cfgTotpSetupCreate(options) {
2787
- return (options?.client ?? client).post({
2788
- security: [{ scheme: "bearer", type: "http" }],
2789
- url: "/cfg/totp/setup/",
2790
- ...options,
2791
- headers: {
2792
- "Content-Type": "application/json",
2793
- ...options?.headers
2794
- }
2795
- });
2117
+ // ── Tokens ──────────────────────────────────────────────────────────────
2118
+ getToken() {
2119
+ return auth.getToken();
2796
2120
  }
2797
- /**
2798
- * Confirm 2FA setup with first valid code.
2799
- *
2800
- * Activates the device and generates backup codes.
2801
- */
2802
- static cfgTotpSetupConfirmCreate(options) {
2803
- return (options.client ?? client).post({
2804
- security: [{ scheme: "bearer", type: "http" }],
2805
- url: "/cfg/totp/setup/confirm/",
2806
- ...options,
2807
- headers: {
2808
- "Content-Type": "application/json",
2809
- ...options.headers
2810
- }
2811
- });
2121
+ setToken(token) {
2122
+ auth.setToken(token);
2812
2123
  }
2813
- };
2814
- var TotpVerification = class {
2815
- static {
2816
- __name(this, "TotpVerification");
2124
+ getRefreshToken() {
2125
+ return auth.getRefreshToken();
2817
2126
  }
2818
- /**
2819
- * Verify TOTP code for 2FA session.
2820
- *
2821
- * Completes authentication and returns JWT tokens on success.
2822
- */
2823
- static cfgTotpVerifyCreate(options) {
2824
- return (options.client ?? client).post({
2825
- security: [{ scheme: "bearer", type: "http" }],
2826
- url: "/cfg/totp/verify/",
2827
- ...options,
2828
- headers: {
2829
- "Content-Type": "application/json",
2830
- ...options.headers
2831
- }
2832
- });
2127
+ setRefreshToken(token) {
2128
+ auth.setRefreshToken(token);
2833
2129
  }
2834
- /**
2835
- * Verify backup recovery code for 2FA session.
2836
- *
2837
- * Alternative verification method when TOTP device unavailable.
2838
- */
2839
- static cfgTotpVerifyBackupCreate(options) {
2840
- return (options.client ?? client).post({
2841
- security: [{ scheme: "bearer", type: "http" }],
2842
- url: "/cfg/totp/verify/backup/",
2843
- ...options,
2844
- headers: {
2845
- "Content-Type": "application/json",
2846
- ...options.headers
2847
- }
2848
- });
2130
+ clearToken() {
2131
+ auth.clearTokens();
2132
+ }
2133
+ isAuthenticated() {
2134
+ return auth.isAuthenticated();
2135
+ }
2136
+ // ── Locale / API key ────────────────────────────────────────────────────
2137
+ getLocale() {
2138
+ return auth.getLocale();
2139
+ }
2140
+ setLocale(locale) {
2141
+ auth.setLocale(locale);
2142
+ }
2143
+ getApiKey() {
2144
+ return auth.getApiKey();
2145
+ }
2146
+ setApiKey(key) {
2147
+ auth.setApiKey(key);
2148
+ }
2149
+ // ── 401 handling ────────────────────────────────────────────────────────
2150
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
2151
+ onUnauthorized(cb) {
2152
+ auth.onUnauthorized(cb);
2153
+ }
2154
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
2155
+ setRefreshHandler(fn) {
2156
+ auth.setRefreshHandler(fn);
2849
2157
  }
2850
2158
  };
2159
+
2160
+ // src/_api/generated/index.ts
2161
+ var CfgAccountsApi = new API();
2162
+ var CfgCentrifugoApi = new API2();
2163
+ var CfgTotpApi = new API3();
2851
2164
  //# sourceMappingURL=index.cjs.map