@djangocfg/api 2.1.426 → 2.1.428

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 (41) hide show
  1. package/README.md +56 -0
  2. package/dist/auth-server.cjs +248 -32
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +248 -32
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +271 -29
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.mjs +271 -29
  9. package/dist/auth.mjs.map +1 -1
  10. package/dist/clients.cjs +222 -25
  11. package/dist/clients.cjs.map +1 -1
  12. package/dist/clients.d.cts +35 -28
  13. package/dist/clients.d.ts +35 -28
  14. package/dist/clients.mjs +222 -25
  15. package/dist/clients.mjs.map +1 -1
  16. package/dist/hooks.cjs +117 -4
  17. package/dist/hooks.cjs.map +1 -1
  18. package/dist/hooks.mjs +117 -4
  19. package/dist/hooks.mjs.map +1 -1
  20. package/dist/index.cjs +277 -26
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +98 -29
  23. package/dist/index.d.ts +98 -29
  24. package/dist/index.mjs +277 -26
  25. package/dist/index.mjs.map +1 -1
  26. package/package.json +2 -2
  27. package/src/_api/generated/client/index.ts +1 -0
  28. package/src/_api/generated/client/utils.gen.ts +2 -2
  29. package/src/_api/generated/client.gen.ts +2 -2
  30. package/src/_api/generated/core/auth.gen.ts +7 -0
  31. package/src/_api/generated/core/params.gen.ts +10 -8
  32. package/src/_api/generated/core/pathSerializer.gen.ts +6 -6
  33. package/src/_api/generated/core/queryKeySerializer.gen.ts +1 -1
  34. package/src/_api/generated/core/utils.gen.ts +4 -4
  35. package/src/_api/generated/helpers/auth.ts +127 -1
  36. package/src/_api/generated/sdk.gen.ts +149 -53
  37. package/src/auth/context/AuthContext.tsx +8 -0
  38. package/src/auth/utils/env.ts +18 -0
  39. package/src/auth/utils/logger.ts +11 -4
  40. package/src/index.ts +12 -0
  41. package/src/log-control.ts +81 -0
@@ -313,6 +313,99 @@ async function tryRefresh() {
313
313
  return _refreshInflight;
314
314
  }
315
315
  __name(tryRefresh, "tryRefresh");
