comty.js 0.47.2 → 0.49.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _events = require('@foxify/events'); var _events2 = _interopRequireDefault(_events);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }var _packagejson = require('../package.json'); var _packagejson2 = _interopRequireDefault(_packagejson);
2
+ var _events = require('@foxify/events'); var _events2 = _interopRequireDefault(_events);
2
3
 
3
4
  var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
4
5
  var _socketioclient = require('socket.io-client');
@@ -145,6 +146,7 @@ if (globalThis.isServerMode) {
145
146
  instances: Object(),
146
147
  wsInstances: Object(),
147
148
  rest: null,
149
+ version: _packagejson2.default.version,
148
150
  }
149
151
 
150
152
  if (globalThis.isServerMode) {
@@ -1,6 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
2
2
  var _session = require('../session'); var _session2 = _interopRequireDefault(_session);
3
3
 
4
+ const emailRegex = new RegExp(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)
5
+
4
6
  class AuthModel {
5
7
  static __initStatic() {this.login = async (payload) => {
6
8
  const response = await _request2.default.call(void 0, {
@@ -50,4 +52,31 @@ var _session = require('../session'); var _session2 = _interopRequireDefault(_se
50
52
 
51
53
  return response
52
54
  }}
53
- } AuthModel.__initStatic(); AuthModel.__initStatic2(); AuthModel.__initStatic3(); exports.default = AuthModel;
55
+
56
+ static __initStatic4() {this.usernameValidation = async (username) => {
57
+ let payload = {}
58
+
59
+ // check if usename arguemnt is an email
60
+ if (emailRegex.test(username)) {
61
+ payload.email = username
62
+ } else {
63
+ payload.username = username
64
+ }
65
+
66
+ const response = await _request2.default.call(void 0, {
67
+ method: "get",
68
+ url: "/auth/login/validation",
69
+ params: payload,
70
+ }).catch((error) => {
71
+ console.error(error)
72
+
73
+ return false
74
+ })
75
+
76
+ if (!response) {
77
+ throw new Error("Unable to validate user")
78
+ }
79
+
80
+ return response.data
81
+ }}
82
+ } AuthModel.__initStatic(); AuthModel.__initStatic2(); AuthModel.__initStatic3(); AuthModel.__initStatic4(); exports.default = AuthModel;
@@ -0,0 +1,56 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _request = require('../../handlers/request'); var _request2 = _interopRequireDefault(_request);
2
+
3
+ class NFCModel {
4
+ static async getOwnTags() {
5
+ const { data } = await _request2.default.call(void 0, {
6
+ method: "GET",
7
+ url: `/nfc/tags`
8
+ })
9
+
10
+ return data
11
+ }
12
+
13
+ static async getTagById(id) {
14
+ if (!id) {
15
+ throw new Error("ID is required")
16
+ }
17
+
18
+ const { data } = await _request2.default.call(void 0, {
19
+ method: "GET",
20
+ url: `/nfc/tags/${id}`
21
+ })
22
+
23
+ return data
24
+ }
25
+
26
+ static async getTagBySerial(serial) {
27
+ if (!serial) {
28
+ throw new Error("Serial is required")
29
+ }
30
+
31
+ const { data } = await _request2.default.call(void 0, {
32
+ method: "GET",
33
+ url: `/nfc/tag/serial/${serial}`
34
+ })
35
+
36
+ return data
37
+ }
38
+
39
+ static async registerTag(serial, payload) {
40
+ if (!serial) {
41
+ throw new Error("Serial is required")
42
+ }
43
+
44
+ if (!payload) {
45
+ throw new Error("Payload is required")
46
+ }
47
+
48
+ const { data } = await _request2.default.call(void 0, {
49
+ method: "POST",
50
+ url: `/nfc/tag/${serial}`,
51
+ data: payload
52
+ })
53
+
54
+ return data
55
+ }
56
+ } exports.default = NFCModel;
@@ -34,7 +34,7 @@
34
34
  return data
35
35
  }}
36
36
 
37
- static __initStatic3() {this.deletePlaylist = async (id) => {
37
+ static __initStatic3() {this.deletePlaylist = async (id, options = {}) => {
38
38
  if (!id) {
39
39
  throw new Error("ID is required")
40
40
  }
@@ -43,6 +43,7 @@
43
43
  instance: PlaylistsModel.api_instance,
44
44
  method: "DELETE",
45
45
  url: `/playlists/${id}`,
46
+ params: options,
46
47
  })
47
48
 
48
49
  return data
@@ -92,7 +92,7 @@ var _request = require('../../handlers/request'); var _request2 = _interopRequir
92
92
 
93
93
  const { data } = await _request2.default.call(void 0, {
94
94
  method: "POST",
95
- url: "/self/update_password",
95
+ url: "/user/self/update_password",
96
96
  data: {
97
97
  currentPassword,
98
98
  newPassword,
package/dist/remotes.js CHANGED
@@ -1,5 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }function composeRemote(path) {
2
- return envOrigins[process.env.NODE_ENV][path]
2
+ if (typeof window !== "undefined") {
3
+ if (window.localStorage.getItem("comty:use_indev") || window.location.hostname === "indev.comty.app") {
4
+ return envOrigins["indev"][path]
5
+ }
6
+ }
7
+
8
+ return envOrigins[_nullishCoalesce(process.env.NODE_ENV, () => ( "production"))][path]
3
9
  }
4
10
 
5
11
  function getCurrentHostname() {
@@ -19,6 +25,14 @@ const envOrigins = {
19
25
  music: `http://${getCurrentHostname()}:3050`,
20
26
  files: `http://${getCurrentHostname()}:3060`,
21
27
  },
28
+ "indev": {
29
+ default: `https://indev_api.comty.app/default`,
30
+ chat: `https://indev_api.comty.app/chat`,
31
+ livestreaming: `https://indev_api.comty.app/livestreaming`,
32
+ marketplace: `https://indev_api.comty.app/marketplace`,
33
+ music: `https://indev_api.comty.app/music`,
34
+ files: `https://indev_api.comty.app/files`,
35
+ },
22
36
  "production": {
23
37
  default: "https://api.comty.app",
24
38
  chat: `https://chat_api.comty.app`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comty.js",
3
- "version": "0.47.2",
3
+ "version": "0.49.3",
4
4
  "main": "./dist/index.js",
5
5
  "author": "RageStudio <support@ragestudio.net>",
6
6
  "scripts": {