@riocrypto/common-server 1.0.2720 → 1.0.2722
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 +1 -0
- package/build/index.js +1 -0
- package/build/middlewares/authorize.d.ts +4 -0
- package/build/middlewares/authorize.js +28 -1
- package/build/models/bulk-crypto-payment.js +1 -0
- package/build/models/indicative-quote-page-verification.d.ts +23 -0
- package/build/models/indicative-quote-page-verification.js +50 -0
- package/build/models/indicative-quote-page.d.ts +2 -4
- package/build/models/indicative-quote-page.js +1 -4
- package/build/models/order.js +1 -0
- package/package.json +2 -2
package/build/index.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ export * from "./models/compliance-bot-rule";
|
|
|
118
118
|
export * from "./models/compliance-bot-rule-result";
|
|
119
119
|
export * from "./models/static-bank-payment-reference";
|
|
120
120
|
export * from "./models/indicative-quote-page";
|
|
121
|
+
export * from "./models/indicative-quote-page-verification";
|
|
121
122
|
export * from "./clients/axios-with-logging";
|
|
122
123
|
export * from "./clients/slack-client";
|
|
123
124
|
export * from "./clients/fireblocks-client";
|
package/build/index.js
CHANGED
|
@@ -134,6 +134,7 @@ __exportStar(require("./models/compliance-bot-rule"), exports);
|
|
|
134
134
|
__exportStar(require("./models/compliance-bot-rule-result"), exports);
|
|
135
135
|
__exportStar(require("./models/static-bank-payment-reference"), exports);
|
|
136
136
|
__exportStar(require("./models/indicative-quote-page"), exports);
|
|
137
|
+
__exportStar(require("./models/indicative-quote-page-verification"), exports);
|
|
137
138
|
__exportStar(require("./clients/axios-with-logging"), exports);
|
|
138
139
|
__exportStar(require("./clients/slack-client"), exports);
|
|
139
140
|
__exportStar(require("./clients/fireblocks-client"), exports);
|
|
@@ -200,6 +200,31 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
200
200
|
}))());
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
+
// Check for indicative quote auth token - only if needed
|
|
204
|
+
if (authorizationTypes.includes(common_1.AuthorizationType.IndicativeQuoteAuth)) {
|
|
205
|
+
const authHeader = req.header("Authorization");
|
|
206
|
+
const token = (authHeader === null || authHeader === void 0 ? void 0 : authHeader.startsWith("Bearer "))
|
|
207
|
+
? authHeader.slice(7)
|
|
208
|
+
: null;
|
|
209
|
+
if (token) {
|
|
210
|
+
promises.push((() => __awaiter(void 0, void 0, void 0, function* () {
|
|
211
|
+
try {
|
|
212
|
+
const INDICATIVE_PAGE_TOKEN_SECRET = yield secret_manager_client_1.secretManagerClient.getSecretValue("INDICATIVE_PAGE_TOKEN_SECRET");
|
|
213
|
+
if (!INDICATIVE_PAGE_TOKEN_SECRET) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const payload = jsonwebtoken_1.default.verify(token, INDICATIVE_PAGE_TOKEN_SECRET);
|
|
217
|
+
if (payload.email && payload.pageId) {
|
|
218
|
+
req.indicativeQuoteAuth = {
|
|
219
|
+
email: payload.email,
|
|
220
|
+
pageId: payload.pageId,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
catch (err) { }
|
|
225
|
+
}))());
|
|
226
|
+
}
|
|
227
|
+
}
|
|
203
228
|
// Wait for all promises to complete
|
|
204
229
|
yield Promise.all(promises);
|
|
205
230
|
// Check authorization results and proceed if authorized
|
|
@@ -216,7 +241,9 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
|
|
|
216
241
|
req.adminAuth) ||
|
|
217
242
|
((authorizationTypes.includes(common_1.AuthorizationType.User) ||
|
|
218
243
|
authorizationTypes.includes(common_1.AuthorizationType.UserNoKYC)) &&
|
|
219
|
-
req.user)
|
|
244
|
+
req.user) ||
|
|
245
|
+
(authorizationTypes.includes(common_1.AuthorizationType.IndicativeQuoteAuth) &&
|
|
246
|
+
req.indicativeQuoteAuth)) {
|
|
220
247
|
next();
|
|
221
248
|
return;
|
|
222
249
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Mongoose, Model, Document } from "mongoose";
|
|
2
|
+
interface IndicativeQuotePageVerificationAttrs {
|
|
3
|
+
pageId: string;
|
|
4
|
+
email: string;
|
|
5
|
+
verificationCode: string;
|
|
6
|
+
expiresAt: Date;
|
|
7
|
+
attempts: number;
|
|
8
|
+
createdAt: Date;
|
|
9
|
+
}
|
|
10
|
+
interface IndicativeQuotePageVerificationModel extends Model<IndicativeQuotePageVerificationDoc> {
|
|
11
|
+
build(attrs: IndicativeQuotePageVerificationAttrs): IndicativeQuotePageVerificationDoc;
|
|
12
|
+
}
|
|
13
|
+
interface IndicativeQuotePageVerificationDoc extends Document {
|
|
14
|
+
_id: string;
|
|
15
|
+
pageId: string;
|
|
16
|
+
email: string;
|
|
17
|
+
verificationCode: string;
|
|
18
|
+
expiresAt: Date;
|
|
19
|
+
attempts: number;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
}
|
|
22
|
+
declare const buildIndicativeQuotePageVerification: (mongoose: Mongoose) => IndicativeQuotePageVerificationModel;
|
|
23
|
+
export { buildIndicativeQuotePageVerification, IndicativeQuotePageVerificationDoc, IndicativeQuotePageVerificationAttrs, };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildIndicativeQuotePageVerification = void 0;
|
|
4
|
+
const buildIndicativeQuotePageVerification = (mongoose) => {
|
|
5
|
+
if (mongoose.models.IndicativeQuotePageVerification) {
|
|
6
|
+
return mongoose.model("IndicativeQuotePageVerification");
|
|
7
|
+
}
|
|
8
|
+
const IndicativeQuotePageVerificationSchema = new mongoose.Schema({
|
|
9
|
+
pageId: {
|
|
10
|
+
type: String,
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
email: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: true,
|
|
16
|
+
},
|
|
17
|
+
verificationCode: {
|
|
18
|
+
type: String,
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
expiresAt: {
|
|
22
|
+
type: Date,
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
attempts: {
|
|
26
|
+
type: Number,
|
|
27
|
+
default: 0,
|
|
28
|
+
},
|
|
29
|
+
createdAt: {
|
|
30
|
+
type: Date,
|
|
31
|
+
required: true,
|
|
32
|
+
},
|
|
33
|
+
}, {
|
|
34
|
+
toJSON: {
|
|
35
|
+
transform(doc, ret) {
|
|
36
|
+
ret.id = ret._id.valueOf();
|
|
37
|
+
delete ret._id;
|
|
38
|
+
delete ret.__v;
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
IndicativeQuotePageVerificationSchema.index({ pageId: 1, email: 1 }, { unique: true });
|
|
43
|
+
IndicativeQuotePageVerificationSchema.index({ expiresAt: 1 }, { expireAfterSeconds: 0 });
|
|
44
|
+
IndicativeQuotePageVerificationSchema.statics.build = (attrs) => {
|
|
45
|
+
return new IndicativeQuotePageVerification(attrs);
|
|
46
|
+
};
|
|
47
|
+
const IndicativeQuotePageVerification = mongoose.model("IndicativeQuotePageVerification", IndicativeQuotePageVerificationSchema);
|
|
48
|
+
return IndicativeQuotePageVerification;
|
|
49
|
+
};
|
|
50
|
+
exports.buildIndicativeQuotePageVerification = buildIndicativeQuotePageVerification;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { IndicativeQuotePageQuoteConfig } from "@riocrypto/common";
|
|
2
2
|
import { Mongoose, Model, Document } from "mongoose";
|
|
3
3
|
interface IndicativeQuotePageAttrs {
|
|
4
|
-
userId?: string;
|
|
5
4
|
quotes: IndicativeQuotePageQuoteConfig[];
|
|
6
|
-
|
|
5
|
+
allowedEmails: string[];
|
|
7
6
|
createdBy: string;
|
|
8
7
|
createdAt: Date;
|
|
9
8
|
updatedAt: Date;
|
|
@@ -13,9 +12,8 @@ interface IndicativeQuotePageModel extends Model<IndicativeQuotePageDoc> {
|
|
|
13
12
|
}
|
|
14
13
|
interface IndicativeQuotePageDoc extends Document {
|
|
15
14
|
_id: string;
|
|
16
|
-
userId?: string;
|
|
17
15
|
quotes: IndicativeQuotePageQuoteConfig[];
|
|
18
|
-
|
|
16
|
+
allowedEmails: string[];
|
|
19
17
|
createdBy: string;
|
|
20
18
|
createdAt: Date;
|
|
21
19
|
updatedAt: Date;
|
|
@@ -54,14 +54,11 @@ const buildIndicativeQuotePage = (mongoose) => {
|
|
|
54
54
|
},
|
|
55
55
|
}, { _id: false });
|
|
56
56
|
const IndicativeQuotePageSchema = new mongoose.Schema({
|
|
57
|
-
userId: {
|
|
58
|
-
type: String,
|
|
59
|
-
},
|
|
60
57
|
quotes: {
|
|
61
58
|
type: [QuoteConfigSchema],
|
|
62
59
|
required: true,
|
|
63
60
|
},
|
|
64
|
-
|
|
61
|
+
allowedEmails: {
|
|
65
62
|
type: [String],
|
|
66
63
|
required: true,
|
|
67
64
|
},
|
package/build/models/order.js
CHANGED
|
@@ -376,6 +376,7 @@ const buildOrder = (mongoose) => {
|
|
|
376
376
|
orderSchema.index({ userId: 1, "TWAP.sessionId": 1, createdAt: 1 });
|
|
377
377
|
orderSchema.index({ brokerId: 1, "TWAP.sessionId": 1, createdAt: 1 });
|
|
378
378
|
orderSchema.index({ clientReferenceId: 1 }, { sparse: true });
|
|
379
|
+
orderSchema.index({ "paymentsReceived.blockchainTxId": 1 }, { sparse: true });
|
|
379
380
|
orderSchema.statics.build = (attrs) => {
|
|
380
381
|
return new Order(attrs);
|
|
381
382
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2722",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@google-cloud/secret-manager": "^5.3.0",
|
|
29
29
|
"@google-cloud/storage": "^6.9.5",
|
|
30
30
|
"@hyperdx/node-opentelemetry": "^0.7.0",
|
|
31
|
-
"@riocrypto/common": "^1.0.
|
|
31
|
+
"@riocrypto/common": "^1.0.2517",
|
|
32
32
|
"@types/express": "^4.17.13",
|
|
33
33
|
"axios": "^1.7.4",
|
|
34
34
|
"crypto-js": "^4.2.0",
|