316
+ function dpopEnabled() {
317
+ try {
318
+ return typeof process !== "undefined" && process.env?.NEXT_PUBLIC_DPOP_ENABLED === "true";
319
+ } catch {
320
+ return false;
321
+ }
322
+ }
323
+ __name(dpopEnabled, "dpopEnabled");
324
+ var _DPOP_DB = "cfg-auth";
325
+ var _DPOP_STORE = "keys";
326
+ var _DPOP_KEY_ID = "dpop-ec-p256";
327
+ function _idbOpen() {
328
+ return new Promise((resolve, reject) => {
329
+ const req = indexedDB.open(_DPOP_DB, 1);
330
+ req.onupgradeneeded = () => req.result.createObjectStore(_DPOP_STORE);
331
+ req.onsuccess = () => resolve(req.result);
332
+ req.onerror = () => reject(req.error);
333
+ });
334
+ }
335
+ __name(_idbOpen, "_idbOpen");
336
+ function _idbGet(key) {
337
+ return _idbOpen().then((db) => new Promise((resolve, reject) => {
338
+ const tx = db.transaction(_DPOP_STORE, "readonly");
339
+ const req = tx.objectStore(_DPOP_STORE).get(key);
340
+ req.onsuccess = () => resolve(req.result);
341
+ req.onerror = () => reject(req.error);
342
+ }));
343
+ }
344
+ __name(_idbGet, "_idbGet");
345
+ function _idbPut(key, value) {
346
+ return _idbOpen().then((db) => new Promise((resolve, reject) => {
347
+ const tx = db.transaction(_DPOP_STORE, "readwrite");
348
+ tx.objectStore(_DPOP_STORE).put(value, key);
349
+ tx.oncomplete = () => resolve();
350
+ tx.onerror = () => reject(tx.error);
351
+ }));
352
+ }
353
+ __name(_idbPut, "_idbPut");
354
+ var _dpopKeyPromise = null;
355
+ function _getDpopKeyPair() {
356
+ if (_dpopKeyPromise) return _dpopKeyPromise;
357
+ _dpopKeyPromise = (async () => {
358
+ const existing = await _idbGet(_DPOP_KEY_ID).catch(() => void 0);
359
+ if (existing) return existing;
360
+ const pair = await crypto.subtle.generateKey(
361
+ { name: "ECDSA", namedCurve: "P-256" },
362
+ false,
363
+ // extractable:false — JS can sign but never export the private key
364
+ ["sign"]
365
+ );
366
+ await _idbPut(_DPOP_KEY_ID, pair).catch(() => {
367
+ });
368
+ return pair;
369
+ })();
370
+ return _dpopKeyPromise;
371
+ }
372
+ __name(_getDpopKeyPair, "_getDpopKeyPair");
373
+ function _b64urlFromBytes(bytes) {
374
+ const arr = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
375
+ let s = "";
376
+ for (let i = 0; i < arr.length; i++) s += String.fromCharCode(arr[i]);
377
+ return btoa(s).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
378
+ }
379
+ __name(_b64urlFromBytes, "_b64urlFromBytes");
380
+ function _b64urlFromString(str) {
381
+ return _b64urlFromBytes(new TextEncoder().encode(str));
382
+ }
383
+ __name(_b64urlFromString, "_b64urlFromString");
384
+ async function _publicJwk(pub) {
385
+ const jwk = await crypto.subtle.exportKey("jwk", pub);
386
+ return { kty: "EC", crv: "P-256", x: jwk.x, y: jwk.y };
387
+ }
388
+ __name(_publicJwk, "_publicJwk");
389
+ async function _makeDpopProof(method, url) {
390
+ try {
391
+ const pair = await _getDpopKeyPair();
392
+ const jwk = await _publicJwk(pair.publicKey);
393
+ const header = { typ: "dpop+jwt", alg: "ES256", jwk };
394
+ const htu = url.split("#")[0].split("?")[0];
395
+ const jti = crypto.randomUUID && crypto.randomUUID() || _b64urlFromBytes(crypto.getRandomValues(new Uint8Array(16)));
396
+ const payload = { htm: method.toUpperCase(), htu, iat: Math.floor(Date.now() / 1e3), jti };
397
+ const signingInput = `${_b64urlFromString(JSON.stringify(header))}.${_b64urlFromString(JSON.stringify(payload))}`;
398
+ const sig = await crypto.subtle.sign(
399
+ { name: "ECDSA", hash: "SHA-256" },
400
+ pair.privateKey,
401
+ new TextEncoder().encode(signingInput)
402
+ );
403
+ return `${signingInput}.${_b64urlFromBytes(sig)}`;
404
+ } catch {
405
+ return null;
406
+ }
407
+ }
408
+ __name(_makeDpopProof, "_makeDpopProof");
316
409
  function installAuthOnClient(client2) {
317
410
  if (_client) return;
318
411
  _client = client2;
@@ -320,7 +413,7 @@ function installAuthOnClient(client2) {
320
413
  baseUrl: auth.getBaseUrl(),
321
414
  credentials: _withCredentials ? "include" : "same-origin"
322
415
  });
