streamby-core 0.8.1 → 0.8.2
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/adapters/s3.js +9 -2
- package/package.json +3 -1
package/dist/adapters/s3.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createS3Adapter = createS3Adapter;
|
|
4
7
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
5
8
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
9
|
+
const bcrypt_1 = __importDefault(require("bcrypt"));
|
|
6
10
|
function createS3Adapter(config) {
|
|
7
11
|
const s3 = new client_s3_1.S3Client({
|
|
8
12
|
region: config.region,
|
|
@@ -13,14 +17,17 @@ function createS3Adapter(config) {
|
|
|
13
17
|
});
|
|
14
18
|
return {
|
|
15
19
|
async getPresignedUrl(filename, contentType, projectId) {
|
|
16
|
-
const
|
|
20
|
+
const salt = await bcrypt_1.default.genSalt();
|
|
21
|
+
const hashedPassword = await bcrypt_1.default.hash(filename, salt);
|
|
22
|
+
const key = `${projectId}/file-${Date.now()}-${hashedPassword}`;
|
|
17
23
|
const command = new client_s3_1.PutObjectCommand({
|
|
18
24
|
Bucket: config.bucket,
|
|
19
25
|
Key: key,
|
|
20
26
|
ContentType: contentType,
|
|
21
27
|
});
|
|
22
28
|
const url = await (0, s3_request_presigner_1.getSignedUrl)(s3, command, { expiresIn: 60 });
|
|
23
|
-
|
|
29
|
+
const publicUrl = `https://${config.bucket}.s3.${config.region}.amazonaws.com/${key}`;
|
|
30
|
+
return { url, publicUrl };
|
|
24
31
|
},
|
|
25
32
|
async listFiles(projectId) {
|
|
26
33
|
const command = new client_s3_1.ListObjectsV2Command({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "streamby-core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "StreamBy middleware framework for media storage management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@aws-sdk/client-s3": "^3.528.0",
|
|
33
33
|
"@aws-sdk/s3-request-presigner": "^3.787.0",
|
|
34
|
+
"bcrypt": "^5.1.1",
|
|
34
35
|
"express": "^4.0.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
38
|
+
"@types/bcrypt": "^5.0.2",
|
|
37
39
|
"@types/express": "^4.17.17",
|
|
38
40
|
"@types/supertest": "^6.0.3",
|
|
39
41
|
"supertest": "^7.1.0",
|