@settlemint/dalp-cli 3.1.32-main.42600267094 → 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.42600267094",
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);
@@ -55013,4 +55034,4 @@ if (false) {}
55013
55034
  // src/bin.ts
55014
55035
  await cli.serve();
55015
55036
 
55016
- //# debugId=9A6D1338301FCC5464756E2164756E21
55037
+ //# debugId=62F81022351D668364756E2164756E21