@amerged/ohmyhost-cli 0.1.71 → 0.1.73

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/index.js CHANGED
@@ -107,7 +107,7 @@ import {
107
107
  selectWorkspace,
108
108
  verifiedUserId,
109
109
  workspaceOf
110
- } from "./chunk-OMMRWO6A.js";
110
+ } from "./chunk-5R7JYYZD.js";
111
111
  import {
112
112
  CredentialStoreIntegrityError,
113
113
  CredentialStoreUnavailableError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amerged/ohmyhost-cli",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohmyhost/product-cli",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "private": true,
5
5
  "ohmyhost": {
6
6
  "deployment": "production",
@@ -375,6 +375,10 @@ const HELP_USAGE = Object.freeze({
375
375
  "ohmyhost connection import --organization ULID --grant ULID --project ULID --environment ULID --provider-organization ID --team ID --connection ID --idempotency-key KEY --json",
376
376
  "connection disconnect":
377
377
  "ohmyhost connection disconnect --organization ULID --grant ULID --idempotency-key KEY --yes --json",
378
+ "connection credential-request-create":
379
+ "ohmyhost connection credential-request-create --organization ULID --grant ULID --provider-organization ID --team ID --selections JSON --idempotency-key KEY --json",
380
+ "connection credential-request-status":
381
+ "ohmyhost connection credential-request-status --organization ULID --grant ULID --request HASH --json",
378
382
  "github connect":
379
383
  "ohmyhost github connect --organization ULID --idempotency-key KEY --json (connect once, then link covered repositories without another browser consent)",
380
384
  "github status": "ohmyhost github status --organization ULID --json",
@@ -949,7 +953,9 @@ export class ProductCli {
949
953
  command.kind === "connection-status" ||
950
954
  command.kind === "connection-discover" ||
951
955
  command.kind === "connection-import" ||
952
- command.kind === "connection-disconnect"
956
+ command.kind === "connection-disconnect" ||
957
+ command.kind === "connection-credential-request-create" ||
958
+ command.kind === "connection-credential-request-status"
953
959
  ) {
954
960
  const api = await this.authenticatedApi(command.credentialStore, signal);
955
961
  if (!api.connection) throw new ResponseContractError();
@@ -4036,6 +4042,10 @@ const parsedCommandName = (command: ProductCliCommand): CommandLabel => {
4036
4042
  if (command.kind === "connection-discover") return "connection discover";
4037
4043
  if (command.kind === "connection-import") return "connection import";
4038
4044
  if (command.kind === "connection-disconnect") return "connection disconnect";
4045
+ if (command.kind === "connection-credential-request-create")
4046
+ return "connection credential-request-create";
4047
+ if (command.kind === "connection-credential-request-status")
4048
+ return "connection credential-request-status";
4039
4049
  if (command.kind === "organization-mcp-connections-list")
4040
4050
  return "organization mcp-connections list";
4041
4051
  if (command.kind === "organization-mcp-connection-revoke")
@@ -1,4 +1,8 @@
1
1
  import { isUserSecretName } from "@ohmyhost/contracts/secret-names";
2
+ import {
3
+ parseMakeCredentialSelections,
4
+ type MakeCredentialSelection,
5
+ } from "@ohmyhost/contracts/connection-management";
2
6
  import { MCP_CONNECTION_ID_PATTERN } from "@ohmyhost/contracts/organization-mcp-connections";
3
7
  import {
4
8
  DATABASE_PAGE_MAX_ITEMS,
@@ -180,6 +184,23 @@ export type ProductCliCommand =
180
184
  readonly yes: true;
181
185
  readonly credentialStore: "native";
182
186
  }
187
+ | {
188
+ readonly kind: "connection-credential-request-create";
189
+ readonly organizationId: string;
190
+ readonly grantId: string;
191
+ readonly providerOrganizationId: number;
192
+ readonly teamId: number;
193
+ readonly selections: MakeCredentialSelection[];
194
+ readonly idempotencyKey: string;
195
+ readonly credentialStore: "native";
196
+ }
197
+ | {
198
+ readonly kind: "connection-credential-request-status";
199
+ readonly organizationId: string;
200
+ readonly grantId: string;
201
+ readonly requestId: string;
202
+ readonly credentialStore: "native";
203
+ }
183
204
  | {
184
205
  readonly kind: "organization-mcp-connections-list";
185
206
  readonly organizationId: string;
@@ -1203,6 +1224,8 @@ export type RecognizedCommandLabel =
1203
1224
  | "connection discover"
1204
1225
  | "connection import"
1205
1226
  | "connection disconnect"
1227
+ | "connection credential-request-create"
1228
+ | "connection credential-request-status"
1206
1229
  | "github connect"
1207
1230
  | "github status"
1208
1231
  | "github disconnect"
@@ -1341,7 +1364,16 @@ export const recognizedCommandLabel = (argv: readonly string[]): RecognizedComma
1341
1364
  if (value === "profile" && values[0] === "list") return "profile list";
1342
1365
  if (
1343
1366
  value === "connection" &&
1344
- ["begin", "list", "status", "discover", "import", "disconnect"].includes(values[0] ?? "")
1367
+ [
1368
+ "begin",
1369
+ "list",
1370
+ "status",
1371
+ "discover",
1372
+ "import",
1373
+ "disconnect",
1374
+ "credential-request-create",
1375
+ "credential-request-status",
1376
+ ].includes(values[0] ?? "")
1345
1377
  )
1346
1378
  return `connection ${values[0]}` as RecognizedCommandLabel;
1347
1379
  if (value === "github" && values[0] === "connect") return "github connect";
@@ -2197,6 +2229,7 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
2197
2229
  "--provider-organization",
2198
2230
  "--team",
2199
2231
  "--connection",
2232
+ "--selections",
2200
2233
  ] as const);
2201
2234
  const org = options["--organization"];
2202
2235
  if (!org || !ORGANIZATION_ULID.test(org)) throw new InvalidCommandError();
@@ -2208,6 +2241,58 @@ export const parseProductCliCommand = (argv: readonly string[]): ProductCliComma
2208
2241
  options["--environment"] &&
2209
2242
  ORGANIZATION_ULID.test(options["--project"]) &&
2210
2243
  ORGANIZATION_ULID.test(options["--environment"]);
2244
+ if (
2245
+ operation === "credential-request-create" &&
2246
+ exact([
2247
+ "--organization",
2248
+ "--grant",
2249
+ "--provider-organization",
2250
+ "--team",
2251
+ "--selections",
2252
+ "--idempotency-key",
2253
+ ])
2254
+ ) {
2255
+ const grantId = options["--grant"] ?? "";
2256
+ const idempotencyKey = options["--idempotency-key"] ?? "";
2257
+ const providerOrganization = options["--provider-organization"] ?? "";
2258
+ const team = options["--team"] ?? "";
2259
+ if (
2260
+ !ORGANIZATION_ULID.test(grantId) ||
2261
+ !/^[A-Za-z0-9._:-]{1,128}$/u.test(idempotencyKey) ||
2262
+ [providerOrganization, team].some(
2263
+ (id) => !/^[1-9][0-9]{0,15}$/u.test(id) || !Number.isSafeInteger(Number(id)),
2264
+ )
2265
+ )
2266
+ throw new InvalidCommandError();
2267
+ try {
2268
+ const json = options["--selections"] ?? "";
2269
+ return {
2270
+ kind: "connection-credential-request-create",
2271
+ organizationId: org,
2272
+ grantId,
2273
+ providerOrganizationId: Number(providerOrganization),
2274
+ teamId: Number(team),
2275
+ selections: parseMakeCredentialSelections(JSON.parse(json)),
2276
+ idempotencyKey,
2277
+ credentialStore,
2278
+ };
2279
+ } catch {
2280
+ throw new InvalidCommandError();
2281
+ }
2282
+ }
2283
+ if (
2284
+ operation === "credential-request-status" &&
2285
+ exact(["--organization", "--grant", "--request"]) &&
2286
+ ORGANIZATION_ULID.test(options["--grant"] ?? "") &&
2287
+ /^[a-f0-9]{64}$/u.test(options["--request"] ?? "")
2288
+ )
2289
+ return {
2290
+ kind: "connection-credential-request-status",
2291
+ organizationId: org,
2292
+ grantId: options["--grant"] ?? "",
2293
+ requestId: options["--request"] ?? "",
2294
+ credentialStore,
2295
+ };
2211
2296
  if (operation === "list" && exact(["--organization"]))
2212
2297
  return { kind: "connection-list", organizationId: org, credentialStore };
2213
2298
  if (
@@ -6,6 +6,8 @@ import {
6
6
  getConnectionRequest,
7
7
  discoverConnection,
8
8
  disconnectConnection,
9
+ createMakeCredentialRequest,
10
+ getMakeCredentialRequest,
9
11
  } from "@ohmyhost/sdk-ts";
10
12
  import type { ProductCliCommand } from "./command.js";
11
13
  import { randomUUID } from "node:crypto";
@@ -312,6 +314,8 @@ export type ConnectionCommand = Extract<
312
314
  | "connection-status"
313
315
  | "connection-discover"
314
316
  | "connection-disconnect"
317
+ | "connection-credential-request-create"
318
+ | "connection-credential-request-status"
315
319
  | "connection-import";
316
320
  }
317
321
  >;
@@ -869,6 +873,27 @@ export async function executeConnectionCommand(
869
873
  { client: client },
870
874
  );
871
875
  break;
876
+ case "connection-credential-request-create":
877
+ result = await createMakeCredentialRequest(
878
+ {
879
+ organization_id,
880
+ grant_id: command.grantId,
881
+ "Idempotency-Key": command.idempotencyKey,
882
+ makeCredentialRequestCreate: {
883
+ provider_organization_id: command.providerOrganizationId,
884
+ team_id: command.teamId,
885
+ selections: command.selections,
886
+ },
887
+ },
888
+ { client },
889
+ );
890
+ break;
891
+ case "connection-credential-request-status":
892
+ result = await getMakeCredentialRequest(
893
+ { organization_id, grant_id: command.grantId, request_id: command.requestId },
894
+ { client },
895
+ );
896
+ break;
872
897
  }
873
898
  return parseConnectionResponse(command.kind, result, origin);
874
899
  }
@@ -1,4 +1,101 @@
1
1
  const ulid = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/u;
2
+ const requestId = /^[a-f0-9]{64}$/u;
3
+ const appName = /^[A-Za-z0-9_-]{1,128}$/u;
4
+ const moduleId = /^[A-Za-z0-9_.:-]{1,128}$/u;
5
+ const makeOrigins = new Set([
6
+ "https://eu1.make.com",
7
+ "https://eu2.make.com",
8
+ "https://us1.make.com",
9
+ "https://us2.make.com",
10
+ "https://we.make.com",
11
+ "https://eu1.make.celonis.com",
12
+ "https://us1.make.celonis.com",
13
+ ]);
14
+
15
+ export interface MakeCredentialSelection {
16
+ app_name: string;
17
+ app_version: number;
18
+ module_ids?: string[];
19
+ endpoint_names?: string[];
20
+ }
21
+
22
+ function selectors(raw: unknown, format: RegExp): boolean {
23
+ return (
24
+ Array.isArray(raw) &&
25
+ raw.length >= 1 &&
26
+ raw.length <= 64 &&
27
+ raw.every(
28
+ (value) =>
29
+ typeof value === "string" &&
30
+ format.test(value) &&
31
+ value.replaceAll(/[-_.:]/gu, "").toLowerCase() !== "arbitrarycall",
32
+ ) &&
33
+ new Set(raw).size === raw.length
34
+ );
35
+ }
36
+
37
+ export function parseMakeCredentialSelections(raw: unknown): MakeCredentialSelection[] {
38
+ if (!Array.isArray(raw) || raw.length < 1 || raw.length > 64)
39
+ throw new TypeError("Invalid Make credential selections");
40
+ for (const entry of raw) {
41
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
42
+ throw new TypeError("Invalid Make credential selection");
43
+ const value = entry as Record<string, unknown>;
44
+ if (
45
+ Object.keys(value).some(
46
+ (key) => !["app_name", "app_version", "module_ids", "endpoint_names"].includes(key),
47
+ ) ||
48
+ typeof value["app_name"] !== "string" ||
49
+ !appName.test(value["app_name"]) ||
50
+ !Number.isSafeInteger(value["app_version"]) ||
51
+ Number(value["app_version"]) < 1 ||
52
+ !(Object.hasOwn(value, "module_ids") || Object.hasOwn(value, "endpoint_names")) ||
53
+ (Object.hasOwn(value, "module_ids") && !selectors(value["module_ids"], moduleId)) ||
54
+ (Object.hasOwn(value, "endpoint_names") && !selectors(value["endpoint_names"], appName))
55
+ )
56
+ throw new TypeError("Invalid Make credential selection");
57
+ }
58
+ return raw as MakeCredentialSelection[];
59
+ }
60
+
61
+ function parseMakeCredentialResult(raw: unknown, create: boolean): void {
62
+ if (!raw || typeof raw !== "object" || Array.isArray(raw))
63
+ throw new TypeError("Invalid connection response");
64
+ const value = raw as Record<string, unknown>;
65
+ const state = value["state"];
66
+ if (
67
+ Object.keys(value).some(
68
+ (key) =>
69
+ !["state", "request_id", "provider_status", "authorization_url", "expires_at"].includes(
70
+ key,
71
+ ),
72
+ ) ||
73
+ !["created", "running", "uncertain", "reconnect_required"].includes(String(state)) ||
74
+ ((state === "created" || value["request_id"] !== undefined) &&
75
+ (typeof value["request_id"] !== "string" || !requestId.test(value["request_id"]))) ||
76
+ (state === "created"
77
+ ? typeof value["provider_status"] !== "string" ||
78
+ !/^[a-z_]{1,64}$/u.test(value["provider_status"])
79
+ : value["provider_status"] !== undefined || value["expires_at"] !== undefined)
80
+ )
81
+ throw new TypeError("Invalid connection response");
82
+ if (value["expires_at"] !== null && value["expires_at"] !== undefined) date(value["expires_at"]);
83
+ if (value["authorization_url"] === undefined) return;
84
+ if (!create || state !== "created" || typeof value["authorization_url"] !== "string")
85
+ throw new TypeError("Invalid connection response");
86
+ const url = new URL(value["authorization_url"]);
87
+ if (
88
+ !makeOrigins.has(url.origin) ||
89
+ url.username ||
90
+ url.password ||
91
+ url.hash ||
92
+ !/^\/[1-9][0-9]*\/credentials-requests\/inbox$/u.test(url.pathname) ||
93
+ url.searchParams.size !== 1 ||
94
+ !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/u.test(url.searchParams.get("requestId") ?? "")
95
+ )
96
+ throw new TypeError("Invalid connection response");
97
+ }
98
+
2
99
  function record(raw: unknown, keys: readonly string[]): Record<string, unknown> {
3
100
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
4
101
  throw new TypeError("Invalid connection response");
@@ -32,11 +129,18 @@ export function parseConnectionResponse(
32
129
  | "connection-status"
33
130
  | "connection-discover"
34
131
  | "connection-disconnect"
35
- | "connection-import",
132
+ | "connection-import"
133
+ | "connection-credential-request-create"
134
+ | "connection-credential-request-status",
36
135
  raw: unknown,
37
136
  expectedOrigin?: string,
38
137
  ): unknown {
39
- if (kind === "connection-begin") {
138
+ if (
139
+ kind === "connection-credential-request-create" ||
140
+ kind === "connection-credential-request-status"
141
+ ) {
142
+ parseMakeCredentialResult(raw, kind === "connection-credential-request-create");
143
+ } else if (kind === "connection-begin") {
40
144
  const v = record(raw, ["request_id", "url", "expires_at"]);
41
145
  date(v["expires_at"]);
42
146
  if (
@@ -114,6 +114,10 @@ const failures = {
114
114
  "The runtime refused to load the built Worker.",
115
115
  "The built Worker could not be loaded: top-level code throws or calls fetch, timers or random values outside a handler, an import cannot be resolved, a Worker module such as src/ohmyhost/companion.ts has no default export, or the bundle is too large. Fix that, save or push the corrected version and plan its commit; replaying this operation cannot pass. If none of this applies, report the operation ID through feedback.",
116
116
  ],
117
+ native_auth_launch_unavailable: [
118
+ "Native Auth rollout access is unavailable for this project.",
119
+ "Ask ohmyho.st support to check Native Auth rollout access for this workspace and project. Once access is enabled, plan the saved commit again. Then check the project’s Paid access, verified sender and approved application origin.",
120
+ ],
117
121
  storage_jurisdiction_conflict: [
118
122
  "storage.jurisdiction must match the project's recorded storage jurisdiction.",
119
123
  "Read 'Storage jurisdiction' in 'ohmyhost project context --project ULID --json' and set storage.jurisdiction in ohmyhost.yaml to that recorded value (us or eu). Existing R2 buckets and reservations keep their jurisdiction after a project-region migration; only new storage without a recorded bucket uses the project region. If context reports unavailable, report the request ID through feedback rather than guessing. Save or push the corrected version and plan its commit; for promotion, deploy it to Dev and promote again. Do not delete or recreate the project to move files.",
@@ -726,7 +726,7 @@ export const PROBLEM_POLICY = {
726
726
  retryable: false,
727
727
  title: "Native Auth cannot launch yet",
728
728
  action:
729
- "Read the Native Auth configuration with 'ohmyhost auth config get --project ULID --environment ULID --json'. Its readiness shows which requirement is missing: a Paid plan, a verified sender domain, an approved canonical origin or storage. Complete that requirement, then send the change again with a new idempotency key. Repeating unchanged does not help.",
729
+ "Ask ohmyho.st support to check Native Auth rollout access for this workspace and project. Once access is enabled, read the Native Auth configuration for the target environment to check Paid access, the verified sender, the approved application origin and storage. Retry after the missing requirement is satisfied.",
730
730
  },
731
731
  native_auth_provider_unavailable: {
732
732
  status: 409,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ohmyhost/sdk-ts",
3
- "version": "0.1.71",
3
+ "version": "0.1.73",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,6 +23,7 @@ export {
23
23
  createCloudflareDnsAuthorization,
24
24
  createDeployment,
25
25
  createMakeActionBinding,
26
+ createMakeCredentialRequest,
26
27
  createManagedSourceUpload,
27
28
  createNativeAuthUser,
28
29
  createOrganization,
@@ -69,6 +70,7 @@ export {
69
70
  getFeatureInterests,
70
71
  getFeedback,
71
72
  getGithubOrganizationConnection,
73
+ getMakeCredentialRequest,
72
74
  getManagedMailAttachment,
73
75
  getManagedMailDomain,
74
76
  getManagedMailMessage,
@@ -324,6 +326,11 @@ export type {
324
326
  CreateMakeActionBindingErrors,
325
327
  CreateMakeActionBindingResponse,
326
328
  CreateMakeActionBindingResponses,
329
+ CreateMakeCredentialRequestData,
330
+ CreateMakeCredentialRequestError,
331
+ CreateMakeCredentialRequestErrors,
332
+ CreateMakeCredentialRequestResponse,
333
+ CreateMakeCredentialRequestResponses,
327
334
  CreateManagedSourceUploadData,
328
335
  CreateManagedSourceUploadError,
329
336
  CreateManagedSourceUploadErrors,
@@ -630,6 +637,11 @@ export type {
630
637
  GetGithubOrganizationConnectionErrors,
631
638
  GetGithubOrganizationConnectionResponse,
632
639
  GetGithubOrganizationConnectionResponses,
640
+ GetMakeCredentialRequestData,
641
+ GetMakeCredentialRequestError,
642
+ GetMakeCredentialRequestErrors,
643
+ GetMakeCredentialRequestResponse,
644
+ GetMakeCredentialRequestResponses,
633
645
  GetManagedMailAttachmentData,
634
646
  GetManagedMailAttachmentError,
635
647
  GetManagedMailAttachmentErrors,
@@ -920,6 +932,10 @@ export type {
920
932
  MakeActionRunSuccess,
921
933
  MakeActionUnavailable,
922
934
  MakeActionUncertain,
935
+ MakeCredentialRequestCreate,
936
+ MakeCredentialRequestResult,
937
+ MakeCredentialRequestStatus,
938
+ MakeCredentialSelection,
923
939
  ManagedMailContent,
924
940
  ManagedMailContentResult,
925
941
  ManagedMailDisabled,