@djangocfg/api 2.1.441 → 2.1.443

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/dist/auth-server.cjs +53 -119
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +53 -119
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +222 -277
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.mjs +222 -277
  8. package/dist/auth.mjs.map +1 -1
  9. package/dist/clients.cjs +53 -119
  10. package/dist/clients.cjs.map +1 -1
  11. package/dist/clients.d.cts +50 -1
  12. package/dist/clients.d.ts +50 -1
  13. package/dist/clients.mjs +53 -119
  14. package/dist/clients.mjs.map +1 -1
  15. package/dist/hooks.cjs +102 -20
  16. package/dist/hooks.cjs.map +1 -1
  17. package/dist/hooks.d.cts +13 -0
  18. package/dist/hooks.d.ts +13 -0
  19. package/dist/hooks.mjs +102 -20
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.cjs +53 -119
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +70 -5
  24. package/dist/index.d.ts +70 -5
  25. package/dist/index.mjs +53 -119
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +2 -2
  28. package/src/_api/generated/_cfg_accounts/hooks/index.ts +1 -0
  29. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts +64 -0
  30. package/src/_api/generated/_cfg_accounts/openapi.json +92 -15
  31. package/src/_api/generated/_cfg_accounts/schemas/APIKeyReveal.ts +13 -0
  32. package/src/_api/generated/_cfg_accounts/schemas/index.ts +1 -0
  33. package/src/_api/generated/_cfg_centrifugo/openapi.json +0 -5
  34. package/src/_api/generated/_cfg_totp/openapi.json +0 -5
  35. package/src/_api/generated/client/index.ts +1 -0
  36. package/src/_api/generated/core/params.gen.ts +18 -11
  37. package/src/_api/generated/core/types.gen.ts +6 -0
  38. package/src/_api/generated/openapi.json +92 -15
  39. package/src/_api/generated/sdk.gen.ts +57 -122
  40. package/src/_api/generated/types.gen.ts +38 -0
  41. package/src/hooks/useApiKey.ts +30 -2
