ravejs 1.0.1 → 1.2.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.
Files changed (46) hide show
  1. package/dist/constants.d.ts +74 -1
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +93 -2
  4. package/dist/core/httpworkflow.d.ts +15 -0
  5. package/dist/core/httpworkflow.d.ts.map +1 -0
  6. package/dist/core/httpworkflow.js +55 -0
  7. package/dist/core/rave.d.ts +10 -0
  8. package/dist/core/rave.d.ts.map +1 -0
  9. package/dist/core/rave.js +26 -0
  10. package/dist/factories/user-factory.d.ts +9 -0
  11. package/dist/factories/user-factory.d.ts.map +1 -0
  12. package/dist/factories/user-factory.js +16 -0
  13. package/dist/index.d.ts +3 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +39 -0
  16. package/dist/schemas/configs.d.ts +13 -0
  17. package/dist/schemas/configs.d.ts.map +1 -0
  18. package/dist/schemas/configs.js +12 -0
  19. package/dist/schemas/error.d.ts +7 -0
  20. package/dist/schemas/error.d.ts.map +1 -0
  21. package/dist/schemas/error.js +8 -0
  22. package/dist/schemas/index.d.ts +2 -0
  23. package/dist/schemas/index.d.ts.map +1 -0
  24. package/dist/schemas/index.js +17 -0
  25. package/dist/schemas/public.d.ts +16 -0
  26. package/dist/schemas/public.d.ts.map +1 -0
  27. package/dist/schemas/public.js +21 -0
  28. package/dist/schemas/rave/user.d.ts +14 -0
  29. package/dist/schemas/rave/user.d.ts.map +1 -0
  30. package/dist/schemas/rave/user.js +18 -0
  31. package/dist/schemas/responses.d.ts +16 -0
  32. package/dist/schemas/responses.d.ts.map +1 -0
  33. package/dist/schemas/responses.js +11 -0
  34. package/dist/utils/cryptography.d.ts +3 -0
  35. package/dist/utils/cryptography.d.ts.map +1 -0
  36. package/dist/utils/cryptography.js +20 -0
  37. package/dist/utils/exceptions.d.ts +8 -0
  38. package/dist/utils/exceptions.d.ts.map +1 -0
  39. package/dist/utils/exceptions.js +28 -0
  40. package/dist/utils/logger.d.ts +5 -0
  41. package/dist/utils/logger.d.ts.map +1 -0
  42. package/dist/utils/logger.js +21 -0
  43. package/dist/utils/utils.d.ts +2 -0
  44. package/dist/utils/utils.d.ts.map +1 -0
  45. package/dist/utils/utils.js +5 -0
  46. package/package.json +7 -1
@@ -1,2 +1,75 @@
1
- export declare const VERSION = "1.0.1";
1
+ import { APIErrorData } from './schemas/error';
2
+ export declare const VERSION = "1.2.1";
3
+ export declare const API_URL = "https://api1.a-l-p-a.com";
4
+ export declare const MOJO_AUTH_URL = "https://api.mojoauth.com";
5
+ export declare const HASH_SECRET = "c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2";
6
+ export declare const WE_MESH_HEADERS: {
7
+ 'Content-Type': string;
8
+ Accept: string;
9
+ Connection: string;
10
+ 'User-Agent': string;
11
+ 'WeMesh-API-Version': string;
12
+ 'WeMesh-Platform': string;
13
+ ssaid: string;
14
+ 'Client-Version': string;
15
+ };
16
+ export declare const MOJO_AUTH_HEADERS: {
17
+ Connection: string;
18
+ 'User-Agent': string;
19
+ Host: string;
20
+ 'Content-Type': string;
21
+ 'X-API-Key': string;
22
+ };
23
+ export declare const PATCHED_DEVICE: {
24
+ adId: string;
25
+ appVersionRelease: number;
26
+ appVersionStr: string;
27
+ carriers: string[];
28
+ isBackground: boolean;
29
+ isChromebook: boolean;
30
+ isLandscape: boolean;
31
+ isPhone: boolean;
32
+ isTV: boolean;
33
+ isTablet: boolean;
34
+ isVPN: boolean;
35
+ lang: string;
36
+ network: string;
37
+ osName: string;
38
+ osVersion: string;
39
+ phoneModelBrand: string;
40
+ phoneModelManufacturer: string;
41
+ phoneModelModel: string;
42
+ ramFree: number;
43
+ ramTotal: number;
44
+ ramUsed: number;
45
+ screenX: number;
46
+ screenY: number;
47
+ sdkVersion: number;
48
+ };
49
+ export declare const PATCHED_IP_DATA: {
50
+ as: string;
51
+ asname: string;
52
+ city: string;
53
+ continent: string;
54
+ continentCode: string;
55
+ country: string;
56
+ countryCode: string;
57
+ currency: string;
58
+ district: string;
59
+ hosting: boolean;
60
+ isp: string;
61
+ lat: number;
62
+ lon: number;
63
+ mobile: boolean;
64
+ offset: number;
65
+ org: string;
66
+ proxy: boolean;
67
+ query: string;
68
+ region: string;
69
+ regionName: string;
70
+ status: string;
71
+ timezone: string;
72
+ zip: string;
73
+ };
74
+ export declare const CODES_MAP: Record<number, APIErrorData>;
2
75
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,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,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"}
package/dist/constants.js CHANGED
@@ -1,4 +1,95 @@
1
1
  "use strict";
