ravejs 1.1.1 → 1.3.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.
@@ -1,8 +1,10 @@
1
1
  import { APIErrorData } from './schemas/error';
2
- export declare const VERSION = "1.1.1";
2
+ export declare const VERSION = "1.3.1";
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;;;;;;;;;CAS3B,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":"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,aAAa,6BAA6B,CAAC;AACxD,eAAO,MAAM,WAAW,qEAC4C,CAAC;AACrE,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAIrC,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,mBAAmB;;;;;;;;;;CAU/B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAiBlD,CAAC"}
package/dist/constants.js CHANGED
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  // Constants
3
3
  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.1.1';
4
+ 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;
5
+ exports.VERSION = '1.3.1';
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 666; FuckYourApp; AminoDorks; ru)',
16
+ 'User-Agent': 'Rave/2133 (8.1.93) (Android 15; 24117RN76O; Redmi tanzanite; 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',
@@ -1,13 +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);
7
- private __configureGetHeaders;
8
- private __configurePostHeaders;
5
+ get token(): string;
6
+ set token(token: string);
7
+ private __configureHeaders;
8
+ private __configureDataHeaders;
9
9
  private __handleResponse;
10
+ private __sendDataRequest;
10
11
  sendGet: <T>(config: GetRequestConfig, schema: z.ZodSchema) => Promise<T>;
11
12
  sendPost: <T>(config: PostRequestConfig, schema: z.ZodSchema) => Promise<T>;
13
+ sendPut: <T>(config: PostRequestConfig, schema: z.ZodSchema) => Promise<T>;
14
+ sendRaw: <T>(config: RawRequestConfig, schema: z.ZodSchema) => Promise<T>;
12
15
  }
