oorja 1.9.0 → 1.11.3

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 (49) hide show
  1. package/README.md +73 -29
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.js +5 -0
  5. package/bin/teletype.js +7 -0
  6. package/dist/commands/signout.js +6 -10
  7. package/dist/commands/teletype/index.d.ts +5 -5
  8. package/dist/commands/teletype/index.js +57 -57
  9. package/dist/index.js +1 -5
  10. package/dist/lib/config.d.ts +4 -2
  11. package/dist/lib/config.js +33 -25
  12. package/dist/lib/encryption.d.ts +2 -2
  13. package/dist/lib/encryption.js +9 -17
  14. package/dist/lib/oorja/index.d.ts +5 -5
  15. package/dist/lib/oorja/index.js +43 -45
  16. package/dist/lib/oorja/preflight.d.ts +3 -3
  17. package/dist/lib/oorja/preflight.js +41 -40
  18. package/dist/lib/surya/errors.js +3 -9
  19. package/dist/lib/surya/index.d.ts +3 -3
  20. package/dist/lib/surya/index.js +168 -170
  21. package/dist/lib/surya/resources.js +2 -5
  22. package/dist/lib/surya/types.d.ts +1 -1
  23. package/dist/lib/surya/types.js +1 -2
  24. package/dist/lib/surya/vendor/phoenix/ajax.js +6 -9
  25. package/dist/lib/surya/vendor/phoenix/channel.d.ts +1 -1
  26. package/dist/lib/surya/vendor/phoenix/channel.js +28 -31
  27. package/dist/lib/surya/vendor/phoenix/constants.js +11 -14
  28. package/dist/lib/surya/vendor/phoenix/index.d.ts +5 -5
  29. package/dist/lib/surya/vendor/phoenix/index.js +6 -13
  30. package/dist/lib/surya/vendor/phoenix/longpoll.js +11 -14
  31. package/dist/lib/surya/vendor/phoenix/presence.js +1 -4
  32. package/dist/lib/surya/vendor/phoenix/push.js +1 -4
  33. package/dist/lib/surya/vendor/phoenix/serializer.js +3 -5
  34. package/dist/lib/surya/vendor/phoenix/socket.d.ts +2 -2
  35. package/dist/lib/surya/vendor/phoenix/socket.js +32 -35
  36. package/dist/lib/surya/vendor/phoenix/timer.js +1 -4
  37. package/dist/lib/surya/vendor/phoenix/utils.js +1 -5
  38. package/dist/lib/teletype/auxiliary.d.ts +1 -1
  39. package/dist/lib/teletype/auxiliary.js +6 -13
  40. package/dist/lib/teletype/index.d.ts +4 -4
  41. package/dist/lib/teletype/index.js +18 -22
  42. package/dist/lib/utils.d.ts +1 -1
  43. package/dist/lib/utils.js +10 -10
  44. package/oclif.manifest.json +51 -31
  45. package/package.json +55 -62
  46. package/bin/dev +0 -17
  47. package/bin/oorja +0 -5
  48. package/bin/teletype +0 -7
  49. /package/bin/{oorja.cmd → run.cmd} +0 -0
package/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  TeleType
2
2
  =====
3
3
 
