ravejs 1.2.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.2.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;;;;;;;;;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":"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,11 +1,13 @@
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.2.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',
@@ -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,9 +1,9 @@
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
7
  private __configureHeaders;
8
8
  private __configureDataHeaders;
9
9
  private __handleResponse;
@@ -11,5 +11,6 @@ export declare class HttpWorkflow {
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,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"}
@@ -15,7 +15,7 @@ class HttpWorkflow {
15
15
  };
16
16
  this.__configureDataHeaders = (data) => {
17
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) });
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)) {
@@ -47,9 +47,20 @@ class HttpWorkflow {
47
47
  this.sendPut = async (config, schema) => {
48
48
  return await this.__sendDataRequest('PUT', config, schema);
49
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,
54
+ body: config.body,
55
+ });
56
+ return await this.__handleResponse(statusCode, config.path, body, schema);
57
+ };
58
+ }
59
+ get token() {
60
+ return this.__headers.Authorization.slice(7, this.__headers.Authorization.length);
50
61
  }
51
- set headers(headers) {
52
- this.__headers = Object.assign(Object.assign({}, headers), this.__headers);
62
+ set token(token) {
63
+ this.__headers.Authorization = `Bearer ${token}`;
53
64
  }
54
65
  }
55
66
  exports.HttpWorkflow = HttpWorkflow;
@@ -1,10 +1,13 @@
1
+ import { AuthFactory } from '../factories/auth-factory';
1
2
  import { UserFactory } from '../factories/user-factory';
2
3
  import { RaveConfig } from '../schemas/public';
3
4
  export declare class Rave {
4
5
  private __config?;
5
6
  private __http;
7
+ private __authFactory?;
6
8
  private __userFactory?;
7
9
  constructor(config?: RaveConfig);
10
+ get auth(): AuthFactory;
8
11
  get user(): UserFactory;
9
12
  }
10
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,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,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,19 +4,23 @@ 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");
7
8
  const user_factory_1 = require("../factories/user-factory");
8
9
  const logger_1 = __importDefault(require("../utils/logger"));
9
10
  const httpworkflow_1 = require("./httpworkflow");
10
11
  class Rave {
11
12
  constructor(config = {}) {
12
- var _a;
13
13
  this.__config = config;
14
14
  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
- };
15
+ if (this.__config.credentials)
16
+ this.__http.token = this.__config.credentials.token;
18
17
  (0, logger_1.default)(!!config.enableLogging);
19
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
+ }
20
24
  get user() {
21
25
  if (!this.__userFactory)
22
26
  return (this.__userFactory = new user_factory_1.UserFactory(this.__http));
@@ -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;
@@ -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
+ });
@@ -1,5 +1,5 @@
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;
@@ -12,5 +12,84 @@ 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 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>;
16
95
  //# 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;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"}
@@ -3,9 +3,80 @@ 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.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
+ exports.EditProfileSchema = zod_1.default.object({
10
10
  data: user_1.UserSchema,
11
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.2.1",
3
+ "version": "1.3.1",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "files": [