fied 0.2.10 → 0.2.12

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/bin.js +18 -5
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -732,7 +732,6 @@ async function main() {
732
732
  let session;
733
733
  let allowInsecureRelay = false;
734
734
  let showReadonlyLink = false;
735
- let showReadonlyLinkExplicit = false;
736
735
  for (let i = 0; i < args.length; i++) {
737
736
  if ((args[i] === "--session" || args[i] === "-s") && args[i + 1]) {
738
737
  session = args[++i];
@@ -742,7 +741,6 @@ async function main() {
742
741
  allowInsecureRelay = true;
743
742
  } else if (args[i] === "--view-only") {
744
743
  showReadonlyLink = true;
745
- showReadonlyLinkExplicit = true;
746
744
  } else if (!args[i].startsWith("-")) {
747
745
  continue;
748
746
  } else {
@@ -802,15 +800,21 @@ async function main() {
802
800
  if (!session) {
803
801
  throw new Error("No tmux session selected");
804
802
  }
805
- if (!showReadonlyLinkExplicit && process.stdin.isTTY && process.stderr.isTTY) {
806
- showReadonlyLink = await confirm("Enable view-only share link?");
807
- }
808
803
  await share({
809
804
  session,
810
805
  relay,
811
806
  allowInsecureRelay,
812
807
  showReadonlyLink,
813
808
  onShareUrl: async (url) => {
809
+ if (!showReadonlyLink && process.stdin.isTTY && process.stderr.isTTY) {
810
+ const wantReadonly = await confirm("Also share a view-only link?");
811
+ if (wantReadonly) {
812
+ const readonlyUrl = deriveReadonlyUrl(url);
813
+ console.log(` \x1B[1mShare (view-only):\x1B[0m`);
814
+ console.log(` \x1B[4m\x1B[36m${readonlyUrl}\x1B[0m`);
815
+ console.log("");
816
+ }
817
+ }
814
818
  const background = await confirm("Run in background?");
815
819
  if (!background) {
816
820
  return;
@@ -856,6 +860,15 @@ function spawnBackground(options) {
856
860
  child.unref();
857
861
  return child;
858
862
  }
863
+ function deriveReadonlyUrl(interactiveUrl) {
864
+ const parsed = new URL(interactiveUrl);
865
+ parsed.pathname = parsed.pathname.replace(/\/$/, "") + "/v";
866
+ const params = new URLSearchParams(parsed.hash.slice(1));
867
+ const readKey = params.get("r");
868
+ if (!readKey) throw new Error("No read key in URL");
869
+ parsed.hash = `r=${encodeURIComponent(readKey)}`;
870
+ return parsed.toString();
871
+ }
859
872
  function parseShareUrl(url) {
860
873
  const parsed = new URL(url);
861
874
  const match = parsed.pathname.match(/^\/s\/([A-Za-z0-9_-]{8,64})$/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fied",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "Share your tmux session in the browser with end-to-end encryption",
5
5
  "type": "module",
6
6
  "bin": "dist/bin.js",