@coffre/ui 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{audit-sentence-JrQIUq6j.js → audit-sentence-DpYySuqg.js} +74 -7
- package/dist/chunks/audit-sentence-DpYySuqg.js.map +1 -0
- package/dist/chunks/{connected-apps-Dr8UgjK7.js → connected-apps-D48SFJsG.js} +4 -4
- package/dist/chunks/{connected-apps-Dr8UgjK7.js.map → connected-apps-D48SFJsG.js.map} +1 -1
- package/dist/chunks/{delete-place-CQCDHkne.js → delete-place-Cg_M6rAq.js} +4 -4
- package/dist/chunks/{delete-place-CQCDHkne.js.map → delete-place-Cg_M6rAq.js.map} +1 -1
- package/dist/chunks/{directory-XcSbDRJv.js → directory-_LTgdiIM.js} +11 -9
- package/dist/chunks/directory-_LTgdiIM.js.map +1 -0
- package/dist/chunks/{folders-Dw240WMJ.js → folders-D3A1NGpt.js} +2 -2
- package/dist/chunks/{folders-Dw240WMJ.js.map → folders-D3A1NGpt.js.map} +1 -1
- package/dist/chunks/{grants-CmdZjKYU.js → grants-CNM913EY.js} +6 -6
- package/dist/chunks/{grants-CmdZjKYU.js.map → grants-CNM913EY.js.map} +1 -1
- package/dist/chunks/{multi-combobox-CsIXihuc.js → multi-combobox-B0JzP1QN.js} +2 -2
- package/dist/chunks/{multi-combobox-CsIXihuc.js.map → multi-combobox-B0JzP1QN.js.map} +1 -1
- package/dist/chunks/{offboarding-CrgwaetA.js → offboarding-BeaNM3sf.js} +3 -3
- package/dist/chunks/{offboarding-CrgwaetA.js.map → offboarding-BeaNM3sf.js.map} +1 -1
- package/dist/chunks/{personal-tokens-Dvl1FktE.js → personal-tokens-KsXajpx4.js} +4 -4
- package/dist/chunks/{personal-tokens-Dvl1FktE.js.map → personal-tokens-KsXajpx4.js.map} +1 -1
- package/dist/chunks/{principal-page-bOaEYWJB.js → principal-page-BaiZXh6D.js} +94 -78
- package/dist/chunks/principal-page-BaiZXh6D.js.map +1 -0
- package/dist/chunks/{project-page-BI--vjt3.js → project-page-CYZ_MkfX.js} +2 -2
- package/dist/chunks/{project-page-BI--vjt3.js.map → project-page-CYZ_MkfX.js.map} +1 -1
- package/dist/chunks/protected-BL_DsZO6.js +22 -0
- package/dist/chunks/protected-BL_DsZO6.js.map +1 -0
- package/dist/chunks/{queries-epz4MIuW.js → queries-Danu0o75.js} +99 -31
- package/dist/chunks/queries-Danu0o75.js.map +1 -0
- package/dist/chunks/{references-DImfw0cz.js → references-BK2aPXae.js} +4 -4
- package/dist/chunks/{references-DImfw0cz.js.map → references-BK2aPXae.js.map} +1 -1
- package/dist/chunks/{role-field-C1KhNaIR.js → role-field-DIJiRz9B.js} +8 -5
- package/dist/chunks/role-field-DIJiRz9B.js.map +1 -0
- package/dist/chunks/{row-state-BsIHspy4.js → row-state-xtRGFnDc.js} +2 -2
- package/dist/chunks/{row-state-BsIHspy4.js.map → row-state-xtRGFnDc.js.map} +1 -1
- package/dist/chunks/{theme-3b4DnCow.js → theme-Ck45wzWB.js} +2 -2
- package/dist/chunks/{theme-3b4DnCow.js.map → theme-Ck45wzWB.js.map} +1 -1
- package/dist/chunks/{ui-2kwXXfrX.js → ui-D-blFWfx.js} +29 -5
- package/dist/chunks/{ui-2kwXXfrX.js.map → ui-D-blFWfx.js.map} +1 -1
- package/dist/chunks/{use-action-BB-RcHo1.js → use-action-BafZVwux.js} +2 -2
- package/dist/chunks/{use-action-BB-RcHo1.js.map → use-action-BafZVwux.js.map} +1 -1
- package/dist/chunks/{use-change-BY6KPmnJ.js → use-change-DhV6i_Ge.js} +218 -101
- package/dist/chunks/use-change-DhV6i_Ge.js.map +1 -0
- package/dist/chunks/use-roles-Daje0ikO.js +224 -0
- package/dist/chunks/use-roles-Daje0ikO.js.map +1 -0
- package/dist/chunks/{use-shell-C_NmvCt_.js → use-shell-BX9mzfaL.js} +2 -2
- package/dist/chunks/{use-shell-C_NmvCt_.js.map → use-shell-BX9mzfaL.js.map} +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +29 -15
- package/dist/index.js.map +1 -1
- package/dist/pages/account.js +9 -9
- package/dist/pages/approval.js +1 -1
- package/dist/pages/audit.js +96 -34
- package/dist/pages/audit.js.map +1 -1
- package/dist/pages/device-login.js +1 -1
- package/dist/pages/environment.js +255 -115
- package/dist/pages/environment.js.map +1 -1
- package/dist/pages/login.js +2 -2
- package/dist/pages/oauth-authorize.js +1 -1
- package/dist/pages/project-access.js +79 -46
- package/dist/pages/project-access.js.map +1 -1
- package/dist/pages/project-environments.js +79 -30
- package/dist/pages/project-environments.js.map +1 -1
- package/dist/pages/project-settings.js +7 -7
- package/dist/pages/project.js +2 -2
- package/dist/pages/projects.js +26 -14
- package/dist/pages/projects.js.map +1 -1
- package/dist/pages/service-account.js +22 -15
- package/dist/pages/service-account.js.map +1 -1
- package/dist/pages/service-accounts.js +4 -4
- package/dist/pages/settings.js +580 -8
- package/dist/pages/settings.js.map +1 -1
- package/dist/pages/unregistered.js +1 -1
- package/dist/pages/user.js +5 -5
- package/dist/pages/users.js +4 -4
- package/package.json +3 -3
- package/src/components/directory.tsx +5 -2
- package/src/components/grants.tsx +1 -1
- package/src/components/principal-page.tsx +38 -23
- package/src/components/protected.tsx +17 -0
- package/src/components/role-editor.tsx +582 -0
- package/src/components/role-field.tsx +7 -3
- package/src/components/scope-picker.tsx +19 -9
- package/src/components/shell.tsx +7 -1
- package/src/components/ui.tsx +25 -2
- package/src/lib/access-plan.ts +35 -36
- package/src/lib/audit-sentences.ts +75 -9
- package/src/lib/changes.ts +46 -8
- package/src/lib/project-access.ts +4 -78
- package/src/lib/queries.ts +97 -29
- package/src/lib/roles.ts +201 -0
- package/src/lib/row-reads.ts +12 -0
- package/src/lib/secret-edit-batch.ts +147 -56
- package/src/lib/sensitivity.ts +50 -0
- package/src/lib/service-setup.ts +20 -8
- package/src/lib/use-roles.ts +17 -0
- package/src/options.ts +2 -3
- package/src/pages/audit.tsx +99 -26
- package/src/pages/environment.tsx +264 -101
- package/src/pages/project-access.tsx +49 -19
- package/src/pages/project-environments.tsx +62 -3
- package/src/pages/projects.tsx +3 -1
- package/src/pages/settings.tsx +2 -0
- package/src/parity.ts +42 -5
- package/src/shared/models.ts +2 -9
- package/src/styles/globals.css +322 -25
- package/dist/chunks/audit-sentence-JrQIUq6j.js.map +0 -1
- package/dist/chunks/directory-XcSbDRJv.js.map +0 -1
- package/dist/chunks/principal-page-bOaEYWJB.js.map +0 -1
- package/dist/chunks/queries-epz4MIuW.js.map +0 -1
- package/dist/chunks/role-field-C1KhNaIR.js.map +0 -1
- package/dist/chunks/use-change-BY6KPmnJ.js.map +0 -1
|
@@ -1,48 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as refresh, o as keys, t as affects } from "./queries-Danu0o75.js";
|
|
2
2
|
import { a as Refusal, o as failureMessage, s as memberRef } from "./page-JTORvh-N.js";
|
|
3
|
-
import { o as announce } from "./row-state-
|
|
3
|
+
import { o as announce } from "./row-state-xtRGFnDc.js";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
|
-
import { EVERYWHERE,
|
|
5
|
+
import { EVERYWHERE, unscoped } from "@coffre/core/access";
|
|
6
6
|
import { useMutation, useMutationState, useQueryClient } from "@tanstack/react-query";
|
|
7
7
|
import { regenerateWrite } from "@coffre/core/recipe";
|
|
8
8
|
//#region src/lib/project-access.ts
|
|
9
|
-
|
|
10
|
-
const options = [{
|
|
11
|
-
value: "owner:",
|
|
12
|
-
role: "owner",
|
|
13
|
-
environmentSlug: null,
|
|
14
|
-
label: ROLES.owner.name
|
|
15
|
-
}];
|
|
16
|
-
for (const role of ["viewer", "developer"]) options.push({
|
|
17
|
-
value: `${role}:`,
|
|
18
|
-
role,
|
|
19
|
-
environmentSlug: null,
|
|
20
|
-
label: `${ROLES[role].name}: all`
|
|
21
|
-
});
|
|
22
|
-
for (const environment of environments) {
|
|
23
|
-
if (environment.details === null || environment.details.archivedAt !== null) continue;
|
|
24
|
-
for (const role of ["viewer", "developer"]) options.push({
|
|
25
|
-
value: `${role}:${environment.slug}`,
|
|
26
|
-
role,
|
|
27
|
-
environmentSlug: environment.slug,
|
|
28
|
-
label: `${ROLES[role].name}: ${environment.slug}`
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return options;
|
|
32
|
-
}
|
|
33
|
-
function parseProjectAccess(value) {
|
|
34
|
-
const [role, environmentSlug = ""] = value.split(":", 2);
|
|
35
|
-
if (role !== "owner" && role !== "viewer" && role !== "developer") throw new Error("unknown project access level");
|
|
36
|
-
return {
|
|
37
|
-
role,
|
|
38
|
-
environmentSlug: environmentSlug || null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/** "Owner", "Viewer: all" or "Developer: prod": a grant by its role's name, and where. */
|
|
9
|
+
/** "Owner", "Viewer: all" or "Developer: prod": a grant by its role's name, as the instance names it, and where. */
|
|
42
10
|
function projectAccessLabel(grant) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return `${name}: ${grant.environmentSlug ?? "all"}`;
|
|
11
|
+
if (grant.role === "owner") return grant.roleName;
|
|
12
|
+
return `${grant.roleName}: ${grant.environmentSlug ?? "all"}`;
|
|
46
13
|
}
|
|
47
14
|
/**
|
|
48
15
|
* The Access tab's rows, project by project: a row per grant, and a project
|
|
@@ -111,29 +78,93 @@ function regenerateWaits(key, generated, busy) {
|
|
|
111
78
|
return [key, ...regeneratedKeys(key, generated)].some(busy);
|
|
112
79
|
}
|
|
113
80
|
//#endregion
|
|
81
|
+
//#region src/lib/sensitivity.ts
|
|
82
|
+
/**
|
|
83
|
+
* Who sees a key's value, loosest first: `plain`, whoever lists its
|
|
84
|
+
* environment; `secret`, the default, people whose role reads secrets;
|
|
85
|
+
* `sensitive`, no person, Owners included, while their apps use it through
|
|
86
|
+
* the credential proxy and service accounts read it. A key is made
|
|
87
|
+
* stricter with its value kept; looser only with its value typed again, so
|
|
88
|
+
* nobody shows a value by flipping it.
|
|
89
|
+
*/
|
|
90
|
+
var SENSITIVITIES = [
|
|
91
|
+
"plain",
|
|
92
|
+
"secret",
|
|
93
|
+
"sensitive"
|
|
94
|
+
];
|
|
95
|
+
/** Each level as the page names it, and who it lets see the value. */
|
|
96
|
+
var LEVELS = {
|
|
97
|
+
plain: {
|
|
98
|
+
label: "Plain",
|
|
99
|
+
hint: "Visible to anyone who can see this environment"
|
|
100
|
+
},
|
|
101
|
+
secret: {
|
|
102
|
+
label: "Secret",
|
|
103
|
+
hint: "Visible to people whose role can read secrets"
|
|
104
|
+
},
|
|
105
|
+
sensitive: {
|
|
106
|
+
label: "Sensitive",
|
|
107
|
+
hint: "Never shown to anyone, Owners included. Used through the proxy or by services"
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
/** The levels in your personal config, `dev@me`, whose values nobody else sees, whatever their level. */
|
|
111
|
+
var PERSONAL_LEVELS = {
|
|
112
|
+
plain: {
|
|
113
|
+
label: "Plain",
|
|
114
|
+
hint: "Visible to you alone, as it is"
|
|
115
|
+
},
|
|
116
|
+
secret: {
|
|
117
|
+
label: "Secret",
|
|
118
|
+
hint: "Visible to you alone, when you reveal it"
|
|
119
|
+
},
|
|
120
|
+
sensitive: {
|
|
121
|
+
label: "Sensitive",
|
|
122
|
+
hint: "Never shown, you included. Your app uses it through the proxy"
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
/** Each level as a page names it, in your personal config or elsewhere. */
|
|
126
|
+
function levelsIn(personal) {
|
|
127
|
+
return personal ? PERSONAL_LEVELS : LEVELS;
|
|
128
|
+
}
|
|
129
|
+
/** Whether `a` lets fewer people see a value than `b`. */
|
|
130
|
+
function stricter(a, b) {
|
|
131
|
+
return SENSITIVITIES.indexOf(a) > SENSITIVITIES.indexOf(b);
|
|
132
|
+
}
|
|
133
|
+
/** A key's own value, which a mark makes stricter in place: not a reference's, nor one a fork inherits. */
|
|
134
|
+
function markable(entry) {
|
|
135
|
+
return entry.sensitivity !== null && entry.reference === null && (entry.parent === null || entry.parent.state === "overridden");
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Whether a change of who sees a key waits for its value typed: looser
|
|
139
|
+
* than the key is, or where it has no value of its own to mark.
|
|
140
|
+
*/
|
|
141
|
+
function waitsForValue(entry, change) {
|
|
142
|
+
if (change === void 0 || change.archived || change.value !== null || change.sensitivity === void 0) return false;
|
|
143
|
+
return !markable(entry) || stricter(entry.sensitivity, change.sensitivity);
|
|
144
|
+
}
|
|
145
|
+
//#endregion
|
|
114
146
|
//#region src/lib/secret-edit-batch.ts
|
|
115
147
|
/**
|
|
116
|
-
* What
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
148
|
+
* What an edit of a row's value, and of who sees it, makes of its change,
|
|
149
|
+
* from where it started: `from.start`, the value the editor opened on (''
|
|
150
|
+
* when it could not be read), and `from.level`, who sees the row's value
|
|
151
|
+
* now (null for none of its own: a secret is written). A value left as it
|
|
152
|
+
* opened writes nothing; its level changed alone is then a mark. Looser
|
|
153
|
+
* than the row, the field opens empty, as that takes the value typed again:
|
|
154
|
+
* a stored value is never made more visible by a flip. Back where it
|
|
155
|
+
* started, it is no change.
|
|
156
|
+
*
|
|
157
|
+
* secret 'sk_1', opened on 'sk_1': Sensitive -> { value: null, sensitivity: 'sensitive' }, a mark
|
|
158
|
+
* secret 'sk_1', opened on 'sk_1': Plain -> { value: null, sensitivity: 'plain' }, waiting for a value
|
|
159
|
+
* then 'sk_2' typed -> { value: 'sk_2', sensitivity: 'plain' }
|
|
123
160
|
*/
|
|
124
|
-
function valueEdit(
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
plain: void 0,
|
|
129
|
-
replaces
|
|
130
|
-
};
|
|
161
|
+
function valueEdit(from, next) {
|
|
162
|
+
const level = from.level ?? "secret";
|
|
163
|
+
const opened = stricter(level, next.sensitivity) ? "" : from.start;
|
|
164
|
+
const value = next.value === opened ? null : next.value;
|
|
131
165
|
return {
|
|
132
166
|
value,
|
|
133
|
-
|
|
134
|
-
replaces,
|
|
135
|
-
companion: void 0,
|
|
136
|
-
recipe: void 0
|
|
167
|
+
sensitivity: value === null && next.sensitivity === level ? void 0 : next.sensitivity
|
|
137
168
|
};
|
|
138
169
|
}
|
|
139
170
|
/**
|
|
@@ -150,27 +181,85 @@ function generationOf(key, edit) {
|
|
|
150
181
|
}
|
|
151
182
|
};
|
|
152
183
|
}
|
|
153
|
-
/**
|
|
154
|
-
function
|
|
184
|
+
/** Who sees the value a row writes: a secret unless it says, and a generated one never plain. */
|
|
185
|
+
function levelOf(edit) {
|
|
186
|
+
return edit.sensitivity === "sensitive" || edit.sensitivity === "plain" && edit.recipe === void 0 ? edit.sensitivity : "secret";
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Who sees each listed key's value now, by its name after the save: a
|
|
190
|
+
* renamed key keeps its level under its new name; an archived one is gone.
|
|
191
|
+
*/
|
|
192
|
+
function levelsNow(active, changes) {
|
|
193
|
+
const out = /* @__PURE__ */ new Map();
|
|
194
|
+
for (const entry of active) {
|
|
195
|
+
const change = secretChangeFor(changes, entry.key);
|
|
196
|
+
if (change?.archived) continue;
|
|
197
|
+
out.set(change?.key.trim() ?? entry.key, entry.sensitivity ?? null);
|
|
198
|
+
}
|
|
199
|
+
return out;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Who sees the public key a pair writes: who the user chose, else who sees
|
|
203
|
+
* the key it writes over now, or a secret, as a generated value is never
|
|
204
|
+
* plain. A public key need not be hidden, so a sensitive private key does
|
|
205
|
+
* not make it sensitive.
|
|
206
|
+
*
|
|
207
|
+
* PRIVATE_KEY sensitive, PUBLIC_KEY secret -> PUBLIC_KEY written secret
|
|
208
|
+
* PRIVATE_KEY secret, PUBLIC_KEY sensitive -> PUBLIC_KEY written sensitive
|
|
209
|
+
* PUBLIC_KEY new -> secret
|
|
210
|
+
*/
|
|
211
|
+
function companionLevel(companion, now) {
|
|
212
|
+
return companion.sensitivity ?? (now.get(companion.key.trim()) === "sensitive" ? "sensitive" : "secret");
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* What a row writes under each key: its value, and its companion's beside
|
|
216
|
+
* it, each saying who sees it, as every write does: over a sensitive key,
|
|
217
|
+
* one that said nothing would stay sensitive.
|
|
218
|
+
*/
|
|
219
|
+
function rowPatch(key, value, edit, now) {
|
|
155
220
|
const generated = generationOf(key, edit);
|
|
156
|
-
const
|
|
221
|
+
const entry = (each, sensitivity) => generated === void 0 || sensitivity === "plain" ? {
|
|
157
222
|
value: each,
|
|
158
|
-
|
|
223
|
+
sensitivity
|
|
159
224
|
} : {
|
|
160
225
|
value: each,
|
|
161
|
-
|
|
162
|
-
|
|
226
|
+
generated,
|
|
227
|
+
sensitivity
|
|
163
228
|
};
|
|
164
|
-
const entry = (each) => generated !== void 0 ? {
|
|
165
|
-
value: each,
|
|
166
|
-
generated
|
|
167
|
-
} : edit.plain === true ? plain(each) : each;
|
|
168
229
|
const patch = Object.create(null);
|
|
169
|
-
patch[key] = entry(value);
|
|
170
|
-
if (edit.companion !== void 0) patch[edit.companion.key.trim()] = entry(edit.companion.value);
|
|
230
|
+
patch[key] = entry(value, levelOf(edit));
|
|
231
|
+
if (edit.companion !== void 0) patch[edit.companion.key.trim()] = entry(edit.companion.value, companionLevel(edit.companion, now));
|
|
232
|
+
return patch;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The one merge patch a save writes, by each key's name after its renames:
|
|
236
|
+
* every value with its companion, every mark and every archive. An edit
|
|
237
|
+
* whose key went from the list writes nothing.
|
|
238
|
+
*/
|
|
239
|
+
function patchOf(active, drafts, changes) {
|
|
240
|
+
const now = levelsNow(active, changes);
|
|
241
|
+
const patch = Object.create(null);
|
|
242
|
+
for (const entry of active) {
|
|
243
|
+
const change = secretChangeFor(changes, entry.key);
|
|
244
|
+
if (change === void 0) continue;
|
|
245
|
+
const key = change.key.trim();
|
|
246
|
+
if (change.archived) patch[entry.key] = null;
|
|
247
|
+
else if (change.value !== null) Object.assign(patch, rowPatch(key, change.value, change, now));
|
|
248
|
+
else if (change.sensitivity !== void 0) patch[key] = { sensitivity: change.sensitivity };
|
|
249
|
+
}
|
|
250
|
+
for (const draft of drafts) Object.assign(patch, rowPatch(draft.key.trim(), draft.value, draft, now));
|
|
171
251
|
return patch;
|
|
172
252
|
}
|
|
173
253
|
/**
|
|
254
|
+
* The keys a save makes sensitive, by their names after it: each it writes
|
|
255
|
+
* sensitive, a companion included, that was not sensitive before. Nobody
|
|
256
|
+
* sees them again, so the save asks first.
|
|
257
|
+
*/
|
|
258
|
+
function madeSensitive(active, drafts, changes) {
|
|
259
|
+
const now = levelsNow(active, changes);
|
|
260
|
+
return Object.entries(patchOf(active, drafts, changes)).filter(([key, write]) => write !== null && write.sensitivity === "sensitive" && now.get(key) !== "sensitive").map(([key]) => key);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
174
263
|
* The recipe each key a save writes will hold, by its name after the save:
|
|
175
264
|
* what the list shows of it until it is read back.
|
|
176
265
|
*/
|
|
@@ -190,16 +279,15 @@ function generationsOf(active, drafts, changes) {
|
|
|
190
279
|
return out;
|
|
191
280
|
}
|
|
192
281
|
/**
|
|
193
|
-
*
|
|
194
|
-
* save: what the list shows of it until it is read back.
|
|
282
|
+
* Who sees each value a save writes, and a plain one's value, by its key's
|
|
283
|
+
* name after the save: what the list shows of it until it is read back.
|
|
195
284
|
*/
|
|
196
|
-
function
|
|
285
|
+
function levelsOf(active, drafts, changes) {
|
|
197
286
|
const out = /* @__PURE__ */ new Map();
|
|
198
|
-
for (const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
287
|
+
for (const [key, write] of Object.entries(patchOf(active, drafts, changes))) if (write !== null && "value" in write) out.set(key, {
|
|
288
|
+
sensitivity: write.sensitivity,
|
|
289
|
+
value: write.sensitivity === "plain" ? write.value : null
|
|
290
|
+
});
|
|
203
291
|
return out;
|
|
204
292
|
}
|
|
205
293
|
function secretChangeFor(changes, key) {
|
|
@@ -224,7 +312,7 @@ function hasSecretEditConflict(active, drafts, changes) {
|
|
|
224
312
|
if (new Set(draftKeys).size !== draftKeys.length) return true;
|
|
225
313
|
const valueEditTargets = new Set(active.flatMap((entry) => {
|
|
226
314
|
const change = secretChangeFor(changes, entry.key);
|
|
227
|
-
return change !== void 0 && !change.archived && change.value !== null ? [change.key.trim()] : [];
|
|
315
|
+
return change !== void 0 && !change.archived && (change.value !== null || change.sensitivity !== void 0) ? [change.key.trim()] : [];
|
|
228
316
|
}));
|
|
229
317
|
if (draftKeys.some((key) => valueEditTargets.has(key))) return true;
|
|
230
318
|
const archivedKeys = new Set(active.filter((entry) => secretChangeFor(changes, entry.key)?.archived).map((entry) => entry.key));
|
|
@@ -250,26 +338,19 @@ async function applySecretEditBatch({ active, drafts, changes, operations }) {
|
|
|
250
338
|
error: plan
|
|
251
339
|
};
|
|
252
340
|
let applied = 0;
|
|
253
|
-
const patch =
|
|
341
|
+
const patch = patchOf(active, drafts, changes);
|
|
254
342
|
try {
|
|
255
343
|
for (const { sourceKey, change } of plan) {
|
|
256
|
-
if (change.archived) {
|
|
257
|
-
patch[sourceKey] = null;
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
344
|
const key = change.key.trim();
|
|
261
|
-
if (key
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
if (change.value !== null) Object.assign(patch, rowPatch(key, change.value, change));
|
|
345
|
+
if (change.archived || key === sourceKey) continue;
|
|
346
|
+
await operations.rename(sourceKey, key);
|
|
347
|
+
delete remainingChanges[sourceKey];
|
|
348
|
+
applied += 1;
|
|
349
|
+
if (change.value !== null || change.sensitivity !== void 0) remainingChanges[key] = {
|
|
350
|
+
...change,
|
|
351
|
+
key
|
|
352
|
+
};
|
|
271
353
|
}
|
|
272
|
-
for (const draft of drafts) Object.assign(patch, rowPatch(draft.key.trim(), draft.value, draft));
|
|
273
354
|
const written = Object.keys(patch).length;
|
|
274
355
|
if (written > 0) await operations.write({ ...patch });
|
|
275
356
|
return {
|
|
@@ -395,7 +476,7 @@ function grantPlace(project, environmentSlug) {
|
|
|
395
476
|
function grantAccess(client, project) {
|
|
396
477
|
return {
|
|
397
478
|
list: grantsList(project),
|
|
398
|
-
label: (vars) => `${vars
|
|
479
|
+
label: (vars) => `${projectAccessLabel(vars)} for ${vars.principalId}`,
|
|
399
480
|
targets: (vars) => [saving(grantId(vars))],
|
|
400
481
|
apply: (grants, vars) => {
|
|
401
482
|
const row = {
|
|
@@ -658,6 +739,7 @@ function createEnvironment(client, project) {
|
|
|
658
739
|
name: vars.slug,
|
|
659
740
|
accessible: false,
|
|
660
741
|
parent: vars.inherit === true ? vars.from ?? null : null,
|
|
742
|
+
protected: vars.from !== void 0 && environments.some((environment) => environment.slug === vars.from && environment.protected),
|
|
661
743
|
personal: false,
|
|
662
744
|
details: {
|
|
663
745
|
archivedAt: null,
|
|
@@ -689,6 +771,26 @@ function renameEnvironment(client, project) {
|
|
|
689
771
|
};
|
|
690
772
|
}
|
|
691
773
|
/**
|
|
774
|
+
* Protect an environment, or take its protection off (docs/design/roles.md):
|
|
775
|
+
* shown on its card at once, and the card says if the server refuses. Only
|
|
776
|
+
* an Owner of the whole instance unprotects one, which the page offers to
|
|
777
|
+
* them alone. What everyone holds there changes, so the roles' readers are
|
|
778
|
+
* refetched too.
|
|
779
|
+
*/
|
|
780
|
+
function protectEnvironment(client, project) {
|
|
781
|
+
return {
|
|
782
|
+
list: environmentsList(project),
|
|
783
|
+
label: (vars) => `environment ${vars.slug}`,
|
|
784
|
+
targets: (vars) => [saving(environmentId(project, vars.slug))],
|
|
785
|
+
apply: (environments, vars) => environments.map((environment) => environment.slug === vars.slug ? {
|
|
786
|
+
...environment,
|
|
787
|
+
protected: vars.protected
|
|
788
|
+
} : environment),
|
|
789
|
+
affects: () => [...affects.places(), ...affects.roles()],
|
|
790
|
+
run: (vars) => client.environments.protect(`${project}/${vars.slug}`, vars.protected)
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
692
794
|
* Archive an environment or bring it back. Archiving ends every read of it,
|
|
693
795
|
* so it waits for the server, as a removal does; restoring shows at once.
|
|
694
796
|
*/
|
|
@@ -751,9 +853,10 @@ function saveSecrets(client, place, author) {
|
|
|
751
853
|
apply: (entries, vars) => {
|
|
752
854
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
753
855
|
const generations = generationsOf(vars.active, vars.drafts, vars.changes);
|
|
754
|
-
const
|
|
856
|
+
const levels = levelsOf(vars.active, vars.drafts, vars.changes);
|
|
755
857
|
const bumped = (entry, key) => {
|
|
756
858
|
const inherited = entry?.parent != null && entry.parent.state !== "overridden" && entry.key === key;
|
|
859
|
+
const level = levels.get(key);
|
|
757
860
|
return {
|
|
758
861
|
key,
|
|
759
862
|
folder: entry?.folder ?? null,
|
|
@@ -764,7 +867,9 @@ function saveSecrets(client, place, author) {
|
|
|
764
867
|
updatedAt: now,
|
|
765
868
|
updatedBy: author,
|
|
766
869
|
generated: generations.get(key) ?? null,
|
|
767
|
-
value:
|
|
870
|
+
value: level?.value ?? null,
|
|
871
|
+
sensitivity: level?.sensitivity ?? "secret",
|
|
872
|
+
readable: level?.value != null || (level?.sensitivity ?? "secret") === "secret" && !inherited && entry?.sensitivity === "secret" && entry.readable,
|
|
768
873
|
parent: entry?.parent == null || entry.key !== key ? null : {
|
|
769
874
|
...entry.parent,
|
|
770
875
|
state: "overridden",
|
|
@@ -779,10 +884,21 @@ function saveSecrets(client, place, author) {
|
|
|
779
884
|
if (change === void 0 || change.archived) return entry;
|
|
780
885
|
const key = change.key.trim();
|
|
781
886
|
if (key !== entry.key) renames.set(entry.key, key);
|
|
782
|
-
|
|
887
|
+
if (change.value !== null) return bumped(entry, key);
|
|
888
|
+
return change.sensitivity === void 0 ? {
|
|
783
889
|
...entry,
|
|
784
890
|
key
|
|
785
|
-
} :
|
|
891
|
+
} : {
|
|
892
|
+
...entry,
|
|
893
|
+
key,
|
|
894
|
+
version: (entry.version ?? 0) + 1,
|
|
895
|
+
versionId: null,
|
|
896
|
+
updatedAt: now,
|
|
897
|
+
updatedBy: author,
|
|
898
|
+
value: null,
|
|
899
|
+
sensitivity: change.sensitivity,
|
|
900
|
+
readable: false
|
|
901
|
+
};
|
|
786
902
|
});
|
|
787
903
|
next = renamePairs(next, renames);
|
|
788
904
|
for (const draft of written(vars)) {
|
|
@@ -867,6 +983,7 @@ function regenerateSecret(client, place, author) {
|
|
|
867
983
|
updatedBy: author,
|
|
868
984
|
generated: vars.generated,
|
|
869
985
|
value: null,
|
|
986
|
+
sensitivity: entry.sensitivity === "sensitive" ? "sensitive" : "secret",
|
|
870
987
|
parent: entry.parent == null ? null : {
|
|
871
988
|
...entry.parent,
|
|
872
989
|
state: "overridden",
|
|
@@ -1191,6 +1308,6 @@ function useChangeStatus(list) {
|
|
|
1191
1308
|
};
|
|
1192
1309
|
}
|
|
1193
1310
|
//#endregion
|
|
1194
|
-
export {
|
|
1311
|
+
export { restoreSecret as A, valueEdit as B, projectsList as C, removeMember as D, removeBinding as E, unlinkIdentity as F, stricter as G, SENSITIVITIES as H, companionsOf as I, regenerateWaits as J, waitsForValue as K, hasSecretEditConflict as L, revokeGrant as M, revokeMemberToken as N, renameEnvironment as O, saveSecrets as P, madeSensitive as R, moveSecret as S, regenerateSecret as T, levelsIn as U, LEVELS as V, markable as W, accessRows as X, regeneratedKeys as Y, projectAccessLabel as Z, forkKey as _, UnsavedEdits as a, invite as b, changeRole as c, directoryList as d, disconnectApp as f, environmentId as g, endSession as h, changeOptions as i, revokeCredential as j, restoreMissing as k, createEnvironment as l, dismissMissing as m, useChangeStatus as n, archiveEnvironment as o, disconnectMemberApp as p, liveGeneration as q, changeKey as r, archiveSecret as s, useChange as t, createProject as u, grantAccess as v, protectEnvironment as w, missingList as x, grantId as y, secretChangeFor as z };
|
|
1195
1312
|
|
|
1196
|
-
//# sourceMappingURL=use-change-
|
|
1313
|
+
//# sourceMappingURL=use-change-DhV6i_Ge.js.map
|