oorja 2.1.4 → 2.1.5
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/dist/commands/teletype/index.js +3 -3
- package/dist/lib/config.js +2 -1
- package/dist/lib/connect/index.js +3 -1
- package/dist/lib/oorja/client.js +3 -2
- package/dist/lib/oorja/index.js +3 -2
- package/dist/lib/oorja/preflight.js +8 -5
- package/dist/lib/teletype/index.js +5 -5
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +4 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import * as os from 'os';
|
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { ROOM_LINK_SAMPLE } from '../../lib/config.js';
|
|
7
7
|
import { getApp } from '../../lib/oorja/index.js';
|
|
8
|
-
import { promptRoomLink } from '../../lib/utils.js';
|
|
8
|
+
import { printExitMessage, promptRoomLink } from '../../lib/utils.js';
|
|
9
9
|
const DEFAULT_SHELL = os.platform() === 'win32' ? 'powershell.exe' : process.env.SHELL || 'bash';
|
|
10
10
|
export default class TeleTypeCommand extends Command {
|
|
11
11
|
static order = 1;
|
|
@@ -81,7 +81,7 @@ Will also allow participants to write to your terminal!
|
|
|
81
81
|
async streamToLink(options) {
|
|
82
82
|
const roomLink = options.roomLink || (await promptRoomLink());
|
|
83
83
|
if (!roomLink) {
|
|
84
|
-
|
|
84
|
+
printExitMessage(chalk.redBright('Space link not provided :('));
|
|
85
85
|
process.exit();
|
|
86
86
|
}
|
|
87
87
|
const app = await getApp({ roomLink });
|
|
@@ -111,7 +111,7 @@ Will also allow participants to write to your terminal!
|
|
|
111
111
|
},
|
|
112
112
|
})
|
|
113
113
|
.catch((e) => {
|
|
114
|
-
|
|
114
|
+
printExitMessage('Failed to create space.');
|
|
115
115
|
process.exit(9);
|
|
116
116
|
});
|
|
117
117
|
spinner.succeed(chalk.bold('Space created')).clear();
|
package/dist/lib/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
export const CLI_VERSION = 2.5;
|
|
3
3
|
import Conf from 'conf';
|
|
4
|
+
import { printExitMessage } from './utils.js';
|
|
4
5
|
export const config = new Conf({
|
|
5
6
|
projectName: 'oorja',
|
|
6
7
|
schema: {
|
|
@@ -41,7 +42,7 @@ export const determineENV = (roomURL) => {
|
|
|
41
42
|
case 'localhost:3000':
|
|
42
43
|
return 'local';
|
|
43
44
|
default:
|
|
44
|
-
|
|
45
|
+
printExitMessage(INVALID_ROOM_LINK_MESSAGE);
|
|
45
46
|
process.exit(1);
|
|
46
47
|
}
|
|
47
48
|
};
|
|
@@ -7,6 +7,7 @@ import { getConnectConfig } from '../config.js';
|
|
|
7
7
|
import { Unauthorized, BadRequest } from './errors.js';
|
|
8
8
|
import { Socket, Presence } from 'phoenix';
|
|
9
9
|
import camelcaseKeys from 'camelcase-keys';
|
|
10
|
+
import { printExitMessage } from '../utils.js';
|
|
10
11
|
export class ApiClientError extends Error {
|
|
11
12
|
}
|
|
12
13
|
export class ConnectClient {
|
|
@@ -157,7 +158,7 @@ export class ConnectClient {
|
|
|
157
158
|
reject();
|
|
158
159
|
return;
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
+
printExitMessage('connection error');
|
|
161
162
|
process.exit(2);
|
|
162
163
|
});
|
|
163
164
|
// @ts-ignore
|
|
@@ -195,6 +196,7 @@ export class ConnectClient {
|
|
|
195
196
|
onError(new Unauthorized('unauthorized: user needs to join the room before a stream can be started.'));
|
|
196
197
|
return;
|
|
197
198
|
}
|
|
199
|
+
printExitMessage('error on channel');
|
|
198
200
|
process.exit(3);
|
|
199
201
|
});
|
|
200
202
|
return chan;
|
package/dist/lib/oorja/client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import haversine from 'haversine-distance';
|
|
2
|
+
import { printExitMessage } from '../utils.js';
|
|
2
3
|
export class OorjaClientError extends Error {
|
|
3
4
|
}
|
|
4
5
|
const _maybeError = (response) => {
|
|
@@ -27,7 +28,7 @@ export const getRegion = async () => {
|
|
|
27
28
|
method: 'GET',
|
|
28
29
|
});
|
|
29
30
|
if (response.status !== 200) {
|
|
30
|
-
|
|
31
|
+
printExitMessage('There seems to be an issue with the network');
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
34
|
const settings = (await response.json());
|
|
@@ -46,7 +47,7 @@ export const getRegion = async () => {
|
|
|
46
47
|
return minDistance.name;
|
|
47
48
|
}
|
|
48
49
|
catch {
|
|
49
|
-
|
|
50
|
+
printExitMessage('error determining region');
|
|
50
51
|
process.exit(1);
|
|
51
52
|
}
|
|
52
53
|
};
|
package/dist/lib/oorja/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { importKey, createRoomKey, exportKey } from '../encryption.js';
|
|
|
6
6
|
import { loginByRoomOTP, preflight, promptAuth, resumeSession, validateCliVersion } from './preflight.js';
|
|
7
7
|
import { getRegion } from './client.js';
|
|
8
8
|
import ora from 'ora';
|
|
9
|
+
import { printExitMessage } from '../utils.js';
|
|
9
10
|
export class InvalidRoomLink extends Error {
|
|
10
11
|
}
|
|
11
12
|
class OORJA {
|
|
@@ -47,7 +48,7 @@ class OORJA {
|
|
|
47
48
|
const parseRoomURL = (roomLink) => {
|
|
48
49
|
const url = new URL(roomLink);
|
|
49
50
|
if (!url.hash || !getRoomId(url)) {
|
|
50
|
-
|
|
51
|
+
printExitMessage(INVALID_ROOM_LINK_MESSAGE);
|
|
51
52
|
process.exit(3);
|
|
52
53
|
}
|
|
53
54
|
return url;
|
|
@@ -80,7 +81,7 @@ const init = async (env, options = {}) => {
|
|
|
80
81
|
else {
|
|
81
82
|
token = await promptAuth(connectClient, linkForTokenGen(config));
|
|
82
83
|
if (!token) {
|
|
83
|
-
|
|
84
|
+
printExitMessage('Token not provided :(');
|
|
84
85
|
process.exit(12);
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -3,6 +3,7 @@ import inquirer from 'inquirer';
|
|
|
3
3
|
import ora from 'ora';
|
|
4
4
|
import { setENVAccessToken, CLI_VERSION, getENVAccessToken } from '../config.js';
|
|
5
5
|
import { BadRequest, Unauthorized } from '../connect/errors.js';
|
|
6
|
+
import { printExitMessage } from '../utils.js';
|
|
6
7
|
const promptToken = () => inquirer
|
|
7
8
|
.prompt([
|
|
8
9
|
{
|
|
@@ -48,7 +49,7 @@ export const loginByRoomOTP = async (connectClient, roomId) => {
|
|
|
48
49
|
const otp = await promptRoomParticipantOTP();
|
|
49
50
|
if (!otp) {
|
|
50
51
|
console.log('OTP not provided :(');
|
|
51
|
-
|
|
52
|
+
printExitMessage(OTP_HELP_MESSAGE);
|
|
52
53
|
process.exit(213);
|
|
53
54
|
}
|
|
54
55
|
try {
|
|
@@ -57,7 +58,7 @@ export const loginByRoomOTP = async (connectClient, roomId) => {
|
|
|
57
58
|
catch (e) {
|
|
58
59
|
if (e instanceof BadRequest) {
|
|
59
60
|
console.log(chalk.redBright('Invalid otp. It may have expired.'));
|
|
60
|
-
|
|
61
|
+
printExitMessage(OTP_HELP_MESSAGE);
|
|
61
62
|
process.exit();
|
|
62
63
|
}
|
|
63
64
|
throw e;
|
|
@@ -66,7 +67,7 @@ export const loginByRoomOTP = async (connectClient, roomId) => {
|
|
|
66
67
|
export const validateCliVersion = async (connectClient) => {
|
|
67
68
|
const manifest = await connectClient.fetchCliManifest();
|
|
68
69
|
if (manifest.cliVersion > CLI_VERSION) {
|
|
69
|
-
|
|
70
|
+
printExitMessage(chalk.redBright('Your oorja cli is outdated. Please run: npm update -g oorja'));
|
|
70
71
|
process.exit(1);
|
|
71
72
|
}
|
|
72
73
|
};
|
|
@@ -118,11 +119,13 @@ export const preflight = async (env, connectClient) => {
|
|
|
118
119
|
catch (e) {
|
|
119
120
|
setENVAccessToken(env, '');
|
|
120
121
|
if (e instanceof Unauthorized) {
|
|
121
|
-
spinner.fail(
|
|
122
|
+
spinner.fail();
|
|
123
|
+
printExitMessage('Your access token failed authentication, resetting...');
|
|
122
124
|
process.exit(33);
|
|
123
125
|
}
|
|
124
126
|
else {
|
|
125
|
-
spinner.fail(
|
|
127
|
+
spinner.fail();
|
|
128
|
+
printExitMessage('Something went wrong :(');
|
|
126
129
|
}
|
|
127
130
|
throw e;
|
|
128
131
|
}
|
|
@@ -4,7 +4,7 @@ import { getDimensions, initScreen, areDimensionEqual, resizeBestFit } from './a
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { Unauthorized } from '../connect/errors.js';
|
|
6
6
|
import { encrypt, decrypt } from '../encryption.js';
|
|
7
|
-
import { Future } from '../utils.js';
|
|
7
|
+
import { Future, printExitMessage } from '../utils.js';
|
|
8
8
|
var MessageType;
|
|
9
9
|
(function (MessageType) {
|
|
10
10
|
MessageType["IN"] = "i";
|
|
@@ -96,15 +96,15 @@ export const teletypeApp = (options) => {
|
|
|
96
96
|
stdin.on('data', (d) => term.write(d.toString('utf8')));
|
|
97
97
|
},
|
|
98
98
|
onClose: () => {
|
|
99
|
-
|
|
99
|
+
printExitMessage(chalk.redBright('connection closed, terminated stream.'));
|
|
100
100
|
process.exit(3);
|
|
101
101
|
},
|
|
102
102
|
onError: (err) => {
|
|
103
103
|
if (err instanceof Unauthorized) {
|
|
104
|
-
|
|
104
|
+
printExitMessage(chalk.redBright(err.message));
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
|
-
|
|
107
|
+
printExitMessage(chalk.redBright('connection error, terminated stream.'));
|
|
108
108
|
}
|
|
109
109
|
process.exit(4);
|
|
110
110
|
},
|
|
@@ -125,7 +125,7 @@ export const teletypeApp = (options) => {
|
|
|
125
125
|
term.write(data);
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
|
-
|
|
128
|
+
printExitMessage(chalk.redBright(`unexpected input from user: ${userId}, terminating stream for safety. Please report this issue`));
|
|
129
129
|
process.exit(5);
|
|
130
130
|
}
|
|
131
131
|
}
|
package/dist/lib/utils.d.ts
CHANGED
package/dist/lib/utils.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import inquirer from 'inquirer';
|
|
2
|
+
import { writeSync } from 'fs';
|
|
3
|
+
export const printExitMessage = (printMessage) => {
|
|
4
|
+
writeSync(process.stdout.fd, printMessage);
|
|
5
|
+
};
|
|
2
6
|
export const promptRoomLink = async () => {
|
|
3
7
|
const { spaceLink } = await inquirer.prompt([
|
|
4
8
|
{
|
package/oclif.manifest.json
CHANGED