oorja 2.2.1 → 2.3.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.
@@ -102,7 +102,7 @@ Will also allow participants to write to your terminal! Collaboration mode must
102
102
  discardStdin: false,
103
103
  }).start();
104
104
  const now = new Date();
105
- const { roomKey } = await oorja
105
+ const { roomKey, inviteCode } = await oorja
106
106
  .createRoom({
107
107
  roomName: `Teletype session - ${hostname()} @ ${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`,
108
108
  apps: {
@@ -127,7 +127,7 @@ Will also allow participants to write to your terminal! Collaboration mode must
127
127
  return Promise.reject();
128
128
  });
129
129
  spinner.succeed(chalk.bold('Space created')).clear();
130
- const link = oorja.linkForRoom(roomKey);
130
+ const link = oorja.linkForRoom(roomKey, inviteCode);
131
131
  console.log(`\n${chalk.bold(chalk.blueBright(link))}\n`);
132
132
  console.log(chalk.bold("^^ You'll be streaming here ^^"));
133
133
  this.clearstdin();
@@ -1,4 +1,4 @@
1
- export declare const CLI_VERSION = 2.7;
1
+ export declare const CLI_VERSION = 2.8;
2
2
  export type env = 'local' | 'prod';
3
3
  export declare class Config {
4
4
  streamKeyAuth: boolean;
@@ -1,7 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
3
3
  import path from 'path';
4
- export const CLI_VERSION = 2.7;
4
+ export const CLI_VERSION = 2.8;
5
5
  export class Config {
6
6
  streamKeyAuth = false;
7
7
  configPath;
@@ -1,4 +1,4 @@
1
- import { User, RoomApps, Room, CliManifest } from './types.js';
1
+ import { User, RoomApps, Room, CliManifest, NewRoomInviteResponse } from './types.js';
2
2
  import { env } from '../config.js';
3
3
  import { Channel } from 'phoenix';
4
4
  export declare class ApiClientError extends Error {
@@ -16,6 +16,9 @@ export declare class ConnectClient {
16
16
  fetchCliManifest: () => Promise<CliManifest>;
17
17
  fetchSessionUser: (v2?: boolean) => Promise<User>;
18
18
  createRoom: ({ roomName, apps }: CreateRoomOptions) => Promise<Room>;
19
+ createInviteCode: ({ roomId }: {
20
+ roomId: string;
21
+ }) => Promise<NewRoomInviteResponse>;
19
22
  createAnonymousUser: () => Promise<string>;
20
23
  fetchRoom: (roomId: string) => Promise<Room>;
21
24
  establishSocket: () => Promise<void>;
@@ -100,6 +100,22 @@ export class ConnectClient {
100
100
  return handleError(error);
101
101
  }
102
102
  };
103
+ createInviteCode = async ({ roomId }) => {
104
+ const body = {
105
+ participant_access: 'can_edit',
106
+ };
107
+ try {
108
+ const response = await this._fetch(`/v1/rooms/${roomId}/invites`, {
109
+ method: 'POST',
110
+ body: JSON.stringify(body),
111
+ });
112
+ const data = await response.json();
113
+ return defaultParser(data);
114
+ }
115
+ catch (error) {
116
+ return handleError(error);
117
+ }
118
+ };
103
119
  createAnonymousUser = async () => {
104
120
  try {
105
121
  const response = await this._fetch('/v1/session/anon', { method: 'POST' });
@@ -34,7 +34,17 @@ export type RoomKey = {
34
34
  roomId: string;
35
35
  key: Buffer;
36
36
  };
37
- export type Hash<T> = {
38
- [key: string]: T;
37
+ export type ParticipantAccess = 'full_access' | 'can_edit' | 'can_view';
38
+ export type RoomInvite = {
39
+ id: string;
40
+ creatorId: string;
41
+ insertedAt: string;
42
+ inviteCode: string;
43
+ participantAccess: ParticipantAccess;
44
+ roomId: string;
45
+ };
46
+ export type NewRoomInviteResponse = {
47
+ allInvites: RoomInvite[];
48
+ data: RoomInvite;
39
49
  };
40
50
  export {};
@@ -13,8 +13,9 @@ export declare class OORJA {
13
13
  createRoom: (options: CreateRoomOptions) => Promise<{
14
14
  room: import("../connect/types.js").Room;
15
15
  roomKey: RoomKey;
16
+ inviteCode: string;
16
17
  }>;
17
- linkForRoom: (roomKey: RoomKey) => string;
18
+ linkForRoom: (roomKey: RoomKey, inviteCode: string) => string;
18
19
  getRoomKey(streamKey: StreamKey): RoomKey;
19
20
  teletype: (options: Omit<TeletypeOptions, "userId" | "joinChannel">) => Promise<unknown>;
20
21
  }
@@ -24,13 +24,15 @@ export class OORJA {
24
24
  createRoom = async (options) => {
25
25
  const room = await this.connectClient.createRoom(options);
26
26
  const roomKey = createRoomKey(room.id);
27
+ const { data: { inviteCode }, } = await this.connectClient.createInviteCode({ roomId: room.id });
27
28
  return {
28
29
  room,
29
30
  roomKey,
31
+ inviteCode,
30
32
  };
31
33
  };
32
- linkForRoom = (roomKey) => {
33
- return `${oorjaURL(this.config)}/rooms?id=${roomKey.roomId}#${exportKey(roomKey.key)}`;
34
+ linkForRoom = (roomKey, inviteCode) => {
35
+ return `${oorjaURL(this.config)}/rooms?id=${roomKey.roomId}&inviteCode=${inviteCode}#${exportKey(roomKey.key)}`;
34
36
  };
35
37
  getRoomKey(streamKey) {
36
38
  return {
@@ -1,5 +1,4 @@
1
1
  import { IPty } from 'node-pty';
2
- import { Hash } from '../connect/types.js';
3
2
  export declare const initScreen: (username: string, hostname: string, shell: string, multiplexed: boolean) => void;
4
3
  export type dimensions = {
5
4
  rows: number;
@@ -7,4 +6,4 @@ export type dimensions = {
7
6
  };
8
7
  export declare const getDimensions: () => dimensions;
9
8
  export declare const areDimensionEqual: (a: dimensions, b: dimensions) => boolean;
10
- export declare const resizeBestFit: (term: IPty, userDimensions: Hash<dimensions>, shouldClearScreen?: boolean) => void;
9
+ export declare const resizeBestFit: (term: IPty, userDimensions: Record<string, dimensions>, shouldClearScreen?: boolean) => void;
@@ -85,5 +85,5 @@
85
85
  ]
86
86
  }
87
87
  },
88
- "version": "2.2.1"
88
+ "version": "2.3.0"
89
89
  }
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": "2.2.1",
4
+ "version": "2.3.0",
5
5
  "keywords": [
6
6
  "teletype",
7
7
  "terminal",