@amerged/ohmyhost-cli 0.1.10

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.
Files changed (68) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +11 -0
  4. package/THIRD_PARTY_NOTICES.md +139 -0
  5. package/dist/bin.js +18 -0
  6. package/dist/chunk-4HFQ54FP.js +138 -0
  7. package/dist/chunk-Z75ASLEB.js +24669 -0
  8. package/dist/credential-store.js +15 -0
  9. package/dist/index.js +249 -0
  10. package/package.json +33 -0
  11. package/src/apps/product-cli/bin.ts +24 -0
  12. package/src/apps/product-cli/cli.ts +2271 -0
  13. package/src/apps/product-cli/command.ts +1811 -0
  14. package/src/apps/product-cli/composition.ts +823 -0
  15. package/src/apps/product-cli/credential-store.ts +149 -0
  16. package/src/apps/product-cli/device-token-expiry.ts +89 -0
  17. package/src/apps/product-cli/file-credential-store.ts +166 -0
  18. package/src/apps/product-cli/index.ts +23 -0
  19. package/src/apps/product-cli/product-api.ts +1082 -0
  20. package/src/apps/product-cli/project-link-store.ts +30 -0
  21. package/src/apps/product-cli/psql-session.ts +29 -0
  22. package/src/apps/product-cli/repository-init.ts +1622 -0
  23. package/src/apps/product-cli/runtime-contract.ts +1747 -0
  24. package/src/apps/product-cli/user-token-file.ts +214 -0
  25. package/src/apps/product-cli/workspace.ts +92 -0
  26. package/src/packages/contracts/application-root.ts +80 -0
  27. package/src/packages/contracts/billing.ts +172 -0
  28. package/src/packages/contracts/credit-pricing.ts +214 -0
  29. package/src/packages/contracts/database-access.ts +257 -0
  30. package/src/packages/contracts/database-compute.ts +72 -0
  31. package/src/packages/contracts/database-migration-admission.ts +235 -0
  32. package/src/packages/contracts/feedback.ts +96 -0
  33. package/src/packages/contracts/framework-admission.ts +280 -0
  34. package/src/packages/contracts/framework-family.ts +18 -0
  35. package/src/packages/contracts/functions.ts +76 -0
  36. package/src/packages/contracts/index.ts +245 -0
  37. package/src/packages/contracts/operation-deployment-result.ts +165 -0
  38. package/src/packages/contracts/operation-failure.ts +150 -0
  39. package/src/packages/contracts/platform-origins.ts +5 -0
  40. package/src/packages/contracts/project-context.ts +59 -0
  41. package/src/packages/contracts/project-exports.ts +102 -0
  42. package/src/packages/contracts/user-api-keys.ts +98 -0
  43. package/src/packages/sdk-ts/generated/client/client.gen.ts +277 -0
  44. package/src/packages/sdk-ts/generated/client/index.ts +27 -0
  45. package/src/packages/sdk-ts/generated/client/types.gen.ts +217 -0
  46. package/src/packages/sdk-ts/generated/client/utils.gen.ts +316 -0
  47. package/src/packages/sdk-ts/generated/client.gen.ts +24 -0
  48. package/src/packages/sdk-ts/generated/core/auth.gen.ts +48 -0
  49. package/src/packages/sdk-ts/generated/core/bodySerializer.gen.ts +82 -0
  50. package/src/packages/sdk-ts/generated/core/params.gen.ts +178 -0
  51. package/src/packages/sdk-ts/generated/core/pathSerializer.gen.ts +171 -0
  52. package/src/packages/sdk-ts/generated/core/queryKeySerializer.gen.ts +117 -0
  53. package/src/packages/sdk-ts/generated/core/serverSentEvents.gen.ts +242 -0
  54. package/src/packages/sdk-ts/generated/core/types.gen.ts +114 -0
  55. package/src/packages/sdk-ts/generated/core/utils.gen.ts +140 -0
  56. package/src/packages/sdk-ts/generated/index.ts +578 -0
  57. package/src/packages/sdk-ts/generated/sdk.gen.ts +3440 -0
  58. package/src/packages/sdk-ts/generated/types.gen.ts +5790 -0
  59. package/src/packages/sdk-ts/index.ts +7 -0
  60. package/src/packages/workos-auth-contracts/device-flow.ts +271 -0
  61. package/src/packages/workos-auth-contracts/index.ts +8 -0
  62. package/src/packages/workos-auth-contracts/management-rpc.ts +379 -0
  63. package/src/packages/workos-auth-contracts/organizations.ts +113 -0
  64. package/src/packages/workos-auth-contracts/parsing.ts +75 -0
  65. package/src/packages/workos-auth-contracts/session-status.ts +53 -0
  66. package/src/packages/workos-auth-contracts/tokens.ts +216 -0
  67. package/src/packages/workos-auth-contracts/user-api-keys.ts +85 -0
  68. package/src/packages/workos-auth-contracts/webhooks.ts +127 -0
