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