ravejs 1.2.1 → 1.4.2

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/dist/constants.d.ts +14 -1
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +21 -4
  4. package/dist/core/httpworkflow.d.ts +5 -4
  5. package/dist/core/httpworkflow.d.ts.map +1 -1
  6. package/dist/core/httpworkflow.js +20 -9
  7. package/dist/core/rave.d.ts +6 -0
  8. package/dist/core/rave.d.ts.map +1 -1
  9. package/dist/core/rave.js +14 -4
  10. package/dist/factories/auth-factory.d.ts +16 -0
  11. package/dist/factories/auth-factory.d.ts.map +1 -0
  12. package/dist/factories/auth-factory.js +87 -0
  13. package/dist/factories/mesh-factory.d.ts +10 -0
  14. package/dist/factories/mesh-factory.d.ts.map +1 -0
  15. package/dist/factories/mesh-factory.js +18 -0
  16. package/dist/factories/user-factory.d.ts +4 -1
  17. package/dist/factories/user-factory.d.ts.map +1 -1
  18. package/dist/factories/user-factory.js +26 -0
  19. package/dist/schemas/configs.d.ts +7 -0
  20. package/dist/schemas/configs.d.ts.map +1 -1
  21. package/dist/schemas/configs.js +7 -1
  22. package/dist/schemas/index.d.ts +1 -0
  23. package/dist/schemas/index.d.ts.map +1 -1
  24. package/dist/schemas/index.js +1 -0
  25. package/dist/schemas/public.d.ts +17 -0
  26. package/dist/schemas/public.d.ts.map +1 -1
  27. package/dist/schemas/public.js +10 -1
  28. package/dist/schemas/rave/mesh.d.ts +44 -0
  29. package/dist/schemas/rave/mesh.d.ts.map +1 -0
  30. package/dist/schemas/rave/mesh.js +48 -0
  31. package/dist/schemas/rave/user.d.ts +1 -1
  32. package/dist/schemas/rave/user.js +1 -1
  33. package/dist/schemas/responses.d.ts +160 -3
  34. package/dist/schemas/responses.d.ts.map +1 -1
  35. package/dist/schemas/responses.js +100 -2
  36. package/dist/utils/cryptography.d.ts.map +1 -1
  37. package/dist/utils/cryptography.js +4 -3
  38. package/package.json +1 -1
@@ -1,8 +1,10 @@
1
1
  import { APIErrorData } from './schemas/error';
2
- export declare const VERSION = "1.2.1";
2
+ export declare const VERSION = "1.4.2";
3
3
  export declare const API_URL = "https://api1.a-l-p-a.com";
4
+ export declare const THIRD_API_URL = "https://api3.a-l-p-a.com";
4
5
  export declare const MOJO_AUTH_URL = "https://api.mojoauth.com";
5
6
  export declare const HASH_SECRET = "c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2";
