@strapi/provider-upload-aws-s3 0.0.0-next.fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a → 0.0.0-next.fb92031f3d90f3d2a2d191ba65725b6c8e329a5d
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/LICENSE +18 -3
- package/README.md +60 -9
- package/dist/index.d.ts +27 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -4321
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +105 -4321
- package/dist/index.mjs.map +1 -1
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +97 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +94 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +14 -12
package/dist/utils.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
+
import type { AwsCredentialIdentity } from '@aws-sdk/types';
|
|
2
|
+
import type { InitOptions } from '.';
|
|
1
3
|
export declare function isUrlFromBucket(fileUrl: string, bucketName: string, baseUrl?: string): boolean;
|
|
4
|
+
export declare const extractCredentials: (options: InitOptions) => AwsCredentialIdentity | null;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,CAAC;AASrC,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG,OAAO,CAoB1F;AA4DD,eAAO,MAAM,kBAAkB,YAAa,WAAW,KAAG,qBAAqB,GAAG,IAQjF,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ENDPOINT_PATTERN = /^(.+\.)?s3[.-]([a-z0-9-]+)\./;
|
|
4
|
+
function isUrlFromBucket(fileUrl, bucketName, baseUrl = '') {
|
|
5
|
+
const url = new URL(fileUrl);
|
|
6
|
+
// Check if the file URL is using a base URL (e.g. a CDN).
|
|
7
|
+
// In this case do not sign the URL.
|
|
8
|
+
if (baseUrl) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const { bucket } = getBucketFromAwsUrl(fileUrl);
|
|
12
|
+
if (bucket) {
|
|
13
|
+
return bucket === bucketName;
|
|
14
|
+
}
|
|
15
|
+
// File URL might be of an S3-compatible provider. (or an invalid URL)
|
|
16
|
+
// In this case, check if the bucket name appears in the URL host or path.
|
|
17
|
+
// e.g. https://minio.example.com/bucket-name/object-key
|
|
18
|
+
// e.g. https://bucket.nyc3.digitaloceanspaces.com/folder/img.png
|
|
19
|
+
return url.host.startsWith(`${bucketName}.`) || url.pathname.includes(`/${bucketName}/`);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parse the bucket name from a URL.
|
|
23
|
+
* See all URL formats in https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html
|
|
24
|
+
*
|
|
25
|
+
* @param {string} fileUrl - the URL to parse
|
|
26
|
+
* @returns {object} result
|
|
27
|
+
* @returns {string} result.bucket - the bucket name
|
|
28
|
+
* @returns {string} result.err - if any
|
|
29
|
+
*/ function getBucketFromAwsUrl(fileUrl) {
|
|
30
|
+
const url = new URL(fileUrl);
|
|
31
|
+
// S3://<bucket-name>/<key>
|
|
32
|
+
if (url.protocol === 's3:') {
|
|
33
|
+
const bucket = url.host;
|
|
34
|
+
if (!bucket) {
|
|
35
|
+
return {
|
|
36
|
+
err: `Invalid S3 url: no bucket: ${url}`
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
bucket
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (!url.host) {
|
|
44
|
+
return {
|
|
45
|
+
err: `Invalid S3 url: no hostname: ${url}`
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const matches = url.host.match(ENDPOINT_PATTERN);
|
|
49
|
+
if (!matches) {
|
|
50
|
+
return {
|
|
51
|
+
err: `Invalid S3 url: hostname does not appear to be a valid S3 endpoint: ${url}`
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const prefix = matches[1];
|
|
55
|
+
// https://s3.amazonaws.com/<bucket-name>
|
|
56
|
+
if (!prefix) {
|
|
57
|
+
if (url.pathname === '/') {
|
|
58
|
+
return {
|
|
59
|
+
bucket: null
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const index = url.pathname.indexOf('/', 1);
|
|
63
|
+
// https://s3.amazonaws.com/<bucket-name>
|
|
64
|
+
if (index === -1) {
|
|
65
|
+
return {
|
|
66
|
+
bucket: url.pathname.substring(1)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// https://s3.amazonaws.com/<bucket-name>/
|
|
70
|
+
if (index === url.pathname.length - 1) {
|
|
71
|
+
return {
|
|
72
|
+
bucket: url.pathname.substring(1, index)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// https://s3.amazonaws.com/<bucket-name>/key
|
|
76
|
+
return {
|
|
77
|
+
bucket: url.pathname.substring(1, index)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// https://<bucket-name>.s3.amazonaws.com/
|
|
81
|
+
return {
|
|
82
|
+
bucket: prefix.substring(0, prefix.length - 1)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const extractCredentials = (options)=>{
|
|
86
|
+
if (options.s3Options?.credentials) {
|
|
87
|
+
return {
|
|
88
|
+
accessKeyId: options.s3Options.credentials.accessKeyId,
|
|
89
|
+
secretAccessKey: options.s3Options.credentials.secretAccessKey
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
return null;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
exports.extractCredentials = extractCredentials;
|
|
96
|
+
exports.isUrlFromBucket = isUrlFromBucket;
|
|
97
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import type { AwsCredentialIdentity } from '@aws-sdk/types';\nimport type { InitOptions } from '.';\n\nconst ENDPOINT_PATTERN = /^(.+\\.)?s3[.-]([a-z0-9-]+)\\./;\n\ninterface BucketInfo {\n bucket?: string | null;\n err?: string;\n}\n\nexport function isUrlFromBucket(fileUrl: string, bucketName: string, baseUrl = ''): boolean {\n const url = new URL(fileUrl);\n\n // Check if the file URL is using a base URL (e.g. a CDN).\n // In this case do not sign the URL.\n if (baseUrl) {\n return false;\n }\n\n const { bucket } = getBucketFromAwsUrl(fileUrl);\n\n if (bucket) {\n return bucket === bucketName;\n }\n\n // File URL might be of an S3-compatible provider. (or an invalid URL)\n // In this case, check if the bucket name appears in the URL host or path.\n // e.g. https://minio.example.com/bucket-name/object-key\n // e.g. https://bucket.nyc3.digitaloceanspaces.com/folder/img.png\n return url.host.startsWith(`${bucketName}.`) || url.pathname.includes(`/${bucketName}/`);\n}\n\n/**\n * Parse the bucket name from a URL.\n * See all URL formats in https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html\n *\n * @param {string} fileUrl - the URL to parse\n * @returns {object} result\n * @returns {string} result.bucket - the bucket name\n * @returns {string} result.err - if any\n */\nfunction getBucketFromAwsUrl(fileUrl: string): BucketInfo {\n const url = new URL(fileUrl);\n\n // S3://<bucket-name>/<key>\n if (url.protocol === 's3:') {\n const bucket = url.host;\n\n if (!bucket) {\n return { err: `Invalid S3 url: no bucket: ${url}` };\n }\n return { bucket };\n }\n\n if (!url.host) {\n return { err: `Invalid S3 url: no hostname: ${url}` };\n }\n\n const matches = url.host.match(ENDPOINT_PATTERN);\n if (!matches) {\n return { err: `Invalid S3 url: hostname does not appear to be a valid S3 endpoint: ${url}` };\n }\n\n const prefix = matches[1];\n // https://s3.amazonaws.com/<bucket-name>\n if (!prefix) {\n if (url.pathname === '/') {\n return { bucket: null };\n }\n\n const index = url.pathname.indexOf('/', 1);\n\n // https://s3.amazonaws.com/<bucket-name>\n if (index === -1) {\n return { bucket: url.pathname.substring(1) };\n }\n\n // https://s3.amazonaws.com/<bucket-name>/\n if (index === url.pathname.length - 1) {\n return { bucket: url.pathname.substring(1, index) };\n }\n\n // https://s3.amazonaws.com/<bucket-name>/key\n return { bucket: url.pathname.substring(1, index) };\n }\n\n // https://<bucket-name>.s3.amazonaws.com/\n return { bucket: prefix.substring(0, prefix.length - 1) };\n}\n\nexport const extractCredentials = (options: InitOptions): AwsCredentialIdentity | null => {\n if (options.s3Options?.credentials) {\n return {\n accessKeyId: options.s3Options.credentials.accessKeyId,\n secretAccessKey: options.s3Options.credentials.secretAccessKey,\n };\n }\n return null;\n};\n"],"names":["ENDPOINT_PATTERN","isUrlFromBucket","fileUrl","bucketName","baseUrl","url","URL","bucket","getBucketFromAwsUrl","host","startsWith","pathname","includes","protocol","err","matches","match","prefix","index","indexOf","substring","length","extractCredentials","options","s3Options","credentials","accessKeyId","secretAccessKey"],"mappings":";;AAGA,MAAMA,gBAAmB,GAAA,8BAAA;AAOlB,SAASC,eAAgBC,CAAAA,OAAe,EAAEC,UAAkB,EAAEC,UAAU,EAAE,EAAA;IAC/E,MAAMC,GAAAA,GAAM,IAAIC,GAAIJ,CAAAA,OAAAA,CAAAA;;;AAIpB,IAAA,IAAIE,OAAS,EAAA;QACX,OAAO,KAAA;AACT;AAEA,IAAA,MAAM,EAAEG,MAAM,EAAE,GAAGC,mBAAoBN,CAAAA,OAAAA,CAAAA;AAEvC,IAAA,IAAIK,MAAQ,EAAA;AACV,QAAA,OAAOA,MAAWJ,KAAAA,UAAAA;AACpB;;;;;IAMA,OAAOE,GAAAA,CAAII,IAAI,CAACC,UAAU,CAAC,CAAC,EAAEP,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M,CAAAA,QAAQ,CAACS,SAAS,CAAC,CAAA;AAAG,aAAA;AAC7C;;AAGA,QAAA,IAAIF,UAAUb,GAAIM,CAAAA,QAAQ,CAACU,MAAM,GAAG,CAAG,EAAA;YACrC,OAAO;AAAEd,gBAAAA,MAAAA,EAAQF,GAAIM,CAAAA,QAAQ,CAACS,SAAS,CAAC,CAAGF,EAAAA,KAAAA;AAAO,aAAA;AACpD;;QAGA,OAAO;AAAEX,YAAAA,MAAAA,EAAQF,GAAIM,CAAAA,QAAQ,CAACS,SAAS,CAAC,CAAGF,EAAAA,KAAAA;AAAO,SAAA;AACpD;;IAGA,OAAO;AAAEX,QAAAA,MAAAA,EAAQU,OAAOG,SAAS,CAAC,CAAGH,EAAAA,MAAAA,CAAOI,MAAM,GAAG,CAAA;AAAG,KAAA;AAC1D;AAEO,MAAMC,qBAAqB,CAACC,OAAAA,GAAAA;IACjC,IAAIA,OAAAA,CAAQC,SAAS,EAAEC,WAAa,EAAA;QAClC,OAAO;AACLC,YAAAA,WAAAA,EAAaH,OAAQC,CAAAA,SAAS,CAACC,WAAW,CAACC,WAAW;AACtDC,YAAAA,eAAAA,EAAiBJ,OAAQC,CAAAA,SAAS,CAACC,WAAW,CAACE;AACjD,SAAA;AACF;IACA,OAAO,IAAA;AACT;;;;;"}
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const ENDPOINT_PATTERN = /^(.+\.)?s3[.-]([a-z0-9-]+)\./;
|
|
2
|
+
function isUrlFromBucket(fileUrl, bucketName, baseUrl = '') {
|
|
3
|
+
const url = new URL(fileUrl);
|
|
4
|
+
// Check if the file URL is using a base URL (e.g. a CDN).
|
|
5
|
+
// In this case do not sign the URL.
|
|
6
|
+
if (baseUrl) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const { bucket } = getBucketFromAwsUrl(fileUrl);
|
|
10
|
+
if (bucket) {
|
|
11
|
+
return bucket === bucketName;
|
|
12
|
+
}
|
|
13
|
+
// File URL might be of an S3-compatible provider. (or an invalid URL)
|
|
14
|
+
// In this case, check if the bucket name appears in the URL host or path.
|
|
15
|
+
// e.g. https://minio.example.com/bucket-name/object-key
|
|
16
|
+
// e.g. https://bucket.nyc3.digitaloceanspaces.com/folder/img.png
|
|
17
|
+
return url.host.startsWith(`${bucketName}.`) || url.pathname.includes(`/${bucketName}/`);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Parse the bucket name from a URL.
|
|
21
|
+
* See all URL formats in https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html
|
|
22
|
+
*
|
|
23
|
+
* @param {string} fileUrl - the URL to parse
|
|
24
|
+
* @returns {object} result
|
|
25
|
+
* @returns {string} result.bucket - the bucket name
|
|
26
|
+
* @returns {string} result.err - if any
|
|
27
|
+
*/ function getBucketFromAwsUrl(fileUrl) {
|
|
28
|
+
const url = new URL(fileUrl);
|
|
29
|
+
// S3://<bucket-name>/<key>
|
|
30
|
+
if (url.protocol === 's3:') {
|
|
31
|
+
const bucket = url.host;
|
|
32
|
+
if (!bucket) {
|
|
33
|
+
return {
|
|
34
|
+
err: `Invalid S3 url: no bucket: ${url}`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
bucket
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (!url.host) {
|
|
42
|
+
return {
|
|
43
|
+
err: `Invalid S3 url: no hostname: ${url}`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const matches = url.host.match(ENDPOINT_PATTERN);
|
|
47
|
+
if (!matches) {
|
|
48
|
+
return {
|
|
49
|
+
err: `Invalid S3 url: hostname does not appear to be a valid S3 endpoint: ${url}`
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const prefix = matches[1];
|
|
53
|
+
// https://s3.amazonaws.com/<bucket-name>
|
|
54
|
+
if (!prefix) {
|
|
55
|
+
if (url.pathname === '/') {
|
|
56
|
+
return {
|
|
57
|
+
bucket: null
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const index = url.pathname.indexOf('/', 1);
|
|
61
|
+
// https://s3.amazonaws.com/<bucket-name>
|
|
62
|
+
if (index === -1) {
|
|
63
|
+
return {
|
|
64
|
+
bucket: url.pathname.substring(1)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// https://s3.amazonaws.com/<bucket-name>/
|
|
68
|
+
if (index === url.pathname.length - 1) {
|
|
69
|
+
return {
|
|
70
|
+
bucket: url.pathname.substring(1, index)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// https://s3.amazonaws.com/<bucket-name>/key
|
|
74
|
+
return {
|
|
75
|
+
bucket: url.pathname.substring(1, index)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// https://<bucket-name>.s3.amazonaws.com/
|
|
79
|
+
return {
|
|
80
|
+
bucket: prefix.substring(0, prefix.length - 1)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const extractCredentials = (options)=>{
|
|
84
|
+
if (options.s3Options?.credentials) {
|
|
85
|
+
return {
|
|
86
|
+
accessKeyId: options.s3Options.credentials.accessKeyId,
|
|
87
|
+
secretAccessKey: options.s3Options.credentials.secretAccessKey
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { extractCredentials, isUrlFromBucket };
|
|
94
|
+
//# sourceMappingURL=utils.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { AwsCredentialIdentity } from '@aws-sdk/types';\nimport type { InitOptions } from '.';\n\nconst ENDPOINT_PATTERN = /^(.+\\.)?s3[.-]([a-z0-9-]+)\\./;\n\ninterface BucketInfo {\n bucket?: string | null;\n err?: string;\n}\n\nexport function isUrlFromBucket(fileUrl: string, bucketName: string, baseUrl = ''): boolean {\n const url = new URL(fileUrl);\n\n // Check if the file URL is using a base URL (e.g. a CDN).\n // In this case do not sign the URL.\n if (baseUrl) {\n return false;\n }\n\n const { bucket } = getBucketFromAwsUrl(fileUrl);\n\n if (bucket) {\n return bucket === bucketName;\n }\n\n // File URL might be of an S3-compatible provider. (or an invalid URL)\n // In this case, check if the bucket name appears in the URL host or path.\n // e.g. https://minio.example.com/bucket-name/object-key\n // e.g. https://bucket.nyc3.digitaloceanspaces.com/folder/img.png\n return url.host.startsWith(`${bucketName}.`) || url.pathname.includes(`/${bucketName}/`);\n}\n\n/**\n * Parse the bucket name from a URL.\n * See all URL formats in https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-bucket-intro.html\n *\n * @param {string} fileUrl - the URL to parse\n * @returns {object} result\n * @returns {string} result.bucket - the bucket name\n * @returns {string} result.err - if any\n */\nfunction getBucketFromAwsUrl(fileUrl: string): BucketInfo {\n const url = new URL(fileUrl);\n\n // S3://<bucket-name>/<key>\n if (url.protocol === 's3:') {\n const bucket = url.host;\n\n if (!bucket) {\n return { err: `Invalid S3 url: no bucket: ${url}` };\n }\n return { bucket };\n }\n\n if (!url.host) {\n return { err: `Invalid S3 url: no hostname: ${url}` };\n }\n\n const matches = url.host.match(ENDPOINT_PATTERN);\n if (!matches) {\n return { err: `Invalid S3 url: hostname does not appear to be a valid S3 endpoint: ${url}` };\n }\n\n const prefix = matches[1];\n // https://s3.amazonaws.com/<bucket-name>\n if (!prefix) {\n if (url.pathname === '/') {\n return { bucket: null };\n }\n\n const index = url.pathname.indexOf('/', 1);\n\n // https://s3.amazonaws.com/<bucket-name>\n if (index === -1) {\n return { bucket: url.pathname.substring(1) };\n }\n\n // https://s3.amazonaws.com/<bucket-name>/\n if (index === url.pathname.length - 1) {\n return { bucket: url.pathname.substring(1, index) };\n }\n\n // https://s3.amazonaws.com/<bucket-name>/key\n return { bucket: url.pathname.substring(1, index) };\n }\n\n // https://<bucket-name>.s3.amazonaws.com/\n return { bucket: prefix.substring(0, prefix.length - 1) };\n}\n\nexport const extractCredentials = (options: InitOptions): AwsCredentialIdentity | null => {\n if (options.s3Options?.credentials) {\n return {\n accessKeyId: options.s3Options.credentials.accessKeyId,\n secretAccessKey: options.s3Options.credentials.secretAccessKey,\n };\n }\n return null;\n};\n"],"names":["ENDPOINT_PATTERN","isUrlFromBucket","fileUrl","bucketName","baseUrl","url","URL","bucket","getBucketFromAwsUrl","host","startsWith","pathname","includes","protocol","err","matches","match","prefix","index","indexOf","substring","length","extractCredentials","options","s3Options","credentials","accessKeyId","secretAccessKey"],"mappings":"AAGA,MAAMA,gBAAmB,GAAA,8BAAA;AAOlB,SAASC,eAAgBC,CAAAA,OAAe,EAAEC,UAAkB,EAAEC,UAAU,EAAE,EAAA;IAC/E,MAAMC,GAAAA,GAAM,IAAIC,GAAIJ,CAAAA,OAAAA,CAAAA;;;AAIpB,IAAA,IAAIE,OAAS,EAAA;QACX,OAAO,KAAA;AACT;AAEA,IAAA,MAAM,EAAEG,MAAM,EAAE,GAAGC,mBAAoBN,CAAAA,OAAAA,CAAAA;AAEvC,IAAA,IAAIK,MAAQ,EAAA;AACV,QAAA,OAAOA,MAAWJ,KAAAA,UAAAA;AACpB;;;;;IAMA,OAAOE,GAAAA,CAAII,IAAI,CAACC,UAAU,CAAC,CAAC,EAAEP,WAAW,CAAC,CAAC,KAAKE,GAAIM,CAAAA,QAAQ,CAACC,QAAQ,CAAC,CAAC,CAAC,EAAET,UAAW,CAAA,CAAC,CAAC,CAAA;AACzF;AAEA;;;;;;;;IASA,SAASK,oBAAoBN,OAAe,EAAA;IAC1C,MAAMG,GAAAA,GAAM,IAAIC,GAAIJ,CAAAA,OAAAA,CAAAA;;IAGpB,IAAIG,GAAAA,CAAIQ,QAAQ,KAAK,KAAO,EAAA;QAC1B,MAAMN,MAAAA,GAASF,IAAII,IAAI;AAEvB,QAAA,IAAI,CAACF,MAAQ,EAAA;YACX,OAAO;AAAEO,gBAAAA,GAAAA,EAAK,CAAC,2BAA2B,EAAET,GAAAA,CA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,CAAC,CAAGH,EAAAA,MAAAA,CAAOI,MAAM,GAAG,CAAA;AAAG,KAAA;AAC1D;AAEO,MAAMC,qBAAqB,CAACC,OAAAA,GAAAA;IACjC,IAAIA,OAAAA,CAAQC,SAAS,EAAEC,WAAa,EAAA;QAClC,OAAO;AACLC,YAAAA,WAAAA,EAAaH,OAAQC,CAAAA,SAAS,CAACC,WAAW,CAACC,WAAW;AACtDC,YAAAA,eAAAA,EAAiBJ,OAAQC,CAAAA,SAAS,CAACC,WAAW,CAACE;AACjD,SAAA;AACF;IACA,OAAO,IAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/provider-upload-aws-s3",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.fb92031f3d90f3d2a2d191ba65725b6c8e329a5d",
|
|
4
4
|
"description": "AWS S3 provider for strapi upload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"upload",
|
|
@@ -34,30 +34,32 @@
|
|
|
34
34
|
"source": "./src/index.ts",
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"files": [
|
|
37
|
-
"
|
|
37
|
+
"dist/"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "
|
|
40
|
+
"build": "run -T npm-run-all clean --parallel build:code build:types",
|
|
41
|
+
"build:code": "run -T rollup -c",
|
|
42
|
+
"build:types": "run -T tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
41
43
|
"clean": "run -T rimraf ./dist",
|
|
42
44
|
"lint": "run -T eslint .",
|
|
43
|
-
"prepublishOnly": "yarn clean && yarn build",
|
|
44
45
|
"test:unit": "run -T jest",
|
|
45
46
|
"test:unit:watch": "run -T jest --watch",
|
|
46
|
-
"watch": "
|
|
47
|
+
"watch": "run -T rollup -c -w"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"aws-sdk": "
|
|
50
|
+
"@aws-sdk/client-s3": "3.600.0",
|
|
51
|
+
"@aws-sdk/lib-storage": "3.433.0",
|
|
52
|
+
"@aws-sdk/s3-request-presigner": "3.433.0",
|
|
53
|
+
"@aws-sdk/types": "3.433.0",
|
|
50
54
|
"lodash": "4.17.21"
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|
|
53
|
-
"@strapi/pack-up": "0.0.0-next.fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a",
|
|
54
57
|
"@types/jest": "29.5.2",
|
|
55
|
-
"eslint-config-custom": "0.0.0-next.
|
|
56
|
-
"tsconfig": "0.0.0-next.
|
|
58
|
+
"eslint-config-custom": "0.0.0-next.fb92031f3d90f3d2a2d191ba65725b6c8e329a5d",
|
|
59
|
+
"tsconfig": "0.0.0-next.fb92031f3d90f3d2a2d191ba65725b6c8e329a5d"
|
|
57
60
|
},
|
|
58
61
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
62
|
+
"node": ">=18.0.0 <=22.x.x",
|
|
60
63
|
"npm": ">=6.0.0"
|
|
61
|
-
}
|
|
62
|
-
"gitHead": "fb3a0b82484ce466b1efb1b28f16fc8ef73aba4a"
|
|
64
|
+
}
|
|
63
65
|
}
|