oorja 1.6.6 → 1.7.0

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
@@ -87,11 +87,11 @@ EXAMPLES
87
87
  will prompt to choose streaming destination - existing room or create a new one.
88
88
 
89
89
 
90
- $ teletype 'https://oorja.io/rooms?id=foo'
90
+ $ teletype 'https://oorja.io/rooms/foo#key'
91
91
  will stream to the room specified by secret link, you must have joined the room before streaming.
92
92
 
93
93
 
94
- $ teletype -m 'https://oorja.io/rooms?id=foo'
94
+ $ teletype -m 'https://oorja.io/rooms/foo#key'
95
95
  Will also allow room participants to write to your terminal!
96
96
  ```
97
97
 
@@ -7,6 +7,7 @@ export default class TeleTypeCommand extends Command {
7
7
  help: import("@oclif/parser/lib/flags").IBooleanFlag<void>;
8
8
  shell: flags.IOptionFlag<string>;
9
9
  multiplex: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
+ new_room: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
10
11
  };
11
12
  static args: {
12
13
  name: string;
@@ -11,11 +11,15 @@ const utils_1 = require("../../lib/utils");
11
11
  const DEFAULT_SHELL = os.platform() === "win32" ? "powershell.exe" : process.env.SHELL || "bash";
12
12
  class TeleTypeCommand extends command_1.Command {
13
13
  async run() {
14
- const { args, flags: { shell, multiplex }, } = this.parse(TeleTypeCommand);
14
+ const { args, flags: { shell, multiplex, new_room }, } = this.parse(TeleTypeCommand);
15
15
  if (args.room) {
16
16
  await this.streamToLink({ shell, multiplex, roomLink: args.room });
17
17
  process.exit(0);
18
18
  }
19
+ if (new_room) {
20
+ await this.createRoomAndStream({ shell, multiplex });
21
+ process.exit(0);
22
+ }
19
23
  console.log("(use -h for description and options) \n");
20
24
  // room not known, prompt
21
25
  const ROOM = "To an existing room (you have the room link)";
@@ -110,5 +114,10 @@ TeleTypeCommand.flags = {
110
114
  description: "Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default",
111
115
  default: false,
112
116
  }),
117
+ new_room: command_1.flags.boolean({
118
+ char: "n",
119
+ description: "Create new room",
120
+ default: false,
121
+ }),
113
122
  };
114
123
  TeleTypeCommand.args = [{ name: "room" }];
@@ -1,5 +1,5 @@
1
1
  import { URL } from "url";
2
- export declare const CLI_VERSION = 1.6;
2
+ export declare const CLI_VERSION = 1.7;
3
3
  export declare const config: any;
4
4
  export type env = "staging" | "local" | "prod" | "prod-teletype";
5
5
  export type SuryaConfig = {
@@ -8,7 +8,7 @@ export type SuryaConfig = {
8
8
  token: string;
9
9
  };
10
10
  export declare const getSuryaConfig: (env: env) => SuryaConfig;
11
- export declare const ROOM_LINK_SAMPLE = "https://oorja.io/rooms?id=foo#key";
11
+ export declare const ROOM_LINK_SAMPLE = "https://oorja.io/rooms/foo#key";
12
12
  export declare const INVALID_ROOM_LINK_MESSAGE: string;
13
13
  export declare const determineENV: (roomURL?: URL) => env;
14
14
  export declare const getENVAccessToken: (env: env) => string;
package/lib/lib/config.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getoorjaConfig = exports.setENVAccessToken = exports.getENVAccessToken = exports.determineENV = exports.INVALID_ROOM_LINK_MESSAGE = exports.ROOM_LINK_SAMPLE = exports.getSuryaConfig = exports.config = exports.CLI_VERSION = void 0;
4
4
  const chalk = require("chalk");
5
- exports.CLI_VERSION = 1.6;
5
+ exports.CLI_VERSION = 1.7;
6
6
  const Conf = require("conf");
7
7
  exports.config = new Conf({
8
8
  projectName: "oorja",
@@ -26,7 +26,7 @@ const getSuryaConfig = (env) => {
26
26
  };
27
27
  };
28
28
  exports.getSuryaConfig = getSuryaConfig;
29
- exports.ROOM_LINK_SAMPLE = "https://oorja.io/rooms?id=foo#key";
29
+ exports.ROOM_LINK_SAMPLE = "https://oorja.io/rooms/foo#key";
30
30
  exports.INVALID_ROOM_LINK_MESSAGE = `${chalk.redBright("invalid url ")}🤔. It should look like: ${chalk.blue(exports.ROOM_LINK_SAMPLE)}`;
31
31
  const determineENV = (roomURL) => {
32
32
  if (!roomURL)
@@ -25,7 +25,7 @@ class OORJA {
25
25
  };
26
26
  };
27
27
  this.linkForRoom = (roomKey) => {
28
- return `${oorjaURL(this.config)}/rooms?id=${roomKey.roomId}#${(0, encryption_1.exportKey)(roomKey.key)}`;
28
+ return `${oorjaURL(this.config)}/rooms/${roomKey.roomId}#${(0, encryption_1.exportKey)(roomKey.key)}`;
29
29
  };
