@signskart/uploader 2.0.9 → 2.0.11
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/package.json +1 -1
- package/dist/server/index.d.mts +0 -20
- package/dist/server/index.d.ts +0 -20
- package/dist/server/index.js +0 -43
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs +0 -41
- package/dist/server/index.mjs.map +0 -1
package/package.json
CHANGED
package/dist/server/index.d.mts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface PresignConfig {
|
|
2
|
-
region: string;
|
|
3
|
-
accessKeyId: string;
|
|
4
|
-
secretAccessKey: string;
|
|
5
|
-
bucket: string;
|
|
6
|
-
publicUrl: string;
|
|
7
|
-
expiresIn?: number;
|
|
8
|
-
}
|
|
9
|
-
interface PresignRequest {
|
|
10
|
-
fileName: string;
|
|
11
|
-
contentType: string;
|
|
12
|
-
folder?: string;
|
|
13
|
-
}
|
|
14
|
-
declare function createS3PresignHandler(config: PresignConfig): ({ fileName, contentType, folder, }: PresignRequest) => Promise<{
|
|
15
|
-
signedUrl: string;
|
|
16
|
-
key: string;
|
|
17
|
-
publicUrl: string;
|
|
18
|
-
}>;
|
|
19
|
-
|
|
20
|
-
export { type PresignConfig, type PresignRequest, createS3PresignHandler };
|
package/dist/server/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
interface PresignConfig {
|
|
2
|
-
region: string;
|
|
3
|
-
accessKeyId: string;
|
|
4
|
-
secretAccessKey: string;
|
|
5
|
-
bucket: string;
|
|
6
|
-
publicUrl: string;
|
|
7
|
-
expiresIn?: number;
|
|
8
|
-
}
|
|
9
|
-
interface PresignRequest {
|
|
10
|
-
fileName: string;
|
|
11
|
-
contentType: string;
|
|
12
|
-
folder?: string;
|
|
13
|
-
}
|
|
14
|
-
declare function createS3PresignHandler(config: PresignConfig): ({ fileName, contentType, folder, }: PresignRequest) => Promise<{
|
|
15
|
-
signedUrl: string;
|
|
16
|
-
key: string;
|
|
17
|
-
publicUrl: string;
|
|
18
|
-
}>;
|
|
19
|
-
|
|
20
|
-
export { type PresignConfig, type PresignRequest, createS3PresignHandler };
|
package/dist/server/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var clientS3 = require('@aws-sdk/client-s3');
|
|
4
|
-
var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
|
|
5
|
-
|
|
6
|
-
// src/server/createS3PresignHandler.ts
|
|
7
|
-
function createS3PresignHandler(config) {
|
|
8
|
-
const s3 = new clientS3.S3Client({
|
|
9
|
-
region: config.region,
|
|
10
|
-
credentials: {
|
|
11
|
-
accessKeyId: config.accessKeyId,
|
|
12
|
-
secretAccessKey: config.secretAccessKey
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return async function generatePresignedUpload({
|
|
16
|
-
fileName,
|
|
17
|
-
contentType,
|
|
18
|
-
folder
|
|
19
|
-
}) {
|
|
20
|
-
if (!fileName || !contentType) {
|
|
21
|
-
throw new Error("fileName and contentType are required");
|
|
22
|
-
}
|
|
23
|
-
const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
24
|
-
const key = `${folder || "uploads"}/${Date.now()}-${safeFileName}`;
|
|
25
|
-
const command = new clientS3.PutObjectCommand({
|
|
26
|
-
Bucket: config.bucket,
|
|
27
|
-
Key: key,
|
|
28
|
-
ContentType: contentType
|
|
29
|
-
});
|
|
30
|
-
const signedUrl = await s3RequestPresigner.getSignedUrl(s3, command, {
|
|
31
|
-
expiresIn: config.expiresIn ?? 300
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
signedUrl,
|
|
35
|
-
key,
|
|
36
|
-
publicUrl: `${config.publicUrl}/${key}`
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
exports.createS3PresignHandler = createS3PresignHandler;
|
|
42
|
-
//# sourceMappingURL=index.js.map
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
package/dist/server/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/createS3PresignHandler.ts"],"names":["S3Client","PutObjectCommand","getSignedUrl"],"mappings":";;;;;;AAkBO,SAAS,uBAAuB,MAAA,EAAuB;AAC1D,EAAA,MAAM,EAAA,GAAK,IAAIA,iBAAA,CAAS;AAAA,IACpB,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,WAAA,EAAa;AAAA,MACT,aAAa,MAAA,CAAO,WAAA;AAAA,MACpB,iBAAiB,MAAA,CAAO;AAAA;AAC5B,GACH,CAAA;AAED,EAAA,OAAO,eAAe,uBAAA,CAAwB;AAAA,IAC1C,QAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACJ,EAAmB;AACf,IAAA,IAAI,CAAC,QAAA,IAAY,CAAC,WAAA,EAAa;AAC3B,MAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,IAC3D;AAEA,IAAA,MAAM,YAAA,GAAe,QAAA,CAAS,OAAA,CAAQ,kBAAA,EAAoB,GAAG,CAAA;AAC7D,IAAA,MAAM,GAAA,GAAM,GAAG,MAAA,IAAU,SAAS,IAAI,IAAA,CAAK,GAAA,EAAK,CAAA,CAAA,EAAI,YAAY,CAAA,CAAA;AAEhE,IAAA,MAAM,OAAA,GAAU,IAAIC,yBAAA,CAAiB;AAAA,MACjC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,GAAA,EAAK,GAAA;AAAA,MACL,WAAA,EAAa;AAAA,KAChB,CAAA;AAED,IAAA,MAAM,SAAA,GAAY,MAAMC,+BAAA,CAAa,EAAA,EAAI,OAAA,EAAS;AAAA,MAC9C,SAAA,EAAW,OAAO,SAAA,IAAa;AAAA,KAClC,CAAA;AAED,IAAA,OAAO;AAAA,MACH,SAAA;AAAA,MACA,GAAA;AAAA,MACA,SAAA,EAAW,CAAA,EAAG,MAAA,CAAO,SAAS,IAAI,GAAG,CAAA;AAAA,KACzC;AAAA,EACJ,CAAA;AACJ","file":"index.js","sourcesContent":["import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\n\nexport interface PresignConfig {\n region: string;\n accessKeyId: string;\n secretAccessKey: string;\n bucket: string;\n publicUrl: string;\n expiresIn?: number;\n}\n\nexport interface PresignRequest {\n fileName: string;\n contentType: string;\n folder?: string;\n}\n\nexport function createS3PresignHandler(config: PresignConfig) {\n const s3 = new S3Client({\n region: config.region,\n credentials: {\n accessKeyId: config.accessKeyId,\n secretAccessKey: config.secretAccessKey,\n },\n });\n\n return async function generatePresignedUpload({\n fileName,\n contentType,\n folder,\n }: PresignRequest) {\n if (!fileName || !contentType) {\n throw new Error('fileName and contentType are required');\n }\n\n const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n const key = `${folder || 'uploads'}/${Date.now()}-${safeFileName}`;\n\n const command = new PutObjectCommand({\n Bucket: config.bucket,\n Key: key,\n ContentType: contentType,\n });\n\n const signedUrl = await getSignedUrl(s3, command, {\n expiresIn: config.expiresIn ?? 300,\n });\n\n return {\n signedUrl,\n key,\n publicUrl: `${config.publicUrl}/${key}`,\n };\n };\n}"]}
|
package/dist/server/index.mjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
|
|
2
|
-
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
3
|
-
|
|
4
|
-
// src/server/createS3PresignHandler.ts
|
|
5
|
-
function createS3PresignHandler(config) {
|
|
6
|
-
const s3 = new S3Client({
|
|
7
|
-
region: config.region,
|
|
8
|
-
credentials: {
|
|
9
|
-
accessKeyId: config.accessKeyId,
|
|
10
|
-
secretAccessKey: config.secretAccessKey
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
return async function generatePresignedUpload({
|
|
14
|
-
fileName,
|
|
15
|
-
contentType,
|
|
16
|
-
folder
|
|
17
|
-
}) {
|
|
18
|
-
if (!fileName || !contentType) {
|
|
19
|
-
throw new Error("fileName and contentType are required");
|
|
20
|
-
}
|
|
21
|
-
const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
22
|
-
const key = `${folder || "uploads"}/${Date.now()}-${safeFileName}`;
|
|
23
|
-
const command = new PutObjectCommand({
|
|
24
|
-
Bucket: config.bucket,
|
|
25
|
-
Key: key,
|
|
26
|
-
ContentType: contentType
|
|
27
|
-
});
|
|
28
|
-
const signedUrl = await getSignedUrl(s3, command, {
|
|
29
|
-
expiresIn: config.expiresIn ?? 300
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
signedUrl,
|
|
33
|
-
key,
|
|
34
|
-
publicUrl: `${config.publicUrl}/${key}`
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export { createS3PresignHandler };
|
|
40
|
-
//# sourceMappingURL=index.mjs.map
|
|
41
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/createS3PresignHandler.ts"],"names":[],"mappings":";;;;AAkBO,SAAS,uBAAuB,MAAA,EAAuB;AAC1D,EAAA,MAAM,EAAA,GAAK,IAAI,QAAA,CAAS;AAAA,IACpB,QAAQ,MAAA,CAAO,MAAA;AAAA,IACf,WAAA,EAAa;AAAA,MACT,aAAa,MAAA,CAAO,WAAA;AAAA,MACpB,iBAAiB,MAAA,CAAO;AAAA;AAC5B,GACH,CAAA;AAED,EAAA,OAAO,eAAe,uBAAA,CAAwB;AAAA,IAC1C,QAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACJ,EAAmB;AACf,IAAA,IAAI,CAAC,QAAA,IAAY,CAAC,WAAA,EAAa;AAC3B,MAAA,MAAM,IAAI,MAAM,uCAAuC,CAAA;AAAA,IAC3D;AAEA,IAAA,MAAM,YAAA,GAAe,QAAA,CAAS,OAAA,CAAQ,kBAAA,EAAoB,GAAG,CAAA;AAC7D,IAAA,MAAM,GAAA,GAAM,GAAG,MAAA,IAAU,SAAS,IAAI,IAAA,CAAK,GAAA,EAAK,CAAA,CAAA,EAAI,YAAY,CAAA,CAAA;AAEhE,IAAA,MAAM,OAAA,GAAU,IAAI,gBAAA,CAAiB;AAAA,MACjC,QAAQ,MAAA,CAAO,MAAA;AAAA,MACf,GAAA,EAAK,GAAA;AAAA,MACL,WAAA,EAAa;AAAA,KAChB,CAAA;AAED,IAAA,MAAM,SAAA,GAAY,MAAM,YAAA,CAAa,EAAA,EAAI,OAAA,EAAS;AAAA,MAC9C,SAAA,EAAW,OAAO,SAAA,IAAa;AAAA,KAClC,CAAA;AAED,IAAA,OAAO;AAAA,MACH,SAAA;AAAA,MACA,GAAA;AAAA,MACA,SAAA,EAAW,CAAA,EAAG,MAAA,CAAO,SAAS,IAAI,GAAG,CAAA;AAAA,KACzC;AAAA,EACJ,CAAA;AACJ","file":"index.mjs","sourcesContent":["import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';\nimport { getSignedUrl } from '@aws-sdk/s3-request-presigner';\n\nexport interface PresignConfig {\n region: string;\n accessKeyId: string;\n secretAccessKey: string;\n bucket: string;\n publicUrl: string;\n expiresIn?: number;\n}\n\nexport interface PresignRequest {\n fileName: string;\n contentType: string;\n folder?: string;\n}\n\nexport function createS3PresignHandler(config: PresignConfig) {\n const s3 = new S3Client({\n region: config.region,\n credentials: {\n accessKeyId: config.accessKeyId,\n secretAccessKey: config.secretAccessKey,\n },\n });\n\n return async function generatePresignedUpload({\n fileName,\n contentType,\n folder,\n }: PresignRequest) {\n if (!fileName || !contentType) {\n throw new Error('fileName and contentType are required');\n }\n\n const safeFileName = fileName.replace(/[^a-zA-Z0-9._-]/g, \"_\");\n const key = `${folder || 'uploads'}/${Date.now()}-${safeFileName}`;\n\n const command = new PutObjectCommand({\n Bucket: config.bucket,\n Key: key,\n ContentType: contentType,\n });\n\n const signedUrl = await getSignedUrl(s3, command, {\n expiresIn: config.expiresIn ?? 300,\n });\n\n return {\n signedUrl,\n key,\n publicUrl: `${config.publicUrl}/${key}`,\n };\n };\n}"]}
|