ravejs 1.7.3 → 1.9.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 (38) hide show
  1. package/README.MD +339 -1
  2. package/README.RU.MD +390 -0
  3. package/dist/constants.d.ts +2 -1
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/constants.js +3 -2
  6. package/dist/core/httpworkflow.d.ts +5 -0
  7. package/dist/core/httpworkflow.d.ts.map +1 -1
  8. package/dist/core/httpworkflow.js +18 -0
  9. package/dist/core/mesh-socket.d.ts +16 -0
  10. package/dist/core/mesh-socket.d.ts.map +1 -0
  11. package/dist/core/mesh-socket.js +74 -0
  12. package/dist/core/rave.d.ts +23 -0
  13. package/dist/core/rave.d.ts.map +1 -1
  14. package/dist/core/rave.js +70 -4
  15. package/dist/factories/mesh-factory.d.ts +2 -0
  16. package/dist/factories/mesh-factory.d.ts.map +1 -1
  17. package/dist/factories/mesh-factory.js +38 -0
  18. package/dist/factories/thread-factory.d.ts.map +1 -1
  19. package/dist/factories/thread-factory.js +2 -2
  20. package/dist/schemas/configs.d.ts +1 -1
  21. package/dist/schemas/private.d.ts +10 -0
  22. package/dist/schemas/private.d.ts.map +1 -1
  23. package/dist/schemas/private.js +8 -1
  24. package/dist/schemas/public.d.ts +26 -2
  25. package/dist/schemas/public.d.ts.map +1 -1
  26. package/dist/schemas/public.js +8 -6
  27. package/dist/schemas/rave/account.d.ts +22 -0
  28. package/dist/schemas/rave/account.d.ts.map +1 -0
  29. package/dist/schemas/rave/account.js +9 -0
  30. package/dist/schemas/rave/user.d.ts +3 -3
  31. package/dist/schemas/rave/user.js +1 -1
  32. package/dist/schemas/responses.d.ts +31 -5
  33. package/dist/schemas/responses.d.ts.map +1 -1
  34. package/dist/schemas/responses.js +8 -1
  35. package/dist/utils/utils.d.ts +2 -1
  36. package/dist/utils/utils.d.ts.map +1 -1
  37. package/dist/utils/utils.js +22 -5
  38. package/package.json +4 -1
