@burdenoff/microfe-security 2026.519.1 → 2026.523.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/dist/security/pages/SecretCreatePage.d.ts.map +1 -1
- package/dist/security/pages/SecretCreatePage.js +69 -58
- package/dist/security/pages/SecretCreatePage.js.map +1 -1
- package/dist/security/pages/VaultCreatePage.d.ts.map +1 -1
- package/dist/security/pages/VaultCreatePage.js +49 -38
- package/dist/security/pages/VaultCreatePage.js.map +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretCreatePage.d.ts","sourceRoot":"","sources":["../../../src/security/pages/SecretCreatePage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SecretCreatePage.d.ts","sourceRoot":"","sources":["../../../src/security/pages/SecretCreatePage.tsx"],"names":[],"mappings":"AA6BA,wBAAgB,gBAAgB,4CAqN/B"}
|
|
@@ -13,34 +13,37 @@ import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
|
13
13
|
import { AlertTriangle as g, ArrowLeft as _, Info as v, Loader2 as y, Save as b, ShieldCheck as x } from "lucide-react";
|
|
14
14
|
import { useI18n as S } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
15
15
|
//#region src/security/pages/SecretCreatePage.tsx
|
|
16
|
-
function C() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
function C(e) {
|
|
17
|
+
return e instanceof Error && ("graphQLErrors" in e || "networkError" in e || "clientErrors" in e);
|
|
18
|
+
}
|
|
19
|
+
function w() {
|
|
20
|
+
let { vaultId: w } = p(), { basePath: T = "/", navigate: E } = e(), D = f(), { t: O } = S(), k = (e, t, n) => i(O, e, t, n), [A, { loading: j }] = o(), { emit: M } = a(), [N, P] = d("CREDENTIAL"), [F, I] = d(""), [L, R] = d(""), [z, B] = d(""), [V, H] = d([]), [U, W] = d(null), G = (e) => {
|
|
21
|
+
E ? E(e) : D(e);
|
|
22
|
+
}, K = () => {
|
|
23
|
+
G(`${T}/vaults/${w}`);
|
|
21
24
|
};
|
|
22
25
|
return /* @__PURE__ */ m(u, {
|
|
23
26
|
permission: "secret:create",
|
|
24
27
|
children: /* @__PURE__ */ m(t, {
|
|
25
|
-
title:
|
|
26
|
-
description:
|
|
28
|
+
title: k("security.secretCreate.title", "Add New Secret"),
|
|
29
|
+
description: k("security.secretCreate.description", "Store a new credential, API key, or sensitive text securely."),
|
|
27
30
|
breadcrumbs: [
|
|
28
31
|
{
|
|
29
|
-
label:
|
|
30
|
-
path:
|
|
32
|
+
label: k("security.common.breadcrumbs.security", "Security"),
|
|
33
|
+
path: T
|
|
31
34
|
},
|
|
32
35
|
{
|
|
33
|
-
label:
|
|
34
|
-
path: `${
|
|
36
|
+
label: k("security.common.breadcrumbs.vault", "Vault"),
|
|
37
|
+
path: `${T}/vaults/${w}`
|
|
35
38
|
},
|
|
36
|
-
{ label:
|
|
39
|
+
{ label: k("security.secretCreate.breadcrumb", "New Secret") }
|
|
37
40
|
],
|
|
38
41
|
actions: /* @__PURE__ */ h(n, {
|
|
39
42
|
variant: "outline",
|
|
40
43
|
size: "sm",
|
|
41
|
-
onClick:
|
|
42
|
-
"aria-label":
|
|
43
|
-
children: [/* @__PURE__ */ m(_, { className: "h-4 w-4" }),
|
|
44
|
+
onClick: K,
|
|
45
|
+
"aria-label": k("security.secretCreate.actions.backToVault", "Back to Vault"),
|
|
46
|
+
children: [/* @__PURE__ */ m(_, { className: "h-4 w-4" }), k("security.secretCreate.actions.backToVault", "Back to Vault")]
|
|
44
47
|
}),
|
|
45
48
|
children: /* @__PURE__ */ h("div", {
|
|
46
49
|
className: "grid grid-cols-1 lg:grid-cols-3 gap-8",
|
|
@@ -50,60 +53,68 @@ function C() {
|
|
|
50
53
|
className: "p-6 shadow-md border-border/60",
|
|
51
54
|
children: [
|
|
52
55
|
/* @__PURE__ */ m(l, {
|
|
53
|
-
type:
|
|
54
|
-
onTypeChange:
|
|
55
|
-
name:
|
|
56
|
-
onNameChange:
|
|
57
|
-
value:
|
|
58
|
-
onValueChange:
|
|
59
|
-
description:
|
|
60
|
-
onDescriptionChange:
|
|
61
|
-
labels:
|
|
62
|
-
onLabelsChange:
|
|
56
|
+
type: N,
|
|
57
|
+
onTypeChange: P,
|
|
58
|
+
name: F,
|
|
59
|
+
onNameChange: I,
|
|
60
|
+
value: L,
|
|
61
|
+
onValueChange: R,
|
|
62
|
+
description: z,
|
|
63
|
+
onDescriptionChange: B,
|
|
64
|
+
labels: V,
|
|
65
|
+
onLabelsChange: H
|
|
63
66
|
}),
|
|
64
|
-
|
|
67
|
+
U && /* @__PURE__ */ h("div", {
|
|
65
68
|
className: "mt-6 p-3 rounded-md bg-destructive/10 text-destructive text-sm border border-destructive/20 flex items-start gap-2",
|
|
66
|
-
children: [/* @__PURE__ */ m(g, { className: "h-4 w-4 shrink-0 mt-0.5" }),
|
|
69
|
+
children: [/* @__PURE__ */ m(g, { className: "h-4 w-4 shrink-0 mt-0.5" }), U]
|
|
67
70
|
}),
|
|
68
71
|
/* @__PURE__ */ h("div", {
|
|
69
72
|
className: "flex justify-end gap-3 mt-8 pt-6 border-t border-border/60",
|
|
70
73
|
children: [/* @__PURE__ */ m(n, {
|
|
71
74
|
variant: "outline",
|
|
72
|
-
onClick:
|
|
73
|
-
disabled:
|
|
74
|
-
"aria-label":
|
|
75
|
-
children:
|
|
75
|
+
onClick: K,
|
|
76
|
+
disabled: j,
|
|
77
|
+
"aria-label": k("security.secretCreate.actions.cancel", "Cancel"),
|
|
78
|
+
children: k("security.secretCreate.actions.cancel", "Cancel")
|
|
76
79
|
}), /* @__PURE__ */ h(n, {
|
|
77
80
|
onClick: async () => {
|
|
78
|
-
if (s("light"), !
|
|
79
|
-
|
|
81
|
+
if (s("light"), !F.trim()) {
|
|
82
|
+
W(k("security.secretCreate.error.nameRequired", "Name is required."));
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
|
-
if (!
|
|
83
|
-
|
|
85
|
+
if (!L.trim()) {
|
|
86
|
+
W(k("security.secretCreate.error.valueRequired", "Value is required."));
|
|
84
87
|
return;
|
|
85
88
|
}
|
|
86
|
-
|
|
89
|
+
W(null);
|
|
87
90
|
try {
|
|
88
|
-
let e = await
|
|
89
|
-
vaultId:
|
|
90
|
-
name:
|
|
91
|
-
key:
|
|
92
|
-
value:
|
|
93
|
-
type:
|
|
94
|
-
description:
|
|
95
|
-
tags:
|
|
91
|
+
let e = await A({ variables: { input: {
|
|
92
|
+
vaultId: w ?? "",
|
|
93
|
+
name: F.trim(),
|
|
94
|
+
key: F.trim().toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, ""),
|
|
95
|
+
value: L.trim(),
|
|
96
|
+
type: N,
|
|
97
|
+
description: z.trim() || void 0,
|
|
98
|
+
tags: V.length > 0 ? V : void 0
|
|
96
99
|
} } });
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
100
|
+
if (e.error) {
|
|
101
|
+
W(e.error.message ?? k("security.secretCreate.error.createFailed", "Failed to create secret")), c("error");
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (e.data?.createSecret?.id) {
|
|
105
|
+
M("secret.created", {
|
|
106
|
+
secretId: e.data.createSecret.id,
|
|
107
|
+
vaultId: w
|
|
108
|
+
}), c("success"), K();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
W(k("security.secretCreate.error.createFailed", "Failed to create secret")), c("error");
|
|
101
112
|
} catch (e) {
|
|
102
|
-
|
|
113
|
+
W(C(e) ? e.message : k("security.secretCreate.error.createFailed", "Failed to create secret")), c("error");
|
|
103
114
|
}
|
|
104
115
|
},
|
|
105
|
-
disabled:
|
|
106
|
-
children: [
|
|
116
|
+
disabled: j || !F.trim() || !L.trim(),
|
|
117
|
+
children: [j ? /* @__PURE__ */ m(y, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ m(b, { className: "h-4 w-4" }), j ? k("security.secretCreate.actions.creating", "Creating...") : k("security.secretCreate.actions.createSecret", "Create Secret")]
|
|
107
118
|
})]
|
|
108
119
|
})
|
|
109
120
|
]
|
|
@@ -114,22 +125,22 @@ function C() {
|
|
|
114
125
|
className: "p-6 bg-primary/5 border-primary/10 shadow-sm",
|
|
115
126
|
children: [/* @__PURE__ */ h("h3", {
|
|
116
127
|
className: "text-sm font-bold text-primary flex items-center gap-2 mb-3 uppercase tracking-wider",
|
|
117
|
-
children: [/* @__PURE__ */ m(x, { className: "h-4 w-4" }),
|
|
128
|
+
children: [/* @__PURE__ */ m(x, { className: "h-4 w-4" }), k("security.secretCreate.secureStorage.title", "Secure Storage")]
|
|
118
129
|
}), /* @__PURE__ */ m("p", {
|
|
119
130
|
className: "text-xs text-muted-foreground leading-relaxed",
|
|
120
|
-
children:
|
|
131
|
+
children: k("security.secretCreate.secureStorage.description", "Your secret will be encrypted using a vault-specific key derived from the master encryption system. Once saved, the plain-text value is never shown unless explicitly revealed by an authorized user.")
|
|
121
132
|
})]
|
|
122
133
|
}), /* @__PURE__ */ h(r, {
|
|
123
134
|
className: "p-6 border-border/60 shadow-sm",
|
|
124
135
|
children: [/* @__PURE__ */ h("h3", {
|
|
125
136
|
className: "text-sm font-bold text-foreground flex items-center gap-2 mb-3",
|
|
126
|
-
children: [/* @__PURE__ */ m(v, { className: "h-4 w-4 text-muted-foreground" }),
|
|
137
|
+
children: [/* @__PURE__ */ m(v, { className: "h-4 w-4 text-muted-foreground" }), k("security.secretCreate.namingTips.title", "Naming Tips")]
|
|
127
138
|
}), /* @__PURE__ */ h("ul", {
|
|
128
139
|
className: "text-xs text-muted-foreground space-y-2 list-disc pl-4",
|
|
129
140
|
children: [
|
|
130
|
-
/* @__PURE__ */ m("li", { children:
|
|
131
|
-
/* @__PURE__ */ m("li", { children:
|
|
132
|
-
/* @__PURE__ */ m("li", { children:
|
|
141
|
+
/* @__PURE__ */ m("li", { children: k("security.secretCreate.namingTips.productionDb", "Use descriptive names like Production Database URL") }),
|
|
142
|
+
/* @__PURE__ */ m("li", { children: k("security.secretCreate.namingTips.autoKey", "A unique key will be automatically generated from the name") }),
|
|
143
|
+
/* @__PURE__ */ m("li", { children: k("security.secretCreate.namingTips.labels", "You can add labels to group secrets by environment or project") })
|
|
133
144
|
]
|
|
134
145
|
})]
|
|
135
146
|
})]
|
|
@@ -139,6 +150,6 @@ function C() {
|
|
|
139
150
|
});
|
|
140
151
|
}
|
|
141
152
|
//#endregion
|
|
142
|
-
export {
|
|
153
|
+
export { w as SecretCreatePage };
|
|
143
154
|
|
|
144
155
|
//# sourceMappingURL=SecretCreatePage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SecretCreatePage.js","names":[],"sources":["../../../src/security/pages/SecretCreatePage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useParams, useNavigate } from 'react-router-dom';\nimport { Save, ArrowLeft, Loader2, ShieldCheck, Info, AlertTriangle } from 'lucide-react';\nimport { PageLayout } from '../components/PageLayout';\nimport { SecretFormFields } from '../components/SecretFormFields';\nimport { Button, Card } from '../components/ui';\nimport { useCreateSecret } from '../hooks/useSecretQueries';\nimport { useSecurityEventEmitter } from '../hooks/useSecurityEventEmitter';\nimport { useSecurity } from '../providers/SecurityProvider';\nimport { SecurityPermissionGuard } from '../components/SecurityPermissionGuard';\nimport { cn } from '../utils/cn';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { translateWithFallback } from '../utils/i18n';\nimport type { SecretType } from '../types';\nimport { nativeImpact, nativeNotify } from '../../utils/nativeBridge';\n\nexport function SecretCreatePage() {\n const { vaultId } = useParams<{ vaultId: string }>();\n const { basePath = '/', navigate: shellNavigate } = useSecurity();\n const routerNavigate = useNavigate();\n const { t } = useI18n();\n const tx = (key: string, fallback: string, params?: Record<string, string | number>) =>\n translateWithFallback(t, key, fallback, params);\n\n const [createSecret, { loading: creating }] = useCreateSecret();\n const { emit } = useSecurityEventEmitter();\n\n const [type, setType] = useState<SecretType>('CREDENTIAL');\n const [name, setName] = useState('');\n const [value, setValue] = useState('');\n const [description, setDescription] = useState('');\n const [labels, setLabels] = useState<string[]>([]);\n const [error, setError] = useState<string | null>(null);\n\n const handleNavigate = (path: string) => {\n if (shellNavigate) {\n shellNavigate(path);\n } else {\n routerNavigate(path);\n }\n };\n\n const handleBack = () => {\n handleNavigate(`${basePath}/vaults/${vaultId}`);\n };\n\n const handleSave = async () => {\n void nativeImpact('light');\n if (!name.trim()) {\n setError(tx('security.secretCreate.error.nameRequired', 'Name is required.'));\n return;\n }\n if (!value.trim()) {\n setError(tx('security.secretCreate.error.valueRequired', 'Value is required.'));\n return;\n }\n\n setError(null);\n\n try {\n const result = await createSecret({\n variables: {\n input: {\n vaultId: vaultId ?? '',\n name: name.trim(),\n key: name\n .trim()\n .toLowerCase()\n .replace(/\\s+/g, '_')\n .replace(/[^a-z0-9_]/g, ''),\n value: value.trim(),\n type,\n description: description.trim() || undefined,\n tags: labels.length > 0 ? labels : undefined,\n },\n },\n });\n if (result.data?.createSecret?.id) {\n emit('secret.created', { secretId: result.data.createSecret.id, vaultId });\n }\n void nativeNotify('success');\n handleBack();\n } catch (err) {\n setError(\n err instanceof Error\n ? err.message\n : tx('security.secretCreate.error.createFailed', 'Failed to create secret')\n );\n void nativeNotify('error');\n }\n };\n\n return (\n <SecurityPermissionGuard permission=\"secret:create\">\n <PageLayout\n title={tx('security.secretCreate.title', 'Add New Secret')}\n description={tx(\n 'security.secretCreate.description',\n 'Store a new credential, API key, or sensitive text securely.'\n )}\n breadcrumbs={[\n { label: tx('security.common.breadcrumbs.security', 'Security'), path: basePath },\n {\n label: tx('security.common.breadcrumbs.vault', 'Vault'),\n path: `${basePath}/vaults/${vaultId}`,\n },\n { label: tx('security.secretCreate.breadcrumb', 'New Secret') },\n ]}\n actions={\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleBack}\n aria-label={tx('security.secretCreate.actions.backToVault', 'Back to Vault')}\n >\n <ArrowLeft className=\"h-4 w-4\" />\n {tx('security.secretCreate.actions.backToVault', 'Back to Vault')}\n </Button>\n }\n >\n <div className=\"grid grid-cols-1 lg:grid-cols-3 gap-8\">\n <div className=\"lg:col-span-2\">\n <Card className=\"p-6 shadow-md border-border/60\">\n <SecretFormFields\n type={type}\n onTypeChange={setType}\n name={name}\n onNameChange={setName}\n value={value}\n onValueChange={setValue}\n description={description}\n onDescriptionChange={setDescription}\n labels={labels}\n onLabelsChange={setLabels}\n />\n\n {error && (\n <div className=\"mt-6 p-3 rounded-md bg-destructive/10 text-destructive text-sm border border-destructive/20 flex items-start gap-2\">\n <AlertTriangle className=\"h-4 w-4 shrink-0 mt-0.5\" />\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3 mt-8 pt-6 border-t border-border/60\">\n <Button\n variant=\"outline\"\n onClick={handleBack}\n disabled={creating}\n aria-label={tx('security.secretCreate.actions.cancel', 'Cancel')}\n >\n {tx('security.secretCreate.actions.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSave} disabled={creating || !name.trim() || !value.trim()}>\n {creating ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <Save className=\"h-4 w-4\" />\n )}\n {creating\n ? tx('security.secretCreate.actions.creating', 'Creating...')\n : tx('security.secretCreate.actions.createSecret', 'Create Secret')}\n </Button>\n </div>\n </Card>\n </div>\n\n <div className=\"space-y-6\">\n <Card className=\"p-6 bg-primary/5 border-primary/10 shadow-sm\">\n <h3 className=\"text-sm font-bold text-primary flex items-center gap-2 mb-3 uppercase tracking-wider\">\n <ShieldCheck className=\"h-4 w-4\" />\n {tx('security.secretCreate.secureStorage.title', 'Secure Storage')}\n </h3>\n <p className=\"text-xs text-muted-foreground leading-relaxed\">\n {tx(\n 'security.secretCreate.secureStorage.description',\n 'Your secret will be encrypted using a vault-specific key derived from the master encryption system. Once saved, the plain-text value is never shown unless explicitly revealed by an authorized user.'\n )}\n </p>\n </Card>\n\n <Card className=\"p-6 border-border/60 shadow-sm\">\n <h3 className=\"text-sm font-bold text-foreground flex items-center gap-2 mb-3\">\n <Info className=\"h-4 w-4 text-muted-foreground\" />\n {tx('security.secretCreate.namingTips.title', 'Naming Tips')}\n </h3>\n <ul className=\"text-xs text-muted-foreground space-y-2 list-disc pl-4\">\n <li>\n {tx(\n 'security.secretCreate.namingTips.productionDb',\n 'Use descriptive names like Production Database URL'\n )}\n </li>\n <li>\n {tx(\n 'security.secretCreate.namingTips.autoKey',\n 'A unique key will be automatically generated from the name'\n )}\n </li>\n <li>\n {tx(\n 'security.secretCreate.namingTips.labels',\n 'You can add labels to group secrets by environment or project'\n )}\n </li>\n </ul>\n </Card>\n </div>\n </div>\n </PageLayout>\n </SecurityPermissionGuard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgBA,SAAgB,IAAmB;CACjC,IAAM,EAAE,eAAY,GAAgC,EAC9C,EAAE,cAAW,KAAK,UAAU,MAAkB,GAAa,EAC3D,IAAiB,GAAa,EAC9B,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,GAAkB,MACzC,EAAsB,GAAG,GAAK,GAAU,EAAO,EAE3C,CAAC,GAAc,EAAE,SAAS,OAAc,GAAiB,EACzD,EAAE,YAAS,GAAyB,EAEpC,CAAC,GAAM,KAAW,EAAqB,aAAa,EACpD,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAO,KAAY,EAAS,GAAG,EAChC,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAQ,KAAa,EAAmB,EAAE,CAAC,EAC5C,CAAC,GAAO,KAAY,EAAwB,KAAK,EAEjD,KAAkB,MAAiB;AACvC,EAAI,IACF,EAAc,EAAK,GAEnB,EAAe,EAAK;IAIlB,UAAmB;AACvB,IAAe,GAAG,EAAS,UAAU,IAAU;;AAiDjD,QACE,kBAAC,GAAD;EAAyB,YAAW;YAClC,kBAAC,GAAD;GACE,OAAO,EAAG,+BAA+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AC,MAAD,EAAA,UACG,EACC,4CACA,6DACD,EACE,CAAA;QACL,kBAAC,MAAD,EAAA,UACG,EACC,2CACA,gEACD,EACE,CAAA;QACF;SACA;QACH;OACF;;GACK,CAAA;EACW,CAAA"}
|
|
1
|
+
{"version":3,"file":"SecretCreatePage.js","names":[],"sources":["../../../src/security/pages/SecretCreatePage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useParams, useNavigate } from 'react-router-dom';\nimport { Save, ArrowLeft, Loader2, ShieldCheck, Info, AlertTriangle } from 'lucide-react';\nimport { PageLayout } from '../components/PageLayout';\nimport { SecretFormFields } from '../components/SecretFormFields';\nimport { Button, Card } from '../components/ui';\nimport { useCreateSecret } from '../hooks/useSecretQueries';\nimport { useSecurityEventEmitter } from '../hooks/useSecurityEventEmitter';\nimport { useSecurity } from '../providers/SecurityProvider';\nimport { SecurityPermissionGuard } from '../components/SecurityPermissionGuard';\nimport { cn } from '../utils/cn';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { translateWithFallback } from '../utils/i18n';\nimport type { SecretType } from '../types';\nimport { nativeImpact, nativeNotify } from '../../utils/nativeBridge';\n\n/**\n * Detect Apollo-shaped errors structurally (works across Apollo v3 and v4).\n * Apollo errors carry `graphQLErrors`, `networkError`, or `clientErrors` —\n * those messages are already shaped for client display. Other thrown Errors\n * fall through to the generic translation to avoid leaking internal details.\n */\nfunction isApolloError(err: unknown): err is Error {\n return (\n err instanceof Error &&\n ('graphQLErrors' in err || 'networkError' in err || 'clientErrors' in err)\n );\n}\n\nexport function SecretCreatePage() {\n const { vaultId } = useParams<{ vaultId: string }>();\n const { basePath = '/', navigate: shellNavigate } = useSecurity();\n const routerNavigate = useNavigate();\n const { t } = useI18n();\n const tx = (key: string, fallback: string, params?: Record<string, string | number>) =>\n translateWithFallback(t, key, fallback, params);\n\n const [createSecret, { loading: creating }] = useCreateSecret();\n const { emit } = useSecurityEventEmitter();\n\n const [type, setType] = useState<SecretType>('CREDENTIAL');\n const [name, setName] = useState('');\n const [value, setValue] = useState('');\n const [description, setDescription] = useState('');\n const [labels, setLabels] = useState<string[]>([]);\n const [error, setError] = useState<string | null>(null);\n\n const handleNavigate = (path: string) => {\n if (shellNavigate) {\n shellNavigate(path);\n } else {\n routerNavigate(path);\n }\n };\n\n const handleBack = () => {\n handleNavigate(`${basePath}/vaults/${vaultId}`);\n };\n\n const handleSave = async () => {\n void nativeImpact('light');\n if (!name.trim()) {\n setError(tx('security.secretCreate.error.nameRequired', 'Name is required.'));\n return;\n }\n if (!value.trim()) {\n setError(tx('security.secretCreate.error.valueRequired', 'Value is required.'));\n return;\n }\n\n setError(null);\n\n try {\n const result = await createSecret({\n variables: {\n input: {\n vaultId: vaultId ?? '',\n name: name.trim(),\n key: name\n .trim()\n .toLowerCase()\n .replace(/\\s+/g, '_')\n .replace(/[^a-z0-9_]/g, ''),\n value: value.trim(),\n type,\n description: description.trim() || undefined,\n tags: labels.length > 0 ? labels : undefined,\n },\n },\n });\n // Apollo v4 exposes a single aggregated `error` on the mutation result.\n if (result.error) {\n setError(\n result.error.message ??\n tx('security.secretCreate.error.createFailed', 'Failed to create secret')\n );\n void nativeNotify('error');\n return;\n }\n\n if (result.data?.createSecret?.id) {\n emit('secret.created', { secretId: result.data.createSecret.id, vaultId });\n void nativeNotify('success');\n handleBack();\n return;\n }\n\n // No data and no errors — surface a generic failure rather than navigate away silently.\n setError(tx('security.secretCreate.error.createFailed', 'Failed to create secret'));\n void nativeNotify('error');\n } catch (err) {\n // Only surface raw error messages that come from Apollo — those are\n // already shaped for client consumption. Anything else falls back to\n // the generic translation to avoid leaking internal details into the UI.\n setError(\n isApolloError(err)\n ? err.message\n : tx('security.secretCreate.error.createFailed', 'Failed to create secret')\n );\n void nativeNotify('error');\n }\n };\n\n return (\n <SecurityPermissionGuard permission=\"secret:create\">\n <PageLayout\n title={tx('security.secretCreate.title', 'Add New Secret')}\n description={tx(\n 'security.secretCreate.description',\n 'Store a new credential, API key, or sensitive text securely.'\n )}\n breadcrumbs={[\n { label: tx('security.common.breadcrumbs.security', 'Security'), path: basePath },\n {\n label: tx('security.common.breadcrumbs.vault', 'Vault'),\n path: `${basePath}/vaults/${vaultId}`,\n },\n { label: tx('security.secretCreate.breadcrumb', 'New Secret') },\n ]}\n actions={\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={handleBack}\n aria-label={tx('security.secretCreate.actions.backToVault', 'Back to Vault')}\n >\n <ArrowLeft className=\"h-4 w-4\" />\n {tx('security.secretCreate.actions.backToVault', 'Back to Vault')}\n </Button>\n }\n >\n <div className=\"grid grid-cols-1 lg:grid-cols-3 gap-8\">\n <div className=\"lg:col-span-2\">\n <Card className=\"p-6 shadow-md border-border/60\">\n <SecretFormFields\n type={type}\n onTypeChange={setType}\n name={name}\n onNameChange={setName}\n value={value}\n onValueChange={setValue}\n description={description}\n onDescriptionChange={setDescription}\n labels={labels}\n onLabelsChange={setLabels}\n />\n\n {error && (\n <div className=\"mt-6 p-3 rounded-md bg-destructive/10 text-destructive text-sm border border-destructive/20 flex items-start gap-2\">\n <AlertTriangle className=\"h-4 w-4 shrink-0 mt-0.5\" />\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-3 mt-8 pt-6 border-t border-border/60\">\n <Button\n variant=\"outline\"\n onClick={handleBack}\n disabled={creating}\n aria-label={tx('security.secretCreate.actions.cancel', 'Cancel')}\n >\n {tx('security.secretCreate.actions.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSave} disabled={creating || !name.trim() || !value.trim()}>\n {creating ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <Save className=\"h-4 w-4\" />\n )}\n {creating\n ? tx('security.secretCreate.actions.creating', 'Creating...')\n : tx('security.secretCreate.actions.createSecret', 'Create Secret')}\n </Button>\n </div>\n </Card>\n </div>\n\n <div className=\"space-y-6\">\n <Card className=\"p-6 bg-primary/5 border-primary/10 shadow-sm\">\n <h3 className=\"text-sm font-bold text-primary flex items-center gap-2 mb-3 uppercase tracking-wider\">\n <ShieldCheck className=\"h-4 w-4\" />\n {tx('security.secretCreate.secureStorage.title', 'Secure Storage')}\n </h3>\n <p className=\"text-xs text-muted-foreground leading-relaxed\">\n {tx(\n 'security.secretCreate.secureStorage.description',\n 'Your secret will be encrypted using a vault-specific key derived from the master encryption system. Once saved, the plain-text value is never shown unless explicitly revealed by an authorized user.'\n )}\n </p>\n </Card>\n\n <Card className=\"p-6 border-border/60 shadow-sm\">\n <h3 className=\"text-sm font-bold text-foreground flex items-center gap-2 mb-3\">\n <Info className=\"h-4 w-4 text-muted-foreground\" />\n {tx('security.secretCreate.namingTips.title', 'Naming Tips')}\n </h3>\n <ul className=\"text-xs text-muted-foreground space-y-2 list-disc pl-4\">\n <li>\n {tx(\n 'security.secretCreate.namingTips.productionDb',\n 'Use descriptive names like Production Database URL'\n )}\n </li>\n <li>\n {tx(\n 'security.secretCreate.namingTips.autoKey',\n 'A unique key will be automatically generated from the name'\n )}\n </li>\n <li>\n {tx(\n 'security.secretCreate.namingTips.labels',\n 'You can add labels to group secrets by environment or project'\n )}\n </li>\n </ul>\n </Card>\n </div>\n </div>\n </PageLayout>\n </SecurityPermissionGuard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAS,EAAc,GAA4B;AACjD,QACE,aAAe,UACd,mBAAmB,KAAO,kBAAkB,KAAO,kBAAkB;;AAI1E,SAAgB,IAAmB;CACjC,IAAM,EAAE,eAAY,GAAgC,EAC9C,EAAE,cAAW,KAAK,UAAU,MAAkB,GAAa,EAC3D,IAAiB,GAAa,EAC9B,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,GAAkB,MACzC,EAAsB,GAAG,GAAK,GAAU,EAAO,EAE3C,CAAC,GAAc,EAAE,SAAS,OAAc,GAAiB,EACzD,EAAE,YAAS,GAAyB,EAEpC,CAAC,GAAM,KAAW,EAAqB,aAAa,EACpD,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAO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B,CAC9D;WACL;;OACD;;KACH,CAAA,EAEN,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,GAAD;MAAM,WAAU;gBAAhB,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAd,CACE,kBAAC,GAAD,EAAa,WAAU,WAAY,CAAA,EAClC,EAAG,6CAA6C,iBAAiB,CAC/D;UACL,kBAAC,KAAD;OAAG,WAAU;iBACV,EACC,mDACA,wMACD;OACC,CAAA,CACC;SAEP,kBAAC,GAAD;MAAM,WAAU;gBAAhB,CACE,kBAAC,MAAD;OAAI,WAAU;iBAAd,CACE,kBAAC,GAAD,EAAM,WAAU,iCAAkC,CAAA,EACjD,EAAG,0CAA0C,cAAc,CACzD;UACL,kBAAC,MAAD;OAAI,WAAU;iBAAd;QACE,kBAAC,MAAD,EAAA,UACG,EACC,iDACA,qDACD,EACE,CAAA;QACL,kBAAC,MAAD,EAAA,UACG,EACC,4CACA,6DACD,EACE,CAAA;QACL,kBAAC,MAAD,EAAA,UACG,EACC,2CACA,gEACD,EACE,CAAA;QACF;SACA;QACH;OACF;;GACK,CAAA;EACW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VaultCreatePage.d.ts","sourceRoot":"","sources":["../../../src/security/pages/VaultCreatePage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VaultCreatePage.d.ts","sourceRoot":"","sources":["../../../src/security/pages/VaultCreatePage.tsx"],"names":[],"mappings":"AA2BA,wBAAgB,eAAe,4CAiJ9B"}
|
|
@@ -12,69 +12,80 @@ import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
|
12
12
|
import { ArrowLeft as m, Loader2 as h, Save as g } from "lucide-react";
|
|
13
13
|
import { useI18n as _ } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
14
14
|
//#region src/security/pages/VaultCreatePage.tsx
|
|
15
|
-
function v() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
function v(e) {
|
|
16
|
+
return e instanceof Error && ("graphQLErrors" in e || "networkError" in e || "clientErrors" in e);
|
|
17
|
+
}
|
|
18
|
+
function y() {
|
|
19
|
+
let { basePath: y = "/", navigate: b } = e(), x = d(), { t: S } = _(), C = (e, t, n) => i(S, e, t, n), [w, { loading: T }] = a(), { emit: E } = o(), [D, O] = u(""), [k, A] = u(""), [j, M] = u("WORKSPACE"), [N, P] = u(null), F = (e) => {
|
|
20
|
+
b ? b(e) : x(e);
|
|
21
|
+
}, I = () => {
|
|
22
|
+
F(y);
|
|
20
23
|
};
|
|
21
24
|
return /* @__PURE__ */ f(t, {
|
|
22
|
-
title:
|
|
23
|
-
description:
|
|
25
|
+
title: C("security.vaultCreate.title", "Create Vault"),
|
|
26
|
+
description: C("security.vaultCreate.description", "Create a new secure container for your secrets."),
|
|
24
27
|
breadcrumbs: [{
|
|
25
|
-
label:
|
|
26
|
-
path:
|
|
27
|
-
}, { label:
|
|
28
|
+
label: C("security.common.breadcrumbs.security", "Security"),
|
|
29
|
+
path: y
|
|
30
|
+
}, { label: C("security.vaultCreate.breadcrumb", "New Vault") }],
|
|
28
31
|
actions: /* @__PURE__ */ p(n, {
|
|
29
32
|
variant: "outline",
|
|
30
|
-
onClick:
|
|
31
|
-
children: [/* @__PURE__ */ f(m, { className: "h-4 w-4" }),
|
|
33
|
+
onClick: I,
|
|
34
|
+
children: [/* @__PURE__ */ f(m, { className: "h-4 w-4" }), C("security.common.actions.back", "Back")]
|
|
32
35
|
}),
|
|
33
36
|
children: /* @__PURE__ */ p(r, {
|
|
34
37
|
className: "p-6 max-w-2xl mx-auto",
|
|
35
38
|
children: [
|
|
36
39
|
/* @__PURE__ */ f(l, {
|
|
37
|
-
name:
|
|
38
|
-
onNameChange:
|
|
39
|
-
description:
|
|
40
|
-
onDescriptionChange:
|
|
41
|
-
scope:
|
|
42
|
-
onScopeChange:
|
|
40
|
+
name: D,
|
|
41
|
+
onNameChange: O,
|
|
42
|
+
description: k,
|
|
43
|
+
onDescriptionChange: A,
|
|
44
|
+
scope: j,
|
|
45
|
+
onScopeChange: M
|
|
43
46
|
}),
|
|
44
|
-
|
|
47
|
+
N && /* @__PURE__ */ f("div", {
|
|
45
48
|
className: "mt-4 p-3 rounded-md bg-destructive/10 text-destructive text-sm border border-destructive/20",
|
|
46
|
-
children:
|
|
49
|
+
children: N
|
|
47
50
|
}),
|
|
48
51
|
/* @__PURE__ */ p("div", {
|
|
49
52
|
className: "flex justify-end gap-2 mt-8 pt-4 border-t border-border",
|
|
50
53
|
children: [/* @__PURE__ */ f(n, {
|
|
51
54
|
variant: "outline",
|
|
52
|
-
onClick:
|
|
53
|
-
disabled:
|
|
54
|
-
"aria-label":
|
|
55
|
-
children:
|
|
55
|
+
onClick: I,
|
|
56
|
+
disabled: T,
|
|
57
|
+
"aria-label": C("security.vaultCreate.actions.cancel", "Cancel"),
|
|
58
|
+
children: C("security.common.actions.cancel", "Cancel")
|
|
56
59
|
}), /* @__PURE__ */ p(n, {
|
|
57
60
|
onClick: async () => {
|
|
58
|
-
if (s("light"), !
|
|
59
|
-
|
|
61
|
+
if (s("light"), !D.trim()) {
|
|
62
|
+
P(C("security.vaultCreate.error.nameRequired", "Name is required."));
|
|
60
63
|
return;
|
|
61
64
|
}
|
|
62
|
-
|
|
65
|
+
P(null);
|
|
63
66
|
try {
|
|
64
|
-
let e = await
|
|
65
|
-
name:
|
|
66
|
-
description:
|
|
67
|
-
scope:
|
|
67
|
+
let e = await w({ variables: { input: {
|
|
68
|
+
name: D.trim(),
|
|
69
|
+
description: k.trim() || void 0,
|
|
70
|
+
scope: j,
|
|
68
71
|
scopeId: void 0
|
|
69
72
|
} } });
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
if (e.error) {
|
|
74
|
+
P(e.error.message ?? C("security.vaultCreate.error.createFailed", "Failed to create vault")), c("error");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (e.data?.createVault?.id) {
|
|
78
|
+
E("vault.created", { vaultId: e.data.createVault.id }), c("success"), F(`${y}/vaults/${e.data.createVault.id}`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
P(C("security.vaultCreate.error.createFailed", "Failed to create vault")), c("error");
|
|
82
|
+
} catch (e) {
|
|
83
|
+
P(v(e) ? e.message : C("security.vaultCreate.error.createFailed", "Failed to create vault")), c("error");
|
|
73
84
|
}
|
|
74
85
|
},
|
|
75
|
-
disabled:
|
|
76
|
-
"aria-label":
|
|
77
|
-
children: [
|
|
86
|
+
disabled: T || !D.trim(),
|
|
87
|
+
"aria-label": C("security.vaultCreate.actions.create", T ? C("security.vaultCreate.actions.creating", "Creating...") : C("security.vaultCreate.actions.createVault", "Create Vault")),
|
|
88
|
+
children: [T ? /* @__PURE__ */ f(h, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ f(g, { className: "h-4 w-4" }), T ? C("security.vaultCreate.actions.creating", "Creating...") : C("security.vaultCreate.actions.createVault", "Create Vault")]
|
|
78
89
|
})]
|
|
79
90
|
})
|
|
80
91
|
]
|
|
@@ -82,6 +93,6 @@ function v() {
|
|
|
82
93
|
});
|
|
83
94
|
}
|
|
84
95
|
//#endregion
|
|
85
|
-
export {
|
|
96
|
+
export { y as VaultCreatePage };
|
|
86
97
|
|
|
87
98
|
//# sourceMappingURL=VaultCreatePage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VaultCreatePage.js","names":[],"sources":["../../../src/security/pages/VaultCreatePage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Save, ArrowLeft, Loader2 } from 'lucide-react';\nimport { PageLayout } from '../components/PageLayout';\nimport { VaultFormFields } from '../components/VaultFormFields';\nimport { Button, Card } from '../components/ui';\nimport { useCreateVault } from '../hooks/useVaultQueries';\nimport { useSecurityEventEmitter } from '../hooks/useSecurityEventEmitter';\nimport { useSecurity } from '../providers/SecurityProvider';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { translateWithFallback } from '../utils/i18n';\nimport { nativeImpact, nativeNotify } from '../../utils/nativeBridge';\n\nexport function VaultCreatePage() {\n const { basePath = '/', navigate: shellNavigate } = useSecurity();\n const routerNavigate = useNavigate();\n const { t } = useI18n();\n const tx = (key: string, fallback: string, params?: Record<string, string | number>) =>\n translateWithFallback(t, key, fallback, params);\n\n const [createVault, { loading: creating }] = useCreateVault();\n const { emit } = useSecurityEventEmitter();\n\n const [name, setName] = useState('');\n const [description, setDescription] = useState('');\n const [scope, setScope] = useState('WORKSPACE');\n const [error, setError] = useState<string | null>(null);\n\n const handleNavigate = (path: string) => {\n if (shellNavigate) {\n shellNavigate(path);\n } else {\n routerNavigate(path);\n }\n };\n\n const handleBack = () => {\n handleNavigate(basePath);\n };\n\n const handleSave = async () => {\n void nativeImpact('light');\n if (!name.trim()) {\n setError(tx('security.vaultCreate.error.nameRequired', 'Name is required.'));\n return;\n }\n\n setError(null);\n\n try {\n const result = await createVault({\n variables: {\n input: {\n name: name.trim(),\n description: description.trim() || undefined,\n scope,\n scopeId: scope === 'WORKSPACE' ? undefined : undefined,\n },\n },\n });\n\n if (result.data?.createVault?.id) {\n emit('vault.created', { vaultId: result.data.createVault.id });\n void nativeNotify('success');\n handleNavigate(`${basePath}/vaults/${result.data.createVault.id}`);\n }
|
|
1
|
+
{"version":3,"file":"VaultCreatePage.js","names":[],"sources":["../../../src/security/pages/VaultCreatePage.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Save, ArrowLeft, Loader2 } from 'lucide-react';\nimport { PageLayout } from '../components/PageLayout';\nimport { VaultFormFields } from '../components/VaultFormFields';\nimport { Button, Card } from '../components/ui';\nimport { useCreateVault } from '../hooks/useVaultQueries';\nimport { useSecurityEventEmitter } from '../hooks/useSecurityEventEmitter';\nimport { useSecurity } from '../providers/SecurityProvider';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { translateWithFallback } from '../utils/i18n';\nimport { nativeImpact, nativeNotify } from '../../utils/nativeBridge';\n\n/**\n * Detect Apollo-shaped errors structurally (works across Apollo v3 and v4\n * where the `ApolloError` class either lives under different paths or is\n * replaced by categorized error types). Apollo errors carry `graphQLErrors`,\n * `networkError`, or `clientErrors` on the Error instance — those messages\n * are already shaped for client display.\n */\nfunction isApolloError(err: unknown): err is Error {\n return (\n err instanceof Error &&\n ('graphQLErrors' in err || 'networkError' in err || 'clientErrors' in err)\n );\n}\n\nexport function VaultCreatePage() {\n const { basePath = '/', navigate: shellNavigate } = useSecurity();\n const routerNavigate = useNavigate();\n const { t } = useI18n();\n const tx = (key: string, fallback: string, params?: Record<string, string | number>) =>\n translateWithFallback(t, key, fallback, params);\n\n const [createVault, { loading: creating }] = useCreateVault();\n const { emit } = useSecurityEventEmitter();\n\n const [name, setName] = useState('');\n const [description, setDescription] = useState('');\n const [scope, setScope] = useState('WORKSPACE');\n const [error, setError] = useState<string | null>(null);\n\n const handleNavigate = (path: string) => {\n if (shellNavigate) {\n shellNavigate(path);\n } else {\n routerNavigate(path);\n }\n };\n\n const handleBack = () => {\n handleNavigate(basePath);\n };\n\n const handleSave = async () => {\n void nativeImpact('light');\n if (!name.trim()) {\n setError(tx('security.vaultCreate.error.nameRequired', 'Name is required.'));\n return;\n }\n\n setError(null);\n\n try {\n const result = await createVault({\n variables: {\n input: {\n name: name.trim(),\n description: description.trim() || undefined,\n scope,\n scopeId: scope === 'WORKSPACE' ? undefined : undefined,\n },\n },\n });\n\n // Apollo v4 returns a single aggregated `error` on result instead of throwing.\n // Surface it as an inline error so the user knows what failed.\n if (result.error) {\n setError(\n result.error.message ??\n tx('security.vaultCreate.error.createFailed', 'Failed to create vault')\n );\n void nativeNotify('error');\n return;\n }\n\n if (result.data?.createVault?.id) {\n emit('vault.created', { vaultId: result.data.createVault.id });\n void nativeNotify('success');\n handleNavigate(`${basePath}/vaults/${result.data.createVault.id}`);\n return;\n }\n\n // No data and no errors — unexpected; surface generic failure rather than silently navigating away.\n setError(tx('security.vaultCreate.error.createFailed', 'Failed to create vault'));\n void nativeNotify('error');\n } catch (err) {\n // Only surface raw error messages that come from Apollo — those are\n // already shaped for client consumption. Anything else (random thrown\n // Error from network internals, unexpected JS exception) falls back to\n // the generic translation to avoid leaking internal details into the UI.\n setError(\n isApolloError(err)\n ? err.message\n : tx('security.vaultCreate.error.createFailed', 'Failed to create vault')\n );\n void nativeNotify('error');\n }\n };\n\n return (\n <PageLayout\n title={tx('security.vaultCreate.title', 'Create Vault')}\n description={tx(\n 'security.vaultCreate.description',\n 'Create a new secure container for your secrets.'\n )}\n breadcrumbs={[\n { label: tx('security.common.breadcrumbs.security', 'Security'), path: basePath },\n { label: tx('security.vaultCreate.breadcrumb', 'New Vault') },\n ]}\n actions={\n <Button variant=\"outline\" onClick={handleBack}>\n <ArrowLeft className=\"h-4 w-4\" />\n {tx('security.common.actions.back', 'Back')}\n </Button>\n }\n >\n <Card className=\"p-6 max-w-2xl mx-auto\">\n <VaultFormFields\n name={name}\n onNameChange={setName}\n description={description}\n onDescriptionChange={setDescription}\n scope={scope}\n onScopeChange={setScope}\n />\n\n {error && (\n <div className=\"mt-4 p-3 rounded-md bg-destructive/10 text-destructive text-sm border border-destructive/20\">\n {error}\n </div>\n )}\n\n <div className=\"flex justify-end gap-2 mt-8 pt-4 border-t border-border\">\n <Button\n variant=\"outline\"\n onClick={handleBack}\n disabled={creating}\n aria-label={tx('security.vaultCreate.actions.cancel', 'Cancel')}\n >\n {tx('security.common.actions.cancel', 'Cancel')}\n </Button>\n <Button\n onClick={handleSave}\n disabled={creating || !name.trim()}\n aria-label={tx(\n 'security.vaultCreate.actions.create',\n creating\n ? tx('security.vaultCreate.actions.creating', 'Creating...')\n : tx('security.vaultCreate.actions.createVault', 'Create Vault')\n )}\n >\n {creating ? <Loader2 className=\"h-4 w-4 animate-spin\" /> : <Save className=\"h-4 w-4\" />}\n {creating\n ? tx('security.vaultCreate.actions.creating', 'Creating...')\n : tx('security.vaultCreate.actions.createVault', 'Create Vault')}\n </Button>\n </div>\n </Card>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,SAAS,EAAc,GAA4B;AACjD,QACE,aAAe,UACd,mBAAmB,KAAO,kBAAkB,KAAO,kBAAkB;;AAI1E,SAAgB,IAAkB;CAChC,IAAM,EAAE,cAAW,KAAK,UAAU,MAAkB,GAAa,EAC3D,IAAiB,GAAa,EAC9B,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,GAAkB,MACzC,EAAsB,GAAG,GAAK,GAAU,EAAO,EAE3C,CAAC,GAAa,EAAE,SAAS,OAAc,GAAgB,EACvD,EAAE,YAAS,GAAyB,EAEpC,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAO,KAAY,EAAS,YAAY,EACzC,CAAC,GAAO,KAAY,EAAwB,KAAK,EAEjD,KAAkB,MAAiB;AACvC,EAAI,IACF,EAAc,EAAK,GAEnB,EAAe,EAAK;IAIlB,UAAmB;AACvB,IAAe,EAAS;;AA2D1B,QACE,kBAAC,GAAD;EACE,OAAO,EAAG,8BAA8B,eAAe;EACvD,aAAa,EACX,oCACA,kDACD;EACD,aAAa,CACX;GAAE,OAAO,EAAG,wCAAwC,WAAW;GAAE,MAAM;GAAU,EACjF,EAAE,OAAO,EAAG,mCAAmC,YAAY,EAAE,CAC9D;EACD,SACE,kBAAC,GAAD;GAAQ,SAAQ;GAAU,SAAS;aAAnC,CACE,kBAAC,GAAD,EAAW,WAAU,WAAY,CAAA,EAChC,EAAG,gCAAgC,OAAO,CACpC;;YAGX,kBAAC,GAAD;GAAM,WAAU;aAAhB;IACE,kBAAC,GAAD;KACQ;KACN,cAAc;KACD;KACb,qBAAqB;KACd;KACP,eAAe;KACf,CAAA;IAED,KACC,kBAAC,OAAD;KAAK,WAAU;eACZ;KACG,CAAA;IAGR,kBA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e,CAC3D;QACL;;IACD;;EACI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-security",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.523.1",
|
|
4
4
|
"description": "Security vault management microfrontend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"lint:sanity": "if [ \"${CI:-}\" = \"true\" ]; then bun run lint; else bun run lint -- --cache --cache-location .eslintcache; fi",
|
|
28
28
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
29
29
|
"type:check": "tsc --noEmit",
|
|
30
|
+
"knip": "bunx knip",
|
|
30
31
|
"sanity": "bun run codegen && bun run lint:sanity && bun run format && bun run type:check && bun run build",
|
|
31
32
|
"schema:pull": "graphql-codegen --project schema-wspace && graphql-codegen --project schema-global",
|
|
32
33
|
"codegen": "graphql-codegen --project wspace && graphql-codegen --project global",
|