auth-mn 0.1.9 → 0.2.0

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/README.md CHANGED
@@ -1 +1 @@
1
- # AUTH.MN
1
+ # AUTH.MN
package/dist/find.d.ts CHANGED
@@ -1,70 +1,85 @@
1
+ export declare const genders: readonly ["MEN", "WOMEN"];
2
+ export type Gender = (typeof genders)[number];
3
+ export interface UserEmailItem {
4
+ email: string;
5
+ verified: boolean;
6
+ primary: boolean;
7
+ }
8
+ export interface UserPhoneItem {
9
+ number: string;
10
+ verified: boolean;
11
+ primary: boolean;
12
+ }
13
+ export interface UserAuthProfiles {
14
+ facebook_id?: string | null;
15
+ google_id?: string | null;
16
+ steam_id?: string | null;
17
+ apple_id?: string | null;
18
+ twitter_id?: string | null;
19
+ monpay_id?: string | null;
20
+ toki_id?: string | null;
21
+ social_id?: string | null;
22
+ hipay_id?: string | null;
23
+ digi_id?: string | null;
24
+ }
25
+ export interface UserPreferences {
26
+ language: string;
27
+ notifications: boolean;
28
+ }
29
+ export interface UserStatus {
30
+ is_active: boolean;
31
+ is_banned: boolean;
32
+ verified: boolean;
33
+ }
34
+ export interface UserSecurity {
35
+ password_hash: string;
36
+ two_factor_enabled: boolean;
37
+ last_password_change: Date | null;
38
+ }
39
+ export interface UserVerifyInfo {
40
+ first_name: string;
41
+ last_name: string;
42
+ born_date: Date | null;
43
+ national_id: string;
44
+ }
45
+ export interface UserAppItem {
46
+ app_name: string;
47
+ app_id: string;
48
+ device_id: string;
49
+ }
50
+ export interface UserWalletItem {
51
+ key_id: string;
52
+ wallet_id: string;
53
+ wallet_key: string;
54
+ wallet_type: string;
55
+ wallet_name: string;
56
+ role: string[];
57
+ }
1
58
  type UserT = {
2
- _id?: string;
3
- user_id?: number;
4
- user_name?: string;
5
- nick_name?: string;
6
- exp?: number;
7
- primary_email?: string;
8
- primary_phone?: string;
9
- emails?: Array<{
10
- email: string;
11
- verified: boolean;
12
- primary: boolean;
13
- }>;
14
- phone_numbers?: Array<{
15
- number: string;
16
- verified: boolean;
17
- primary: boolean;
18
- }>;
19
- auth_profiles?: {
20
- facebook_id?: string;
21
- google_id?: string;
22
- steam_id?: string;
23
- apple_id?: string;
24
- twitter_id?: string;
25
- monpay_id?: string;
26
- toki_id?: string;
27
- social_id?: string;
28
- hipay_id?: string;
29
- digi_id?: string;
30
- };
31
- profile_image_url?: string;
32
- date_of_birth?: Date;
33
- gender?: "MEN" | "WOMEN";
34
- sign_up_date?: Date;
35
- last_login?: Date;
36
- wallet_id?: string;
37
- wallet_key?: string;
38
- preferences?: {
39
- language?: string;
40
- notifications?: boolean;
41
- };
42
- status?: {
43
- is_active?: boolean;
44
- is_banned?: boolean;
45
- verified?: boolean;
46
- };
47
- security?: {
48
- password_hash?: string;
49
- two_factor_enabled?: boolean;
50
- last_password_change?: Date;
51
- };
52
- verify_info?: {
53
- first_name?: string;
54
- last_name?: string;
55
- born_date?: Date;
56
- national_id?: string;
57
- };
58
- dynamic_info?: {
59
- [key: string]: any;
60
- };
61
- apps?: {
62
- app_name: string;
63
- app_id: string;
64
- device_id: string;
65
- }[];
66
- createdAt?: Date;
67
- updatedAt?: Date;
59
+ user_id: number;
60
+ user_name: string;
61
+ nick_name: string;
62
+ exp: number;
63
+ primary_email?: string | null;
64
+ primary_phone?: string | null;
65
+ emails: UserEmailItem[];
66
+ phone_numbers: UserPhoneItem[];
67
+ auth_profiles: UserAuthProfiles;
68
+ profile_image_url: string;
69
+ date_of_birth: Date | null;
70
+ gender?: Gender;
71
+ sign_up_date: Date | null;
72
+ last_login: Date | null;
73
+ wallets: UserWalletItem[];
74
+ preferences: UserPreferences;
75
+ status: UserStatus;
76
+ security: UserSecurity;
77
+ verify_info: UserVerifyInfo;
78
+ dynamic_info: Record<string, any>;
79
+ apps: UserAppItem[];
80
+ search_string?: string;
81
+ delFlg?: boolean;
82
+ order_index?: number;
68
83
  };