323
- client2.interceptors.request.use((request) => {
416
+ client2.interceptors.request.use(async (request) => {
324
417
  const token = auth.getToken();
325
418
  if (token) request.headers.set("Authorization", `Bearer ${token}`);
326
419
  const locale = auth.getLocale();
@@ -333,6 +426,10 @@ function installAuthOnClient(client2) {
333
426
  } catch {
334
427
  }
335
428
  request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
429
+ if (dpopEnabled() && typeof window !== "undefined") {
430
+ const proof = await _makeDpopProof(request.method, request.url);
431
+ if (proof) request.headers.set("DPoP", proof);
432
+ }
336
433
  return request;
337
434
  });
338
435
  client2.interceptors.error.use((err, res, req) => {
@@ -366,6 +463,10 @@ function installAuthOnClient(client2) {
366
463
  const retry = request.clone();
367
464
  retry.headers.set("Authorization", `Bearer ${newToken}`);
368
465
  retry.headers.set(RETRY_MARKER, "1");
466
+ if (dpopEnabled() && typeof window !== "undefined") {
467
+ const proof = await _makeDpopProof(retry.method, retry.url);
468
+ if (proof) retry.headers.set("DPoP", proof);
469
+ }
369
470
  try {
370
471
  const retried = await fetch(retry);
371
472
  if (retried.status === 401 && _onUnauthorized) {
@@ -1315,7 +1416,11 @@ var CfgAccountsApiKey = class {
1315
1416
  static cfgAccountsApiKeyRetrieve(options) {
1316
1417
  return (options?.client ?? client).get({
1317
1418
  security: [
1318
- { scheme: "bearer", type: "http" },
1419
+ {
1420
+ key: "jwtAuth",
1421
+ scheme: "bearer",
1422
+ type: "http"
1423
+ },
1319
1424
  {
1320
1425
  in: "cookie",
1321
1426
  name: "sessionid",
@@ -1335,7 +1440,11 @@ var CfgAccountsApiKey = class {
1335
1440
  static cfgAccountsApiKeyRegenerateCreate(options) {
1336
1441
  return (options.client ?? client).post({
1337
1442
  security: [
1338
- { scheme: "bearer", type: "http" },
1443
+ {
1444
+ key: "jwtAuth",
1445
+ scheme: "bearer",
1446
+ type: "http"
1447
+ },
1339
1448
  {
1340
1449
  in: "cookie",
1341
1450
  name: "sessionid",
@@ -1359,7 +1468,11 @@ var CfgAccountsApiKey = class {
1359
1468
  static cfgAccountsApiKeyTestCreate(options) {
1360
1469
  return (options.client ?? client).post({
1361
1470
  security: [
1362
- { scheme: "bearer", type: "http" },
1471
+ {
1472
+ key: "jwtAuth",
1473
+ scheme: "bearer",
1474
+ type: "http"
1475
+ },
1363
1476
  {
1364
1477
  in: "cookie",
1365
1478
  name: "sessionid",
@@ -1387,7 +1500,11 @@ var CfgAccountsOauth = class {
1387
1500
  */
1388
1501
  static cfgAccountsOauthConnectionsList(options) {
1389
1502
  return (options?.client ?? client).get({
1390
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1503
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1504
+ key: "jwtAuthWithLastLogin",
1505
+ scheme: "bearer",
1506
+ type: "http"
1507
+ }],
1391
1508
  url: "/cfg/accounts/oauth/connections/",
1392
1509
  ...options
1393
1510
  });
@@ -1399,7 +1516,11 @@ var CfgAccountsOauth = class {
1399
1516
  */
1400
1517
  static cfgAccountsOauthDisconnectCreate(options) {
1401
1518
  return (options.client ?? client).post({
1402
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1519
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1520
+ key: "jwtAuthWithLastLogin",
1521
+ scheme: "bearer",
1522
+ type: "http"
1523
+ }],
1403
1524
  url: "/cfg/accounts/oauth/disconnect/",
1404
1525
  ...options,
1405
1526
  headers: {
@@ -1456,7 +1577,11 @@ var CfgAccounts = class {
1456
1577
  */
1457
1578
  static cfgAccountsOtpRequestCreate(options) {
1458
1579
  return (options.client ?? client).post({
1459
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1580
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1581
+ key: "jwtAuthWithLastLogin",
1582
+ scheme: "bearer",
1583
+ type: "http"
1584
+ }],
1460
1585
  url: "/cfg/accounts/otp/request/",
1461
1586
  ...options,
1462
1587
  headers: {
@@ -1477,7 +1602,11 @@ var CfgAccounts = class {
1477
1602
  */
1478
1603
  static cfgAccountsOtpVerifyCreate(options) {
1479
1604
  return (options.client ?? client).post({
1480
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1605
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1606
+ key: "jwtAuthWithLastLogin",
1607
+ scheme: "bearer",
1608
+ type: "http"
1609
+ }],
1481
1610
  url: "/cfg/accounts/otp/verify/",
1482
1611
  ...options,
1483
1612
  headers: {
@@ -1498,7 +1627,11 @@ var CfgAccountsProfile = class {
1498
1627
  */
1499
1628
  static cfgAccountsProfileRetrieve(options) {
1500
1629
  return (options?.client ?? client).get({
1501
- security: [{ scheme: "bearer", type: "http" }, {
1630
+ security: [{
1631
+ key: "jwtAuth",
1632
+ scheme: "bearer",
1633
+ type: "http"
1634
+ }, {
1502
1635
  in: "cookie",
1503
1636
  name: "sessionid",
1504
1637
  type: "apiKey"
@@ -1515,7 +1648,11 @@ var CfgAccountsProfile = class {
1515
1648
  static cfgAccountsProfileAvatarCreate(options) {
1516
1649
  return (options?.client ?? client).post({
1517
1650
  ...formDataBodySerializer,
1518
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1651
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1652
+ key: "jwtAuthWithLastLogin",
1653
+ scheme: "bearer",
1654
+ type: "http"
1655
+ }],
1519
1656
  url: "/cfg/accounts/profile/avatar/",
1520
1657
  ...options,
1521
1658
  headers: {
@@ -1541,7 +1678,11 @@ var CfgAccountsProfile = class {
1541
1678
  */
1542
1679
  static cfgAccountsProfileDeleteCreate(options) {
1543
1680
  return (options?.client ?? client).post({
1544
- security: [{ scheme: "bearer", type: "http" }, {
1681
+ security: [{
1682
+ key: "jwtAuth",
1683
+ scheme: "bearer",
1684
+ type: "http"
1685
+ }, {
1545
1686
  in: "cookie",
1546
1687
  name: "sessionid",
1547
1688
  type: "apiKey"
@@ -1557,7 +1698,11 @@ var CfgAccountsProfile = class {
1557
1698
  */
1558
1699
  static cfgAccountsProfilePartialPartialUpdate(options) {
1559
1700
  return (options?.client ?? client).patch({
1560
- security: [{ scheme: "bearer", type: "http" }, {
1701
+ security: [{
1702
+ key: "jwtAuth",
1703
+ scheme: "bearer",
1704
+ type: "http"
1705
+ }, {
1561
1706
  in: "cookie",
1562
1707
  name: "sessionid",
1563
1708
  type: "apiKey"
@@ -1577,7 +1722,11 @@ var CfgAccountsProfile = class {
1577
1722
  */
1578
1723
  static cfgAccountsProfilePartialUpdate(options) {
1579
1724
  return (options?.client ?? client).put({
1580
- security: [{ scheme: "bearer", type: "http" }, {
1725
+ security: [{
1726
+ key: "jwtAuth",
1727
+ scheme: "bearer",
1728
+ type: "http"
1729
+ }, {
1581
1730
  in: "cookie",
1582
1731
  name: "sessionid",
1583
1732
  type: "apiKey"
@@ -1597,7 +1746,11 @@ var CfgAccountsProfile = class {
1597
1746
  */
1598
1747
  static cfgAccountsProfileUpdatePartialUpdate(options) {
1599
1748
  return (options?.client ?? client).patch({
1600
- security: [{ scheme: "bearer", type: "http" }, {
1749
+ security: [{
1750
+ key: "jwtAuth",
1751
+ scheme: "bearer",
1752
+ type: "http"
1753
+ }, {
1601
1754
  in: "cookie",
1602
1755
  name: "sessionid",
1603
1756
  type: "apiKey"
@@ -1617,7 +1770,11 @@ var CfgAccountsProfile = class {
1617
1770
  */
1618
1771
  static cfgAccountsProfileUpdateUpdate(options) {
1619
1772
  return (options?.client ?? client).put({
1620
- security: [{ scheme: "bearer", type: "http" }, {
1773
+ security: [{
1774
+ key: "jwtAuth",
1775
+ scheme: "bearer",
1776
+ type: "http"
1777
+ }, {
1621
1778
  in: "cookie",
1622
1779
  name: "sessionid",
1623
1780
  type: "apiKey"
@@ -1660,7 +1817,11 @@ var CfgCentrifugo = class {
1660
1817
  */
1661
1818
  static cfgCentrifugoAuthTokenRetrieve(options) {
1662
1819
  return (options?.client ?? client).get({
1663
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1820
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1821
+ key: "jwtAuthWithLastLogin",
1822
+ scheme: "bearer",
1823
+ type: "http"
1824
+ }],
1664
1825
  url: "/cfg/centrifugo/auth/token/",
1665
1826
  ...options
1666
1827
  });
@@ -1675,7 +1836,11 @@ var CfgTotpBackupCodes = class {
1675
1836
  */
1676
1837
  static cfgTotpBackupCodesRetrieve(options) {
1677
1838
  return (options?.client ?? client).get({
1678
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1839
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1840
+ key: "jwtAuthWithLastLogin",
1841
+ scheme: "bearer",
1842
+ type: "http"
1843
+ }],
1679
1844
  url: "/cfg/totp/backup-codes/",
1680
1845
  ...options
1681
1846
  });
@@ -1688,7 +1853,11 @@ var CfgTotpBackupCodes = class {
1688
1853
  */
1689
1854
  static cfgTotpBackupCodesRegenerateCreate(options) {
1690
1855
  return (options.client ?? client).post({
1691
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1856
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1857
+ key: "jwtAuthWithLastLogin",
1858
+ scheme: "bearer",
1859
+ type: "http"
1860
+ }],
1692
1861
  url: "/cfg/totp/backup-codes/regenerate/",
1693
1862
  ...options,
1694
1863
  headers: {
@@ -1707,7 +1876,11 @@ var CfgTotp = class {
1707
1876
  */
1708
1877
  static cfgTotpDevicesRetrieve(options) {
1709
1878
  return (options?.client ?? client).get({
1710
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1879
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1880
+ key: "jwtAuthWithLastLogin",
1881
+ scheme: "bearer",
1882
+ type: "http"
1883
+ }],
1711
1884
  url: "/cfg/totp/devices/",
1712
1885
  ...options
1713
1886
  });
@@ -1719,7 +1892,11 @@ var CfgTotp = class {
1719
1892
  */
1720
1893
  static cfgTotpDevicesDestroy(options) {
1721
1894
  return (options.client ?? client).delete({
1722
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1895
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1896
+ key: "jwtAuthWithLastLogin",
1897
+ scheme: "bearer",
1898
+ type: "http"
1899
+ }],
1723
1900
  url: "/cfg/totp/devices/{id}/",
1724
1901
  ...options
1725
1902
  });
@@ -1731,7 +1908,11 @@ var CfgTotp = class {
1731
1908
  */
1732
1909
  static cfgTotpDisableCreate(options) {
1733
1910
  return (options.client ?? client).post({
1734
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1911
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1912
+ key: "jwtAuthWithLastLogin",
1913
+ scheme: "bearer",
1914
+ type: "http"
1915
+ }],
1735
1916
  url: "/cfg/totp/disable/",
1736
1917
  ...options,
1737
1918
  headers: {
@@ -1752,7 +1933,11 @@ var CfgTotpSetup = class {
1752
1933
  */
1753
1934
  static cfgTotpSetupCreate(options) {
1754
1935
  return (options?.client ?? client).post({
1755
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1936
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1937
+ key: "jwtAuthWithLastLogin",
1938
+ scheme: "bearer",
1939
+ type: "http"
1940
+ }],
1756
1941
  url: "/cfg/totp/setup/",
1757
1942
  ...options,
1758
1943
  headers: {
@@ -1768,7 +1953,11 @@ var CfgTotpSetup = class {
1768
1953
  */
1769
1954
  static cfgTotpSetupConfirmCreate(options) {
1770
1955
  return (options.client ?? client).post({
1771
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1956
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1957
+ key: "jwtAuthWithLastLogin",
1958
+ scheme: "bearer",
1959
+ type: "http"
1960
+ }],
1772
1961
  url: "/cfg/totp/setup/confirm/",
1773
1962
  ...options,
1774
1963
  headers: {
@@ -1789,7 +1978,11 @@ var CfgTotpVerify = class {
1789
1978
  */
1790
1979
  static cfgTotpVerifyCreate(options) {
1791
1980
  return (options.client ?? client).post({
1792
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
1981
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
1982
+ key: "jwtAuthWithLastLogin",
1983
+ scheme: "bearer",
1984
+ type: "http"
1985
+ }],
1793
1986
  url: "/cfg/totp/verify/",
1794
1987
  ...options,
1795
1988
  headers: {
@@ -1805,7 +1998,11 @@ var CfgTotpVerify = class {
1805
1998
  */
1806
1999
  static cfgTotpVerifyBackupCreate(options) {
1807
2000
  return (options.client ?? client).post({
1808
- security: [{ name: "X-API-Key", type: "apiKey" }, { scheme: "bearer", type: "http" }],
2001
+ security: [{ name: "X-API-Key", type: "apiKey" }, {
2002
+ key: "jwtAuthWithLastLogin",
2003
+ scheme: "bearer",
2004
+ type: "http"
2005
+ }],
1809
2006
  url: "/cfg/totp/verify/backup/",
1810
2007
  ...options,
1811
2008
  headers: {
@@ -2020,19 +2217,38 @@ var CfgAccountsApi = new API();
2020
2217
  var CfgCentrifugoApi = new API2();
2021
2218
  var CfgTotpApi = new API3();
2022
2219
 
2023
- // src/auth/utils/logger.ts
2024
- import { createConsola as createConsola2 } from "consola";
2025
-
2026
2220
  // src/auth/utils/env.ts
2027
2221
  var isDev = process.env.NODE_ENV === "development";
2222
+ var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
2223
+ var dpopEnabled2 = process.env.NEXT_PUBLIC_DPOP_ENABLED === "true";
2224
+
2225
+ // src/log-control.ts
2226
+ var verboseByDefault = isDev || isStaticBuild;
2227
+ var DEFAULT_LEVEL = verboseByDefault ? 4 : 1;
2228
+ var _level = DEFAULT_LEVEL;
2229
+ var _subscribers = /* @__PURE__ */ new Set();
2230
+ function getLogLevel() {
2231
+ return _level;
2232
+ }
2233
+ __name(getLogLevel, "getLogLevel");
2234
+ function onLogLevelChange(fn) {
2235
+ _subscribers.add(fn);
2236
+ try {
2237
+ fn(_level);
2238
+ } catch {
2239
+ }
2240
+ return () => _subscribers.delete(fn);
2241
+ }
2242
+ __name(onLogLevelChange, "onLogLevelChange");
2028
2243
 
2029
2244
  // src/auth/utils/logger.ts
2030
- var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
2031
- var showLogs = isDev || isStaticBuild;
2245
+ import { createConsola as createConsola2 } from "consola";
2032
2246
  var logger = createConsola2({
2033
- level: showLogs ? 4 : 1
2034
- // dev: debug, production: errors only
2247
+ level: getLogLevel()
2035
2248
  }).withTag("api");
2249
+ onLogLevelChange((level) => {
2250
+ logger.level = level;
2251
+ });
2036
2252
  var authLogger = logger.withTag("auth");
2037
2253
 
2038
2254
  // src/auth/middlewares/tokenRefresh.ts