oorja 1.11.4 → 2.0.1
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 +14 -52
- package/dist/commands/signout.d.ts +1 -1
- package/dist/commands/signout.js +4 -4
- package/dist/commands/teletype/index.d.ts +7 -6
- package/dist/commands/teletype/index.js +49 -47
- package/dist/lib/config.d.ts +7 -10
- package/dist/lib/config.js +29 -49
- package/dist/lib/{surya → connect}/index.d.ts +8 -8
- package/dist/lib/{surya → connect}/index.js +39 -36
- package/dist/lib/{surya → connect}/resources.js +2 -2
- package/dist/lib/{surya → connect}/types.d.ts +1 -3
- package/dist/lib/encryption.d.ts +2 -3
- package/dist/lib/encryption.js +6 -10
- package/dist/lib/oorja/client.d.ts +3 -0
- package/dist/lib/oorja/client.js +52 -0
- package/dist/lib/oorja/index.d.ts +7 -7
- package/dist/lib/oorja/index.js +40 -29
- package/dist/lib/oorja/preflight.d.ts +8 -8
- package/dist/lib/oorja/preflight.js +45 -41
- package/dist/lib/teletype/auxiliary.d.ts +2 -2
- package/dist/lib/teletype/auxiliary.js +5 -5
- package/dist/lib/teletype/index.d.ts +3 -4
- package/dist/lib/teletype/index.js +16 -16
- package/dist/lib/utils.js +5 -5
- package/oclif.manifest.json +11 -10
- package/package.json +22 -18
- package/dist/lib/surya/vendor/phoenix/ajax.d.ts +0 -8
- package/dist/lib/surya/vendor/phoenix/ajax.js +0 -82
- package/dist/lib/surya/vendor/phoenix/channel.d.ts +0 -154
- package/dist/lib/surya/vendor/phoenix/channel.js +0 -308
- package/dist/lib/surya/vendor/phoenix/constants.d.ts +0 -33
- package/dist/lib/surya/vendor/phoenix/constants.js +0 -29
- package/dist/lib/surya/vendor/phoenix/index.d.ts +0 -199
- package/dist/lib/surya/vendor/phoenix/index.js +0 -200
- package/dist/lib/surya/vendor/phoenix/longpoll.d.ts +0 -12
- package/dist/lib/surya/vendor/phoenix/longpoll.js +0 -126
- package/dist/lib/surya/vendor/phoenix/presence.d.ts +0 -44
- package/dist/lib/surya/vendor/phoenix/presence.js +0 -152
- package/dist/lib/surya/vendor/phoenix/push.d.ts +0 -57
- package/dist/lib/surya/vendor/phoenix/push.js +0 -122
- package/dist/lib/surya/vendor/phoenix/serializer.d.ts +0 -53
- package/dist/lib/surya/vendor/phoenix/serializer.js +0 -100
- package/dist/lib/surya/vendor/phoenix/socket.d.ts +0 -222
- package/dist/lib/surya/vendor/phoenix/socket.js +0 -541
- package/dist/lib/surya/vendor/phoenix/timer.d.ts +0 -25
- package/dist/lib/surya/vendor/phoenix/timer.js +0 -40
- package/dist/lib/surya/vendor/phoenix/utils.d.ts +0 -1
- package/dist/lib/surya/vendor/phoenix/utils.js +0 -11
- /package/dist/lib/{surya → connect}/errors.d.ts +0 -0
- /package/dist/lib/{surya → connect}/errors.js +0 -0
- /package/dist/lib/{surya → connect}/resources.d.ts +0 -0
- /package/dist/lib/{surya → connect}/types.js +0 -0
package/README.md
CHANGED
|
@@ -19,7 +19,6 @@ cli tool that allows you to share your terminal online conveniently. Check out [
|
|
|
19
19
|
Your stream can be view-only or collaboration enabled (command-line flag).
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
23
22
|
<!-- toc -->
|
|
24
23
|
* [Install and stream!](#install-and-stream)
|
|
25
24
|
* [Commands](#commands)
|
|
@@ -27,7 +26,7 @@ Your stream can be view-only or collaboration enabled (command-line flag).
|
|
|
27
26
|
|
|
28
27
|
# Install and stream!
|
|
29
28
|
|
|
30
|
-
- You'll need Node
|
|
29
|
+
- You'll need Node 22.10.0 >. CLI is available via npm. <br />
|
|
31
30
|
<a href="https://nodejs.org/en/download/" target="_blank">
|
|
32
31
|
You can setup node/npm from here.
|
|
33
32
|
</a>
|
|
@@ -50,24 +49,20 @@ Any participant in the room can stream their terminal(s) i.e there can be multip
|
|
|
50
49
|
For options: `teletype -h`
|
|
51
50
|
|
|
52
51
|
**Note**
|
|
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/
|
|
54
|
-
TLDR:
|
|
52
|
+
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).
|
|
53
|
+
TLDR: Your data is end-to-end encrypted, no prying eyes 🍻.
|
|
55
54
|
|
|
56
55
|
Like it ? [follow or tweet, tell your colleagues](https://twitter.com/oorja_app) 👩🏻💻
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Feel free to open [issues](https://github.com/akshaykmr/TeleType/issues) for bugs, improvements, app-discussions, and anything else really.
|
|
57
|
+
Open [issues](https://github.com/akshaykmr/TeleType/issues).
|
|
61
58
|
|
|
62
59
|
More ways to [contact](https://oorja.io/contact).
|
|
63
60
|
|
|
64
61
|
|
|
65
62
|
# Commands
|
|
66
|
-
<!-- commands-disabled-->
|
|
63
|
+
<!-- commands-disabled -->
|
|
67
64
|
* [`oorja help [COMMAND]`](#oorja-help-command)
|
|
68
|
-
* [`oorja teletype [
|
|
69
|
-
* [`oorja tty [ROOM]`](#oorja-tty-room)
|
|
70
|
-
* [`oorja conf [KEY] [VALUE]`](#oorja-conf-key-value)
|
|
65
|
+
* [`oorja teletype [SPACE]`](#oorja-teletype-space)
|
|
71
66
|
* [`oorja signout`](#oorja-signout)
|
|
72
67
|
|
|
73
68
|
## `oorja help [COMMAND]`
|
|
@@ -88,22 +83,19 @@ DESCRIPTION
|
|
|
88
83
|
Display help for oorja.
|
|
89
84
|
```
|
|
90
85
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## `oorja teletype [ROOM]`
|
|
86
|
+
## `oorja teletype [SPACE_URL]`
|
|
95
87
|
|
|
96
88
|
Launch a terminal streaming session in oorja.
|
|
97
89
|
|
|
98
90
|
```
|
|
99
91
|
USAGE
|
|
100
|
-
$ oorja teletype [
|
|
92
|
+
$ oorja teletype [SPACE_URL] [-h] [-s <value>] [-m] [-n]
|
|
101
93
|
|
|
102
94
|
FLAGS
|
|
103
95
|
-h, --help Show CLI help.
|
|
104
|
-
-m, --multiplex Allows
|
|
96
|
+
-m, --multiplex Allows users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust space
|
|
105
97
|
participants. Off by default
|
|
106
|
-
-n, --
|
|
98
|
+
-n, --new_space Create new space
|
|
107
99
|
-s, --shell=<value> [default: /usr/bin/zsh] shell to use. e.g. bash, fish
|
|
108
100
|
|
|
109
101
|
DESCRIPTION
|
|
@@ -114,17 +106,15 @@ ALIASES
|
|
|
114
106
|
|
|
115
107
|
EXAMPLES
|
|
116
108
|
$ teletype
|
|
117
|
-
Will prompt to choose streaming destination - existing
|
|
109
|
+
Will prompt to choose streaming destination - existing space or create a new one.
|
|
118
110
|
|
|
119
|
-
$ teletype 'https://oorja.io/
|
|
120
|
-
Will stream to the
|
|
111
|
+
$ teletype 'https://oorja.io/spaces?id=foo#key'
|
|
112
|
+
Will stream to the space specified by secret link, you must have joined the space before streaming.
|
|
121
113
|
|
|
122
114
|
$ teletype -m
|
|
123
|
-
Will also allow
|
|
115
|
+
Will also allow participants to write to your terminal!
|
|
124
116
|
```
|
|
125
117
|
|
|
126
|
-
_See code: [src/commands/teletype/index.ts](https://github.com/akshaykmr/teletype/blob/v1.11.2/src/commands/teletype/index.ts)_
|
|
127
|
-
|
|
128
118
|
## `oorja signout`
|
|
129
119
|
|
|
130
120
|
Sign-out of oorja. Clears saved auth-token
|
|
@@ -137,32 +127,4 @@ DESCRIPTION
|
|
|
137
127
|
Sign-out of oorja. Clears saved auth-token
|
|
138
128
|
```
|
|
139
129
|
|
|
140
|
-
_See code: [src/commands/signout.ts](https://github.com/akshaykmr/teletype/blob/v1.11.2/src/commands/signout.ts)_
|
|
141
|
-
|
|
142
|
-
## `oorja conf [KEY] [VALUE]`
|
|
143
|
-
|
|
144
|
-
manage configuration (for setting access tokens and env vars)
|
|
145
|
-
|
|
146
|
-
```
|
|
147
|
-
USAGE
|
|
148
|
-
$ oorja conf [KEY] [VALUE] [-h] [-k <value>] [-v <value>] [-d] [-p <value>] [-n <value>] [-d <value>]
|
|
149
|
-
|
|
150
|
-
ARGUMENTS
|
|
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
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
_See code: [conf-cli](https://github.com/natzcam/conf-cli/blob/v0.1.9/src/commands/conf.ts)_
|
|
168
130
|
<!-- commandsstop-disabled -->
|
package/dist/commands/signout.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Command } from
|
|
2
|
-
import { determineENV, setENVAccessToken } from
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
import { determineENV, setENVAccessToken } from '../lib/config.js';
|
|
3
3
|
export class SignOut extends Command {
|
|
4
4
|
static description = `Sign-out of oorja. Clears saved auth-token`;
|
|
5
5
|
async run() {
|
|
6
6
|
const env = determineENV();
|
|
7
|
-
setENVAccessToken(env,
|
|
8
|
-
console.log(
|
|
7
|
+
setENVAccessToken(env, '');
|
|
8
|
+
console.log('Sign-out complete');
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { Command } from
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
2
|
export default class TeleTypeCommand extends Command {
|
|
3
|
+
static order: number;
|
|
3
4
|
static aliases: string[];
|
|
4
5
|
static description: string;
|
|
5
6
|
static examples: string[];
|
|
6
7
|
static flags: {
|
|
7
|
-
help: import("@oclif/core/
|
|
8
|
-
shell: import("@oclif/core/
|
|
9
|
-
multiplex: import("@oclif/core/
|
|
10
|
-
|
|
8
|
+
help: import("@oclif/core/interfaces").BooleanFlag<void>;
|
|
9
|
+
shell: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
multiplex: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
new_space: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
12
|
};
|
|
12
13
|
static args: {
|
|
13
|
-
|
|
14
|
+
space: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
14
15
|
};
|
|
15
16
|
run(): Promise<void>;
|
|
16
17
|
private streamToLink;
|
|
@@ -1,74 +1,75 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
|
-
import { Command, Flags, Args } from
|
|
3
|
-
import ora from
|
|
4
|
-
import * as os from
|
|
5
|
-
import chalk from
|
|
6
|
-
import { ROOM_LINK_SAMPLE } from
|
|
7
|
-
import { getApp } from
|
|
8
|
-
import { promptRoomLink } from
|
|
9
|
-
const DEFAULT_SHELL = os.platform() ===
|
|
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';
|
|
9
|
+
const DEFAULT_SHELL = os.platform() === 'win32' ? 'powershell.exe' : process.env.SHELL || 'bash';
|
|
10
10
|
export default class TeleTypeCommand extends Command {
|
|
11
|
-
static
|
|
11
|
+
static order = 1;
|
|
12
|
+
static aliases = ['tty'];
|
|
12
13
|
static description = `Launch a terminal streaming session in oorja.`;
|
|
13
14
|
static examples = [
|
|
14
|
-
`${chalk.blueBright(
|
|
15
|
-
Will prompt to choose streaming destination - existing
|
|
15
|
+
`${chalk.blueBright('$ teletype')}
|
|
16
|
+
Will prompt to choose streaming destination - existing space or create a new one.
|
|
16
17
|
|
|
17
18
|
`,
|
|
18
19
|
`${chalk.blueBright(`$ teletype '${ROOM_LINK_SAMPLE}'`)}
|
|
19
|
-
Will stream to the
|
|
20
|
+
Will stream to the space specified by secret link, you must have joined the space before streaming.
|
|
20
21
|
|
|
21
22
|
`,
|
|
22
|
-
`${chalk.blueBright(
|
|
23
|
-
Will also allow
|
|
23
|
+
`${chalk.blueBright('$ teletype -m')}
|
|
24
|
+
Will also allow participants to write to your terminal!
|
|
24
25
|
|
|
25
26
|
`,
|
|
26
27
|
];
|
|
27
28
|
static flags = {
|
|
28
|
-
help: Flags.help({ char:
|
|
29
|
+
help: Flags.help({ char: 'h' }),
|
|
29
30
|
shell: Flags.string({
|
|
30
|
-
char:
|
|
31
|
-
description:
|
|
31
|
+
char: 's',
|
|
32
|
+
description: 'shell to use. e.g. bash, fish',
|
|
32
33
|
default: DEFAULT_SHELL,
|
|
33
34
|
}),
|
|
34
35
|
multiplex: Flags.boolean({
|
|
35
|
-
char:
|
|
36
|
-
description:
|
|
36
|
+
char: 'm',
|
|
37
|
+
description: 'Allows users to WRITE TO YOUR SHELL i.e enables collaboration mode. Make sure you trust space participants. Off by default',
|
|
37
38
|
default: false,
|
|
38
39
|
}),
|
|
39
|
-
|
|
40
|
-
char:
|
|
41
|
-
description:
|
|
40
|
+
new_space: Flags.boolean({
|
|
41
|
+
char: 'n',
|
|
42
|
+
description: 'Create new space',
|
|
42
43
|
default: false,
|
|
43
44
|
}),
|
|
44
45
|
};
|
|
45
46
|
static args = {
|
|
46
|
-
|
|
47
|
+
space: Args.string({}),
|
|
47
48
|
};
|
|
48
49
|
async run() {
|
|
49
|
-
const { args, flags: { shell, multiplex,
|
|
50
|
-
if (args.
|
|
51
|
-
await this.streamToLink({ shell, multiplex, roomLink: args.
|
|
50
|
+
const { args, flags: { shell, multiplex, new_space }, } = await this.parse(TeleTypeCommand);
|
|
51
|
+
if (args.space) {
|
|
52
|
+
await this.streamToLink({ shell, multiplex, roomLink: args.space });
|
|
52
53
|
process.exit(0);
|
|
53
54
|
}
|
|
54
|
-
if (
|
|
55
|
+
if (new_space) {
|
|
55
56
|
await this.createRoomAndStream({ shell, multiplex });
|
|
56
57
|
process.exit(0);
|
|
57
58
|
}
|
|
58
|
-
console.log(
|
|
59
|
+
console.log('(use -h for description and options) \n');
|
|
59
60
|
// room not known, prompt
|
|
60
|
-
const
|
|
61
|
-
const NEW =
|
|
61
|
+
const SPACE = 'To an existing space (you have the link)';
|
|
62
|
+
const NEW = 'New space';
|
|
62
63
|
const { answer } = await inquirer.prompt([
|
|
63
64
|
{
|
|
64
65
|
type: 'list',
|
|
65
66
|
name: 'answer',
|
|
66
67
|
message: 'Choose streaming destination',
|
|
67
|
-
choices: [NEW,
|
|
68
|
-
}
|
|
68
|
+
choices: [NEW, SPACE],
|
|
69
|
+
},
|
|
69
70
|
]);
|
|
70
71
|
switch (answer) {
|
|
71
|
-
case
|
|
72
|
+
case SPACE:
|
|
72
73
|
await this.streamToLink({ shell, multiplex });
|
|
73
74
|
break;
|
|
74
75
|
case NEW:
|
|
@@ -80,7 +81,7 @@ Will also allow room participants to write to your terminal!
|
|
|
80
81
|
async streamToLink(options) {
|
|
81
82
|
const roomLink = options.roomLink || (await promptRoomLink());
|
|
82
83
|
if (!roomLink) {
|
|
83
|
-
console.log(chalk.redBright(
|
|
84
|
+
console.log(chalk.redBright('Space link not provided :('));
|
|
84
85
|
process.exit();
|
|
85
86
|
}
|
|
86
87
|
const app = await getApp({ roomLink });
|
|
@@ -88,35 +89,36 @@ Will also allow room participants to write to your terminal!
|
|
|
88
89
|
this.clearstdin();
|
|
89
90
|
await app.teletype({ roomKey, ...options, process });
|
|
90
91
|
}
|
|
91
|
-
async createRoomAndStream({ shell, multiplex
|
|
92
|
+
async createRoomAndStream({ shell, multiplex }) {
|
|
92
93
|
const app = await getApp();
|
|
93
94
|
const spinner = ora({
|
|
94
|
-
text: chalk.bold(
|
|
95
|
+
text: chalk.bold('Creating space with TeleType app'),
|
|
95
96
|
discardStdin: false,
|
|
96
97
|
}).start();
|
|
97
98
|
const { roomKey } = await app
|
|
98
99
|
.createRoom({
|
|
99
|
-
roomName:
|
|
100
|
+
roomName: 'Untitled Space',
|
|
100
101
|
apps: {
|
|
101
|
-
defaultFocus:
|
|
102
|
+
defaultFocus: '39',
|
|
102
103
|
appList: [
|
|
103
|
-
{ appId:
|
|
104
|
-
{ appId:
|
|
105
|
-
{ appId:
|
|
106
|
-
{ appId:
|
|
107
|
-
{ appId:
|
|
108
|
-
{ appId:
|
|
104
|
+
{ appId: '31', config: {} },
|
|
105
|
+
{ appId: '100', config: {} },
|
|
106
|
+
{ appId: '40', config: {} },
|
|
107
|
+
{ appId: '90', config: {} },
|
|
108
|
+
{ appId: '39', config: {} },
|
|
109
|
+
{ appId: '102', config: {} },
|
|
110
|
+
{ appId: '103', config: {} },
|
|
109
111
|
],
|
|
110
112
|
},
|
|
111
113
|
})
|
|
112
114
|
.catch((e) => {
|
|
113
|
-
console.log(
|
|
115
|
+
console.log('Failed to create space.');
|
|
114
116
|
process.exit(9);
|
|
115
117
|
});
|
|
116
|
-
spinner.succeed(chalk.bold(
|
|
118
|
+
spinner.succeed(chalk.bold('Space created')).clear();
|
|
117
119
|
const link = app.linkForRoom(roomKey);
|
|
118
120
|
console.log(`\n${chalk.bold(chalk.blueBright(link))}\n`);
|
|
119
|
-
console.log(chalk.bold("^^ You'll be streaming here
|
|
121
|
+
console.log(chalk.bold("^^ You'll be streaming here ^^"));
|
|
120
122
|
this.clearstdin();
|
|
121
123
|
return await app.teletype({ roomKey, shell, multiplex, process });
|
|
122
124
|
}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import Conf from "conf";
|
|
1
|
+
import { URL } from 'url';
|
|
2
|
+
export declare const CLI_VERSION = 2;
|
|
3
|
+
import Conf from 'conf';
|
|
5
4
|
export declare const config: Conf<string>;
|
|
6
|
-
export type env =
|
|
7
|
-
export type
|
|
5
|
+
export type env = 'local' | 'prod';
|
|
6
|
+
export type ConnectConfig = {
|
|
8
7
|
host: string;
|
|
9
|
-
enableTLS: boolean;
|
|
10
8
|
token: string;
|
|
11
9
|
};
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const ROOM_LINK_SAMPLE = "https://oorja.io/
|
|
10
|
+
export declare const getConnectConfig: (env: env, region: string) => ConnectConfig;
|
|
11
|
+
export declare const ROOM_LINK_SAMPLE = "https://oorja.io/spaces?id=foo#key";
|
|
14
12
|
export declare const INVALID_ROOM_LINK_MESSAGE: string;
|
|
15
13
|
export declare const determineENV: (roomURL?: URL) => env;
|
|
16
14
|
export declare const getENVAccessToken: (env: env) => string;
|
|
17
15
|
export declare const setENVAccessToken: (env: env, token: string) => void;
|
|
18
16
|
export type oorjaConfig = {
|
|
19
17
|
host: string;
|
|
20
|
-
enableTLS: boolean;
|
|
21
18
|
};
|
|
22
19
|
export declare const getoorjaConfig: (env: env) => oorjaConfig;
|
package/dist/lib/config.js
CHANGED
|
@@ -1,65 +1,52 @@
|
|
|
1
|
-
import chalk from
|
|
2
|
-
export const CLI_VERSION =
|
|
3
|
-
import Conf from
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export const CLI_VERSION = 2.0;
|
|
3
|
+
import Conf from 'conf';
|
|
4
4
|
export const config = new Conf({
|
|
5
|
-
projectName:
|
|
5
|
+
projectName: 'oorja',
|
|
6
6
|
schema: {
|
|
7
|
-
|
|
8
|
-
type: 'string'
|
|
7
|
+
env: {
|
|
8
|
+
type: 'string',
|
|
9
9
|
},
|
|
10
|
-
|
|
11
|
-
type: 'string'
|
|
10
|
+
'staging-access-token': {
|
|
11
|
+
type: 'string',
|
|
12
12
|
},
|
|
13
|
-
|
|
14
|
-
type: 'string'
|
|
13
|
+
'prod-access-token': {
|
|
14
|
+
type: 'string',
|
|
15
15
|
},
|
|
16
|
-
|
|
17
|
-
type: 'string'
|
|
18
|
-
},
|
|
19
|
-
"prod-teletype-access-token": {
|
|
20
|
-
type: 'string'
|
|
21
|
-
},
|
|
22
|
-
}
|
|
16
|
+
},
|
|
23
17
|
});
|
|
24
|
-
export const
|
|
18
|
+
export const getConnectConfig = (env, region) => {
|
|
25
19
|
const getHost = (env) => {
|
|
26
20
|
switch (env) {
|
|
27
|
-
case
|
|
28
|
-
return
|
|
29
|
-
case
|
|
30
|
-
return
|
|
31
|
-
case "prod":
|
|
32
|
-
case "prod-teletype":
|
|
33
|
-
return "surya.oorja.io";
|
|
21
|
+
case 'local':
|
|
22
|
+
return 'connect-staging.oorja.io';
|
|
23
|
+
case 'prod':
|
|
24
|
+
return region ? `${region}.connect.oorja.io` : 'connect.oorja.io';
|
|
34
25
|
}
|
|
35
26
|
};
|
|
36
27
|
return {
|
|
37
28
|
host: getHost(env),
|
|
38
29
|
token: getENVAccessToken(env),
|
|
39
|
-
enableTLS: env !== "local",
|
|
40
30
|
};
|
|
41
31
|
};
|
|
42
|
-
export const ROOM_LINK_SAMPLE =
|
|
43
|
-
export const INVALID_ROOM_LINK_MESSAGE = `${chalk.redBright(
|
|
32
|
+
export const ROOM_LINK_SAMPLE = 'https://oorja.io/spaces?id=foo#key';
|
|
33
|
+
export const INVALID_ROOM_LINK_MESSAGE = `${chalk.redBright('invalid url ')}🤔. It should look like: ${chalk.blue(ROOM_LINK_SAMPLE)}`;
|
|
44
34
|
export const determineENV = (roomURL) => {
|
|
45
35
|
if (!roomURL)
|
|
46
|
-
return config.get(
|
|
36
|
+
return config.get('env') || 'prod';
|
|
47
37
|
switch (roomURL.host) {
|
|
48
|
-
case
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return "staging";
|
|
54
|
-
case "localhost:3000":
|
|
55
|
-
return "local";
|
|
38
|
+
case 'oorja.io':
|
|
39
|
+
case 'teletype.oorja.io':
|
|
40
|
+
return 'prod';
|
|
41
|
+
case 'localhost:3000':
|
|
42
|
+
return 'local';
|
|
56
43
|
default:
|
|
57
44
|
console.error(INVALID_ROOM_LINK_MESSAGE);
|
|
58
45
|
process.exit(1);
|
|
59
46
|
}
|
|
60
47
|
};
|
|
61
48
|
export const getENVAccessToken = (env) => {
|
|
62
|
-
return config.get(`${env}-access-token`) ||
|
|
49
|
+
return config.get(`${env}-access-token`) || '';
|
|
63
50
|
};
|
|
64
51
|
export const setENVAccessToken = (env, token) => {
|
|
65
52
|
config.set(`${env}-access-token`, token);
|
|
@@ -67,21 +54,14 @@ export const setENVAccessToken = (env, token) => {
|
|
|
67
54
|
export const getoorjaConfig = (env) => {
|
|
68
55
|
let host;
|
|
69
56
|
switch (env) {
|
|
70
|
-
case
|
|
71
|
-
host =
|
|
72
|
-
break;
|
|
73
|
-
case "staging":
|
|
74
|
-
host = "staging.oorja.io";
|
|
75
|
-
break;
|
|
76
|
-
case "prod":
|
|
77
|
-
host = "oorja.io";
|
|
57
|
+
case 'local':
|
|
58
|
+
host = 'localhost:3000';
|
|
78
59
|
break;
|
|
79
|
-
case
|
|
80
|
-
host =
|
|
60
|
+
case 'prod':
|
|
61
|
+
host = 'oorja.io';
|
|
81
62
|
break;
|
|
82
63
|
}
|
|
83
64
|
return {
|
|
84
65
|
host,
|
|
85
|
-
enableTLS: env !== "local",
|
|
86
66
|
};
|
|
87
67
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { User, RoomApps, Room, CliManifest } from
|
|
2
|
-
import { env } from
|
|
3
|
-
import { Channel } from
|
|
4
|
-
export declare class
|
|
1
|
+
import { User, RoomApps, Room, CliManifest } from './types.js';
|
|
2
|
+
import { env } from '../config.js';
|
|
3
|
+
import { Channel } from 'phoenix';
|
|
4
|
+
export declare class ApiClientError extends Error {
|
|
5
5
|
}
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class ConnectClient {
|
|
7
7
|
private config;
|
|
8
8
|
private client;
|
|
9
9
|
private socket?;
|
|
10
|
-
constructor(env: env);
|
|
10
|
+
constructor(env: env, region: string);
|
|
11
11
|
fetchCliManifest: () => Promise<CliManifest>;
|
|
12
12
|
fetchSessionUser: () => Promise<User>;
|
|
13
13
|
createRoom: ({ roomName, apps }: CreateRoomOptions) => Promise<Room>;
|
|
@@ -29,6 +29,6 @@ export type JoinChannelOptions<T> = {
|
|
|
29
29
|
onError?: (reason: any) => void;
|
|
30
30
|
onClose?: (payload: any, ref: any, joinRef: any) => void;
|
|
31
31
|
onMessage: (payload: any) => void;
|
|
32
|
-
handleSessionJoin: (session: string) => void;
|
|
33
|
-
handleSessionLeave: (session: string) => void;
|
|
32
|
+
handleSessionJoin: (session: string | undefined, _ignore: any, metas: any) => void;
|
|
33
|
+
handleSessionLeave: (session: string | undefined) => void;
|
|
34
34
|
};
|