69
84
  type MerchantT = {
70
85
  _id?: string;
package/dist/find.js CHANGED
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CRM = exports.CLIENT = exports.ADMIN = exports.MERCHANT = exports.USER = void 0;
3
+ exports.CRM = exports.CLIENT = exports.ADMIN = exports.MERCHANT = exports.USER = exports.genders = void 0;
4
4
  const _1 = require(".");
5
5
  const auth_1 = require("./auth");
6
6
  const axios_master_1 = require("axios-master");
7
+ /* -----------------------------
8
+ * Enums
9
+ * ----------------------------- */
10
+ exports.genders = ["MEN", "WOMEN"];
7
11
  const USER = async (body) => {
8
12
  var _a;
9
13
  try {
@@ -47,7 +51,7 @@ const USER = async (body) => {
47
51
  }
48
52
  return {
49
53
  success: false,
50
- data: null,
54
+ data: [],
51
55
  message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || ""
52
56
  };
53
57
  }
@@ -96,7 +100,7 @@ const MERCHANT = async (body) => {
96
100
  }
97
101
  return {
98
102
  success: false,
99
- data: null,
103
+ data: [],
100
104
  message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || ""
101
105
  };
102
106
  }
@@ -145,7 +149,7 @@ const ADMIN = async (body) => {
145
149
  }
146
150
  return {
147
151
  success: false,
148
- data: null,
152
+ data: [],
149
153
  message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || ""
150
154
  };
151
155
  }
@@ -194,7 +198,7 @@ const CLIENT = async (body) => {
194
198
  }
195
199
  return {
196
200
  success: false,
197
- data: null,
201
+ data: [],
198
202
  message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || ""
199
203
  };
200
204
  }
@@ -243,7 +247,7 @@ const CRM = async (body) => {
243
247
  }
244
248
  return {
245
249
  success: false,
246
- data: null,
250
+ data: [],
247
251
  message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || ""
248
252
  };
249
253
  }
package/dist/index.d.ts CHANGED
@@ -144,144 +144,69 @@ declare const _default: {
144
144
  data: null;
145
145
  message: string;
146
146
  }>;
147
+ EMIT: (body: {
148
+ user_id: number;
149
+ emit_name: string;
150
+ data: any;
151
+ }[]) => Promise<{
152
+ success: boolean;
153
+ data: null;
154
+ message: string;
155
+ }>;
147
156
  };
148
157
  find: {
149
158
  USER: (body: {
150
- _id?: string;
151
- user_id?: number;
152
- user_name?: string;
153
- nick_name?: string;
154
- exp?: number;
155
- primary_email?: string;
156
- primary_phone?: string;
157
- emails?: Array<{
158
- email: string;
159
- verified: boolean;
160
- primary: boolean;
161
- }>;
162
- phone_numbers?: Array<{
163
- number: string;
164
- verified: boolean;
165
- primary: boolean;
166
- }>;
167
- auth_profiles?: {
168
- facebook_id?: string;
169
- google_id?: string;
170
- steam_id?: string;
171
- apple_id?: string;
172
- twitter_id?: string;
173
- monpay_id?: string;
174
- toki_id?: string;
175
- social_id?: string;
176
- hipay_id?: string;
177
- digi_id?: string;
178
- };
179
- profile_image_url?: string;
180
- date_of_birth?: Date;
181
- gender?: "MEN" | "WOMEN";
182
- sign_up_date?: Date;
183
- last_login?: Date;
184
- wallet_id?: string;
185
- wallet_key?: string;
186
- preferences?: {
187
- language?: string;
188
- notifications?: boolean;
189
- };
190
- status?: {
191
- is_active?: boolean;
192
- is_banned?: boolean;
193
- verified?: boolean;
194
- };
195
- security?: {
196
- password_hash?: string;
197
- two_factor_enabled?: boolean;
198
- last_password_change?: Date;
199
- };
200
- verify_info?: {
201
- first_name?: string;
202
- last_name?: string;
203
- born_date?: Date;
204
- national_id?: string;
205
- };
206
- dynamic_info?: {
207
- [key: string]: any;
208
- };
209
- apps?: {
210
- app_name: string;
211
- app_id: string;
212
- device_id: string;
213
- }[];
214
- createdAt?: Date;
215
- updatedAt?: Date;
159
+ user_id: number;
160
+ user_name: string;
161
+ nick_name: string;
162
+ exp: number;
163
+ primary_email?: string | null;
164
+ primary_phone?: string | null;
165
+ emails: import("./find").UserEmailItem[];
166
+ phone_numbers: import("./find").UserPhoneItem[];
167
+ auth_profiles: import("./find").UserAuthProfiles;
168
+ profile_image_url: string;
169
+ date_of_birth: Date | null;
170
+ gender?: import("./find").Gender;
171
+ sign_up_date: Date | null;
172
+ last_login: Date | null;
173
+ wallets: import("./find").UserWalletItem[];
174
+ preferences: import("./find").UserPreferences;
175
+ status: import("./find").UserStatus;
176
+ security: import("./find").UserSecurity;
177
+ verify_info: import("./find").UserVerifyInfo;
178
+ dynamic_info: Record<string, any>;
179
+ apps: import("./find").UserAppItem[];
180
+ search_string?: string;
181
+ delFlg?: boolean;
182
+ order_index?: number;
216
183
  }) => Promise<{
217
184
  success: boolean;
218
185
  data: {
219
- _id?: string;
220
- user_id?: number;
221
- user_name?: string;
222
- nick_name?: string;
223
- exp?: number;
224
- primary_email?: string;
225
- primary_phone?: string;
226
- emails?: Array<{
227
- email: string;
228
- verified: boolean;
229
- primary: boolean;
230
- }>;
231
- phone_numbers?: Array<{
232
- number: string;
233
- verified: boolean;
234
- primary: boolean;
235
- }>;
236
- auth_profiles?: {
237
- facebook_id?: string;
238
- google_id?: string;
239
- steam_id?: string;
240
- apple_id?: string;
241
- twitter_id?: string;
242
- monpay_id?: string;
243
- toki_id?: string;
244
- social_id?: string;
245
- hipay_id?: string;
246
- digi_id?: string;
247
- };
248
- profile_image_url?: string;
249
- date_of_birth?: Date;
250
- gender?: "MEN" | "WOMEN";
251
- sign_up_date?: Date;
252
- last_login?: Date;
253
- wallet_id?: string;
254
- wallet_key?: string;
255
- preferences?: {
256
- language?: string;
257
- notifications?: boolean;
258
- };
259
- status?: {
260
- is_active?: boolean;
261
- is_banned?: boolean;
262
- verified?: boolean;
263
- };
264
- security?: {
265
- password_hash?: string;
266
- two_factor_enabled?: boolean;
267
- last_password_change?: Date;
268
- };
269
- verify_info?: {
270
- first_name?: string;
271
- last_name?: string;
272
- born_date?: Date;
273
- national_id?: string;
274
- };
275
- dynamic_info?: {
276
- [key: string]: any;
277
- };
278
- apps?: {
279
- app_name: string;
280
- app_id: string;
281
- device_id: string;
282
- }[];
283
- createdAt?: Date;
284
- updatedAt?: Date;
186
+ user_id: number;
187
+ user_name: string;
188
+ nick_name: string;
189
+ exp: number;
190
+ primary_email?: string | null;
191
+ primary_phone?: string | null;
192
+ emails: import("./find").UserEmailItem[];
193
+ phone_numbers: import("./find").UserPhoneItem[];
194
+ auth_profiles: import("./find").UserAuthProfiles;
195
+ profile_image_url: string;
196
+ date_of_birth: Date | null;
197
+ gender?: import("./find").Gender;
198
+ sign_up_date: Date | null;
199
+ last_login: Date | null;
200
+ wallets: import("./find").UserWalletItem[];
201
+ preferences: import("./find").UserPreferences;
202
+ status: import("./find").UserStatus;
203
+ security: import("./find").UserSecurity;
204
+ verify_info: import("./find").UserVerifyInfo;
205
+ dynamic_info: Record<string, any>;
206
+ apps: import("./find").UserAppItem[];
207
+ search_string?: string;
208
+ delFlg?: boolean;
209
+ order_index?: number;
285
210
  }[];
286
211
  message: string;
287
212
  }>;
package/dist/socket.d.ts CHANGED
@@ -38,6 +38,15 @@ export declare const ShowOrderStatus: (body: {
38
38
  data: null;
39
39
  message: string;
40
40
  }>;
41
+ export declare const EMIT: (body: {
42
+ user_id: number;
43
+ emit_name: string;
44
+ data: any;
45
+ }[]) => Promise<{
46
+ success: boolean;
47
+ data: null;
48
+ message: string;
49
+ }>;
41
50
  declare const _default: {
42
51
  ShowToast: (body: {
43
52
  user_id: number;
@@ -79,5 +88,14 @@ declare const _default: {
79
88
  data: null;
80
89
  message: string;
81
90
  }>;
91
+ EMIT: (body: {
92
+ user_id: number;
93
+ emit_name: string;
94
+ data: any;
95
+ }[]) => Promise<{
96
+ success: boolean;
97
+ data: null;
98
+ message: string;
99
+ }>;
82
100
  };
83
101
  export default _default;
package/dist/socket.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ShowOrderStatus = exports.ShowStatus = exports.ShowToast = void 0;
3
+ exports.EMIT = exports.ShowOrderStatus = exports.ShowStatus = exports.ShowToast = void 0;
4
4
  const _1 = require(".");
5
5
  const auth_1 = require("./auth");
6
6
  const axios_master_1 = require("axios-master");
@@ -149,4 +149,52 @@ const ShowOrderStatus = async (body) => {
149
149
  }
150
150
  };
151
151
  exports.ShowOrderStatus = ShowOrderStatus;
152
- exports.default = { ShowToast: exports.ShowToast, ShowStatus: exports.ShowStatus, ShowOrderStatus: exports.ShowOrderStatus };
152
+ const EMIT = async (body) => {
153
+ var _a;
154
+ try {
155
+ const result = await (0, axios_master_1.axiosMasterLogger)({
156
+ method: "POST",
157
+ url: `${_1.config.hosts.MAIN}/main/v1/socket/emit`,
158
+ headers: {
159
+ Accept: "application/json",
160
+ "Content-Type": "application/json",
161
+ Authorization: `Bearer ${_1.config.token}`
162
+ },
163
+ data: body
164
+ }, {
165
+ name: "socket emit",
166
+ timeout: 20000,
167
+ retryFunction: auth_1.getToken,
168
+ shouldRetry: true,
169
+ shouldRetryStatus: [401, 400],
170
+ logger(data) {
171
+ if (_1.config.logger) {
172
+ console.log({
173
+ time: data.json.time,
174
+ request: data.json.request,
175
+ response: `${data.json.response}`,
176
+ responseBody: data.json.responseBody,
177
+ statusCode: data.json.statusCode
178
+ });
179
+ }
180
+ }
181
+ });
182
+ return { success: true, data: result.data, message: result.message };
183
+ }
184
+ catch (error) {
185
+ const axiosError = error;
186
+ if (axiosError.data) {
187
+ console.log(axiosError.data);
188
+ }
189
+ else {
190
+ console.error("Request Failed:", axiosError);
191
+ }
192
+ return {
193
+ success: false,
194
+ data: null,
195
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || ""
196
+ };
197
+ }
198
+ };
199
+ exports.EMIT = EMIT;
200
+ exports.default = { ShowToast: exports.ShowToast, ShowStatus: exports.ShowStatus, ShowOrderStatus: exports.ShowOrderStatus, EMIT: exports.EMIT };
package/package.json CHANGED
@@ -1,48 +1,48 @@
1
- {
2
- "name": "auth-mn",
3
- "version": "0.1.9",
4
- "description": "Auth.mn API",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist/"
9
- ],
10
- "scripts": {
11
- "test": "echo \"Error: no test specified\" && exit 1",
12
- "build-ts": "rm -rf ./dist && npx tsc",
13
- "build": "npx tsc",
14
- "debug": "npm run build && npm run watch-debug",
15
- "lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/togtokh-dev/auth-mn.git"
20
- },
21
- "keywords": [
22
- "auth.mn",
23
- "axios",
24
- "togtokh.dev"
25
- ],
26
- "author": "TOGTOKH.DEV",
27
- "license": "ISC",
28
- "bugs": {
29
- "url": "https://github.com/togtokh-dev/auth-mn/issues"
30
- },
31
- "homepage": "https://github.com/togtokh-dev/auth-mn/#readme",
32
- "dependencies": {
33
- "axios": "^1.6.2",
34
- "axios-master": "^2.0.7",
35
- "https": "^1.0.0",
36
- "ts-node": "^10.9.2",
37
- "typescript": "^5.0.4"
38
- },
39
- "devDependencies": {
40
- "@types/node": "^18.15.11",
41
- "@typescript-eslint/eslint-plugin": "^6.4.0",
42
- "@typescript-eslint/parser": "^6.4.0",
43
- "eslint": "^8.47.0"
44
- },
45
- "publishConfig": {
46
- "access": "public"
47
- }
48
- }
1
+ {
2
+ "name": "auth-mn",
3
+ "version": "0.2.0",
4
+ "description": "Auth.mn API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist/"
9
+ ],
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1",
12
+ "build-ts": "rm -rf ./dist && npx tsc",
13
+ "build": "npx tsc",
14
+ "debug": "npm run build && npm run watch-debug",
15
+ "lint": "tsc --noEmit && eslint \"**/*.{js,ts}\" --quiet --fix"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/togtokh-dev/auth-mn.git"
20
+ },
21
+ "keywords": [
22
+ "auth.mn",
23
+ "axios",
24
+ "togtokh.dev"
25
+ ],
26
+ "author": "TOGTOKH.DEV",
27
+ "license": "ISC",
28
+ "bugs": {
29
+ "url": "https://github.com/togtokh-dev/auth-mn/issues"
30
+ },
31
+ "homepage": "https://github.com/togtokh-dev/auth-mn/#readme",
32
+ "dependencies": {
33
+ "axios": "^1.6.2",
34
+ "axios-master": "^2.0.7",
35
+ "https": "^1.0.0",
36
+ "ts-node": "^10.9.2",
37
+ "typescript": "^5.0.4"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^18.15.11",
41
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
42
+ "@typescript-eslint/parser": "^6.4.0",
43
+ "eslint": "^8.47.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }