@settlemint/dalp-cli 3.1.19-main.35205572771 → 3.1.19-main.35210702637

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 CHANGED
@@ -67,12 +67,12 @@ dalp get monitoring api request-logs stream
67
67
 
68
68
  ## Architecture
69
69
 
70
- | Concern | Implementation |
71
- | --------- | ------------------------------------------------------------------ |
72
- | Framework | Incur + Zod |
73
- | HTTP | `createDalpClient` + route ids from `@settlemint/dalp-sdk/routes` |
74
- | Docs | Compile-time OpenAPI surface |
75
- | Auth | Device login → API key; `X-Organization-Id` from stored active org |
70
+ | Concern | Implementation |
71
+ | --------- | ------------------------------------------------------------------------------- |
72
+ | Framework | Incur + Zod |
73
+ | HTTP | `createDalpClient` + route ids from `@settlemint/dalp-sdk/routes` |
74
+ | Docs | Compile-time OpenAPI surface |
75
+ | Auth | Device login → API key for one organization; `org switch` accepts only that org |
76
76
 
77
77
  ## License
78
78
 
package/dist/dalp.js CHANGED
@@ -41909,7 +41909,7 @@ var WEBHOOK_MANIFEST_VERSION = Webhook.MANIFEST_VERSION;
41909
41909
  // ../sdk/package.json
41910
41910
  var package_default = {
41911
41911
  name: "@settlemint/dalp-sdk",
41912
- version: "3.1.19-main.35205572771",
41912
+ version: "3.1.19-main.35210702637",
41913
41913
  private: false,
41914
41914
  description: "Fully typed SDK for the DALP tokenization platform API",
41915
41915
  homepage: "https://settlemint.com",
@@ -107673,7 +107673,7 @@ function commandsFromErrorHints(input) {
107673
107673
  }
107674
107674
  const org = category === "permission" || code.includes("ORGANIZATION") || code.includes("ACTIVE_ORG") || fix.includes("organization") || fix.includes("org ");
107675
107675
  if (org) {
107676
- commands.push({ command: "org switch", description: "Select an active organization" });
107676
+ commands.push({ command: "org switch", description: "Save the key's organization as active" });
107677
107677
  commands.push({ command: "whoami", description: "Show current user and organization" });
107678
107678
  }
107679
107679
  if (commands.length === 0 && (category === "client" || category === "config")) {
@@ -107933,7 +107933,7 @@ async function runCommand(context, operation, errorContext = UNKNOWN_COMMAND_ERR
107933
107933
  // package.json
107934
107934
  var package_default2 = {
107935
107935
  name: "@settlemint/dalp-cli",
107936
- version: "3.1.19-main.35205572771",
107936
+ version: "3.1.19-main.35210702637",
107937
107937
  private: false,
107938
107938
  description: "CLI for the Digital Asset Lifecycle Platform \u2014 manage tokens, identities, compliance, and more from the command line.",
107939
107939
  homepage: "https://settlemint.com",
@@ -108493,7 +108493,7 @@ Open this URL in your browser:
108493
108493
  description: "You're logged in. Try:",
108494
108494
  commands: [
108495
108495
  { command: "whoami", description: "View current user" },
108496
- { command: "org switch", description: "Select an organization" },
108496
+ { command: "org switch", description: "Save the key's organization as active" },
108497
108497
  { command: "tokens list", description: "List tokens" }
108498
108498
  ]
108499
108499
  }
@@ -108547,6 +108547,9 @@ async function authRequest(apiUrl, credentials, route, init) {
108547
108547
  }
108548
108548
 
108549
108549
  // src/commands/org.ts
108550
+ var ApiKeyOrganizationSchema = object({
108551
+ metadata: object({ organizationId: string2().min(1).optional() }).nullish()
108552
+ });
108550
108553
  var orgCommand = create("org", {
108551
108554
  description: "Active organization for organization-scoped requests",
108552
108555
  vars: cliVars
@@ -108572,7 +108575,7 @@ orgCommand.command("list", {
108572
108575
  }
108573
108576
  });
108574
108577
  orgCommand.command("switch", {
108575
- description: "Set the active organization persisted for subsequent CLI requests",
108578
+ description: "Save the organization of the stored API key as the active organization",
108576
108579
  args: object({
108577
108580
  organizationId: string2().describe("Organization id to activate")
108578
108581
  }),
@@ -108586,10 +108589,22 @@ orgCommand.command("switch", {
108586
108589
  });
108587
108590
  }
108588
108591
  return runCommand(c, (async () => {
108589
- await authRequest(credentials.apiUrl, credentials, "/organization/set-active", {
108590
- method: "POST",
108591
- body: { organizationId: c.args.organizationId }
108592
- });
108592
+ const key = ApiKeyOrganizationSchema.safeParse(await authRequest(credentials.apiUrl, credentials, `/api-key/get?id=${encodeURIComponent(credentials.apiKeyId)}`));
108593
+ const keyOrganizationId = key.data?.metadata?.organizationId;
108594
+ if (keyOrganizationId === undefined) {
108595
+ return c.error({
108596
+ code: "KEY_HAS_NO_ORGANIZATION",
108597
+ message: "The stored API key names no organization. Run 'dalp login' to get a key for one.",
108598
+ retryable: false
108599
+ });
108600
+ }
108601
+ if (keyOrganizationId !== c.args.organizationId) {
108602
+ return c.error({
108603
+ code: "ORGANIZATION_NOT_ON_KEY",
108604
+ message: `The stored API key belongs to \`${keyOrganizationId}\`, not \`${c.args.organizationId}\`. Run 'dalp login' with \`${c.args.organizationId}\` as the active organization to get a key for it.`,
108605
+ retryable: false
108606
+ });
108607
+ }
108593
108608
  const latest = await loadCredentials() ?? credentials;
108594
108609
  await saveCredentials({
108595
108610
  ...latest,
@@ -108598,13 +108613,13 @@ orgCommand.command("switch", {
108598
108613
  await saveGlobalConfig({ defaultOrg: c.args.organizationId });
108599
108614
  return {
108600
108615
  activeOrgId: c.args.organizationId,
108601
- message: "Active organization saved. Subsequent requests send X-Organization-Id."
108616
+ message: "Active organization saved. It matches the organization of the stored API key."
108602
108617
  };
108603
108618
  })());
108604
108619
  }
108605
108620
  });
108606
108621
  orgCommand.command("current", {
108607
- description: "Show the active organization id used for X-Organization-Id",
108622
+ description: "Show the active organization id saved with the stored credentials",
108608
108623
  run(c) {
108609
108624
  return {
108610
108625
  activeOrgId: c.var.credentials?.activeOrgId ?? null,
@@ -109268,4 +109283,4 @@ if (false) {}
109268
109283
  // src/bin.ts
109269
109284
  await cli.serve();
109270
109285
 
109271
- //# debugId=A976DACF5BB926BE64756E2164756E21
109286
+ //# debugId=8F7A30A4856BC86264756E2164756E21