package/README.MD CHANGED
@@ -1 +1,339 @@
1
- # Work In Progress
1
+ <div align="center">
2
+ <h1>RaveJS</h1>
3
+ <a href="https://t.me/aminodorks"><img src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram"></a>
4
+ <a href="https://www.npmjs.com/package/ravejs"><img src="https://img.shields.io/badge/NPM-%23CB3837.svg?style=for-the-badge&logo=npm&logoColor=white" alt="NPM"></a>
5
+ </div>
6
+ <div align="center">
7
+ <img src="https://img.shields.io/npm/dm/ravejs" alt="Downloads">
8
+ <img src="https://img.shields.io/npm/v/ravejs.svg" alt="Version">
9
+ <h2>RaveJS is a TypeScript library that interacts with the Rave: Watch Party App API.</h2>
10
+ </div>
11
+
12
+ ## [README on English](https://github.com/thatcelt/ravejs/blob/master/README.MD)
13
+ ## [README на Русском](https://github.com/thatcelt/ravejs/blob/master/README.RU.MD)
14
+
15
+ ## Table of Contents
16
+ -----------------
17
+
18
+ * [Features](#features)
19
+ * [Getting Started](#getting-started)
20
+ * [Usage](#usage)
21
+ * [API Documentation](#api-documentation)
22
+ * [Contributing](#contributing)
23
+ * [License](#license)
24
+
25
+ ## Features
26
+ --------
27
+
28
+ RaveJS contains a many features for example:
29
+ - Modular structure
30
+ - Easy to use
31
+ - Support any functions for using
32
+ - This is the first TypeScript library for this app
33
+
34
+ ## Getting Started
35
+ ---------------
36
+
37
+ To get started with RaveJS, follow these steps:
38
+ 1. Initialize npm package: `npm init`
39
+ 2. Install TypeScript: `npm i -g typescript`
40
+ 3. Initialize TypeScript config and configure it: `tsc --init`
41
+ 4. Install package via npm: `npm i ravejs`
42
+
43
+ ## Usage
44
+ -----
45
+ ### Basic authorization
46
+
47
+ ```typescript
48
+ import { Rave } from 'ravejs';
49
+
50
+ (async () => {
51
+ const rave = new Rave({
52
+ credentials: {
53
+ deviceId: 'your_device_id',
54
+ token: 'your_token'
55
+ }
56
+ });
57
+ console.log(`logged as ${(await rave.getAccount()).id}`);
58
+ })();
59
+ ```
60
+
61
+ ## Documentation
62
+ -----------------
63
+
64
+ ### `Rave(config: RaveConfig)`
65
+ A main class to interacting with API in global namespace of app.
66
+ config - configuration for library, you can find it in `RaveConfig` type...
67
+ `RaveConfig` =>
68
+ * credentials?: { deviceId: string, token: string } - main credentials for authorization
69
+ * enableLogging?: boolean - enable logging for library
70
+ * account?: Account - Your user profile information after authorization
71
+
72
+ #### Rave Properties
73
+
74
+ 1. `Rave.token: string` - Authorization bearer token
75
+ 2. `Rave.JWT: string` - Authorization JWT token for we mesh API
76
+ 3. `Rave.account: Account` - Your user profile information after authorization
77
+ 4. `Rave.proxy: string | undefined` - Proxy for requests (you can set socks proxy with proxy property setter too)
78
+
79
+ #### Rave Methods
80
+
81
+ 1. `refreshJWT = async (deviceId?: string): Promise<string>` - Refresh JWT token for we mesh API
82
+ 2. `getAccount = async (): Promise<Account>` - Get your user profile information after authorization
83
+
84
+ -----------------
85
+ Rave haves the fully modular structure and parts called `Factories`. Now i will describe them:
86
+
87
+ ### `AuthFactory`
88
+ The main factory for authorization and authentication. Can be called with `Rave.auth` property
89
+
90
+ #### Authenticate Factory methods
91
+
92
+ 1. `sendMagicLink = async (email: string, language: string = DEFAULT_LANGUAGE): Promise<SendMagicLinkResponse> - Send magic link to email for authorization, if you doesn't know your credentials or just wanna register`
93
+ * DEFAULT_LANGUAGE = 'ru'
94
+ * SendMagicLinkResponse - { stateId: string } - stateId for magic link
95
+
96
+ 2. `checkRegisterState = async (stateId: string): Promise<CheckRegisterStateResponse> - Check stateId for magic link`
97
+ * CheckRegisterStateResponse - {
98
+ authenticated: boolean,
99
+ isSecondFactorLogin: boolean,
100
+ oauth: {
101
+ accessToken: string,
102
+ idToken: string,
103
+ refreshToken: string,
104
+ expiresIn: string,
105
+ tokenType: string
106
+ },
107
+ user: {
108
+ createdAt: string,
109
+ updatedAt: string,
110
+ issuer: string
111
+ userId: string
112
+ identifier: string
113
+ email: string
114
+ }
115
+ }
116
+
117
+ 3. `parseUserCredentials = async (idToken: string, email: string): Promise<ParseUserCredentialsResponse> - Parse user credentials from idToken and email`
118
+ * ParseUserCredentialsResponse - {
119
+ objectId: string,
120
+ createdAt: string,
121
+ username: string,
122
+ sessionToken: string,
123
+ }
124
+
125
+ 4. `mojoLogin = async (email: string, parseId: string, parseToken: string, name: string, deviceId?: string, language = DEFAULT_LANGUAGE): Promise<MojoLoginResponse> - Login with mojo service to Rave`
126
+ * MojoLoginResponse - { data: {
127
+ isValid: boolean,
128
+ newUser: boolean,
129
+ suggestedHandles: string[],
130
+ }}
131
+
132
+ 5. `login = async (stateId: string, name?: string, deviceId?: string, language = DEFAULT_LANGUAGE): Promise<AuthenticateResponse> - Simply summary of previous functions for login`
133
+ * AuthenticateResponse - {
134
+ isNewUser: boolean,
135
+ email: string,
136
+ username: string,
137
+ deviceId: string,
138
+ token: string,
139
+ }
140
+
141
+ 6. `register = async (email: string, name: string, deviceId?: string, language = DEFAULT_LANGUAGE): Promise<AuthenticateResponse> - Register a new user`
142
+ * RegisterResponse - {
143
+ isNewUser: boolean,
144
+ email: string,
145
+ username: string,
146
+ deviceId: string,
147
+ token: string,
148
+ }
149
+
150
+ ### `MeshFactory`
151
+ Factory for interacting with Meshes (rooms in Rave where you can watch videos). Can be called with `Rave.mesh` property
152
+
153
+ #### Mesh Factory methods
154
+
155
+ 1. `get = async (meshId: string): Promise<GetMeshResponse>` - Get a mesh by its ID
156
+ * GetMeshResponse - {
157
+ data: {
158
+ blurT?: boolean,
159
+ category: string,
160
+ channel: number,
161
+ createdAt: string,
162
+ currentState: 'play' | 'paus',
163
+ explicit: boolean,
164
+ id: string,
165
+ isFriend: boolean,
166
+ isLocal: boolean,
167
+ isPublic: boolean,
168
+ kickMode: string,
169
+ maturity: string,
170
+ mediaUrl: string,
171
+ originator: number,
172
+ playMode: string,
173
+ position: number,
174
+ server: string,
175
+ shareLink: string,
176
+ thumbnails?: {
177
+ channel?: string,
178
+ standard?: string,
179
+ animated?: string,
180
+ maxres?: string,
181
+ medium?: string,
182
+ default?: string,
183
+ high?: string,
184
+ },
185
+ time: number,
186
+ videoAuthor: string,
187
+ videoDuration: number,
188
+ videoProvider: string,
189
+ videoPublishedAt: string,
190
+ videoThumbnail: string,
191
+ videoTitle: string,
192
+ videoUrl: string,
193
+ vikiPass: boolean,
194
+ voipMode: string,
195
+ users: {
196
+ avatar: string,
197
+ country: string,
198
+ displayName?: string,
199
+ handle?: string,
200
+ id: number,
201
+ lang?: string
202
+ lat: number,
203
+ lng: number,
204
+ name: string
205
+ }[]
206
+ },
207
+ }
208
+
209
+ 2. `getByLink = async (meshLink: string): Promise<GetMeshResponse>` - Get a mesh by its link
210
+
211
+ 3. `getMany = async (params: GetManyMeshesParams): Promise<GetManyMeshesResponse>` - Get multiple meshes from recently board
212
+ * GetManyMeshesParams - {
213
+ isPublic?: boolean,
214
+ limit: number,
215
+ hasFriends: boolean,
216
+ local: boolean,
217
+ hasInvited: boolean,
218
+ language?: string,
219
+ }
220
+
221
+ 4. `join = async (meshId: string): Promise<MeshSocket>` - Join a mesh by its ID
222
+ * MeshSocket - special class for working with mesh socket workflow, events and unique methods. Will be described later
223
+
224
+ ### `ThreadFactory`
225
+ Factory for interacting with threads (your chats with friends etc). Can be called with `Rave.thread` property
226
+
227
+ #### Thread Factory methods
228
+
229
+ 1. `getMany = async (): Promise<Thread[]>` - Get all threads from your account
230
+ * Thread - {
231
+ expiryMode: number,
232
+ isFriend: boolean,
233
+ myself: number,
234
+ opposingUser: number,
235
+ spokenLangs: string[],
236
+ threadId: string,
237
+ }
238
+
239
+ 2. `create = async (userId: number): Promise<Thread>` - Create a new thread with a user
240
+
241
+ 3. `sendMessage async (threadId: string, content: string): Promise<SendMessageResponse>` - Send a message to a thread
242
+ * SendMessageResponse - {
243
+ data: {
244
+ correlateId: string,
245
+ threadId: string,
246
+ messageType: string,
247
+ originator: number,
248
+ messageBody: {
249
+ content: string,
250
+ detectedLang: string,
251
+ id: string,
252
+ translations: Record<string, string>,
253
+ },
254
+ }
255
+ }
256
+
257
+ ### `UserFactory`
258
+ Factory for globally interacting with users from app. Can be called with `Rave.user` property
259
+
260
+ #### User Factory methods
261
+
262
+ 1. `get = async (userId: number): Promise<GetUserResponse>` - Get user by id
263
+ * GetUserResponse - {
264
+ data: {
265
+ bio: {
266
+ bio?: string,
267
+ metadata: {
268
+ position: number,
269
+ privacy: string
270
+ }
271
+ },
272
+ profile: {
273
+ avatar: string,
274
+ country: string,
275
+ displayName?: string,
276
+ handle?: string,
277
+ }
278
+ }
279
+ }
280
+
281
+ 2. `sendFriendship = async (userId: number): Promise<FriendshipResponse>` - Send a friendship request to a user
282
+ * FriendshipResponse - {
283
+ data: {
284
+ fromUserId: number,
285
+ state: string,
286
+ toUserId: number,
287
+ }
288
+ }
289
+
290
+ 3. `acceptFriendship = async (userId: number): Promise<FriendshipResponse>` - Accept a friendship requests from a user
291
+
292
+ 4. `declineFriendship = async (userId: number): Promise<FriendshipResponse>` - Decline a friendship request from a user
293
+
294
+ 5. `edit = async (builder: EditProfileBuilder): Promise<EditProfileResponse>` - Edit user profile
295
+ * EditProfileBuilder - {
296
+ displayAvatar?: string,
297
+ displayName?: string,
298
+ handle?: string,
299
+ }
300
+
301
+ * EditProfileResponse - {
302
+ data: User
303
+ } - User Schema equals to previous `user` models
304
+
305
+ 6. `getAvatarUpload = async (): Promise<GetAvatarUploadResponse>` - Get avatar upload url
306
+ * GetAvatarUploadResponse - {
307
+ data: {
308
+ expiresAt: string,
309
+ fileName: string,
310
+ mime: string,
311
+ uploadUrl: string,
312
+ }
313
+ }
314
+
315
+ 7. `uploadOnUrl = async (uploadUrl: string, image: Buffer): Promise<any>` - Upload avatar on url
316
+
317
+ 8. `uploadAvatar = async (image: Buffer): Promise<string>` - Fast using of `getAvatarUpload` and `uploadOnUrl`
318
+
319
+ ### `MeshSocket`
320
+ The main class of opened mesh socket to interact with mesh
321
+
322
+ #### Mesh Socket methods
323
+
324
+ 1. `onclose = (handler: () => Promise<void>)` - Register a handler to be called when the socket is closed
325
+ 2. `onerror = (handler: () => Promise<void>)` - Register a handler to be called when the socket encounters an error
326
+ 3. `onmessage = (handler: (data: string) => Promise<void>)` - Register a handler to be called when the socket receives a message
327
+ 4. `sendMessage = (content: string): void` - Send a message to the mesh
328
+ 5. `leave = (): void` - Leave the mesh
329
+
330
+ ## Contributing
331
+ ------------
332
+
333
+ Contributions are welcome! Please submit a pull request with your changes.
334
+
335
+ ## License
336
+ -------
337
+
338
+ RaveJS is licensed under the MIT License. See LICENSE for more information.
339
+ If you're will use my generators - write about it to my [DM](https://t.me/celt_is_god)