@amerged/ohmyhost-cli 0.1.75 → 0.1.76
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/README.md +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-2APPOPVY.js → chunk-N6LDQC3B.js} +1184 -493
- package/dist/index.js +26 -140
- package/package.json +1 -1
- package/src/apps/product-cli/package.json +1 -1
- package/src/apps/product-cli/src/cli.ts +180 -60
- package/src/apps/product-cli/src/composition.ts +132 -48
- package/src/apps/product-cli/src/credential-refresh.ts +65 -0
- package/src/apps/product-cli/src/file-credential-store.ts +131 -57
- package/src/apps/product-cli/src/index.ts +2 -0
- package/src/apps/product-cli/src/login-ownership.ts +291 -0
- package/src/apps/product-cli/src/profile-store.ts +303 -39
- package/src/apps/product-cli/src/runtime-contract.ts +12 -1
- package/src/apps/product-cli/src/workspace.ts +41 -27
- package/src/packages/contracts/src/problem-policy.ts +6 -6
- package/src/packages/sdk-ts/package.json +1 -1
- package/src/packages/sdk-ts/src/generated/mcp-remote.gen.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,9 @@ import { createRequire as __ohmyhostCreateRequire } from "node:module"; const re
|
|
|
2
2
|
import {
|
|
3
3
|
ACCOUNT_SENSITIVE_PROBLEMS,
|
|
4
4
|
AccountVerificationError,
|
|
5
|
-
|
|
5
|
+
DIRECT_OWNERSHIP,
|
|
6
|
+
FileCredentialStoreRefusedError,
|
|
7
|
+
FileProfileRegistry,
|
|
6
8
|
GeneratedSdkManagedSourceApi,
|
|
7
9
|
GeneratedSdkProductApi,
|
|
8
10
|
GeneratedSdkSessionRevoker,
|
|
@@ -11,8 +13,12 @@ import {
|
|
|
11
13
|
LifecycleTransportError,
|
|
12
14
|
LinkedProjectAmbiguousError,
|
|
13
15
|
LocalSourcePublicationError,
|
|
16
|
+
LoginGoneError,
|
|
17
|
+
LoginOwnership,
|
|
18
|
+
LoginOwnershipTimeoutError,
|
|
14
19
|
NativeKeyringProfileRegistry,
|
|
15
20
|
NetworkTransportError,
|
|
21
|
+
OwnerOnlyFileCredentialStore,
|
|
16
22
|
OwnerOnlyProjectLinkStore,
|
|
17
23
|
PrivateSecretFileError,
|
|
18
24
|
ProductApiAuthenticationError,
|
|
@@ -45,8 +51,11 @@ import {
|
|
|
45
51
|
createAuthenticatedProductTransport,
|
|
46
52
|
createBoundedFetch,
|
|
47
53
|
createProductionAuthenticatedProductApi,
|
|
54
|
+
createProfileRegistry,
|
|
48
55
|
createSourceSnapshot,
|
|
56
|
+
credentialStoreUnavailableAction,
|
|
49
57
|
defaultProfileName,
|
|
58
|
+
describeFileStoreRefusal,
|
|
50
59
|
describeProfile,
|
|
51
60
|
endedLoginAction,
|
|
52
61
|
executeConnectionCommand,
|
|
@@ -62,6 +71,7 @@ import {
|
|
|
62
71
|
isProfileUserId,
|
|
63
72
|
isSourcePublicationIdempotencyKey,
|
|
64
73
|
linkedOrganization,
|
|
74
|
+
linuxProcessProbe,
|
|
65
75
|
listSavedProfiles,
|
|
66
76
|
loadProfiles,
|
|
67
77
|
parseAccountProfile,
|
|
@@ -92,6 +102,7 @@ import {
|
|
|
92
102
|
publicProfile,
|
|
93
103
|
publicWorkspace,
|
|
94
104
|
publishSourceSnapshot,
|
|
105
|
+
quietly,
|
|
95
106
|
readBoundedResponseBody,
|
|
96
107
|
readPrivateWebhookCreateRequest,
|
|
97
108
|
readProjectLinks,
|
|
@@ -99,6 +110,7 @@ import {
|
|
|
99
110
|
recognizedCommandLabel,
|
|
100
111
|
refreshFailedAction,
|
|
101
112
|
removeLegacyProjectLink,
|
|
113
|
+
renewLogin,
|
|
102
114
|
resolveProductCliEnvironment,
|
|
103
115
|
runProductionCli,
|
|
104
116
|
sameLogin,
|
|
@@ -107,7 +119,7 @@ import {
|
|
|
107
119
|
selectWorkspace,
|
|
108
120
|
verifiedUserId,
|
|
109
121
|
workspaceOf
|
|
110
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-N6LDQC3B.js";
|
|
111
123
|
import {
|
|
112
124
|
CredentialStoreIntegrityError,
|
|
113
125
|
CredentialStoreUnavailableError,
|
|
@@ -117,149 +129,14 @@ import {
|
|
|
117
129
|
parseCredential,
|
|
118
130
|
serializeCredential
|
|
119
131
|
} from "./chunk-7D2RFLWM.js";
|
|
120
|
-
|
|
121
|
-
// apps/product-cli/dist/file-credential-store.js
|
|
122
|
-
import { constants, lstat, mkdir, open, rename, unlink } from "node:fs/promises";
|
|
123
|
-
import { dirname, join } from "node:path";
|
|
124
|
-
var DIRECTORY_MODE = 448;
|
|
125
|
-
var FILE_MODE = 384;
|
|
126
|
-
var OwnerOnlyFileCredentialStore = class {
|
|
127
|
-
directory;
|
|
128
|
-
ownerId;
|
|
129
|
-
#credentialPath;
|
|
130
|
-
#temporaryPath;
|
|
131
|
-
constructor(directory, ownerId) {
|
|
132
|
-
this.directory = directory;
|
|
133
|
-
this.ownerId = ownerId;
|
|
134
|
-
this.#credentialPath = join(directory, "credentials.json");
|
|
135
|
-
this.#temporaryPath = join(directory, ".credentials.next");
|
|
136
|
-
}
|
|
137
|
-
async read() {
|
|
138
|
-
try {
|
|
139
|
-
await this.ensureDirectory();
|
|
140
|
-
await this.recoverTemporary();
|
|
141
|
-
if (!await this.validateFile())
|
|
142
|
-
return void 0;
|
|
143
|
-
const handle = await open(this.#credentialPath, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
144
|
-
try {
|
|
145
|
-
const status = await handle.stat();
|
|
146
|
-
this.assertOwnedStatus(status, FILE_MODE, false);
|
|
147
|
-
return parseCredential(await handle.readFile("utf8"));
|
|
148
|
-
} finally {
|
|
149
|
-
await handle.close();
|
|
150
|
-
}
|
|
151
|
-
} catch {
|
|
152
|
-
throw new CredentialStoreUnavailableError();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async replace(credential) {
|
|
156
|
-
try {
|
|
157
|
-
await this.ensureDirectory();
|
|
158
|
-
await this.recoverTemporary();
|
|
159
|
-
await this.validateFile();
|
|
160
|
-
const handle = await open(this.#temporaryPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, FILE_MODE);
|
|
161
|
-
try {
|
|
162
|
-
await handle.writeFile(serializeCredential(credential), "utf8");
|
|
163
|
-
await handle.sync();
|
|
164
|
-
} finally {
|
|
165
|
-
await handle.close();
|
|
166
|
-
}
|
|
167
|
-
await this.validateOwnedPath(this.#temporaryPath, FILE_MODE, false);
|
|
168
|
-
await rename(this.#temporaryPath, this.#credentialPath);
|
|
169
|
-
await this.syncDirectory();
|
|
170
|
-
await this.validateOwnedPath(this.#credentialPath, FILE_MODE, false);
|
|
171
|
-
} catch {
|
|
172
|
-
await unlink(this.#temporaryPath).catch(() => void 0);
|
|
173
|
-
throw new CredentialStoreUnavailableError();
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async clear() {
|
|
177
|
-
try {
|
|
178
|
-
await this.ensureDirectory();
|
|
179
|
-
let failed = false;
|
|
180
|
-
for (const path of [this.#credentialPath, this.#temporaryPath]) {
|
|
181
|
-
try {
|
|
182
|
-
await unlink(path);
|
|
183
|
-
} catch (error) {
|
|
184
|
-
if (!isMissing(error))
|
|
185
|
-
failed = true;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
try {
|
|
189
|
-
await this.syncDirectory();
|
|
190
|
-
} catch {
|
|
191
|
-
failed = true;
|
|
192
|
-
}
|
|
193
|
-
for (const path of [this.#credentialPath, this.#temporaryPath]) {
|
|
194
|
-
try {
|
|
195
|
-
await lstat(path);
|
|
196
|
-
failed = true;
|
|
197
|
-
} catch (error) {
|
|
198
|
-
if (!isMissing(error))
|
|
199
|
-
failed = true;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (failed)
|
|
203
|
-
throw new Error("Credential artifact cleanup failed");
|
|
204
|
-
} catch {
|
|
205
|
-
throw new CredentialStoreUnavailableError();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
async ensureDirectory() {
|
|
209
|
-
await mkdir(this.directory, { mode: DIRECTORY_MODE, recursive: true });
|
|
210
|
-
await this.validateOwnedPath(this.directory, DIRECTORY_MODE, true);
|
|
211
|
-
}
|
|
212
|
-
async recoverTemporary() {
|
|
213
|
-
try {
|
|
214
|
-
const status = await lstat(this.#temporaryPath);
|
|
215
|
-
const invalid = status.isSymbolicLink() || !status.isFile() || status.uid !== this.ownerId || (status.mode & 511) !== FILE_MODE;
|
|
216
|
-
await unlink(this.#temporaryPath);
|
|
217
|
-
await this.syncDirectory();
|
|
218
|
-
if (invalid)
|
|
219
|
-
throw new Error("Temporary credential artifact was invalid");
|
|
220
|
-
} catch (error) {
|
|
221
|
-
if (!isMissing(error))
|
|
222
|
-
throw error;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
async validateFile() {
|
|
226
|
-
try {
|
|
227
|
-
await this.validateOwnedPath(this.#credentialPath, FILE_MODE, false);
|
|
228
|
-
return true;
|
|
229
|
-
} catch (error) {
|
|
230
|
-
if (isMissing(error))
|
|
231
|
-
return false;
|
|
232
|
-
throw error;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
async validateOwnedPath(path, mode, directory) {
|
|
236
|
-
const status = await lstat(path);
|
|
237
|
-
if (status.isSymbolicLink()) {
|
|
238
|
-
throw new Error("Credential path ownership or mode is invalid");
|
|
239
|
-
}
|
|
240
|
-
this.assertOwnedStatus(status, mode, directory);
|
|
241
|
-
}
|
|
242
|
-
assertOwnedStatus(status, mode, directory) {
|
|
243
|
-
if ((directory ? !status.isDirectory() : !status.isFile()) || status.uid !== this.ownerId || (Number(status.mode) & 511) !== mode) {
|
|
244
|
-
throw new Error("Credential path ownership or mode is invalid");
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
async syncDirectory() {
|
|
248
|
-
const handle = await open(dirname(this.#credentialPath), constants.O_RDONLY);
|
|
249
|
-
try {
|
|
250
|
-
await handle.sync();
|
|
251
|
-
} finally {
|
|
252
|
-
await handle.close();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
var isMissing = (error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
257
132
|
export {
|
|
258
133
|
ACCOUNT_SENSITIVE_PROBLEMS,
|
|
259
134
|
AccountVerificationError,
|
|
260
|
-
CREDENTIAL_STORE_UNAVAILABLE_ACTION,
|
|
261
135
|
CredentialStoreIntegrityError,
|
|
262
136
|
CredentialStoreUnavailableError,
|
|
137
|
+
DIRECT_OWNERSHIP,
|
|
138
|
+
FileCredentialStoreRefusedError,
|
|
139
|
+
FileProfileRegistry,
|
|
263
140
|
GeneratedSdkManagedSourceApi,
|
|
264
141
|
GeneratedSdkProductApi,
|
|
265
142
|
GeneratedSdkSessionRevoker,
|
|
@@ -269,6 +146,9 @@ export {
|
|
|
269
146
|
LifecycleTransportError,
|
|
270
147
|
LinkedProjectAmbiguousError,
|
|
271
148
|
LocalSourcePublicationError,
|
|
149
|
+
LoginGoneError,
|
|
150
|
+
LoginOwnership,
|
|
151
|
+
LoginOwnershipTimeoutError,
|
|
272
152
|
NativeKeyringProfileRegistry,
|
|
273
153
|
NativeNapiKeyringCredentialStore,
|
|
274
154
|
NetworkTransportError,
|
|
@@ -306,8 +186,11 @@ export {
|
|
|
306
186
|
createBoundedFetch,
|
|
307
187
|
createNativeEntryFactory,
|
|
308
188
|
createProductionAuthenticatedProductApi,
|
|
189
|
+
createProfileRegistry,
|
|
309
190
|
createSourceSnapshot,
|
|
191
|
+
credentialStoreUnavailableAction,
|
|
310
192
|
defaultProfileName,
|
|
193
|
+
describeFileStoreRefusal,
|
|
311
194
|
describeProfile,
|
|
312
195
|
endedLoginAction,
|
|
313
196
|
executeConnectionCommand,
|
|
@@ -323,6 +206,7 @@ export {
|
|
|
323
206
|
isProfileUserId,
|
|
324
207
|
isSourcePublicationIdempotencyKey,
|
|
325
208
|
linkedOrganization,
|
|
209
|
+
linuxProcessProbe,
|
|
326
210
|
listSavedProfiles,
|
|
327
211
|
loadProfiles,
|
|
328
212
|
parseAccountProfile,
|
|
@@ -354,6 +238,7 @@ export {
|
|
|
354
238
|
publicProfile,
|
|
355
239
|
publicWorkspace,
|
|
356
240
|
publishSourceSnapshot,
|
|
241
|
+
quietly,
|
|
357
242
|
readBoundedResponseBody,
|
|
358
243
|
readPrivateWebhookCreateRequest,
|
|
359
244
|
readProjectLinks,
|
|
@@ -361,6 +246,7 @@ export {
|
|
|
361
246
|
recognizedCommandLabel,
|
|
362
247
|
refreshFailedAction,
|
|
363
248
|
removeLegacyProjectLink,
|
|
249
|
+
renewLogin,
|
|
364
250
|
resolveProductCliEnvironment,
|
|
365
251
|
runProductionCli,
|
|
366
252
|
sameLogin,
|
package/package.json
CHANGED