@burdenoff/microfe-security 2026.624.2 → 2026.625.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/components/SecurityScoreCard.js +20 -19
- package/dist/security/components/SecurityScoreCard.js.map +1 -1
- package/dist/security/components/ui.js +2 -2
- package/dist/security/components/ui.js.map +1 -1
- package/dist/security/pages/ProviderDetailPage.js +122 -127
- package/dist/security/pages/ProviderDetailPage.js.map +1 -1
- package/dist/security/pages/ProvidersPage.js +118 -113
- package/dist/security/pages/ProvidersPage.js.map +1 -1
- package/dist/security/pages/SecretCreatePage.js +73 -68
- package/dist/security/pages/SecretCreatePage.js.map +1 -1
- package/dist/security/pages/SecretDetailPage.js +141 -149
- package/dist/security/pages/SecretDetailPage.js.map +1 -1
- package/dist/security/pages/SecurityDashboardPage.js +89 -85
- package/dist/security/pages/SecurityDashboardPage.js.map +1 -1
- package/dist/security/pages/VaultDetailPage.js +137 -183
- package/dist/security/pages/VaultDetailPage.js.map +1 -1
- package/dist/security/pages/VaultShareViewer.js +61 -59
- package/dist/security/pages/VaultShareViewer.js.map +1 -1
- package/dist/security/pages/VaultsDashboardPage.js +66 -64
- package/dist/security/pages/VaultsDashboardPage.js.map +1 -1
- package/package.json +2 -2
|
@@ -11,39 +11,40 @@ import { useState as d } from "react";
|
|
|
11
11
|
import { useNavigate as f, useParams as p } from "react-router-dom";
|
|
12
12
|
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
|
-
import {
|
|
14
|
+
import { GlassCard as S, ShowMore as C } from "@burdenoff/fe-libs/ui";
|
|
15
|
+
import { useI18n as w } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
15
16
|
//#region src/security/pages/SecretCreatePage.tsx
|
|
16
|
-
function
|
|
17
|
+
function T(e) {
|
|
17
18
|
return e instanceof Error && ("graphQLErrors" in e || "networkError" in e || "clientErrors" in e);
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
-
let { vaultId:
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
|
|
20
|
+
function E() {
|
|
21
|
+
let { vaultId: E } = p(), { basePath: D = "/", navigate: O } = e(), k = f(), { t: A } = w(), j = (e, t, n) => i(A, e, t, n), [M, { loading: N }] = o(), { emit: P } = a(), [F, I] = d("CREDENTIAL"), [L, R] = d(""), [z, B] = d(""), [V, H] = d(""), [U, W] = d([]), [G, K] = d(null), q = (e) => {
|
|
22
|
+
O ? O(e) : k(e);
|
|
23
|
+
}, J = () => {
|
|
24
|
+
q(`${D}/vaults/${E}`);
|
|
24
25
|
};
|
|
25
26
|
return /* @__PURE__ */ m(u, {
|
|
26
27
|
permission: "secret:create",
|
|
27
28
|
children: /* @__PURE__ */ m(t, {
|
|
28
|
-
title:
|
|
29
|
-
description:
|
|
29
|
+
title: j("security.secretCreate.title", "Add New Secret"),
|
|
30
|
+
description: j("security.secretCreate.description", "Store a new credential, API key, or sensitive text securely."),
|
|
30
31
|
breadcrumbs: [
|
|
31
32
|
{
|
|
32
|
-
label:
|
|
33
|
-
path:
|
|
33
|
+
label: j("security.common.breadcrumbs.security", "Security"),
|
|
34
|
+
path: D
|
|
34
35
|
},
|
|
35
36
|
{
|
|
36
|
-
label:
|
|
37
|
-
path: `${
|
|
37
|
+
label: j("security.common.breadcrumbs.vault", "Vault"),
|
|
38
|
+
path: `${D}/vaults/${E}`
|
|
38
39
|
},
|
|
39
|
-
{ label:
|
|
40
|
+
{ label: j("security.secretCreate.breadcrumb", "New Secret") }
|
|
40
41
|
],
|
|
41
42
|
actions: /* @__PURE__ */ h(n, {
|
|
42
43
|
variant: "outline",
|
|
43
44
|
size: "sm",
|
|
44
|
-
onClick:
|
|
45
|
-
"aria-label":
|
|
46
|
-
children: [/* @__PURE__ */ m(_, { className: "size-4" }),
|
|
45
|
+
onClick: J,
|
|
46
|
+
"aria-label": j("security.secretCreate.actions.backToVault", "Back to Vault"),
|
|
47
|
+
children: [/* @__PURE__ */ m(_, { className: "size-4" }), j("security.secretCreate.actions.backToVault", "Back to Vault")]
|
|
47
48
|
}),
|
|
48
49
|
children: /* @__PURE__ */ h("div", {
|
|
49
50
|
className: "grid grid-cols-1 lg:grid-cols-3 gap-8",
|
|
@@ -53,95 +54,99 @@ function w() {
|
|
|
53
54
|
className: "p-6 shadow-md border-border-subtle/60",
|
|
54
55
|
children: [
|
|
55
56
|
/* @__PURE__ */ m(l, {
|
|
56
|
-
type:
|
|
57
|
-
onTypeChange:
|
|
58
|
-
name:
|
|
59
|
-
onNameChange:
|
|
60
|
-
value:
|
|
61
|
-
onValueChange:
|
|
62
|
-
description:
|
|
63
|
-
onDescriptionChange:
|
|
64
|
-
labels:
|
|
65
|
-
onLabelsChange:
|
|
57
|
+
type: F,
|
|
58
|
+
onTypeChange: I,
|
|
59
|
+
name: L,
|
|
60
|
+
onNameChange: R,
|
|
61
|
+
value: z,
|
|
62
|
+
onValueChange: B,
|
|
63
|
+
description: V,
|
|
64
|
+
onDescriptionChange: H,
|
|
65
|
+
labels: U,
|
|
66
|
+
onLabelsChange: W
|
|
66
67
|
}),
|
|
67
|
-
|
|
68
|
+
G && /* @__PURE__ */ h("div", {
|
|
68
69
|
className: "mt-6 p-3 rounded-md bg-status-error-bg/10 text-status-error-text text-sm border border-status-error-border/20 flex items-start gap-2",
|
|
69
|
-
children: [/* @__PURE__ */ m(g, { className: "size-4 shrink-0 mt-0.5" }),
|
|
70
|
+
children: [/* @__PURE__ */ m(g, { className: "size-4 shrink-0 mt-0.5" }), G]
|
|
70
71
|
}),
|
|
71
72
|
/* @__PURE__ */ h("div", {
|
|
72
73
|
className: "flex justify-end gap-3 mt-8 pt-6 border-t border-border-subtle/60",
|
|
73
74
|
children: [/* @__PURE__ */ m(n, {
|
|
74
75
|
variant: "outline",
|
|
75
|
-
onClick:
|
|
76
|
-
disabled:
|
|
77
|
-
"aria-label":
|
|
78
|
-
children:
|
|
76
|
+
onClick: J,
|
|
77
|
+
disabled: N,
|
|
78
|
+
"aria-label": j("security.secretCreate.actions.cancel", "Cancel"),
|
|
79
|
+
children: j("security.secretCreate.actions.cancel", "Cancel")
|
|
79
80
|
}), /* @__PURE__ */ h(n, {
|
|
80
81
|
onClick: async () => {
|
|
81
|
-
if (s("light"), !
|
|
82
|
-
|
|
82
|
+
if (s("light"), !L.trim()) {
|
|
83
|
+
K(j("security.secretCreate.error.nameRequired", "Name is required."));
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
|
-
if (!
|
|
86
|
-
|
|
86
|
+
if (!z.trim()) {
|
|
87
|
+
K(j("security.secretCreate.error.valueRequired", "Value is required."));
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
+
K(null);
|
|
90
91
|
try {
|
|
91
|
-
let e = await
|
|
92
|
-
vaultId:
|
|
93
|
-
name:
|
|
94
|
-
key:
|
|
95
|
-
value:
|
|
96
|
-
type:
|
|
97
|
-
description:
|
|
98
|
-
tags:
|
|
92
|
+
let e = await M({ variables: { input: {
|
|
93
|
+
vaultId: E ?? "",
|
|
94
|
+
name: L.trim(),
|
|
95
|
+
key: L.trim().toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, ""),
|
|
96
|
+
value: z.trim(),
|
|
97
|
+
type: F,
|
|
98
|
+
description: V.trim() || void 0,
|
|
99
|
+
tags: U.length > 0 ? U : void 0
|
|
99
100
|
} } });
|
|
100
101
|
if (e.error) {
|
|
101
|
-
|
|
102
|
+
K(e.error.message ?? j("security.secretCreate.error.createFailed", "Failed to create secret")), c("error");
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
if (e.data?.createSecret?.id) {
|
|
105
|
-
|
|
106
|
+
P("secret.created", {
|
|
106
107
|
secretId: e.data.createSecret.id,
|
|
107
|
-
vaultId:
|
|
108
|
-
}), c("success"),
|
|
108
|
+
vaultId: E
|
|
109
|
+
}), c("success"), J();
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
+
K(j("security.secretCreate.error.createFailed", "Failed to create secret")), c("error");
|
|
112
113
|
} catch (e) {
|
|
113
|
-
|
|
114
|
+
K(T(e) ? e.message : j("security.secretCreate.error.createFailed", "Failed to create secret")), c("error");
|
|
114
115
|
}
|
|
115
116
|
},
|
|
116
|
-
disabled:
|
|
117
|
-
children: [
|
|
117
|
+
disabled: N || !L.trim() || !z.trim(),
|
|
118
|
+
children: [N ? /* @__PURE__ */ m(y, { className: "size-4 animate-spin" }) : /* @__PURE__ */ m(b, { className: "size-4" }), N ? j("security.secretCreate.actions.creating", "Creating...") : j("security.secretCreate.actions.createSecret", "Create Secret")]
|
|
118
119
|
})]
|
|
119
120
|
})
|
|
120
121
|
]
|
|
121
122
|
})
|
|
122
123
|
}), /* @__PURE__ */ h("div", {
|
|
123
124
|
className: "space-y-6",
|
|
124
|
-
children: [/* @__PURE__ */ h(
|
|
125
|
-
|
|
125
|
+
children: [/* @__PURE__ */ h(S, {
|
|
126
|
+
treatment: "insight",
|
|
127
|
+
className: "p-6",
|
|
126
128
|
children: [/* @__PURE__ */ h("h3", {
|
|
127
129
|
className: "text-sm font-bold text-primary flex items-center gap-2 mb-3 uppercase tracking-wider",
|
|
128
|
-
children: [/* @__PURE__ */ m(x, { className: "size-4" }),
|
|
130
|
+
children: [/* @__PURE__ */ m(x, { className: "size-4" }), j("security.secretCreate.secureStorage.title", "Secure Storage")]
|
|
129
131
|
}), /* @__PURE__ */ m("p", {
|
|
130
132
|
className: "text-xs text-text-secondary leading-relaxed",
|
|
131
|
-
children:
|
|
133
|
+
children: j("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.")
|
|
132
134
|
})]
|
|
133
135
|
}), /* @__PURE__ */ h(r, {
|
|
134
|
-
className: "p-6
|
|
136
|
+
className: "p-6",
|
|
135
137
|
children: [/* @__PURE__ */ h("h3", {
|
|
136
138
|
className: "text-sm font-bold text-text-primary flex items-center gap-2 mb-3",
|
|
137
|
-
children: [/* @__PURE__ */ m(v, { className: "size-4 text-text-secondary" }),
|
|
138
|
-
}), /* @__PURE__ */
|
|
139
|
-
|
|
140
|
-
children:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
139
|
+
children: [/* @__PURE__ */ m(v, { className: "size-4 text-text-secondary" }), j("security.secretCreate.namingTips.title", "Naming Tips")]
|
|
140
|
+
}), /* @__PURE__ */ m(C, {
|
|
141
|
+
collapsedHeight: 64,
|
|
142
|
+
children: /* @__PURE__ */ h("ul", {
|
|
143
|
+
className: "text-xs text-text-secondary space-y-2 list-disc pl-4",
|
|
144
|
+
children: [
|
|
145
|
+
/* @__PURE__ */ m("li", { children: j("security.secretCreate.namingTips.productionDb", "Use descriptive names like Production Database URL") }),
|
|
146
|
+
/* @__PURE__ */ m("li", { children: j("security.secretCreate.namingTips.autoKey", "A unique key will be automatically generated from the name") }),
|
|
147
|
+
/* @__PURE__ */ m("li", { children: j("security.secretCreate.namingTips.labels", "You can add labels to group secrets by environment or project") })
|
|
148
|
+
]
|
|
149
|
+
})
|
|
145
150
|
})]
|
|
146
151
|
})]
|
|
147
152
|
})]
|
|
@@ -150,6 +155,6 @@ function w() {
|
|
|
150
155
|
});
|
|
151
156
|
}
|
|
152
157
|
//#endregion
|
|
153
|
-
export {
|
|
158
|
+
export { E as SecretCreatePage };
|
|
154
159
|
|
|
155
160
|
//# 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\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=\"size-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-subtle/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-status-error-bg/10 text-status-error-text text-sm border border-status-error-border/20 flex items-start gap-2\">\n <AlertTriangle className=\"size-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-subtle/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=\"size-4 animate-spin\" />\n ) : (\n <Save className=\"size-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-action-primary-bg/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=\"size-4\" />\n {tx('security.secretCreate.secureStorage.title', 'Secure Storage')}\n </h3>\n <p className=\"text-xs text-text-secondary 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-subtle/60 shadow-sm\">\n <h3 className=\"text-sm font-bold text-text-primary flex items-center gap-2 mb-3\">\n <Info className=\"size-4 text-text-secondary\" />\n {tx('security.secretCreate.namingTips.title', 'Naming Tips')}\n </h3>\n <ul className=\"text-xs text-text-secondary 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,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;;AAmEjD,QACE,kBAAC,GAAD;EAAyB,YAAW;YAClC,kBAAC,GAAD;GACE,OAAO,EAAG,+BAA+B,iBAAiB;GAC1D,aAAa,EACX,qCAC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BAAC,GAAD,EAAM,WAAU,8BAA+B,CAAA,EAC9C,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
|
+
{"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 { GlassCard, ShowMore } from '@burdenoff/fe-libs/ui';\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=\"size-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-subtle/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-status-error-bg/10 text-status-error-text text-sm border border-status-error-border/20 flex items-start gap-2\">\n <AlertTriangle className=\"size-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-subtle/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=\"size-4 animate-spin\" />\n ) : (\n <Save className=\"size-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 <GlassCard treatment=\"insight\" className=\"p-6\">\n <h3 className=\"text-sm font-bold text-primary flex items-center gap-2 mb-3 uppercase tracking-wider\">\n <ShieldCheck className=\"size-4\" />\n {tx('security.secretCreate.secureStorage.title', 'Secure Storage')}\n </h3>\n <p className=\"text-xs text-text-secondary 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 </GlassCard>\n\n <Card className=\"p-6\">\n <h3 className=\"text-sm font-bold text-text-primary flex items-center gap-2 mb-3\">\n <Info className=\"size-4 text-text-secondary\" />\n {tx('security.secretCreate.namingTips.title', 'Naming Tips')}\n </h3>\n <ShowMore collapsedHeight={64}>\n <ul className=\"text-xs text-text-secondary 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 </ShowMore>\n </Card>\n </div>\n </div>\n </PageLayout>\n </SecurityPermissionGuard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,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,KAA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