@riocrypto/common 1.0.376 → 1.0.378
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/build/index.d.ts +7 -1
- package/build/index.js +8 -1
- package/build/middlewares/get-order.d.ts +2 -1
- package/build/middlewares/get-order.js +3 -2
- package/build/middlewares/get-partner.d.ts +2 -1
- package/build/middlewares/get-partner.js +3 -2
- package/build/middlewares/get-user.d.ts +2 -1
- package/build/middlewares/get-user.js +5 -3
- package/build/middlewares/validate-order.d.ts +0 -2
- package/build/middlewares/validate-order.js +19 -26
- package/build/models/admin-auth.d.ts +4 -12
- package/build/models/admin-auth.js +37 -39
- package/build/models/auth.d.ts +5 -5
- package/build/models/auth.js +57 -58
- package/build/models/bank-payout.d.ts +5 -5
- package/build/models/bank-payout.js +36 -37
- package/build/models/business-user.d.ts +5 -5
- package/build/models/business-user.js +97 -98
- package/build/models/order.d.ts +5 -5
- package/build/models/order.js +106 -107
- package/build/models/partner.d.ts +5 -5
- package/build/models/partner.js +55 -56
- package/build/models/user.d.ts +6 -5
- package/build/models/user.js +81 -82
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export * from "./middlewares/get-partner";
|
|
|
32
32
|
export * from "./middlewares/get-user";
|
|
33
33
|
export * from "./middlewares/require-priveleges";
|
|
34
34
|
export * from "./middlewares/validate-kyc";
|
|
35
|
-
export * from "./middlewares/validate-order";
|
|
36
35
|
export * from "./events/base-listener";
|
|
37
36
|
export * from "./events/base-publisher";
|
|
38
37
|
export * from "./events/subjects";
|
|
@@ -142,3 +141,10 @@ export * from "./classes/USStateAsset";
|
|
|
142
141
|
export * from "./classes/WyrePaymentMethodAsset";
|
|
143
142
|
export * from "./services/apiKey";
|
|
144
143
|
export * from "./services/password";
|
|
144
|
+
export * from "./models/admin-auth";
|
|
145
|
+
export * from "./models/auth";
|
|
146
|
+
export * from "./models/business-user";
|
|
147
|
+
export * from "./models/bank-payout";
|
|
148
|
+
export * from "./models/order";
|
|
149
|
+
export * from "./models/partner";
|
|
150
|
+
export * from "./models/user";
|
package/build/index.js
CHANGED
|
@@ -48,7 +48,7 @@ __exportStar(require("./middlewares/get-partner"), exports);
|
|
|
48
48
|
__exportStar(require("./middlewares/get-user"), exports);
|
|
49
49
|
__exportStar(require("./middlewares/require-priveleges"), exports);
|
|
50
50
|
__exportStar(require("./middlewares/validate-kyc"), exports);
|
|
51
|
-
|
|
51
|
+
// export * from "./middlewares/validate-order";
|
|
52
52
|
__exportStar(require("./events/base-listener"), exports);
|
|
53
53
|
__exportStar(require("./events/base-publisher"), exports);
|
|
54
54
|
__exportStar(require("./events/subjects"), exports);
|
|
@@ -158,3 +158,10 @@ __exportStar(require("./classes/USStateAsset"), exports);
|
|
|
158
158
|
__exportStar(require("./classes/WyrePaymentMethodAsset"), exports);
|
|
159
159
|
__exportStar(require("./services/apiKey"), exports);
|
|
160
160
|
__exportStar(require("./services/password"), exports);
|
|
161
|
+
__exportStar(require("./models/admin-auth"), exports);
|
|
162
|
+
__exportStar(require("./models/auth"), exports);
|
|
163
|
+
__exportStar(require("./models/business-user"), exports);
|
|
164
|
+
__exportStar(require("./models/bank-payout"), exports);
|
|
165
|
+
__exportStar(require("./models/order"), exports);
|
|
166
|
+
__exportStar(require("./models/partner"), exports);
|
|
167
|
+
__exportStar(require("./models/user"), exports);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
import { Mongoose } from "mongoose";
|
|
2
3
|
import { OrderDoc } from "../models/order";
|
|
3
4
|
declare global {
|
|
4
5
|
namespace Express {
|
|
@@ -7,4 +8,4 @@ declare global {
|
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
export declare const getOrder: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
11
|
+
export declare const getOrder: (req: Request, res: Response, next: NextFunction, mongoose: Mongoose) => Promise<void>;
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getOrder = void 0;
|
|
13
13
|
const not_found_error_1 = require("../errors/not-found-error");
|
|
14
14
|
const order_1 = require("../models/order");
|
|
15
|
-
const getOrder = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const getOrder = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
16
|
let orderId = "";
|
|
17
17
|
if (req.body.orderId) {
|
|
18
18
|
orderId = req.body.orderId;
|
|
@@ -27,7 +27,8 @@ const getOrder = (req, res, next) => __awaiter(void 0, void 0, void 0, function*
|
|
|
27
27
|
throw new Error("Failed to provide orderId");
|
|
28
28
|
}
|
|
29
29
|
try {
|
|
30
|
-
const
|
|
30
|
+
const Order = yield (0, order_1.buildOrder)(mongoose);
|
|
31
|
+
const order = yield Order.findById(orderId);
|
|
31
32
|
if (!order) {
|
|
32
33
|
throw new Error();
|
|
33
34
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
import { Mongoose } from "mongoose";
|
|
2
3
|
declare global {
|
|
3
4
|
namespace Express {
|
|
4
5
|
interface Request {
|
|
@@ -6,4 +7,4 @@ declare global {
|
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
|
-
export declare const getPartner: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
10
|
+
export declare const getPartner: (req: Request, res: Response, next: NextFunction, mongoose: Mongoose) => Promise<void>;
|
|
@@ -16,7 +16,7 @@ exports.getPartner = void 0;
|
|
|
16
16
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
17
17
|
const partner_1 = require("../models/partner");
|
|
18
18
|
const apiKey_1 = require("../services/apiKey");
|
|
19
|
-
const getPartner = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const getPartner = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
20
|
try {
|
|
21
21
|
if (!req.headers["x-api-key"]) {
|
|
22
22
|
const payload = jsonwebtoken_1.default.verify(req.cookies.partnerAuthJwt, process.env.JWT_KEY_PARTNER);
|
|
@@ -24,7 +24,8 @@ const getPartner = (req, res, next) => __awaiter(void 0, void 0, void 0, functio
|
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
26
|
const hashedApiKey = yield apiKey_1.ApiKey.toHash(req.headers["x-api-key"]);
|
|
27
|
-
const
|
|
27
|
+
const Partner = yield (0, partner_1.buildPartner)(mongoose);
|
|
28
|
+
const partner = yield Partner.findOne({
|
|
28
29
|
apiKeys: { $elemMatch: { value: hashedApiKey } },
|
|
29
30
|
});
|
|
30
31
|
if (partner) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from "express";
|
|
2
2
|
import { BusinessUserDoc } from "../models/business-user";
|
|
3
3
|
import { UserDoc } from "../models/user";
|
|
4
|
+
import { Mongoose } from "mongoose";
|
|
4
5
|
declare global {
|
|
5
6
|
namespace Express {
|
|
6
7
|
interface Request {
|
|
@@ -8,4 +9,4 @@ declare global {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
|
-
export declare const getUser: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
12
|
+
export declare const getUser: (req: Request, res: Response, next: NextFunction, mongoose: Mongoose) => Promise<void>;
|
|
@@ -13,11 +13,12 @@ exports.getUser = void 0;
|
|
|
13
13
|
const business_user_1 = require("../models/business-user");
|
|
14
14
|
const user_1 = require("../models/user");
|
|
15
15
|
const user_attribute_1 = require("../types/user-attribute");
|
|
16
|
-
const getUser = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const getUser = (req, res, next, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
17
|
let individualUser;
|
|
18
18
|
let businessUser;
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
const User = yield (0, user_1.buildUser)(mongoose);
|
|
21
|
+
individualUser = yield User.findOne({
|
|
21
22
|
phoneNumber: req.currentAuth.phoneNumber,
|
|
22
23
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
23
24
|
});
|
|
@@ -26,7 +27,8 @@ const getUser = (req, res, next) => __awaiter(void 0, void 0, void 0, function*
|
|
|
26
27
|
individualUser = null;
|
|
27
28
|
}
|
|
28
29
|
try {
|
|
29
|
-
|
|
30
|
+
const BusinessUser = yield (0, business_user_1.buildBusinessUser)(mongoose);
|
|
31
|
+
businessUser = yield BusinessUser.findOne({
|
|
30
32
|
phoneNumber: req.currentAuth.phoneNumber,
|
|
31
33
|
attributes: { $ne: user_attribute_1.UserAttribute.deleted },
|
|
32
34
|
});
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (req.user && req.user._id.valueOf() !== order.userId) {
|
|
23
|
-
throw new not_authorized_error_1.NotAuthorizedError();
|
|
24
|
-
}
|
|
25
|
-
next();
|
|
26
|
-
});
|
|
27
|
-
exports.validateOrder = validateOrder;
|
|
2
|
+
// import { Request, Response, NextFunction } from "express";
|
|
3
|
+
// import { NotAuthorizedError } from "../errors/not-authorized-error";
|
|
4
|
+
// export const validateOrder = async (
|
|
5
|
+
// req: Request,
|
|
6
|
+
// res: Response,
|
|
7
|
+
// next: NextFunction
|
|
8
|
+
// ) => {
|
|
9
|
+
// const order = req.order;
|
|
10
|
+
// if (!order) {
|
|
11
|
+
// throw new NotAuthorizedError();
|
|
12
|
+
// }
|
|
13
|
+
// if (req.partnerId && req.partnerId !== order.partnerId) {
|
|
14
|
+
// throw new NotAuthorizedError();
|
|
15
|
+
// }
|
|
16
|
+
// if (req.user && req.user._id.valueOf() !== order.userId) {
|
|
17
|
+
// throw new NotAuthorizedError();
|
|
18
|
+
// }
|
|
19
|
+
// next();
|
|
20
|
+
// };
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
interface
|
|
1
|
+
import { Mongoose, Document } from "mongoose";
|
|
2
|
+
interface AdminAuthDoc extends Document {
|
|
3
3
|
email: string;
|
|
4
4
|
password: string;
|
|
5
5
|
previousPasswords?: string[];
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
password: string;
|
|
10
|
-
previousPasswords?: string[];
|
|
11
|
-
}
|
|
12
|
-
interface AdminAuthModel extends mongoose.Model<AdminAuthDoc> {
|
|
13
|
-
build(attrs: AdminAuthAttrs): AdminAuthDoc;
|
|
14
|
-
}
|
|
15
|
-
declare const AdminAuth: AdminAuthModel;
|
|
16
|
-
export { AdminAuth, AdminAuthDoc };
|
|
7
|
+
declare const buildAdminAuth: (mongoose: Mongoose) => void;
|
|
8
|
+
export { buildAdminAuth, AdminAuthDoc };
|
|
@@ -8,49 +8,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
const mongoose_1 = __importDefault(require("mongoose"));
|
|
12
|
+
exports.buildAdminAuth = void 0;
|
|
17
13
|
const password_1 = require("../services/password");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
required: true,
|
|
26
|
-
},
|
|
27
|
-
previousPasswords: [
|
|
28
|
-
{
|
|
14
|
+
const buildAdminAuth = (mongoose) => {
|
|
15
|
+
const AdminSchema = new mongoose.Schema({
|
|
16
|
+
email: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
password: {
|
|
29
21
|
type: String,
|
|
30
|
-
required:
|
|
22
|
+
required: true,
|
|
31
23
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
previousPasswords: [
|
|
25
|
+
{
|
|
26
|
+
type: String,
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
}, {
|
|
31
|
+
toJSON: {
|
|
32
|
+
transform(doc, ret) {
|
|
33
|
+
ret.id = ret._id.valueOf();
|
|
34
|
+
delete ret._id;
|
|
35
|
+
delete ret.__v;
|
|
36
|
+
delete ret.password;
|
|
37
|
+
},
|
|
40
38
|
},
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
AdminSchema.pre("save", function (done) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (this.isModified("password")) {
|
|
46
|
-
const hashed = yield password_1.Password.toHash(this.get("password"));
|
|
47
|
-
this.set("password", hashed);
|
|
48
|
-
}
|
|
49
|
-
done();
|
|
50
39
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
40
|
+
AdminSchema.pre("save", function (done) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
if (this.isModified("password")) {
|
|
43
|
+
const hashed = yield password_1.Password.toHash(this.get("password"));
|
|
44
|
+
this.set("password", hashed);
|
|
45
|
+
}
|
|
46
|
+
done();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
AdminSchema.statics.build = (attrs) => {
|
|
50
|
+
return new AdminAuth(attrs);
|
|
51
|
+
};
|
|
52
|
+
const AdminAuth = mongoose.model("Admin", AdminSchema);
|
|
54
53
|
};
|
|
55
|
-
|
|
56
|
-
exports.AdminAuth = AdminAuth;
|
|
54
|
+
exports.buildAdminAuth = buildAdminAuth;
|
package/build/models/auth.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
1
|
import { APIKey } from "../types/api-key";
|
|
3
2
|
import { SecurityQuestion } from "../types/security-question";
|
|
3
|
+
import { Mongoose, Model, Document } from "mongoose";
|
|
4
4
|
interface AuthAttrs {
|
|
5
5
|
phoneNumber: string;
|
|
6
6
|
password?: string;
|
|
@@ -9,7 +9,7 @@ interface AuthAttrs {
|
|
|
9
9
|
previousPasswords?: string[];
|
|
10
10
|
apiKeys?: APIKey[];
|
|
11
11
|
}
|
|
12
|
-
interface AuthDoc extends
|
|
12
|
+
interface AuthDoc extends Document {
|
|
13
13
|
phoneNumber: string;
|
|
14
14
|
password?: string;
|
|
15
15
|
securityQuestion?: SecurityQuestion;
|
|
@@ -17,8 +17,8 @@ interface AuthDoc extends mongoose.Document {
|
|
|
17
17
|
previousPasswords?: string[];
|
|
18
18
|
apiKeys?: APIKey[];
|
|
19
19
|
}
|
|
20
|
-
interface AuthModel extends
|
|
20
|
+
interface AuthModel extends Model<AuthDoc> {
|
|
21
21
|
build(attrs: AuthAttrs): AuthDoc;
|
|
22
22
|
}
|
|
23
|
-
declare const
|
|
24
|
-
export {
|
|
23
|
+
declare const buildAuth: (mongoose: Mongoose) => AuthModel;
|
|
24
|
+
export { buildAuth, AuthDoc };
|
package/build/models/auth.js
CHANGED
|
@@ -8,73 +8,72 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
16
|
-
const mongoose_1 = __importDefault(require("mongoose"));
|
|
12
|
+
exports.buildAuth = void 0;
|
|
17
13
|
const password_1 = require("../services/password");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
securityQuestion: {
|
|
27
|
-
type: String,
|
|
28
|
-
},
|
|
29
|
-
securityAnswer: {
|
|
30
|
-
type: String,
|
|
31
|
-
},
|
|
32
|
-
previousPasswords: [
|
|
33
|
-
{
|
|
14
|
+
const buildAuth = (mongoose) => {
|
|
15
|
+
const AuthSchema = new mongoose.Schema({
|
|
16
|
+
phoneNumber: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
password: {
|
|
34
21
|
type: String,
|
|
35
22
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
securityQuestion: {
|
|
24
|
+
type: String,
|
|
25
|
+
},
|
|
26
|
+
securityAnswer: {
|
|
27
|
+
type: String,
|
|
28
|
+
},
|
|
29
|
+
previousPasswords: [
|
|
30
|
+
{
|
|
40
31
|
type: String,
|
|
41
|
-
required: true,
|
|
42
32
|
},
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
],
|
|
34
|
+
apiKeys: [
|
|
35
|
+
{
|
|
36
|
+
value: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: true,
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: String,
|
|
42
|
+
},
|
|
43
|
+
id: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
45
47
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
],
|
|
49
|
+
}, {
|
|
50
|
+
toJSON: {
|
|
51
|
+
transform(doc, ret) {
|
|
52
|
+
ret.id = ret._id.valueOf();
|
|
53
|
+
delete ret._id;
|
|
54
|
+
delete ret.__v;
|
|
55
|
+
delete ret.password;
|
|
56
|
+
delete ret.securityAnswer;
|
|
57
|
+
delete ret.previousPasswords;
|
|
58
|
+
for (let apiKey of ret.apiKeys) {
|
|
59
|
+
delete apiKey.value;
|
|
60
|
+
}
|
|
49
61
|
},
|
|
50
62
|
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
delete ret.__v;
|
|
58
|
-
delete ret.password;
|
|
59
|
-
delete ret.securityAnswer;
|
|
60
|
-
delete ret.previousPasswords;
|
|
61
|
-
for (let apiKey of ret.apiKeys) {
|
|
62
|
-
delete apiKey.value;
|
|
63
|
+
});
|
|
64
|
+
AuthSchema.pre("save", function (done) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
if (this.isModified("password")) {
|
|
67
|
+
const hashed = yield password_1.Password.toHash(this.get("password"));
|
|
68
|
+
this.set("password", hashed);
|
|
63
69
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
AuthSchema.pre("save", function (done) {
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
if (this.isModified("password")) {
|
|
70
|
-
const hashed = yield password_1.Password.toHash(this.get("password"));
|
|
71
|
-
this.set("password", hashed);
|
|
72
|
-
}
|
|
73
|
-
done();
|
|
70
|
+
done();
|
|
71
|
+
});
|
|
74
72
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
AuthSchema.statics.build = (attrs) => {
|
|
74
|
+
return new Auth(attrs);
|
|
75
|
+
};
|
|
76
|
+
const Auth = mongoose.model("Auth", AuthSchema);
|
|
77
|
+
return Auth;
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
exports.Auth = Auth;
|
|
79
|
+
exports.buildAuth = buildAuth;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Mongoose, Model, Document } from "mongoose";
|
|
2
2
|
interface BankPayoutAttrs {
|
|
3
3
|
orderId: string;
|
|
4
4
|
originBank: string;
|
|
@@ -6,15 +6,15 @@ interface BankPayoutAttrs {
|
|
|
6
6
|
accountNumber: string;
|
|
7
7
|
status: string;
|
|
8
8
|
}
|
|
9
|
-
interface BankPayoutDoc extends
|
|
9
|
+
interface BankPayoutDoc extends Document {
|
|
10
10
|
orderId: string;
|
|
11
11
|
originBank: string;
|
|
12
12
|
destinationBank?: string;
|
|
13
13
|
accountNumber: string;
|
|
14
14
|
status: string;
|
|
15
15
|
}
|
|
16
|
-
interface BankPayoutModel extends
|
|
16
|
+
interface BankPayoutModel extends Model<BankPayoutDoc> {
|
|
17
17
|
build(attrs: BankPayoutAttrs): BankPayoutDoc;
|
|
18
18
|
}
|
|
19
|
-
declare const
|
|
20
|
-
export {
|
|
19
|
+
declare const buildBankPayout: (mongoose: Mongoose) => BankPayoutModel;
|
|
20
|
+
export { buildBankPayout, BankPayoutDoc };
|
|
@@ -1,41 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const
|
|
8
|
-
const BankPayoutSchema = new
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
3
|
+
exports.buildBankPayout = void 0;
|
|
4
|
+
const buildBankPayout = (mongoose) => {
|
|
5
|
+
const BankPayoutSchema = new mongoose.Schema({
|
|
6
|
+
orderId: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
},
|
|
10
|
+
originBank: {
|
|
11
|
+
type: String,
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
accountNumber: {
|
|
15
|
+
type: String,
|
|
16
|
+
required: true,
|
|
17
|
+
},
|
|
18
|
+
status: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
destinationBank: {
|
|
23
|
+
type: String,
|
|
24
|
+
},
|
|
25
|
+
}, {
|
|
26
|
+
toJSON: {
|
|
27
|
+
transform(doc, ret) {
|
|
28
|
+
ret.id = ret._id;
|
|
29
|
+
delete ret._id;
|
|
30
|
+
delete ret.__v;
|
|
31
|
+
},
|
|
34
32
|
},
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
});
|
|
34
|
+
BankPayoutSchema.statics.build = (attrs) => {
|
|
35
|
+
return new BankPayout(attrs);
|
|
36
|
+
};
|
|
37
|
+
const BankPayout = mongoose.model("BankPayout", BankPayoutSchema);
|
|
38
|
+
return BankPayout;
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
exports.BankPayout = BankPayout;
|
|
40
|
+
exports.buildBankPayout = buildBankPayout;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
1
|
import { Country } from "../types/country";
|
|
3
2
|
import { KYCStatus } from "../types/kyc-status";
|
|
4
3
|
import { Language } from "../types/language";
|
|
@@ -6,6 +5,7 @@ import { PlatformFeeRange } from "../types/platform-fee-range";
|
|
|
6
5
|
import { USState } from "../types/us-state";
|
|
7
6
|
import { UserAttribute } from "../types/user-attribute";
|
|
8
7
|
import { UserType } from "../types/user-type";
|
|
8
|
+
import { Mongoose, Model, Document } from "mongoose";
|
|
9
9
|
interface BusinessUserAttrs {
|
|
10
10
|
type: UserType;
|
|
11
11
|
companyName: string;
|
|
@@ -27,10 +27,10 @@ interface BusinessUserAttrs {
|
|
|
27
27
|
brokerId?: string;
|
|
28
28
|
platformFeeRanges?: PlatformFeeRange[];
|
|
29
29
|
}
|
|
30
|
-
interface BusinessUserModel extends
|
|
30
|
+
interface BusinessUserModel extends Model<BusinessUserDoc> {
|
|
31
31
|
build(attrs: BusinessUserAttrs): BusinessUserDoc;
|
|
32
32
|
}
|
|
33
|
-
interface BusinessUserDoc extends
|
|
33
|
+
interface BusinessUserDoc extends Document {
|
|
34
34
|
type: UserType;
|
|
35
35
|
companyName: string;
|
|
36
36
|
legalRepresentative: string;
|
|
@@ -51,5 +51,5 @@ interface BusinessUserDoc extends mongoose.Document {
|
|
|
51
51
|
brokerId?: string;
|
|
52
52
|
platformFeeRanges?: PlatformFeeRange[];
|
|
53
53
|
}
|
|
54
|
-
declare const
|
|
55
|
-
export {
|
|
54
|
+
declare const buildBusinessUser: (mongoose: Mongoose) => BusinessUserModel;
|
|
55
|
+
export { buildBusinessUser, BusinessUserDoc };
|