@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
@@ -403,201 +403,32 @@ var APILogger = class {
403
403
  };
404
404
  var defaultLogger = new APILogger();
405
405
 
406
- // src/_api/generated/_cfg_accounts/api.ts
407
- var API = class {
408
- static {
409
- __name(this, "API");
410
- }
411
- logger;
412
- constructor(_baseUrl, opts = {}) {
413
- this.logger = new APILogger(opts.logger);
414
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
415
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
416
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
417
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
418
- }
419
- // ── Base URL ────────────────────────────────────────────────────────────
420
- getBaseUrl() {
421
- return auth.getBaseUrl();
422
- }
423
- setBaseUrl(url) {
424
- auth.setBaseUrl(url);
425
- }
426
- // ── Tokens ──────────────────────────────────────────────────────────────
427
- getToken() {
428
- return auth.getToken();
429
- }
430
- setToken(token) {
431
- auth.setToken(token);
432
- }
433
- getRefreshToken() {
434
- return auth.getRefreshToken();
435
- }
436
- setRefreshToken(token) {
437
- auth.setRefreshToken(token);
438
- }
439
- clearToken() {
440
- auth.clearTokens();
441
- }
442
- isAuthenticated() {
443
- return auth.isAuthenticated();
444
- }
445
- // ── Locale / API key ────────────────────────────────────────────────────
446
- getLocale() {
447
- return auth.getLocale();
448
- }
449
- setLocale(locale) {
450
- auth.setLocale(locale);
451
- }
452
- getApiKey() {
453
- return auth.getApiKey();
454
- }
455
- setApiKey(key) {
456
- auth.setApiKey(key);
457
- }
458
- // ── 401 handling ────────────────────────────────────────────────────────
459
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
460
- onUnauthorized(cb) {
461
- auth.onUnauthorized(cb);
462
- }
463
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
464
- setRefreshHandler(fn) {
465
- auth.setRefreshHandler(fn);
466
- }
467
- };
468
-
469
- // src/_api/generated/_cfg_centrifugo/api.ts
470
- var API2 = class {
471
- static {
472
- __name(this, "API");
473
- }
474
- logger;
475
- constructor(_baseUrl, opts = {}) {
476
- this.logger = new APILogger(opts.logger);
477
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
478
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
479
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
480
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
481
- }
482
- // ── Base URL ────────────────────────────────────────────────────────────
483
- getBaseUrl() {
484
- return auth.getBaseUrl();
485
- }
486
- setBaseUrl(url) {
487
- auth.setBaseUrl(url);
488
- }
489
- // ── Tokens ──────────────────────────────────────────────────────────────
490
- getToken() {
491
- return auth.getToken();
492
- }
493
- setToken(token) {
494
- auth.setToken(token);
495
- }
496
- getRefreshToken() {
497
- return auth.getRefreshToken();
498
- }
499
- setRefreshToken(token) {
500
- auth.setRefreshToken(token);
501
- }
502
- clearToken() {
503
- auth.clearTokens();
504
- }
505
- isAuthenticated() {
506
- return auth.isAuthenticated();
507
- }
508
- // ── Locale / API key ────────────────────────────────────────────────────
509
- getLocale() {
510
- return auth.getLocale();
511
- }
512
- setLocale(locale) {
513
- auth.setLocale(locale);
514
- }
515
- getApiKey() {
516
- return auth.getApiKey();
517
- }
518
- setApiKey(key) {
519
- auth.setApiKey(key);
520
- }
521
- // ── 401 handling ────────────────────────────────────────────────────────
522
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
523
- onUnauthorized(cb) {
524
- auth.onUnauthorized(cb);
525
- }
526
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
527
- setRefreshHandler(fn) {
528
- auth.setRefreshHandler(fn);
529
- }
530
- };
531
-
532
- // src/_api/generated/_cfg_totp/api.ts
533
- var API3 = class {
534
- static {
535
- __name(this, "API");
536
- }
537
- logger;
538
- constructor(_baseUrl, opts = {}) {
539
- this.logger = new APILogger(opts.logger);
540
- if (_baseUrl) auth.setBaseUrl(_baseUrl);
541
- if (opts.locale !== void 0) auth.setLocale(opts.locale);
542
- if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
543
- if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
544
- }
545
- // ── Base URL ────────────────────────────────────────────────────────────
546
- getBaseUrl() {
547
- return auth.getBaseUrl();
548
- }
549
- setBaseUrl(url) {
550
- auth.setBaseUrl(url);
551
- }
552
- // ── Tokens ──────────────────────────────────────────────────────────────
553
- getToken() {
554
- return auth.getToken();
555
- }
556
- setToken(token) {
557
- auth.setToken(token);
558
- }
559
- getRefreshToken() {
560
- return auth.getRefreshToken();
561
- }
562
- setRefreshToken(token) {
563
- auth.setRefreshToken(token);
564
- }
565
- clearToken() {
566
- auth.clearTokens();
567
- }
568
- isAuthenticated() {
569
- return auth.isAuthenticated();
570
- }
571
- // ── Locale / API key ────────────────────────────────────────────────────
572
- getLocale() {
573
- return auth.getLocale();
574
- }
575
- setLocale(locale) {
576
- auth.setLocale(locale);
577
- }
578
- getApiKey() {
579
- return auth.getApiKey();
580
- }
581
- setApiKey(key) {
582
- auth.setApiKey(key);
583
- }
584
- // ── 401 handling ────────────────────────────────────────────────────────
585
- /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
586
- onUnauthorized(cb) {
587
- auth.onUnauthorized(cb);
588
- }
589
- /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
590
- setRefreshHandler(fn) {
591
- auth.setRefreshHandler(fn);
592
- }
593
- };
594
-
595
- // src/_api/generated/index.ts
596
- var CfgAccountsApi = new API();
597
- var CfgCentrifugoApi = new API2();
598
- var CfgTotpApi = new API3();
599
-
600
406
  // src/_api/generated/core/bodySerializer.gen.ts
