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