package/dist/hooks.cjs CHANGED
@@ -1317,11 +1317,7 @@ var CfgAccountsApiKey = class {
1317
1317
  static cfgAccountsApiKeyRetrieve(options) {
1318
1318
  return (options?.client ?? client).get({
1319
1319
  security: [
1320
- {
1321
- key: "jwtAuth",
1322
- scheme: "bearer",
1323
- type: "http"
1324
- },
1320
+ { scheme: "bearer", type: "http" },
1325
1321
  {
1326
1322
  in: "cookie",
1327
1323
  name: "sessionid",
@@ -1341,11 +1337,31 @@ var CfgAccountsApiKey = class {
1341
1337
  static cfgAccountsApiKeyRegenerateCreate(options) {
1342
1338
  return (options.client ?? client).post({
1343
1339
  security: [
1340
+ { scheme: "bearer", type: "http" },
1344
1341
  {
1345
- key: "jwtAuth",
1346
- scheme: "bearer",
1347
- type: "http"
1342
+ in: "cookie",
1343
+ name: "sessionid",
1344
+ type: "apiKey"
1348
1345
  },
1346
+ { name: "X-API-Key", type: "apiKey" }
1347
+ ],
1348
+ url: "/cfg/accounts/api-key/regenerate/",
1349
+ ...options,
1350
+ headers: {
1351
+ "Content-Type": "application/json",
1352
+ ...options.headers
1353
+ }
1354
+ });
1355
+ }
1356
+ /**
1357
+ * Reveal API key
1358
+ *
1359
+ * Return the current full API key WITHOUT rotating it. The same durable value every one of the user's agents uses — for the signed-in user to copy and paste into agent onboarding. Default GET stays masked; this is the explicit reveal action.
1360
+ */
1361
+ static cfgAccountsApiKeyRevealCreate(options) {
1362
+ return (options.client ?? client).post({
1363
+ security: [
1364
+ { scheme: "bearer", type: "http" },
1349
1365
  {
1350
1366
  in: "cookie",
1351
1367
  name: "sessionid",
@@ -1353,7 +1369,7 @@ var CfgAccountsApiKey = class {
1353
1369
  },
1354
1370
  { name: "X-API-Key", type: "apiKey" }
1355
1371
  ],
1356
- url: "/cfg/accounts/api-key/regenerate/",
1372
+ url: "/cfg/accounts/api-key/reveal/",
1357
1373
  ...options,
1358
1374
  headers: {
1359
1375
  "Content-Type": "application/json",
@@ -1369,11 +1385,7 @@ var CfgAccountsApiKey = class {
1369
1385
  static cfgAccountsApiKeyTestCreate(options) {
1370
1386
  return (options.client ?? client).post({
1371
1387
  security: [
1372
- {
1373
- key: "jwtAuth",
1374
- scheme: "bearer",
1375
- type: "http"
1376
- },
1388
+ { scheme: "bearer", type: "http" },
1377
1389
  {
1378
1390
  in: "cookie",
1379
1391
  name: "sessionid",
@@ -1505,19 +1517,77 @@ function useCfgAccountsApiKeyRetrieve(args, config) {
1505
1517
  }
1506
1518
  __name(useCfgAccountsApiKeyRetrieve, "useCfgAccountsApiKeyRetrieve");
1507
1519
 
1508
- // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
1520
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts
1509
1521
  var import_mutation2 = __toESM(require("swr/mutation"), 1);
1510
1522
 
1511
- // src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts
1523
+ // src/_api/generated/_cfg_accounts/schemas/APIKeyReveal.ts
1512
1524
  var import_zod3 = require("zod");
1513
- var APIKeyTestResultSchema = import_zod3.z.object({
1514
- valid: import_zod3.z.boolean(),
1515
- user_id: import_zod3.z.string().nullable()
1525
+ var APIKeyRevealSchema = import_zod3.z.object({
1526
+ key: import_zod3.z.string(),
1527
+ created_at: import_zod3.z.string().datetime({ offset: true }),
1528
+ reissued_at: import_zod3.z.string().datetime({ offset: true }).nullable()
1529
+ });
1530
+
1531
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts
1532
+ function useCfgAccountsApiKeyRevealCreate(config) {
1533
+ return (0, import_mutation2.default)(
1534
+ ["cfg_accounts_api_key_reveal_create"],
1535
+ async (_key, { arg }) => {
1536
+ const res = await CfgAccountsApiKey.cfgAccountsApiKeyRevealCreate({ ...arg, throwOnError: true });
1537
+ const data = res.data;
1538
+ const parsed = APIKeyRevealSchema.safeParse(data);
1539
+ if (!parsed.success) {
1540
+ console.warn(
1541
+ "[zod] response did not match schema",
1542
+ {
1543
+ operation: "cfg_accounts_api_key_reveal_create",
1544
+ method: "POST",
1545
+ path: "/cfg/accounts/api-key/reveal/",
1546
+ issues: parsed.error.issues,
1547
+ data
1548
+ }
1549
+ );
1550
+ if (typeof window !== "undefined") {
1551
+ try {
1552
+ window.dispatchEvent(
1553
+ new CustomEvent("zod-validation-error", {
1554
+ detail: {
1555
+ operation: "cfg_accounts_api_key_reveal_create",
1556
+ method: "POST",
1557
+ path: "/cfg/accounts/api-key/reveal/",
1558
+ issues: parsed.error.issues,
1559
+ data,
1560
+ timestamp: /* @__PURE__ */ new Date()
1561
+ },
1562
+ bubbles: true,
1563
+ cancelable: false
1564
+ })
1565
+ );
1566
+ } catch {
1567
+ }
1568
+ }
1569
+ return data;
1570
+ }
1571
+ return parsed.data;
1572
+ },
1573
+ config
1574
+ );
1575
+ }
1576
+ __name(useCfgAccountsApiKeyRevealCreate, "useCfgAccountsApiKeyRevealCreate");
1577
+
1578
+ // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
1579
+ var import_mutation3 = __toESM(require("swr/mutation"), 1);
1580
+
1581
+ // src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts
1582
+ var import_zod4 = require("zod");
1583
+ var APIKeyTestResultSchema = import_zod4.z.object({
1584
+ valid: import_zod4.z.boolean(),
1585
+ user_id: import_zod4.z.string().nullable()
1516
1586
  });
1517
1587
 
1518
1588
  // src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
1519
1589
  function useCfgAccountsApiKeyTestCreate(config) {
1520
- return (0, import_mutation2.default)(
1590
+ return (0, import_mutation3.default)(
1521
1591
  ["cfg_accounts_api_key_test_create"],
1522
1592
  async (_key, { arg }) => {
1523
1593
  const res = await CfgAccountsApiKey.cfgAccountsApiKeyTestCreate({ ...arg, throwOnError: true });
@@ -1565,12 +1635,21 @@ __name(useCfgAccountsApiKeyTestCreate, "useCfgAccountsApiKeyTestCreate");
1565
1635
  // src/hooks/useApiKey.ts
1566
1636
  function useApiKey() {
1567
1637
  const { data, isLoading, mutate } = useCfgAccountsApiKeyRetrieve();
1638
+ const { trigger: revealTrigger, isMutating: isRevealing } = useCfgAccountsApiKeyRevealCreate();
1568
1639
  const { trigger: regenerateTrigger, isMutating: isRegenerating } = useCfgAccountsApiKeyRegenerateCreate();
1569
1640
  const { trigger: testTrigger, isMutating: isTesting } = useCfgAccountsApiKeyTestCreate();
1570
1641
  const [freshKey, setFreshKey] = (0, import_react.useState)(null);
1571
1642
  const apiKey = freshKey ?? (data?.key ?? null);
1643
+ const isRevealed = freshKey !== null;
1572
1644
  const reissuedAt = data?.reissued_at ?? null;
1573
1645
  const createdAt = data?.created_at ?? null;
1646
+ const reveal = (0, import_react.useCallback)(async () => {
1647
+ const result = await revealTrigger({});
1648
+ const fullKey = result?.key;
1649
+ if (fullKey) {
1650
+ setFreshKey(fullKey);
1651
+ }
1652
+ }, [revealTrigger]);
1574
1653
  const regenerate = (0, import_react.useCallback)(async () => {
1575
1654
  const result = await regenerateTrigger({});
1576
1655
  const newKey = result?.key;
@@ -1592,11 +1671,14 @@ function useApiKey() {
1592
1671
  }, [mutate]);
1593
1672
  return {
1594
1673
  apiKey,
1674
+ isRevealed,
1595
1675
  reissuedAt,
1596
1676
  createdAt,
1597
1677
  isLoading,
1678
+ isRevealing,
1598
1679
  isRegenerating,
1599
1680
  isTesting,
1681
+ reveal,
1600
1682
  regenerate,
1601
1683
  testKey,
1602
1684
  refresh