407
+ var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
408
+ if (typeof value === "string" || value instanceof Blob) {
409
+ data.append(key, value);
410
+ } else if (value instanceof Date) {
411
+ data.append(key, value.toISOString());
412
+ } else {
413
+ data.append(key, JSON.stringify(value));
414
+ }
415
+ }, "serializeFormDataPair");
416
+ var formDataBodySerializer = {
417
+ bodySerializer: /* @__PURE__ */ __name((body) => {
418
+ const data = new FormData();
419
+ Object.entries(body).forEach(([key, value]) => {
420
+ if (value === void 0 || value === null) {
421
+ return;
422
+ }
423
+ if (Array.isArray(value)) {
424
+ value.forEach((v) => serializeFormDataPair(data, key, v));
425
+ } else {
426
+ serializeFormDataPair(data, key, value);
427
+ }
428
+ });
429
+ return data;
430
+ }, "bodySerializer")
431
+ };
601
432
  var jsonBodySerializer = {
602
433
  bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
603
434
  };
@@ -1398,16 +1229,59 @@ var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
1398
1229
  installAuthOnClient(client);
1399
1230
 
1400
1231
  // src/_api/generated/sdk.gen.ts
1401
- var Auth = class {
1232
+ var CfgAccountsApiKey = class {
1402
1233
  static {
1403
- __name(this, "Auth");
1234
+ __name(this, "CfgAccountsApiKey");
1404
1235
  }
1405
1236
  /**
1406
- * Refresh JWT token.
1237
+ * Get API key details
1238
+ *
1239
+ * Retrieve the current user's API key (masked) and metadata.
1407
1240
  */
1408
- static cfgAccountsTokenRefreshCreate(options) {
1241
+ static cfgAccountsApiKeyRetrieve(options) {
1242
+ return (options?.client ?? client).get({
1243
+ security: [{ scheme: "bearer", type: "http" }, {
1244
+ in: "cookie",
1245
+ name: "sessionid",
1246
+ type: "apiKey"
1247
+ }],
1248
+ url: "/cfg/accounts/api-key/",
1249
+ ...options
1250
+ });
1251
+ }
1252
+ /**
1253
+ * Regenerate API key
1254
+ *
1255
+ * Generate a new API key. The full key is returned only once.
1256
+ */
1257
+ static cfgAccountsApiKeyRegenerateCreate(options) {
1409
1258
  return (options.client ?? client).post({
1410
- url: "/cfg/accounts/token/refresh/",
1259
+ security: [{ scheme: "bearer", type: "http" }, {
1260
+ in: "cookie",
1261
+ name: "sessionid",
1262
+ type: "apiKey"
1263
+ }],
1264
+ url: "/cfg/accounts/api-key/regenerate/",
1265
+ ...options,
1266
+ headers: {
1267
+ "Content-Type": "application/json",
1268
+ ...options.headers
1269
+ }
1270
+ });
1271
+ }
1272
+ /**
1273
+ * Test API key
1274
+ *
1275
+ * Test whether an API key is valid without consuming it.
1276
+ */
1277
+ static cfgAccountsApiKeyTestCreate(options) {
1278
+ return (options.client ?? client).post({
1279
+ security: [{ scheme: "bearer", type: "http" }, {
1280
+ in: "cookie",
1281
+ name: "sessionid",
1282
+ type: "apiKey"
1283
+ }],
1284
+ url: "/cfg/accounts/api-key/test/",
1411
1285
  ...options,
1412
1286
  headers: {
1413
1287
  "Content-Type": "application/json",
@@ -1416,6 +1290,649 @@ var Auth = class {
1416
1290
  });
1417
1291
  }
1418
1292
  };
1293
+ var CfgAccountsOauth = class {
1294
+ static {
1295
+ __name(this, "CfgAccountsOauth");
1296
+ }
1297
+ /**
1298
+ * List OAuth connections
1299
+ *
1300
+ * Get all OAuth connections for the current user.
1301
+ */
1302
+ static cfgAccountsOauthConnectionsList(options) {
1303
+ return (options?.client ?? client).get({
1304
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1305
+ url: "/cfg/accounts/oauth/connections/",
1306
+ ...options
1307
+ });
1308
+ }
1309
+ /**
1310
+ * Disconnect OAuth provider
1311
+ *
1312
+ * Remove OAuth connection for the specified provider.
1313
+ */
1314
+ static cfgAccountsOauthDisconnectCreate(options) {
1315
+ return (options.client ?? client).post({
1316
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1317
+ url: "/cfg/accounts/oauth/disconnect/",
1318
+ ...options,
1319
+ headers: {
1320
+ "Content-Type": "application/json",
1321
+ ...options.headers
1322
+ }
1323
+ });
1324
+ }
1325
+ /**
1326
+ * Start GitHub OAuth
1327
+ *
1328
+ * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1329
+ */
1330
+ static cfgAccountsOauthGithubAuthorizeCreate(options) {
1331
+ return (options?.client ?? client).post({
1332
+ url: "/cfg/accounts/oauth/github/authorize/",
1333
+ ...options,
1334
+ headers: {
1335
+ "Content-Type": "application/json",
1336
+ ...options?.headers
1337
+ }
1338
+ });
1339
+ }
1340
+ /**
1341
+ * Complete GitHub OAuth
1342
+ *
1343
+ * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1344
+ */
1345
+ static cfgAccountsOauthGithubCallbackCreate(options) {
1346
+ return (options.client ?? client).post({
1347
+ url: "/cfg/accounts/oauth/github/callback/",
1348
+ ...options,
1349
+ headers: {
1350
+ "Content-Type": "application/json",
1351
+ ...options.headers
1352
+ }
1353
+ });
1354
+ }
1355
+ /**
1356
+ * List OAuth providers
1357
+ *
1358
+ * Get list of available OAuth providers for authentication.
1359
+ */
1360
+ static cfgAccountsOauthProvidersRetrieve(options) {
1361
+ return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1362
+ }
1363
+ };
1364
+ var CfgAccounts = class {
1365
+ static {
1366
+ __name(this, "CfgAccounts");
1367
+ }
1368
+ /**
1369
+ * Request OTP code to email.
1370
+ */
1371
+ static cfgAccountsOtpRequestCreate(options) {
1372
+ return (options.client ?? client).post({
1373
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1374
+ url: "/cfg/accounts/otp/request/",
1375
+ ...options,
1376
+ headers: {
1377
+ "Content-Type": "application/json",
1378
+ ...options.headers
1379
+ }
1380
+ });
1381
+ }
1382
+ /**
1383
+ * Verify OTP code and return JWT tokens or 2FA session.
1384
+ *
1385
+ * If user has 2FA enabled:
1386
+ * - Returns requires_2fa=True with session_id
1387
+ * - Client must complete 2FA verification at /cfg/totp/verify/
1388
+ *
1389
+ * If user has no 2FA:
1390
+ * - Returns JWT tokens and user data directly
1391
+ */
1392
+ static cfgAccountsOtpVerifyCreate(options) {
1393
+ return (options.client ?? client).post({
1394
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1395
+ url: "/cfg/accounts/otp/verify/",
1396
+ ...options,
1397
+ headers: {
1398
+ "Content-Type": "application/json",
1399
+ ...options.headers
1400
+ }
1401
+ });
1402
+ }
1403
+ };
1404
+ var CfgAccountsProfile = class {
1405
+ static {
1406
+ __name(this, "CfgAccountsProfile");
1407
+ }
1408
+ /**
1409
+ * Get current user profile
1410
+ *
1411
+ * Retrieve the current authenticated user's profile information.
1412
+ */
1413
+ static cfgAccountsProfileRetrieve(options) {
1414
+ return (options?.client ?? client).get({
1415
+ security: [{ scheme: "bearer", type: "http" }, {
1416
+ in: "cookie",
1417
+ name: "sessionid",
1418
+ type: "apiKey"
1419
+ }],
1420
+ url: "/cfg/accounts/profile/",
1421
+ ...options
1422
+ });
1423
+ }
1424
+ /**
1425
+ * Upload user avatar
1426
+ *
1427
+ * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1428
+ */
1429
+ static cfgAccountsProfileAvatarCreate(options) {
1430
+ return (options?.client ?? client).post({
1431
+ ...formDataBodySerializer,
1432
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1433
+ url: "/cfg/accounts/profile/avatar/",
1434
+ ...options,
1435
+ headers: {
1436
+ "Content-Type": null,
1437
+ ...options?.headers
1438
+ }
1439
+ });
1440
+ }
1441
+ /**
1442
+ * Delete user account
1443
+ *
1444
+ *
1445
+ * Permanently delete the current user's account.
1446
+ *
1447
+ * This operation:
1448
+ * - Deactivates the account (user cannot log in)
1449
+ * - Anonymizes personal data (GDPR compliance)
1450
+ * - Frees up the email address for re-registration
1451
+ * - Preserves audit trail
1452
+ *
1453
+ * The account can be restored by an administrator if needed.
1454
+ *
1455
+ */
1456
+ static cfgAccountsProfileDeleteCreate(options) {
1457
+ return (options?.client ?? client).post({
1458
+ security: [{ scheme: "bearer", type: "http" }, {
1459
+ in: "cookie",
1460
+ name: "sessionid",
1461
+ type: "apiKey"
1462
+ }],
1463
+ url: "/cfg/accounts/profile/delete/",
1464
+ ...options
1465
+ });
1466
+ }
1467
+ /**
1468
+ * Partial update user profile
1469
+ *
1470
+ * Partially update the current authenticated user's profile information. Supports avatar upload.
1471
+ */
1472
+ static cfgAccountsProfilePartialPartialUpdate(options) {
1473
+ return (options?.client ?? client).patch({
1474
+ security: [{ scheme: "bearer", type: "http" }, {
1475
+ in: "cookie",
1476
+ name: "sessionid",
1477
+ type: "apiKey"
1478
+ }],
1479
+ url: "/cfg/accounts/profile/partial/",
1480
+ ...options,
1481
+ headers: {
1482
+ "Content-Type": "application/json",
1483
+ ...options?.headers
1484
+ }
1485
+ });
1486
+ }
1487
+ /**
1488
+ * Partial update user profile
1489
+ *
1490
+ * Partially update the current authenticated user's profile information. Supports avatar upload.
1491
+ */
1492
+ static cfgAccountsProfilePartialUpdate(options) {
1493
+ return (options?.client ?? client).put({
1494
+ security: [{ scheme: "bearer", type: "http" }, {
1495
+ in: "cookie",
1496
+ name: "sessionid",
1497
+ type: "apiKey"
1498
+ }],
1499
+ url: "/cfg/accounts/profile/partial/",
1500
+ ...options,
1501
+ headers: {
1502
+ "Content-Type": "application/json",
1503
+ ...options?.headers
1504
+ }
1505
+ });
1506
+ }
1507
+ /**
1508
+ * Update user profile
1509
+ *
1510
+ * Update the current authenticated user's profile information.
1511
+ */
1512
+ static cfgAccountsProfileUpdatePartialUpdate(options) {
1513
+ return (options?.client ?? client).patch({
1514
+ security: [{ scheme: "bearer", type: "http" }, {
1515
+ in: "cookie",
1516
+ name: "sessionid",
1517
+ type: "apiKey"
1518
+ }],
1519
+ url: "/cfg/accounts/profile/update/",
1520
+ ...options,
1521
+ headers: {
1522
+ "Content-Type": "application/json",
1523
+ ...options?.headers
1524
+ }
1525
+ });
1526
+ }
1527
+ /**
1528
+ * Update user profile
1529
+ *
1530
+ * Update the current authenticated user's profile information.
1531
+ */
1532
+ static cfgAccountsProfileUpdateUpdate(options) {
1533
+ return (options?.client ?? client).put({
1534
+ security: [{ scheme: "bearer", type: "http" }, {
1535
+ in: "cookie",
1536
+ name: "sessionid",
1537
+ type: "apiKey"
1538
+ }],
1539
+ url: "/cfg/accounts/profile/update/",
1540
+ ...options,
1541
+ headers: {
1542
+ "Content-Type": "application/json",
1543
+ ...options?.headers
1544
+ }
1545
+ });
1546
+ }
1547
+ };
1548
+ var CfgAccountsAuth = class {
1549
+ static {
1550
+ __name(this, "CfgAccountsAuth");
1551
+ }
1552
+ /**
1553
+ * Refresh JWT token.
1554
+ */
1555
+ static cfgAccountsTokenRefreshCreate(options) {
1556
+ return (options.client ?? client).post({
1557
+ url: "/cfg/accounts/token/refresh/",
1558
+ ...options,
1559
+ headers: {
1560
+ "Content-Type": "application/json",
1561
+ ...options.headers
1562
+ }
1563
+ });
1564
+ }
1565
+ };
1566
+ var CfgCentrifugo = class {
1567
+ static {
1568
+ __name(this, "CfgCentrifugo");
1569
+ }
1570
+ /**
1571
+ * Get Centrifugo connection token
1572
+ *
1573
+ * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
1574
+ */
1575
+ static cfgCentrifugoAuthTokenRetrieve(options) {
1576
+ return (options?.client ?? client).get({
1577
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1578
+ url: "/cfg/centrifugo/auth/token/",
1579
+ ...options
1580
+ });
1581
+ }
1582
+ };
1583
+ var CfgTotpBackupCodes = class {
1584
+ static {
1585
+ __name(this, "CfgTotpBackupCodes");
1586
+ }
1587
+ /**
1588
+ * Get backup codes status for user.
1589
+ */
1590
+ static cfgTotpBackupCodesRetrieve(options) {
1591
+ return (options?.client ?? client).get({
1592
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1593
+ url: "/cfg/totp/backup-codes/",
1594
+ ...options
1595
+ });
1596
+ }
1597
+ /**
1598
+ * Regenerate backup codes.
1599
+ *
1600
+ * Requires TOTP code for verification.
1601
+ * Invalidates all existing codes.
1602
+ */
1603
+ static cfgTotpBackupCodesRegenerateCreate(options) {
1604
+ return (options.client ?? client).post({
1605
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1606
+ url: "/cfg/totp/backup-codes/regenerate/",
1607
+ ...options,
1608
+ headers: {
1609
+ "Content-Type": "application/json",
1610
+ ...options.headers
1611
+ }
1612
+ });
1613
+ }
1614
+ };
1615
+ var CfgTotp = class {
1616
+ static {
1617
+ __name(this, "CfgTotp");
1618
+ }
1619
+ /**
1620
+ * List all TOTP devices for user.
1621
+ */
1622
+ static cfgTotpDevicesRetrieve(options) {
1623
+ return (options?.client ?? client).get({
1624
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1625
+ url: "/cfg/totp/devices/",
1626
+ ...options
1627
+ });
1628
+ }
1629
+ /**
1630
+ * Delete a TOTP device.
1631
+ *
1632
+ * Requires verification code if removing the last/primary device.
1633
+ */
1634
+ static cfgTotpDevicesDestroy(options) {
1635
+ return (options.client ?? client).delete({
1636
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1637
+ url: "/cfg/totp/devices/{id}/",
1638
+ ...options
1639
+ });
1640
+ }
1641
+ /**
1642
+ * Completely disable 2FA for account.
1643
+ *
1644
+ * Requires verification code.
1645
+ */
1646
+ static cfgTotpDisableCreate(options) {
1647
+ return (options.client ?? client).post({
1648
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1649
+ url: "/cfg/totp/disable/",
1650
+ ...options,
1651
+ headers: {
1652
+ "Content-Type": "application/json",
1653
+ ...options.headers
1654
+ }
1655
+ });
1656
+ }
1657
+ };
1658
+ var CfgTotpSetup = class {
1659
+ static {
1660
+ __name(this, "CfgTotpSetup");
1661
+ }
1662
+ /**
1663
+ * Start 2FA setup process.
1664
+ *
1665
+ * Creates a new TOTP device and returns QR code for scanning.
1666
+ */
1667
+ static cfgTotpSetupCreate(options) {
1668
+ return (options?.client ?? client).post({
1669
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1670
+ url: "/cfg/totp/setup/",
1671
+ ...options,
1672
+ headers: {
1673
+ "Content-Type": "application/json",
1674
+ ...options?.headers
1675
+ }
1676
+ });
1677
+ }
1678
+ /**
1679
+ * Confirm 2FA setup with first valid code.
1680
+ *
1681
+ * Activates the device and generates backup codes.
1682
+ */
1683
+ static cfgTotpSetupConfirmCreate(options) {
1684
+ return (options.client ?? client).post({
1685
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1686
+ url: "/cfg/totp/setup/confirm/",
1687
+ ...options,
1688
+ headers: {
1689
+ "Content-Type": "application/json",
1690
+ ...options.headers
1691
+ }
1692
+ });
1693
+ }
1694
+ };
1695
+ var CfgTotpVerify = class {
1696
+ static {
1697
+ __name(this, "CfgTotpVerify");
1698
+ }
1699
+ /**
1700
+ * Verify TOTP code for 2FA session.
1701
+ *
1702
+ * Completes authentication and returns JWT tokens on success.
1703
+ */
1704
+ static cfgTotpVerifyCreate(options) {
1705
+ return (options.client ?? client).post({
1706
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1707
+ url: "/cfg/totp/verify/",
1708
+ ...options,
1709
+ headers: {
1710
+ "Content-Type": "application/json",
1711
+ ...options.headers
1712
+ }
1713
+ });
1714
+ }
1715
+ /**
1716
+ * Verify backup recovery code for 2FA session.
1717
+ *
1718
+ * Alternative verification method when TOTP device unavailable.
1719
+ */
1720
+ static cfgTotpVerifyBackupCreate(options) {
1721
+ return (options.client ?? client).post({
1722
+ security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1723
+ url: "/cfg/totp/verify/backup/",
1724
+ ...options,
1725
+ headers: {
1726
+ "Content-Type": "application/json",
1727
+ ...options.headers
1728
+ }
1729
+ });
1730
+ }
1731
+ };
1732
+
1733
+ // src/_api/generated/_cfg_accounts/api.ts
1734
+ var API = class {
1735
+ static {
1736
+ __name(this, "API");
1737
+ }
1738
+ logger;
1739
+ cfgAccountsApiKey = CfgAccountsApiKey;
1740
+ cfgAccountsOauth = CfgAccountsOauth;
1741
+ cfgAccounts = CfgAccounts;
1742
+ cfgAccountsProfile = CfgAccountsProfile;
1743
+ cfgAccountsAuth = CfgAccountsAuth;
1744
+ constructor(_baseUrl, opts = {}) {
1745
+ this.logger = new APILogger(opts.logger);
1746
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1747
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1748
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1749
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1750
+ }
1751
+ // ── Base URL ────────────────────────────────────────────────────────────
1752
+ getBaseUrl() {
1753
+ return auth.getBaseUrl();
1754
+ }
1755
+ setBaseUrl(url) {
1756
+ auth.setBaseUrl(url);
1757
+ }
1758
+ // ── Tokens ──────────────────────────────────────────────────────────────
1759
+ getToken() {
1760
+ return auth.getToken();
1761
+ }
1762
+ setToken(token) {
1763
+ auth.setToken(token);
1764
+ }
1765
+ getRefreshToken() {
1766
+ return auth.getRefreshToken();
1767
+ }
1768
+ setRefreshToken(token) {
1769
+ auth.setRefreshToken(token);
1770
+ }
1771
+ clearToken() {
1772
+ auth.clearTokens();
1773
+ }
1774
+ isAuthenticated() {
1775
+ return auth.isAuthenticated();
1776
+ }
1777
+ // ── Locale / API key ────────────────────────────────────────────────────
1778
+ getLocale() {
1779
+ return auth.getLocale();
1780
+ }
1781
+ setLocale(locale) {
1782
+ auth.setLocale(locale);
1783
+ }
1784
+ getApiKey() {
1785
+ return auth.getApiKey();
1786
+ }
1787
+ setApiKey(key) {
1788
+ auth.setApiKey(key);
1789
+ }
1790
+ // ── 401 handling ────────────────────────────────────────────────────────
1791
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
1792
+ onUnauthorized(cb) {
1793
+ auth.onUnauthorized(cb);
1794
+ }
1795
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
1796
+ setRefreshHandler(fn) {
1797
+ auth.setRefreshHandler(fn);
1798
+ }
1799
+ };
1800
+
1801
+ // src/_api/generated/_cfg_centrifugo/api.ts
1802
+ var API2 = class {
1803
+ static {
1804
+ __name(this, "API");
1805
+ }
1806
+ logger;
1807
+ cfgCentrifugo = CfgCentrifugo;
1808
+ constructor(_baseUrl, opts = {}) {
1809
+ this.logger = new APILogger(opts.logger);
1810
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1811
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1812
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1813
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1814
+ }
1815
+ // ── Base URL ────────────────────────────────────────────────────────────
1816
+ getBaseUrl() {
1817
+ return auth.getBaseUrl();
1818
+ }
1819
+ setBaseUrl(url) {
1820
+ auth.setBaseUrl(url);
1821
+ }
1822
+ // ── Tokens ──────────────────────────────────────────────────────────────
1823
+ getToken() {
1824
+ return auth.getToken();
1825
+ }
1826
+ setToken(token) {
1827
+ auth.setToken(token);
1828
+ }
1829
+ getRefreshToken() {
1830
+ return auth.getRefreshToken();
1831
+ }
1832
+ setRefreshToken(token) {
1833
+ auth.setRefreshToken(token);
1834
+ }
1835
+ clearToken() {
1836
+ auth.clearTokens();
1837
+ }
1838
+ isAuthenticated() {
1839
+ return auth.isAuthenticated();
1840
+ }
1841
+ // ── Locale / API key ────────────────────────────────────────────────────
1842
+ getLocale() {
1843
+ return auth.getLocale();
1844
+ }
1845
+ setLocale(locale) {
1846
+ auth.setLocale(locale);
1847
+ }
1848
+ getApiKey() {
1849
+ return auth.getApiKey();
1850
+ }
1851
+ setApiKey(key) {
1852
+ auth.setApiKey(key);
1853
+ }
1854
+ // ── 401 handling ────────────────────────────────────────────────────────
1855
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
1856
+ onUnauthorized(cb) {
1857
+ auth.onUnauthorized(cb);
1858
+ }
1859
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
1860
+ setRefreshHandler(fn) {
1861
+ auth.setRefreshHandler(fn);
1862
+ }
1863
+ };
1864
+
1865
+ // src/_api/generated/_cfg_totp/api.ts
1866
+ var API3 = class {
1867
+ static {
1868
+ __name(this, "API");
1869
+ }
1870
+ logger;
1871
+ cfgTotpBackupCodes = CfgTotpBackupCodes;
1872
+ cfgTotp = CfgTotp;
1873
+ cfgTotpSetup = CfgTotpSetup;
1874
+ cfgTotpVerify = CfgTotpVerify;
1875
+ constructor(_baseUrl, opts = {}) {
1876
+ this.logger = new APILogger(opts.logger);
1877
+ if (_baseUrl) auth.setBaseUrl(_baseUrl);
1878
+ if (opts.locale !== void 0) auth.setLocale(opts.locale);
1879
+ if (opts.apiKey !== void 0) auth.setApiKey(opts.apiKey);
1880
+ if (opts.withCredentials !== void 0) auth.setWithCredentials(opts.withCredentials);
1881
+ }
1882
+ // ── Base URL ────────────────────────────────────────────────────────────
1883
+ getBaseUrl() {
1884
+ return auth.getBaseUrl();
1885
+ }
1886
+ setBaseUrl(url) {
1887
+ auth.setBaseUrl(url);
1888
+ }
1889
+ // ── Tokens ──────────────────────────────────────────────────────────────
1890
+ getToken() {
1891
+ return auth.getToken();
1892
+ }
1893
+ setToken(token) {
1894
+ auth.setToken(token);
1895
+ }
1896
+ getRefreshToken() {
1897
+ return auth.getRefreshToken();
1898
+ }
1899
+ setRefreshToken(token) {
1900
+ auth.setRefreshToken(token);
1901
+ }
1902
+ clearToken() {
1903
+ auth.clearTokens();
1904
+ }
1905
+ isAuthenticated() {
1906
+ return auth.isAuthenticated();
1907
+ }
1908
+ // ── Locale / API key ────────────────────────────────────────────────────
1909
+ getLocale() {
1910
+ return auth.getLocale();
1911
+ }
1912
+ setLocale(locale) {
1913
+ auth.setLocale(locale);
1914
+ }
1915
+ getApiKey() {
1916
+ return auth.getApiKey();
1917
+ }
1918
+ setApiKey(key) {
1919
+ auth.setApiKey(key);
1920
+ }
1921
+ // ── 401 handling ────────────────────────────────────────────────────────
1922
+ /** Fired only on terminal 401 (after refresh+retry path is exhausted). */
1923
+ onUnauthorized(cb) {
1924
+ auth.onUnauthorized(cb);
1925
+ }
1926
+ /** Provide a refresh strategy. See `auth.setRefreshHandler` for the contract. */
1927
+ setRefreshHandler(fn) {
1928
+ auth.setRefreshHandler(fn);
1929
+ }
1930
+ };
1931
+
1932
+ // src/_api/generated/index.ts
1933
+ var CfgAccountsApi = new API();
1934
+ var CfgCentrifugoApi = new API2();
1935
+ var CfgTotpApi = new API3();
1419
1936
 
1420
1937
  // src/auth/utils/logger.ts
1421
1938
  import { createConsola as createConsola2 } from "consola";
@@ -1459,7 +1976,7 @@ async function refreshAccessToken() {
1459
1976
  onTokenRefreshed(null);
1460
1977
  return null;
1461
1978
  }
1462
- const result = await Auth.cfgAccountsTokenRefreshCreate({
1979
+ const result = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({
1463
1980
  body: { refresh: refreshToken },
1464
1981
  throwOnError: true
1465
1982
  });