@@ -0,0 +1,15 @@
1
+ import { createRequire as __ohmyhostCreateRequire } from "node:module"; const require = __ohmyhostCreateRequire(import.meta.url);
2
+ import {
3
+ CredentialStoreIntegrityError,
4
+ CredentialStoreUnavailableError,
5
+ NativeNapiKeyringCredentialStore,
6
+ parseCredential,
7
+ serializeCredential
8
+ } from "./chunk-4HFQ54FP.js";
9
+ export {
10
+ CredentialStoreIntegrityError,
11
+ CredentialStoreUnavailableError,
12
+ NativeNapiKeyringCredentialStore,
13
+ parseCredential,
14
+ serializeCredential
15
+ };
package/dist/index.js ADDED
@@ -0,0 +1,249 @@
1
+ import { createRequire as __ohmyhostCreateRequire } from "node:module"; const require = __ohmyhostCreateRequire(import.meta.url);
2
+ import {
3
+ GeneratedSdkProductApi,
4
+ GeneratedSdkSessionRevoker,
5
+ InteractiveSessionRequiredError,
6
+ InvalidCommandError,
7
+ LifecycleTransportError,
8
+ NetworkTransportError,
9
+ OwnerOnlyProjectLinkStore,
10
+ ProductApiAuthenticationError,
11
+ ProductCli,
12
+ ProviderCapabilityBlockedError,
13
+ PsqlUnavailableError,
14
+ PublicResponseTooLargeError,
15
+ PublicWorkosTokenRefresher,
16
+ RepositoryInitBlockedError,
17
+ RepositoryInitConflictError,
18
+ RepositoryInitError,
19
+ SecretInputError,
20
+ StderrDeviceAuthorizationPresenter,
21
+ TokenRefreshRejectedError,
22
+ UserTokenFileError,
23
+ chooseWorkspace,
24
+ cliMetadataResult,
25
+ createAuthenticatedProductTransport,
26
+ createBoundedFetch,
27
+ createProductionAuthenticatedProductApi,
28
+ initializeRepository,
29
+ parseAccountProfile,
30
+ parseCloudflareDnsAuthorization,
31
+ parseCloudflareDnsAuthorizationStatus,
32
+ parseCurrentIdentity,
33
+ parseDevAccessTicket,
34
+ parseOperation,
35
+ parseOperationEvent,
36
+ parsePaidDomain,
37
+ parsePaidDomainPlan,
38
+ parseProductCliCommand,
39
+ parseSafeProblem,
40
+ prepareUserTokenFile,
41
+ publicWorkspace,
42
+ readBoundedResponseBody,
43
+ readSecretValueFromStandardInput,
44
+ recognizedCommandLabel,
45
+ resolveProductCliEnvironment,
46
+ runProductionCli,
47
+ selectWorkspace,
48
+ selectedWorkspaceId,
49
+ workspaceOf
50
+ } from "./chunk-Z75ASLEB.js";
51
+ import {
52
+ CredentialStoreIntegrityError,
53
+ CredentialStoreUnavailableError,
54
+ NativeNapiKeyringCredentialStore,
55
+ parseCredential,
56
+ serializeCredential
57
+ } from "./chunk-4HFQ54FP.js";
58
+
59
+ // apps/product-cli/dist/file-credential-store.js
60
+ import { constants, lstat, mkdir, open, rename, unlink } from "node:fs/promises";
61
+ import { dirname, join } from "node:path";
62
+ var DIRECTORY_MODE = 448;
63
+ var FILE_MODE = 384;
64
+ var OwnerOnlyFileCredentialStore = class {
65
+ directory;
66
+ ownerId;
67
+ #credentialPath;
68
+ #temporaryPath;
69
+ constructor(directory, ownerId) {
70
+ this.directory = directory;
71
+ this.ownerId = ownerId;
72
+ this.#credentialPath = join(directory, "credentials.json");
73
+ this.#temporaryPath = join(directory, ".credentials.next");
74
+ }
75
+ async read() {
76
+ try {
77
+ await this.ensureDirectory();
78
+ await this.recoverTemporary();
79
+ if (!await this.validateFile())
80
+ return void 0;
81
+ const handle = await open(this.#credentialPath, constants.O_RDONLY | constants.O_NOFOLLOW);
82
+ try {
83
+ const status = await handle.stat();
84
+ this.assertOwnedStatus(status, FILE_MODE, false);
85
+ return parseCredential(await handle.readFile("utf8"));
86
+ } finally {
87
+ await handle.close();
88
+ }
89
+ } catch {
90
+ throw new CredentialStoreUnavailableError();
91
+ }
92
+ }
93
+ async replace(credential) {
94
+ try {
95
+ await this.ensureDirectory();
96
+ await this.recoverTemporary();
97
+ await this.validateFile();
98
+ const handle = await open(this.#temporaryPath, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW, FILE_MODE);
99
+ try {
100
+ await handle.writeFile(serializeCredential(credential), "utf8");
101
+ await handle.sync();
102
+ } finally {
103
+ await handle.close();
104
+ }
105
+ await this.validateOwnedPath(this.#temporaryPath, FILE_MODE, false);
106
+ await rename(this.#temporaryPath, this.#credentialPath);
107
+ await this.syncDirectory();
108
+ await this.validateOwnedPath(this.#credentialPath, FILE_MODE, false);
109
+ } catch {
110
+ await unlink(this.#temporaryPath).catch(() => void 0);
111
+ throw new CredentialStoreUnavailableError();
112
+ }
113
+ }
114
+ async clear() {
115
+ try {
116
+ await this.ensureDirectory();
117
+ let failed = false;
118
+ for (const path of [this.#credentialPath, this.#temporaryPath]) {
119
+ try {
120
+ await unlink(path);
121
+ } catch (error) {
122
+ if (!isMissing(error))
123
+ failed = true;
124
+ }
125
+ }
126
+ try {
127
+ await this.syncDirectory();
128
+ } catch {
129
+ failed = true;
130
+ }
131
+ for (const path of [this.#credentialPath, this.#temporaryPath]) {
132
+ try {
133
+ await lstat(path);
134
+ failed = true;
135
+ } catch (error) {
136
+ if (!isMissing(error))
137
+ failed = true;
138
+ }
139
+ }
140
+ if (failed)
141
+ throw new Error("Credential artifact cleanup failed");
142
+ } catch {
143
+ throw new CredentialStoreUnavailableError();
144
+ }
145
+ }
146
+ async ensureDirectory() {
147
+ await mkdir(this.directory, { mode: DIRECTORY_MODE, recursive: true });
148
+ await this.validateOwnedPath(this.directory, DIRECTORY_MODE, true);
149
+ }
150
+ async recoverTemporary() {
151
+ try {
152
+ const status = await lstat(this.#temporaryPath);
153
+ const invalid = status.isSymbolicLink() || !status.isFile() || status.uid !== this.ownerId || (status.mode & 511) !== FILE_MODE;
154
+ await unlink(this.#temporaryPath);
155
+ await this.syncDirectory();
156
+ if (invalid)
157
+ throw new Error("Temporary credential artifact was invalid");
158
+ } catch (error) {
159
+ if (!isMissing(error))
160
+ throw error;
161
+ }
162
+ }
163
+ async validateFile() {
164
+ try {
165
+ await this.validateOwnedPath(this.#credentialPath, FILE_MODE, false);
166
+ return true;
167
+ } catch (error) {
168
+ if (isMissing(error))
169
+ return false;
170
+ throw error;
171
+ }
172
+ }
173
+ async validateOwnedPath(path, mode, directory) {
174
+ const status = await lstat(path);
175
+ if (status.isSymbolicLink()) {
176
+ throw new Error("Credential path ownership or mode is invalid");
177
+ }
178
+ this.assertOwnedStatus(status, mode, directory);
179
+ }
180
+ assertOwnedStatus(status, mode, directory) {
181
+ if ((directory ? !status.isDirectory() : !status.isFile()) || status.uid !== this.ownerId || (Number(status.mode) & 511) !== mode) {
182
+ throw new Error("Credential path ownership or mode is invalid");
183
+ }
184
+ }
185
+ async syncDirectory() {
186
+ const handle = await open(dirname(this.#credentialPath), constants.O_RDONLY);
187
+ try {
188
+ await handle.sync();
189
+ } finally {
190
+ await handle.close();
191
+ }
192
+ }
193
+ };
194
+ var isMissing = (error) => typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
195
+ export {
196
+ CredentialStoreIntegrityError,
197
+ CredentialStoreUnavailableError,
198
+ GeneratedSdkProductApi,
199
+ GeneratedSdkSessionRevoker,
200
+ InteractiveSessionRequiredError,
201
+ InvalidCommandError,
202
+ LifecycleTransportError,
203
+ NativeNapiKeyringCredentialStore,
204
+ NetworkTransportError,
205
+ OwnerOnlyFileCredentialStore,
206
+ OwnerOnlyProjectLinkStore,
207
+ ProductApiAuthenticationError,
208
+ ProductCli,
209
+ ProviderCapabilityBlockedError,
210
+ PsqlUnavailableError,
211
+ PublicResponseTooLargeError,
212
+ PublicWorkosTokenRefresher,
213
+ RepositoryInitBlockedError,
214
+ RepositoryInitConflictError,
215
+ RepositoryInitError,
216
+ SecretInputError,
217
+ StderrDeviceAuthorizationPresenter,
218
+ TokenRefreshRejectedError,
219
+ UserTokenFileError,
220
+ chooseWorkspace,
221
+ cliMetadataResult,
222
+ createAuthenticatedProductTransport,
223
+ createBoundedFetch,
224
+ createProductionAuthenticatedProductApi,
225
+ initializeRepository,
226
+ parseAccountProfile,
227
+ parseCloudflareDnsAuthorization,
228
+ parseCloudflareDnsAuthorizationStatus,
229
+ parseCredential,
230
+ parseCurrentIdentity,
231
+ parseDevAccessTicket,
232
+ parseOperation,
233
+ parseOperationEvent,
234
+ parsePaidDomain,
235
+ parsePaidDomainPlan,
236
+ parseProductCliCommand,
237
+ parseSafeProblem,
238
+ prepareUserTokenFile,
239
+ publicWorkspace,
240
+ readBoundedResponseBody,
241
+ readSecretValueFromStandardInput,
242
+ recognizedCommandLabel,
243
+ resolveProductCliEnvironment,
244
+ runProductionCli,
245
+ selectWorkspace,
246
+ selectedWorkspaceId,
247
+ serializeCredential,
248
+ workspaceOf
249
+ };
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@amerged/ohmyhost-cli",
3
+ "version": "0.1.10",
4
+ "type": "module",
5
+ "engines": {
6
+ "node": ">=22"
7
+ },
8
+ "files": [
9
+ "dist",
10
+ "src",
11
+ "LICENSE",
12
+ "NOTICE",
13
+ "README.md",
14
+ "THIRD_PARTY_NOTICES.md"
15
+ ],
16
+ "bin": {
17
+ "ohmyhost": "./dist/bin.js"
18
+ },
19
+ "exports": {
20
+ ".": "./dist/index.js",
21
+ "./credential-store": "./dist/credential-store.js"
22
+ },
23
+ "dependencies": {
24
+ "@napi-rs/keyring": "1.3.0"
25
+ },
26
+ "license": "Apache-2.0",
27
+ "homepage": "https://docs.ohmyho.st/",
28
+ "description": "ohmyho.st cli client",
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "registry": "https://registry.npmjs.org/"
32
+ }
33
+ }
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runProductionCli } from "./composition.js";
4
+
5
+ const controller = new AbortController();
6
+ process.once("SIGINT", () => controller.abort(new DOMException("Cancelled", "AbortError")));
7
+ process.once("SIGTERM", () => controller.abort(new DOMException("Cancelled", "AbortError")));
8
+
9
+ process.exitCode = await runProductionCli(
10
+ process.argv.slice(2),
11
+ {
12
+ ...(process.env["OHMYHOST_ENVIRONMENT"] === undefined
13
+ ? {}
14
+ : { OHMYHOST_ENVIRONMENT: process.env["OHMYHOST_ENVIRONMENT"] }),
15
+ ...(process.env["OHMYHOST_TOKEN"] === undefined
16
+ ? {}
17
+ : { OHMYHOST_TOKEN: process.env["OHMYHOST_TOKEN"] }),
18
+ },
19
+ {
20
+ writeStdout: (value) => process.stdout.write(value),
21
+ writeStderr: (value) => process.stderr.write(value),
22
+ },
23
+ controller.signal,
24
+ );