@kong-ui-public/entities-keys 3.16.2-pr.3869.e876c8c8a.0 → 3.16.2
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/entities-keys.es.js +949 -0
- package/dist/entities-keys.umd.js +1 -0
- package/dist/style.css +1 -0
- package/dist/types/components/KeyConfigCard.vue.d.ts +80 -0
- package/dist/types/components/KeyConfigCard.vue.d.ts.map +1 -0
- package/dist/types/components/KeyForm.vue.d.ts +83 -0
- package/dist/types/components/KeyForm.vue.d.ts.map +1 -0
- package/dist/types/components/KeyList.vue.d.ts +107 -0
- package/dist/types/components/KeyList.vue.d.ts.map +1 -0
- package/dist/types/composables/index.d.ts +6 -0
- package/dist/types/composables/index.d.ts.map +1 -0
- package/dist/types/composables/useI18n.d.ts +9 -0
- package/dist/types/composables/useI18n.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/keys-endpoints.d.ts +40 -0
- package/dist/types/keys-endpoints.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/key-config-card.d.ts +19 -0
- package/dist/types/types/key-config-card.d.ts.map +1 -0
- package/dist/types/types/key-form.d.ts +38 -0
- package/dist/types/types/key-form.d.ts.map +1 -0
- package/dist/types/types/key-list.d.ts +35 -0
- package/dist/types/types/key-list.d.ts.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,949 @@
|
|
|
1
|
+
import { defineComponent as me, computed as m, ref as b, watch as Z, onBeforeMount as $e, resolveComponent as j, openBlock as g, createElementBlock as q, createVNode as c, unref as t, createSlots as pe, withCtx as r, createTextVNode as R, toDisplayString as h, createElementVNode as $, createBlock as C, Teleport as De, createCommentVNode as U, reactive as _e, Fragment as Se, renderList as we } from "vue";
|
|
2
|
+
import { useRouter as je } from "vue-router";
|
|
3
|
+
import { BookIcon as Ie, AddIcon as Ce, KeyIcon as Fe } from "@kong/icons";
|
|
4
|
+
import { createI18n as Te, i18nTComponent as Be } from "@kong-ui-public/i18n";
|
|
5
|
+
import { useAxios as ge, useTableState as Ae, useManagedByColumn as Pe, useFetcher as Ue, useDeleteUrlBuilder as qe, FetcherStatus as Oe, EntityBaseTable as Ne, PermissionsWrapper as ie, getManagedByLabel as Je, TableTags as Le, EntityFilter as We, EntityDeleteModal as He, EntityTypes as Qe, useErrors as Ge, EntityBaseFormType as Y, useDebouncedFilter as ze, EntityBaseForm as Xe, SupportedEntityType as Ee, EntityFormSection as Ke, useStringHelpers as Ye, ConfigurationSchemaType as ue, ConfigurationSchemaSection as ke, EntityBaseConfigCard as Ze, InternalLinkItem as et, ConfigCardItem as xe } from "@kong-ui-public/entities-shared";
|
|
6
|
+
const tt = { title: "Keys", list: { toolbar_actions: { new_key: "New key" }, table_headers: { name: "Name", key_id: "Key ID", id: "ID", tags: "Tags" }, empty_state: { title: "Configure a new key", description: "A key object holds a representation of asymmetric keys in various formats." }, empty_state_v2: { title: "Configure your first key", group: "Keys created in gateways within this group will automatically appear here.", description: "Keys hold a representation of asymmetric keys that gateways and plugins can use for secure operations.", create_cta: "New key", learn_more: "Learn more" } }, actions: { create: "New key", copy_id: "Copy ID", copy_json: "Copy JSON", edit: "Edit", delete: "Delete", clear: "Clear", view: "View details", loading: "Loading..." }, search: { placeholder: "Filter by exact name or ID", no_results: "No results found" }, delete: { title: "Delete a key", description: "This action cannot be reversed so make sure to check the key usage before deleting." }, errors: { general: "Keys could not be retrieved", delete: "The key could not be deleted at this time.", copy: "Failed to copy to clipboard", key_sets: { fetch: "Could not fetch available key sets", invalid: "Please select a valid key set ID" } }, copy: { success: "Copied {val} to clipboard", success_brief: "Successfully copied to clipboard" }, form: { sections: { general: { title: "General information", description: "General information will help identify and manage this key." }, keys: { title: "Asymmetric keys", description: "Choose the preferred format for this asymmetric key. Currently only support PEM and JWK format." } }, fields: { id: { label: "Key ID", placeholder: "Enter a key ID", tooltip: "An identifier for a key", help: "If using JWK, need to match with the jwk.kid field" }, x5t: { label: "X.509 Certificate thumbprint (x5t)", placeholder: "Enter the certificate thumbprint that identifies the key to be used to validate JWT signature", tooltip: "x5t is a base64url-encoded SHA-1 thumbprint of the DER encoding of X.509 certificate", help: "If using x5t, need to match with the jwk.x5t field" }, name: { label: "Name", placeholder: "Enter a unique name for this key", tooltip: "The name to associate with the given key" }, tags: { label: "Tags", placeholder: "Enter a list of tags separated by comma", help: "e.g. tag1, tag2, tag3", tooltip: "An optional set of strings for grouping and filtering, separated by commas." }, key_set: { label: "Key set", placeholder: "Select a key set to add into", footer: "Search by exact ID to find key sets not included in the list" }, key_format: { label: "Key format", options: { jwk: "JWK", pem: "PEM" } }, jwk: { label: "JWK", placeholder: "Enter a JWK", tooltip: "A JSON Web key represented as a string" }, kid: { label: "Key ID", tooltip: "A unique identifier for a key." }, set: { label: "Key set", tooltip: "The id (an UUID) of the key-set with which to associate the key." }, private_key: { label: "Private key", placeholder: "Enter a private key" }, public_key: { label: "Public key", placeholder: "Enter a public key" } } } }, at = {
|
|
7
|
+
keys: tt
|
|
8
|
+
};
|
|
9
|
+
function lt() {
|
|
10
|
+
const i = Te("en-us", at);
|
|
11
|
+
return {
|
|
12
|
+
i18n: i,
|
|
13
|
+
i18nT: Be(i)
|
|
14
|
+
// Translation component <i18n-t>
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const ve = {
|
|
18
|
+
useI18n: lt
|
|
19
|
+
}, D = "/v2/control-planes/{controlPlaneId}/core-entities/{workspace}", F = "/{workspace}", T = {
|
|
20
|
+
list: {
|
|
21
|
+
konnect: {
|
|
22
|
+
all: `${D}/keys`,
|
|
23
|
+
forKeySet: `${D}/key-sets/{keySetId}/keys`
|
|
24
|
+
},
|
|
25
|
+
kongManager: {
|
|
26
|
+
all: `${F}/keys`,
|
|
27
|
+
forKeySet: `${F}/key-sets/{keySetId}/keys`
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
form: {
|
|
31
|
+
konnect: {
|
|
32
|
+
create: {
|
|
33
|
+
all: `${D}/keys`,
|
|
34
|
+
forKeySet: `${D}/key-sets/{keySetId}/keys`
|
|
35
|
+
},
|
|
36
|
+
edit: {
|
|
37
|
+
all: `${D}/keys/{id}`,
|
|
38
|
+
forKeySet: `${D}/key-sets/{keySetId}/keys/{id}`
|
|
39
|
+
},
|
|
40
|
+
keySets: `${D}/key-sets`,
|
|
41
|
+
getKeySet: `${D}/key-sets/{keySetId}`
|
|
42
|
+
},
|
|
43
|
+
kongManager: {
|
|
44
|
+
create: {
|
|
45
|
+
all: `${F}/keys`,
|
|
46
|
+
forKeySet: `${F}/key-sets/{keySetId}/keys`
|
|
47
|
+
},
|
|
48
|
+
edit: {
|
|
49
|
+
all: `${F}/keys/{id}`,
|
|
50
|
+
forKeySet: `${F}/key-sets/{keySetId}/keys/{id}`
|
|
51
|
+
},
|
|
52
|
+
keySets: `${F}/key-sets`,
|
|
53
|
+
getKeySet: `${F}/key-sets/{keySetId}`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, it = { class: "kong-ui-entities-keys-list" }, ot = { class: "button-row" }, st = /* @__PURE__ */ me({
|
|
57
|
+
__name: "KeyList",
|
|
58
|
+
props: {
|
|
59
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
60
|
+
config: {
|
|
61
|
+
type: Object,
|
|
62
|
+
required: !0,
|
|
63
|
+
validator: (i) => !(!i || !["konnect", "kongManager"].includes(i?.app) || !i.createRoute || !i.getViewRoute || !i.getEditRoute || i.app === "kongManager" && !i.isExactMatch && !i.filterSchema)
|
|
64
|
+
},
|
|
65
|
+
// used to override the default identifier for the cache entry
|
|
66
|
+
cacheIdentifier: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: ""
|
|
69
|
+
},
|
|
70
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can create a new entity */
|
|
71
|
+
canCreate: {
|
|
72
|
+
type: Function,
|
|
73
|
+
required: !1,
|
|
74
|
+
default: async () => !0
|
|
75
|
+
},
|
|
76
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can delete a given entity */
|
|
77
|
+
canDelete: {
|
|
78
|
+
type: Function,
|
|
79
|
+
required: !1,
|
|
80
|
+
default: async () => !0
|
|
81
|
+
},
|
|
82
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can edit a given entity */
|
|
83
|
+
canEdit: {
|
|
84
|
+
type: Function,
|
|
85
|
+
required: !1,
|
|
86
|
+
default: async () => !0
|
|
87
|
+
},
|
|
88
|
+
/** A synchronous or asynchronous function, that returns a boolean, that evaluates if the user can retrieve (view details) a given entity */
|
|
89
|
+
canRetrieve: {
|
|
90
|
+
type: Function,
|
|
91
|
+
required: !1,
|
|
92
|
+
default: async () => !0
|
|
93
|
+
},
|
|
94
|
+
/** default to false, setting to true will teleport the toolbar button to the destination in the consuming app */
|
|
95
|
+
useActionOutside: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: !1
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
emits: ["error", "click:learn-more", "copy:success", "copy:error", "delete:success"],
|
|
101
|
+
setup(i, { emit: B }) {
|
|
102
|
+
const v = B, a = i, { i18n: { t: d } } = ve.useI18n(), s = je(), { axiosInstance: S } = ge(a.config?.axiosRequestConfig), { hasRecords: A, handleStateChange: G } = Ae(() => K.value), w = m(() => A.value && a.config.app === "konnect"), e = m(() => !!a.config.keySetId), I = m(() => a.config.app !== "kongManager" || !!a.config.disableSorting), E = {
|
|
103
|
+
// the Name column is non-hidable
|
|
104
|
+
name: { label: d("keys.list.table_headers.name"), searchable: !0, sortable: !0, hidable: !1 },
|
|
105
|
+
kid: { label: d("keys.list.table_headers.key_id"), sortable: !0 },
|
|
106
|
+
tags: { label: d("keys.list.table_headers.tags") },
|
|
107
|
+
id: { label: d("keys.list.table_headers.id"), sortable: !0 }
|
|
108
|
+
}, { defaultTablePreferences: V, tableHeaders: z } = Pe(E), O = m(() => {
|
|
109
|
+
let l = `${a.config.apiBaseUrl}${T.list[a.config.app][a.config.keySetId ? "forKeySet" : "all"]}`;
|
|
110
|
+
return a.config.app === "konnect" && (l = l.replace(/{controlPlaneId}/gi, a.config?.controlPlaneId || "")), l.replace(/\/{workspace}/gi, a.config?.workspace ? `/${a.config.workspace}` : "").replace(/{keySetId}/gi, a.config?.keySetId || "");
|
|
111
|
+
}), K = b(""), u = m(() => {
|
|
112
|
+
const l = a.config.app === "konnect" || a.config.isExactMatch;
|
|
113
|
+
if (l)
|
|
114
|
+
return {
|
|
115
|
+
isExactMatch: l,
|
|
116
|
+
placeholder: d("keys.search.placeholder")
|
|
117
|
+
};
|
|
118
|
+
const p = { name: E.name };
|
|
119
|
+
return {
|
|
120
|
+
isExactMatch: l,
|
|
121
|
+
fields: p,
|
|
122
|
+
schema: a.config.filterSchema
|
|
123
|
+
};
|
|
124
|
+
}), {
|
|
125
|
+
fetcher: k,
|
|
126
|
+
fetcherState: _,
|
|
127
|
+
fetcherCacheKey: y
|
|
128
|
+
} = Ue(m(() => ({ ...a.config, cacheIdentifier: a.cacheIdentifier })), O), ee = () => {
|
|
129
|
+
K.value = "";
|
|
130
|
+
}, oe = () => {
|
|
131
|
+
y.value++;
|
|
132
|
+
}, N = b(null), se = async (l, p) => {
|
|
133
|
+
const M = l.id;
|
|
134
|
+
if (!await p(M)) {
|
|
135
|
+
de(l, "id");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
re(l, "id");
|
|
139
|
+
}, ne = async (l, p) => {
|
|
140
|
+
const M = JSON.stringify(l);
|
|
141
|
+
if (!await p(M)) {
|
|
142
|
+
v("copy:error", {
|
|
143
|
+
entity: l,
|
|
144
|
+
message: d("keys.errors.copy")
|
|
145
|
+
});
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
v("copy:success", {
|
|
149
|
+
entity: l,
|
|
150
|
+
message: d("keys.copy.success_brief")
|
|
151
|
+
});
|
|
152
|
+
}, re = (l, p) => {
|
|
153
|
+
v("copy:success", {
|
|
154
|
+
entity: l,
|
|
155
|
+
field: p,
|
|
156
|
+
message: d("keys.copy.success", { val: l[p] })
|
|
157
|
+
});
|
|
158
|
+
}, de = (l, p) => {
|
|
159
|
+
v("copy:error", {
|
|
160
|
+
entity: l,
|
|
161
|
+
field: p,
|
|
162
|
+
message: d("keys.errors.copy")
|
|
163
|
+
});
|
|
164
|
+
}, ce = async (l) => {
|
|
165
|
+
await a.canRetrieve?.(l) && s.push(a.config.getViewRoute(l.id));
|
|
166
|
+
}, ye = (l) => ({
|
|
167
|
+
label: d("keys.actions.view"),
|
|
168
|
+
to: a.config.getViewRoute(l)
|
|
169
|
+
}), te = (l) => ({
|
|
170
|
+
label: d("keys.actions.edit"),
|
|
171
|
+
to: a.config.getEditRoute(l)
|
|
172
|
+
}), x = b(void 0), J = b(!1), L = b(!1), W = b(""), ae = qe(a.config, O.value), fe = (l) => {
|
|
173
|
+
x.value = l, J.value = !0;
|
|
174
|
+
}, o = () => {
|
|
175
|
+
J.value = !1;
|
|
176
|
+
}, n = async () => {
|
|
177
|
+
if (x.value?.id) {
|
|
178
|
+
L.value = !0;
|
|
179
|
+
try {
|
|
180
|
+
await S.delete(ae(x.value.id)), L.value = !1, J.value = !1, y.value++, v("delete:success", x.value);
|
|
181
|
+
} catch (l) {
|
|
182
|
+
W.value = l.response?.data?.message || l.message || d("keys.errors.delete"), v("error", l);
|
|
183
|
+
} finally {
|
|
184
|
+
L.value = !1;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, H = () => {
|
|
188
|
+
s.push(a.config.createRoute);
|
|
189
|
+
};
|
|
190
|
+
Z(_, (l) => {
|
|
191
|
+
if (l.status === Oe.Error) {
|
|
192
|
+
N.value = {
|
|
193
|
+
title: d("keys.errors.general")
|
|
194
|
+
}, l.error?.response?.data?.message && (N.value.message = l.error.response.data.message), v("error", l.error);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
N.value = null;
|
|
198
|
+
});
|
|
199
|
+
const Q = b({
|
|
200
|
+
ctaPath: a.config.createRoute,
|
|
201
|
+
ctaText: void 0,
|
|
202
|
+
message: `${d("keys.list.empty_state.description")}${a.config.additionMessageForEmptyState ? ` ${a.config.additionMessageForEmptyState}` : ""}`,
|
|
203
|
+
title: d("keys.title")
|
|
204
|
+
}), P = b(!1);
|
|
205
|
+
return $e(async () => {
|
|
206
|
+
P.value = await a.canCreate(), P.value && (Q.value.title = d("keys.list.empty_state.title"), Q.value.ctaText = d("keys.actions.create"));
|
|
207
|
+
}), (l, p) => {
|
|
208
|
+
const M = j("KButton"), Me = j("KEmptyState"), he = j("KCopy"), X = j("KDropdownItem"), be = j("KClipboardProvider");
|
|
209
|
+
return g(), q("div", it, [
|
|
210
|
+
c(t(Ne), {
|
|
211
|
+
"cache-identifier": i.cacheIdentifier,
|
|
212
|
+
"default-table-preferences": t(V),
|
|
213
|
+
"disable-sorting": I.value,
|
|
214
|
+
"empty-state-options": Q.value,
|
|
215
|
+
"enable-entity-actions": "",
|
|
216
|
+
"error-message": N.value,
|
|
217
|
+
fetcher: t(k),
|
|
218
|
+
"fetcher-cache-key": t(y),
|
|
219
|
+
"pagination-type": "offset",
|
|
220
|
+
"preferences-storage-key": "kong-ui-entities-keys-list",
|
|
221
|
+
query: K.value,
|
|
222
|
+
"table-headers": t(z),
|
|
223
|
+
onClearSearchInput: ee,
|
|
224
|
+
"onClick:row": p[3] || (p[3] = (f) => ce(f)),
|
|
225
|
+
onSort: oe,
|
|
226
|
+
onState: t(G)
|
|
227
|
+
}, pe({
|
|
228
|
+
"toolbar-filter": r(() => [
|
|
229
|
+
c(t(We), {
|
|
230
|
+
modelValue: K.value,
|
|
231
|
+
"onUpdate:modelValue": p[0] || (p[0] = (f) => K.value = f),
|
|
232
|
+
config: u.value
|
|
233
|
+
}, null, 8, ["modelValue", "config"])
|
|
234
|
+
]),
|
|
235
|
+
"toolbar-button": r(() => [
|
|
236
|
+
(g(), C(De, {
|
|
237
|
+
disabled: !i.useActionOutside,
|
|
238
|
+
to: "#kong-ui-app-page-header-action-button"
|
|
239
|
+
}, [
|
|
240
|
+
$("div", ot, [
|
|
241
|
+
!e.value && w.value ? (g(), C(M, {
|
|
242
|
+
key: 0,
|
|
243
|
+
appearance: "secondary",
|
|
244
|
+
class: "open-learning-hub",
|
|
245
|
+
"data-testid": "keys-learn-more-button",
|
|
246
|
+
icon: "",
|
|
247
|
+
onClick: p[1] || (p[1] = (f) => l.$emit("click:learn-more"))
|
|
248
|
+
}, {
|
|
249
|
+
default: r(() => [
|
|
250
|
+
c(t(Ie), { decorative: "" })
|
|
251
|
+
]),
|
|
252
|
+
_: 1
|
|
253
|
+
})) : U("", !0),
|
|
254
|
+
c(t(ie), {
|
|
255
|
+
"auth-function": () => i.canCreate()
|
|
256
|
+
}, {
|
|
257
|
+
default: r(() => [
|
|
258
|
+
c(M, {
|
|
259
|
+
appearance: "primary",
|
|
260
|
+
"data-testid": "toolbar-add-key",
|
|
261
|
+
size: i.useActionOutside ? "medium" : "large",
|
|
262
|
+
to: i.config.createRoute
|
|
263
|
+
}, {
|
|
264
|
+
default: r(() => [
|
|
265
|
+
c(t(Ce)),
|
|
266
|
+
R(" " + h(t(d)("keys.list.toolbar_actions.new_key")), 1)
|
|
267
|
+
]),
|
|
268
|
+
_: 1
|
|
269
|
+
}, 8, ["size", "to"])
|
|
270
|
+
]),
|
|
271
|
+
_: 1
|
|
272
|
+
}, 8, ["auth-function"])
|
|
273
|
+
])
|
|
274
|
+
], 8, ["disabled"]))
|
|
275
|
+
]),
|
|
276
|
+
name: r(({ rowValue: f }) => [
|
|
277
|
+
$("b", null, h(f ?? "-"), 1)
|
|
278
|
+
]),
|
|
279
|
+
kid: r(({ rowValue: f }) => [
|
|
280
|
+
c(he, { text: f }, null, 8, ["text"])
|
|
281
|
+
]),
|
|
282
|
+
tags: r(({ rowValue: f }) => [
|
|
283
|
+
c(t(Le), { tags: f }, null, 8, ["tags"])
|
|
284
|
+
]),
|
|
285
|
+
id: r(({ rowValue: f }) => [
|
|
286
|
+
c(he, {
|
|
287
|
+
text: f,
|
|
288
|
+
truncate: ""
|
|
289
|
+
}, null, 8, ["text"])
|
|
290
|
+
]),
|
|
291
|
+
managed_by: r(({ rowValue: f }) => [
|
|
292
|
+
R(h(t(Je)(f) ?? "-"), 1)
|
|
293
|
+
]),
|
|
294
|
+
actions: r(({ row: f }) => [
|
|
295
|
+
c(be, null, {
|
|
296
|
+
default: r(({ copyToClipboard: le }) => [
|
|
297
|
+
c(X, {
|
|
298
|
+
"data-testid": "action-entity-copy-id",
|
|
299
|
+
onClick: (Re) => se(f, le)
|
|
300
|
+
}, {
|
|
301
|
+
default: r(() => [
|
|
302
|
+
R(h(t(d)("keys.actions.copy_id")), 1)
|
|
303
|
+
]),
|
|
304
|
+
_: 1
|
|
305
|
+
}, 8, ["onClick"])
|
|
306
|
+
]),
|
|
307
|
+
_: 2
|
|
308
|
+
}, 1024),
|
|
309
|
+
c(be, null, {
|
|
310
|
+
default: r(({ copyToClipboard: le }) => [
|
|
311
|
+
c(X, {
|
|
312
|
+
"data-testid": "action-entity-copy-json",
|
|
313
|
+
onClick: (Re) => ne(f, le)
|
|
314
|
+
}, {
|
|
315
|
+
default: r(() => [
|
|
316
|
+
R(h(t(d)("keys.actions.copy_json")), 1)
|
|
317
|
+
]),
|
|
318
|
+
_: 1
|
|
319
|
+
}, 8, ["onClick"])
|
|
320
|
+
]),
|
|
321
|
+
_: 2
|
|
322
|
+
}, 1024),
|
|
323
|
+
c(t(ie), {
|
|
324
|
+
"auth-function": () => i.canRetrieve(f)
|
|
325
|
+
}, {
|
|
326
|
+
default: r(() => [
|
|
327
|
+
c(X, {
|
|
328
|
+
"data-testid": "action-entity-view",
|
|
329
|
+
"has-divider": "",
|
|
330
|
+
item: ye(f.id)
|
|
331
|
+
}, null, 8, ["item"])
|
|
332
|
+
]),
|
|
333
|
+
_: 2
|
|
334
|
+
}, 1032, ["auth-function"]),
|
|
335
|
+
c(t(ie), {
|
|
336
|
+
"auth-function": () => i.canEdit(f)
|
|
337
|
+
}, {
|
|
338
|
+
default: r(() => [
|
|
339
|
+
c(X, {
|
|
340
|
+
"data-testid": "action-entity-edit",
|
|
341
|
+
item: te(f.id)
|
|
342
|
+
}, null, 8, ["item"])
|
|
343
|
+
]),
|
|
344
|
+
_: 2
|
|
345
|
+
}, 1032, ["auth-function"]),
|
|
346
|
+
c(t(ie), {
|
|
347
|
+
"auth-function": () => i.canDelete(f)
|
|
348
|
+
}, {
|
|
349
|
+
default: r(() => [
|
|
350
|
+
c(X, {
|
|
351
|
+
danger: "",
|
|
352
|
+
"data-testid": "action-entity-delete",
|
|
353
|
+
"has-divider": "",
|
|
354
|
+
onClick: (le) => fe(f)
|
|
355
|
+
}, {
|
|
356
|
+
default: r(() => [
|
|
357
|
+
R(h(t(d)("keys.actions.delete")), 1)
|
|
358
|
+
]),
|
|
359
|
+
_: 1
|
|
360
|
+
}, 8, ["onClick"])
|
|
361
|
+
]),
|
|
362
|
+
_: 2
|
|
363
|
+
}, 1032, ["auth-function"])
|
|
364
|
+
]),
|
|
365
|
+
_: 2
|
|
366
|
+
}, [
|
|
367
|
+
!K.value && i.config.app === "konnect" ? {
|
|
368
|
+
name: "empty-state",
|
|
369
|
+
fn: r(() => [
|
|
370
|
+
c(Me, {
|
|
371
|
+
"data-testid": i.config.keySetId ? "nested-keys-entity-empty-state" : "keys-entity-empty-state",
|
|
372
|
+
"icon-background": "",
|
|
373
|
+
message: t(d)("keys.list.empty_state_v2.description"),
|
|
374
|
+
title: t(d)("keys.list.empty_state_v2.title")
|
|
375
|
+
}, pe({
|
|
376
|
+
icon: r(() => [
|
|
377
|
+
c(t(Fe), { decorative: "" })
|
|
378
|
+
]),
|
|
379
|
+
action: r(() => [
|
|
380
|
+
P.value ? (g(), C(M, {
|
|
381
|
+
key: 0,
|
|
382
|
+
"data-testid": "entity-create-button",
|
|
383
|
+
onClick: H
|
|
384
|
+
}, {
|
|
385
|
+
default: r(() => [
|
|
386
|
+
c(t(Ce), { decorative: "" }),
|
|
387
|
+
R(" " + h(t(d)("keys.list.empty_state_v2.create_cta")), 1)
|
|
388
|
+
]),
|
|
389
|
+
_: 1
|
|
390
|
+
})) : U("", !0),
|
|
391
|
+
c(M, {
|
|
392
|
+
appearance: "secondary",
|
|
393
|
+
"data-testid": "entity-learn-more-button",
|
|
394
|
+
onClick: p[2] || (p[2] = (f) => l.$emit("click:learn-more"))
|
|
395
|
+
}, {
|
|
396
|
+
default: r(() => [
|
|
397
|
+
c(t(Ie), { decorative: "" }),
|
|
398
|
+
R(" " + h(t(d)("keys.list.empty_state_v2.learn_more")), 1)
|
|
399
|
+
]),
|
|
400
|
+
_: 1
|
|
401
|
+
})
|
|
402
|
+
]),
|
|
403
|
+
_: 2
|
|
404
|
+
}, [
|
|
405
|
+
i.config?.isControlPlaneGroup ? {
|
|
406
|
+
name: "default",
|
|
407
|
+
fn: r(() => [
|
|
408
|
+
R(h(t(d)("keys.list.empty_state_v2.group")), 1)
|
|
409
|
+
]),
|
|
410
|
+
key: "0"
|
|
411
|
+
} : void 0
|
|
412
|
+
]), 1032, ["data-testid", "message", "title"])
|
|
413
|
+
]),
|
|
414
|
+
key: "0"
|
|
415
|
+
} : void 0
|
|
416
|
+
]), 1032, ["cache-identifier", "default-table-preferences", "disable-sorting", "empty-state-options", "error-message", "fetcher", "fetcher-cache-key", "query", "table-headers", "onState"]),
|
|
417
|
+
c(t(He), {
|
|
418
|
+
"action-pending": L.value,
|
|
419
|
+
description: t(d)("keys.delete.description"),
|
|
420
|
+
"entity-name": x.value && (x.value.name || x.value.id),
|
|
421
|
+
"entity-type": t(Qe).Key,
|
|
422
|
+
error: W.value,
|
|
423
|
+
title: t(d)("keys.delete.title"),
|
|
424
|
+
visible: J.value,
|
|
425
|
+
onCancel: o,
|
|
426
|
+
onProceed: n
|
|
427
|
+
}, null, 8, ["action-pending", "description", "entity-name", "entity-type", "error", "title", "visible"])
|
|
428
|
+
]);
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
}), Ve = (i, B) => {
|
|
432
|
+
const v = i.__vccOpts || i;
|
|
433
|
+
for (const [a, d] of B)
|
|
434
|
+
v[a] = d;
|
|
435
|
+
return v;
|
|
436
|
+
}, St = /* @__PURE__ */ Ve(st, [["__scopeId", "data-v-84422c8b"]]), nt = { class: "kong-ui-entities-keys-form" }, rt = { "data-testid": "no-search-results" }, dt = { class: "select-item-container" }, ct = { class: "select-item-label" }, yt = { class: "select-item-description" }, ft = {
|
|
437
|
+
key: 1,
|
|
438
|
+
class: "invalid-key-set-message",
|
|
439
|
+
"data-testid": "invalid-key-set-message"
|
|
440
|
+
}, ut = { "data-testid": "key-format-container" }, kt = /* @__PURE__ */ me({
|
|
441
|
+
__name: "KeyForm",
|
|
442
|
+
props: {
|
|
443
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
444
|
+
config: {
|
|
445
|
+
type: Object,
|
|
446
|
+
required: !0,
|
|
447
|
+
validator: (i) => !(!i || !["konnect", "kongManager"].includes(i?.app) || i.app === "konnect" && !i.controlPlaneId || i.app === "kongManager" && typeof i.workspace != "string" || !i.cancelRoute)
|
|
448
|
+
},
|
|
449
|
+
/** If a valid Key ID is provided, it will put the form in Edit mode instead of Create */
|
|
450
|
+
keyId: {
|
|
451
|
+
type: String,
|
|
452
|
+
required: !1,
|
|
453
|
+
default: null
|
|
454
|
+
},
|
|
455
|
+
/** Specific the keyset Id if the key entity is a scoped entity [both create and edit form] */
|
|
456
|
+
keySetId: {
|
|
457
|
+
type: String,
|
|
458
|
+
required: !1,
|
|
459
|
+
default: null
|
|
460
|
+
},
|
|
461
|
+
/** Pre-select the Key Set field and mark it as read-only [create form only] */
|
|
462
|
+
fixedKeySetId: {
|
|
463
|
+
type: String,
|
|
464
|
+
required: !1,
|
|
465
|
+
default: null
|
|
466
|
+
},
|
|
467
|
+
/** Whether to provide x5t field in key form */
|
|
468
|
+
showx5t: {
|
|
469
|
+
type: Boolean,
|
|
470
|
+
required: !1,
|
|
471
|
+
default: !1
|
|
472
|
+
}
|
|
473
|
+
},
|
|
474
|
+
emits: ["update", "error", "loading"],
|
|
475
|
+
setup(i, { emit: B }) {
|
|
476
|
+
const v = B, a = i, d = je(), { i18n: { t: s } } = ve.useI18n(), { getMessageFromError: S } = Ge(), { axiosInstance: A } = ge(a.config?.axiosRequestConfig), G = m(() => a.keySetId ? T.form[a.config.app].edit.forKeySet.replace(/{keySetId}/gi, a.keySetId) : T.form[a.config.app].edit.all), w = m(() => a.keyId ? Y.Edit : Y.Create), e = _e({
|
|
477
|
+
fields: {
|
|
478
|
+
/**
|
|
479
|
+
* Generates a unique key name using the current timestamp.
|
|
480
|
+
* The name format is "new-key-" followed by numbers from the ISO timestamp.
|
|
481
|
+
*
|
|
482
|
+
* Example output: "new-key-20250307123045789"
|
|
483
|
+
*/
|
|
484
|
+
name: w.value === Y.Create ? `new-key-${(/* @__PURE__ */ new Date()).toISOString().replace(/\D/g, "").slice(0, 17)}` : "",
|
|
485
|
+
tags: "",
|
|
486
|
+
key_id: "",
|
|
487
|
+
key_format: "jwk",
|
|
488
|
+
key_set: "",
|
|
489
|
+
jwk: "",
|
|
490
|
+
private_key: "",
|
|
491
|
+
public_key: "",
|
|
492
|
+
...a.showx5t ? { x5t: "" } : {}
|
|
493
|
+
},
|
|
494
|
+
isReadonly: !1,
|
|
495
|
+
errorMessage: ""
|
|
496
|
+
}), I = _e({
|
|
497
|
+
name: "",
|
|
498
|
+
tags: "",
|
|
499
|
+
key_id: "",
|
|
500
|
+
key_format: "jwk",
|
|
501
|
+
key_set: "",
|
|
502
|
+
jwk: "",
|
|
503
|
+
private_key: "",
|
|
504
|
+
public_key: ""
|
|
505
|
+
}), E = [
|
|
506
|
+
{
|
|
507
|
+
label: s("keys.form.fields.key_format.options.jwk"),
|
|
508
|
+
value: "jwk"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
label: s("keys.form.fields.key_format.options.pem"),
|
|
512
|
+
value: "pem"
|
|
513
|
+
}
|
|
514
|
+
], V = m(() => e.isReadonly || w.value === Y.Create && !!a.fixedKeySetId), z = m(() => !V.value);
|
|
515
|
+
Z(() => a.fixedKeySetId, (o) => {
|
|
516
|
+
w.value === Y.Create && (e.fields.key_set = o ?? "");
|
|
517
|
+
}, { immediate: !0 });
|
|
518
|
+
const O = m(() => JSON.stringify(e.fields) !== JSON.stringify(I) && !!e.fields.key_id && !!e.fields.key_format && (e.fields.key_format === "jwk" && !!e.fields.jwk || e.fields.key_format === "pem" && !!e.fields.private_key && !!e.fields.public_key)), K = (o) => {
|
|
519
|
+
e.fields.key_id = o?.kid || "", e.fields.name = o?.name || "", e.fields.tags = o?.tags?.join(", ") || "", e.fields.key_set = o?.set?.id || "", e.fields.key_format = o?.pem ? "pem" : "jwk", e.fields.jwk = o?.jwk || "", e.fields.private_key = o?.pem?.private_key || "", e.fields.public_key = o?.pem?.public_key || "", a.showx5t && (e.fields.x5t = o?.x5t || ""), Object.assign(I, e.fields);
|
|
520
|
+
}, u = () => {
|
|
521
|
+
d.push(a.config.cancelRoute);
|
|
522
|
+
}, k = m(() => {
|
|
523
|
+
let o = `${a.config.apiBaseUrl}${T.form[a.config.app][w.value][a.keySetId ? "forKeySet" : "all"]}`;
|
|
524
|
+
return a.config.app === "konnect" && (o = o.replace(/{controlPlaneId}/gi, a.config?.controlPlaneId || "")), o.replace(/\/{workspace}/gi, a.config?.workspace ? `/${a.config.workspace}` : "").replace(/{id}/gi, a.keyId ?? "").replace(/{keySetId}/gi, a.keySetId || "");
|
|
525
|
+
}), _ = m(() => ({
|
|
526
|
+
kid: e.fields.key_id,
|
|
527
|
+
...a.showx5t ? { x5t: e.fields.x5t || null } : {},
|
|
528
|
+
name: e.fields.name || null,
|
|
529
|
+
tags: e.fields.tags?.split(",")?.map((o) => String(o || "").trim())?.filter((o) => o !== "") || [],
|
|
530
|
+
set: e.fields.key_set ? { id: e.fields.key_set } : null,
|
|
531
|
+
jwk: e.fields.key_format === "jwk" ? e.fields.jwk : null,
|
|
532
|
+
pem: e.fields.key_format === "pem" ? { private_key: e.fields.private_key, public_key: e.fields.public_key } : null
|
|
533
|
+
})), y = async () => {
|
|
534
|
+
try {
|
|
535
|
+
e.isReadonly = !0;
|
|
536
|
+
let o;
|
|
537
|
+
if (w.value === "create" ? o = await A.post(k.value, _.value) : w.value === "edit" && (o = a.config?.app === "konnect" ? await A.put(k.value, _.value) : await A.patch(k.value, _.value)), o) {
|
|
538
|
+
const { data: n } = o;
|
|
539
|
+
e.fields.key_id = n?.kid || "", e.fields.name = n?.name || "", e.fields.tags = n?.tags?.join(", ") || "", e.fields.key_set = n?.set?.id || "", e.fields.key_format = n?.pem ? "pem" : "jwk", e.fields.jwk = n?.jwk || "", e.fields.private_key = n?.pem?.private_key || "", e.fields.public_key = n?.pem?.public_key || "", a.showx5t && (e.fields.x5t = n?.x5t || ""), Object.assign(I, e.fields), v("update", o?.data);
|
|
540
|
+
}
|
|
541
|
+
} catch (o) {
|
|
542
|
+
e.errorMessage = S(o), v("error", o);
|
|
543
|
+
} finally {
|
|
544
|
+
e.isReadonly = !1;
|
|
545
|
+
}
|
|
546
|
+
}, {
|
|
547
|
+
debouncedQueryChange: ee,
|
|
548
|
+
loading: oe,
|
|
549
|
+
allRecords: N,
|
|
550
|
+
error: se,
|
|
551
|
+
validationError: ne,
|
|
552
|
+
loadItems: re,
|
|
553
|
+
results: de
|
|
554
|
+
} = ze(a.config, T.form[a.config.app].keySets, void 0, {
|
|
555
|
+
fetchedItemsKey: "data",
|
|
556
|
+
searchKeys: ["id", "name"]
|
|
557
|
+
}), ce = (o) => {
|
|
558
|
+
(!o || o !== e.fields.key_set && o !== I.key_set) && ee(o);
|
|
559
|
+
}, ye = m(() => se.value ? s("keys.errors.key_sets.fetch") : ""), te = m(() => ne.value ? s("keys.errors.key_sets.invalid") : ""), x = b(0), J = m(() => N.value === void 0), L = m(() => {
|
|
560
|
+
if (J.value)
|
|
561
|
+
return a.config.app === "konnect" ? s("keys.form.fields.key_set.footer") : void 0;
|
|
562
|
+
}), W = b(/* @__PURE__ */ new Set()), ae = m(() => Array.from(W.value).map((n) => ({
|
|
563
|
+
name: n.name || "",
|
|
564
|
+
// can't use name for label or it tries to search => 404
|
|
565
|
+
label: "",
|
|
566
|
+
// leave it blank so no flicker when used with selected-item-template
|
|
567
|
+
value: n.id,
|
|
568
|
+
selected: e.fields.key_set === n.id
|
|
569
|
+
}))), fe = (o) => {
|
|
570
|
+
W.value.clear();
|
|
571
|
+
let n;
|
|
572
|
+
for (n of o)
|
|
573
|
+
W.value.add(n);
|
|
574
|
+
};
|
|
575
|
+
return Z(de, (o) => {
|
|
576
|
+
fe(o);
|
|
577
|
+
}, { immediate: !0, deep: !0 }), Z(ae, () => {
|
|
578
|
+
x.value++;
|
|
579
|
+
}, { immediate: !0, deep: !0 }), $e(async () => {
|
|
580
|
+
await re();
|
|
581
|
+
}), (o, n) => {
|
|
582
|
+
const H = j("KInput"), Q = j("KSelect"), P = j("KTextArea");
|
|
583
|
+
return g(), q("div", nt, [
|
|
584
|
+
c(t(Xe), {
|
|
585
|
+
"can-submit": O.value,
|
|
586
|
+
config: i.config,
|
|
587
|
+
"edit-id": i.keyId,
|
|
588
|
+
"entity-type": t(Ee).Key,
|
|
589
|
+
"error-message": e.errorMessage || ye.value,
|
|
590
|
+
"fetch-url": G.value,
|
|
591
|
+
"form-fields": _.value,
|
|
592
|
+
"is-readonly": e.isReadonly,
|
|
593
|
+
onCancel: u,
|
|
594
|
+
"onFetch:error": n[9] || (n[9] = (l) => o.$emit("error", l)),
|
|
595
|
+
"onFetch:success": K,
|
|
596
|
+
onLoading: n[10] || (n[10] = (l) => o.$emit("loading", l)),
|
|
597
|
+
onSubmit: y
|
|
598
|
+
}, {
|
|
599
|
+
default: r(() => [
|
|
600
|
+
c(t(Ke), {
|
|
601
|
+
description: t(s)("keys.form.sections.general.description"),
|
|
602
|
+
title: t(s)("keys.form.sections.general.title")
|
|
603
|
+
}, {
|
|
604
|
+
default: r(() => [
|
|
605
|
+
c(H, {
|
|
606
|
+
modelValue: e.fields.key_id,
|
|
607
|
+
"onUpdate:modelValue": n[0] || (n[0] = (l) => e.fields.key_id = l),
|
|
608
|
+
modelModifiers: { trim: !0 },
|
|
609
|
+
autocomplete: "off",
|
|
610
|
+
"data-testid": "key-form-id",
|
|
611
|
+
help: t(s)("keys.form.fields.id.help"),
|
|
612
|
+
label: t(s)("keys.form.fields.id.label"),
|
|
613
|
+
"label-attributes": {
|
|
614
|
+
info: t(s)("keys.form.fields.id.tooltip"),
|
|
615
|
+
tooltipAttributes: { maxWidth: "400" }
|
|
616
|
+
},
|
|
617
|
+
placeholder: t(s)("keys.form.fields.id.placeholder"),
|
|
618
|
+
readonly: e.isReadonly,
|
|
619
|
+
required: "",
|
|
620
|
+
type: "text"
|
|
621
|
+
}, null, 8, ["modelValue", "help", "label", "label-attributes", "placeholder", "readonly"]),
|
|
622
|
+
i.showx5t ? (g(), C(H, {
|
|
623
|
+
key: 0,
|
|
624
|
+
modelValue: e.fields.x5t,
|
|
625
|
+
"onUpdate:modelValue": n[1] || (n[1] = (l) => e.fields.x5t = l),
|
|
626
|
+
modelModifiers: { trim: !0 },
|
|
627
|
+
autocomplete: "off",
|
|
628
|
+
"data-testid": "key-form-x5t",
|
|
629
|
+
help: t(s)("keys.form.fields.x5t.help"),
|
|
630
|
+
label: t(s)("keys.form.fields.x5t.label"),
|
|
631
|
+
"label-attributes": {
|
|
632
|
+
info: t(s)("keys.form.fields.x5t.tooltip"),
|
|
633
|
+
tooltipAttributes: { maxWidth: "400" }
|
|
634
|
+
},
|
|
635
|
+
placeholder: t(s)("keys.form.fields.x5t.placeholder"),
|
|
636
|
+
readonly: e.isReadonly,
|
|
637
|
+
type: "text"
|
|
638
|
+
}, null, 8, ["modelValue", "help", "label", "label-attributes", "placeholder", "readonly"])) : U("", !0),
|
|
639
|
+
c(H, {
|
|
640
|
+
modelValue: e.fields.name,
|
|
641
|
+
"onUpdate:modelValue": n[2] || (n[2] = (l) => e.fields.name = l),
|
|
642
|
+
modelModifiers: { trim: !0 },
|
|
643
|
+
autocomplete: "off",
|
|
644
|
+
"data-testid": "key-form-name",
|
|
645
|
+
label: t(s)("keys.form.fields.name.label"),
|
|
646
|
+
placeholder: t(s)("keys.form.fields.name.placeholder"),
|
|
647
|
+
readonly: e.isReadonly,
|
|
648
|
+
type: "text"
|
|
649
|
+
}, null, 8, ["modelValue", "label", "placeholder", "readonly"]),
|
|
650
|
+
c(Q, {
|
|
651
|
+
modelValue: e.fields.key_set,
|
|
652
|
+
"onUpdate:modelValue": n[3] || (n[3] = (l) => e.fields.key_set = l),
|
|
653
|
+
clearable: z.value,
|
|
654
|
+
"data-testid": "key-form-key-set",
|
|
655
|
+
"dropdown-footer-text": L.value,
|
|
656
|
+
"enable-filtering": "",
|
|
657
|
+
"filter-function": () => !0,
|
|
658
|
+
items: ae.value,
|
|
659
|
+
label: t(s)("keys.form.fields.key_set.label"),
|
|
660
|
+
loading: t(oe),
|
|
661
|
+
placeholder: t(s)("keys.form.fields.key_set.placeholder"),
|
|
662
|
+
readonly: V.value,
|
|
663
|
+
width: "100%",
|
|
664
|
+
onQueryChange: ce
|
|
665
|
+
}, {
|
|
666
|
+
loading: r(() => [
|
|
667
|
+
$("div", null, h(t(s)("keys.actions.loading")), 1)
|
|
668
|
+
]),
|
|
669
|
+
empty: r(() => [
|
|
670
|
+
$("div", rt, h(t(s)("keys.search.no_results")), 1)
|
|
671
|
+
]),
|
|
672
|
+
"selected-item-template": r(({ item: l }) => [
|
|
673
|
+
$("div", null, h(l.name), 1)
|
|
674
|
+
]),
|
|
675
|
+
"item-template": r(({ item: l }) => [
|
|
676
|
+
$("div", dt, [
|
|
677
|
+
$("div", ct, h(l.name), 1),
|
|
678
|
+
$("div", yt, h(l.value), 1)
|
|
679
|
+
])
|
|
680
|
+
]),
|
|
681
|
+
_: 1
|
|
682
|
+
}, 8, ["modelValue", "clearable", "dropdown-footer-text", "items", "label", "loading", "placeholder", "readonly"]),
|
|
683
|
+
te.value ? (g(), q("p", ft, h(te.value), 1)) : U("", !0),
|
|
684
|
+
c(H, {
|
|
685
|
+
modelValue: e.fields.tags,
|
|
686
|
+
"onUpdate:modelValue": n[4] || (n[4] = (l) => e.fields.tags = l),
|
|
687
|
+
modelModifiers: { trim: !0 },
|
|
688
|
+
autocomplete: "off",
|
|
689
|
+
"data-testid": "key-form-tags",
|
|
690
|
+
help: t(s)("keys.form.fields.tags.help"),
|
|
691
|
+
label: t(s)("keys.form.fields.tags.label"),
|
|
692
|
+
"label-attributes": {
|
|
693
|
+
info: t(s)("keys.form.fields.tags.tooltip"),
|
|
694
|
+
tooltipAttributes: { maxWidth: "400" }
|
|
695
|
+
},
|
|
696
|
+
placeholder: t(s)("keys.form.fields.tags.placeholder"),
|
|
697
|
+
readonly: e.isReadonly,
|
|
698
|
+
type: "text"
|
|
699
|
+
}, null, 8, ["modelValue", "help", "label", "label-attributes", "placeholder", "readonly"])
|
|
700
|
+
]),
|
|
701
|
+
_: 1
|
|
702
|
+
}, 8, ["description", "title"]),
|
|
703
|
+
c(t(Ke), {
|
|
704
|
+
description: t(s)("keys.form.sections.keys.description"),
|
|
705
|
+
"has-divider": "",
|
|
706
|
+
title: t(s)("keys.form.sections.keys.title")
|
|
707
|
+
}, {
|
|
708
|
+
default: r(() => [
|
|
709
|
+
$("div", ut, [
|
|
710
|
+
c(Q, {
|
|
711
|
+
modelValue: e.fields.key_format,
|
|
712
|
+
"onUpdate:modelValue": n[5] || (n[5] = (l) => e.fields.key_format = l),
|
|
713
|
+
"data-testid": "key-form-key-format",
|
|
714
|
+
items: E,
|
|
715
|
+
label: t(s)("keys.form.fields.key_format.label"),
|
|
716
|
+
readonly: e.isReadonly,
|
|
717
|
+
required: "",
|
|
718
|
+
width: "100%"
|
|
719
|
+
}, null, 8, ["modelValue", "label", "readonly"])
|
|
720
|
+
]),
|
|
721
|
+
e.fields.key_format === "jwk" ? (g(), C(P, {
|
|
722
|
+
key: 0,
|
|
723
|
+
modelValue: e.fields.jwk,
|
|
724
|
+
"onUpdate:modelValue": n[6] || (n[6] = (l) => e.fields.jwk = l),
|
|
725
|
+
modelModifiers: { trim: !0 },
|
|
726
|
+
"character-limit": !1,
|
|
727
|
+
class: "key-form-textarea",
|
|
728
|
+
"data-testid": "key-form-jwk",
|
|
729
|
+
label: t(s)("keys.form.fields.jwk.label"),
|
|
730
|
+
"label-attributes": {
|
|
731
|
+
info: t(s)("keys.form.fields.jwk.tooltip"),
|
|
732
|
+
tooltipAttributes: { maxWidth: "400" }
|
|
733
|
+
},
|
|
734
|
+
placeholder: t(s)("keys.form.fields.jwk.placeholder"),
|
|
735
|
+
readonly: e.isReadonly,
|
|
736
|
+
required: ""
|
|
737
|
+
}, null, 8, ["modelValue", "label", "label-attributes", "placeholder", "readonly"])) : U("", !0),
|
|
738
|
+
e.fields.key_format === "pem" ? (g(), C(P, {
|
|
739
|
+
key: 1,
|
|
740
|
+
modelValue: e.fields.private_key,
|
|
741
|
+
"onUpdate:modelValue": n[7] || (n[7] = (l) => e.fields.private_key = l),
|
|
742
|
+
modelModifiers: { trim: !0 },
|
|
743
|
+
"character-limit": !1,
|
|
744
|
+
class: "key-form-textarea",
|
|
745
|
+
"data-testid": "key-form-private-key",
|
|
746
|
+
label: t(s)("keys.form.fields.private_key.label"),
|
|
747
|
+
placeholder: t(s)("keys.form.fields.private_key.placeholder"),
|
|
748
|
+
readonly: e.isReadonly,
|
|
749
|
+
required: ""
|
|
750
|
+
}, null, 8, ["modelValue", "label", "placeholder", "readonly"])) : U("", !0),
|
|
751
|
+
e.fields.key_format === "pem" ? (g(), C(P, {
|
|
752
|
+
key: 2,
|
|
753
|
+
modelValue: e.fields.public_key,
|
|
754
|
+
"onUpdate:modelValue": n[8] || (n[8] = (l) => e.fields.public_key = l),
|
|
755
|
+
modelModifiers: { trim: !0 },
|
|
756
|
+
"character-limit": !1,
|
|
757
|
+
class: "key-form-textarea",
|
|
758
|
+
"data-testid": "key-form-public-key",
|
|
759
|
+
label: t(s)("keys.form.fields.public_key.label"),
|
|
760
|
+
placeholder: t(s)("keys.form.fields.public_key.placeholder"),
|
|
761
|
+
readonly: e.isReadonly,
|
|
762
|
+
required: ""
|
|
763
|
+
}, null, 8, ["modelValue", "label", "placeholder", "readonly"])) : U("", !0)
|
|
764
|
+
]),
|
|
765
|
+
_: 1
|
|
766
|
+
}, 8, ["description", "title"])
|
|
767
|
+
]),
|
|
768
|
+
_: 1
|
|
769
|
+
}, 8, ["can-submit", "config", "edit-id", "entity-type", "error-message", "fetch-url", "form-fields", "is-readonly"])
|
|
770
|
+
]);
|
|
771
|
+
};
|
|
772
|
+
}
|
|
773
|
+
}), wt = /* @__PURE__ */ Ve(kt, [["__scopeId", "data-v-e35f7792"]]), pt = { class: "kong-ui-entities-keys-entity-config-card" }, mt = { key: 2 }, It = /* @__PURE__ */ me({
|
|
774
|
+
__name: "KeyConfigCard",
|
|
775
|
+
props: {
|
|
776
|
+
/** The base konnect or kongManger config. Pass additional config props in the shared entity component as needed. */
|
|
777
|
+
config: {
|
|
778
|
+
type: Object,
|
|
779
|
+
required: !0,
|
|
780
|
+
validator: (i) => !(!i || !["konnect", "kongManager"].includes(i?.app) || i.app === "konnect" && !i.controlPlaneId || i.app === "kongManager" && typeof i.workspace != "string" || !i.entityId)
|
|
781
|
+
},
|
|
782
|
+
/**
|
|
783
|
+
* External link for documentation that determines visibility of Documentation button
|
|
784
|
+
*/
|
|
785
|
+
configCardDoc: {
|
|
786
|
+
type: String,
|
|
787
|
+
default: "",
|
|
788
|
+
required: !1
|
|
789
|
+
},
|
|
790
|
+
/**
|
|
791
|
+
* Control visibility of card title content
|
|
792
|
+
*/
|
|
793
|
+
hideTitle: {
|
|
794
|
+
type: Boolean,
|
|
795
|
+
default: !1
|
|
796
|
+
},
|
|
797
|
+
/**
|
|
798
|
+
* Keyset id for scoped key entity
|
|
799
|
+
*/
|
|
800
|
+
keySetId: {
|
|
801
|
+
type: String,
|
|
802
|
+
default: null
|
|
803
|
+
}
|
|
804
|
+
},
|
|
805
|
+
emits: ["loading", "fetch:error", "fetch:success", "navigation-click"],
|
|
806
|
+
setup(i, { emit: B }) {
|
|
807
|
+
const v = B, a = i, { axiosInstance: d } = ge(a.config?.axiosRequestConfig), { convertKeyToTitle: s } = Ye(), { i18n: { t: S } } = ve.useI18n(), A = m(() => a.keySetId ? `${T.form[a.config.app].edit.forKeySet}`.replace(/{keySetId}/gi, a.keySetId) : T.form[a.config.app].edit.all), G = m(() => T.form[a.config.app]?.getKeySet), w = b(), e = b({}), I = b(a.keySetId || ""), E = b(""), V = b(!1), z = async (u) => {
|
|
808
|
+
w.value = u, I.value = u?.set?.id, v("fetch:success", u), O(u);
|
|
809
|
+
};
|
|
810
|
+
Z(I, async () => {
|
|
811
|
+
if (!I.value)
|
|
812
|
+
return;
|
|
813
|
+
let u = `${a.config.apiBaseUrl}${G.value}`;
|
|
814
|
+
a.config.app === "konnect" && (u = u.replace(/{controlPlaneId}/gi, a.config?.controlPlaneId || "")), u = u.replace(/\/{workspace}/gi, a.config?.workspace ? `/${a.config.workspace}` : "").replace(/{keySetId}/gi, I.value || "");
|
|
815
|
+
try {
|
|
816
|
+
V.value = !0;
|
|
817
|
+
const { data: k } = await d.get(u, {
|
|
818
|
+
validateStatus: (_) => _ === 404 || _ >= 200 && _ < 300
|
|
819
|
+
// in case KeySet is deleted
|
|
820
|
+
});
|
|
821
|
+
E.value = k?.name || k?.id;
|
|
822
|
+
} catch (k) {
|
|
823
|
+
v("fetch:error", k);
|
|
824
|
+
} finally {
|
|
825
|
+
V.value = !1;
|
|
826
|
+
}
|
|
827
|
+
}, { immediate: !0 });
|
|
828
|
+
const O = (u) => {
|
|
829
|
+
try {
|
|
830
|
+
if (u.jwk) {
|
|
831
|
+
const k = JSON.parse(u.jwk);
|
|
832
|
+
Object.keys(k).forEach((_) => {
|
|
833
|
+
e.value = {
|
|
834
|
+
...e.value,
|
|
835
|
+
[`jwk.${_}`]: k[_]
|
|
836
|
+
};
|
|
837
|
+
});
|
|
838
|
+
} else
|
|
839
|
+
e.value = {
|
|
840
|
+
"pem.public_key": u?.pem?.public_key,
|
|
841
|
+
"pem.private_key": u?.pem?.private_key
|
|
842
|
+
};
|
|
843
|
+
} catch (k) {
|
|
844
|
+
v("fetch:error", k);
|
|
845
|
+
}
|
|
846
|
+
return e;
|
|
847
|
+
}, K = b({
|
|
848
|
+
id: {},
|
|
849
|
+
name: {
|
|
850
|
+
tooltip: S("keys.form.fields.name.tooltip")
|
|
851
|
+
},
|
|
852
|
+
last_updated: {},
|
|
853
|
+
created: {},
|
|
854
|
+
set: {
|
|
855
|
+
label: S("keys.form.fields.set.label"),
|
|
856
|
+
section: ke.Basic,
|
|
857
|
+
tooltip: S("keys.form.fields.set.tooltip"),
|
|
858
|
+
order: 5
|
|
859
|
+
},
|
|
860
|
+
kid: {
|
|
861
|
+
label: S("keys.form.fields.kid.label"),
|
|
862
|
+
section: ke.Basic,
|
|
863
|
+
tooltip: S("keys.form.fields.kid.tooltip")
|
|
864
|
+
},
|
|
865
|
+
tags: {
|
|
866
|
+
tooltip: S("keys.form.fields.tags.tooltip")
|
|
867
|
+
},
|
|
868
|
+
// advanced fields
|
|
869
|
+
jwk: {
|
|
870
|
+
label: S("keys.form.fields.jwk.label"),
|
|
871
|
+
type: ue.Json
|
|
872
|
+
},
|
|
873
|
+
pem: {
|
|
874
|
+
section: ke.Advanced,
|
|
875
|
+
label: S("keys.form.fields.key_format.options.pem"),
|
|
876
|
+
type: ue.Json
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
return (u, k) => {
|
|
880
|
+
const _ = j("KSkeleton");
|
|
881
|
+
return g(), q("div", pt, [
|
|
882
|
+
c(t(Ze), {
|
|
883
|
+
config: i.config,
|
|
884
|
+
"config-card-doc": i.configCardDoc,
|
|
885
|
+
"config-schema": K.value,
|
|
886
|
+
"entity-type": t(Ee).Key,
|
|
887
|
+
"fetch-url": A.value,
|
|
888
|
+
"hide-title": i.hideTitle,
|
|
889
|
+
"onFetch:error": k[0] || (k[0] = (y) => u.$emit("fetch:error", y)),
|
|
890
|
+
"onFetch:success": z,
|
|
891
|
+
onLoading: k[1] || (k[1] = (y) => u.$emit("loading", y))
|
|
892
|
+
}, pe({
|
|
893
|
+
set: r(({ row: y }) => [
|
|
894
|
+
V.value ? (g(), C(_, {
|
|
895
|
+
key: 0,
|
|
896
|
+
"data-testid": "key-set-name-loader",
|
|
897
|
+
type: "spinner"
|
|
898
|
+
})) : y.value && y.value.id === I.value && E.value ? (g(), C(t(et), {
|
|
899
|
+
key: 1,
|
|
900
|
+
item: {
|
|
901
|
+
key: y.value.id,
|
|
902
|
+
value: E.value,
|
|
903
|
+
type: t(ue).LinkInternal
|
|
904
|
+
},
|
|
905
|
+
onClick: (ee) => u.$emit("navigation-click", y.value.id, "key-sets")
|
|
906
|
+
}, null, 8, ["item", "onClick"])) : (g(), q("div", mt, h("–")))
|
|
907
|
+
]),
|
|
908
|
+
_: 2
|
|
909
|
+
}, [
|
|
910
|
+
w.value?.jwk ? {
|
|
911
|
+
name: "jwk",
|
|
912
|
+
fn: r(() => [
|
|
913
|
+
(g(!0), q(Se, null, we(Object.keys(e.value), (y) => (g(), C(t(xe), {
|
|
914
|
+
key: y,
|
|
915
|
+
"data-testid": `${y}`,
|
|
916
|
+
item: {
|
|
917
|
+
key: y,
|
|
918
|
+
label: t(s)(y),
|
|
919
|
+
value: e.value[y]
|
|
920
|
+
}
|
|
921
|
+
}, null, 8, ["data-testid", "item"]))), 128))
|
|
922
|
+
]),
|
|
923
|
+
key: "0"
|
|
924
|
+
} : void 0,
|
|
925
|
+
w.value?.pem ? {
|
|
926
|
+
name: "pem",
|
|
927
|
+
fn: r(() => [
|
|
928
|
+
(g(!0), q(Se, null, we(Object.keys(e.value), (y) => (g(), C(t(xe), {
|
|
929
|
+
key: y,
|
|
930
|
+
"data-testid": `${y}`,
|
|
931
|
+
item: {
|
|
932
|
+
key: y,
|
|
933
|
+
label: t(s)(y),
|
|
934
|
+
value: e.value[y]
|
|
935
|
+
}
|
|
936
|
+
}, null, 8, ["data-testid", "item"]))), 128))
|
|
937
|
+
]),
|
|
938
|
+
key: "1"
|
|
939
|
+
} : void 0
|
|
940
|
+
]), 1032, ["config", "config-card-doc", "config-schema", "entity-type", "fetch-url", "hide-title"])
|
|
941
|
+
]);
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
export {
|
|
946
|
+
It as KeyConfigCard,
|
|
947
|
+
wt as KeyForm,
|
|
948
|
+
St as KeyList
|
|
949
|
+
};
|