2
+ // Constants
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VERSION = void 0;
4
- exports.VERSION = '1.0.1';
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';
6
+ exports.API_URL = 'https://api1.a-l-p-a.com';
7
+ exports.MOJO_AUTH_URL = 'https://api.mojoauth.com';
8
+ exports.HASH_SECRET = 'c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2';
9
+ // Structures
10
+ exports.WE_MESH_HEADERS = {
11
+ 'Content-Type': 'application/json',
12
+ Accept: 'application/json',
13
+ Connection: 'keep-alive',
14
+ 'User-Agent': 'Rave/2133 (8.1.93) (Android 15; 24117RN76O; Redmi tanzanite; ru)',
15
+ 'WeMesh-API-Version': '4.0',
16
+ 'WeMesh-Platform': 'android',
17
+ ssaid: '13c4e8d5fac67aff',
18
+ 'Client-Version': '8.1.93',
19
+ };
20
+ exports.MOJO_AUTH_HEADERS = {
21
+ Connection: 'keep-alive',
22
+ 'User-Agent': 'okhttp/5.1.0',
23
+ Host: 'api.mojoauth.com',
24
+ 'Content-Type': 'application/json; charset=utf-8',
25
+ 'X-API-Key': '45af6a2e-4c1c-45a5-9874-df1eb3a22fe2',
26
+ };
27
+ exports.PATCHED_DEVICE = {
28
+ adId: 'e1bbf669-e099-4559-8a8f-ecf44da51fc4',
29
+ appVersionRelease: 2133,
30
+ appVersionStr: '8.1.93',
31
+ carriers: ['MegaFon RUS'],
32
+ isBackground: true,
33
+ isChromebook: false,
34
+ isLandscape: false,
35
+ isPhone: true,
36
+ isTV: false,
37
+ isTablet: false,
38
+ isVPN: false,
39
+ lang: 'ru',
40
+ network: 'WIFI',
41
+ osName: 'ANDROID',
42
+ osVersion: '15',
43
+ phoneModelBrand: 'Redmi',
44
+ phoneModelManufacturer: 'Xiaomi',
45
+ phoneModelModel: '24117RN76O',
46
+ ramFree: 429,
47
+ ramTotal: 512,
48
+ ramUsed: 83,
49
+ screenX: 1080,
50
+ screenY: 2249,
51
+ sdkVersion: 35,
52
+ };
53
+ exports.PATCHED_IP_DATA = {
54
+ as: 'AS41733 JSC "ER-Telecom Holding"',
55
+ asname: 'ZTELECOM-AS',
56
+ city: 'St Petersburg',
57
+ continent: 'Europe',
58
+ continentCode: 'EU',
59
+ country: 'Russia',
60
+ countryCode: 'RU',
61
+ currency: 'RUB',
62
+ district: '',
63
+ hosting: false,
64
+ isp: 'Z-Telecom',
65
+ lat: 59.8983,
66
+ lon: 30.2618,
67
+ mobile: false,
68
+ offset: 10800,
69
+ org: 'JSC ER-Telecom',
70
+ proxy: false,
71
+ query: '5.18.252.218',
72
+ region: 'SPE',
73
+ regionName: 'St.-Petersburg',
74
+ status: 'success',
75
+ timezone: 'Europe/Moscow',
76
+ zip: '190990',
77
+ };
78
+ exports.CODES_MAP = {
79
+ 400: {
80
+ name: 'RaveJSException.BadRequest',
81
+ message: 'Bad Request. Invalid request parameters.',
82
+ },
83
+ 401: {
84
+ name: 'RaveJSException.Unauthorized',
85
+ message: 'Unauthorized. Invalid credentials.',
86
+ },
87
+ 403: {
88
+ name: 'RaveJSException.Forbidden',
89
+ message: 'Forbidden. Access denied.',
90
+ },
91
+ 404: {
92
+ name: 'RaveJSException.NotFound',
93
+ message: 'Not Found. Resource not found.',
94
+ },
95
+ };
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ import { HeadersType } from '../schemas/private';
3
+ import { GetRequestConfig, PostRequestConfig } from '../schemas/configs';
4
+ export declare class HttpWorkflow {
5
+ private __headers;
6
+ set headers(headers: HeadersType);
7
+ private __configureHeaders;
8
+ private __configureDataHeaders;
9
+ private __handleResponse;
10
+ private __sendDataRequest;
11
+ sendGet: <T>(config: GetRequestConfig, schema: z.ZodSchema) => Promise<T>;
12
+ sendPost: <T>(config: PostRequestConfig, schema: z.ZodSchema) => Promise<T>;
13
+ sendPut: <T>(config: PostRequestConfig, schema: z.ZodSchema) => Promise<T>;
14
+ }
15
+ //# sourceMappingURL=httpworkflow.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpWorkflow = void 0;
4
+ const undici_1 = require("undici");
5
+ const constants_1 = require("../constants");
6
+ const cryptography_1 = require("../utils/cryptography");
7
+ const logger_1 = require("../utils/logger");
8
+ const utils_1 = require("../utils/utils");
9
+ const exceptions_1 = require("../utils/exceptions");
10
+ class HttpWorkflow {
11
+ constructor() {
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) });
19
+ };
20
+ this.__handleResponse = async (statusCode, fullPath, body, schema) => {
21
+ if (!(0, utils_1.isOk)(statusCode)) {
22
+ logger_1.LOGGER.child({ path: fullPath }).error(statusCode);
23
+ exceptions_1.APIException.throw(statusCode);
24
+ }
25
+ const response = await body.text();
26
+ logger_1.LOGGER.child({ path: fullPath }).info(statusCode);
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);
36
+ };
37
+ this.sendGet = async (config, schema) => {
38
+ const { statusCode, body } = await (0, undici_1.request)(`${constants_1.API_URL}${config.path}`, {
39
+ method: 'GET',
40
+ headers: this.__configureHeaders(),
41
+ });
42
+ return await this.__handleResponse(statusCode, `${constants_1.API_URL}${config.path}`, body, schema);
43
+ };
44
+ this.sendPost = async (config, schema) => {
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
+ }
51
+ set headers(headers) {
52
+ this.__headers = Object.assign(Object.assign({}, headers), this.__headers);
53
+ }
54
+ }
55
+ exports.HttpWorkflow = HttpWorkflow;
@@ -0,0 +1,10 @@
1
+ import { UserFactory } from '../factories/user-factory';
2
+ import { RaveConfig } from '../schemas/public';
3
+ export declare class Rave {
4
+ private __config?;
5
+ private __http;
6
+ private __userFactory?;
7
+ constructor(config?: RaveConfig);
8
+ get user(): UserFactory;
9
+ }
10
+ //# sourceMappingURL=rave.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,26 @@
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.Rave = void 0;
7
+ const user_factory_1 = require("../factories/user-factory");
8
+ const logger_1 = __importDefault(require("../utils/logger"));
9
+ const httpworkflow_1 = require("./httpworkflow");
10
+ class Rave {
11
+ constructor(config = {}) {
12
+ var _a;
13
+ this.__config = config;
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
+ };
18
+ (0, logger_1.default)(!!config.enableLogging);
19
+ }
20
+ get user() {
21
+ if (!this.__userFactory)
22
+ return (this.__userFactory = new user_factory_1.UserFactory(this.__http));
23
+ return this.__userFactory;
24
+ }
25
+ }
26
+ exports.Rave = Rave;
@@ -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;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- export {};
1
+ export { Rave } from './core/rave';
2
+ export { APIException } from './utils/exceptions';
3
+ export * as schemas from './schemas/index';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,46 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.schemas = exports.APIException = exports.Rave = void 0;
3
37
  const child_process_1 = require("child_process");