7
+ export declare const DEFAULT_LANGUAGE = "ru";
6
8
  export declare const WE_MESH_HEADERS: {
7
9
  'Content-Type': string;
8
10
  Accept: string;
@@ -71,5 +73,16 @@ export declare const PATCHED_IP_DATA: {
71
73
  timezone: string;
72
74
  zip: string;
73
75
  };
76
+ export declare const PARSE_USERS_HEADERS: {
77
+ 'Content-Type': string;
78
+ Accept: string;
79
+ Connection: string;
80
+ 'User-Agent': string;
81
+ 'X-Parse-Application-Id': string;
82
+ 'X-Parse-Installation-Id': string;
83
+ 'X-Parse-App-Build-Version': string;
84
+ 'X-Parse-App-Display-Version': string;
85
+ 'X-Parse-OS-Version': string;
86
+ };
74
87
  export declare const CODES_MAP: Record<number, APIErrorData>;
75
88
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,aAAa,6BAA6B,CAAC;AACxD,eAAO,MAAM,WAAW,qEAC4C,CAAC;AAIrE,eAAO,MAAM,eAAe;;;;;;;;;CAU3B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;CAM7B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;CAyB1B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;CAwB3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAiBlD,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,eAAO,MAAM,OAAO,6BAA6B,CAAC;AAClD,eAAO,MAAM,aAAa,6BAA6B,CAAC;AACxD,eAAO,MAAM,aAAa,6BAA6B,CAAC;AACxD,eAAO,MAAM,WAAW,qEAC4C,CAAC;AACrE,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAIrC,eAAO,MAAM,eAAe;;;;;;;;;CAS3B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;CAM7B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;CAyB1B,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;CAwB3B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;CAU/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAqBlD,CAAC"}
package/dist/constants.js CHANGED
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
- // Constants
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.CODES_MAP = exports.PATCHED_IP_DATA = exports.PATCHED_DEVICE = exports.MOJO_AUTH_HEADERS = exports.WE_MESH_HEADERS = exports.HASH_SECRET = exports.MOJO_AUTH_URL = exports.API_URL = exports.VERSION = void 0;
5
- exports.VERSION = '1.2.1';
3
+ exports.CODES_MAP = exports.PARSE_USERS_HEADERS = exports.PATCHED_IP_DATA = exports.PATCHED_DEVICE = exports.MOJO_AUTH_HEADERS = exports.WE_MESH_HEADERS = exports.DEFAULT_LANGUAGE = exports.HASH_SECRET = exports.MOJO_AUTH_URL = exports.THIRD_API_URL = exports.API_URL = exports.VERSION = void 0;
4
+ // Constants
5
+ exports.VERSION = '1.4.2';
6
6
  exports.API_URL = 'https://api1.a-l-p-a.com';
7
+ exports.THIRD_API_URL = 'https://api3.a-l-p-a.com';
7
8
  exports.MOJO_AUTH_URL = 'https://api.mojoauth.com';
8
9
  exports.HASH_SECRET = 'c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2';
10
+ exports.DEFAULT_LANGUAGE = 'ru';
9
11
  // Structures
10
12
  exports.WE_MESH_HEADERS = {
11
13
  'Content-Type': 'application/json',
12
14
  Accept: 'application/json',
13
15
  Connection: 'keep-alive',
14
- 'User-Agent': 'Rave/2133 (8.1.93) (Android 15; 24117RN76O; Redmi tanzanite; ru)',
16
+ 'User-Agent': 'Rave/2133 (8.1.93) (Android 666; FuckRave; AndFuckYouAll; ru)',
15
17
  'WeMesh-API-Version': '4.0',
16
18
  'WeMesh-Platform': 'android',
17
19
  ssaid: '13c4e8d5fac67aff',
@@ -75,6 +77,17 @@ exports.PATCHED_IP_DATA = {
75
77
  timezone: 'Europe/Moscow',
76
78
  zip: '190990',
77
79
  };
80
+ exports.PARSE_USERS_HEADERS = {
81
+ 'Content-Type': 'application/json',
82
+ Accept: 'application/json',
83
+ Connection: 'keep-alive',
84
+ 'User-Agent': 'Parse Android SDK API Level 35',
85
+ 'X-Parse-Application-Id': '83a03c48-0f97-4f01-8a80-f603ea2a2270',
86
+ 'X-Parse-Installation-Id': '810ea3e5-b316-4409-afe7-a0abbef37ac2',
87
+ 'X-Parse-App-Build-Version': '2133',
88
+ 'X-Parse-App-Display-Version': '8.1.93',
89
+ 'X-Parse-OS-Version': '15',
90
+ };
78
91
  exports.CODES_MAP = {
79
92
  400: {
80
93
  name: 'RaveJSException.BadRequest',
@@ -92,4 +105,8 @@ exports.CODES_MAP = {
92
105
  name: 'RaveJSException.NotFound',
93
106
  message: 'Not Found. Resource not found.',
94
107
  },
108
+ 429: {
109
+ name: 'RaveJSException.RateLimitExceeded',
110
+ message: 'Rate Limit Exceeded. Too many requests.',
111
+ },
95
112
  };
@@ -1,15 +1,16 @@
1
1
  import { z } from 'zod';
2
- import { HeadersType } from '../schemas/private';
3
- import { GetRequestConfig, PostRequestConfig } from '../schemas/configs';
2
+ import { GetRequestConfig, PostRequestConfig, RawRequestConfig } from '../schemas/configs';
4
3
  export declare class HttpWorkflow {
5
4
  private __headers;
6
- set headers(headers: HeadersType);
5
+ get token(): string;
6
+ set token(token: string);
7
+ set popHeaders(key: string);
7
8
  private __configureHeaders;
8
- private __configureDataHeaders;
9
9
  private __handleResponse;
10
10
  private __sendDataRequest;
11
11
  sendGet: <T>(config: GetRequestConfig, schema: z.ZodSchema) => Promise<T>;
12
12
  sendPost: <T>(config: PostRequestConfig, schema: z.ZodSchema) => Promise<T>;
13
13
  sendPut: <T>(config: PostRequestConfig, schema: z.ZodSchema) => Promise<T>;
14
+ sendRaw: <T>(config: RawRequestConfig, schema: z.ZodSchema) => Promise<T>;
14
15
  }
15
16
  //# sourceMappingURL=httpworkflow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"httpworkflow.d.ts","sourceRoot":"","sources":["../../src/core/httpworkflow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAc,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIzE,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAgC;IAEjD,IAAI,OAAO,CAAC,OAAO,EAAE,WAAW,EAK/B;IAED,OAAO,CAAC,kBAAkB,CAKxB;IAEF,OAAO,CAAC,sBAAsB,CAW5B;IAEF,OAAO,CAAC,gBAAgB,CAetB;IAEF,OAAO,CAAC,iBAAiB,CAiBvB;IAEK,OAAO,GAAU,CAAC,UACf,gBAAgB,UAChB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAYX;IAEK,QAAQ,GAAU,CAAC,UAChB,iBAAiB,UACjB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAEX;IAEK,OAAO,GAAU,CAAC,UACf,iBAAiB,UACjB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAEX;CACH"}
1
+ {"version":3,"file":"httpworkflow.d.ts","sourceRoot":"","sources":["../../src/core/httpworkflow.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAI5B,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAgC;IAEjD,IAAI,KAAK,IAAI,MAAM,CAKlB;IAED,IAAI,KAAK,CAAC,KAAK,EAAE,MAAM,EAEtB;IAED,IAAI,UAAU,CAAC,GAAG,EAAE,MAAM,EAEzB;IAED,OAAO,CAAC,kBAAkB,CAQxB;IAEF,OAAO,CAAC,gBAAgB,CAetB;IAEF,OAAO,CAAC,iBAAiB,CAiBvB;IAEK,OAAO,GAAU,CAAC,UACf,gBAAgB,UAChB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAYX;IAEK,QAAQ,GAAU,CAAC,UAChB,iBAAiB,UACjB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAEX;IAEK,OAAO,GAAU,CAAC,UACf,iBAAiB,UACjB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAEX;IAEK,OAAO,GAAU,CAAC,UACf,gBAAgB,UAChB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAQX;CACH"}
@@ -10,12 +10,9 @@ const exceptions_1 = require("../utils/exceptions");
10
10
  class HttpWorkflow {
11
11
  constructor() {
12
12
  this.__headers = constants_1.WE_MESH_HEADERS;
13
- this.__configureHeaders = () => {
14
- return Object.assign(Object.assign({}, this.__headers), { 'request-ts': Date.now().toString() });
15
- };
16
- this.__configureDataHeaders = (data) => {
17
- const headers = this.__configureHeaders();
18
- return Object.assign(Object.assign({}, headers), { 'request-hash': (0, cryptography_1.generateHash)(headers.Authorization.slice(7, headers.Authorization.length), headers['request-ts'], data.length) });
13
+ this.__configureHeaders = (data) => {
14
+ const timestamp = Date.now().toString();
15
+ return Object.assign(Object.assign({}, this.__headers), { 'request-ts': timestamp, 'request-hash': (0, cryptography_1.generateHash)(this.token, timestamp, (data === null || data === void 0 ? void 0 : data.length) || 0) });
19
16
  };
20
17
  this.__handleResponse = async (statusCode, fullPath, body, schema) => {
21
18
  if (!(0, utils_1.isOk)(statusCode)) {
@@ -29,7 +26,7 @@ class HttpWorkflow {
29
26
  this.__sendDataRequest = async (method, config, schema) => {
30
27
  const { statusCode, body } = await (0, undici_1.request)(`${constants_1.API_URL}${config.path}`, {
31
28
  method,
32
- headers: this.__configureDataHeaders(config.body),
29
+ headers: this.__configureHeaders(config.body),
33
30
  body: config.body,
34
31
  });
35
32
  return await this.__handleResponse(statusCode, `${constants_1.API_URL}${config.path}`, body, schema);
@@ -47,9 +44,23 @@ class HttpWorkflow {
47
44
  this.sendPut = async (config, schema) => {
48
45
  return await this.__sendDataRequest('PUT', config, schema);
49
46
  };
47
+ this.sendRaw = async (config, schema) => {
48
+ const { statusCode, body } = await (0, undici_1.request)(config.path, {
49
+ headers: config.headers,
50
+ method: config.method,
51
+ body: config.body,
52
+ });
53
+ return await this.__handleResponse(statusCode, config.path, body, schema);
54
+ };
55
+ }
56
+ get token() {
57
+ return this.__headers.Authorization.slice(7, this.__headers.Authorization.length);
58
+ }
59
+ set token(token) {
60
+ this.__headers.Authorization = `Bearer ${token}`;
50
61
  }
51
- set headers(headers) {
52
- this.__headers = Object.assign(Object.assign({}, headers), this.__headers);
62
+ set popHeaders(key) {
63
+ delete this.__headers[key];
53
64
  }
54
65
  }
55
66
  exports.HttpWorkflow = HttpWorkflow;
@@ -1,10 +1,16 @@
1
+ import { AuthFactory } from '../factories/auth-factory';
2
+ import { MeshFactory } from '../factories/mesh-factory';
1
3
  import { UserFactory } from '../factories/user-factory';
2
4
  import { RaveConfig } from '../schemas/public';
3
5
  export declare class Rave {
4
6
  private __config?;
5
7
  private __http;
8
+ private __authFactory?;
6
9
  private __userFactory?;
10
+ private __meshFactory?;
7
11
  constructor(config?: RaveConfig);
12
+ get auth(): AuthFactory;
8
13
  get user(): UserFactory;
14
+ get mesh(): MeshFactory;
9
15
  }
10
16
  //# sourceMappingURL=rave.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rave.d.ts","sourceRoot":"","sources":["../../src/core/rave.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,aAAa,CAAC,CAAc;gBAExB,MAAM,GAAE,UAAe;IAUnC,IAAI,IAAI,gBAIP;CACF"}
1
+ {"version":3,"file":"rave.d.ts","sourceRoot":"","sources":["../../src/core/rave.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,MAAM,CAAe;IAE7B,OAAO,CAAC,aAAa,CAAC,CAAc;IACpC,OAAO,CAAC,aAAa,CAAC,CAAc;IACpC,OAAO,CAAC,aAAa,CAAC,CAAc;gBAExB,MAAM,GAAE,UAAe;IASnC,IAAI,IAAI,gBAIP;IAED,IAAI,IAAI,gBAIP;IAED,IAAI,IAAI,gBAIP;CACF"}
package/dist/core/rave.js CHANGED
@@ -4,23 +4,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Rave = void 0;
7
+ const auth_factory_1 = require("../factories/auth-factory");
8
+ const mesh_factory_1 = require("../factories/mesh-factory");
7
9
  const user_factory_1 = require("../factories/user-factory");
8
10
  const logger_1 = __importDefault(require("../utils/logger"));
9
11
  const httpworkflow_1 = require("./httpworkflow");
10
12
  class Rave {
11
13
  constructor(config = {}) {
12
- var _a;
13
14
  this.__config = config;
14
15
  this.__http = new httpworkflow_1.HttpWorkflow();
15
- this.__http.headers = {
16
- Authorization: `Bearer ${(_a = this.__config.credentials) === null || _a === void 0 ? void 0 : _a.token}`,
17
- };
16
+ if (this.__config.credentials)
17
+ this.__http.token = this.__config.credentials.token;
18
18
  (0, logger_1.default)(!!config.enableLogging);
19
19
  }
20
+ get auth() {
21
+ if (!this.__authFactory)
22
+ return (this.__authFactory = new auth_factory_1.AuthFactory(this.__config, this.__http));
23
+ return this.__authFactory;
24
+ }
20
25
  get user() {
21
26
  if (!this.__userFactory)
22
27
  return (this.__userFactory = new user_factory_1.UserFactory(this.__http));
23
28
  return this.__userFactory;
24
29
  }
30
+ get mesh() {
31
+ if (!this.__meshFactory)
32
+ return (this.__meshFactory = new mesh_factory_1.MeshFactory(this.__config, this.__http));
33
+ return this.__meshFactory;
34
+ }
25
35
  }
26
36
  exports.Rave = Rave;
@@ -0,0 +1,16 @@
1
+ import { HttpWorkflow } from '../core/httpworkflow';
2
+ import { RaveConfig } from '../schemas';
3
+ import { AuthenticateResponse, CheckRegisterStateResponse, MojoLoginResponse, ParseUserCredentialsResponse, SendMagicLinkResponse } from '../schemas/responses';
4
+ export declare class AuthFactory {
5
+ private __config;
6
+ private readonly __http;
7
+ constructor(config: RaveConfig | undefined, http: HttpWorkflow);
8
+ private __authenticator;
9
+ sendMagicLink: (email: string, language?: string) => Promise<SendMagicLinkResponse>;
10
+ checkRegisterState: (stateId: string) => Promise<CheckRegisterStateResponse>;
11
+ parseUserCredentials: (idToken: string, email: string) => Promise<ParseUserCredentialsResponse>;
12
+ mojoLogin: (email: string, parseId: string, parseToken: string, name: string, deviceId?: string, language?: string) => Promise<MojoLoginResponse>;
13
+ login: (stateId: string, name?: string, deviceId?: string, language?: string) => Promise<AuthenticateResponse>;
14
+ register: (stateId: string, name?: string, deviceId?: string, language?: string) => Promise<AuthenticateResponse>;
15
+ }
16
+ //# sourceMappingURL=auth-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-factory.d.ts","sourceRoot":"","sources":["../../src/factories/auth-factory.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAEL,oBAAoB,EACpB,0BAA0B,EAE1B,iBAAiB,EAEjB,4BAA4B,EAE5B,qBAAqB,EAEtB,MAAM,sBAAsB,CAAC;AAI9B,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,UAAU,YAAK,EAAE,IAAI,EAAE,YAAY;IAKvD,OAAO,CAAC,eAAe,CAsCrB;IAEK,aAAa,UACX,MAAM,aACH,MAAM,KACf,OAAO,CAAC,qBAAqB,CAAC,CAU/B;IAEK,kBAAkB,YACd,MAAM,KACd,OAAO,CAAC,0BAA0B,CAAC,CASpC;IAEK,oBAAoB,YAChB,MAAM,SACR,MAAM,KACZ,OAAO,CAAC,4BAA4B,CAAC,CAiBtC;IAEK,SAAS,UACP,MAAM,WACJ,MAAM,cACH,MAAM,QACZ,MAAM,aACF,MAAM,aACN,MAAM,KACf,OAAO,CAAC,iBAAiB,CAAC,CAsB3B;IAEK,KAAK,YACD,MAAM,SACR,MAAM,aACF,MAAM,aACN,MAAM,KAChB,OAAO,CAAC,oBAAoB,CAAC,CAQ9B;IAEK,QAAQ,YACJ,MAAM,SACR,MAAM,aACF,MAAM,aACN,MAAM,KAChB,OAAO,CAAC,oBAAoB,CAAC,CAQ9B;CACH"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthFactory = void 0;
4
+ const constants_1 = require("../constants");
5
+ const responses_1 = require("../schemas/responses");
6
+ const cryptography_1 = require("../utils/cryptography");
7
+ const exceptions_1 = require("../utils/exceptions");
8
+ class AuthFactory {
9
+ constructor(config = {}, http) {
10
+ this.__authenticator = async (stateId, action, name = (0, cryptography_1.generateToken)(), deviceId = (0, cryptography_1.generateToken)(), language = constants_1.DEFAULT_LANGUAGE) => {
11
+ var _a;
12
+ const state = await this.checkRegisterState(stateId);
13
+ if (!state.authenticated) {
14
+ exceptions_1.APIException.throw(401);
15
+ }
16
+ const userCredentials = await this.parseUserCredentials(state.oauth.idToken, state.user.email);
17
+ const { data } = await this.mojoLogin(state.user.email, userCredentials.objectId, userCredentials.sessionToken, name, deviceId, language);
18
+ if (action == 'REGISTER')
19
+ this.__http.popHeaders = 'Authorization';
20
+ return responses_1.AuthenticateSchema.parse({
21
+ isNewUser: data.newUser,
22
+ email: (_a = state.user) === null || _a === void 0 ? void 0 : _a.email,
23
+ username: userCredentials.username,
24
+ deviceId: deviceId,
25
+ token: userCredentials.sessionToken.slice(2, userCredentials.sessionToken.length),
26
+ });
27
+ };
28
+ this.sendMagicLink = async (email, language = constants_1.DEFAULT_LANGUAGE) => {
29
+ return await this.__http.sendRaw({
30
+ method: 'POST',
31
+ path: `${constants_1.MOJO_AUTH_URL}/users/magiclink?language=${language}&redirect_url=https://rave.watch/mojoauth`,
32
+ body: JSON.stringify({ email }),
33
+ headers: constants_1.MOJO_AUTH_HEADERS,
34
+ }, responses_1.SendMagicLinkSchema);
35
+ };
36
+ this.checkRegisterState = async (stateId) => {
37
+ return await this.__http.sendRaw({
38
+ method: 'GET',
39
+ path: `${constants_1.MOJO_AUTH_URL}/users/status?state_id=${stateId}`,
40
+ headers: constants_1.MOJO_AUTH_HEADERS,
41
+ }, responses_1.CheckRegisterStateSchema);
42
+ };
43
+ this.parseUserCredentials = async (idToken, email) => {
44
+ return await this.__http.sendRaw({
45
+ method: 'POST',
46
+ headers: constants_1.PARSE_USERS_HEADERS,
47
+ path: `${constants_1.THIRD_API_URL}/parse/users`,
48
+ body: JSON.stringify({
49
+ authData: {
50
+ mojo: {
51
+ id_token: idToken,
52
+ id: email,
53
+ },
54
+ },
55
+ }),
56
+ }, responses_1.ParseUserCredentialsSchema);
57
+ };
58
+ this.mojoLogin = async (email, parseId, parseToken, name, deviceId = (0, cryptography_1.generateToken)(), language = constants_1.DEFAULT_LANGUAGE) => {
59
+ this.__http.token = parseToken.slice(1, parseToken.length);
60
+ this.__config.credentials = {
61
+ token: this.__http.token,
62
+ deviceId,
63
+ };
64
+ return await this.__http.sendPost({
65
+ path: '/auth2/mojo/login',
66
+ body: JSON.stringify({
67
+ deviceId,
68
+ email,
69
+ name,
70
+ parseId,
71
+ parseToken,
72
+ lang: language,
73
+ platId: email,
74
+ }),
75
+ }, responses_1.MojoLoginSchema);
76
+ };
77
+ this.login = async (stateId, name, deviceId, language) => {
78
+ return await this.__authenticator(stateId, 'LOGIN', name, deviceId, language);
79
+ };
80
+ this.register = async (stateId, name, deviceId, language) => {
81
+ return await this.__authenticator(stateId, 'REGISTER', name, deviceId, language);
82
+ };
83
+ this.__config = config;
84
+ this.__http = http;
85
+ }
86
+ }
87
+ exports.AuthFactory = AuthFactory;
@@ -0,0 +1,10 @@
1
+ import { HttpWorkflow } from '../core/httpworkflow';
2
+ import { GetManyMeshesParams, RaveConfig } from '../schemas';
3
+ import { GetManyMeshesResponse } from '../schemas/responses';
4
+ export declare class MeshFactory {
5
+ private readonly __config;
6
+ private readonly __http;
7
+ constructor(config: RaveConfig | undefined, http: HttpWorkflow);
8
+ getMany: (params?: GetManyMeshesParams) => Promise<GetManyMeshesResponse>;
9
+ }
10
+ //# sourceMappingURL=mesh-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh-factory.d.ts","sourceRoot":"","sources":["../../src/factories/mesh-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,qBAAqB,EAEtB,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,UAAU,YAAK,EAAE,IAAI,EAAE,YAAY;IAKhD,OAAO,YACJ,mBAAmB,KAC1B,OAAO,CAAC,qBAAqB,CAAC,CAO/B;CACH"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MeshFactory = void 0;
4
+ const constants_1 = require("../constants");
5
+ const responses_1 = require("../schemas/responses");
6
+ class MeshFactory {
7
+ constructor(config = {}, http) {
8
+ this.getMany = async (params = { limit: 20, language: constants_1.DEFAULT_LANGUAGE }) => {
9
+ var _a;
10
+ return await this.__http.sendGet({
11
+ path: `/meshes/self?deviceId=${(_a = this.__config.credentials) === null || _a === void 0 ? void 0 : _a.deviceId}&public=${!!params.isPublic}&friends=${!!params.hasFriends}&local=${!!params.local}&invited=${!!params.hasInvited}&limit=${params.limit}&lang=${params.language}`,
12
+ }, responses_1.GetManyMeshesSchema);
13
+ };
14
+ this.__config = config;
15
+ this.__http = http;
16
+ }
17
+ }
18
+ exports.MeshFactory = MeshFactory;
@@ -1,9 +1,12 @@
1
1
  import { HttpWorkflow } from '../core/httpworkflow';
2
2
  import { EditProfileBuilder } from '../schemas';
3
- import { EditProfileResponse } from '../schemas/responses';
3
+ import { EditProfileResponse, GetAvatarUploadResponse } from '../schemas/responses';
4
4
  export declare class UserFactory {
5
5
  private readonly __http;
6
6
  constructor(http: HttpWorkflow);
7
7
  edit: (builder: EditProfileBuilder) => Promise<EditProfileResponse>;
8
+ getAvatarUpload: () => Promise<GetAvatarUploadResponse>;
9
+ uploadOnUrl: (uploadUrl: string, image: Buffer) => Promise<any>;
10
+ uploadAvatar: (image: Buffer) => Promise<string>;
8
11
  }
9
12
  //# sourceMappingURL=user-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-factory.d.ts","sourceRoot":"","sources":["../../src/factories/user-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,IAAI,EAAE,YAAY;IAIvB,IAAI,YACA,kBAAkB,KAC1B,OAAO,CAAC,mBAAmB,CAAC,CAQ7B;CACH"}
1
+ {"version":3,"file":"user-factory.d.ts","sourceRoot":"","sources":["../../src/factories/user-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAA4B,MAAM,YAAY,CAAC;AAC1E,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EAExB,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,IAAI,EAAE,YAAY;IAIvB,IAAI,YACA,kBAAkB,KAC1B,OAAO,CAAC,mBAAmB,CAAC,CAQ7B;IAEK,eAAe,QAAa,OAAO,CAAC,uBAAuB,CAAC,CAQjE;IAEK,WAAW,cACL,MAAM,SACV,MAAM,KACZ,OAAO,CAAC,GAAG,CAAC,CAYb;IAEK,YAAY,UAAiB,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,CAI1D;CACH"}
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.UserFactory = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
4
8
  const schemas_1 = require("../schemas");
9
+ const responses_1 = require("../schemas/responses");
5
10
  class UserFactory {
6
11
  constructor(http) {
7
12
  this.edit = async (builder) => {
@@ -10,6 +15,27 @@ class UserFactory {
10
15
  body: JSON.stringify(builder),
11
16
  }, schemas_1.EditProfileBuilderSchema);
12
17
  };
18
+ this.getAvatarUpload = async () => {
19
+ return await this.__http.sendPost({
20
+ path: '/users/self/avatar/upload',
21
+ body: JSON.stringify({ mime: 'image/jpeg' }),
22
+ }, responses_1.GetAvatarUploadSchema);
23
+ };
24
+ this.uploadOnUrl = async (uploadUrl, image) => {
25
+ return await this.__http.sendRaw({
26
+ path: uploadUrl,
27
+ method: 'PUT',
28
+ body: image,
29
+ headers: {
30
+ 'Content-Type': 'image/jpeg',
31
+ },
32
+ }, zod_1.default.any());
33
+ };
34
+ this.uploadAvatar = async (image) => {
35
+ const { data } = await this.getAvatarUpload();
36
+ await this.uploadOnUrl(data.uploadUrl, image);
37
+ return data.uploadUrl;
38
+ };
13
39
  this.__http = http;
14
40
  }
15
41
  }
@@ -8,6 +8,13 @@ export declare const GetRequestConfigSchema: z.ZodObject<{
8
8
  path: z.ZodReadonly<z.ZodString>;
9
9
  contentType: z.ZodOptional<z.ZodString>;
10
10
  }, z.core.$strip>;
11
+ export declare const RawRequestConfigSchema: z.ZodObject<{
12
+ method: z.ZodString;
13
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
14
+ path: z.ZodReadonly<z.ZodString>;
15
+ body: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Buffer, Buffer>]>>;
16
+ }, z.core.$strip>;
11
17
  export type PostRequestConfig = z.infer<typeof PostRequestConfigSchema>;
12
18
  export type GetRequestConfig = z.infer<typeof GetRequestConfigSchema>;
19
+ export type RawRequestConfig = z.infer<typeof RawRequestConfigSchema>;
13
20
  //# sourceMappingURL=configs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/schemas/configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;iBAEjC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/schemas/configs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;iBAEjC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;iBAKjC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetRequestConfigSchema = exports.PostRequestConfigSchema = void 0;
3
+ exports.RawRequestConfigSchema = exports.GetRequestConfigSchema = exports.PostRequestConfigSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.PostRequestConfigSchema = zod_1.z.object({
6
6
  path: zod_1.z.string().readonly(),
@@ -10,3 +10,9 @@ exports.PostRequestConfigSchema = zod_1.z.object({
10
10
  exports.GetRequestConfigSchema = exports.PostRequestConfigSchema.omit({
11
11
  body: true,
12
12
  });
13
+ exports.RawRequestConfigSchema = zod_1.z.object({
14
+ method: zod_1.z.string(),
15
+ headers: zod_1.z.record(zod_1.z.string(), zod_1.z.string()).optional(),
16
+ path: zod_1.z.string().readonly(),
17
+ body: zod_1.z.union([zod_1.z.string(), zod_1.z.instanceof(Buffer)]).optional(),
18
+ });
@@ -1,2 +1,3 @@
1
1
  export * from './public';
2
+ export * from './rave/user';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC"}
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./public"), exports);
18
+ __exportStar(require("./rave/user"), exports);
@@ -1,4 +1,8 @@
1
1
  import z from 'zod';
2
+ export declare const LanguagesSchema: z.ZodEnum<{
3
+ ru: "ru";
4
+ en: "en";
5
+ }>;
2
6
  export declare const RaveConfigSchema: z.ZodObject<{
3
7
  credentials: z.ZodOptional<z.ZodObject<{
4
8
  token: z.ZodString;
@@ -11,6 +15,19 @@ export declare const EditProfileBuilderSchema: z.ZodObject<{
11
15
  displayName: z.ZodOptional<z.ZodString>;
12
16
  handle: z.ZodOptional<z.ZodString>;
13
17
  }, z.core.$strip>;
18
+ export declare const GetManyMeshesSchema: z.ZodObject<{
19
+ isPublic: z.ZodOptional<z.ZodBoolean>;
20
+ limit: z.ZodDefault<z.ZodNumber>;
21
+ hasFriends: z.ZodOptional<z.ZodBoolean>;
22
+ local: z.ZodOptional<z.ZodBoolean>;
23
+ hasInvited: z.ZodOptional<z.ZodBoolean>;
24
+ language: z.ZodEnum<{
25
+ ru: "ru";
26
+ en: "en";
27
+ }>;
28
+ }, z.core.$strip>;
14
29
  export type RaveConfig = z.infer<typeof RaveConfigSchema>;
15
30
  export type EditProfileBuilder = z.infer<typeof EditProfileBuilderSchema>;
31
+ export type GetManyMeshesParams = z.infer<typeof GetManyMeshesSchema>;
32
+ export type Languages = z.infer<typeof LanguagesSchema>;
16
33
  //# sourceMappingURL=public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/schemas/public.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,gBAAgB;;;;;;iBAQ3B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/schemas/public.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,eAAe;;;EAAuB,CAAC;AAEpD,eAAO,MAAM,gBAAgB;;;;;;iBAQ3B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;iBAInC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAO9B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACtE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EditProfileBuilderSchema = exports.RaveConfigSchema = void 0;
6
+ exports.GetManyMeshesSchema = exports.EditProfileBuilderSchema = exports.RaveConfigSchema = exports.LanguagesSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
+ exports.LanguagesSchema = zod_1.default.enum(['en', 'ru']);
8
9
  exports.RaveConfigSchema = zod_1.default.object({
9
10
  credentials: zod_1.default
10
11
  .object({
@@ -19,3 +20,11 @@ exports.EditProfileBuilderSchema = zod_1.default.object({
19
20
  displayName: zod_1.default.string().optional(),
20
21
  handle: zod_1.default.string().optional(),
21
22
  });
23
+ exports.GetManyMeshesSchema = zod_1.default.object({
24
+ isPublic: zod_1.default.boolean().optional(),
25
+ limit: zod_1.default.number().default(20),
26
+ hasFriends: zod_1.default.boolean().optional(),
27
+ local: zod_1.default.boolean().optional(),
28
+ hasInvited: zod_1.default.boolean().optional(),
29
+ language: exports.LanguagesSchema,
30
+ });
@@ -0,0 +1,44 @@
1
+ import z from 'zod';
2
+ export declare const MeshSchema: z.ZodObject<{
3
+ blurT: z.ZodBoolean;
4
+ category: z.ZodString;
5
+ channel: z.ZodNumber;
6
+ createdAt: z.ZodString;
7
+ currentState: z.ZodEnum<{
8
+ play: "play";
9
+ paus: "paus";
10
+ }>;
11
+ explicit: z.ZodBoolean;
12
+ id: z.ZodString;
13
+ isFriend: z.ZodBoolean;
14
+ isLocal: z.ZodBoolean;
15
+ isPublic: z.ZodBoolean;
16
+ kickMode: z.ZodString;
17
+ maturity: z.ZodString;
18
+ mediaUrl: z.ZodString;
19
+ originator: z.ZodNumber;
20
+ playMode: z.ZodString;
21
+ position: z.ZodFloat32;
22
+ server: z.ZodString;
23
+ shareLink: z.ZodString;
24
+ thumbnails: z.ZodOptional<z.ZodObject<{
25
+ channel: z.ZodOptional<z.ZodString>;
26
+ standard: z.ZodOptional<z.ZodString>;
27
+ animated: z.ZodOptional<z.ZodString>;
28
+ maxres: z.ZodOptional<z.ZodString>;
29
+ medium: z.ZodOptional<z.ZodString>;
30
+ default: z.ZodOptional<z.ZodString>;
31
+ high: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>>;
33
+ time: z.ZodFloat32;
34
+ videoAuthor: z.ZodString;
35
+ videoDuration: z.ZodNumber;
36
+ videoProvider: z.ZodString;
37
+ videoPublishedAt: z.ZodString;
38
+ videoThumbnail: z.ZodString;
39
+ videoTitle: z.ZodString;
40
+ videoUrl: z.ZodString;
41
+ vikiPass: z.ZodBoolean;
42
+ voipMode: z.ZodString;
43
+ }, z.core.$strip>;
44
+ //# sourceMappingURL=mesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh.d.ts","sourceRoot":"","sources":["../../../src/schemas/rave/mesh.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAwCrB,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MeshSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.MeshSchema = zod_1.default.object({
9
+ blurT: zod_1.default.boolean(),
10
+ category: zod_1.default.string(),
11
+ channel: zod_1.default.number(),
12
+ createdAt: zod_1.default.string(),
13
+ currentState: zod_1.default.enum(['play', 'paus']),
14
+ explicit: zod_1.default.boolean(),
15
+ id: zod_1.default.string(),
16
+ isFriend: zod_1.default.boolean(),
17
+ isLocal: zod_1.default.boolean(),
18
+ isPublic: zod_1.default.boolean(),
19
+ kickMode: zod_1.default.string(),
20
+ maturity: zod_1.default.string(),
21
+ mediaUrl: zod_1.default.string(),
22
+ originator: zod_1.default.number(),
23
+ playMode: zod_1.default.string(),
24
+ position: zod_1.default.float32(),
25
+ server: zod_1.default.string(),
26
+ shareLink: zod_1.default.string(),
27
+ thumbnails: zod_1.default
28
+ .object({
29
+ channel: zod_1.default.string().optional(),
30
+ standard: zod_1.default.string().optional(),
31
+ animated: zod_1.default.string().optional(),
32
+ maxres: zod_1.default.string().optional(),
33
+ medium: zod_1.default.string().optional(),
34
+ default: zod_1.default.string().optional(),
35
+ high: zod_1.default.string().optional(),
36
+ })
37
+ .optional(),
38
+ time: zod_1.default.float32(),
39
+ videoAuthor: zod_1.default.string(),
40
+ videoDuration: zod_1.default.number(),
41
+ videoProvider: zod_1.default.string(),
42
+ videoPublishedAt: zod_1.default.string(),
43
+ videoThumbnail: zod_1.default.string(),
44
+ videoTitle: zod_1.default.string(),
45
+ videoUrl: zod_1.default.string(),
46
+ vikiPass: zod_1.default.boolean(),
47
+ voipMode: zod_1.default.string(),
48
+ });
@@ -2,7 +2,7 @@ import z from 'zod';
2
2
  export declare const UserSchema: z.ZodObject<{
3
3
  avatar: z.ZodString;
4
4
  country: z.ZodString;
5
- displayName: z.ZodString;
5
+ displayName: z.ZodOptional<z.ZodString>;
6
6
  handle: z.ZodString;
7
7
  id: z.ZodNumber;
8
8
  lang: z.ZodString;
@@ -8,7 +8,7 @@ const zod_1 = __importDefault(require("zod"));
8
8
  exports.UserSchema = zod_1.default.object({
9
9
  avatar: zod_1.default.string(),
10
10
  country: zod_1.default.string(),
11
- displayName: zod_1.default.string(),
11
+ displayName: zod_1.default.string().optional(),
12
12
  handle: zod_1.default.string(),
13
13
  id: zod_1.default.number(),
14
14
  lang: zod_1.default.string(),
@@ -1,9 +1,9 @@
1
1
  import z from 'zod';
2
- export declare const EditProfileResponseSchema: z.ZodObject<{
2
+ export declare const EditProfileSchema: z.ZodObject<{
3
3
  data: z.ZodObject<{
4
4
  avatar: z.ZodString;
5
5
  country: z.ZodString;
6
- displayName: z.ZodString;
6
+ displayName: z.ZodOptional<z.ZodString>;
7
7
  handle: z.ZodString;
8
8
  id: z.ZodNumber;
9
9
  lang: z.ZodString;
@@ -12,5 +12,162 @@ export declare const EditProfileResponseSchema: z.ZodObject<{
12
12
  name: z.ZodString;
13
13
  }, z.core.$strip>;
14
14
  }, z.core.$strip>;
15
- export type EditProfileResponse = z.infer<typeof EditProfileResponseSchema>;
15
+ export declare const SendMagicLinkSchema: z.ZodPipe<z.ZodObject<{
16
+ state_id: z.ZodString;
17
+ }, z.core.$strip>, z.ZodTransform<{
18
+ stateId: string;
19
+ }, {
20
+ state_id: string;
21
+ }>>;
22
+ export declare const CheckRegisterStateSchema: z.ZodPipe<z.ZodObject<{
23
+ authenticated: z.ZodBoolean;
24
+ is_second_factor_login: z.ZodOptional<z.ZodBoolean>;
25
+ oauth: z.ZodOptional<z.ZodObject<{
26
+ access_token: z.ZodString;
27
+ id_token: z.ZodString;
28
+ refresh_token: z.ZodString;
29
+ expires_in: z.ZodString;
30
+ token_type: z.ZodString;
31
+ }, z.core.$strip>>;
32
+ user: z.ZodOptional<z.ZodObject<{
33
+ created_at: z.ZodString;
34
+ updated_at: z.ZodString;
35
+ issuer: z.ZodString;
36
+ user_id: z.ZodString;
37
+ identifier: z.ZodString;
38
+ email: z.ZodString;
39
+ }, z.core.$strip>>;
40
+ }, z.core.$strip>, z.ZodTransform<{
41
+ authenticated: boolean;
42
+ isSecondFactorLogin: boolean | undefined;
43
+ oauth: {
44
+ accessToken: string;
45
+ idToken: string;
46
+ refreshToken: string;
47
+ expiresIn: string;
48
+ tokenType: string;
49
+ } | undefined;
50
+ user: {
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ issuer: string;
54
+ userId: string;
55
+ identifier: string;
56
+ email: string;
57
+ } | undefined;
58
+ }, {
59
+ authenticated: boolean;
60
+ is_second_factor_login?: boolean | undefined;
61
+ oauth?: {
62
+ access_token: string;
63
+ id_token: string;
64
+ refresh_token: string;
65
+ expires_in: string;
66
+ token_type: string;
67
+ } | undefined;
68
+ user?: {
69
+ created_at: string;
70
+ updated_at: string;
71
+ issuer: string;
72
+ user_id: string;
73
+ identifier: string;
74
+ email: string;
75
+ } | undefined;
76
+ }>>;
77
+ export declare const ParseUserCredentialsSchema: z.ZodObject<{
78
+ objectId: z.ZodString;
79
+ createdAt: z.ZodString;
80
+ username: z.ZodString;
81
+ sessionToken: z.ZodString;
82
+ }, z.core.$strip>;
83
+ export declare const MojoLoginSchema: z.ZodObject<{
84
+ data: z.ZodObject<{
85
+ isValid: z.ZodBoolean;
86
+ newUser: z.ZodBoolean;
87
+ suggestedHandles: z.ZodArray<z.ZodString>;
88
+ }, z.core.$strip>;
89
+ }, z.core.$strip>;
90
+ export declare const AuthenticateSchema: z.ZodObject<{
91
+ isNewUser: z.ZodBoolean;
92
+ email: z.ZodString;
93
+ username: z.ZodString;
94
+ deviceId: z.ZodString;
95
+ token: z.ZodString;
96
+ }, z.core.$strip>;
97
+ export declare const GetAvatarUploadSchema: z.ZodObject<{
98
+ data: z.ZodObject<{
99
+ expiresAt: z.ZodString;
100
+ fileName: z.ZodString;
101
+ mime: z.ZodString;
102
+ uploadUrl: z.ZodString;
103
+ }, z.core.$strip>;
104
+ }, z.core.$strip>;
105
+ export declare const GetManyMeshesSchema: z.ZodObject<{
106
+ data: z.ZodArray<z.ZodObject<{
107
+ mesh: z.ZodObject<{
108
+ blurT: z.ZodBoolean;
109
+ category: z.ZodString;
110
+ channel: z.ZodNumber;
111
+ createdAt: z.ZodString;
112
+ currentState: z.ZodEnum<{
113
+ play: "play";
114
+ paus: "paus";
115
+ }>;
116
+ explicit: z.ZodBoolean;
117
+ id: z.ZodString;
118
+ isFriend: z.ZodBoolean;
119
+ isLocal: z.ZodBoolean;
120
+ isPublic: z.ZodBoolean;
121
+ kickMode: z.ZodString;
122
+ maturity: z.ZodString;
123
+ mediaUrl: z.ZodString;
124
+ originator: z.ZodNumber;
125
+ playMode: z.ZodString;
126
+ position: z.ZodFloat32;
127
+ server: z.ZodString;
128
+ shareLink: z.ZodString;
129
+ thumbnails: z.ZodOptional<z.ZodObject<{
130
+ channel: z.ZodOptional<z.ZodString>;
131
+ standard: z.ZodOptional<z.ZodString>;
132
+ animated: z.ZodOptional<z.ZodString>;
133
+ maxres: z.ZodOptional<z.ZodString>;
134
+ medium: z.ZodOptional<z.ZodString>;
135
+ default: z.ZodOptional<z.ZodString>;
136
+ high: z.ZodOptional<z.ZodString>;
137
+ }, z.core.$strip>>;
138
+ time: z.ZodFloat32;
139
+ videoAuthor: z.ZodString;
140
+ videoDuration: z.ZodNumber;
141
+ videoProvider: z.ZodString;
142
+ videoPublishedAt: z.ZodString;
143
+ videoThumbnail: z.ZodString;
144
+ videoTitle: z.ZodString;
145
+ videoUrl: z.ZodString;
146
+ vikiPass: z.ZodBoolean;
147
+ voipMode: z.ZodString;
148
+ }, z.core.$strip>;
149
+ users: z.ZodArray<z.ZodObject<{
150
+ avatar: z.ZodString;
151
+ country: z.ZodString;
152
+ displayName: z.ZodOptional<z.ZodString>;
153
+ handle: z.ZodString;
154
+ id: z.ZodNumber;
155
+ lang: z.ZodString;
156
+ lat: z.ZodFloat32;
157
+ lng: z.ZodFloat32;
158
+ name: z.ZodString;
159
+ }, z.core.$strip>>;
160
+ }, z.core.$strip>>;
161
+ paging: z.ZodOptional<z.ZodObject<{
162
+ next: z.ZodOptional<z.ZodString>;
163
+ }, z.core.$strip>>;
164
+ }, z.core.$strip>;
165
+ export type EditProfileResponse = z.infer<typeof EditProfileSchema>;
166
+ export type SendMagicLinkResponse = z.infer<typeof SendMagicLinkSchema>;
167
+ export type CheckRegisterStateResponse = z.infer<typeof CheckRegisterStateSchema>;
168
+ export type ParseUserCredentialsResponse = z.infer<typeof ParseUserCredentialsSchema>;
169
+ export type MojoLoginResponse = z.infer<typeof MojoLoginSchema>;
170
+ export type AuthenticateResponse = z.infer<typeof AuthenticateSchema>;
171
+ export type GetAvatarUploadResponse = z.infer<typeof GetAvatarUploadSchema>;
172
+ export type GetManyMeshesResponse = z.infer<typeof GetManyMeshesSchema>;
16
173
  //# sourceMappingURL=responses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/schemas/responses.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;iBAEpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
1
+ {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/schemas/responses.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAIpB,eAAO,MAAM,iBAAiB;;;;;;;;;;;;iBAE5B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;GAQ5B,CAAC;AAEL,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDjC,CAAC;AAEL,eAAO,MAAM,0BAA0B;;;;;iBAKrC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;iBAM1B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;iBAM7B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;iBAOhC,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACpE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACxE,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,wBAAwB,CAChC,CAAC;AACF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,0BAA0B,CAClC,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAChE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACtE,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC5E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -3,9 +3,107 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EditProfileResponseSchema = void 0;
6
+ exports.GetManyMeshesSchema = exports.GetAvatarUploadSchema = exports.AuthenticateSchema = exports.MojoLoginSchema = exports.ParseUserCredentialsSchema = exports.CheckRegisterStateSchema = exports.SendMagicLinkSchema = exports.EditProfileSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
8
  const user_1 = require("./rave/user");
9
- exports.EditProfileResponseSchema = zod_1.default.object({
9
+ const mesh_1 = require("./rave/mesh");
10
+ exports.EditProfileSchema = zod_1.default.object({
10
11
  data: user_1.UserSchema,
11
12
  });
13
+ exports.SendMagicLinkSchema = zod_1.default
14
+ .object({
15
+ state_id: zod_1.default.string(),
16
+ })
17
+ .transform((data) => {
18
+ return {
19
+ stateId: data.state_id,
20
+ };
21
+ });
22
+ exports.CheckRegisterStateSchema = zod_1.default
23
+ .object({
24
+ authenticated: zod_1.default.boolean(),
25
+ is_second_factor_login: zod_1.default.boolean().optional(),
26
+ oauth: zod_1.default
27
+ .object({
28
+ access_token: zod_1.default.string(),
29
+ id_token: zod_1.default.string(),
30
+ refresh_token: zod_1.default.string(),
31
+ expires_in: zod_1.default.string(),
32
+ token_type: zod_1.default.string(),
33
+ })
34
+ .optional(),
35
+ user: zod_1.default
36
+ .object({
37
+ created_at: zod_1.default.string(),
38
+ updated_at: zod_1.default.string(),
39
+ issuer: zod_1.default.string(),
40
+ user_id: zod_1.default.string(),
41
+ identifier: zod_1.default.string(),
42
+ email: zod_1.default.string(),
43
+ })
44
+ .optional(),
45
+ })
46
+ .transform((data) => {
47
+ return {
48
+ authenticated: data.authenticated,
49
+ isSecondFactorLogin: data.is_second_factor_login,
50
+ oauth: data.oauth
51
+ ? {
52
+ accessToken: data.oauth.access_token,
53
+ idToken: data.oauth.id_token,
54
+ refreshToken: data.oauth.refresh_token,
55
+ expiresIn: data.oauth.expires_in,
56
+ tokenType: data.oauth.token_type,
57
+ }
58
+ : undefined,
59
+ user: data.user
60
+ ? {
61
+ createdAt: data.user.created_at,
62
+ updatedAt: data.user.updated_at,
63
+ issuer: data.user.issuer,
64
+ userId: data.user.user_id,
65
+ identifier: data.user.identifier,
66
+ email: data.user.email,
67
+ }
68
+ : undefined,
69
+ };
70
+ });
71
+ exports.ParseUserCredentialsSchema = zod_1.default.object({
72
+ objectId: zod_1.default.string(),
73
+ createdAt: zod_1.default.string(),
74
+ username: zod_1.default.string(),
75
+ sessionToken: zod_1.default.string(),
76
+ });
77
+ exports.MojoLoginSchema = zod_1.default.object({
78
+ data: zod_1.default.object({
79
+ isValid: zod_1.default.boolean(),
80
+ newUser: zod_1.default.boolean(),
81
+ suggestedHandles: zod_1.default.array(zod_1.default.string()),
82
+ }),
83
+ });
84
+ exports.AuthenticateSchema = zod_1.default.object({
85
+ isNewUser: zod_1.default.boolean(),
86
+ email: zod_1.default.string(),
87
+ username: zod_1.default.string(),
88
+ deviceId: zod_1.default.string(),
89
+ token: zod_1.default.string(),
90
+ });
91
+ exports.GetAvatarUploadSchema = zod_1.default.object({
92
+ data: zod_1.default.object({
93
+ expiresAt: zod_1.default.string(),
94
+ fileName: zod_1.default.string(),
95
+ mime: zod_1.default.string(),
96
+ uploadUrl: zod_1.default.string(),
97
+ }),
98
+ });
99
+ exports.GetManyMeshesSchema = zod_1.default.object({
100
+ data: zod_1.default.array(zod_1.default.object({
101
+ mesh: mesh_1.MeshSchema,
102
+ users: zod_1.default.array(user_1.UserSchema),
103
+ })),
104
+ paging: zod_1.default
105
+ .object({
106
+ next: zod_1.default.string().optional(),
107
+ })
108
+ .optional(),
109
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"cryptography.d.ts","sourceRoot":"","sources":["../../src/utils/cryptography.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,YAAY,UAChB,MAAM,aACF,MAAM,iBACF,MAAM,WAMtB,CAAC;AAEF,eAAO,MAAM,aAAa,cAKzB,CAAC"}
1
+ {"version":3,"file":"cryptography.d.ts","sourceRoot":"","sources":["../../src/utils/cryptography.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,UAChB,MAAM,aACF,MAAM,iBACF,MAAM,WAMtB,CAAC;AAEF,eAAO,MAAM,aAAa,cAOzB,CAAC"}
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateToken = exports.generateHash = void 0;
4
4
  const crypto_1 = require("crypto");
5
- const uuid_1 = require("uuid");
6
5
  const constants_1 = require("../constants");
7
6
  const generateHash = (token, timestamp, contentLength) => {
8
7
  const hash = (0, crypto_1.createHmac)('sha256', constants_1.HASH_SECRET)
@@ -12,9 +11,11 @@ const generateHash = (token, timestamp, contentLength) => {
12
11
  };
13
12
  exports.generateHash = generateHash;
14
13
  const generateToken = () => {
15
- return (0, uuid_1.v4)().replace(/[xy]/g, (c) => {
14
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
15
+ .replace(/[xy]/g, (c) => {
16
16
  const r = (Math.random() * 16) | 0;
17
17
  return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
18
- });
18
+ })
19
+ .replace(/-/g, '');
19
20
  };
20
21
  exports.generateToken = generateToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ravejs",
3
- "version": "1.2.1",
3
+ "version": "1.4.2",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "files": [