@settlemint/dalp-cli 3.1.32-main.42593324632 → 3.1.32-main.42608383459

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/dalp.js CHANGED
@@ -53056,7 +53056,7 @@ async function runCommand(context, operation, errorContext = UNKNOWN_COMMAND_ERR
53056
53056
  // package.json
53057
53057
  var package_default = {
53058
53058
  name: "@settlemint/dalp-cli",
53059
- version: "3.1.32-main.42593324632",
53059
+ version: "3.1.32-main.42608383459",
53060
53060
  private: false,
53061
53061
  description: "CLI for the Digital Asset Lifecycle Platform \u2014 manage tokens, identities, compliance, and more from the command line.",
53062
53062
  homepage: "https://settlemint.com",
@@ -53268,6 +53268,9 @@ import path8 from "path";
53268
53268
  var KEYCHAIN_ENTRY_SEPARATOR_PATTERN = /\n(?=keychain:)/u;
53269
53269
  var ACCOUNT_PATTERN = /"acct"<blob>="([^"]*)"/u;
53270
53270
  var SERVICE_NAME = "dalp-cli";
53271
+ var SECURITY_INTERACTIVE_MAX_LINE_BYTES = 4094;
53272
+ var SECURITY_QUOTED_ESCAPE_PATTERN = /["\\]/gu;
53273
+ var SECURITY_LINE_BREAK_PATTERN = /[\n\r\0]/u;
53271
53274
  var StoredCredentialsSchema = object({
53272
53275
  apiKey: string2().min(1),
53273
53276
  apiKeyId: string2().min(1),
@@ -53276,8 +53279,12 @@ var StoredCredentialsSchema = object({
53276
53279
  activeOrgId: string2().min(1).optional(),
53277
53280
  apiUrl: url()
53278
53281
  });
53279
- var defaultRunSecurity = async (args) => {
53280
- const proc = Bun.spawn(["security", ...args], { stdout: "pipe", stderr: "pipe" });
53282
+ var defaultRunSecurity = async (args, stdin) => {
53283
+ const proc = Bun.spawn(["security", ...args], {
53284
+ stdin: stdin === undefined ? "ignore" : new TextEncoder().encode(stdin),
53285
+ stdout: "pipe",
53286
+ stderr: "pipe"
53287
+ });
53281
53288
  const [stdout, exitCode] = await Promise.all([new Response(proc.stdout).text(), proc.exited]);
53282
53289
  return { exitCode, stdout };
53283
53290
  };
@@ -53313,6 +53320,35 @@ async function deleteKeychainAccount(runSecurity, account) {
53313
53320
  });
53314
53321
  }
53315
53322
  }
53323
+ function quoteSecurityArgument(value) {
53324
+ return `"${value.replaceAll(SECURITY_QUOTED_ESCAPE_PATTERN, (character) => `\\${character}`)}"`;
53325
+ }
53326
+ async function addKeychainPassword(runSecurity, account, password) {
53327
+ const command = [
53328
+ "add-generic-password",
53329
+ "-s",
53330
+ quoteSecurityArgument(SERVICE_NAME),
53331
+ "-a",
53332
+ quoteSecurityArgument(account),
53333
+ "-X",
53334
+ Buffer.from(password, "utf8").toString("hex"),
53335
+ "-U"
53336
+ ].join(" ");
53337
+ if (SECURITY_LINE_BREAK_PATTERN.test(account) || Buffer.byteLength(command, "utf8") > SECURITY_INTERACTIVE_MAX_LINE_BYTES) {
53338
+ throw makeCliError({
53339
+ code: "kit.cli.CREDENTIAL_STORE_FAILED",
53340
+ message: `The ${SERVICE_NAME} keychain item for ${JSON.stringify(account)} cannot be passed to the macOS security tool as one command line.`
53341
+ });
53342
+ }
53343
+ const result = await runSecurity(["-i"], `${command}
53344
+ `);
53345
+ if (result.exitCode !== 0) {
53346
+ throw makeCliError({
53347
+ code: "kit.cli.CREDENTIAL_STORE_FAILED",
53348
+ message: `Keychain save failed with exit code ${result.exitCode}`
53349
+ });
53350
+ }
53351
+ }
53316
53352
  function resolvePlatform(options) {
53317
53353
  if (options.platform !== undefined) {
53318
53354
  return options.platform;
@@ -53331,22 +53367,7 @@ async function saveCredentials(credentials, options = {}) {
53331
53367
  const encoded = JSON.stringify(parsed);
53332
53368
  if (platform === "darwin") {
53333
53369
  const existing = await keychainAccounts(runSecurity);
53334
- const result = await runSecurity([
53335
- "add-generic-password",
53336
- "-s",
53337
- SERVICE_NAME,
53338
- "-a",
53339
- parsed.userEmail,
53340
- "-w",
53341
- encoded,
53342
- "-U"
53343
- ]);
53344
- if (result.exitCode !== 0) {
53345
- throw makeCliError({
53346
- code: "kit.cli.CREDENTIAL_STORE_FAILED",
53347
- message: `Keychain save failed with exit code ${result.exitCode}`
53348
- });
53349
- }
53370
+ await addKeychainPassword(runSecurity, parsed.userEmail, encoded);
53350
53371
  try {
53351
53372
  for (const account of existing.filter((name) => name !== parsed.userEmail)) {
53352
53373
  await deleteKeychainAccount(runSecurity, account);
@@ -53528,6 +53549,15 @@ var apiKeyResponseSchema = object({
53528
53549
  var MAX_LOGIN_RESPONSE_BYTES = 1024 * 1024;
53529
53550
  var CLI_API_KEY_EXPIRES_IN_SECONDS = 90 * 24 * 60 * 60;
53530
53551
  var DEVICE_CLIENT_ID = "dalp-cli";
53552
+ var SERVER_API_KEY_NAME_MAX_LENGTH = 32;
53553
+ var cliApiKeyName = (machine) => {
53554
+ const name = `${DEVICE_CLIENT_ID} (${machine})`;
53555
+ if (name.length <= SERVER_API_KEY_NAME_MAX_LENGTH) {
53556
+ return name;
53557
+ }
53558
+ const room = SERVER_API_KEY_NAME_MAX_LENGTH - `${DEVICE_CLIENT_ID} (\u2026)`.length;
53559
+ return `${DEVICE_CLIENT_ID} (${machine.slice(0, room)}\u2026)`;
53560
+ };
53531
53561
  var isLoopbackHost = (host) => host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "[::1]";
53532
53562
  function validateLoginBaseUrl(apiUrl) {
53533
53563
  let parsed;
@@ -53757,7 +53787,7 @@ Open this URL in your browser:
53757
53787
  }
53758
53788
  const { walletFactor } = c.options;
53759
53789
  const walletCode = await readWalletCode(walletFactor, c.env.DALP_WALLET_CODE, c.agent === true);
53760
- const apiKeyName = `dalp-cli (${hostname3()})`;
53790
+ const apiKeyName = cliApiKeyName(hostname3());
53761
53791
  const apiKeyResponse = await postJson(`${baseUrl}/api/auth/api-key/create`, {
53762
53792
  name: apiKeyName,
53763
53793
  expiresIn: CLI_API_KEY_EXPIRES_IN_SECONDS,
@@ -55004,4 +55034,4 @@ if (false) {}
55004
55034
  // src/bin.ts
55005
55035
  await cli.serve();
55006
55036
 
55007
- //# debugId=57E788197DD2D10364756E2164756E21
55037
+ //# debugId=62F81022351D668364756E2164756E21