@mdxui/auth 1.1.0 → 1.1.1
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/README.md +128 -1
- package/dist/hooks/index.d.ts +91 -1
- package/dist/hooks/index.js +84 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/{index-Bl4BwORF.d.ts → index-DGthQxCM.d.ts} +104 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +859 -34
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.js +69 -1
- package/dist/providers/index.js.map +1 -1
- package/dist/types-8tixck1H.d.ts +123 -0
- package/dist/vault/index.d.ts +192 -0
- package/dist/vault/index.js +692 -0
- package/dist/vault/index.js.map +1 -0
- package/package.json +9 -2
package/dist/index.js
CHANGED
|
@@ -182,56 +182,121 @@ function AuthGate({
|
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
// src/providers/vault-provider.tsx
|
|
186
|
+
import { createContext, useContext, useMemo } from "react";
|
|
187
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
188
|
+
var VaultContext = createContext(null);
|
|
189
|
+
var defaultFields = [
|
|
190
|
+
{ key: "api_key", label: "API Key", type: "password", required: true }
|
|
191
|
+
];
|
|
192
|
+
function VaultProvider({
|
|
193
|
+
children,
|
|
194
|
+
client,
|
|
195
|
+
initialItems = []
|
|
196
|
+
}) {
|
|
197
|
+
const contextValue = useMemo(() => {
|
|
198
|
+
const getIntegrationFields = (integrationId) => {
|
|
199
|
+
if (client?.getIntegrationFields) {
|
|
200
|
+
return client.getIntegrationFields(integrationId);
|
|
201
|
+
}
|
|
202
|
+
return defaultFields;
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
client: client ?? null,
|
|
206
|
+
items: initialItems,
|
|
207
|
+
loading: false,
|
|
208
|
+
error: null,
|
|
209
|
+
reload: async () => {
|
|
210
|
+
if (!client) {
|
|
211
|
+
console.warn("VaultProvider: No client provided, cannot reload");
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
await client.list();
|
|
215
|
+
},
|
|
216
|
+
createItem: async (integrationId, credentials) => {
|
|
217
|
+
if (!client) {
|
|
218
|
+
throw new Error("VaultProvider: No client provided");
|
|
219
|
+
}
|
|
220
|
+
await client.create(integrationId, credentials);
|
|
221
|
+
},
|
|
222
|
+
rotateItem: async (id, credentials) => {
|
|
223
|
+
if (!client) {
|
|
224
|
+
throw new Error("VaultProvider: No client provided");
|
|
225
|
+
}
|
|
226
|
+
await client.rotate(id, credentials);
|
|
227
|
+
},
|
|
228
|
+
deleteItem: async (id) => {
|
|
229
|
+
if (!client) {
|
|
230
|
+
throw new Error("VaultProvider: No client provided");
|
|
231
|
+
}
|
|
232
|
+
await client.delete(id);
|
|
233
|
+
},
|
|
234
|
+
getIntegrationFields
|
|
235
|
+
};
|
|
236
|
+
}, [client, initialItems]);
|
|
237
|
+
return /* @__PURE__ */ jsx4(VaultContext.Provider, { value: contextValue, children });
|
|
238
|
+
}
|
|
239
|
+
function useVaultContext() {
|
|
240
|
+
const context = useContext(VaultContext);
|
|
241
|
+
if (!context) {
|
|
242
|
+
throw new Error("useVaultContext must be used within a VaultProvider");
|
|
243
|
+
}
|
|
244
|
+
return context;
|
|
245
|
+
}
|
|
246
|
+
function useVaultContextOptional() {
|
|
247
|
+
return useContext(VaultContext);
|
|
248
|
+
}
|
|
249
|
+
|
|
185
250
|
// src/widgets/user-profile.tsx
|
|
186
251
|
import { UserProfile as WorkOSUserProfile } from "@workos-inc/widgets";
|
|
187
|
-
import { jsx as
|
|
252
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
188
253
|
function UserProfile({ authToken, className }) {
|
|
189
|
-
return /* @__PURE__ */
|
|
254
|
+
return /* @__PURE__ */ jsx5("div", { className, children: /* @__PURE__ */ jsx5(WorkOSUserProfile, { authToken }) });
|
|
190
255
|
}
|
|
191
256
|
|
|
192
257
|
// src/widgets/user-security.tsx
|
|
193
258
|
import { UserSecurity as WorkOSUserSecurity } from "@workos-inc/widgets";
|
|
194
|
-
import { jsx as
|
|
259
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
195
260
|
function UserSecurity({ authToken, className }) {
|
|
196
|
-
return /* @__PURE__ */
|
|
261
|
+
return /* @__PURE__ */ jsx6("div", { className, children: /* @__PURE__ */ jsx6(WorkOSUserSecurity, { authToken }) });
|
|
197
262
|
}
|
|
198
263
|
|
|
199
264
|
// src/widgets/user-sessions.tsx
|
|
200
265
|
import { UserSessions as WorkOSUserSessions } from "@workos-inc/widgets";
|
|
201
|
-
import { jsx as
|
|
266
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
202
267
|
function UserSessions(props) {
|
|
203
268
|
const { className, ...rest } = props;
|
|
204
|
-
return /* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ jsx7("div", { className, children: /* @__PURE__ */ jsx7(WorkOSUserSessions, { ...rest }) });
|
|
205
270
|
}
|
|
206
271
|
|
|
207
272
|
// src/widgets/api-keys.tsx
|
|
208
273
|
import { ApiKeys as WorkOSApiKeys } from "@workos-inc/widgets";
|
|
209
|
-
import { jsx as
|
|
274
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
210
275
|
function ApiKeys({ authToken, className }) {
|
|
211
|
-
return /* @__PURE__ */
|
|
276
|
+
return /* @__PURE__ */ jsx8("div", { className, children: /* @__PURE__ */ jsx8(WorkOSApiKeys, { authToken }) });
|
|
212
277
|
}
|
|
213
278
|
|
|
214
279
|
// src/widgets/users-management.tsx
|
|
215
280
|
import { UsersManagement as WorkOSUsersManagement } from "@workos-inc/widgets";
|
|
216
|
-
import { jsx as
|
|
281
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
217
282
|
function UsersManagement({
|
|
218
283
|
authToken,
|
|
219
284
|
organizationId: _organizationId,
|
|
220
285
|
className
|
|
221
286
|
}) {
|
|
222
|
-
return /* @__PURE__ */
|
|
287
|
+
return /* @__PURE__ */ jsx9("div", { className, children: /* @__PURE__ */ jsx9(WorkOSUsersManagement, { authToken }) });
|
|
223
288
|
}
|
|
224
289
|
|
|
225
290
|
// src/widgets/pipes.tsx
|
|
226
291
|
import { Pipes as WorkOSPipes } from "@workos-inc/widgets";
|
|
227
|
-
import { jsx as
|
|
292
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
228
293
|
function Pipes({ authToken, className }) {
|
|
229
|
-
return /* @__PURE__ */
|
|
294
|
+
return /* @__PURE__ */ jsx10("div", { className, children: /* @__PURE__ */ jsx10(WorkOSPipes, { authToken }) });
|
|
230
295
|
}
|
|
231
296
|
|
|
232
297
|
// src/widgets/organization-switcher.tsx
|
|
233
298
|
import { OrganizationSwitcher as WorkOSOrganizationSwitcher } from "@workos-inc/widgets";
|
|
234
|
-
import { jsx as
|
|
299
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
235
300
|
function OrganizationSwitcher({
|
|
236
301
|
authToken,
|
|
237
302
|
switchToOrganization,
|
|
@@ -240,7 +305,7 @@ function OrganizationSwitcher({
|
|
|
240
305
|
truncateBehavior,
|
|
241
306
|
className
|
|
242
307
|
}) {
|
|
243
|
-
return /* @__PURE__ */
|
|
308
|
+
return /* @__PURE__ */ jsx11("div", { className, children: /* @__PURE__ */ jsx11(
|
|
244
309
|
WorkOSOrganizationSwitcher,
|
|
245
310
|
{
|
|
246
311
|
authToken,
|
|
@@ -252,9 +317,692 @@ function OrganizationSwitcher({
|
|
|
252
317
|
) });
|
|
253
318
|
}
|
|
254
319
|
|
|
320
|
+
// src/vault/secrets-manager/secrets-manager.tsx
|
|
321
|
+
import {
|
|
322
|
+
Badge,
|
|
323
|
+
Button as Button2,
|
|
324
|
+
Card,
|
|
325
|
+
CardContent,
|
|
326
|
+
CardDescription,
|
|
327
|
+
CardHeader,
|
|
328
|
+
CardTitle,
|
|
329
|
+
Dialog,
|
|
330
|
+
DialogContent,
|
|
331
|
+
DialogHeader,
|
|
332
|
+
DialogTitle,
|
|
333
|
+
DialogTrigger,
|
|
334
|
+
Input as Input2,
|
|
335
|
+
Select as Select2,
|
|
336
|
+
SelectContent as SelectContent2,
|
|
337
|
+
SelectItem as SelectItem2,
|
|
338
|
+
SelectTrigger as SelectTrigger2,
|
|
339
|
+
SelectValue as SelectValue2,
|
|
340
|
+
Table,
|
|
341
|
+
TableBody,
|
|
342
|
+
TableCell,
|
|
343
|
+
TableHead,
|
|
344
|
+
TableHeader,
|
|
345
|
+
TableRow
|
|
346
|
+
} from "@mdxui/primitives";
|
|
347
|
+
import { cn } from "@mdxui/primitives/lib/utils";
|
|
348
|
+
import {
|
|
349
|
+
Copy,
|
|
350
|
+
Edit,
|
|
351
|
+
Eye,
|
|
352
|
+
EyeOff,
|
|
353
|
+
Filter,
|
|
354
|
+
Plus,
|
|
355
|
+
Search,
|
|
356
|
+
Trash2
|
|
357
|
+
} from "lucide-react";
|
|
358
|
+
import * as React2 from "react";
|
|
359
|
+
import { toast } from "sonner";
|
|
360
|
+
|
|
361
|
+
// src/vault/secrets-manager/secret-form.tsx
|
|
362
|
+
import {
|
|
363
|
+
Button,
|
|
364
|
+
Input,
|
|
365
|
+
Label,
|
|
366
|
+
Select,
|
|
367
|
+
SelectContent,
|
|
368
|
+
SelectItem,
|
|
369
|
+
SelectTrigger,
|
|
370
|
+
SelectValue,
|
|
371
|
+
Textarea
|
|
372
|
+
} from "@mdxui/primitives";
|
|
373
|
+
import * as React from "react";
|
|
374
|
+
import { jsx as jsx12, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
375
|
+
function SecretForm({
|
|
376
|
+
secret,
|
|
377
|
+
environment: defaultEnvironment,
|
|
378
|
+
environments,
|
|
379
|
+
onSubmit,
|
|
380
|
+
onCancel
|
|
381
|
+
}) {
|
|
382
|
+
const [key, setKey] = React.useState(secret?.key || "");
|
|
383
|
+
const [value, setValue] = React.useState(secret?.value || "");
|
|
384
|
+
const [description, setDescription] = React.useState(
|
|
385
|
+
secret?.description || ""
|
|
386
|
+
);
|
|
387
|
+
const [environment, setEnvironment] = React.useState(
|
|
388
|
+
secret?.environment || defaultEnvironment
|
|
389
|
+
);
|
|
390
|
+
const handleSubmit = (e) => {
|
|
391
|
+
e.preventDefault();
|
|
392
|
+
if (!key.trim() || !value.trim()) return;
|
|
393
|
+
onSubmit({
|
|
394
|
+
key: key.trim(),
|
|
395
|
+
value: value.trim(),
|
|
396
|
+
description: description.trim() || void 0,
|
|
397
|
+
environment
|
|
398
|
+
});
|
|
399
|
+
};
|
|
400
|
+
return /* @__PURE__ */ jsxs2("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
401
|
+
/* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
402
|
+
/* @__PURE__ */ jsx12(Label, { htmlFor: "key", children: "Key *" }),
|
|
403
|
+
/* @__PURE__ */ jsx12(
|
|
404
|
+
Input,
|
|
405
|
+
{
|
|
406
|
+
id: "key",
|
|
407
|
+
placeholder: "DATABASE_URL",
|
|
408
|
+
value: key,
|
|
409
|
+
onChange: (e) => setKey(e.target.value.toUpperCase().replace(/[^A-Z0-9_]/g, "_")),
|
|
410
|
+
required: true,
|
|
411
|
+
autoFocus: true
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
/* @__PURE__ */ jsx12("p", { className: "text-xs text-muted-foreground", children: "Use UPPER_CASE with underscores (e.g., API_KEY, DATABASE_URL)" })
|
|
415
|
+
] }),
|
|
416
|
+
/* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
417
|
+
/* @__PURE__ */ jsx12(Label, { htmlFor: "value", children: "Value *" }),
|
|
418
|
+
/* @__PURE__ */ jsx12(
|
|
419
|
+
Textarea,
|
|
420
|
+
{
|
|
421
|
+
id: "value",
|
|
422
|
+
placeholder: "Enter secret value",
|
|
423
|
+
value,
|
|
424
|
+
onChange: (e) => setValue(e.target.value),
|
|
425
|
+
rows: 3,
|
|
426
|
+
required: true,
|
|
427
|
+
className: "font-mono"
|
|
428
|
+
}
|
|
429
|
+
)
|
|
430
|
+
] }),
|
|
431
|
+
/* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
432
|
+
/* @__PURE__ */ jsx12(Label, { htmlFor: "environment", children: "Environment *" }),
|
|
433
|
+
/* @__PURE__ */ jsxs2(Select, { value: environment, onValueChange: setEnvironment, children: [
|
|
434
|
+
/* @__PURE__ */ jsx12(SelectTrigger, { id: "environment", children: /* @__PURE__ */ jsx12(SelectValue, {}) }),
|
|
435
|
+
/* @__PURE__ */ jsx12(SelectContent, { children: environments.map((env) => /* @__PURE__ */ jsx12(SelectItem, { value: env, children: env.charAt(0).toUpperCase() + env.slice(1) }, env)) })
|
|
436
|
+
] })
|
|
437
|
+
] }),
|
|
438
|
+
/* @__PURE__ */ jsxs2("div", { className: "space-y-2", children: [
|
|
439
|
+
/* @__PURE__ */ jsx12(Label, { htmlFor: "description", children: "Description" }),
|
|
440
|
+
/* @__PURE__ */ jsx12(
|
|
441
|
+
Textarea,
|
|
442
|
+
{
|
|
443
|
+
id: "description",
|
|
444
|
+
placeholder: "Optional description of this secret",
|
|
445
|
+
value: description,
|
|
446
|
+
onChange: (e) => setDescription(e.target.value),
|
|
447
|
+
rows: 2
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
] }),
|
|
451
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex justify-end gap-2", children: [
|
|
452
|
+
/* @__PURE__ */ jsx12(Button, { type: "button", variant: "outline", onClick: onCancel, children: "Cancel" }),
|
|
453
|
+
/* @__PURE__ */ jsxs2(Button, { type: "submit", disabled: !key.trim() || !value.trim(), children: [
|
|
454
|
+
secret ? "Update" : "Create",
|
|
455
|
+
" Secret"
|
|
456
|
+
] })
|
|
457
|
+
] })
|
|
458
|
+
] });
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
// src/vault/secrets-manager/secrets-manager.tsx
|
|
462
|
+
import { jsx as jsx13, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
463
|
+
function SecretsManager({
|
|
464
|
+
secrets: externalSecrets = [],
|
|
465
|
+
environments = ["development", "staging", "production"],
|
|
466
|
+
currentEnvironment = "development",
|
|
467
|
+
onEnvironmentChange,
|
|
468
|
+
onCreate,
|
|
469
|
+
onUpdate,
|
|
470
|
+
onDelete,
|
|
471
|
+
hideValues: initialHideValues = true,
|
|
472
|
+
editable = true,
|
|
473
|
+
className
|
|
474
|
+
}) {
|
|
475
|
+
const [localSecrets, setLocalSecrets] = React2.useState([]);
|
|
476
|
+
const [hideValues, setHideValues] = React2.useState(initialHideValues);
|
|
477
|
+
const [searchQuery, setSearchQuery] = React2.useState("");
|
|
478
|
+
const [environment, setEnvironment] = React2.useState(currentEnvironment);
|
|
479
|
+
const [visibleSecrets, setVisibleSecrets] = React2.useState(
|
|
480
|
+
/* @__PURE__ */ new Set()
|
|
481
|
+
);
|
|
482
|
+
const [editingSecret, setEditingSecret] = React2.useState(null);
|
|
483
|
+
const [isCreateDialogOpen, setIsCreateDialogOpen] = React2.useState(false);
|
|
484
|
+
const [isEditDialogOpen, setIsEditDialogOpen] = React2.useState(false);
|
|
485
|
+
const secrets = externalSecrets.length > 0 ? externalSecrets : localSecrets;
|
|
486
|
+
React2.useEffect(() => {
|
|
487
|
+
setEnvironment(currentEnvironment);
|
|
488
|
+
}, [currentEnvironment]);
|
|
489
|
+
const filteredSecrets = React2.useMemo(() => {
|
|
490
|
+
return secrets.filter((secret) => {
|
|
491
|
+
const matchesSearch = searchQuery ? secret.key.toLowerCase().includes(searchQuery.toLowerCase()) || secret.description?.toLowerCase().includes(searchQuery.toLowerCase()) : true;
|
|
492
|
+
const matchesEnvironment = environment === "all" || secret.environment === environment;
|
|
493
|
+
return matchesSearch && matchesEnvironment;
|
|
494
|
+
});
|
|
495
|
+
}, [secrets, searchQuery, environment]);
|
|
496
|
+
const handleEnvironmentChange = (newEnvironment) => {
|
|
497
|
+
setEnvironment(newEnvironment);
|
|
498
|
+
onEnvironmentChange?.(newEnvironment);
|
|
499
|
+
};
|
|
500
|
+
const handleCreate = async (secretData) => {
|
|
501
|
+
const newSecret = {
|
|
502
|
+
...secretData,
|
|
503
|
+
id: crypto.randomUUID(),
|
|
504
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
505
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
506
|
+
};
|
|
507
|
+
try {
|
|
508
|
+
await onCreate?.(secretData);
|
|
509
|
+
if (externalSecrets.length === 0) {
|
|
510
|
+
setLocalSecrets((prev) => [...prev, newSecret]);
|
|
511
|
+
}
|
|
512
|
+
setIsCreateDialogOpen(false);
|
|
513
|
+
toast.success("Secret created successfully");
|
|
514
|
+
} catch (error) {
|
|
515
|
+
toast.error("Failed to create secret");
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
const handleUpdate = async (id, updates) => {
|
|
519
|
+
try {
|
|
520
|
+
await onUpdate?.(id, { ...updates, updatedAt: /* @__PURE__ */ new Date() });
|
|
521
|
+
if (externalSecrets.length === 0) {
|
|
522
|
+
setLocalSecrets(
|
|
523
|
+
(prev) => prev.map(
|
|
524
|
+
(secret) => secret.id === id ? { ...secret, ...updates, updatedAt: /* @__PURE__ */ new Date() } : secret
|
|
525
|
+
)
|
|
526
|
+
);
|
|
527
|
+
}
|
|
528
|
+
setIsEditDialogOpen(false);
|
|
529
|
+
setEditingSecret(null);
|
|
530
|
+
toast.success("Secret updated successfully");
|
|
531
|
+
} catch (error) {
|
|
532
|
+
toast.error("Failed to update secret");
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
const handleDelete = async (id) => {
|
|
536
|
+
if (!confirm("Are you sure you want to delete this secret?")) return;
|
|
537
|
+
try {
|
|
538
|
+
await onDelete?.(id);
|
|
539
|
+
if (externalSecrets.length === 0) {
|
|
540
|
+
setLocalSecrets((prev) => prev.filter((secret) => secret.id !== id));
|
|
541
|
+
}
|
|
542
|
+
toast.success("Secret deleted");
|
|
543
|
+
} catch (error) {
|
|
544
|
+
toast.error("Failed to delete secret");
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
const handleCopy = (value) => {
|
|
548
|
+
navigator.clipboard.writeText(value);
|
|
549
|
+
toast.success("Value copied to clipboard");
|
|
550
|
+
};
|
|
551
|
+
const toggleSecretVisibility = (id) => {
|
|
552
|
+
setVisibleSecrets((prev) => {
|
|
553
|
+
const next = new Set(prev);
|
|
554
|
+
if (next.has(id)) {
|
|
555
|
+
next.delete(id);
|
|
556
|
+
} else {
|
|
557
|
+
next.add(id);
|
|
558
|
+
}
|
|
559
|
+
return next;
|
|
560
|
+
});
|
|
561
|
+
};
|
|
562
|
+
const toggleAllVisibility = () => {
|
|
563
|
+
setHideValues(!hideValues);
|
|
564
|
+
if (!hideValues) {
|
|
565
|
+
setVisibleSecrets(/* @__PURE__ */ new Set());
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
const isSecretVisible = (id) => {
|
|
569
|
+
return hideValues ? visibleSecrets.has(id) : true;
|
|
570
|
+
};
|
|
571
|
+
return /* @__PURE__ */ jsxs3("div", { className: cn("space-y-4", className), children: [
|
|
572
|
+
/* @__PURE__ */ jsxs3(Card, { children: [
|
|
573
|
+
/* @__PURE__ */ jsx13(CardHeader, { children: /* @__PURE__ */ jsxs3("div", { className: "flex items-start justify-between", children: [
|
|
574
|
+
/* @__PURE__ */ jsxs3("div", { children: [
|
|
575
|
+
/* @__PURE__ */ jsx13(CardTitle, { children: "Environment Variables" }),
|
|
576
|
+
/* @__PURE__ */ jsx13(CardDescription, { children: "Manage your application secrets and configuration" })
|
|
577
|
+
] }),
|
|
578
|
+
editable && /* @__PURE__ */ jsxs3(
|
|
579
|
+
Dialog,
|
|
580
|
+
{
|
|
581
|
+
open: isCreateDialogOpen,
|
|
582
|
+
onOpenChange: setIsCreateDialogOpen,
|
|
583
|
+
children: [
|
|
584
|
+
/* @__PURE__ */ jsx13(DialogTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3(Button2, { children: [
|
|
585
|
+
/* @__PURE__ */ jsx13(Plus, { className: "mr-2 size-4" }),
|
|
586
|
+
"Add Secret"
|
|
587
|
+
] }) }),
|
|
588
|
+
/* @__PURE__ */ jsxs3(DialogContent, { children: [
|
|
589
|
+
/* @__PURE__ */ jsx13(DialogHeader, { children: /* @__PURE__ */ jsx13(DialogTitle, { children: "Create New Secret" }) }),
|
|
590
|
+
/* @__PURE__ */ jsx13(
|
|
591
|
+
SecretForm,
|
|
592
|
+
{
|
|
593
|
+
environment,
|
|
594
|
+
environments,
|
|
595
|
+
onSubmit: handleCreate,
|
|
596
|
+
onCancel: () => setIsCreateDialogOpen(false)
|
|
597
|
+
}
|
|
598
|
+
)
|
|
599
|
+
] })
|
|
600
|
+
]
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
] }) }),
|
|
604
|
+
/* @__PURE__ */ jsxs3(CardContent, { className: "space-y-4", children: [
|
|
605
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
606
|
+
/* @__PURE__ */ jsxs3("div", { className: "relative flex-1", children: [
|
|
607
|
+
/* @__PURE__ */ jsx13(Search, { className: "absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" }),
|
|
608
|
+
/* @__PURE__ */ jsx13(
|
|
609
|
+
Input2,
|
|
610
|
+
{
|
|
611
|
+
placeholder: "Search secrets...",
|
|
612
|
+
value: searchQuery,
|
|
613
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
614
|
+
className: "pl-9"
|
|
615
|
+
}
|
|
616
|
+
)
|
|
617
|
+
] }),
|
|
618
|
+
/* @__PURE__ */ jsxs3(Select2, { value: environment, onValueChange: handleEnvironmentChange, children: [
|
|
619
|
+
/* @__PURE__ */ jsxs3(SelectTrigger2, { className: "w-[180px]", children: [
|
|
620
|
+
/* @__PURE__ */ jsx13(Filter, { className: "mr-2 size-4" }),
|
|
621
|
+
/* @__PURE__ */ jsx13(SelectValue2, {})
|
|
622
|
+
] }),
|
|
623
|
+
/* @__PURE__ */ jsxs3(SelectContent2, { children: [
|
|
624
|
+
/* @__PURE__ */ jsx13(SelectItem2, { value: "all", children: "All Environments" }),
|
|
625
|
+
environments.map((env) => /* @__PURE__ */ jsx13(SelectItem2, { value: env, children: env.charAt(0).toUpperCase() + env.slice(1) }, env))
|
|
626
|
+
] })
|
|
627
|
+
] }),
|
|
628
|
+
/* @__PURE__ */ jsx13(Button2, { variant: "outline", size: "icon", onClick: toggleAllVisibility, children: hideValues ? /* @__PURE__ */ jsx13(Eye, { className: "size-4" }) : /* @__PURE__ */ jsx13(EyeOff, { className: "size-4" }) })
|
|
629
|
+
] }),
|
|
630
|
+
filteredSecrets.length > 0 ? /* @__PURE__ */ jsx13("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxs3(Table, { children: [
|
|
631
|
+
/* @__PURE__ */ jsx13(TableHeader, { children: /* @__PURE__ */ jsxs3(TableRow, { children: [
|
|
632
|
+
/* @__PURE__ */ jsx13(TableHead, { children: "Key" }),
|
|
633
|
+
/* @__PURE__ */ jsx13(TableHead, { children: "Value" }),
|
|
634
|
+
/* @__PURE__ */ jsx13(TableHead, { children: "Environment" }),
|
|
635
|
+
/* @__PURE__ */ jsx13(TableHead, { children: "Description" }),
|
|
636
|
+
/* @__PURE__ */ jsx13(TableHead, { className: "w-[100px]", children: "Actions" })
|
|
637
|
+
] }) }),
|
|
638
|
+
/* @__PURE__ */ jsx13(TableBody, { children: filteredSecrets.map((secret) => /* @__PURE__ */ jsxs3(TableRow, { children: [
|
|
639
|
+
/* @__PURE__ */ jsx13(TableCell, { children: /* @__PURE__ */ jsx13("code", { className: "rounded bg-muted px-2 py-1 font-mono text-sm", children: secret.key }) }),
|
|
640
|
+
/* @__PURE__ */ jsx13(TableCell, { children: /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
|
|
641
|
+
/* @__PURE__ */ jsx13("code", { className: "flex-1 rounded bg-muted px-2 py-1 font-mono text-sm", children: isSecretVisible(secret.id) ? secret.value : "\u2022".repeat(Math.min(secret.value.length, 20)) }),
|
|
642
|
+
/* @__PURE__ */ jsx13(
|
|
643
|
+
Button2,
|
|
644
|
+
{
|
|
645
|
+
variant: "ghost",
|
|
646
|
+
size: "icon-sm",
|
|
647
|
+
onClick: () => toggleSecretVisibility(secret.id),
|
|
648
|
+
children: isSecretVisible(secret.id) ? /* @__PURE__ */ jsx13(EyeOff, { className: "size-4" }) : /* @__PURE__ */ jsx13(Eye, { className: "size-4" })
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
/* @__PURE__ */ jsx13(
|
|
652
|
+
Button2,
|
|
653
|
+
{
|
|
654
|
+
variant: "ghost",
|
|
655
|
+
size: "icon-sm",
|
|
656
|
+
onClick: () => handleCopy(secret.value),
|
|
657
|
+
children: /* @__PURE__ */ jsx13(Copy, { className: "size-4" })
|
|
658
|
+
}
|
|
659
|
+
)
|
|
660
|
+
] }) }),
|
|
661
|
+
/* @__PURE__ */ jsx13(TableCell, { children: /* @__PURE__ */ jsx13(Badge, { variant: "secondary", children: secret.environment }) }),
|
|
662
|
+
/* @__PURE__ */ jsx13(TableCell, { children: /* @__PURE__ */ jsx13("span", { className: "text-sm text-muted-foreground", children: secret.description || "-" }) }),
|
|
663
|
+
/* @__PURE__ */ jsx13(TableCell, { children: editable && /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
|
|
664
|
+
/* @__PURE__ */ jsx13(
|
|
665
|
+
Button2,
|
|
666
|
+
{
|
|
667
|
+
variant: "ghost",
|
|
668
|
+
size: "icon-sm",
|
|
669
|
+
onClick: () => {
|
|
670
|
+
setEditingSecret(secret);
|
|
671
|
+
setIsEditDialogOpen(true);
|
|
672
|
+
},
|
|
673
|
+
children: /* @__PURE__ */ jsx13(Edit, { className: "size-4" })
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
/* @__PURE__ */ jsx13(
|
|
677
|
+
Button2,
|
|
678
|
+
{
|
|
679
|
+
variant: "ghost",
|
|
680
|
+
size: "icon-sm",
|
|
681
|
+
onClick: () => handleDelete(secret.id),
|
|
682
|
+
children: /* @__PURE__ */ jsx13(Trash2, { className: "size-4 text-destructive" })
|
|
683
|
+
}
|
|
684
|
+
)
|
|
685
|
+
] }) })
|
|
686
|
+
] }, secret.id)) })
|
|
687
|
+
] }) }) : /* @__PURE__ */ jsx13("div", { className: "flex h-32 items-center justify-center rounded-md border-2 border-dashed", children: /* @__PURE__ */ jsx13("p", { className: "text-sm text-muted-foreground", children: searchQuery ? "No secrets found matching your search" : "No secrets yet. Add your first secret to get started." }) })
|
|
688
|
+
] })
|
|
689
|
+
] }),
|
|
690
|
+
editingSecret && /* @__PURE__ */ jsx13(Dialog, { open: isEditDialogOpen, onOpenChange: setIsEditDialogOpen, children: /* @__PURE__ */ jsxs3(DialogContent, { children: [
|
|
691
|
+
/* @__PURE__ */ jsx13(DialogHeader, { children: /* @__PURE__ */ jsx13(DialogTitle, { children: "Edit Secret" }) }),
|
|
692
|
+
/* @__PURE__ */ jsx13(
|
|
693
|
+
SecretForm,
|
|
694
|
+
{
|
|
695
|
+
secret: editingSecret,
|
|
696
|
+
environment,
|
|
697
|
+
environments,
|
|
698
|
+
onSubmit: (data) => handleUpdate(editingSecret.id, data),
|
|
699
|
+
onCancel: () => {
|
|
700
|
+
setIsEditDialogOpen(false);
|
|
701
|
+
setEditingSecret(null);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
)
|
|
705
|
+
] }) })
|
|
706
|
+
] });
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/vault/vault-delete-dialog.tsx
|
|
710
|
+
import {
|
|
711
|
+
Button as Button3,
|
|
712
|
+
Dialog as Dialog2,
|
|
713
|
+
DialogContent as DialogContent2,
|
|
714
|
+
DialogDescription,
|
|
715
|
+
DialogFooter,
|
|
716
|
+
DialogHeader as DialogHeader2,
|
|
717
|
+
DialogTitle as DialogTitle2
|
|
718
|
+
} from "@mdxui/primitives";
|
|
719
|
+
import { jsx as jsx14, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
720
|
+
function VaultDeleteDialog({ isOpen, onClose, itemName, onConfirm }) {
|
|
721
|
+
return /* @__PURE__ */ jsx14(Dialog2, { open: isOpen, onOpenChange: onClose, children: /* @__PURE__ */ jsxs4(DialogContent2, { children: [
|
|
722
|
+
/* @__PURE__ */ jsxs4(DialogHeader2, { children: [
|
|
723
|
+
/* @__PURE__ */ jsx14(DialogTitle2, { children: "Delete Credentials" }),
|
|
724
|
+
/* @__PURE__ */ jsxs4(DialogDescription, { children: [
|
|
725
|
+
"Are you sure you want to delete credentials for ",
|
|
726
|
+
itemName,
|
|
727
|
+
"? This action cannot be undone."
|
|
728
|
+
] })
|
|
729
|
+
] }),
|
|
730
|
+
/* @__PURE__ */ jsxs4(DialogFooter, { children: [
|
|
731
|
+
/* @__PURE__ */ jsx14(Button3, { variant: "outline", onClick: onClose, children: "Cancel" }),
|
|
732
|
+
/* @__PURE__ */ jsx14(Button3, { variant: "destructive", onClick: onConfirm, children: "Delete" })
|
|
733
|
+
] })
|
|
734
|
+
] }) });
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
// src/vault/vault-empty-state.tsx
|
|
738
|
+
import { Button as Button4 } from "@mdxui/primitives";
|
|
739
|
+
import { Lock } from "lucide-react";
|
|
740
|
+
import { jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
741
|
+
function VaultEmptyState({ onAddCredential }) {
|
|
742
|
+
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center justify-center rounded-md border border-dashed py-24 px-4 text-center", children: [
|
|
743
|
+
/* @__PURE__ */ jsx15("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-muted mb-4", children: /* @__PURE__ */ jsx15(Lock, { className: "h-6 w-6 text-muted-foreground" }) }),
|
|
744
|
+
/* @__PURE__ */ jsx15("h3", { className: "text-lg font-semibold mb-2", children: "No saved credentials" }),
|
|
745
|
+
/* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground mb-6 max-w-md", children: "Add API keys and account credentials for your agents to use securely." }),
|
|
746
|
+
/* @__PURE__ */ jsx15(Button4, { onClick: onAddCredential, children: "Add Credential" })
|
|
747
|
+
] });
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
// src/vault/vault-input-modal.tsx
|
|
751
|
+
import {
|
|
752
|
+
Button as Button5,
|
|
753
|
+
Dialog as Dialog3,
|
|
754
|
+
DialogContent as DialogContent3,
|
|
755
|
+
DialogFooter as DialogFooter2,
|
|
756
|
+
DialogHeader as DialogHeader3,
|
|
757
|
+
DialogTitle as DialogTitle3,
|
|
758
|
+
Input as Input3,
|
|
759
|
+
Label as Label2
|
|
760
|
+
} from "@mdxui/primitives";
|
|
761
|
+
import { Key } from "lucide-react";
|
|
762
|
+
import { useState as useState4 } from "react";
|
|
763
|
+
import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
764
|
+
function VaultInputModal({
|
|
765
|
+
isOpen,
|
|
766
|
+
onClose,
|
|
767
|
+
mode,
|
|
768
|
+
integration,
|
|
769
|
+
onSave
|
|
770
|
+
}) {
|
|
771
|
+
const [values, setValues] = useState4({});
|
|
772
|
+
const [loading, setLoading] = useState4(false);
|
|
773
|
+
const handleSubmit = async (e) => {
|
|
774
|
+
e.preventDefault();
|
|
775
|
+
setLoading(true);
|
|
776
|
+
try {
|
|
777
|
+
await onSave(values);
|
|
778
|
+
setValues({});
|
|
779
|
+
onClose();
|
|
780
|
+
} catch (error) {
|
|
781
|
+
console.error("Failed to save credentials:", error);
|
|
782
|
+
} finally {
|
|
783
|
+
setLoading(false);
|
|
784
|
+
}
|
|
785
|
+
};
|
|
786
|
+
const handleClose = () => {
|
|
787
|
+
setValues({});
|
|
788
|
+
onClose();
|
|
789
|
+
};
|
|
790
|
+
if (!integration) return null;
|
|
791
|
+
const isValid = integration.fields.filter((f) => f.required).every((f) => values[f.key]?.trim());
|
|
792
|
+
return /* @__PURE__ */ jsx16(Dialog3, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs6(DialogContent3, { children: [
|
|
793
|
+
/* @__PURE__ */ jsx16(DialogHeader3, { children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-3", children: [
|
|
794
|
+
/* @__PURE__ */ jsx16("div", { className: "flex h-10 w-10 items-center justify-center rounded-md bg-white overflow-hidden p-1 border border-border", children: integration.logoUrl ? /* @__PURE__ */ jsx16(
|
|
795
|
+
"img",
|
|
796
|
+
{
|
|
797
|
+
src: integration.logoUrl,
|
|
798
|
+
alt: integration.name,
|
|
799
|
+
width: 32,
|
|
800
|
+
height: 32,
|
|
801
|
+
className: "h-full w-full object-contain rounded-sm"
|
|
802
|
+
}
|
|
803
|
+
) : /* @__PURE__ */ jsx16(Key, { className: "h-5 w-5 text-muted-foreground" }) }),
|
|
804
|
+
/* @__PURE__ */ jsxs6(DialogTitle3, { children: [
|
|
805
|
+
mode === "create" ? "Add" : "Rotate",
|
|
806
|
+
" ",
|
|
807
|
+
integration.name,
|
|
808
|
+
" Credentials"
|
|
809
|
+
] })
|
|
810
|
+
] }) }),
|
|
811
|
+
/* @__PURE__ */ jsxs6("form", { onSubmit: handleSubmit, children: [
|
|
812
|
+
/* @__PURE__ */ jsx16("div", { className: "grid gap-4 py-4", children: integration.fields.map((field) => /* @__PURE__ */ jsxs6("div", { className: "grid gap-2", children: [
|
|
813
|
+
/* @__PURE__ */ jsxs6(Label2, { htmlFor: field.key, children: [
|
|
814
|
+
field.label,
|
|
815
|
+
field.required && /* @__PURE__ */ jsx16("span", { className: "text-destructive", children: "*" })
|
|
816
|
+
] }),
|
|
817
|
+
/* @__PURE__ */ jsx16(
|
|
818
|
+
Input3,
|
|
819
|
+
{
|
|
820
|
+
id: field.key,
|
|
821
|
+
type: field.type,
|
|
822
|
+
placeholder: field.placeholder,
|
|
823
|
+
value: values[field.key] || "",
|
|
824
|
+
onChange: (e) => setValues((prev) => ({
|
|
825
|
+
...prev,
|
|
826
|
+
[field.key]: e.target.value
|
|
827
|
+
})),
|
|
828
|
+
required: field.required
|
|
829
|
+
}
|
|
830
|
+
)
|
|
831
|
+
] }, field.key)) }),
|
|
832
|
+
/* @__PURE__ */ jsxs6(DialogFooter2, { children: [
|
|
833
|
+
/* @__PURE__ */ jsx16(Button5, { type: "button", variant: "outline", onClick: handleClose, children: "Cancel" }),
|
|
834
|
+
/* @__PURE__ */ jsx16(Button5, { type: "submit", disabled: loading || !isValid, children: loading ? "Saving..." : "Save" })
|
|
835
|
+
] })
|
|
836
|
+
] })
|
|
837
|
+
] }) });
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// src/vault/vault-item-card.tsx
|
|
841
|
+
import {
|
|
842
|
+
Button as Button6,
|
|
843
|
+
Card as Card2,
|
|
844
|
+
DropdownMenu,
|
|
845
|
+
DropdownMenuContent,
|
|
846
|
+
DropdownMenuItem,
|
|
847
|
+
DropdownMenuTrigger
|
|
848
|
+
} from "@mdxui/primitives";
|
|
849
|
+
import { Key as Key2, MoreVertical } from "lucide-react";
|
|
850
|
+
import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
851
|
+
function formatDate(date) {
|
|
852
|
+
return date.toLocaleDateString("en-US", {
|
|
853
|
+
month: "short",
|
|
854
|
+
day: "numeric",
|
|
855
|
+
year: "numeric"
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
function VaultItemCard({
|
|
859
|
+
id,
|
|
860
|
+
name,
|
|
861
|
+
logoUrl,
|
|
862
|
+
createdAt,
|
|
863
|
+
updatedAt,
|
|
864
|
+
onRotate,
|
|
865
|
+
onDelete
|
|
866
|
+
}) {
|
|
867
|
+
const wasRotated = updatedAt.getTime() !== createdAt.getTime();
|
|
868
|
+
return /* @__PURE__ */ jsx17(Card2, { noPadding: true, className: "p-4", children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center justify-between", children: [
|
|
869
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-3", children: [
|
|
870
|
+
/* @__PURE__ */ jsx17("div", { className: "flex h-10 w-10 items-center justify-center rounded-md bg-white overflow-hidden p-1 border border-border", children: logoUrl ? /* @__PURE__ */ jsx17(
|
|
871
|
+
"img",
|
|
872
|
+
{
|
|
873
|
+
src: logoUrl,
|
|
874
|
+
alt: name,
|
|
875
|
+
width: 32,
|
|
876
|
+
height: 32,
|
|
877
|
+
className: "h-full w-full object-contain rounded-sm"
|
|
878
|
+
}
|
|
879
|
+
) : /* @__PURE__ */ jsx17(Key2, { className: "h-5 w-5 text-muted-foreground" }) }),
|
|
880
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
881
|
+
/* @__PURE__ */ jsx17("h4", { className: "text-sm font-medium", children: name }),
|
|
882
|
+
/* @__PURE__ */ jsx17("p", { className: "text-xs text-muted-foreground", children: wasRotated ? `Rotated: ${formatDate(updatedAt)}` : `Created: ${formatDate(createdAt)}` })
|
|
883
|
+
] })
|
|
884
|
+
] }),
|
|
885
|
+
/* @__PURE__ */ jsxs7(DropdownMenu, { children: [
|
|
886
|
+
/* @__PURE__ */ jsx17(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs7(Button6, { variant: "ghost", size: "icon-sm", children: [
|
|
887
|
+
/* @__PURE__ */ jsx17(MoreVertical, { className: "h-4 w-4" }),
|
|
888
|
+
/* @__PURE__ */ jsx17("span", { className: "sr-only", children: "Open menu" })
|
|
889
|
+
] }) }),
|
|
890
|
+
/* @__PURE__ */ jsxs7(DropdownMenuContent, { align: "end", children: [
|
|
891
|
+
/* @__PURE__ */ jsx17(DropdownMenuItem, { onClick: () => onRotate(id), children: "Rotate" }),
|
|
892
|
+
/* @__PURE__ */ jsx17(
|
|
893
|
+
DropdownMenuItem,
|
|
894
|
+
{
|
|
895
|
+
className: "text-destructive focus:text-destructive",
|
|
896
|
+
onClick: () => onDelete(id),
|
|
897
|
+
children: "Delete"
|
|
898
|
+
}
|
|
899
|
+
)
|
|
900
|
+
] })
|
|
901
|
+
] })
|
|
902
|
+
] }) });
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
// src/vault/vault-list.tsx
|
|
906
|
+
import { useState as useState5 } from "react";
|
|
907
|
+
import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
908
|
+
var defaultFields2 = [
|
|
909
|
+
{ key: "api_key", label: "API Key", type: "password", required: true }
|
|
910
|
+
];
|
|
911
|
+
function VaultList({
|
|
912
|
+
items,
|
|
913
|
+
onRotate,
|
|
914
|
+
onDelete,
|
|
915
|
+
onOpenAddModal,
|
|
916
|
+
getIntegrationFields
|
|
917
|
+
}) {
|
|
918
|
+
const [deleteDialogOpen, setDeleteDialogOpen] = useState5(false);
|
|
919
|
+
const [inputModalOpen, setInputModalOpen] = useState5(false);
|
|
920
|
+
const [selectedItem, setSelectedItem] = useState5(null);
|
|
921
|
+
const [modalMode, setModalMode] = useState5("create");
|
|
922
|
+
const handleRotate = (id) => {
|
|
923
|
+
const item = items.find((i) => i.id === id);
|
|
924
|
+
if (!item) return;
|
|
925
|
+
setSelectedItem(item);
|
|
926
|
+
setModalMode("rotate");
|
|
927
|
+
setInputModalOpen(true);
|
|
928
|
+
};
|
|
929
|
+
const handleDeleteClick = (id) => {
|
|
930
|
+
const item = items.find((i) => i.id === id);
|
|
931
|
+
if (!item) return;
|
|
932
|
+
setSelectedItem(item);
|
|
933
|
+
setDeleteDialogOpen(true);
|
|
934
|
+
};
|
|
935
|
+
const handleConfirmDelete = async () => {
|
|
936
|
+
if (!selectedItem) return;
|
|
937
|
+
await onDelete(selectedItem.id);
|
|
938
|
+
setDeleteDialogOpen(false);
|
|
939
|
+
setSelectedItem(null);
|
|
940
|
+
};
|
|
941
|
+
const handleSave = async (credentials) => {
|
|
942
|
+
if (modalMode === "rotate" && selectedItem) {
|
|
943
|
+
await onRotate(selectedItem.id, credentials);
|
|
944
|
+
}
|
|
945
|
+
setInputModalOpen(false);
|
|
946
|
+
setSelectedItem(null);
|
|
947
|
+
};
|
|
948
|
+
const getIntegrationForModal = () => {
|
|
949
|
+
if (!selectedItem) return void 0;
|
|
950
|
+
const fields = getIntegrationFields ? getIntegrationFields(selectedItem.integrationId) : defaultFields2;
|
|
951
|
+
return {
|
|
952
|
+
id: selectedItem.integrationId,
|
|
953
|
+
name: selectedItem.name,
|
|
954
|
+
logoUrl: selectedItem.logoUrl,
|
|
955
|
+
fields
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
if (items.length === 0) {
|
|
959
|
+
return /* @__PURE__ */ jsx18(VaultEmptyState, { onAddCredential: onOpenAddModal });
|
|
960
|
+
}
|
|
961
|
+
return /* @__PURE__ */ jsxs8(Fragment2, { children: [
|
|
962
|
+
/* @__PURE__ */ jsx18("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: items.map((item) => /* @__PURE__ */ jsx18(
|
|
963
|
+
VaultItemCard,
|
|
964
|
+
{
|
|
965
|
+
id: item.id,
|
|
966
|
+
name: item.name,
|
|
967
|
+
logoUrl: item.logoUrl,
|
|
968
|
+
createdAt: item.createdAt,
|
|
969
|
+
updatedAt: item.updatedAt,
|
|
970
|
+
onRotate: handleRotate,
|
|
971
|
+
onDelete: handleDeleteClick
|
|
972
|
+
},
|
|
973
|
+
item.id
|
|
974
|
+
)) }),
|
|
975
|
+
/* @__PURE__ */ jsx18(
|
|
976
|
+
VaultDeleteDialog,
|
|
977
|
+
{
|
|
978
|
+
isOpen: deleteDialogOpen,
|
|
979
|
+
onClose: () => {
|
|
980
|
+
setDeleteDialogOpen(false);
|
|
981
|
+
setSelectedItem(null);
|
|
982
|
+
},
|
|
983
|
+
itemName: selectedItem?.name || "",
|
|
984
|
+
onConfirm: handleConfirmDelete
|
|
985
|
+
}
|
|
986
|
+
),
|
|
987
|
+
/* @__PURE__ */ jsx18(
|
|
988
|
+
VaultInputModal,
|
|
989
|
+
{
|
|
990
|
+
isOpen: inputModalOpen,
|
|
991
|
+
onClose: () => {
|
|
992
|
+
setInputModalOpen(false);
|
|
993
|
+
setSelectedItem(null);
|
|
994
|
+
},
|
|
995
|
+
mode: modalMode,
|
|
996
|
+
integration: getIntegrationForModal(),
|
|
997
|
+
onSave: handleSave
|
|
998
|
+
}
|
|
999
|
+
)
|
|
1000
|
+
] });
|
|
1001
|
+
}
|
|
1002
|
+
|
|
255
1003
|
// src/components/sign-in-button.tsx
|
|
256
1004
|
import { useAuth as useAuth2 } from "@workos-inc/authkit-react";
|
|
257
|
-
import { jsx as
|
|
1005
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
258
1006
|
function SignInButton({
|
|
259
1007
|
children = "Sign In",
|
|
260
1008
|
onSignIn,
|
|
@@ -267,7 +1015,7 @@ function SignInButton({
|
|
|
267
1015
|
onSignIn?.();
|
|
268
1016
|
signIn();
|
|
269
1017
|
};
|
|
270
|
-
return /* @__PURE__ */
|
|
1018
|
+
return /* @__PURE__ */ jsx19(
|
|
271
1019
|
"button",
|
|
272
1020
|
{
|
|
273
1021
|
type: "button",
|
|
@@ -282,7 +1030,7 @@ function SignInButton({
|
|
|
282
1030
|
|
|
283
1031
|
// src/components/sign-out-button.tsx
|
|
284
1032
|
import { useAuth as useAuth3 } from "@workos-inc/authkit-react";
|
|
285
|
-
import { jsx as
|
|
1033
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
286
1034
|
function SignOutButton({
|
|
287
1035
|
children = "Sign Out",
|
|
288
1036
|
onSignOut,
|
|
@@ -295,7 +1043,7 @@ function SignOutButton({
|
|
|
295
1043
|
onSignOut?.();
|
|
296
1044
|
signOut();
|
|
297
1045
|
};
|
|
298
|
-
return /* @__PURE__ */
|
|
1046
|
+
return /* @__PURE__ */ jsx20(
|
|
299
1047
|
"button",
|
|
300
1048
|
{
|
|
301
1049
|
type: "button",
|
|
@@ -310,7 +1058,7 @@ function SignOutButton({
|
|
|
310
1058
|
|
|
311
1059
|
// src/components/user-menu.tsx
|
|
312
1060
|
import { useAuth as useAuth4 } from "@workos-inc/authkit-react";
|
|
313
|
-
import { jsx as
|
|
1061
|
+
import { jsx as jsx21, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
314
1062
|
function getInitials(name) {
|
|
315
1063
|
if (!name) return "?";
|
|
316
1064
|
const parts = name.trim().split(/\s+/);
|
|
@@ -320,7 +1068,7 @@ function getInitials(name) {
|
|
|
320
1068
|
function UserMenu({ renderTrigger, renderMenu, className }) {
|
|
321
1069
|
const { user, signOut, isLoading } = useAuth4();
|
|
322
1070
|
if (isLoading) {
|
|
323
|
-
return /* @__PURE__ */
|
|
1071
|
+
return /* @__PURE__ */ jsx21("div", { className, children: /* @__PURE__ */ jsx21("div", { className: "flex items-center gap-2 p-2", children: /* @__PURE__ */ jsx21("div", { className: "h-8 w-8 animate-pulse rounded-full bg-muted" }) }) });
|
|
324
1072
|
}
|
|
325
1073
|
if (!user) {
|
|
326
1074
|
return null;
|
|
@@ -332,8 +1080,8 @@ function UserMenu({ renderTrigger, renderMenu, className }) {
|
|
|
332
1080
|
const triggerProps = { user, displayName, initials };
|
|
333
1081
|
const menuProps = { user, displayName, initials, signOut };
|
|
334
1082
|
if (!renderTrigger && !renderMenu) {
|
|
335
|
-
return /* @__PURE__ */
|
|
336
|
-
/* @__PURE__ */
|
|
1083
|
+
return /* @__PURE__ */ jsx21("div", { className, children: /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2 p-2", children: [
|
|
1084
|
+
/* @__PURE__ */ jsx21("div", { className: "h-8 w-8 rounded-full bg-muted flex items-center justify-center text-sm font-medium", children: user.profilePictureUrl ? /* @__PURE__ */ jsx21(
|
|
337
1085
|
"img",
|
|
338
1086
|
{
|
|
339
1087
|
src: user.profilePictureUrl,
|
|
@@ -341,11 +1089,11 @@ function UserMenu({ renderTrigger, renderMenu, className }) {
|
|
|
341
1089
|
className: "h-full w-full rounded-full object-cover"
|
|
342
1090
|
}
|
|
343
1091
|
) : initials }),
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
-
/* @__PURE__ */
|
|
346
|
-
/* @__PURE__ */
|
|
1092
|
+
/* @__PURE__ */ jsxs9("div", { className: "text-sm", children: [
|
|
1093
|
+
/* @__PURE__ */ jsx21("p", { className: "font-medium", children: displayName }),
|
|
1094
|
+
/* @__PURE__ */ jsx21("p", { className: "text-muted-foreground text-xs", children: user.email })
|
|
347
1095
|
] }),
|
|
348
|
-
/* @__PURE__ */
|
|
1096
|
+
/* @__PURE__ */ jsx21(
|
|
349
1097
|
"button",
|
|
350
1098
|
{
|
|
351
1099
|
type: "button",
|
|
@@ -356,7 +1104,7 @@ function UserMenu({ renderTrigger, renderMenu, className }) {
|
|
|
356
1104
|
)
|
|
357
1105
|
] }) });
|
|
358
1106
|
}
|
|
359
|
-
return /* @__PURE__ */
|
|
1107
|
+
return /* @__PURE__ */ jsxs9("div", { className, children: [
|
|
360
1108
|
renderTrigger?.(triggerProps),
|
|
361
1109
|
renderMenu?.(menuProps)
|
|
362
1110
|
] });
|
|
@@ -365,7 +1113,7 @@ function UserMenu({ renderTrigger, renderMenu, className }) {
|
|
|
365
1113
|
// src/components/team-switcher.tsx
|
|
366
1114
|
import { useAuth as useAuth5 } from "@workos-inc/authkit-react";
|
|
367
1115
|
import { OrganizationSwitcher as OrganizationSwitcher2 } from "@workos-inc/widgets";
|
|
368
|
-
import { jsx as
|
|
1116
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
369
1117
|
function TeamSwitcher({
|
|
370
1118
|
renderWrapper,
|
|
371
1119
|
renderNoOrganization,
|
|
@@ -380,7 +1128,7 @@ function TeamSwitcher({
|
|
|
380
1128
|
}) => {
|
|
381
1129
|
return switchToOrganization({ organizationId: organizationId2 });
|
|
382
1130
|
};
|
|
383
|
-
const widget = /* @__PURE__ */
|
|
1131
|
+
const widget = /* @__PURE__ */ jsx22("div", { className: `organization-switcher-wrapper ${className ?? ""}`, children: /* @__PURE__ */ jsx22(
|
|
384
1132
|
OrganizationSwitcher2,
|
|
385
1133
|
{
|
|
386
1134
|
authToken: getAccessToken,
|
|
@@ -394,15 +1142,15 @@ function TeamSwitcher({
|
|
|
394
1142
|
import { useAuth as useAuth6 } from "@workos-inc/authkit-react";
|
|
395
1143
|
|
|
396
1144
|
// src/hooks/use-widget-token.ts
|
|
397
|
-
import { useCallback, useEffect as
|
|
1145
|
+
import { useCallback, useEffect as useEffect3, useState as useState6 } from "react";
|
|
398
1146
|
function useWidgetToken({
|
|
399
1147
|
widget,
|
|
400
1148
|
organizationId,
|
|
401
1149
|
endpoint = "/api/workos/widget-token"
|
|
402
1150
|
}) {
|
|
403
|
-
const [token, setToken] =
|
|
404
|
-
const [loading, setLoading] =
|
|
405
|
-
const [error, setError] =
|
|
1151
|
+
const [token, setToken] = useState6(null);
|
|
1152
|
+
const [loading, setLoading] = useState6(true);
|
|
1153
|
+
const [error, setError] = useState6(null);
|
|
406
1154
|
const fetchToken = useCallback(async () => {
|
|
407
1155
|
try {
|
|
408
1156
|
setLoading(true);
|
|
@@ -423,12 +1171,77 @@ function useWidgetToken({
|
|
|
423
1171
|
setLoading(false);
|
|
424
1172
|
}
|
|
425
1173
|
}, [widget, organizationId, endpoint]);
|
|
426
|
-
|
|
1174
|
+
useEffect3(() => {
|
|
427
1175
|
fetchToken();
|
|
428
1176
|
}, [fetchToken]);
|
|
429
1177
|
return { token, loading, error, refetch: fetchToken };
|
|
430
1178
|
}
|
|
431
1179
|
|
|
1180
|
+
// src/hooks/use-vault.ts
|
|
1181
|
+
import { useCallback as useCallback2, useMemo as useMemo3 } from "react";
|
|
1182
|
+
function useVault() {
|
|
1183
|
+
const context = useVaultContext();
|
|
1184
|
+
const findItem = useCallback2(
|
|
1185
|
+
(id) => {
|
|
1186
|
+
return context.items.find((item) => item.id === id);
|
|
1187
|
+
},
|
|
1188
|
+
[context.items]
|
|
1189
|
+
);
|
|
1190
|
+
const findByIntegration = useCallback2(
|
|
1191
|
+
(integrationId) => {
|
|
1192
|
+
return context.items.filter((item) => item.integrationId === integrationId);
|
|
1193
|
+
},
|
|
1194
|
+
[context.items]
|
|
1195
|
+
);
|
|
1196
|
+
return useMemo3(
|
|
1197
|
+
() => ({
|
|
1198
|
+
items: context.items,
|
|
1199
|
+
loading: context.loading,
|
|
1200
|
+
error: context.error,
|
|
1201
|
+
isConnected: context.client !== null,
|
|
1202
|
+
reload: context.reload,
|
|
1203
|
+
create: context.createItem,
|
|
1204
|
+
rotate: context.rotateItem,
|
|
1205
|
+
remove: context.deleteItem,
|
|
1206
|
+
getIntegrationFields: context.getIntegrationFields,
|
|
1207
|
+
findItem,
|
|
1208
|
+
findByIntegration
|
|
1209
|
+
}),
|
|
1210
|
+
[context, findItem, findByIntegration]
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
function useVaultOptional() {
|
|
1214
|
+
const context = useVaultContextOptional();
|
|
1215
|
+
const findItem = useCallback2(
|
|
1216
|
+
(id) => {
|
|
1217
|
+
return context?.items.find((item) => item.id === id);
|
|
1218
|
+
},
|
|
1219
|
+
[context?.items]
|
|
1220
|
+
);
|
|
1221
|
+
const findByIntegration = useCallback2(
|
|
1222
|
+
(integrationId) => {
|
|
1223
|
+
return context?.items.filter((item) => item.integrationId === integrationId) ?? [];
|
|
1224
|
+
},
|
|
1225
|
+
[context?.items]
|
|
1226
|
+
);
|
|
1227
|
+
if (!context) {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
return {
|
|
1231
|
+
items: context.items,
|
|
1232
|
+
loading: context.loading,
|
|
1233
|
+
error: context.error,
|
|
1234
|
+
isConnected: context.client !== null,
|
|
1235
|
+
reload: context.reload,
|
|
1236
|
+
create: context.createItem,
|
|
1237
|
+
rotate: context.rotateItem,
|
|
1238
|
+
remove: context.deleteItem,
|
|
1239
|
+
getIntegrationFields: context.getIntegrationFields,
|
|
1240
|
+
findItem,
|
|
1241
|
+
findByIntegration
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
|
|
432
1245
|
// src/schemas/auth-user.ts
|
|
433
1246
|
import { z } from "zod";
|
|
434
1247
|
import { UserIdentitySchema } from "mdxui/zod";
|
|
@@ -572,6 +1385,8 @@ export {
|
|
|
572
1385
|
Pipes,
|
|
573
1386
|
RadiusSchema,
|
|
574
1387
|
ScalingSchema,
|
|
1388
|
+
SecretForm,
|
|
1389
|
+
SecretsManager,
|
|
575
1390
|
SignInButton,
|
|
576
1391
|
SignOutButton,
|
|
577
1392
|
TeamSwitcher,
|
|
@@ -583,10 +1398,20 @@ export {
|
|
|
583
1398
|
UserSecurity,
|
|
584
1399
|
UserSessions,
|
|
585
1400
|
UsersManagement,
|
|
1401
|
+
VaultDeleteDialog,
|
|
1402
|
+
VaultEmptyState,
|
|
1403
|
+
VaultInputModal,
|
|
1404
|
+
VaultItemCard,
|
|
1405
|
+
VaultList,
|
|
1406
|
+
VaultProvider,
|
|
586
1407
|
WidgetsProvider,
|
|
587
1408
|
WidgetsProviderPropsSchema,
|
|
588
1409
|
useAuth6 as useAuth,
|
|
589
1410
|
useThemeDetection,
|
|
1411
|
+
useVault,
|
|
1412
|
+
useVaultContext,
|
|
1413
|
+
useVaultContextOptional,
|
|
1414
|
+
useVaultOptional,
|
|
590
1415
|
useWidgetToken
|
|
591
1416
|
};
|
|
592
1417
|
//# sourceMappingURL=index.js.map
|