oorja 1.9.1 → 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.
- package/README.md +73 -29
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/bin/teletype.js +7 -0
- package/dist/commands/signout.js +6 -10
- package/dist/commands/teletype/index.d.ts +5 -5
- package/dist/commands/teletype/index.js +57 -57
- package/dist/index.js +1 -5
- package/dist/lib/config.d.ts +4 -2
- package/dist/lib/config.js +33 -25
- package/dist/lib/encryption.d.ts +2 -2
- package/dist/lib/encryption.js +9 -17
- package/dist/lib/oorja/index.d.ts +5 -5
- package/dist/lib/oorja/index.js +43 -45
- package/dist/lib/oorja/preflight.d.ts +3 -3
- package/dist/lib/oorja/preflight.js +41 -40
- package/dist/lib/surya/errors.js +3 -9
- package/dist/lib/surya/index.d.ts +3 -3
- package/dist/lib/surya/index.js +168 -170
- package/dist/lib/surya/resources.js +2 -5
- package/dist/lib/surya/types.d.ts +1 -1
- package/dist/lib/surya/types.js +1 -2
- package/dist/lib/surya/vendor/phoenix/ajax.js +6 -9
- package/dist/lib/surya/vendor/phoenix/channel.d.ts +1 -1
- package/dist/lib/surya/vendor/phoenix/channel.js +28 -31
- package/dist/lib/surya/vendor/phoenix/constants.js +11 -14
- package/dist/lib/surya/vendor/phoenix/index.d.ts +5 -5
- package/dist/lib/surya/vendor/phoenix/index.js +6 -13
- package/dist/lib/surya/vendor/phoenix/longpoll.js +11 -14
- package/dist/lib/surya/vendor/phoenix/presence.js +1 -4
- package/dist/lib/surya/vendor/phoenix/push.js +1 -4
- package/dist/lib/surya/vendor/phoenix/serializer.js +3 -5
- package/dist/lib/surya/vendor/phoenix/socket.d.ts +2 -2
- package/dist/lib/surya/vendor/phoenix/socket.js +32 -35
- package/dist/lib/surya/vendor/phoenix/timer.js +1 -4
- package/dist/lib/surya/vendor/phoenix/utils.js +1 -5
- package/dist/lib/teletype/auxiliary.d.ts +1 -1
- package/dist/lib/teletype/auxiliary.js +6 -13
- package/dist/lib/teletype/index.d.ts +4 -4
- package/dist/lib/teletype/index.js +18 -22
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +10 -10
- package/oclif.manifest.json +3 -3
- package/package.json +55 -64
- package/bin/dev +0 -17
- package/bin/oorja +0 -5
- package/bin/teletype +0 -7
- /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 [
|
|
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
|
[](https://npmjs.org/package/oorja)
|
|
7
7
|
[](https://npmjs.org/package/oorja)
|
|
8
8
|
[](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.
|
|
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 [
|
|
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://
|
|
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://
|
|
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
|
-
|
|
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
|
-
|
|
80
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
140
|
+
_See code: [src/commands/signout.ts](https://github.com/akshaykmr/teletype/blob/v1.11.2/src/commands/signout.ts)_
|
|
112
141
|
|
|
113
|
-
|
|
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
|
|
148
|
+
$ oorja conf [KEY] [VALUE] [-h] [-k <value>] [-v <value>] [-d] [-p <value>] [-n <value>] [-d <value>]
|
|
118
149
|
|
|
119
150
|
ARGUMENTS
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
package/bin/dev.js
ADDED
package/bin/run.js
ADDED
package/bin/teletype.js
ADDED
package/dist/commands/signout.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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 =
|
|
9
|
-
|
|
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").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").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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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';
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
1
2
|
import { URL } from "url";
|
|
2
|
-
export declare const CLI_VERSION = 1.
|
|
3
|
-
|
|
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;
|
package/dist/lib/config.js
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
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
|
-
|
|
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:
|
|
38
|
+
token: getENVAccessToken(env),
|
|
26
39
|
enableTLS: env !== "local",
|
|
27
40
|
};
|
|
28
41
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
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(
|
|
57
|
+
console.error(INVALID_ROOM_LINK_MESSAGE);
|
|
46
58
|
process.exit(1);
|
|
47
59
|
}
|
|
48
60
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return exports.config.get(`${env}-access-token`);
|
|
61
|
+
export const getENVAccessToken = (env) => {
|
|
62
|
+
return config.get(`${env}-access-token`) || "";
|
|
52
63
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
exports.config.set(`${env}-access-token`, token);
|
|
64
|
+
export const setENVAccessToken = (env, token) => {
|
|
65
|
+
config.set(`${env}-access-token`, token);
|
|
56
66
|
};
|
|
57
|
-
|
|
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;
|
package/dist/lib/encryption.d.ts
CHANGED
|
@@ -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;
|
package/dist/lib/encryption.js
CHANGED
|
@@ -1,40 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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(
|
|
20
|
+
cipher.update(encode(data)),
|
|
27
21
|
cipher.final(),
|
|
28
22
|
cipher.getAuthTag(),
|
|
29
23
|
]),
|
|
30
24
|
};
|
|
31
25
|
};
|
|
32
|
-
|
|
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
|
|
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;
|