@constructive-io/bucket-provisioner 0.26.0 → 0.28.0
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/README.md +1 -6
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/naming.d.ts +4 -15
- package/esm/naming.js +4 -23
- package/esm/types.d.ts +2 -2
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/naming.d.ts +4 -15
- package/naming.js +4 -24
- package/package.json +4 -4
- package/types.d.ts +2 -2
package/README.md
CHANGED
|
@@ -146,7 +146,7 @@ The main class that orchestrates bucket creation and configuration.
|
|
|
146
146
|
|
|
147
147
|
| Option | Type | Description |
|
|
148
148
|
|--------|------|-------------|
|
|
149
|
-
| `connection.provider` | `'s3' \| 'minio' \| 'r2' \| 'gcs' \| 'spaces'` | Storage provider type |
|
|
149
|
+
| `connection.provider` | `'s3' \| 'minio' \| 'rustfs' \| 'r2' \| 'gcs' \| 'spaces'` | Storage provider type |
|
|
150
150
|
| `connection.region` | `string` | S3 region (e.g., `'us-east-1'`) |
|
|
151
151
|
| `connection.endpoint` | `string?` | S3-compatible endpoint URL. Required for non-AWS providers. |
|
|
152
152
|
| `connection.accessKeyId` | `string` | AWS access key ID |
|
|
@@ -196,11 +196,6 @@ belongs to one database at one scope, and there is no global bucket namespace to
|
|
|
196
196
|
prefix into. Each readable component has its own budget, so a long scope cannot
|
|
197
197
|
crowd out the database label, and the digest covers the untruncated identity.
|
|
198
198
|
|
|
199
|
-
#### `mintPhysicalBucketName(prefix, databaseId, bucketKey)`
|
|
200
|
-
|
|
201
|
-
The prefixed policy — `{prefix}-{bucketKey}-{digest}` — for a deployment that
|
|
202
|
-
names its own bucket namespace.
|
|
203
|
-
|
|
204
199
|
### Policy Builders
|
|
205
200
|
|
|
206
201
|
Standalone functions for generating S3 policy documents.
|
package/esm/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
export type { BucketProvisionerOptions } from './provisioner';
|
|
30
30
|
export { BucketProvisioner } from './provisioner';
|
|
31
31
|
export type { PhysicalBucketIdentity } from './naming';
|
|
32
|
-
export {
|
|
32
|
+
export { physicalBucketName } from './naming';
|
|
33
33
|
export { createS3Client } from './client';
|
|
34
34
|
export type { BucketPolicyDocument, BucketPolicyStatement, PublicAccessBlockConfig, } from './policies';
|
|
35
35
|
export { buildCloudFrontOacPolicy, buildPresignedUrlIamPolicy, buildPublicReadPolicy, getPublicAccessBlock, } from './policies';
|
package/esm/index.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
export { BucketProvisioner } from './provisioner';
|
|
30
|
-
export {
|
|
30
|
+
export { physicalBucketName } from './naming';
|
|
31
31
|
// S3 client factory
|
|
32
32
|
export { createS3Client } from './client';
|
|
33
33
|
export { buildCloudFrontOacPolicy, buildPresignedUrlIamPolicy, buildPublicReadPolicy, getPublicAccessBlock, } from './policies';
|
package/esm/naming.d.ts
CHANGED
|
@@ -14,24 +14,13 @@ export interface PhysicalBucketIdentity {
|
|
|
14
14
|
*
|
|
15
15
|
* This is the policy for a platform-provisioned bucket, and it takes no prefix
|
|
16
16
|
* because there is no global bucket namespace to prefix into: a bucket belongs
|
|
17
|
-
* to one database at one scope, and that is what its name should say.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* to one database at one scope, and that is what its name should say. The
|
|
18
|
+
* reconciler derives names from here rather than composing a prefix of its own,
|
|
19
|
+
* and consumers of a bucket row never consult this policy: the recorded
|
|
20
|
+
* `physical_name` is authoritative.
|
|
21
21
|
*
|
|
22
22
|
* The scope is part of the digested identity untruncated, so two scopes of one
|
|
23
23
|
* database that declare the same bucket key stay distinct even when their
|
|
24
24
|
* readable labels truncate to the same thing.
|
|
25
25
|
*/
|
|
26
26
|
export declare function physicalBucketName(identity: PhysicalBucketIdentity): string;
|
|
27
|
-
/**
|
|
28
|
-
* The prefixed physical-bucket naming policy:
|
|
29
|
-
* `{prefix}-{bucketKey}-{digest}` (e.g. `myapp-public-3f9c1a2b7e04`).
|
|
30
|
-
*
|
|
31
|
-
* For a deployment that names its own bucket namespace — a single-app
|
|
32
|
-
* installation, or the presigned-upload (lazy) path meeting a bucket an app
|
|
33
|
-
* configured. A platform-provisioned bucket uses {@link physicalBucketName}
|
|
34
|
-
* instead, whose components come from the bucket row rather than from
|
|
35
|
-
* deployment config.
|
|
36
|
-
*/
|
|
37
|
-
export declare function mintPhysicalBucketName(prefix: string, databaseId: string, bucketKey: string): string;
|
package/esm/naming.js
CHANGED
|
@@ -5,9 +5,6 @@ const MAX_BUCKET_NAME_LENGTH = 63;
|
|
|
5
5
|
const MIN_BUCKET_NAME_LENGTH = 3;
|
|
6
6
|
/** Hex characters of the identity digest kept as the uniqueness tail. */
|
|
7
7
|
const IDENTITY_DIGEST_LENGTH = 12;
|
|
8
|
-
/** Readable budget: how much of the name the prefix and key may each occupy. */
|
|
9
|
-
const PREFIX_BUDGET = 20;
|
|
10
|
-
const BUCKET_KEY_BUDGET = 63 - IDENTITY_DIGEST_LENGTH - PREFIX_BUDGET - 3;
|
|
11
8
|
/**
|
|
12
9
|
* Readable budgets for a name minted from a bucket's own identity.
|
|
13
10
|
*
|
|
@@ -74,10 +71,10 @@ function assembleBucketName(readable, identity, describeIdentity) {
|
|
|
74
71
|
*
|
|
75
72
|
* This is the policy for a platform-provisioned bucket, and it takes no prefix
|
|
76
73
|
* because there is no global bucket namespace to prefix into: a bucket belongs
|
|
77
|
-
* to one database at one scope, and that is what its name should say.
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
74
|
+
* to one database at one scope, and that is what its name should say. The
|
|
75
|
+
* reconciler derives names from here rather than composing a prefix of its own,
|
|
76
|
+
* and consumers of a bucket row never consult this policy: the recorded
|
|
77
|
+
* `physical_name` is authoritative.
|
|
81
78
|
*
|
|
82
79
|
* The scope is part of the digested identity untruncated, so two scopes of one
|
|
83
80
|
* database that declare the same bucket key stay distinct even when their
|
|
@@ -91,19 +88,3 @@ export function physicalBucketName(identity) {
|
|
|
91
88
|
readableComponent(bucketKey, IDENTITY_KEY_BUDGET),
|
|
92
89
|
], `${scope}/${databaseId}/${bucketKey}`, `key "${bucketKey}" at scope "${scope}"`);
|
|
93
90
|
}
|
|
94
|
-
/**
|
|
95
|
-
* The prefixed physical-bucket naming policy:
|
|
96
|
-
* `{prefix}-{bucketKey}-{digest}` (e.g. `myapp-public-3f9c1a2b7e04`).
|
|
97
|
-
*
|
|
98
|
-
* For a deployment that names its own bucket namespace — a single-app
|
|
99
|
-
* installation, or the presigned-upload (lazy) path meeting a bucket an app
|
|
100
|
-
* configured. A platform-provisioned bucket uses {@link physicalBucketName}
|
|
101
|
-
* instead, whose components come from the bucket row rather than from
|
|
102
|
-
* deployment config.
|
|
103
|
-
*/
|
|
104
|
-
export function mintPhysicalBucketName(prefix, databaseId, bucketKey) {
|
|
105
|
-
return assembleBucketName([
|
|
106
|
-
readableComponent(prefix, PREFIX_BUDGET),
|
|
107
|
-
readableComponent(bucketKey, BUCKET_KEY_BUDGET),
|
|
108
|
-
], `${prefix}/${databaseId}/${bucketKey}`, `key "${bucketKey}"`);
|
|
109
|
-
}
|
package/esm/types.d.ts
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
* Used to select provider-specific behavior (e.g., path-style URLs for MinIO,
|
|
11
11
|
* jurisdiction headers for R2).
|
|
12
12
|
*/
|
|
13
|
-
export type StorageProvider = 's3' | 'minio' | 'r2' | 'gcs' | 'spaces';
|
|
13
|
+
export type StorageProvider = 's3' | 'minio' | 'rustfs' | 'r2' | 'gcs' | 'spaces';
|
|
14
14
|
/**
|
|
15
15
|
* Connection configuration for an S3-compatible storage backend.
|
|
16
16
|
*
|
|
17
17
|
* This is the input you provide to connect to your storage provider.
|
|
18
18
|
* For AWS S3, only `region` and credentials are needed.
|
|
19
|
-
* For MinIO/R2/etc., also provide `endpoint`.
|
|
19
|
+
* For MinIO/RustFS/R2/etc., also provide `endpoint`.
|
|
20
20
|
*/
|
|
21
21
|
export interface StorageConnectionConfig {
|
|
22
22
|
/** Storage provider type */
|
package/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
export type { BucketProvisionerOptions } from './provisioner';
|
|
30
30
|
export { BucketProvisioner } from './provisioner';
|
|
31
31
|
export type { PhysicalBucketIdentity } from './naming';
|
|
32
|
-
export {
|
|
32
|
+
export { physicalBucketName } from './naming';
|
|
33
33
|
export { createS3Client } from './client';
|
|
34
34
|
export type { BucketPolicyDocument, BucketPolicyStatement, PublicAccessBlockConfig, } from './policies';
|
|
35
35
|
export { buildCloudFrontOacPolicy, buildPresignedUrlIamPolicy, buildPublicReadPolicy, getPublicAccessBlock, } from './policies';
|
package/index.js
CHANGED
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.ProvisionerError = exports.buildTempCleanupRule = exports.buildAbortIncompleteMultipartRule = exports.buildUploadCorsRules = exports.buildPrivateCorsRules = exports.getPublicAccessBlock = exports.buildPublicReadPolicy = exports.buildPresignedUrlIamPolicy = exports.buildCloudFrontOacPolicy = exports.createS3Client = exports.physicalBucketName = exports.
|
|
31
|
+
exports.ProvisionerError = exports.buildTempCleanupRule = exports.buildAbortIncompleteMultipartRule = exports.buildUploadCorsRules = exports.buildPrivateCorsRules = exports.getPublicAccessBlock = exports.buildPublicReadPolicy = exports.buildPresignedUrlIamPolicy = exports.buildCloudFrontOacPolicy = exports.createS3Client = exports.physicalBucketName = exports.BucketProvisioner = void 0;
|
|
32
32
|
var provisioner_1 = require("./provisioner");
|
|
33
33
|
Object.defineProperty(exports, "BucketProvisioner", { enumerable: true, get: function () { return provisioner_1.BucketProvisioner; } });
|
|
34
34
|
var naming_1 = require("./naming");
|
|
35
|
-
Object.defineProperty(exports, "mintPhysicalBucketName", { enumerable: true, get: function () { return naming_1.mintPhysicalBucketName; } });
|
|
36
35
|
Object.defineProperty(exports, "physicalBucketName", { enumerable: true, get: function () { return naming_1.physicalBucketName; } });
|
|
37
36
|
// S3 client factory
|
|
38
37
|
var client_1 = require("./client");
|
package/naming.d.ts
CHANGED
|
@@ -14,24 +14,13 @@ export interface PhysicalBucketIdentity {
|
|
|
14
14
|
*
|
|
15
15
|
* This is the policy for a platform-provisioned bucket, and it takes no prefix
|
|
16
16
|
* because there is no global bucket namespace to prefix into: a bucket belongs
|
|
17
|
-
* to one database at one scope, and that is what its name should say.
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* to one database at one scope, and that is what its name should say. The
|
|
18
|
+
* reconciler derives names from here rather than composing a prefix of its own,
|
|
19
|
+
* and consumers of a bucket row never consult this policy: the recorded
|
|
20
|
+
* `physical_name` is authoritative.
|
|
21
21
|
*
|
|
22
22
|
* The scope is part of the digested identity untruncated, so two scopes of one
|
|
23
23
|
* database that declare the same bucket key stay distinct even when their
|
|
24
24
|
* readable labels truncate to the same thing.
|
|
25
25
|
*/
|
|
26
26
|
export declare function physicalBucketName(identity: PhysicalBucketIdentity): string;
|
|
27
|
-
/**
|
|
28
|
-
* The prefixed physical-bucket naming policy:
|
|
29
|
-
* `{prefix}-{bucketKey}-{digest}` (e.g. `myapp-public-3f9c1a2b7e04`).
|
|
30
|
-
*
|
|
31
|
-
* For a deployment that names its own bucket namespace — a single-app
|
|
32
|
-
* installation, or the presigned-upload (lazy) path meeting a bucket an app
|
|
33
|
-
* configured. A platform-provisioned bucket uses {@link physicalBucketName}
|
|
34
|
-
* instead, whose components come from the bucket row rather than from
|
|
35
|
-
* deployment config.
|
|
36
|
-
*/
|
|
37
|
-
export declare function mintPhysicalBucketName(prefix: string, databaseId: string, bucketKey: string): string;
|
package/naming.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.physicalBucketName = physicalBucketName;
|
|
4
|
-
exports.mintPhysicalBucketName = mintPhysicalBucketName;
|
|
5
4
|
const crypto_1 = require("crypto");
|
|
6
5
|
/** S3's hard ceiling on a bucket name. */
|
|
7
6
|
const MAX_BUCKET_NAME_LENGTH = 63;
|
|
@@ -9,9 +8,6 @@ const MAX_BUCKET_NAME_LENGTH = 63;
|
|
|
9
8
|
const MIN_BUCKET_NAME_LENGTH = 3;
|
|
10
9
|
/** Hex characters of the identity digest kept as the uniqueness tail. */
|
|
11
10
|
const IDENTITY_DIGEST_LENGTH = 12;
|
|
12
|
-
/** Readable budget: how much of the name the prefix and key may each occupy. */
|
|
13
|
-
const PREFIX_BUDGET = 20;
|
|
14
|
-
const BUCKET_KEY_BUDGET = 63 - IDENTITY_DIGEST_LENGTH - PREFIX_BUDGET - 3;
|
|
15
11
|
/**
|
|
16
12
|
* Readable budgets for a name minted from a bucket's own identity.
|
|
17
13
|
*
|
|
@@ -78,10 +74,10 @@ function assembleBucketName(readable, identity, describeIdentity) {
|
|
|
78
74
|
*
|
|
79
75
|
* This is the policy for a platform-provisioned bucket, and it takes no prefix
|
|
80
76
|
* because there is no global bucket namespace to prefix into: a bucket belongs
|
|
81
|
-
* to one database at one scope, and that is what its name should say.
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
77
|
+
* to one database at one scope, and that is what its name should say. The
|
|
78
|
+
* reconciler derives names from here rather than composing a prefix of its own,
|
|
79
|
+
* and consumers of a bucket row never consult this policy: the recorded
|
|
80
|
+
* `physical_name` is authoritative.
|
|
85
81
|
*
|
|
86
82
|
* The scope is part of the digested identity untruncated, so two scopes of one
|
|
87
83
|
* database that declare the same bucket key stay distinct even when their
|
|
@@ -95,19 +91,3 @@ function physicalBucketName(identity) {
|
|
|
95
91
|
readableComponent(bucketKey, IDENTITY_KEY_BUDGET),
|
|
96
92
|
], `${scope}/${databaseId}/${bucketKey}`, `key "${bucketKey}" at scope "${scope}"`);
|
|
97
93
|
}
|
|
98
|
-
/**
|
|
99
|
-
* The prefixed physical-bucket naming policy:
|
|
100
|
-
* `{prefix}-{bucketKey}-{digest}` (e.g. `myapp-public-3f9c1a2b7e04`).
|
|
101
|
-
*
|
|
102
|
-
* For a deployment that names its own bucket namespace — a single-app
|
|
103
|
-
* installation, or the presigned-upload (lazy) path meeting a bucket an app
|
|
104
|
-
* configured. A platform-provisioned bucket uses {@link physicalBucketName}
|
|
105
|
-
* instead, whose components come from the bucket row rather than from
|
|
106
|
-
* deployment config.
|
|
107
|
-
*/
|
|
108
|
-
function mintPhysicalBucketName(prefix, databaseId, bucketKey) {
|
|
109
|
-
return assembleBucketName([
|
|
110
|
-
readableComponent(prefix, PREFIX_BUDGET),
|
|
111
|
-
readableComponent(bucketKey, BUCKET_KEY_BUDGET),
|
|
112
|
-
], `${prefix}/${databaseId}/${bucketKey}`, `key "${bucketKey}"`);
|
|
113
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/bucket-provisioner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "S3-compatible bucket provisioning library — create buckets, configure privacy policies, CORS, and access controls",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@aws-sdk/client-s3": "^3.1052.0",
|
|
33
|
-
"@constructive-io/s3-utils": "^2.
|
|
33
|
+
"@constructive-io/s3-utils": "^2.33.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"makage": "^0.
|
|
36
|
+
"makage": "^0.8.0"
|
|
37
37
|
},
|
|
38
38
|
"keywords": [
|
|
39
39
|
"s3",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"storage",
|
|
45
45
|
"constructive"
|
|
46
46
|
],
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "5e0bfead2856d1a062b495d343a43e543343f9b8"
|
|
48
48
|
}
|
package/types.d.ts
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
* Used to select provider-specific behavior (e.g., path-style URLs for MinIO,
|
|
11
11
|
* jurisdiction headers for R2).
|
|
12
12
|
*/
|
|
13
|
-
export type StorageProvider = 's3' | 'minio' | 'r2' | 'gcs' | 'spaces';
|
|
13
|
+
export type StorageProvider = 's3' | 'minio' | 'rustfs' | 'r2' | 'gcs' | 'spaces';
|
|
14
14
|
/**
|
|
15
15
|
* Connection configuration for an S3-compatible storage backend.
|
|
16
16
|
*
|
|
17
17
|
* This is the input you provide to connect to your storage provider.
|
|
18
18
|
* For AWS S3, only `region` and credentials are needed.
|
|
19
|
-
* For MinIO/R2/etc., also provide `endpoint`.
|
|
19
|
+
* For MinIO/RustFS/R2/etc., also provide `endpoint`.
|
|
20
20
|
*/
|
|
21
21
|
export interface StorageConnectionConfig {
|
|
22
22
|
/** Storage provider type */
|