13
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,EAAE,MAAM,oBAAoB,CAAC;AAGjD,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,qBAAqB,CAK3B;IAEF,OAAO,CAAC,sBAAsB,CAW5B;IAEF,OAAO,CAAC,gBAAgB,CAetB;IAEK,OAAO,GAAU,CAAC,UACf,gBAAgB,UAChB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAOX;IAEK,QAAQ,GAAU,CAAC,UAChB,iBAAiB,UACjB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAQX;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,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;IAEK,OAAO,GAAU,CAAC,UACf,gBAAgB,UAChB,CAAC,CAAC,SAAS,KAClB,OAAO,CAAC,CAAC,CAAC,CAQX;CACH"}
@@ -10,12 +10,12 @@ const exceptions_1 = require("../utils/exceptions");
10
10
  class HttpWorkflow {
11
11
  constructor() {
12
12
  this.__headers = constants_1.WE_MESH_HEADERS;
13
- this.__configureGetHeaders = () => {
13
+ this.__configureHeaders = () => {
14
14
  return Object.assign(Object.assign({}, this.__headers), { 'request-ts': Date.now().toString() });
15
15
  };
16
- this.__configurePostHeaders = (data) => {
17
- const headers = this.__configureGetHeaders();
18
- return Object.assign(Object.assign({}, headers), { 'request-hash': (0, cryptography_1.generateHash)(headers.Authorization, headers['request-ts'], data.length) });
16
+ this.__configureDataHeaders = (data) => {
17
+ const headers = this.__configureHeaders();
18
+ return Object.assign(Object.assign({}, headers), { 'request-hash': (0, cryptography_1.generateHash)(this.token, headers['request-ts'], data.length) });
19
19
  };
20
20
  this.__handleResponse = async (statusCode, fullPath, body, schema) => {
21
21
  if (!(0, utils_1.isOk)(statusCode)) {
@@ -24,26 +24,43 @@ class HttpWorkflow {
24
24
  }
25
25
  const response = await body.text();
26
26
  logger_1.LOGGER.child({ path: fullPath }).info(statusCode);
27
- return schema.parse(response);
27
+ return schema.parse(JSON.parse(response));
28
+ };
29
+ this.__sendDataRequest = async (method, config, schema) => {
30
+ const { statusCode, body } = await (0, undici_1.request)(`${constants_1.API_URL}${config.path}`, {
31
+ method,
32
+ headers: this.__configureDataHeaders(config.body),
33
+ body: config.body,
34
+ });
35
+ return await this.__handleResponse(statusCode, `${constants_1.API_URL}${config.path}`, body, schema);
28
36
  };
29
37
  this.sendGet = async (config, schema) => {
30
38
  const { statusCode, body } = await (0, undici_1.request)(`${constants_1.API_URL}${config.path}`, {
31
39
  method: 'GET',
32
- headers: this.__configureGetHeaders(),
40
+ headers: this.__configureHeaders(),
33
41
  });
34
- return await this.__handleResponse(statusCode, config.path, body, schema);
42
+ return await this.__handleResponse(statusCode, `${constants_1.API_URL}${config.path}`, body, schema);
35
43
  };
36
44
  this.sendPost = async (config, schema) => {
37
- const { statusCode, body } = await (0, undici_1.request)(`${constants_1.API_URL}${config.path}`, {
38
- method: 'POST',
39
- headers: this.__configurePostHeaders(config.body),
45
+ return await this.__sendDataRequest('POST', config, schema);
46
+ };
47
+ this.sendPut = async (config, schema) => {
48
+ return await this.__sendDataRequest('PUT', config, schema);
49
+ };
50
+ this.sendRaw = async (config, schema) => {
51
+ const { statusCode, body } = await (0, undici_1.request)(config.path, {
52
+ headers: config.headers,
53
+ method: config.method,
40
54
  body: config.body,
41
55
  });
42
56
  return await this.__handleResponse(statusCode, config.path, body, schema);
43
57
  };
44
58
  }
45
- set headers(headers) {
46
- this.__headers = Object.assign(Object.assign({}, this.__headers), headers);
59
+ get token() {
60
+ return this.__headers.Authorization.slice(7, this.__headers.Authorization.length);
61
+ }
62
+ set token(token) {
63
+ this.__headers.Authorization = `Bearer ${token}`;
47
64
  }
48
65
  }
49
66
  exports.HttpWorkflow = HttpWorkflow;
@@ -1,7 +1,13 @@
1
+ import { AuthFactory } from '../factories/auth-factory';
2
+ import { UserFactory } from '../factories/user-factory';
1
3
  import { RaveConfig } from '../schemas/public';
2
4
  export declare class Rave {
3
- private __config;
5
+ private __config?;
4
6
  private __http;
5
- constructor(config: RaveConfig);
7
+ private __authFactory?;
8
+ private __userFactory?;
9
+ constructor(config?: RaveConfig);
10
+ get auth(): AuthFactory;
11
+ get user(): UserFactory;
6
12
  }
7
13
  //# 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,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI/C,qBAAa,IAAI;IACf,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,UAAU;CAS/B"}
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,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;gBAExB,MAAM,GAAE,UAAe;IASnC,IAAI,IAAI,gBAIP;IAED,IAAI,IAAI,gBAIP;CACF"}
package/dist/core/rave.js CHANGED
@@ -4,17 +4,27 @@ 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 user_factory_1 = require("../factories/user-factory");
7
9
  const logger_1 = __importDefault(require("../utils/logger"));
8
10
  const httpworkflow_1 = require("./httpworkflow");
9
11
  class Rave {
10
- constructor(config) {
11
- var _a;
12
+ constructor(config = {}) {
12
13
  this.__config = config;
13
14
  this.__http = new httpworkflow_1.HttpWorkflow();
14
- this.__http.headers = {
15
- Authorization: `Bearer ${(_a = this.__config.credentials) === null || _a === void 0 ? void 0 : _a.token}`,
16
- };
15
+ if (this.__config.credentials)
16
+ this.__http.token = this.__config.credentials.token;
17
17
  (0, logger_1.default)(!!config.enableLogging);
18
18
  }
19
+ get auth() {
20
+ if (!this.__authFactory)
21
+ return (this.__authFactory = new auth_factory_1.AuthFactory(this.__config, this.__http));
22
+ return this.__authFactory;
23
+ }
24
+ get user() {
25
+ if (!this.__userFactory)
26
+ return (this.__userFactory = new user_factory_1.UserFactory(this.__http));
27
+ return this.__userFactory;
28
+ }
19
29
  }
20
30
  exports.Rave = Rave;
@@ -0,0 +1,13 @@
1
+ import { HttpWorkflow } from '../core/httpworkflow';
2
+ import { RaveConfig } from '../schemas';
3
+ import { 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
+ sendMagicLink: (email: string, language?: string) => Promise<SendMagicLinkResponse>;
9
+ checkRegisterState: (stateId: string) => Promise<CheckRegisterStateResponse>;
10
+ parseUserCredentials: (idToken: string, email: string) => Promise<ParseUserCredentialsResponse>;
11
+ mojoLogin: (email: string, parseId: string, parseToken: string, name: string, deviceId?: string, language?: string) => Promise<MojoLoginResponse>;
12
+ }
13
+ //# 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;AACxC,OAAO,EACL,0BAA0B,EAE1B,iBAAiB,EAEjB,4BAA4B,EAE5B,qBAAqB,EAEtB,MAAM,sBAAsB,CAAC;AAG9B,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;gBAE1B,MAAM,EAAE,UAAU,YAAK,EAAE,IAAI,EAAE,YAAY;IAKhD,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;CACH"}
@@ -0,0 +1,62 @@
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
+ class AuthFactory {
8
+ constructor(config = {}, http) {
9
+ this.sendMagicLink = async (email, language = constants_1.DEFAULT_LANGUAGE) => {
10
+ return await this.__http.sendRaw({
11
+ method: 'POST',
12
+ path: `${constants_1.MOJO_AUTH_URL}/users/magiclink?language=${language}&redirect_url=https://rave.watch/mojoauth`,
13
+ body: JSON.stringify({ email }),
14
+ headers: constants_1.MOJO_AUTH_HEADERS,
15
+ }, responses_1.SendMagicLinkSchema);
16
+ };
17
+ this.checkRegisterState = async (stateId) => {
18
+ return await this.__http.sendRaw({
19
+ method: 'GET',
20
+ path: `${constants_1.MOJO_AUTH_URL}/users/status?state_id=${stateId}`,
21
+ headers: constants_1.MOJO_AUTH_HEADERS,
22
+ }, responses_1.CheckRegisterStateSchema);
23
+ };
24
+ this.parseUserCredentials = async (idToken, email) => {
25
+ return await this.__http.sendRaw({
26
+ method: 'POST',
27
+ headers: constants_1.PARSE_USERS_HEADERS,
28
+ path: `${constants_1.THIRD_API_URL}/parse/users`,
29
+ body: JSON.stringify({
30
+ authData: {
31
+ mojo: {
32
+ id_token: idToken,
33
+ id: email,
34
+ },
35
+ },
36
+ }),
37
+ }, responses_1.ParseUserCredentialsSchema);
38
+ };
39
+ this.mojoLogin = async (email, parseId, parseToken, name, deviceId = (0, cryptography_1.generateToken)(), language = constants_1.DEFAULT_LANGUAGE) => {
40
+ this.__http.token = parseToken.slice(1, parseToken.length);
41
+ this.__config.credentials = {
42
+ token: this.__http.token,
43
+ deviceId,
44
+ };
45
+ return await this.__http.sendPost({
46
+ path: '/auth2/mojo/login',
47
+ body: JSON.stringify({
48
+ deviceId,
49
+ email,
50
+ name,
51
+ parseId,
52
+ parseToken,
53
+ lang: language,
54
+ platId: email,
55
+ }),
56
+ }, responses_1.MojoLoginSchema);
57
+ };
58
+ this.__config = config;
59
+ this.__http = http;
60
+ }
61
+ }
62
+ exports.AuthFactory = AuthFactory;
@@ -0,0 +1,9 @@
1
+ import { HttpWorkflow } from '../core/httpworkflow';
2
+ import { EditProfileBuilder } from '../schemas';
3
+ import { EditProfileResponse } from '../schemas/responses';
4
+ export declare class UserFactory {
5
+ private readonly __http;
6
+ constructor(http: HttpWorkflow);
7
+ edit: (builder: EditProfileBuilder) => Promise<EditProfileResponse>;
8
+ }
9
+ //# sourceMappingURL=user-factory.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserFactory = void 0;
4
+ const schemas_1 = require("../schemas");
5
+ class UserFactory {
6
+ constructor(http) {
7
+ this.edit = async (builder) => {
8
+ return await this.__http.sendPut({
9
+ path: '/users/self',
10
+ body: JSON.stringify(builder),
11
+ }, schemas_1.EditProfileBuilderSchema);
12
+ };
13
+ this.__http = http;
14
+ }
15
+ }
16
+ exports.UserFactory = UserFactory;
@@ -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.ZodString>;
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.string().optional(),
18
+ });
@@ -6,5 +6,11 @@ export declare const RaveConfigSchema: z.ZodObject<{
6
6
  }, z.core.$strip>>;
7
7
  enableLogging: z.ZodOptional<z.ZodBoolean>;
8
8
  }, z.core.$strip>;
9
+ export declare const EditProfileBuilderSchema: z.ZodObject<{
10
+ displayAvatar: z.ZodOptional<z.ZodString>;
11
+ displayName: z.ZodOptional<z.ZodString>;
12
+ handle: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>;
9
14
  export type RaveConfig = z.infer<typeof RaveConfigSchema>;
15
+ export type EditProfileBuilder = z.infer<typeof EditProfileBuilderSchema>;
10
16
  //# 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,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,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,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"}
@@ -3,7 +3,7 @@ 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.RaveConfigSchema = void 0;
6
+ exports.EditProfileBuilderSchema = exports.RaveConfigSchema = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
8
  exports.RaveConfigSchema = zod_1.default.object({
9
9
  credentials: zod_1.default
@@ -14,3 +14,8 @@ exports.RaveConfigSchema = zod_1.default.object({
14
14
  .optional(),
15
15
  enableLogging: zod_1.default.boolean().optional(),
16
16
  });
17
+ exports.EditProfileBuilderSchema = zod_1.default.object({
18
+ displayAvatar: zod_1.default.string().optional(),
19
+ displayName: zod_1.default.string().optional(),
20
+ handle: zod_1.default.string().optional(),
21
+ });
@@ -0,0 +1,14 @@
1
+ import z from 'zod';
2
+ export declare const UserSchema: z.ZodObject<{
3
+ avatar: z.ZodString;
4
+ country: z.ZodString;
5
+ displayName: z.ZodString;
6
+ handle: z.ZodString;
7
+ id: z.ZodNumber;
8
+ lang: z.ZodString;
9
+ lat: z.ZodFloat32;
10
+ lng: z.ZodFloat32;
11
+ name: z.ZodString;
12
+ }, z.core.$strip>;
13
+ export type User = z.infer<typeof UserSchema>;
14
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/schemas/rave/user.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,UAAU;;;;;;;;;;iBAUrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -0,0 +1,18 @@
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.UserSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.UserSchema = zod_1.default.object({
9
+ avatar: zod_1.default.string(),
10
+ country: zod_1.default.string(),
11
+ displayName: zod_1.default.string(),
12
+ handle: zod_1.default.string(),
13
+ id: zod_1.default.number(),
14
+ lang: zod_1.default.string(),
15
+ lat: zod_1.default.float32(),
16
+ lng: zod_1.default.float32(),
17
+ name: zod_1.default.string(),
18
+ });
@@ -0,0 +1,95 @@
1
+ import z from 'zod';
2
+ export declare const EditProfileSchema: z.ZodObject<{
3
+ data: z.ZodObject<{
4
+ avatar: z.ZodString;
5
+ country: z.ZodString;
6
+ displayName: z.ZodString;
7
+ handle: z.ZodString;
8
+ id: z.ZodNumber;
9
+ lang: z.ZodString;
10
+ lat: z.ZodFloat32;
11
+ lng: z.ZodFloat32;
12
+ name: z.ZodString;
13
+ }, z.core.$strip>;
14
+ }, z.core.$strip>;
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 type EditProfileResponse = z.infer<typeof EditProfileSchema>;
91
+ export type SendMagicLinkResponse = z.infer<typeof SendMagicLinkSchema>;
92
+ export type CheckRegisterStateResponse = z.infer<typeof CheckRegisterStateSchema>;
93
+ export type ParseUserCredentialsResponse = z.infer<typeof ParseUserCredentialsSchema>;
94
+ export type MojoLoginResponse = z.infer<typeof MojoLoginSchema>;
95
+ //# sourceMappingURL=responses.d.ts.map
@@ -0,0 +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,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,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"}
@@ -0,0 +1,82 @@
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.MojoLoginSchema = exports.ParseUserCredentialsSchema = exports.CheckRegisterStateSchema = exports.SendMagicLinkSchema = exports.EditProfileSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ const user_1 = require("./rave/user");
9
+ exports.EditProfileSchema = zod_1.default.object({
10
+ data: user_1.UserSchema,
11
+ });
12
+ exports.SendMagicLinkSchema = zod_1.default
13
+ .object({
14
+ state_id: zod_1.default.string(),
15
+ })
16
+ .transform((data) => {
17
+ return {
18
+ stateId: data.state_id,
19
+ };
20
+ });
21
+ exports.CheckRegisterStateSchema = zod_1.default
22
+ .object({
23
+ authenticated: zod_1.default.boolean(),
24
+ is_second_factor_login: zod_1.default.boolean().optional(),
25
+ oauth: zod_1.default
26
+ .object({
27
+ access_token: zod_1.default.string(),
28
+ id_token: zod_1.default.string(),
29
+ refresh_token: zod_1.default.string(),
30
+ expires_in: zod_1.default.string(),
31
+ token_type: zod_1.default.string(),
32
+ })
33
+ .optional(),
34
+ user: zod_1.default
35
+ .object({
36
+ created_at: zod_1.default.string(),
37
+ updated_at: zod_1.default.string(),
38
+ issuer: zod_1.default.string(),
39
+ user_id: zod_1.default.string(),
40
+ identifier: zod_1.default.string(),
41
+ email: zod_1.default.string(),
42
+ })
43
+ .optional(),
44
+ })
45
+ .transform((data) => {
46
+ return {
47
+ authenticated: data.authenticated,
48
+ isSecondFactorLogin: data.is_second_factor_login,
49
+ oauth: data.oauth
50
+ ? {
51
+ accessToken: data.oauth.access_token,
52
+ idToken: data.oauth.id_token,
53
+ refreshToken: data.oauth.refresh_token,
54
+ expiresIn: data.oauth.expires_in,
55
+ tokenType: data.oauth.token_type,
56
+ }
57
+ : undefined,
58
+ user: data.user
59
+ ? {
60
+ createdAt: data.user.created_at,
61
+ updatedAt: data.user.updated_at,
62
+ issuer: data.user.issuer,
63
+ userId: data.user.user_id,
64
+ identifier: data.user.identifier,
65
+ email: data.user.email,
66
+ }
67
+ : undefined,
68
+ };
69
+ });
70
+ exports.ParseUserCredentialsSchema = zod_1.default.object({
71
+ objectId: zod_1.default.string(),
72
+ createdAt: zod_1.default.string(),
73
+ username: zod_1.default.string(),
74
+ sessionToken: zod_1.default.string(),
75
+ });
76
+ exports.MojoLoginSchema = zod_1.default.object({
77
+ data: zod_1.default.object({
78
+ isValid: zod_1.default.boolean(),
79
+ newUser: zod_1.default.boolean(),
80
+ suggestedHandles: zod_1.default.array(zod_1.default.string()),
81
+ }),
82
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ravejs",
3
- "version": "1.1.1",
3
+ "version": "1.3.1",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "files": [