@riocrypto/common 1.0.426 → 1.0.428
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/get-order.js +16 -25
- package/build/services/s3.d.ts +5 -0
- package/build/services/s3.js +21 -0
- package/package.json +2 -1
package/build/index.d.ts
CHANGED
|
@@ -146,6 +146,7 @@ export * from "./classes/USStateAsset";
|
|
|
146
146
|
export * from "./classes/WyrePaymentMethodAsset";
|
|
147
147
|
export * from "./services/apiKey";
|
|
148
148
|
export * from "./services/password";
|
|
149
|
+
export * from "./services/s3";
|
|
149
150
|
export * from "./models/admin-auth";
|
|
150
151
|
export * from "./models/auth";
|
|
151
152
|
export * from "./models/business-user";
|
package/build/index.js
CHANGED
|
@@ -163,6 +163,7 @@ __exportStar(require("./classes/USStateAsset"), exports);
|
|
|
163
163
|
__exportStar(require("./classes/WyrePaymentMethodAsset"), exports);
|
|
164
164
|
__exportStar(require("./services/apiKey"), exports);
|
|
165
165
|
__exportStar(require("./services/password"), exports);
|
|
166
|
+
__exportStar(require("./services/s3"), exports);
|
|
166
167
|
__exportStar(require("./models/admin-auth"), exports);
|
|
167
168
|
__exportStar(require("./models/auth"), exports);
|
|
168
169
|
__exportStar(require("./models/business-user"), exports);
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getOrder = void 0;
|
|
13
13
|
const not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
14
|
-
const not_found_error_1 = require("../errors/not-found-error");
|
|
15
14
|
const wrong_processor_error_1 = require("../errors/wrong-processor-error");
|
|
16
15
|
const order_1 = require("../models/order");
|
|
17
16
|
const processor_1 = require("../types/processor");
|
|
@@ -28,34 +27,26 @@ const getOrder = (req, res, next, mongoose, onlyBankOrders) => __awaiter(void 0,
|
|
|
28
27
|
orderId = req.query.orderId;
|
|
29
28
|
}
|
|
30
29
|
if (orderId) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
].includes(order.processor)) {
|
|
45
|
-
req.order = order;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
throw new wrong_processor_error_1.WrongProcessorError();
|
|
49
|
-
}
|
|
30
|
+
const Order = yield (0, order_1.buildOrder)(mongoose);
|
|
31
|
+
const order = yield Order.findById(orderId);
|
|
32
|
+
if (!order) {
|
|
33
|
+
throw new Error();
|
|
34
|
+
}
|
|
35
|
+
if (onlyBankOrders) {
|
|
36
|
+
if ([
|
|
37
|
+
processor_1.Processor.Interbank,
|
|
38
|
+
processor_1.Processor.SPEI,
|
|
39
|
+
processor_1.Processor.SWIFT,
|
|
40
|
+
processor_1.Processor.SPID,
|
|
41
|
+
].includes(order.processor)) {
|
|
42
|
+
req.order = order;
|
|
50
43
|
}
|
|
51
44
|
else {
|
|
52
|
-
|
|
45
|
+
throw new wrong_processor_error_1.WrongProcessorError();
|
|
53
46
|
}
|
|
54
47
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
console.log("kakakaka");
|
|
58
|
-
throw new not_found_error_1.NotFoundError();
|
|
48
|
+
else {
|
|
49
|
+
req.order = order;
|
|
59
50
|
}
|
|
60
51
|
if (req.order.userId !== ((_a = req.user) === null || _a === void 0 ? void 0 : _a.toJSON().id) && !req.currentAdminAuth) {
|
|
61
52
|
throw new not_authorized_error_1.NotAuthorizedError();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.s3 = void 0;
|
|
4
|
+
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
5
|
+
class s3 {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._client = new client_s3_1.S3Client({
|
|
8
|
+
endpoint: process.env.S3_ENDPOINT,
|
|
9
|
+
forcePathStyle: false,
|
|
10
|
+
region: process.env.S3_REGION,
|
|
11
|
+
credentials: {
|
|
12
|
+
accessKeyId: process.env.S3_ACCESS_KEY,
|
|
13
|
+
secretAccessKey: process.env.S3_SECRET_KEY, // Secret access key defined through an environment variable.
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
get client() {
|
|
18
|
+
return this._client;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.s3 = s3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.428",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"typescript": "^4.7.4"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"@aws-sdk/client-s3": "^3.297.0",
|
|
23
24
|
"@types/express": "^4.17.13",
|
|
24
25
|
"axios": "^0.27.2",
|
|
25
26
|
"express": "^4.18.1",
|