replicas-cli 0.2.730 → 0.2.731

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 (2) hide show
  1. package/dist/index.cjs +17 -1
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -27261,7 +27261,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
27261
27261
  });
27262
27262
 
27263
27263
  // ../shared/src/cli-version.ts
27264
- var CLI_VERSION = "0.2.730";
27264
+ var CLI_VERSION = "0.2.731";
27265
27265
 
27266
27266
  // ../shared/src/version.ts
27267
27267
  function compareVersions(v1, v2) {
@@ -28468,6 +28468,7 @@ async function whoamiCommand() {
28468
28468
  }
28469
28469
 
28470
28470
  // src/commands/identity.ts
28471
+ var import_node_crypto = require("crypto");
28471
28472
  var import_node_fs = require("fs");
28472
28473
  var import_node_child_process = require("child_process");
28473
28474
  var import_node_os = require("os");
@@ -28534,6 +28535,16 @@ async function identityExecCommand(command, options) {
28534
28535
  process.exit(result.status ?? 1);
28535
28536
  }
28536
28537
  async function identityAwsCredentialsCommand(options) {
28538
+ const key = (0, import_node_crypto.createHash)("sha256").update(JSON.stringify([options.roleArn, options.audience, options.region, options.sessionName])).digest("hex");
28539
+ const cacheFile = (0, import_node_path.join)((0, import_node_os.homedir)(), ".replicas", "aws-credentials", `${key}.json`);
28540
+ try {
28541
+ const cached2 = (0, import_node_fs.readFileSync)(cacheFile, "utf8");
28542
+ if (Date.parse(JSON.parse(cached2).Expiration) - Date.now() > 15 * 6e4) {
28543
+ process.stdout.write(cached2);
28544
+ return;
28545
+ }
28546
+ } catch {
28547
+ }
28537
28548
  const result = await fetchToken(options.audience);
28538
28549
  if (!result.ok) {
28539
28550
  console.error(import_chalk5.default.red(result.error.message));
@@ -28573,6 +28584,11 @@ async function identityAwsCredentialsCommand(options) {
28573
28584
  process.exitCode = credentials.status || 1;
28574
28585
  return;
28575
28586
  }
28587
+ try {
28588
+ (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(cacheFile), { recursive: true, mode: 448 });
28589
+ (0, import_node_fs.writeFileSync)(cacheFile, credentials.stdout, { mode: 384 });
28590
+ } catch {
28591
+ }
28576
28592
  process.stdout.write(credentials.stdout);
28577
28593
  } finally {
28578
28594
  (0, import_node_fs.rmSync)(directory, { recursive: true, force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.730",
3
+ "version": "0.2.731",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {