auth-mn 0.1.3 → 0.1.5

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/find.d.ts ADDED
@@ -0,0 +1,193 @@
1
+ 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;
68
+ };
69
+ type MerchantT = {
70
+ _id?: string;
71
+ user_id: number;
72
+ user_name?: string;
73
+ phone_number?: string;
74
+ user_role?: "merchant" | "sub-merchant";
75
+ avatar?: string;
76
+ authority?: string[];
77
+ user_email?: string;
78
+ password?: string;
79
+ show_router?: string[];
80
+ show_id?: string[];
81
+ merchant: {
82
+ toki_id: string;
83
+ hipay: string;
84
+ };
85
+ wallet_id?: string;
86
+ wallet_key?: string;
87
+ delFlg?: boolean;
88
+ createdAt?: Date;
89
+ updatedAt?: Date;
90
+ };
91
+ type AdminT = {
92
+ _id?: string;
93
+ user_id?: number;
94
+ user_name?: string;
95
+ phone_number?: number;
96
+ user_role?: "admin" | "sub-admin" | "super-admin";
97
+ avatar?: string;
98
+ authority?: string[];
99
+ user_email?: string;
100
+ password?: string;
101
+ show_router?: string[];
102
+ show_id?: string[];
103
+ delFlg?: boolean;
104
+ createdAt?: Date;
105
+ updatedAt?: Date;
106
+ };
107
+ type ClientT = {
108
+ _id?: string;
109
+ user_id?: number;
110
+ user_name?: string;
111
+ phone_number?: number;
112
+ user_role?: "crm" | "sub-crm";
113
+ avatar?: string;
114
+ authority?: string[];
115
+ user_email?: string;
116
+ password?: string;
117
+ show_router?: string[];
118
+ show_id?: string[];
119
+ RefundFun?: boolean;
120
+ delFlg?: boolean;
121
+ createdAt?: Date;
122
+ updatedAt?: Date;
123
+ };
124
+ type CrmT = {
125
+ _id?: string;
126
+ user_id?: number;
127
+ user_name?: string;
128
+ phone_number?: number;
129
+ user_role?: "crm" | "sub-crm";
130
+ avatar?: string;
131
+ authority?: string[];
132
+ user_email?: string;
133
+ password?: string;
134
+ show_router?: string[];
135
+ show_id?: string[];
136
+ RefundFun?: boolean;
137
+ delFlg?: boolean;
138
+ createdAt?: Date;
139
+ updatedAt?: Date;
140
+ };
141
+ export declare const USER: (body: UserT) => Promise<{
142
+ success: boolean;
143
+ data: UserT[];
144
+ message: string;
145
+ }>;
146
+ export declare const MERCHANT: (body: MerchantT) => Promise<{
147
+ success: boolean;
148
+ data: MerchantT[];
149
+ message: string;
150
+ }>;
151
+ export declare const ADMIN: (body: AdminT) => Promise<{
152
+ success: boolean;
153
+ data: AdminT[];
154
+ message: string;
155
+ }>;
156
+ export declare const CLIENT: (body: ClientT) => Promise<{
157
+ success: boolean;
158
+ data: ClientT[];
159
+ message: string;
160
+ }>;
161
+ export declare const CRM: (body: CrmT) => Promise<{
162
+ success: boolean;
163
+ data: CrmT[];
164
+ message: string;
165
+ }>;
166
+ declare const _default: {
167
+ USER: (body: UserT) => Promise<{
168
+ success: boolean;
169
+ data: UserT[];
170
+ message: string;
171
+ }>;
172
+ MERCHANT: (body: MerchantT) => Promise<{
173
+ success: boolean;
174
+ data: MerchantT[];
175
+ message: string;
176
+ }>;
177
+ ADMIN: (body: AdminT) => Promise<{
178
+ success: boolean;
179
+ data: AdminT[];
180
+ message: string;
181
+ }>;
182
+ CLIENT: (body: ClientT) => Promise<{
183
+ success: boolean;
184
+ data: ClientT[];
185
+ message: string;
186
+ }>;
187
+ CRM: (body: CrmT) => Promise<{
188
+ success: boolean;
189
+ data: CrmT[];
190
+ message: string;
191
+ }>;
192
+ };
193
+ export default _default;
package/dist/find.js ADDED
@@ -0,0 +1,222 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CRM = exports.CLIENT = exports.ADMIN = exports.MERCHANT = exports.USER = void 0;
4
+ const _1 = require(".");
5
+ const auth_1 = require("./auth");
6
+ const axios_master_1 = require("axios-master");
7
+ const USER = async (body) => {
8
+ var _a;
9
+ try {
10
+ const result = await (0, axios_master_1.axiosMasterMain)({
11
+ method: "POST",
12
+ maxBodyLength: Infinity,
13
+ url: `${_1.config.hosts.MAIN}/main/v1/auth/support/find/user`,
14
+ headers: {
15
+ Accept: "application/json",
16
+ "Content-Type": "application/json",
17
+ Authorization: `Bearer ${_1.config.token}`,
18
+ },
19
+ data: body,
20
+ }, {
21
+ name: "support/find/user",
22
+ timeout: 20000,
23
+ retryFunction: auth_1.getToken,
24
+ shouldRetry: true,
25
+ shouldRetryStatus: [401, 400],
26
+ logger(data) {
27
+ if (_1.config.logger) {
28
+ console.log(data.json);
29
+ }
30
+ },
31
+ });
32
+ return { success: true, data: result.data, message: result.message };
33
+ }
34
+ catch (error) {
35
+ const axiosError = error;
36
+ if (axiosError.data) {
37
+ console.log(axiosError.data);
38
+ }
39
+ else {
40
+ console.error("Request Failed:", axiosError);
41
+ }
42
+ return {
43
+ success: false,
44
+ data: null,
45
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
46
+ };
47
+ }
48
+ };
49
+ exports.USER = USER;
50
+ const MERCHANT = async (body) => {
51
+ var _a;
52
+ try {
53
+ const result = await (0, axios_master_1.axiosMasterMain)({
54
+ method: "POST",
55
+ maxBodyLength: Infinity,
56
+ url: `${_1.config.hosts.MAIN}/main/v1/auth/support/find/merchant`,
57
+ headers: {
58
+ Accept: "application/json",
59
+ "Content-Type": "application/json",
60
+ Authorization: `Bearer ${_1.config.token}`,
61
+ },
62
+ data: body,
63
+ }, {
64
+ name: "support/find/merchant",
65
+ timeout: 20000,
66
+ retryFunction: auth_1.getToken,
67
+ shouldRetry: true,
68
+ shouldRetryStatus: [401, 400],
69
+ logger(data) {
70
+ if (_1.config.logger) {
71
+ console.log(data.json);
72
+ }
73
+ },
74
+ });
75
+ return { success: true, data: result.data, message: result.message };
76
+ }
77
+ catch (error) {
78
+ const axiosError = error;
79
+ if (axiosError.data) {
80
+ console.log(axiosError.data);
81
+ }
82
+ else {
83
+ console.error("Request Failed:", axiosError);
84
+ }
85
+ return {
86
+ success: false,
87
+ data: null,
88
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
89
+ };
90
+ }
91
+ };
92
+ exports.MERCHANT = MERCHANT;
93
+ const ADMIN = async (body) => {
94
+ var _a;
95
+ try {
96
+ const result = await (0, axios_master_1.axiosMasterMain)({
97
+ method: "POST",
98
+ maxBodyLength: Infinity,
99
+ url: `${_1.config.hosts.MAIN}/main/v1/auth/support/find/admin`,
100
+ headers: {
101
+ Accept: "application/json",
102
+ "Content-Type": "application/json",
103
+ Authorization: `Bearer ${_1.config.token}`,
104
+ },
105
+ data: body,
106
+ }, {
107
+ name: "support/find/admin",
108
+ timeout: 20000,
109
+ retryFunction: auth_1.getToken,
110
+ shouldRetry: true,
111
+ shouldRetryStatus: [401, 400],
112
+ logger(data) {
113
+ if (_1.config.logger) {
114
+ console.log(data.json);
115
+ }
116
+ },
117
+ });
118
+ return { success: true, data: result.data, message: result.message };
119
+ }
120
+ catch (error) {
121
+ const axiosError = error;
122
+ if (axiosError.data) {
123
+ console.log(axiosError.data);
124
+ }
125
+ else {
126
+ console.error("Request Failed:", axiosError);
127
+ }
128
+ return {
129
+ success: false,
130
+ data: null,
131
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
132
+ };
133
+ }
134
+ };
135
+ exports.ADMIN = ADMIN;
136
+ const CLIENT = async (body) => {
137
+ var _a;
138
+ try {
139
+ const result = await (0, axios_master_1.axiosMasterMain)({
140
+ method: "POST",
141
+ maxBodyLength: Infinity,
142
+ url: `${_1.config.hosts.MAIN}/main/v1/auth/support/find/client`,
143
+ headers: {
144
+ Accept: "application/json",
145
+ "Content-Type": "application/json",
146
+ Authorization: `Bearer ${_1.config.token}`,
147
+ },
148
+ data: body,
149
+ }, {
150
+ name: "support/find/client",
151
+ timeout: 20000,
152
+ retryFunction: auth_1.getToken,
153
+ shouldRetry: true,
154
+ shouldRetryStatus: [401, 400],
155
+ logger(data) {
156
+ if (_1.config.logger) {
157
+ console.log(data.json);
158
+ }
159
+ },
160
+ });
161
+ return { success: true, data: result.data, message: result.message };
162
+ }
163
+ catch (error) {
164
+ const axiosError = error;
165
+ if (axiosError.data) {
166
+ console.log(axiosError.data);
167
+ }
168
+ else {
169
+ console.error("Request Failed:", axiosError);
170
+ }
171
+ return {
172
+ success: false,
173
+ data: null,
174
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
175
+ };
176
+ }
177
+ };
178
+ exports.CLIENT = CLIENT;
179
+ const CRM = async (body) => {
180
+ var _a;
181
+ try {
182
+ const result = await (0, axios_master_1.axiosMasterMain)({
183
+ method: "POST",
184
+ maxBodyLength: Infinity,
185
+ url: `${_1.config.hosts.MAIN}/main/v1/auth/support/find/crm`,
186
+ headers: {
187
+ Accept: "application/json",
188
+ "Content-Type": "application/json",
189
+ Authorization: `Bearer ${_1.config.token}`,
190
+ },
191
+ data: body,
192
+ }, {
193
+ name: "support/find/crm",
194
+ timeout: 20000,
195
+ retryFunction: auth_1.getToken,
196
+ shouldRetry: true,
197
+ shouldRetryStatus: [401, 400],
198
+ logger(data) {
199
+ if (_1.config.logger) {
200
+ console.log(data.json);
201
+ }
202
+ },
203
+ });
204
+ return { success: true, data: result.data, message: result.message };
205
+ }
206
+ catch (error) {
207
+ const axiosError = error;
208
+ if (axiosError.data) {
209
+ console.log(axiosError.data);
210
+ }
211
+ else {
212
+ console.error("Request Failed:", axiosError);
213
+ }
214
+ return {
215
+ success: false,
216
+ data: null,
217
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
218
+ };
219
+ }
220
+ };
221
+ exports.CRM = CRM;
222
+ exports.default = { USER: exports.USER, MERCHANT: exports.MERCHANT, ADMIN: exports.ADMIN, CLIENT: exports.CLIENT, CRM: exports.CRM };
package/dist/index.d.ts CHANGED
@@ -55,6 +55,53 @@ declare const _default: {
55
55
  data: null;
56
56
  message: string;
57
57
  }>;
58
+ MAIL: (body: {
59
+ type: "notification" | "otp" | "custom";
60
+ form?: {
61
+ name?: string;
62
+ email?: string;
63
+ };
64
+ to: string[];
65
+ subject: string;
66
+ body: {
67
+ name: string;
68
+ title?: string;
69
+ desc?: string;
70
+ otp?: string | number;
71
+ button?: {
72
+ text: string;
73
+ url: string | null;
74
+ };
75
+ footer_text?: string;
76
+ };
77
+ }) => Promise<{
78
+ success: boolean;
79
+ data: null;
80
+ message: string;
81
+ }>;
82
+ _3RD: {
83
+ TOKI: (body: {
84
+ accountId: string;
85
+ title: string;
86
+ body: string;
87
+ url: string;
88
+ buttonName: string;
89
+ imageURL?: string;
90
+ icon: string;
91
+ }) => Promise<{
92
+ success: boolean;
93
+ data: null;
94
+ message: string;
95
+ }>;
96
+ HIPAY: (body: {
97
+ customerId: string;
98
+ message: string;
99
+ }) => Promise<{
100
+ success: boolean;
101
+ data: null;
102
+ message: string;
103
+ }>;
104
+ };
58
105
  };
59
106
  socket: {
60
107
  ShowToast: (body: {
@@ -98,7 +145,305 @@ declare const _default: {
98
145
  message: string;
99
146
  }>;
100
147
  };
148
+ find: {
149
+ 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;
216
+ }) => Promise<{
217
+ success: boolean;
218
+ 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;
285
+ }[];
286
+ message: string;
287
+ }>;
288
+ MERCHANT: (body: {
289
+ _id?: string;
290
+ user_id: number;
291
+ user_name?: string;
292
+ phone_number?: string;
293
+ user_role?: "merchant" | "sub-merchant";
294
+ avatar?: string;
295
+ authority?: string[];
296
+ user_email?: string;
297
+ password?: string;
298
+ show_router?: string[];
299
+ show_id?: string[];
300
+ merchant: {
301
+ toki_id: string;
302
+ hipay: string;
303
+ };
304
+ wallet_id?: string;
305
+ wallet_key?: string;
306
+ delFlg?: boolean;
307
+ createdAt?: Date;
308
+ updatedAt?: Date;
309
+ }) => Promise<{
310
+ success: boolean;
311
+ data: {
312
+ _id?: string;
313
+ user_id: number;
314
+ user_name?: string;
315
+ phone_number?: string;
316
+ user_role?: "merchant" | "sub-merchant";
317
+ avatar?: string;
318
+ authority?: string[];
319
+ user_email?: string;
320
+ password?: string;
321
+ show_router?: string[];
322
+ show_id?: string[];
323
+ merchant: {
324
+ toki_id: string;
325
+ hipay: string;
326
+ };
327
+ wallet_id?: string;
328
+ wallet_key?: string;
329
+ delFlg?: boolean;
330
+ createdAt?: Date;
331
+ updatedAt?: Date;
332
+ }[];
333
+ message: string;
334
+ }>;
335
+ ADMIN: (body: {
336
+ _id?: string;
337
+ user_id?: number;
338
+ user_name?: string;
339
+ phone_number?: number;
340
+ user_role?: "admin" | "sub-admin" | "super-admin";
341
+ avatar?: string;
342
+ authority?: string[];
343
+ user_email?: string;
344
+ password?: string;
345
+ show_router?: string[];
346
+ show_id?: string[];
347
+ delFlg?: boolean;
348
+ createdAt?: Date;
349
+ updatedAt?: Date;
350
+ }) => Promise<{
351
+ success: boolean;
352
+ data: {
353
+ _id?: string;
354
+ user_id?: number;
355
+ user_name?: string;
356
+ phone_number?: number;
357
+ user_role?: "admin" | "sub-admin" | "super-admin";
358
+ avatar?: string;
359
+ authority?: string[];
360
+ user_email?: string;
361
+ password?: string;
362
+ show_router?: string[];
363
+ show_id?: string[];
364
+ delFlg?: boolean;
365
+ createdAt?: Date;
366
+ updatedAt?: Date;
367
+ }[];
368
+ message: string;
369
+ }>;
370
+ CLIENT: (body: {
371
+ _id?: string;
372
+ user_id?: number;
373
+ user_name?: string;
374
+ phone_number?: number;
375
+ user_role?: "crm" | "sub-crm";
376
+ avatar?: string;
377
+ authority?: string[];
378
+ user_email?: string;
379
+ password?: string;
380
+ show_router?: string[];
381
+ show_id?: string[];
382
+ RefundFun?: boolean;
383
+ delFlg?: boolean;
384
+ createdAt?: Date;
385
+ updatedAt?: Date;
386
+ }) => Promise<{
387
+ success: boolean;
388
+ data: {
389
+ _id?: string;
390
+ user_id?: number;
391
+ user_name?: string;
392
+ phone_number?: number;
393
+ user_role?: "crm" | "sub-crm";
394
+ avatar?: string;
395
+ authority?: string[];
396
+ user_email?: string;
397
+ password?: string;
398
+ show_router?: string[];
399
+ show_id?: string[];
400
+ RefundFun?: boolean;
401
+ delFlg?: boolean;
402
+ createdAt?: Date;
403
+ updatedAt?: Date;
404
+ }[];
405
+ message: string;
406
+ }>;
407
+ CRM: (body: {
408
+ _id?: string;
409
+ user_id?: number;
410
+ user_name?: string;
411
+ phone_number?: number;
412
+ user_role?: "crm" | "sub-crm";
413
+ avatar?: string;
414
+ authority?: string[];
415
+ user_email?: string;
416
+ password?: string;
417
+ show_router?: string[];
418
+ show_id?: string[];
419
+ RefundFun?: boolean;
420
+ delFlg?: boolean;
421
+ createdAt?: Date;
422
+ updatedAt?: Date;
423
+ }) => Promise<{
424
+ success: boolean;
425
+ data: {
426
+ _id?: string;
427
+ user_id?: number;
428
+ user_name?: string;
429
+ phone_number?: number;
430
+ user_role?: "crm" | "sub-crm";
431
+ avatar?: string;
432
+ authority?: string[];
433
+ user_email?: string;
434
+ password?: string;
435
+ show_router?: string[];
436
+ show_id?: string[];
437
+ RefundFun?: boolean;
438
+ delFlg?: boolean;
439
+ createdAt?: Date;
440
+ updatedAt?: Date;
441
+ }[];
442
+ message: string;
443
+ }>;
444
+ };
101
445
  };
