@kong-ui-public/entities-keys 3.10.20 → 3.10.21-pr.2722.b1aa23ae4.0

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