@eyeauras/cli-factory 0.1.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.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/src/app-arguments.d.ts +59 -0
- package/dist/src/app-arguments.d.ts.map +1 -0
- package/dist/src/app-arguments.js +102 -0
- package/dist/src/app-arguments.js.map +1 -0
- package/dist/src/auth.d.ts +14 -0
- package/dist/src/auth.d.ts.map +1 -0
- package/dist/src/auth.js +184 -0
- package/dist/src/auth.js.map +1 -0
- package/dist/src/bounded-lines.d.ts +4 -0
- package/dist/src/bounded-lines.d.ts.map +1 -0
- package/dist/src/bounded-lines.js +68 -0
- package/dist/src/bounded-lines.js.map +1 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +364 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/command-gate.d.ts +9 -0
- package/dist/src/command-gate.d.ts.map +1 -0
- package/dist/src/command-gate.js +64 -0
- package/dist/src/command-gate.js.map +1 -0
- package/dist/src/command-input.d.ts +14 -0
- package/dist/src/command-input.d.ts.map +1 -0
- package/dist/src/command-input.js +2 -0
- package/dist/src/command-input.js.map +1 -0
- package/dist/src/command.d.ts +5 -0
- package/dist/src/command.d.ts.map +1 -0
- package/dist/src/command.js +14 -0
- package/dist/src/command.js.map +1 -0
- package/dist/src/index.d.ts +21 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +16 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/input-limits.d.ts +9 -0
- package/dist/src/input-limits.d.ts.map +1 -0
- package/dist/src/input-limits.js +21 -0
- package/dist/src/input-limits.js.map +1 -0
- package/dist/src/json-rpc.d.ts +8 -0
- package/dist/src/json-rpc.d.ts.map +1 -0
- package/dist/src/json-rpc.js +99 -0
- package/dist/src/json-rpc.js.map +1 -0
- package/dist/src/option-parsers.d.ts +10 -0
- package/dist/src/option-parsers.d.ts.map +1 -0
- package/dist/src/option-parsers.js +26 -0
- package/dist/src/option-parsers.js.map +1 -0
- package/dist/src/output.d.ts +4 -0
- package/dist/src/output.d.ts.map +1 -0
- package/dist/src/output.js +54 -0
- package/dist/src/output.js.map +1 -0
- package/dist/src/permissions.d.ts +11 -0
- package/dist/src/permissions.d.ts.map +1 -0
- package/dist/src/permissions.js +95 -0
- package/dist/src/permissions.js.map +1 -0
- package/dist/src/private-storage.d.ts +5 -0
- package/dist/src/private-storage.d.ts.map +1 -0
- package/dist/src/private-storage.js +68 -0
- package/dist/src/private-storage.js.map +1 -0
- package/dist/src/profile-commands.d.ts +29 -0
- package/dist/src/profile-commands.d.ts.map +1 -0
- package/dist/src/profile-commands.js +265 -0
- package/dist/src/profile-commands.js.map +1 -0
- package/dist/src/profile-file.d.ts +26 -0
- package/dist/src/profile-file.d.ts.map +1 -0
- package/dist/src/profile-file.js +325 -0
- package/dist/src/profile-file.js.map +1 -0
- package/dist/src/profile-store.d.ts +32 -0
- package/dist/src/profile-store.d.ts.map +1 -0
- package/dist/src/profile-store.js +223 -0
- package/dist/src/profile-store.js.map +1 -0
- package/dist/src/proof.d.ts +18 -0
- package/dist/src/proof.d.ts.map +1 -0
- package/dist/src/proof.js +98 -0
- package/dist/src/proof.js.map +1 -0
- package/dist/src/resources.d.ts +4 -0
- package/dist/src/resources.d.ts.map +1 -0
- package/dist/src/resources.js +17 -0
- package/dist/src/resources.js.map +1 -0
- package/dist/src/response-body.d.ts +12 -0
- package/dist/src/response-body.d.ts.map +1 -0
- package/dist/src/response-body.js +70 -0
- package/dist/src/response-body.js.map +1 -0
- package/dist/src/secret-store.d.ts +21 -0
- package/dist/src/secret-store.d.ts.map +1 -0
- package/dist/src/secret-store.js +73 -0
- package/dist/src/secret-store.js.map +1 -0
- package/dist/src/target-commands.d.ts +19 -0
- package/dist/src/target-commands.d.ts.map +1 -0
- package/dist/src/target-commands.js +17 -0
- package/dist/src/target-commands.js.map +1 -0
- package/dist/src/testing-contracts.d.ts +31 -0
- package/dist/src/testing-contracts.d.ts.map +1 -0
- package/dist/src/testing-contracts.js +72 -0
- package/dist/src/testing-contracts.js.map +1 -0
- package/dist/src/testing.d.ts +51 -0
- package/dist/src/testing.d.ts.map +1 -0
- package/dist/src/testing.js +126 -0
- package/dist/src/testing.js.map +1 -0
- package/dist/src/types.d.ts +174 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { promptText } from "./auth.js";
|
|
3
|
+
import { command } from "./command.js";
|
|
4
|
+
import { assertProfileName, assertUniqueProfileName } from "./profile-store.js";
|
|
5
|
+
function hasProfileValue(value) {
|
|
6
|
+
return (value !== undefined &&
|
|
7
|
+
value !== null &&
|
|
8
|
+
(typeof value !== "string" || value.trim() !== ""));
|
|
9
|
+
}
|
|
10
|
+
function configureSyntax(field) {
|
|
11
|
+
return (field.flags.match(/--[a-z0-9-]+(?:[ =](?:<[^>]+>|\[[^\]]+\]))?/i)?.[0] ??
|
|
12
|
+
field.flags);
|
|
13
|
+
}
|
|
14
|
+
/** Configure validates against candidate values without persisting credentials early. */
|
|
15
|
+
function deferSecrets(store) {
|
|
16
|
+
const pending = new Map();
|
|
17
|
+
const secrets = {
|
|
18
|
+
get: async (name) => pending.has(name) ? pending.get(name) : store.get(name),
|
|
19
|
+
async require(name) {
|
|
20
|
+
const value = await secrets.get(name);
|
|
21
|
+
if (!value)
|
|
22
|
+
throw new Error("No credential is available. Run 'auth login' first.");
|
|
23
|
+
return value;
|
|
24
|
+
},
|
|
25
|
+
set: async (name, value) => {
|
|
26
|
+
pending.set(name, value);
|
|
27
|
+
},
|
|
28
|
+
delete: async (name) => {
|
|
29
|
+
pending.set(name, undefined);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
secrets,
|
|
34
|
+
async commit(saveProfile) {
|
|
35
|
+
// Fail closed: never bind an old credential to a newly saved endpoint.
|
|
36
|
+
for (const name of pending.keys())
|
|
37
|
+
await store.delete(name);
|
|
38
|
+
await saveProfile();
|
|
39
|
+
for (const [name, value] of pending) {
|
|
40
|
+
if (value !== undefined)
|
|
41
|
+
await store.set(name, value);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function optionKey(flags) {
|
|
47
|
+
const longFlag = flags.split(/[ ,|]+/).find((part) => part.startsWith("--"));
|
|
48
|
+
if (!longFlag) {
|
|
49
|
+
throw new Error(`Option '${flags}' must include a long flag.`);
|
|
50
|
+
}
|
|
51
|
+
return longFlag
|
|
52
|
+
.replace(/^--(?:no-)?/, "")
|
|
53
|
+
.replace(/[ <[].*$/, "")
|
|
54
|
+
.replace(/-([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
55
|
+
}
|
|
56
|
+
/** Profile/auth declarations and onboarding share the same operations, not a second parser. */
|
|
57
|
+
export function createProfileCommands(definition, profileStore, invocation, invalidateProfile) {
|
|
58
|
+
const profileDefinition = definition.profile ?? {};
|
|
59
|
+
const missingRequiredFields = (profile) => (profileDefinition.fields ?? []).filter((field) => field.required === true && !hasProfileValue(profile.values[field.name]));
|
|
60
|
+
const authenticationRequired = (profile) => definition.auth !== undefined &&
|
|
61
|
+
(definition.auth.required?.(profile) ?? true);
|
|
62
|
+
const configurationState = async (profile) => {
|
|
63
|
+
const missingFields = missingRequiredFields(profile);
|
|
64
|
+
const readiness = definition.auth?.isReady;
|
|
65
|
+
const { appArguments, secrets, signal, environment } = invocation.contextFor(profile);
|
|
66
|
+
const authenticationMissing = missingFields.length === 0 &&
|
|
67
|
+
authenticationRequired(profile) &&
|
|
68
|
+
readiness !== undefined &&
|
|
69
|
+
!(await readiness({
|
|
70
|
+
appArguments,
|
|
71
|
+
profile,
|
|
72
|
+
secrets,
|
|
73
|
+
signal,
|
|
74
|
+
environment,
|
|
75
|
+
}));
|
|
76
|
+
return {
|
|
77
|
+
missingFields,
|
|
78
|
+
authenticationMissing,
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const configurationError = (profile, state) => {
|
|
82
|
+
const missing = [
|
|
83
|
+
...state.missingFields.map((field) => configureSyntax(field)),
|
|
84
|
+
...(state.authenticationMissing
|
|
85
|
+
? (definition.auth?.loginOptions ?? []).map(configureSyntax)
|
|
86
|
+
: []),
|
|
87
|
+
];
|
|
88
|
+
const details = [
|
|
89
|
+
...(state.missingFields.length > 0
|
|
90
|
+
? [
|
|
91
|
+
`missing fields: ${state.missingFields.map((field) => field.name).join(", ")}`,
|
|
92
|
+
]
|
|
93
|
+
: []),
|
|
94
|
+
...(state.authenticationMissing ? ["authentication is missing"] : []),
|
|
95
|
+
].join("; ");
|
|
96
|
+
return new Error(`Profile '${profile.name}' is not configured (${details}). ` +
|
|
97
|
+
`Run '${definition.name} profile configure ${profile.name}${missing.length > 0 ? ` ${missing.join(" ")}` : ""}'.`);
|
|
98
|
+
};
|
|
99
|
+
const authContext = (profile, interactive = false) => ({
|
|
100
|
+
...invocation.contextFor(profile),
|
|
101
|
+
interactive,
|
|
102
|
+
stdinAvailable: invocation.stdinAvailable,
|
|
103
|
+
});
|
|
104
|
+
const configureProfile = async (profileName, options) => {
|
|
105
|
+
assertProfileName(profileName);
|
|
106
|
+
const listed = await profileStore.list();
|
|
107
|
+
const existing = listed.profiles.find((profile) => profile.name === profileName);
|
|
108
|
+
if (!existing)
|
|
109
|
+
assertUniqueProfileName(profileName, listed.profiles.map((profile) => profile.name));
|
|
110
|
+
const values = {
|
|
111
|
+
...(profileDefinition.defaults ?? {}),
|
|
112
|
+
...(existing?.values ?? {}),
|
|
113
|
+
...options.values,
|
|
114
|
+
};
|
|
115
|
+
let candidate = { name: profileName, values };
|
|
116
|
+
const context = invocation.contextFor(candidate);
|
|
117
|
+
let missing = missingRequiredFields(candidate);
|
|
118
|
+
if (missing.length > 0 && options.interactive) {
|
|
119
|
+
for (const field of missing) {
|
|
120
|
+
const value = await promptText(context.io.input, context.io.error, field.description, context.signal);
|
|
121
|
+
if (hasProfileValue(value)) {
|
|
122
|
+
values[field.name] = value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
candidate = { name: profileName, values };
|
|
126
|
+
missing = missingRequiredFields(candidate);
|
|
127
|
+
}
|
|
128
|
+
if (missing.length > 0) {
|
|
129
|
+
throw configurationError(candidate, {
|
|
130
|
+
missingFields: missing,
|
|
131
|
+
authenticationMissing: false,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
await profileDefinition.validate?.(values);
|
|
135
|
+
const saveProfile = () => existing
|
|
136
|
+
? profileStore.set(profileName, values)
|
|
137
|
+
: profileStore.create(profileName, values);
|
|
138
|
+
if (!definition.auth || !authenticationRequired(candidate)) {
|
|
139
|
+
const profile = await saveProfile();
|
|
140
|
+
await invalidateProfile(profile);
|
|
141
|
+
return {
|
|
142
|
+
configured: true,
|
|
143
|
+
profile: profile.name,
|
|
144
|
+
authenticated: true,
|
|
145
|
+
identity: null,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
await invalidateProfile(candidate);
|
|
149
|
+
const loginContext = authContext(candidate, options.interactive);
|
|
150
|
+
const deferred = deferSecrets(loginContext.secrets);
|
|
151
|
+
const status = await definition.auth.login({ ...loginContext, secrets: deferred.secrets }, options.authOptions);
|
|
152
|
+
if (!status.authenticated)
|
|
153
|
+
throw configurationError(candidate, {
|
|
154
|
+
missingFields: [],
|
|
155
|
+
authenticationMissing: true,
|
|
156
|
+
});
|
|
157
|
+
loginContext.signal.throwIfAborted();
|
|
158
|
+
try {
|
|
159
|
+
await deferred.commit(saveProfile);
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
const flags = (definition.auth.loginOptions ?? [])
|
|
163
|
+
.map(configureSyntax)
|
|
164
|
+
.join(" ");
|
|
165
|
+
throw new Error("Could not save profile configuration or authentication. Check the OS credential store. Authentication may be incomplete. " +
|
|
166
|
+
`Run '${definition.name} profile configure ${profileName}${flags ? ` ${flags}` : ""}' again.`);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
configured: true,
|
|
170
|
+
profile: profileName,
|
|
171
|
+
authenticated: true,
|
|
172
|
+
identity: status.identity ?? null,
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
const fields = profileDefinition.fields ?? [];
|
|
176
|
+
// Profile prerequisites may already be stored or prompted; they are not mandatory CLI options.
|
|
177
|
+
const fieldOptions = fields.map(({ flags, description }) => ({
|
|
178
|
+
flags,
|
|
179
|
+
description,
|
|
180
|
+
}));
|
|
181
|
+
const profileValues = (options) => Object.fromEntries(fields
|
|
182
|
+
.map((field) => [field.name, options[optionKey(field.flags)]])
|
|
183
|
+
.filter((entry) => entry[1] !== undefined));
|
|
184
|
+
const profileCommands = command("profile", "Manage service profiles", [
|
|
185
|
+
command("list", "List profiles", async () => {
|
|
186
|
+
const list = await profileStore.list();
|
|
187
|
+
return list.profiles.map((profile) => ({
|
|
188
|
+
default: profile.name === list.active,
|
|
189
|
+
name: profile.name,
|
|
190
|
+
...profile.values,
|
|
191
|
+
}));
|
|
192
|
+
}),
|
|
193
|
+
command("show [name]", "Show one profile", ({ args }, context) => args.name === undefined
|
|
194
|
+
? context.profile
|
|
195
|
+
: profileStore.get(String(args.name))),
|
|
196
|
+
command("configure [name]", "Complete profile settings and authentication", ({ args, options }, context) => configureProfile(args.name === undefined ? context.profile.name : String(args.name), {
|
|
197
|
+
values: profileValues(options),
|
|
198
|
+
authOptions: options,
|
|
199
|
+
interactive: invocation.interactive(),
|
|
200
|
+
}), { options: [...fieldOptions, ...(definition.auth?.loginOptions ?? [])] }),
|
|
201
|
+
command("create <name>", "Create a profile without changing the default", ({ args, options }) => profileStore.create(String(args.name), profileValues(options)), { options: fieldOptions }),
|
|
202
|
+
command("set <name>", "Update an existing profile", async ({ args, options }) => {
|
|
203
|
+
const profile = await profileStore.set(String(args.name), profileValues(options));
|
|
204
|
+
await invalidateProfile(profile);
|
|
205
|
+
return profile;
|
|
206
|
+
}, { options: fieldOptions }),
|
|
207
|
+
command("set-default <name>", "Choose the default profile", ({ args }) => profileStore.setDefault(String(args.name))),
|
|
208
|
+
command("delete <name>", "Delete a non-default profile and its stored credential", async ({ args }) => {
|
|
209
|
+
const name = String(args.name);
|
|
210
|
+
const list = await profileStore.list();
|
|
211
|
+
if (!list.profiles.some((profile) => profile.name === name))
|
|
212
|
+
throw new Error(`Profile '${name}' does not exist.`);
|
|
213
|
+
if (list.profiles.length === 1)
|
|
214
|
+
throw new Error("Cannot delete the only profile. At least one default profile must exist.");
|
|
215
|
+
if (list.active === name)
|
|
216
|
+
throw new Error(`Cannot delete default profile '${name}'. Set another default with 'profile set-default <name>' first.`);
|
|
217
|
+
const profile = await profileStore.get(name);
|
|
218
|
+
const context = authContext(profile);
|
|
219
|
+
await definition.auth?.logout(context);
|
|
220
|
+
await invalidateProfile(profile);
|
|
221
|
+
const deleted = await profileStore.delete(name);
|
|
222
|
+
await rm(context.appArguments.AppDataDirectory, {
|
|
223
|
+
recursive: true,
|
|
224
|
+
force: true,
|
|
225
|
+
});
|
|
226
|
+
return deleted;
|
|
227
|
+
}),
|
|
228
|
+
]);
|
|
229
|
+
const commands = [profileCommands];
|
|
230
|
+
const auth = definition.auth;
|
|
231
|
+
if (auth)
|
|
232
|
+
commands.push(command("auth", "Manage application authentication", [
|
|
233
|
+
command("login", "Authenticate the selected profile", async ({ options }, context) => {
|
|
234
|
+
const missingFields = missingRequiredFields(context.profile);
|
|
235
|
+
if (missingFields.length)
|
|
236
|
+
throw configurationError(context.profile, {
|
|
237
|
+
missingFields,
|
|
238
|
+
authenticationMissing: false,
|
|
239
|
+
});
|
|
240
|
+
if (!authenticationRequired(context.profile))
|
|
241
|
+
throw new Error("This profile does not require authentication.");
|
|
242
|
+
const status = await auth.login(authContext(context.profile, invocation.interactive()), options);
|
|
243
|
+
return {
|
|
244
|
+
...status,
|
|
245
|
+
profile: context.profile.name,
|
|
246
|
+
identity: status.identity ?? null,
|
|
247
|
+
};
|
|
248
|
+
}, { options: auth.loginOptions ?? [] }),
|
|
249
|
+
command("status", "Show authentication status", async (_input, context) => {
|
|
250
|
+
const status = authenticationRequired(context.profile)
|
|
251
|
+
? await auth.status(authContext(context.profile))
|
|
252
|
+
: { authenticated: true, identity: null };
|
|
253
|
+
return { ...status, profile: context.profile.name };
|
|
254
|
+
}),
|
|
255
|
+
command("logout", "Invalidate authentication for the selected profile", async (_input, context) => {
|
|
256
|
+
await auth.logout(authContext(context.profile));
|
|
257
|
+
return {
|
|
258
|
+
authenticated: !authenticationRequired(context.profile),
|
|
259
|
+
profile: context.profile.name,
|
|
260
|
+
};
|
|
261
|
+
}),
|
|
262
|
+
]));
|
|
263
|
+
return { commands, configureProfile, configurationState, configurationError };
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=profile-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-commands.js","sourceRoot":"","sources":["../../src/profile-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AA4BhF,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,KAAK,KAAK,SAAS;QACnB,KAAK,KAAK,IAAI;QACd,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CACnD,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAwB;IAC/C,OAAO,CACL,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,8CAA8C,CAAC,EAAE,CAAC,CAAC,CAAC;QACtE,KAAK,CAAC,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AAsB,CAAC,OAAO,CAAC,OAAO,CAAC;oBACpD,CAAC,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;oBACjD,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBAC5C,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YACtD,CAAC,CACF;YACD,OAAO,CACL,QAAQ,EACR,oDAAoD,EACpD,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;gBACxB,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;gBAChD,OAAO;oBACL,aAAa,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,OAAO,CAAC;oBACvD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;iBAC9B,CAAC;YACJ,CAAC,CACF;SACF,CAAC,CACH,CAAC;IACJ,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare class ProfileFileError extends Error {
|
|
2
|
+
readonly published: boolean;
|
|
3
|
+
readonly cleanupFailed: boolean;
|
|
4
|
+
constructor(message: string, published?: boolean, cleanupFailed?: boolean);
|
|
5
|
+
}
|
|
6
|
+
export interface PublishedProfileFile {
|
|
7
|
+
path: string;
|
|
8
|
+
bytes: number;
|
|
9
|
+
sha256: string;
|
|
10
|
+
}
|
|
11
|
+
export interface StagedProfileFile {
|
|
12
|
+
path: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
prefix: Uint8Array;
|
|
15
|
+
}
|
|
16
|
+
export interface ProfileFileOptions {
|
|
17
|
+
appDataDirectory: string;
|
|
18
|
+
name: string;
|
|
19
|
+
maxBytes: number;
|
|
20
|
+
signal?: AbortSignal | undefined;
|
|
21
|
+
openResponse: () => Promise<Response>;
|
|
22
|
+
inspectResponse: (response: Response) => void | Promise<void>;
|
|
23
|
+
validateFile?: ((file: StagedProfileFile) => void | Promise<void>) | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare function publishProfileFile(options: ProfileFileOptions): Promise<PublishedProfileFile>;
|
|
26
|
+
//# sourceMappingURL=profile-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-file.d.ts","sourceRoot":"","sources":["../../src/profile-file.ts"],"names":[],"mappings":"AAiBA,qBAAa,gBAAiB,SAAQ,KAAK;aAGvB,SAAS;aACT,aAAa;IAH/B,YACE,OAAO,EAAE,MAAM,EACC,SAAS,UAAQ,EACjB,aAAa,UAAQ,EAGtC;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,eAAe,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,YAAY,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAChF;AA0FD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA2N/B"}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { link, lstat, mkdir, mkdtemp, open, realpath, rmdir, unlink, } from "node:fs/promises";
|
|
3
|
+
import { isAbsolute, join, parse, relative, resolve, sep } from "node:path";
|
|
4
|
+
import { privateDirectory } from "./private-storage.js";
|
|
5
|
+
import { consumeResponseBody } from "./response-body.js";
|
|
6
|
+
export class ProfileFileError extends Error {
|
|
7
|
+
published;
|
|
8
|
+
cleanupFailed;
|
|
9
|
+
constructor(message, published = false, cleanupFailed = false) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.published = published;
|
|
12
|
+
this.cleanupFailed = cleanupFailed;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function fileIdentityFromStat(path, stat) {
|
|
16
|
+
if (!stat.isFile())
|
|
17
|
+
throw new Error();
|
|
18
|
+
return {
|
|
19
|
+
path,
|
|
20
|
+
dev: stat.dev,
|
|
21
|
+
ino: stat.ino,
|
|
22
|
+
size: stat.size,
|
|
23
|
+
mtimeNs: stat.mtimeNs,
|
|
24
|
+
ctimeNs: stat.ctimeNs,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function inside(parent, child) {
|
|
28
|
+
const part = relative(parent, child);
|
|
29
|
+
if (part === ".." || part.startsWith(".." + sep) || isAbsolute(part))
|
|
30
|
+
throw new Error();
|
|
31
|
+
}
|
|
32
|
+
async function directoryIdentity(path) {
|
|
33
|
+
const stat = await lstat(path, { bigint: true });
|
|
34
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
35
|
+
throw new Error();
|
|
36
|
+
return { path, dev: stat.dev, ino: stat.ino };
|
|
37
|
+
}
|
|
38
|
+
async function fileIdentity(path) {
|
|
39
|
+
const stat = await lstat(path, { bigint: true });
|
|
40
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
41
|
+
throw new Error();
|
|
42
|
+
return fileIdentityFromStat(path, stat);
|
|
43
|
+
}
|
|
44
|
+
async function prepareDirectories(path) {
|
|
45
|
+
const absolute = resolve(path);
|
|
46
|
+
let current = parse(absolute).root;
|
|
47
|
+
const result = [await directoryIdentity(current)];
|
|
48
|
+
for (const segment of relative(current, absolute).split(sep).filter(Boolean)) {
|
|
49
|
+
current = join(current, segment);
|
|
50
|
+
try {
|
|
51
|
+
await mkdir(current, { mode: 0o700 });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error.code !== "EEXIST")
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
result.push(await directoryIdentity(current));
|
|
58
|
+
}
|
|
59
|
+
const actual = resolve(await realpath(absolute));
|
|
60
|
+
const equal = process.platform === "win32"
|
|
61
|
+
? actual.toLowerCase() === absolute.toLowerCase()
|
|
62
|
+
: actual === absolute;
|
|
63
|
+
if (!equal)
|
|
64
|
+
throw new Error();
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
async function verifyIdentity(expected, kind) {
|
|
68
|
+
const actual = kind === "directory"
|
|
69
|
+
? await directoryIdentity(expected.path)
|
|
70
|
+
: await fileIdentity(expected.path);
|
|
71
|
+
if (actual.dev !== expected.dev || actual.ino !== expected.ino)
|
|
72
|
+
throw new Error();
|
|
73
|
+
}
|
|
74
|
+
async function verifyDirectories(directories) {
|
|
75
|
+
for (const directory of directories)
|
|
76
|
+
await verifyIdentity(directory, "directory");
|
|
77
|
+
}
|
|
78
|
+
async function verifyFileSnapshot(expected) {
|
|
79
|
+
const actual = await fileIdentity(expected.path);
|
|
80
|
+
if (actual.dev !== expected.dev || actual.ino !== expected.ino ||
|
|
81
|
+
actual.size !== expected.size || actual.mtimeNs !== expected.mtimeNs ||
|
|
82
|
+
actual.ctimeNs !== expected.ctimeNs) {
|
|
83
|
+
throw new Error();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function safeBasename(value) {
|
|
87
|
+
return !!value && Buffer.byteLength(value, "utf8") <= 255 && value !== "." && value !== ".." &&
|
|
88
|
+
!/[<>:"/\\|?*\u0000-\u001f\u007f-\u009f\p{Cf}]/u.test(value) && !/[. ]$/.test(value) &&
|
|
89
|
+
!/^(?:con|prn|aux|nul|conin\$|conout\$|clock\$|com[1-9¹²³]|lpt[1-9¹²³])(?:[ .]|$)/i.test(value);
|
|
90
|
+
}
|
|
91
|
+
export async function publishProfileFile(options) {
|
|
92
|
+
const { appDataDirectory, name, maxBytes, signal } = options;
|
|
93
|
+
if (!isAbsolute(appDataDirectory)) {
|
|
94
|
+
throw new ProfileFileError("Downloads require an absolute profile AppData directory.");
|
|
95
|
+
}
|
|
96
|
+
if (!safeBasename(name)) {
|
|
97
|
+
throw new ProfileFileError("Download name must be one safe basename without reserved characters.");
|
|
98
|
+
}
|
|
99
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1) {
|
|
100
|
+
throw new ProfileFileError("Download byte limit must be a positive safe integer.");
|
|
101
|
+
}
|
|
102
|
+
const profileDirectory = resolve(appDataDirectory);
|
|
103
|
+
const downloadDirectory = join(profileDirectory, "downloads");
|
|
104
|
+
const tempDirectory = join(profileDirectory, "temp");
|
|
105
|
+
const destination = join(downloadDirectory, name);
|
|
106
|
+
inside(profileDirectory, downloadDirectory);
|
|
107
|
+
inside(profileDirectory, tempDirectory);
|
|
108
|
+
inside(downloadDirectory, destination);
|
|
109
|
+
let destinationDirectories = [];
|
|
110
|
+
let stagingDirectories = [];
|
|
111
|
+
let stagingDirectory;
|
|
112
|
+
let stagingDirectoryIdentity;
|
|
113
|
+
let stagingPath;
|
|
114
|
+
let stagingIdentity;
|
|
115
|
+
let file;
|
|
116
|
+
let response;
|
|
117
|
+
let published = false;
|
|
118
|
+
let cleanupFailed = false;
|
|
119
|
+
let failureMessage = "Download failed, exceeded its byte limit, was cancelled, or had an incomplete transfer; " +
|
|
120
|
+
"no destination was published.";
|
|
121
|
+
let result;
|
|
122
|
+
const hash = createHash("sha256");
|
|
123
|
+
const prefix = new Uint8Array(8);
|
|
124
|
+
let prefixBytes = 0;
|
|
125
|
+
try {
|
|
126
|
+
if (signal?.aborted)
|
|
127
|
+
throw new Error();
|
|
128
|
+
failureMessage =
|
|
129
|
+
"Download directories could not be verified; symlinks, junctions and replacement are " +
|
|
130
|
+
"unsupported; no destination was published.";
|
|
131
|
+
destinationDirectories = await prepareDirectories(downloadDirectory);
|
|
132
|
+
stagingDirectories = await prepareDirectories(tempDirectory);
|
|
133
|
+
try {
|
|
134
|
+
const existing = await lstat(destination);
|
|
135
|
+
void existing;
|
|
136
|
+
failureMessage =
|
|
137
|
+
"Download destination already exists; no overwrite; no destination was published.";
|
|
138
|
+
throw new Error();
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
if (error.code !== "ENOENT")
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
await verifyDirectories([...destinationDirectories, ...stagingDirectories]);
|
|
145
|
+
stagingDirectory = await mkdtemp(join(tempDirectory, ".download-"));
|
|
146
|
+
stagingDirectoryIdentity = await directoryIdentity(stagingDirectory);
|
|
147
|
+
await privateDirectory(stagingDirectory);
|
|
148
|
+
await verifyIdentity(stagingDirectoryIdentity, "directory");
|
|
149
|
+
stagingPath = join(stagingDirectory, "content");
|
|
150
|
+
file = await open(stagingPath, "wx", 0o600);
|
|
151
|
+
const opened = await file.stat({ bigint: true });
|
|
152
|
+
if (!opened.isFile())
|
|
153
|
+
throw new Error();
|
|
154
|
+
stagingIdentity = fileIdentityFromStat(stagingPath, opened);
|
|
155
|
+
failureMessage =
|
|
156
|
+
"Download failed, exceeded its byte limit, was cancelled, or had an incomplete transfer; " +
|
|
157
|
+
"no destination was published.";
|
|
158
|
+
if (signal?.aborted)
|
|
159
|
+
throw new Error();
|
|
160
|
+
response = await options.openResponse();
|
|
161
|
+
if (signal?.aborted)
|
|
162
|
+
throw new Error();
|
|
163
|
+
try {
|
|
164
|
+
await options.inspectResponse(response);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
if (error instanceof ProfileFileError)
|
|
168
|
+
failureMessage = error.message;
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
const bytes = await consumeResponseBody(response, { maxBytes, signal }, async (chunk) => {
|
|
172
|
+
const owned = Uint8Array.from(chunk);
|
|
173
|
+
if (prefixBytes < prefix.length) {
|
|
174
|
+
const count = Math.min(prefix.length - prefixBytes, owned.byteLength);
|
|
175
|
+
prefix.set(owned.subarray(0, count), prefixBytes);
|
|
176
|
+
prefixBytes += count;
|
|
177
|
+
}
|
|
178
|
+
hash.update(owned);
|
|
179
|
+
let offset = 0;
|
|
180
|
+
while (offset < owned.byteLength) {
|
|
181
|
+
const written = await file.write(owned, offset, owned.byteLength - offset);
|
|
182
|
+
if (!written.bytesWritten)
|
|
183
|
+
throw new Error();
|
|
184
|
+
offset += written.bytesWritten;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
if (signal?.aborted)
|
|
188
|
+
throw new Error();
|
|
189
|
+
await file.sync();
|
|
190
|
+
failureMessage =
|
|
191
|
+
"Download directories or private staging changed during the transfer; " +
|
|
192
|
+
"no destination was published.";
|
|
193
|
+
await verifyDirectories([...destinationDirectories, ...stagingDirectories]);
|
|
194
|
+
await verifyIdentity(stagingDirectoryIdentity, "directory");
|
|
195
|
+
const completedIdentity = await fileIdentity(stagingIdentity.path);
|
|
196
|
+
if (completedIdentity.dev !== stagingIdentity.dev ||
|
|
197
|
+
completedIdentity.ino !== stagingIdentity.ino || completedIdentity.size !== BigInt(bytes)) {
|
|
198
|
+
throw new Error();
|
|
199
|
+
}
|
|
200
|
+
stagingIdentity = completedIdentity;
|
|
201
|
+
failureMessage =
|
|
202
|
+
"Download failed file validation; no destination was published.";
|
|
203
|
+
if (options.validateFile) {
|
|
204
|
+
try {
|
|
205
|
+
await options.validateFile({
|
|
206
|
+
path: stagingPath,
|
|
207
|
+
bytes,
|
|
208
|
+
prefix: prefix.subarray(0, prefixBytes),
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
if (error instanceof ProfileFileError)
|
|
213
|
+
failureMessage = error.message;
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (signal?.aborted) {
|
|
218
|
+
failureMessage = "Download was cancelled; no destination was published.";
|
|
219
|
+
throw new Error();
|
|
220
|
+
}
|
|
221
|
+
failureMessage =
|
|
222
|
+
"Download directories or private staging changed during validation; " +
|
|
223
|
+
"no destination was published.";
|
|
224
|
+
await verifyDirectories([...destinationDirectories, ...stagingDirectories]);
|
|
225
|
+
await verifyIdentity(stagingDirectoryIdentity, "directory");
|
|
226
|
+
await verifyFileSnapshot(stagingIdentity);
|
|
227
|
+
if (signal?.aborted) {
|
|
228
|
+
failureMessage = "Download was cancelled; no destination was published.";
|
|
229
|
+
throw new Error();
|
|
230
|
+
}
|
|
231
|
+
const sha256 = hash.digest("hex");
|
|
232
|
+
try {
|
|
233
|
+
await link(stagingPath, destination);
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
if (error.code === "EEXIST") {
|
|
237
|
+
failureMessage =
|
|
238
|
+
"Download destination already exists; no overwrite; no destination was published.";
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
failureMessage =
|
|
242
|
+
"Download could not be published exclusively; the profile filesystem must support hard links.";
|
|
243
|
+
}
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
published = true;
|
|
247
|
+
failureMessage =
|
|
248
|
+
"Download was published, but its destination identity could not be verified; " +
|
|
249
|
+
"inspect the profile downloads directory.";
|
|
250
|
+
await verifyDirectories([...destinationDirectories, ...stagingDirectories]);
|
|
251
|
+
await verifyIdentity(stagingDirectoryIdentity, "directory");
|
|
252
|
+
await verifyIdentity(stagingIdentity, "file");
|
|
253
|
+
const publishedIdentity = await fileIdentity(destination);
|
|
254
|
+
if (publishedIdentity.dev !== stagingIdentity.dev || publishedIdentity.ino !== stagingIdentity.ino) {
|
|
255
|
+
throw new Error();
|
|
256
|
+
}
|
|
257
|
+
result = { path: destination, bytes, sha256 };
|
|
258
|
+
}
|
|
259
|
+
catch {
|
|
260
|
+
// The selected static message is the only information exposed from this operation.
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
void response?.body?.cancel().catch(() => undefined);
|
|
264
|
+
let cleanupAllowed = true;
|
|
265
|
+
let cleanupIdentity;
|
|
266
|
+
if (file) {
|
|
267
|
+
try {
|
|
268
|
+
if (!stagingPath)
|
|
269
|
+
throw new Error();
|
|
270
|
+
cleanupIdentity = fileIdentityFromStat(stagingPath, await file.stat({ bigint: true }));
|
|
271
|
+
await verifyFileSnapshot(cleanupIdentity);
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
cleanupFailed = true;
|
|
275
|
+
cleanupAllowed = false;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
await file?.close();
|
|
280
|
+
file = undefined;
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
cleanupFailed = true;
|
|
284
|
+
cleanupAllowed = false;
|
|
285
|
+
}
|
|
286
|
+
if (stagingDirectory && cleanupAllowed) {
|
|
287
|
+
try {
|
|
288
|
+
if (!stagingDirectoryIdentity)
|
|
289
|
+
throw new Error();
|
|
290
|
+
await verifyDirectories(stagingDirectories);
|
|
291
|
+
await verifyIdentity(stagingDirectoryIdentity, "directory");
|
|
292
|
+
if (stagingPath && stagingIdentity) {
|
|
293
|
+
try {
|
|
294
|
+
if (!cleanupIdentity)
|
|
295
|
+
throw new Error();
|
|
296
|
+
await verifyFileSnapshot(cleanupIdentity);
|
|
297
|
+
await unlink(stagingPath);
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
if (error.code !== "ENOENT")
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else if (stagingPath) {
|
|
305
|
+
throw new Error();
|
|
306
|
+
}
|
|
307
|
+
await verifyDirectories(stagingDirectories);
|
|
308
|
+
await verifyIdentity(stagingDirectoryIdentity, "directory");
|
|
309
|
+
await rmdir(stagingDirectory);
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
cleanupFailed = true;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (cleanupFailed) {
|
|
317
|
+
throw new ProfileFileError(published
|
|
318
|
+
? "Download was published, but private staging cleanup failed; inspect the profile temp directory."
|
|
319
|
+
: "Download was not published, and private staging cleanup failed; inspect the profile temp directory.", published, true);
|
|
320
|
+
}
|
|
321
|
+
if (!result)
|
|
322
|
+
throw new ProfileFileError(failureMessage, published, false);
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
//# sourceMappingURL=profile-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-file.js","sourceRoot":"","sources":["../../src/profile-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,IAAI,EACJ,KAAK,EACL,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,MAAM,GAEP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAGvB,SAAS;IACT,aAAa;IAH/B,YACE,OAAe,EACC,SAAS,GAAG,KAAK,EACjB,aAAa,GAAG,KAAK;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;yBAHC,SAAS;6BACT,aAAa;IAG/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