102
446
  export default _default;
103
447
  export { default as notification } from "./notification";
104
448
  export { default as socket } from "./socket";
449
+ export { default as find } from "./find";
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.socket = exports.notification = exports.setLogger = exports.setHost = exports.config = exports.ObjectId = exports.jsonToQueryString = void 0;
3
+ exports.find = exports.socket = exports.notification = exports.setLogger = exports.setHost = exports.config = exports.ObjectId = exports.jsonToQueryString = void 0;
4
4
  const auth_1 = require("./auth");
5
5
  const notification_1 = require("./notification");
6
6
  const socket_1 = require("./socket");
7
+ const find_1 = require("./find");
7
8
  const jsonToQueryString = (params) => {
8
9
  const query = Object.entries(params)
9
10
  .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
@@ -52,8 +53,11 @@ exports.default = {
52
53
  ObjectId: exports.ObjectId,
53
54
  notification: notification_1.default,
54
55
  socket: socket_1.default,
56
+ find: find_1.default,
55
57
  };
56
58
  var notification_2 = require("./notification");
57
59
  Object.defineProperty(exports, "notification", { enumerable: true, get: function () { return notification_2.default; } });
58
60
  var socket_2 = require("./socket");
59
61
  Object.defineProperty(exports, "socket", { enumerable: true, get: function () { return socket_2.default; } });
62
+ var find_2 = require("./find");
63
+ Object.defineProperty(exports, "find", { enumerable: true, get: function () { return find_2.default; } });
@@ -12,6 +12,26 @@ type SinglePushNotiT = {
12
12
  } | null;
13
13
  };
14
14
  };
15
+ type MailT = {
16
+ type: "notification" | "otp" | "custom";
17
+ form?: {
18
+ name?: string;
19
+ email?: string;
20
+ };
21
+ to: string[];
22
+ subject: string;
23
+ body: {
24
+ name: string;
25
+ title?: string;
26
+ desc?: string;
27
+ otp?: string | number;
28
+ button?: {
29
+ text: string;
30
+ url: string | null;
31
+ };
32
+ footer_text?: string;
33
+ };
34
+ };
15
35
  export declare const SinglePushNoti: (body: SinglePushNotiT) => Promise<{
16
36
  success: boolean;
17
37
  data: null;
@@ -26,6 +46,32 @@ export declare const SMS: (body: {
26
46
  data: null;
27
47
  message: string;
28
48
  }>;
49
+ export declare const MAIL: (body: MailT) => Promise<{
50
+ success: boolean;
51
+ data: null;
52
+ message: string;
53
+ }>;
54
+ export declare const _3RD_TOKI_NOTI: (body: {
55
+ accountId: string;
56
+ title: string;
57
+ body: string;
58
+ url: string;
59
+ buttonName: string;
60
+ imageURL?: string;
61
+ icon: string;
62
+ }) => Promise<{
63
+ success: boolean;
64
+ data: null;
65
+ message: string;
66
+ }>;
67
+ export declare const _3RD_TOKI_HIPAY: (body: {
68
+ customerId: string;
69
+ message: string;
70
+ }) => Promise<{
71
+ success: boolean;
72
+ data: null;
73
+ message: string;
74
+ }>;
29
75
  declare const _default: {
30
76
  SinglePushNoti: (body: SinglePushNotiT) => Promise<{
31
77
  success: boolean;
@@ -41,5 +87,33 @@ declare const _default: {
41
87
  data: null;
42
88
  message: string;
43
89
  }>;
90
+ MAIL: (body: MailT) => Promise<{
91
+ success: boolean;
92
+ data: null;
93
+ message: string;
94
+ }>;
95
+ _3RD: {
96
+ TOKI: (body: {
97
+ accountId: string;
98
+ title: string;
99
+ body: string;
100
+ url: string;
101
+ buttonName: string;
102
+ imageURL?: string;
103
+ icon: string;
104
+ }) => Promise<{
105
+ success: boolean;
106
+ data: null;
107
+ message: string;
108
+ }>;
109
+ HIPAY: (body: {
110
+ customerId: string;
111
+ message: string;
112
+ }) => Promise<{
113
+ success: boolean;
114
+ data: null;
115
+ message: string;
116
+ }>;
117
+ };
44
118
  };
45
119
  export default _default;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SMS = exports.SinglePushNoti = void 0;
3
+ exports._3RD_TOKI_HIPAY = exports._3RD_TOKI_NOTI = exports.MAIL = exports.SMS = exports.SinglePushNoti = void 0;
4
4
  const _1 = require(".");
5
5
  const auth_1 = require("./auth");
6
6
  const axios_master_1 = require("axios-master");
@@ -90,4 +90,141 @@ const SMS = async (body) => {
90
90
  }
91
91
  };
92
92
  exports.SMS = SMS;
93
- exports.default = { SinglePushNoti: exports.SinglePushNoti, SMS: exports.SMS };
93
+ const MAIL = async (body) => {
94
+ var _a;
95
+ try {
96
+ const result = await (0, axios_master_1.axiosMasterMain)({
97
+ method: "POST",
98
+ maxBodyLength: Infinity,
99
+ url: `${_1.config.hosts.MAIN}/main/v1/notification/mail`,
100
+ headers: {
101
+ Accept: "application/json",
102
+ "Content-Type": "application/json",
103
+ Authorization: `Bearer ${_1.config.token}`,
104
+ },
105
+ data: body,
106
+ }, {
107
+ name: "notification mail",
108
+ timeout: 20000,
109
+ retryFunction: auth_1.getToken,
110
+ shouldRetry: true,
111
+ shouldRetryStatus: [401, 400],
112
+ logger(data) {
113
+ if (_1.config.logger) {
114
+ console.log(data.json);
115
+ }
116
+ },
117
+ });
118
+ return { success: true, data: result.data, message: result.message };
119
+ }
120
+ catch (error) {
121
+ const axiosError = error;
122
+ if (axiosError.data) {
123
+ console.log(axiosError.data);
124
+ }
125
+ else {
126
+ console.error("Request Failed:", axiosError);
127
+ }
128
+ return {
129
+ success: false,
130
+ data: null,
131
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
132
+ };
133
+ }
134
+ };
135
+ exports.MAIL = MAIL;
136
+ const _3RD_TOKI_NOTI = async (body) => {
137
+ var _a;
138
+ try {
139
+ const result = await (0, axios_master_1.axiosMasterMain)({
140
+ method: "POST",
141
+ maxBodyLength: Infinity,
142
+ url: `${_1.config.hosts.MAIN}/main/v1/notification/3rd/toki-app`,
143
+ headers: {
144
+ Accept: "application/json",
145
+ "Content-Type": "application/json",
146
+ Authorization: `Bearer ${_1.config.token}`,
147
+ },
148
+ data: body,
149
+ }, {
150
+ name: "notification 3rd toki",
151
+ timeout: 20000,
152
+ retryFunction: auth_1.getToken,
153
+ shouldRetry: true,
154
+ shouldRetryStatus: [401, 400],
155
+ logger(data) {
156
+ if (_1.config.logger) {
157
+ console.log(data.json);
158
+ }
159
+ },
160
+ });
161
+ return { success: true, data: result.data, message: result.message };
162
+ }
163
+ catch (error) {
164
+ const axiosError = error;
165
+ if (axiosError.data) {
166
+ console.log(axiosError.data);
167
+ }
168
+ else {
169
+ console.error("Request Failed:", axiosError);
170
+ }
171
+ return {
172
+ success: false,
173
+ data: null,
174
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
175
+ };
176
+ }
177
+ };
178
+ exports._3RD_TOKI_NOTI = _3RD_TOKI_NOTI;
179
+ const _3RD_TOKI_HIPAY = async (body) => {
180
+ var _a;
181
+ try {
182
+ const result = await (0, axios_master_1.axiosMasterMain)({
183
+ method: "POST",
184
+ maxBodyLength: Infinity,
185
+ url: `${_1.config.hosts.MAIN}/main/v1/notification/3rd/hipay-app`,
186
+ headers: {
187
+ Accept: "application/json",
188
+ "Content-Type": "application/json",
189
+ Authorization: `Bearer ${_1.config.token}`,
190
+ },
191
+ data: body,
192
+ }, {
193
+ name: "notification 3rd hipay",
194
+ timeout: 20000,
195
+ retryFunction: auth_1.getToken,
196
+ shouldRetry: true,
197
+ shouldRetryStatus: [401, 400],
198
+ logger(data) {
199
+ if (_1.config.logger) {
200
+ console.log(data.json);
201
+ }
202
+ },
203
+ });
204
+ return { success: true, data: result.data, message: result.message };
205
+ }
206
+ catch (error) {
207
+ const axiosError = error;
208
+ if (axiosError.data) {
209
+ console.log(axiosError.data);
210
+ }
211
+ else {
212
+ console.error("Request Failed:", axiosError);
213
+ }
214
+ return {
215
+ success: false,
216
+ data: null,
217
+ message: ((_a = axiosError.data) === null || _a === void 0 ? void 0 : _a.message) || "",
218
+ };
219
+ }
220
+ };
221
+ exports._3RD_TOKI_HIPAY = _3RD_TOKI_HIPAY;
222
+ exports.default = {
223
+ SinglePushNoti: exports.SinglePushNoti,
224
+ SMS: exports.SMS,
225
+ MAIL: exports.MAIL,
226
+ _3RD: {
227
+ TOKI: exports._3RD_TOKI_NOTI,
228
+ HIPAY: exports._3RD_TOKI_HIPAY,
229
+ },
230
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auth-mn",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Auth.mn API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  "homepage": "https://github.com/togtokh-dev/auth-mn/#readme",
32
32
  "dependencies": {
33
33
  "axios": "^1.6.2",
34
- "axios-master": "^1.1.6",
34
+ "axios-master": "^2.0.1",
35
35
  "https": "^1.0.0",
36
36
  "ts-node": "^10.9.2",
37
37
  "typescript": "^5.0.4"