4
38
  const constants_1 = require("./constants");
39
+ var rave_1 = require("./core/rave");
40
+ Object.defineProperty(exports, "Rave", { enumerable: true, get: function () { return rave_1.Rave; } });
41
+ var exceptions_1 = require("./utils/exceptions");
42
+ Object.defineProperty(exports, "APIException", { enumerable: true, get: function () { return exceptions_1.APIException; } });
43
+ exports.schemas = __importStar(require("./schemas/index"));
5
44
  console.log(`\x1b[34mVisit our community:\x1b[32m https://t.me/aminodorks\x1b[0m`);
6
45
  (0, child_process_1.exec)('npm view ravejs version', (error, stdout, stderr) => {
7
46
  if (error) {
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export declare const PostRequestConfigSchema: z.ZodObject<{
3
+ path: z.ZodReadonly<z.ZodString>;
4
+ body: z.ZodReadonly<z.ZodString>;
5
+ contentType: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export declare const GetRequestConfigSchema: z.ZodObject<{
8
+ path: z.ZodReadonly<z.ZodString>;
9
+ contentType: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ export type PostRequestConfig = z.infer<typeof PostRequestConfigSchema>;
12
+ export type GetRequestConfig = z.infer<typeof GetRequestConfigSchema>;
13
+ //# sourceMappingURL=configs.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetRequestConfigSchema = exports.PostRequestConfigSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.PostRequestConfigSchema = zod_1.z.object({
6
+ path: zod_1.z.string().readonly(),
7
+ body: zod_1.z.string().readonly(),
8
+ contentType: zod_1.z.string().optional(),
9
+ });
10
+ exports.GetRequestConfigSchema = exports.PostRequestConfigSchema.omit({
11
+ body: true,
12
+ });
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export declare const APIErrorDataSchema: z.ZodObject<{
3
+ message: z.ZodString;
4
+ name: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export type APIErrorData = z.infer<typeof APIErrorDataSchema>;
7
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/schemas/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;iBAG7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APIErrorDataSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.APIErrorDataSchema = zod_1.z.object({
6
+ message: zod_1.z.string(),
7
+ name: zod_1.z.string().optional(),
8
+ });
@@ -0,0 +1,2 @@
1
+ export * from './public';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./public"), exports);
@@ -0,0 +1,16 @@
1
+ import z from 'zod';
2
+ export declare const RaveConfigSchema: z.ZodObject<{
3
+ credentials: z.ZodOptional<z.ZodObject<{
4
+ token: z.ZodString;
5
+ deviceId: z.ZodString;
6
+ }, z.core.$strip>>;
7
+ enableLogging: z.ZodOptional<z.ZodBoolean>;
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>;
14
+ export type RaveConfig = z.infer<typeof RaveConfigSchema>;
15
+ export type EditProfileBuilder = z.infer<typeof EditProfileBuilderSchema>;
16
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,21 @@
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.EditProfileBuilderSchema = exports.RaveConfigSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ exports.RaveConfigSchema = zod_1.default.object({
9
+ credentials: zod_1.default
10
+ .object({
11
+ token: zod_1.default.string(),
12
+ deviceId: zod_1.default.string(),
13
+ })
14
+ .optional(),
15
+ enableLogging: zod_1.default.boolean().optional(),
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,16 @@
1
+ import z from 'zod';
2
+ export declare const EditProfileResponseSchema: 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 type EditProfileResponse = z.infer<typeof EditProfileResponseSchema>;
16
+ //# 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,yBAAyB;;;;;;;;;;;;iBAEpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
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.EditProfileResponseSchema = void 0;
7
+ const zod_1 = __importDefault(require("zod"));
8
+ const user_1 = require("./rave/user");
9
+ exports.EditProfileResponseSchema = zod_1.default.object({
10
+ data: user_1.UserSchema,
11
+ });
@@ -0,0 +1,3 @@
1
+ export declare const generateHash: (token: string, timestamp: string, contentLength: number) => string;
2
+ export declare const generateToken: () => string;
3
+ //# sourceMappingURL=cryptography.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateToken = exports.generateHash = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const uuid_1 = require("uuid");
6
+ const constants_1 = require("../constants");
7
+ const generateHash = (token, timestamp, contentLength) => {
8
+ const hash = (0, crypto_1.createHmac)('sha256', constants_1.HASH_SECRET)
9
+ .update(`${timestamp}:${token}:${contentLength}`)
10
+ .digest();
11
+ return hash.toString('base64');
12
+ };
13
+ exports.generateHash = generateHash;
14
+ const generateToken = () => {
15
+ return (0, uuid_1.v4)().replace(/[xy]/g, (c) => {
16
+ const r = (Math.random() * 16) | 0;
17
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
18
+ });
19
+ };
20
+ exports.generateToken = generateToken;
@@ -0,0 +1,8 @@
1
+ import { APIErrorData } from '../schemas/error';
2
+ export declare class APIException extends Error {
3
+ readonly code: number;
4
+ constructor(code: number, data: APIErrorData);
5
+ static get(code: number): APIException;
6
+ static throw(code: number): void;
7
+ }
8
+ //# sourceMappingURL=exceptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../../src/utils/exceptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY;IAW5C,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAWtC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAGjC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APIException = void 0;
4
+ const constants_1 = require("../constants");
5
+ class APIException extends Error {
6
+ constructor(code, data) {
7
+ super(data.message);
8
+ this.code = code;
9
+ this.name = data.name || `RaveJSException.${code}`;
10
+ this.code = code;
11
+ if (Error.captureStackTrace) {
12
+ Error.captureStackTrace(this, APIException);
13
+ }
14
+ }
15
+ static get(code) {
16
+ const errorData = constants_1.CODES_MAP[code];
17
+ return errorData
18
+ ? new APIException(code, errorData)
19
+ : new APIException(code, {
20
+ name: 'UnknownError',
21
+ message: 'Unknown error',
22
+ });
23
+ }
24
+ static throw(code) {
25
+ throw this.get(code);
26
+ }
27
+ }
28
+ exports.APIException = APIException;
@@ -0,0 +1,5 @@
1
+ import { Logger } from 'pino';
2
+ export declare let LOGGER: Logger;
3
+ declare const initLogger: (enableLogging: boolean) => Logger;
4
+ export default initLogger;
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,eAAO,IAAI,MAAM,EAAE,MAAM,CAAC;AAE1B,QAAA,MAAM,UAAU,kBAAmB,OAAO,KAAG,MAY5C,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,21 @@
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.LOGGER = void 0;
7
+ const pino_1 = __importDefault(require("pino"));
8
+ const initLogger = (enableLogging) => {
9
+ if (exports.LOGGER)
10
+ return exports.LOGGER;
11
+ return (exports.LOGGER = (0, pino_1.default)({
12
+ enabled: enableLogging,
13
+ transport: {
14
+ target: 'pino-pretty',
15
+ options: {
16
+ colorize: true,
17
+ },
18
+ },
19
+ }));
20
+ };
21
+ exports.default = initLogger;
@@ -0,0 +1,2 @@
1
+ export declare const isOk: (status: number) => boolean;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,WAAY,MAAM,YAAkC,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isOk = void 0;
4
+ const isOk = (status) => status >= 200 && status < 300;
5
+ exports.isOk = isOk;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ravejs",
3
- "version": "1.0.1",
3
+ "version": "1.2.1",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -40,5 +40,11 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "typescript": "^5.2.2"
43
+ },
44
+ "dependencies": {
45
+ "pino": "^10.1.0",
46
+ "pino-pretty": "^13.1.3",
47
+ "uuid": "^13.0.0",
48
+ "zod": "^4.1.13"
43
49
  }
44
50
  }