30
30
  this.teletype = (options) => {
31
31
  return (0, teletype_1.teletypeApp)(Object.assign({ userId: this.user.id, joinChannel: this.suryaClient.joinChannel }, options));
@@ -35,21 +35,24 @@ class OORJA {
35
35
  const url = parseRoomURL(roomLink);
36
36
  return {
37
37
  key: (0, encryption_1.importKey)(url.hash),
38
- roomId: url.searchParams.get("id"),
38
+ roomId: url.pathname.split("/")[2],
39
39
  };
40
40
  }
41
41
  }
42
42
  const parseRoomURL = (roomLink) => {
43
43
  const url = new url_1.URL(roomLink);
44
- if (!url.searchParams.get("id") || !url.hash) {
44
+ if (!url.hash || !getRoomId(url)) {
45
45
  console.log(config_1.INVALID_ROOM_LINK_MESSAGE);
46
46
  process.exit(3);
47
47
  }
48
48
  return url;
49
49
  };
50
50
  const getRoomId = (roomURL) => {
51
- const id = roomURL.searchParams.get("id");
52
- return id || undefined;
51
+ const fragments = roomURL.pathname.split("/");
52
+ if (fragments.length !== 3 || fragments[1] !== "rooms" || !fragments["2"]) {
53
+ return undefined;
54
+ }
55
+ return fragments["2"];
53
56
  };
54
57
  const oorjaURL = (config) => {
55
58
  const { host, enableTLS } = config;
@@ -1 +1 @@
1
- {"version":"1.6.6","commands":{"signout":{"id":"signout","description":"Sign-out of oorja. Clears saved auth-token","pluginName":"oorja","pluginType":"core","aliases":[],"flags":{},"args":[]},"teletype":{"id":"teletype","description":"Launch a terminal streaming session in oorja.","pluginName":"oorja","pluginType":"core","aliases":["tty"],"examples":["\u001b[94m$ teletype\u001b[39m\nWill prompt to choose streaming destination - existing room or create a new one.\n\n","\u001b[94m$ teletype 'https://oorja.io/rooms?id=foo#key'\u001b[39m\nWill stream to the room specified by secret link, you must have joined the room before streaming.\n\n","\u001b[94m$ teletype -m\u001b[39m\nWill also allow room participants to write to your terminal!\n\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"shell":{"name":"shell","type":"option","char":"s","description":"shell to use. e.g. bash, fish","default":"/usr/bin/zsh"},"multiplex":{"name":"multiplex","type":"boolean","char":"m","description":"Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default","allowNo":false}},"args":[{"name":"room"}]}}}
1
+ {"version":"1.7.0","commands":{"signout":{"id":"signout","description":"Sign-out of oorja. Clears saved auth-token","pluginName":"oorja","pluginType":"core","aliases":[],"flags":{},"args":[]},"teletype":{"id":"teletype","description":"Launch a terminal streaming session in oorja.","pluginName":"oorja","pluginType":"core","aliases":["tty"],"examples":["\u001b[94m$ teletype\u001b[39m\nWill prompt to choose streaming destination - existing room or create a new one.\n\n","\u001b[94m$ teletype 'https://oorja.io/rooms/foo#key'\u001b[39m\nWill stream to the room specified by secret link, you must have joined the room before streaming.\n\n","\u001b[94m$ teletype -m\u001b[39m\nWill also allow room participants to write to your terminal!\n\n"],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"shell":{"name":"shell","type":"option","char":"s","description":"shell to use. e.g. bash, fish","default":"/usr/bin/zsh"},"multiplex":{"name":"multiplex","type":"boolean","char":"m","description":"Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default","allowNo":false},"new_room":{"name":"new_room","type":"boolean","char":"n","description":"Create new room","allowNo":false}},"args":[{"name":"room"}]}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oorja",
3
3
  "description": "stream terminals to the web and more.",
4
- "version": "1.6.6",
4
+ "version": "1.7.0",
5
5
  "author": "Akshay Kumar @akshaykmr",
6
6
  "bin": {
7
7
  "oorja": "./bin/run",