@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.
- package/dist/auth-server.cjs +53 -119
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +53 -119
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +222 -277
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.mjs +222 -277
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +53 -119
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +50 -1
- package/dist/clients.d.ts +50 -1
- package/dist/clients.mjs +53 -119
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +102 -20
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +13 -0
- package/dist/hooks.d.ts +13 -0
- package/dist/hooks.mjs +102 -20
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +53 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -5
- package/dist/index.d.ts +70 -5
- package/dist/index.mjs +53 -119
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +1 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/openapi.json +92 -15
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyReveal.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +1 -0
- package/src/_api/generated/_cfg_centrifugo/openapi.json +0 -5
- package/src/_api/generated/_cfg_totp/openapi.json +0 -5
- package/src/_api/generated/client/index.ts +1 -0
- package/src/_api/generated/core/params.gen.ts +18 -11
- package/src/_api/generated/core/types.gen.ts +6 -0
- package/src/_api/generated/openapi.json +92 -15
- package/src/_api/generated/sdk.gen.ts +57 -122
- package/src/_api/generated/types.gen.ts +38 -0
- package/src/hooks/useApiKey.ts +30 -2
package/dist/hooks.d.cts
CHANGED
|
@@ -3,12 +3,25 @@ interface ApiKeyTestResult {
|
|
|
3
3
|
userId: string | null;
|
|
4
4
|
}
|
|
5
5
|
interface UseApiKeyReturn {
|
|
6
|
+
/**
|
|
7
|
+
* The key to display. Masked by default (from retrieve). Becomes the FULL
|
|
8
|
+
* value after `reveal()` or `regenerate()` resolves, so the user can copy it.
|
|
9
|
+
*/
|
|
6
10
|
apiKey: string | null;
|
|
11
|
+
/** True once `reveal()`/`regenerate()` has surfaced the full (unmasked) key. */
|
|
12
|
+
isRevealed: boolean;
|
|
7
13
|
reissuedAt: string | null;
|
|
8
14
|
createdAt: string | null;
|
|
9
15
|
isLoading: boolean;
|
|
16
|
+
isRevealing: boolean;
|
|
10
17
|
isRegenerating: boolean;
|
|
11
18
|
isTesting: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch the current full key WITHOUT rotating it (the durable value every one
|
|
21
|
+
* of the user's agents uses). Use this to let the user copy their key for
|
|
22
|
+
* agent onboarding — `regenerate()` would invalidate the agents already using it.
|
|
23
|
+
*/
|
|
24
|
+
reveal: () => Promise<void>;
|
|
12
25
|
regenerate: () => Promise<void>;
|
|
13
26
|
testKey: (key: string) => Promise<ApiKeyTestResult>;
|
|
14
27
|
refresh: () => void;
|
package/dist/hooks.d.ts
CHANGED
|
@@ -3,12 +3,25 @@ interface ApiKeyTestResult {
|
|
|
3
3
|
userId: string | null;
|
|
4
4
|
}
|
|
5
5
|
interface UseApiKeyReturn {
|
|
6
|
+
/**
|
|
7
|
+
* The key to display. Masked by default (from retrieve). Becomes the FULL
|
|
8
|
+
* value after `reveal()` or `regenerate()` resolves, so the user can copy it.
|
|
9
|
+
*/
|
|
6
10
|
apiKey: string | null;
|
|
11
|
+
/** True once `reveal()`/`regenerate()` has surfaced the full (unmasked) key. */
|
|
12
|
+
isRevealed: boolean;
|
|
7
13
|
reissuedAt: string | null;
|
|
8
14
|
createdAt: string | null;
|
|
9
15
|
isLoading: boolean;
|
|
16
|
+
isRevealing: boolean;
|
|
10
17
|
isRegenerating: boolean;
|
|
11
18
|
isTesting: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Fetch the current full key WITHOUT rotating it (the durable value every one
|
|
21
|
+
* of the user's agents uses). Use this to let the user copy their key for
|
|
22
|
+
* agent onboarding — `regenerate()` would invalidate the agents already using it.
|
|
23
|
+
*/
|
|
24
|
+
reveal: () => Promise<void>;
|
|
12
25
|
regenerate: () => Promise<void>;
|
|
13
26
|
testKey: (key: string) => Promise<ApiKeyTestResult>;
|
|
14
27
|
refresh: () => void;
|
package/dist/hooks.mjs
CHANGED
|
@@ -1284,11 +1284,7 @@ var CfgAccountsApiKey = class {
|
|
|
1284
1284
|
static cfgAccountsApiKeyRetrieve(options) {
|
|
1285
1285
|
return (options?.client ?? client).get({
|
|
1286
1286
|
security: [
|
|
1287
|
-
{
|
|
1288
|
-
key: "jwtAuth",
|
|
1289
|
-
scheme: "bearer",
|
|
1290
|
-
type: "http"
|
|
1291
|
-
},
|
|
1287
|
+
{ scheme: "bearer", type: "http" },
|
|
1292
1288
|
{
|
|
1293
1289
|
in: "cookie",
|
|
1294
1290
|
name: "sessionid",
|
|
@@ -1308,11 +1304,31 @@ var CfgAccountsApiKey = class {
|
|
|
1308
1304
|
static cfgAccountsApiKeyRegenerateCreate(options) {
|
|
1309
1305
|
return (options.client ?? client).post({
|
|
1310
1306
|
security: [
|
|
1307
|
+
{ scheme: "bearer", type: "http" },
|
|
1311
1308
|
{
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
type: "
|
|
1309
|
+
in: "cookie",
|
|
1310
|
+
name: "sessionid",
|
|
1311
|
+
type: "apiKey"
|
|
1315
1312
|
},
|
|
1313
|
+
{ name: "X-API-Key", type: "apiKey" }
|
|
1314
|
+
],
|
|
1315
|
+
url: "/cfg/accounts/api-key/regenerate/",
|
|
1316
|
+
...options,
|
|
1317
|
+
headers: {
|
|
1318
|
+
"Content-Type": "application/json",
|
|
1319
|
+
...options.headers
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Reveal API key
|
|
1325
|
+
*
|
|
1326
|
+
* 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.
|
|
1327
|
+
*/
|
|
1328
|
+
static cfgAccountsApiKeyRevealCreate(options) {
|
|
1329
|
+
return (options.client ?? client).post({
|
|
1330
|
+
security: [
|
|
1331
|
+
{ scheme: "bearer", type: "http" },
|
|
1316
1332
|
{
|
|
1317
1333
|
in: "cookie",
|
|
1318
1334
|
name: "sessionid",
|
|
@@ -1320,7 +1336,7 @@ var CfgAccountsApiKey = class {
|
|
|
1320
1336
|
},
|
|
1321
1337
|
{ name: "X-API-Key", type: "apiKey" }
|
|
1322
1338
|
],
|
|
1323
|
-
url: "/cfg/accounts/api-key/
|
|
1339
|
+
url: "/cfg/accounts/api-key/reveal/",
|
|
1324
1340
|
...options,
|
|
1325
1341
|
headers: {
|
|
1326
1342
|
"Content-Type": "application/json",
|
|
@@ -1336,11 +1352,7 @@ var CfgAccountsApiKey = class {
|
|
|
1336
1352
|
static cfgAccountsApiKeyTestCreate(options) {
|
|
1337
1353
|
return (options.client ?? client).post({
|
|
1338
1354
|
security: [
|
|
1339
|
-
{
|
|
1340
|
-
key: "jwtAuth",
|
|
1341
|
-
scheme: "bearer",
|
|
1342
|
-
type: "http"
|
|
1343
|
-
},
|
|
1355
|
+
{ scheme: "bearer", type: "http" },
|
|
1344
1356
|
{
|
|
1345
1357
|
in: "cookie",
|
|
1346
1358
|
name: "sessionid",
|
|
@@ -1472,19 +1484,77 @@ function useCfgAccountsApiKeyRetrieve(args, config) {
|
|
|
1472
1484
|
}
|
|
1473
1485
|
__name(useCfgAccountsApiKeyRetrieve, "useCfgAccountsApiKeyRetrieve");
|
|
1474
1486
|
|
|
1475
|
-
// src/_api/generated/_cfg_accounts/hooks/
|
|
1487
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts
|
|
1476
1488
|
import useSWRMutation2 from "swr/mutation";
|
|
1477
1489
|
|
|
1478
|
-
// src/_api/generated/_cfg_accounts/schemas/
|
|
1490
|
+
// src/_api/generated/_cfg_accounts/schemas/APIKeyReveal.ts
|
|
1479
1491
|
import { z as z3 } from "zod";
|
|
1480
|
-
var
|
|
1481
|
-
|
|
1482
|
-
|
|
1492
|
+
var APIKeyRevealSchema = z3.object({
|
|
1493
|
+
key: z3.string(),
|
|
1494
|
+
created_at: z3.string().datetime({ offset: true }),
|
|
1495
|
+
reissued_at: z3.string().datetime({ offset: true }).nullable()
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRevealCreate.ts
|
|
1499
|
+
function useCfgAccountsApiKeyRevealCreate(config) {
|
|
1500
|
+
return useSWRMutation2(
|
|
1501
|
+
["cfg_accounts_api_key_reveal_create"],
|
|
1502
|
+
async (_key, { arg }) => {
|
|
1503
|
+
const res = await CfgAccountsApiKey.cfgAccountsApiKeyRevealCreate({ ...arg, throwOnError: true });
|
|
1504
|
+
const data = res.data;
|
|
1505
|
+
const parsed = APIKeyRevealSchema.safeParse(data);
|
|
1506
|
+
if (!parsed.success) {
|
|
1507
|
+
console.warn(
|
|
1508
|
+
"[zod] response did not match schema",
|
|
1509
|
+
{
|
|
1510
|
+
operation: "cfg_accounts_api_key_reveal_create",
|
|
1511
|
+
method: "POST",
|
|
1512
|
+
path: "/cfg/accounts/api-key/reveal/",
|
|
1513
|
+
issues: parsed.error.issues,
|
|
1514
|
+
data
|
|
1515
|
+
}
|
|
1516
|
+
);
|
|
1517
|
+
if (typeof window !== "undefined") {
|
|
1518
|
+
try {
|
|
1519
|
+
window.dispatchEvent(
|
|
1520
|
+
new CustomEvent("zod-validation-error", {
|
|
1521
|
+
detail: {
|
|
1522
|
+
operation: "cfg_accounts_api_key_reveal_create",
|
|
1523
|
+
method: "POST",
|
|
1524
|
+
path: "/cfg/accounts/api-key/reveal/",
|
|
1525
|
+
issues: parsed.error.issues,
|
|
1526
|
+
data,
|
|
1527
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
1528
|
+
},
|
|
1529
|
+
bubbles: true,
|
|
1530
|
+
cancelable: false
|
|
1531
|
+
})
|
|
1532
|
+
);
|
|
1533
|
+
} catch {
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
return data;
|
|
1537
|
+
}
|
|
1538
|
+
return parsed.data;
|
|
1539
|
+
},
|
|
1540
|
+
config
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
__name(useCfgAccountsApiKeyRevealCreate, "useCfgAccountsApiKeyRevealCreate");
|
|
1544
|
+
|
|
1545
|
+
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
|
|
1546
|
+
import useSWRMutation3 from "swr/mutation";
|
|
1547
|
+
|
|
1548
|
+
// src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts
|
|
1549
|
+
import { z as z4 } from "zod";
|
|
1550
|
+
var APIKeyTestResultSchema = z4.object({
|
|
1551
|
+
valid: z4.boolean(),
|
|
1552
|
+
user_id: z4.string().nullable()
|
|
1483
1553
|
});
|
|
1484
1554
|
|
|
1485
1555
|
// src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts
|
|
1486
1556
|
function useCfgAccountsApiKeyTestCreate(config) {
|
|
1487
|
-
return
|
|
1557
|
+
return useSWRMutation3(
|
|
1488
1558
|
["cfg_accounts_api_key_test_create"],
|
|
1489
1559
|
async (_key, { arg }) => {
|
|
1490
1560
|
const res = await CfgAccountsApiKey.cfgAccountsApiKeyTestCreate({ ...arg, throwOnError: true });
|
|
@@ -1532,12 +1602,21 @@ __name(useCfgAccountsApiKeyTestCreate, "useCfgAccountsApiKeyTestCreate");
|
|
|
1532
1602
|
// src/hooks/useApiKey.ts
|
|
1533
1603
|
function useApiKey() {
|
|
1534
1604
|
const { data, isLoading, mutate } = useCfgAccountsApiKeyRetrieve();
|
|
1605
|
+
const { trigger: revealTrigger, isMutating: isRevealing } = useCfgAccountsApiKeyRevealCreate();
|
|
1535
1606
|
const { trigger: regenerateTrigger, isMutating: isRegenerating } = useCfgAccountsApiKeyRegenerateCreate();
|
|
1536
1607
|
const { trigger: testTrigger, isMutating: isTesting } = useCfgAccountsApiKeyTestCreate();
|
|
1537
1608
|
const [freshKey, setFreshKey] = useState(null);
|
|
1538
1609
|
const apiKey = freshKey ?? (data?.key ?? null);
|
|
1610
|
+
const isRevealed = freshKey !== null;
|
|
1539
1611
|
const reissuedAt = data?.reissued_at ?? null;
|
|
1540
1612
|
const createdAt = data?.created_at ?? null;
|
|
1613
|
+
const reveal = useCallback(async () => {
|
|
1614
|
+
const result = await revealTrigger({});
|
|
1615
|
+
const fullKey = result?.key;
|
|
1616
|
+
if (fullKey) {
|
|
1617
|
+
setFreshKey(fullKey);
|
|
1618
|
+
}
|
|
1619
|
+
}, [revealTrigger]);
|
|
1541
1620
|
const regenerate = useCallback(async () => {
|
|
1542
1621
|
const result = await regenerateTrigger({});
|
|
1543
1622
|
const newKey = result?.key;
|
|
@@ -1559,11 +1638,14 @@ function useApiKey() {
|
|
|
1559
1638
|
}, [mutate]);
|
|
1560
1639
|
return {
|
|
1561
1640
|
apiKey,
|
|
1641
|
+
isRevealed,
|
|
1562
1642
|
reissuedAt,
|
|
1563
1643
|
createdAt,
|
|
1564
1644
|
isLoading,
|
|
1645
|
+
isRevealing,
|
|
1565
1646
|
isRegenerating,
|
|
1566
1647
|
isTesting,
|
|
1648
|
+
reveal,
|
|
1567
1649
|
regenerate,
|
|
1568
1650
|
testKey,
|
|
1569
1651
|
refresh
|