@edgestore/server 0.7.0-canary.0 → 0.7.0-canary.1
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type S3ClientConfig } from '@aws-sdk/client-s3';
|
|
2
|
+
import { type MaybePromise, type Provider as EdgeStoreProvider, type RequestUploadParams } from '@edgestore/shared';
|
|
2
3
|
type ProviderUploadedFileInfo = RequestUploadParams['fileInfo'];
|
|
3
4
|
export type AWSOverwritePathFnArgs = {
|
|
4
5
|
esBucketName: string;
|
|
@@ -7,11 +8,20 @@ export type AWSOverwritePathFnArgs = {
|
|
|
7
8
|
};
|
|
8
9
|
export type AWSOverwritePathFn = (args: AWSOverwritePathFnArgs) => MaybePromise<string>;
|
|
9
10
|
export type AWSProviderOptions = {
|
|
11
|
+
/**
|
|
12
|
+
* AWS SDK credentials (or credentials provider) to use for S3 requests.
|
|
13
|
+
*
|
|
14
|
+
* If unset, the AWS SDK will use its default credential provider chain
|
|
15
|
+
* (environment variables, shared config files, instance/task roles, etc).
|
|
16
|
+
*/
|
|
17
|
+
credentials?: S3ClientConfig['credentials'];
|
|
10
18
|
/**
|
|
11
19
|
* Access key for AWS credentials.
|
|
12
20
|
* Can also be set via the `ES_AWS_ACCESS_KEY_ID` environment variable.
|
|
13
21
|
*
|
|
14
22
|
* If unset, the SDK will attempt to use the default credentials provider chain.
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Pass `credentials` instead.
|
|
15
25
|
*/
|
|
16
26
|
accessKeyId?: string;
|
|
17
27
|
/**
|
|
@@ -19,6 +29,8 @@ export type AWSProviderOptions = {
|
|
|
19
29
|
* Can also be set via the `ES_AWS_SECRET_ACCESS_KEY` environment variable.
|
|
20
30
|
*
|
|
21
31
|
* If unset, the SDK will attempt to use the default credentials provider chain.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated Pass `credentials` instead.
|
|
22
34
|
*/
|
|
23
35
|
secretAccessKey?: string;
|
|
24
36
|
/**
|
|
@@ -63,6 +75,6 @@ export type AWSProviderOptions = {
|
|
|
63
75
|
*/
|
|
64
76
|
overwritePath?: AWSOverwritePathFn;
|
|
65
77
|
};
|
|
66
|
-
export declare function AWSProvider(options?: AWSProviderOptions):
|
|
78
|
+
export declare function AWSProvider(options?: AWSProviderOptions): EdgeStoreProvider;
|
|
67
79
|
export {};
|
|
68
80
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,QAAQ,IAAI,iBAAiB,EAClC,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAK3B,KAAK,wBAAwB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;AAEhE,MAAM,MAAM,sBAAsB,GAAG;IAEnC,YAAY,EAAE,MAAM,CAAC;IAErB,QAAQ,EAAE,wBAAwB,CAAC;IAEnC,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,IAAI,EAAE,sBAAsB,KACzB,YAAY,CAAC,MAAM,CAAC,CAAC;AAE1B,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CA0I3E"}
|
|
@@ -6,12 +6,12 @@ var uuid = require('uuid');
|
|
|
6
6
|
var shared = require('../../adapters/shared.js');
|
|
7
7
|
|
|
8
8
|
function AWSProvider(options) {
|
|
9
|
-
const { accessKeyId = shared.getEnv('ES_AWS_ACCESS_KEY_ID'), secretAccessKey = shared.getEnv('ES_AWS_SECRET_ACCESS_KEY'), region = shared.getEnv('ES_AWS_REGION'), bucketName = shared.getEnv('ES_AWS_BUCKET_NAME'), endpoint = shared.getEnv('ES_AWS_ENDPOINT'), forcePathStyle = shared.getEnv('ES_AWS_FORCE_PATH_STYLE') === 'true', overwritePath } = options ?? {};
|
|
9
|
+
const { credentials: credentialsFromOptions, accessKeyId = shared.getEnv('ES_AWS_ACCESS_KEY_ID'), secretAccessKey = shared.getEnv('ES_AWS_SECRET_ACCESS_KEY'), region = shared.getEnv('ES_AWS_REGION'), bucketName = shared.getEnv('ES_AWS_BUCKET_NAME'), endpoint = shared.getEnv('ES_AWS_ENDPOINT'), forcePathStyle = shared.getEnv('ES_AWS_FORCE_PATH_STYLE') === 'true', overwritePath } = options ?? {};
|
|
10
10
|
const baseUrl = options?.baseUrl ?? shared.getEnv('EDGE_STORE_BASE_URL') ?? (endpoint ? `${endpoint}/${bucketName}` : `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
11
|
-
const credentials = accessKeyId && secretAccessKey ? {
|
|
11
|
+
const credentials = credentialsFromOptions ?? (accessKeyId && secretAccessKey ? {
|
|
12
12
|
accessKeyId,
|
|
13
13
|
secretAccessKey
|
|
14
|
-
} : undefined;
|
|
14
|
+
} : undefined);
|
|
15
15
|
const s3Client = new clientS3.S3Client({
|
|
16
16
|
region,
|
|
17
17
|
credentials,
|
|
@@ -4,12 +4,12 @@ import { v4 } from 'uuid';
|
|
|
4
4
|
import { getEnv } from '../../adapters/shared.mjs';
|
|
5
5
|
|
|
6
6
|
function AWSProvider(options) {
|
|
7
|
-
const { accessKeyId = getEnv('ES_AWS_ACCESS_KEY_ID'), secretAccessKey = getEnv('ES_AWS_SECRET_ACCESS_KEY'), region = getEnv('ES_AWS_REGION'), bucketName = getEnv('ES_AWS_BUCKET_NAME'), endpoint = getEnv('ES_AWS_ENDPOINT'), forcePathStyle = getEnv('ES_AWS_FORCE_PATH_STYLE') === 'true', overwritePath } = options ?? {};
|
|
7
|
+
const { credentials: credentialsFromOptions, accessKeyId = getEnv('ES_AWS_ACCESS_KEY_ID'), secretAccessKey = getEnv('ES_AWS_SECRET_ACCESS_KEY'), region = getEnv('ES_AWS_REGION'), bucketName = getEnv('ES_AWS_BUCKET_NAME'), endpoint = getEnv('ES_AWS_ENDPOINT'), forcePathStyle = getEnv('ES_AWS_FORCE_PATH_STYLE') === 'true', overwritePath } = options ?? {};
|
|
8
8
|
const baseUrl = options?.baseUrl ?? getEnv('EDGE_STORE_BASE_URL') ?? (endpoint ? `${endpoint}/${bucketName}` : `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
9
|
-
const credentials = accessKeyId && secretAccessKey ? {
|
|
9
|
+
const credentials = credentialsFromOptions ?? (accessKeyId && secretAccessKey ? {
|
|
10
10
|
accessKeyId,
|
|
11
11
|
secretAccessKey
|
|
12
|
-
} : undefined;
|
|
12
|
+
} : undefined);
|
|
13
13
|
const s3Client = new S3Client({
|
|
14
14
|
region,
|
|
15
15
|
credentials,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestore/server",
|
|
3
|
-
"version": "0.7.0-canary.
|
|
3
|
+
"version": "0.7.0-canary.1",
|
|
4
4
|
"description": "Upload files with ease from React/Next.js",
|
|
5
5
|
"homepage": "https://edgestore.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"!**/__tests__"
|
|
110
110
|
],
|
|
111
111
|
"dependencies": {
|
|
112
|
-
"@edgestore/shared": "0.7.0-canary.
|
|
112
|
+
"@edgestore/shared": "0.7.0-canary.1",
|
|
113
113
|
"@panva/hkdf": "^1.0.4",
|
|
114
114
|
"cookie": "^0.7.0",
|
|
115
115
|
"jose": "^4.13.1",
|
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
HeadObjectCommand,
|
|
4
4
|
PutObjectCommand,
|
|
5
5
|
S3Client,
|
|
6
|
+
type S3ClientConfig,
|
|
6
7
|
} from '@aws-sdk/client-s3';
|
|
7
8
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
8
9
|
import {
|
|
9
10
|
type MaybePromise,
|
|
10
|
-
type Provider,
|
|
11
|
+
type Provider as EdgeStoreProvider,
|
|
11
12
|
type RequestUploadParams,
|
|
12
13
|
} from '@edgestore/shared';
|
|
13
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -30,11 +31,20 @@ export type AWSOverwritePathFn = (
|
|
|
30
31
|
) => MaybePromise<string>;
|
|
31
32
|
|
|
32
33
|
export type AWSProviderOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* AWS SDK credentials (or credentials provider) to use for S3 requests.
|
|
36
|
+
*
|
|
37
|
+
* If unset, the AWS SDK will use its default credential provider chain
|
|
38
|
+
* (environment variables, shared config files, instance/task roles, etc).
|
|
39
|
+
*/
|
|
40
|
+
credentials?: S3ClientConfig['credentials'];
|
|
33
41
|
/**
|
|
34
42
|
* Access key for AWS credentials.
|
|
35
43
|
* Can also be set via the `ES_AWS_ACCESS_KEY_ID` environment variable.
|
|
36
44
|
*
|
|
37
45
|
* If unset, the SDK will attempt to use the default credentials provider chain.
|
|
46
|
+
*
|
|
47
|
+
* @deprecated Pass `credentials` instead.
|
|
38
48
|
*/
|
|
39
49
|
accessKeyId?: string;
|
|
40
50
|
/**
|
|
@@ -42,6 +52,8 @@ export type AWSProviderOptions = {
|
|
|
42
52
|
* Can also be set via the `ES_AWS_SECRET_ACCESS_KEY` environment variable.
|
|
43
53
|
*
|
|
44
54
|
* If unset, the SDK will attempt to use the default credentials provider chain.
|
|
55
|
+
*
|
|
56
|
+
* @deprecated Pass `credentials` instead.
|
|
45
57
|
*/
|
|
46
58
|
secretAccessKey?: string;
|
|
47
59
|
/**
|
|
@@ -87,8 +99,9 @@ export type AWSProviderOptions = {
|
|
|
87
99
|
overwritePath?: AWSOverwritePathFn;
|
|
88
100
|
};
|
|
89
101
|
|
|
90
|
-
export function AWSProvider(options?: AWSProviderOptions):
|
|
102
|
+
export function AWSProvider(options?: AWSProviderOptions): EdgeStoreProvider {
|
|
91
103
|
const {
|
|
104
|
+
credentials: credentialsFromOptions,
|
|
92
105
|
accessKeyId = getEnv('ES_AWS_ACCESS_KEY_ID'),
|
|
93
106
|
secretAccessKey = getEnv('ES_AWS_SECRET_ACCESS_KEY'),
|
|
94
107
|
region = getEnv('ES_AWS_REGION'),
|
|
@@ -106,12 +119,13 @@ export function AWSProvider(options?: AWSProviderOptions): Provider {
|
|
|
106
119
|
: `https://${bucketName}.s3.${region}.amazonaws.com`);
|
|
107
120
|
|
|
108
121
|
const credentials =
|
|
109
|
-
|
|
122
|
+
credentialsFromOptions ??
|
|
123
|
+
(accessKeyId && secretAccessKey
|
|
110
124
|
? {
|
|
111
125
|
accessKeyId,
|
|
112
126
|
secretAccessKey,
|
|
113
127
|
}
|
|
114
|
-
: undefined;
|
|
128
|
+
: undefined);
|
|
115
129
|
const s3Client = new S3Client({
|
|
116
130
|
region,
|
|
117
131
|
credentials,
|