4
- cli tool that allows you to share your terminal online conveniently. Check out [teletype.oorja.io](https://teletype.oorja.io) - show off mad cli-fu, help a colleague, teach, or troubleshoot.
4
+ cli tool that allows you to share your terminal online conveniently. Check out [oorja.io](https://oorja.io) - show off mad cli-fu, help a colleague, teach, or troubleshoot.
5
5
 
6
6
  [![Version](https://img.shields.io/npm/v/oorja.svg)](https://npmjs.org/package/oorja)
7
7
  [![Downloads/week](https://img.shields.io/npm/dw/oorja.svg)](https://npmjs.org/package/oorja)
8
8
  [![Follow](https://img.shields.io/twitter/follow/oorja_app?style=social)](https://twitter.com/oorja_app)
9
9
 
10
+
10
11
  <p align="center">
11
12
  <img width="600" src="https://teletype.oorja.io/images/cli-demo.svg">
12
13
  </p>
@@ -17,6 +18,8 @@ cli tool that allows you to share your terminal online conveniently. Check out [
17
18
 
18
19
  Your stream can be view-only or collaboration enabled (command-line flag).
19
20
 
21
+
22
+
20
23
  <!-- toc -->
21
24
  * [Install and stream!](#install-and-stream)
22
25
  * [Commands](#commands)
@@ -24,7 +27,7 @@ Your stream can be view-only or collaboration enabled (command-line flag).
24
27
 
25
28
  # Install and stream!
26
29
 
27
- - You'll need Node 18.17.1 >. CLI is available via npm. <br />
30
+ - You'll need Node 18.18.0 >. CLI is available via npm. <br />
28
31
  <a href="https://nodejs.org/en/download/" target="_blank">
29
32
  You can setup node/npm from here.
30
33
  </a>
@@ -47,23 +50,46 @@ Any participant in the room can stream their terminal(s) i.e there can be multip
47
50
  For options: `teletype -h`
48
51
 
49
52
  **Note**
50
- This is the cli companion for [teletype.oorja.io](https://teletype.oorja.io) which is a privacy focussed collaboration tool with more features like voice, notes, and chat - [privacy policy](https://teletype.oorja.io/privacy_policy).
53
+ This is the cli companion for [oorja.io](https://oorja.io) which is a privacy focussed collaboration tool with more features like voice, notes, and chat - [privacy policy](https://oorja.io/privacy_policy).
51
54
  TLDR: Nothing stored on servers. Your data is end-to-end encrypted, synced between browsers (and cli) 🍻. No prying eyes.
52
55
 
53
56
  Like it ? [follow or tweet, tell your colleagues](https://twitter.com/oorja_app) 👩🏻‍💻
54
57
 
55
- Love it ? [please subscribe](https://teletype.oorja.io/subscription) 🖖
58
+ Love it ? [please subscribe](https://oorja.io/pricing) 🖖
56
59
 
57
60
  Feel free to open [issues](https://github.com/akshaykmr/TeleType/issues) for bugs, improvements, app-discussions, and anything else really.
58
61
 
59
- More ways to [contact](https://teletype.oorja.io/contact).
62
+ More ways to [contact](https://oorja.io/contact).
60
63
 
61
64
 
62
65
  # Commands
63
-
66
+ <!-- commands-disabled-->
67
+ * [`oorja help [COMMAND]`](#oorja-help-command)
64
68
  * [`oorja teletype [ROOM]`](#oorja-teletype-room)
69
+ * [`oorja tty [ROOM]`](#oorja-tty-room)
70
+ * [`oorja conf [KEY] [VALUE]`](#oorja-conf-key-value)
65
71
  * [`oorja signout`](#oorja-signout)
66
- * [`oorja help [COMMAND]`](#oorja-help-command)
72
+
73
+ ## `oorja help [COMMAND]`
74
+
75
+ Display help for oorja.
76
+
77
+ ```
78
+ USAGE
79
+ $ oorja help [COMMAND...] [-n]
80
+
81
+ ARGUMENTS
82
+ COMMAND... Command to show help for.
83
+
84
+ FLAGS
85
+ -n, --nested-commands Include all nested commands in the output.
86
+
87
+ DESCRIPTION
88
+ Display help for oorja.
89
+ ```
90
+
91
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
92
+
67
93
 
68
94
  ## `oorja teletype [ROOM]`
69
95
 
@@ -71,54 +97,72 @@ Launch a terminal streaming session in oorja.
71
97
 
72
98
  ```
73
99
  USAGE
74
- $ oorja teletype [ROOM]
75
-
76
- OPTIONS
77
- -h, --help show CLI help
100
+ $ oorja teletype [ROOM] [-h] [-s <value>] [-m] [-n]
78
101
 
79
- -m, --multiplex allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room
80
- participants. Off by default
102
+ FLAGS
103
+ -h, --help Show CLI help.
104
+ -m, --multiplex Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room
105
+ participants. Off by default
106
+ -n, --new_room Create new room
107
+ -s, --shell=<value> [default: /usr/bin/zsh] shell to use. e.g. bash, fish
81
108
 
82
- -s, --shell=shell [default: /usr/bin/fish] shell to use. e.g. bash, fish
109
+ DESCRIPTION
110
+ Launch a terminal streaming session in oorja.
83
111
 
84
112
  ALIASES
85
113
  $ oorja tty
86
114
 
87
115
  EXAMPLES
88
116
  $ teletype
89
- will prompt to choose streaming destination - existing room or create a new one.
90
-
117
+ Will prompt to choose streaming destination - existing room or create a new one.
91
118
 
92
119
  $ teletype 'https://oorja.io/rooms?id=foo#key'
93
- will stream to the room specified by secret link, you must have joined the room before streaming.
120
+ Will stream to the room specified by secret link, you must have joined the room before streaming.
94
121
 
95
-
96
- $ teletype -m 'https://oorja.io/rooms?id=foo#key'
122
+ $ teletype -m
97
123
  Will also allow room participants to write to your terminal!
98
124
  ```
99
125
 
126
+ _See code: [src/commands/teletype/index.ts](https://github.com/akshaykmr/teletype/blob/v1.11.2/src/commands/teletype/index.ts)_
127
+
100
128
  ## `oorja signout`
101
129
 
102
- sign-out and clear saved access token from any prior login. By default cli
103
- saves the token for any signed-in user (anonymous tokens aren't remembered).
104
- Any new command will ask for a token again after sign-out.
130
+ Sign-out of oorja. Clears saved auth-token
105
131
 
106
132
  ```
107
133
  USAGE
108
134
  $ oorja signout
135
+
136
+ DESCRIPTION
137
+ Sign-out of oorja. Clears saved auth-token
109
138
  ```
110
139
 
111
- ## `oorja help [COMMAND]`
140
+ _See code: [src/commands/signout.ts](https://github.com/akshaykmr/teletype/blob/v1.11.2/src/commands/signout.ts)_
112
141
 
113
- display help for oorja
142
+ ## `oorja conf [KEY] [VALUE]`
143
+
144
+ manage configuration (for setting access tokens and env vars)
114
145
 
115
146
  ```
116
147
  USAGE
117
- $ oorja help [COMMAND]
148
+ $ oorja conf [KEY] [VALUE] [-h] [-k <value>] [-v <value>] [-d] [-p <value>] [-n <value>] [-d <value>]
118
149
 
119
150
  ARGUMENTS
120
- COMMAND command to show help for
121
-
122
- OPTIONS
123
- --all see all commands in CLI
151
+ KEY key of the config
152
+ VALUE value of the config
153
+
154
+ FLAGS
155
+ -d, --cwd=<value> config file location
156
+ -d, --delete delete?
157
+ -h, --help show CLI help
158
+ -k, --key=<value> key of the config
159
+ -n, --name=<value> config file name
160
+ -p, --project=<value> project name
161
+ -v, --value=<value> value of the config
162
+
163
+ DESCRIPTION
164
+ manage configuration
124
165
  ```
166
+
167
+ _See code: [conf-cli](https://github.com/natzcam/conf-cli/blob/v0.1.9/src/commands/conf.ts)_
168
+ <!-- commandsstop-disabled -->
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S node --trace-warnings --loader ts-node/esm --no-warnings=ExperimentalWarning
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({development: true, dir: import.meta.url})
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+
3
+ process.argv.splice(2, 0, 'teletype')
4
+
5
+ import {execute} from '@oclif/core'
6
+
7
+ await execute({dir: import.meta.url})
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SignOut = void 0;
4
- const core_1 = require("@oclif/core");
5
- const config_1 = require("../lib/config");
6
- class SignOut extends core_1.Command {
1
+ import { Command } from "@oclif/core";
2
+ import { determineENV, setENVAccessToken } from "../lib/config.js";
3
+ export class SignOut extends Command {
4
+ static description = `Sign-out of oorja. Clears saved auth-token`;
7
5
  async run() {
8
- const env = (0, config_1.determineENV)();
9
- (0, config_1.setENVAccessToken)(env, "");
6
+ const env = determineENV();
7
+ setENVAccessToken(env, "");
10
8
  console.log("Sign-out complete");
11
9
  }
12
10
  }
13
- exports.SignOut = SignOut;
14
- SignOut.description = `Sign-out of oorja. Clears saved auth-token`;
@@ -4,13 +4,13 @@ export default class TeleTypeCommand extends Command {
4
4
  static description: string;
5
5
  static examples: string[];
6
6
  static flags: {
7
- help: import("@oclif/core/lib/interfaces").BooleanFlag<void>;
8
- shell: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
9
- multiplex: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
10
- new_room: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
+ help: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<void>;
8
+ shell: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ multiplex: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
+ new_room: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
11
  };
12
12
  static args: {
13
- room: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
13
+ room: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
14
14
  };
15
15
  run(): Promise<void>;
16
16
  private streamToLink;
@@ -1,15 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const { Select } = require("enquirer");
4
- const core_1 = require("@oclif/core");
5
- const ora = require("ora");
6
- const os = require("os");
7
- const chalk = require("chalk");
8
- const config_1 = require("../../lib/config");
9
- const oorja_1 = require("../../lib/oorja");
10
- const utils_1 = require("../../lib/utils");
1
+ import inquirer from 'inquirer';
2
+ import { Command, Flags, Args } from "@oclif/core";
3
+ import ora from "ora";
4
+ import * as os from "os";
5
+ import chalk from "chalk";
6
+ import { ROOM_LINK_SAMPLE } from "../../lib/config.js";
7
+ import { getApp } from "../../lib/oorja/index.js";
8
+ import { promptRoomLink } from "../../lib/utils.js";
11
9
  const DEFAULT_SHELL = os.platform() === "win32" ? "powershell.exe" : process.env.SHELL || "bash";
12
- class TeleTypeCommand extends core_1.Command {
10
+ export default class TeleTypeCommand extends Command {
11
+ static aliases = ["tty"];
12
+ static description = `Launch a terminal streaming session in oorja.`;
13
+ static examples = [
14
+ `${chalk.blueBright("$ teletype")}
15
+ Will prompt to choose streaming destination - existing room or create a new one.
16
+
17
+ `,
18
+ `${chalk.blueBright(`$ teletype '${ROOM_LINK_SAMPLE}'`)}
19
+ Will stream to the room specified by secret link, you must have joined the room before streaming.
20
+
21
+ `,
22
+ `${chalk.blueBright("$ teletype -m")}
23
+ Will also allow room participants to write to your terminal!
24
+
25
+ `,
26
+ ];
27
+ static flags = {
28
+ help: Flags.help({ char: "h" }),
29
+ shell: Flags.string({
30
+ char: "s",
31
+ description: "shell to use. e.g. bash, fish",
32
+ default: DEFAULT_SHELL,
33
+ }),
34
+ multiplex: Flags.boolean({
35
+ char: "m",
36
+ description: "Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default",
37
+ default: false,
38
+ }),
39
+ new_room: Flags.boolean({
40
+ char: "n",
41
+ description: "Create new room",
42
+ default: false,
43
+ }),
44
+ };
45
+ static args = {
46
+ room: Args.string({})
47
+ };
13
48
  async run() {
14
49
  const { args, flags: { shell, multiplex, new_room }, } = await this.parse(TeleTypeCommand);
15
50
  if (args.room) {
@@ -24,11 +59,14 @@ class TeleTypeCommand extends core_1.Command {
24
59
  // room not known, prompt
25
60
  const ROOM = "To an existing room (you have the room link)";
26
61
  const NEW = "New room";
27
- const answer = await new Select({
28
- name: "",
29
- message: "Choose streaming destination",
30
- choices: [NEW, ROOM],
31
- }).run();
62
+ const { answer } = await inquirer.prompt([
63
+ {
64
+ type: 'list',
65
+ name: 'answer',
66
+ message: 'Choose streaming destination',
67
+ choices: [NEW, ROOM],
68
+ }
69
+ ]);
32
70
  switch (answer) {
33
71
  case ROOM:
34
72
  await this.streamToLink({ shell, multiplex });
@@ -40,18 +78,18 @@ class TeleTypeCommand extends core_1.Command {
40
78
  process.exit(0);
41
79
  }
42
80
  async streamToLink(options) {
43
- const roomLink = options.roomLink || (await (0, utils_1.promptRoomLink)());
81
+ const roomLink = options.roomLink || (await promptRoomLink());
44
82
  if (!roomLink) {
45
83
  console.log(chalk.redBright("Room link not provided :("));
46
84
  process.exit();
47
85
  }
48
- const app = await (0, oorja_1.getApp)({ roomLink });
86
+ const app = await getApp({ roomLink });
49
87
  const roomKey = app.getRoomKey(roomLink);
50
88
  this.clearstdin();
51
89
  await app.teletype({ roomKey, ...options, process });
52
90
  }
53
91
  async createRoomAndStream({ shell, multiplex, }) {
54
- const app = await (0, oorja_1.getApp)();
92
+ const app = await getApp();
55
93
  const spinner = ora({
56
94
  text: chalk.bold("Creating room with TeleType app"),
57
95
  discardStdin: false,
@@ -87,41 +125,3 @@ class TeleTypeCommand extends core_1.Command {
87
125
  process.stdin.resume(); // FIXME: investigate weird quirk. stdin hangs if this is not present
88
126
  }
89
127
  }
90
- exports.default = TeleTypeCommand;
91
- TeleTypeCommand.aliases = ["tty"];
92
- TeleTypeCommand.description = `Launch a terminal streaming session in oorja.`;
93
- TeleTypeCommand.examples = [
94
- `${chalk.blueBright("$ teletype")}
95
- Will prompt to choose streaming destination - existing room or create a new one.
96
-
97
- `,
98
- `${chalk.blueBright(`$ teletype '${config_1.ROOM_LINK_SAMPLE}'`)}
99
- Will stream to the room specified by secret link, you must have joined the room before streaming.
100
-
101
- `,
102
- `${chalk.blueBright("$ teletype -m")}
103
- Will also allow room participants to write to your terminal!
104
-
105
- `,
106
- ];
107
- TeleTypeCommand.flags = {
108
- help: core_1.Flags.help({ char: "h" }),
109
- shell: core_1.Flags.string({
110
- char: "s",
111
- description: "shell to use. e.g. bash, fish",
112
- default: DEFAULT_SHELL,
113
- }),
114
- multiplex: core_1.Flags.boolean({
115
- char: "m",
116
- description: "Allows room users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust room participants. Off by default",
117
- default: false,
118
- }),
119
- new_room: core_1.Flags.boolean({
120
- char: "n",
121
- description: "Create new room",
122
- default: false,
123
- }),
124
- };
125
- TeleTypeCommand.args = {
126
- room: core_1.Args.string({})
127
- };
package/dist/index.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- var core_1 = require("@oclif/core");
5
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
1
+ export { run } from '@oclif/core';
@@ -1,6 +1,8 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  import { URL } from "url";
2
- export declare const CLI_VERSION = 1.9;
3
- export declare const config: any;
3
+ export declare const CLI_VERSION = 1.91;
4
+ import Conf from "conf";
5
+ export declare const config: Conf<string>;
4
6
  export type env = "staging" | "local" | "prod" | "prod-teletype";
5
7
  export type SuryaConfig = {
6
8
  host: string;
@@ -1,14 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- const chalk = require("chalk");
5
- exports.CLI_VERSION = 1.90;
6
- const Conf = require("conf");
7
- exports.config = new Conf({
1
+ import chalk from "chalk";
2
+ export const CLI_VERSION = 1.91;
3
+ import Conf from "conf";
4
+ export const config = new Conf({
8
5
  projectName: "oorja",
9
- projectVersion: exports.CLI_VERSION,
6
+ schema: {
7
+ "env": {
8
+ type: 'string'
9
+ },
10
+ "staging-access-token": {
11
+ type: 'string'
12
+ },
13
+ "local-access-token": {
14
+ type: 'string'
15
+ },
16
+ "prod-access-token": {
17
+ type: 'string'
18
+ },
19
+ "prod-teletype-access-token": {
20
+ type: 'string'
21
+ },
22
+ }
10
23
  });
11
- const getSuryaConfig = (env) => {
24
+ export const getSuryaConfig = (env) => {
12
25
  const getHost = (env) => {
13
26
  switch (env) {
14
27
  case "local":
@@ -22,16 +35,15 @@ const getSuryaConfig = (env) => {
22
35
  };
23
36
  return {
24
37
  host: getHost(env),
25
- token: (0, exports.getENVAccessToken)(env),
38
+ token: getENVAccessToken(env),
26
39
  enableTLS: env !== "local",
27
40
  };
28
41
  };
29
- exports.getSuryaConfig = getSuryaConfig;
30
- exports.ROOM_LINK_SAMPLE = "https://oorja.io/rooms?id=foo#key";
31
- exports.INVALID_ROOM_LINK_MESSAGE = `${chalk.redBright("invalid url ")}🤔. It should look like: ${chalk.blue(exports.ROOM_LINK_SAMPLE)}`;
32
- const determineENV = (roomURL) => {
42
+ export const ROOM_LINK_SAMPLE = "https://oorja.io/rooms?id=foo#key";
43
+ export const INVALID_ROOM_LINK_MESSAGE = `${chalk.redBright("invalid url ")}🤔. It should look like: ${chalk.blue(ROOM_LINK_SAMPLE)}`;
44
+ export const determineENV = (roomURL) => {
33
45
  if (!roomURL)
34
- return exports.config.get("env") || "prod-teletype";
46
+ return config.get("env") || "prod-teletype";
35
47
  switch (roomURL.host) {
36
48
  case "oorja.io":
37
49
  return "prod";
@@ -42,20 +54,17 @@ const determineENV = (roomURL) => {
42
54
  case "localhost:3000":
43
55
  return "local";
44
56
  default:
45
- console.error(exports.INVALID_ROOM_LINK_MESSAGE);
57
+ console.error(INVALID_ROOM_LINK_MESSAGE);
46
58
  process.exit(1);
47
59
  }
48
60
  };
49
- exports.determineENV = determineENV;
50
- const getENVAccessToken = (env) => {
51
- return exports.config.get(`${env}-access-token`);
61
+ export const getENVAccessToken = (env) => {
62
+ return config.get(`${env}-access-token`) || "";
52
63
  };
53
- exports.getENVAccessToken = getENVAccessToken;
54
- const setENVAccessToken = (env, token) => {
55
- exports.config.set(`${env}-access-token`, token);
64
+ export const setENVAccessToken = (env, token) => {
65
+ config.set(`${env}-access-token`, token);
56
66
  };
57
- exports.setENVAccessToken = setENVAccessToken;
58
- const getoorjaConfig = (env) => {
67
+ export const getoorjaConfig = (env) => {
59
68
  let host;
60
69
  switch (env) {
61
70
  case "local":
@@ -76,4 +85,3 @@ const getoorjaConfig = (env) => {
76
85
  enableTLS: env !== "local",
77
86
  };
78
87
  };
79
- exports.getoorjaConfig = getoorjaConfig;
@@ -1,5 +1,5 @@
1
- /// <reference types="node" />
2
- import { RoomKey } from "./surya/types";
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { RoomKey } from "./surya/types.js";
3
3
  export type EncryptedPayload = {
4
4
  iv: Buffer | Uint8Array;
5
5
  data: Buffer | Uint8Array;
@@ -1,40 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decrypt = exports.encrypt = exports.importKey = exports.exportKey = exports.createRoomKey = void 0;
4
- const crypto = require("crypto");
5
- const msgpack_1 = require("@msgpack/msgpack");
1
+ import * as crypto from "crypto";
2
+ import { encode, decode } from "@msgpack/msgpack";
6
3
  const ALG = "aes-128-gcm";
7
4
  const KEY_SIZE = 16; // 128 bit AES
8
5
  const AUTH_TAG_LEN = 16;
9
- const createRoomKey = (roomId) => ({
6
+ export const createRoomKey = (roomId) => ({
10
7
  roomId,
11
8
  key: createAESEncryptionKey(),
12
9
  });
13
- exports.createRoomKey = createRoomKey;
14
10
  const createAESEncryptionKey = () => crypto.randomBytes(KEY_SIZE);
15
- const exportKey = (key) => key.toString("base64");
16
- exports.exportKey = exportKey;
17
- const importKey = (exportedKey) => Buffer.from(exportedKey, "base64");
18
- exports.importKey = importKey;
11
+ export const exportKey = (key) => key.toString("base64");
12
+ export const importKey = (exportedKey) => Buffer.from(exportedKey, "base64");
19
13
  const createIV = () => crypto.randomBytes(16);
20
- const encrypt = (data, roomKey) => {
14
+ export const encrypt = (data, roomKey) => {
21
15
  const iv = createIV();
22
16
  const cipher = crypto.createCipheriv(ALG, roomKey.key, iv);
23
17
  return {
24
18
  iv,
25
19
  data: Buffer.concat([
26
- cipher.update((0, msgpack_1.encode)(data)),
20
+ cipher.update(encode(data)),
27
21
  cipher.final(),
28
22
  cipher.getAuthTag(),
29
23
  ]),
30
24
  };
31
25
  };
32
- exports.encrypt = encrypt;
33
- const decrypt = (payload, roomKey) => {
26
+ export const decrypt = (payload, roomKey) => {
34
27
  const data = payload.data.slice(0, payload.data.length - AUTH_TAG_LEN);
35
28
  const authTag = payload.data.slice(payload.data.length - AUTH_TAG_LEN);
36
29
  const decipher = crypto.createDecipheriv(ALG, roomKey.key, payload.iv);
37
30
  decipher.setAuthTag(authTag);
38
- return (0, msgpack_1.decode)(Buffer.concat([decipher.update(data), decipher.final()]));
31
+ return decode(Buffer.concat([decipher.update(data), decipher.final()]));
39
32
  };
40
- exports.decrypt = decrypt;
@@ -1,7 +1,7 @@
1
- import { oorjaConfig } from "../config";
2
- import { User, RoomKey } from "../surya/types";
3
- import { TeletypeOptions } from "../teletype";
4
- import { CreateRoomOptions, SuryaClient } from "../surya";
1
+ import { oorjaConfig } from "../config.js";
2
+ import { User, RoomKey } from "../surya/types.js";
3
+ import { TeletypeOptions } from "../teletype/index.js";
4
+ import { CreateRoomOptions, SuryaClient } from "../surya/index.js";
5
5
  export declare class InvalidRoomLink extends Error {
6
6
  }
7
7
  declare class OORJA {
@@ -10,7 +10,7 @@ declare class OORJA {
10
10
  user: User;
11
11
  constructor(config: oorjaConfig, suryaClient: SuryaClient, user: User);
12
12
  createRoom: (options: CreateRoomOptions) => Promise<{
13
- room: import("../surya/types").Room;
13
+ room: import("../surya/types.js").Room;
14
14
  roomKey: RoomKey;
15
15
  }>;
16
16
  linkForRoom: (roomKey: RoomKey) => string;