@veryfront/ext-blob-s3 0.1.1184
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 +202 -0
- package/NOTICE +2 -0
- package/README.md +139 -0
- package/esm/_dnt.polyfills.d.ts +12 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -0
- package/esm/_dnt.polyfills.js +15 -0
- package/esm/_dnt.shims.d.ts +11 -0
- package/esm/_dnt.shims.d.ts.map +1 -0
- package/esm/_dnt.shims.js +68 -0
- package/esm/index.d.ts +15 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +99 -0
- package/esm/multipart-upload.d.ts +23 -0
- package/esm/multipart-upload.d.ts.map +1 -0
- package/esm/multipart-upload.js +159 -0
- package/esm/package.json +3 -0
- package/esm/s3-storage.d.ts +82 -0
- package/esm/s3-storage.d.ts.map +1 -0
- package/esm/s3-storage.js +694 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @veryfront/ext-blob-s3
|
|
2
|
+
|
|
3
|
+
> **Category:** Storage | **Contract:** `BlobStorage` | **Explicit**
|
|
4
|
+
|
|
5
|
+
Use this extension to select AWS S3 or an S3-compatible service as Veryfront's
|
|
6
|
+
blob store.
|
|
7
|
+
|
|
8
|
+
The extension requires Node.js 20 or newer when used from npm. This matches the
|
|
9
|
+
minimum runtime supported by the pinned AWS SDK; Deno uses the same explicit
|
|
10
|
+
extension package and dependency versions.
|
|
11
|
+
|
|
12
|
+
## Install and compose
|
|
13
|
+
|
|
14
|
+
Add the package to the application, then compose it explicitly in
|
|
15
|
+
`veryfront.config.ts`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import extBlobS3 from "@veryfront/ext-blob-s3";
|
|
19
|
+
|
|
20
|
+
function requiredEnvironmentVariable(name: string): string {
|
|
21
|
+
const value = Deno.env.get(name);
|
|
22
|
+
if (!value) throw new Error(`${name} is required`);
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
extensions: [
|
|
28
|
+
extBlobS3({
|
|
29
|
+
region: requiredEnvironmentVariable("AWS_REGION"),
|
|
30
|
+
bucket: requiredEnvironmentVariable("VERYFRONT_BLOB_BUCKET"),
|
|
31
|
+
accessKeyId: requiredEnvironmentVariable("AWS_ACCESS_KEY_ID"),
|
|
32
|
+
secretAccessKey: requiredEnvironmentVariable("AWS_SECRET_ACCESS_KEY"),
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Pass temporary credentials with `sessionToken`. The extension deliberately does
|
|
39
|
+
not use the AWS ambient credential chain.
|
|
40
|
+
|
|
41
|
+
Do not register another extension that provides `BlobStorage` at the same
|
|
42
|
+
priority. Veryfront rejects that ambiguous selection.
|
|
43
|
+
|
|
44
|
+
## Configure the provider
|
|
45
|
+
|
|
46
|
+
The factory requires these values:
|
|
47
|
+
|
|
48
|
+
| Option | Purpose |
|
|
49
|
+
| ----------------- | ----------------------------- |
|
|
50
|
+
| `region` | AWS signing and bucket region |
|
|
51
|
+
| `bucket` | Destination bucket |
|
|
52
|
+
| `accessKeyId` | Explicit access-key ID |
|
|
53
|
+
| `secretAccessKey` | Explicit secret access key |
|
|
54
|
+
|
|
55
|
+
Use optional settings only when the deployment requires them:
|
|
56
|
+
|
|
57
|
+
| Option | Default | Purpose |
|
|
58
|
+
| ----------------------------- | -------------------------- | ---------------------------------------------------- |
|
|
59
|
+
| `sessionToken` | unset | Temporary-credential token |
|
|
60
|
+
| `endpoint` | AWS S3 | HTTP(S) endpoint for an S3-compatible service |
|
|
61
|
+
| `forcePathStyle` | SDK default | Path-style bucket addressing |
|
|
62
|
+
| `prefix` | empty | Prefix prepended to each blob ID |
|
|
63
|
+
| `baseUrl` | unset | Public HTTP(S) URL used in returned blob references |
|
|
64
|
+
| `defaultTtl` | unset | Default expiry in seconds; `0` disables expiry |
|
|
65
|
+
| `autoCreateBucket` | `false` | Check once and create a missing bucket before upload |
|
|
66
|
+
| `maxAttempts` | `3` | SDK attempts, including the initial request |
|
|
67
|
+
| `retryMode` | `standard` | `standard` or `adaptive` SDK retry mode |
|
|
68
|
+
| `multipartPartSize` | 8 MiB | Part size for unknown-length streams; minimum 5 MiB |
|
|
69
|
+
| `multipartQueueSize` | `2` | Concurrent multipart requests, from 1 through 16 |
|
|
70
|
+
| `useDualstackEndpoint` | `false` | Use AWS dual-stack endpoints |
|
|
71
|
+
| `useFipsEndpoint` | `false` | Use AWS FIPS endpoints |
|
|
72
|
+
| `useArnRegion` | `false` | Resolve an ARN's region |
|
|
73
|
+
| `requestChecksumCalculation` | `WHEN_SUPPORTED` | Request-checksum policy |
|
|
74
|
+
| `responseChecksumValidation` | `WHEN_SUPPORTED` | Response-checksum policy |
|
|
75
|
+
| `disableS3ExpressSessionAuth` | `false` | Disable S3 Express session authentication |
|
|
76
|
+
| `signal` | extension lifecycle signal | Cancel provider operations |
|
|
77
|
+
|
|
78
|
+
Metadata is normalized to lowercase and limited to 100 entries and 2 KiB.
|
|
79
|
+
Unknown-length `ReadableStream` uploads use the pinned AWS multipart uploader;
|
|
80
|
+
failed or aborted uploads cancel their source stream and configure the uploader
|
|
81
|
+
to attempt removal of multipart parts (`leavePartsOnError: false`).
|
|
82
|
+
|
|
83
|
+
Blob IDs use the framework-wide portable alphabet: ASCII letters, digits,
|
|
84
|
+
hyphens, and underscores. Put any provider path hierarchy in `prefix`; IDs with
|
|
85
|
+
slashes, whitespace, query syntax, or Unicode are rejected before transport.
|
|
86
|
+
`BlobRef.url` is populated only when `baseUrl` is configured.
|
|
87
|
+
|
|
88
|
+
`endpoint` and `baseUrl` require HTTPS. Plain HTTP is accepted only for
|
|
89
|
+
`localhost` and loopback IPs so local emulators remain usable without exposing
|
|
90
|
+
payloads or access-key identifiers over an unencrypted remote connection.
|
|
91
|
+
|
|
92
|
+
## Grant capabilities
|
|
93
|
+
|
|
94
|
+
Allow outbound network access to the configured S3 endpoint. The AWS SDK also
|
|
95
|
+
reads these runtime keys for Lambda recursion detection and internal feature
|
|
96
|
+
selection:
|
|
97
|
+
|
|
98
|
+
- `AWS_LAMBDA_BENCHMARK_MODE`
|
|
99
|
+
- `AWS_LAMBDA_FUNCTION_NAME`
|
|
100
|
+
- `AWS_LAMBDA_MAX_CONCURRENCY`
|
|
101
|
+
- `AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA`
|
|
102
|
+
- `AWS_NEW_RETRIES_2026`
|
|
103
|
+
- `AWS_SDK_JS_NODE_VERSION_SUPPORT_WARNING_DISABLED`
|
|
104
|
+
- `SMITHY_NEW_RETRIES_2026`
|
|
105
|
+
- `_X_AMZN_TRACE_ID`
|
|
106
|
+
|
|
107
|
+
If the application reads credentials from environment variables as in the
|
|
108
|
+
example, grant those application-level reads separately.
|
|
109
|
+
|
|
110
|
+
Grant permission to inspect the bucket as well as its objects. An ambiguous S3
|
|
111
|
+
`404` from an object metadata request is verified with `HeadBucket`; Veryfront
|
|
112
|
+
returns `null`/`false` only after proving the bucket still exists. A missing or
|
|
113
|
+
inaccessible bucket remains a provider error.
|
|
114
|
+
|
|
115
|
+
## Verify the extension
|
|
116
|
+
|
|
117
|
+
From the Veryfront repository, run:
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
deno task --cwd extensions/ext-blob-s3 test
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The test task grants only the SDK runtime keys listed above. It exercises both
|
|
124
|
+
single-request and multipart streaming paths through the real SDK middleware.
|
|
125
|
+
|
|
126
|
+
## Migrate from core imports
|
|
127
|
+
|
|
128
|
+
Replace imports from `veryfront/workflow/blob`:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// Before
|
|
132
|
+
import { S3BlobStorage } from "veryfront/workflow/blob";
|
|
133
|
+
|
|
134
|
+
// After
|
|
135
|
+
import { S3BlobStorage } from "@veryfront/ext-blob-s3";
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Prefer `extBlobS3(config)` in application configuration. Direct class
|
|
139
|
+
construction remains available for low-level composition and tests.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Object {
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether an object has a property with the specified name.
|
|
5
|
+
* @param o An object.
|
|
6
|
+
* @param v A property name.
|
|
7
|
+
*/
|
|
8
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=_dnt.polyfills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAeA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd;;;;WAIG;QACH,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;KAC5C;CACF;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
2
|
+
if (!Object.hasOwn) {
|
|
3
|
+
Object.defineProperty(Object, "hasOwn", {
|
|
4
|
+
value: function (object, property) {
|
|
5
|
+
if (object == null) {
|
|
6
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
7
|
+
}
|
|
8
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
9
|
+
},
|
|
10
|
+
configurable: true,
|
|
11
|
+
enumerable: false,
|
|
12
|
+
writable: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
export { crypto, type Crypto, type SubtleCrypto, type AlgorithmIdentifier, type Algorithm, type RsaOaepParams, type BufferSource, type AesCtrParams, type AesCbcParams, type AesGcmParams, type CryptoKey, type KeyAlgorithm, type KeyType, type KeyUsage, type EcdhKeyDeriveParams, type HkdfParams, type HashAlgorithmIdentifier, type Pbkdf2Params, type AesDerivedKeyParams, type HmacImportParams, type JsonWebKey, type RsaOtherPrimesInfo, type KeyFormat, type RsaHashedKeyGenParams, type RsaKeyGenParams, type BigInteger, type EcKeyGenParams, type NamedCurve, type CryptoKeyPair, type AesKeyGenParams, type HmacKeyGenParams, type RsaHashedImportParams, type EcKeyImportParams, type AesKeyAlgorithm, type RsaPssParams, type EcdsaParams } from "@deno/shim-crypto";
|
|
4
|
+
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
5
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno" | "crypto" | "setInterval" | "setTimeout"> & {
|
|
6
|
+
Deno: typeof Deno;
|
|
7
|
+
crypto: import("@deno/shim-crypto").Crypto;
|
|
8
|
+
setInterval: any;
|
|
9
|
+
setTimeout: any;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,mBAAmB,EAAE,KAAK,UAAU,EAAE,KAAK,uBAAuB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,KAAK,SAAS,EAAE,KAAK,qBAAqB,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErvB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ5D,eAAO,MAAM,aAAa;;;;;CAA2C,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
import { crypto } from "@deno/shim-crypto";
|
|
4
|
+
export { crypto } from "@deno/shim-crypto";
|
|
5
|
+
import { setInterval, setTimeout } from "@deno/shim-timers";
|
|
6
|
+
export { setInterval, setTimeout } from "@deno/shim-timers";
|
|
7
|
+
const dntGlobals = {
|
|
8
|
+
Deno,
|
|
9
|
+
crypto,
|
|
10
|
+
setInterval,
|
|
11
|
+
setTimeout,
|
|
12
|
+
};
|
|
13
|
+
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
14
|
+
function createMergeProxy(baseObj, extObj) {
|
|
15
|
+
return new Proxy(baseObj, {
|
|
16
|
+
get(_target, prop, _receiver) {
|
|
17
|
+
if (prop in extObj) {
|
|
18
|
+
return extObj[prop];
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return baseObj[prop];
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
set(_target, prop, value) {
|
|
25
|
+
if (prop in extObj) {
|
|
26
|
+
delete extObj[prop];
|
|
27
|
+
}
|
|
28
|
+
baseObj[prop] = value;
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
deleteProperty(_target, prop) {
|
|
32
|
+
let success = false;
|
|
33
|
+
if (prop in extObj) {
|
|
34
|
+
delete extObj[prop];
|
|
35
|
+
success = true;
|
|
36
|
+
}
|
|
37
|
+
if (prop in baseObj) {
|
|
38
|
+
delete baseObj[prop];
|
|
39
|
+
success = true;
|
|
40
|
+
}
|
|
41
|
+
return success;
|
|
42
|
+
},
|
|
43
|
+
ownKeys(_target) {
|
|
44
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
45
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
46
|
+
const extKeysSet = new Set(extKeys);
|
|
47
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
48
|
+
},
|
|
49
|
+
defineProperty(_target, prop, desc) {
|
|
50
|
+
if (prop in extObj) {
|
|
51
|
+
delete extObj[prop];
|
|
52
|
+
}
|
|
53
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
54
|
+
return true;
|
|
55
|
+
},
|
|
56
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
57
|
+
if (prop in extObj) {
|
|
58
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
has(_target, prop) {
|
|
65
|
+
return prop in extObj || prop in baseObj;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS S3 implementation of Veryfront's first-party `BlobStorage` contract.
|
|
3
|
+
*
|
|
4
|
+
* @module extensions/ext-blob-s3
|
|
5
|
+
*/
|
|
6
|
+
import "./_dnt.polyfills.js";
|
|
7
|
+
import { type Extension } from "veryfront/extensions";
|
|
8
|
+
import { type S3BlobStorageConfig } from "./s3-storage.js";
|
|
9
|
+
/** Create an explicitly configured S3 blob-storage extension. */
|
|
10
|
+
export declare const extBlobS3: (config: S3BlobStorageConfig) => Extension;
|
|
11
|
+
export default extBlobS3;
|
|
12
|
+
export { S3BlobStorage } from "./s3-storage.js";
|
|
13
|
+
export type { S3BlobStorageClient, S3BlobStorageCommand, S3BlobStorageConfig, S3BlobStorageDependencies, S3BlobStorageSendOptions, } from "./s3-storage.js";
|
|
14
|
+
export type { S3BlobStorageStreamUploader, S3BlobStorageStreamUploadInput, } from "./multipart-upload.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,qBAAqB,CAAC;AAG7B,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3E,OAAO,EAAiB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,iEAAiE;AACjE,eAAO,MAAM,SAAS,GAAI,QAAQ,mBAAmB,KAAG,SA0FvD,CAAC;AAEF,eAAe,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,uBAAuB,CAAC"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS S3 implementation of Veryfront's first-party `BlobStorage` contract.
|
|
3
|
+
*
|
|
4
|
+
* @module extensions/ext-blob-s3
|
|
5
|
+
*/
|
|
6
|
+
import "./_dnt.polyfills.js";
|
|
7
|
+
import { composeAbortSignals } from "veryfront/extensions";
|
|
8
|
+
import { BlobStorageContractName } from "veryfront/workflow/blob";
|
|
9
|
+
import { S3BlobStorage } from "./s3-storage.js";
|
|
10
|
+
/** Create an explicitly configured S3 blob-storage extension. */
|
|
11
|
+
export const extBlobS3 = (config) => {
|
|
12
|
+
const selectedConfig = { ...config };
|
|
13
|
+
let activeGeneration;
|
|
14
|
+
let retiringGeneration;
|
|
15
|
+
return {
|
|
16
|
+
name: "ext-blob-s3",
|
|
17
|
+
version: "0.1.0",
|
|
18
|
+
contracts: {
|
|
19
|
+
provides: ["BlobStorage"],
|
|
20
|
+
},
|
|
21
|
+
capabilities: [
|
|
22
|
+
{ type: "net:outbound", hosts: ["*"] },
|
|
23
|
+
{
|
|
24
|
+
type: "env:read",
|
|
25
|
+
keys: [
|
|
26
|
+
"AWS_LAMBDA_BENCHMARK_MODE",
|
|
27
|
+
"AWS_LAMBDA_FUNCTION_NAME",
|
|
28
|
+
"AWS_LAMBDA_MAX_CONCURRENCY",
|
|
29
|
+
"AWS_LAMBDA_NODEJS_NO_GLOBAL_AWSLAMBDA",
|
|
30
|
+
"AWS_NEW_RETRIES_2026",
|
|
31
|
+
"AWS_SDK_JS_NODE_VERSION_SUPPORT_WARNING_DISABLED",
|
|
32
|
+
"SMITHY_NEW_RETRIES_2026",
|
|
33
|
+
"_X_AMZN_TRACE_ID",
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
setup(ctx) {
|
|
38
|
+
if (activeGeneration)
|
|
39
|
+
throw new Error("ext-blob-s3 is already set up");
|
|
40
|
+
if (retiringGeneration) {
|
|
41
|
+
throw new Error("ext-blob-s3 teardown has not completed");
|
|
42
|
+
}
|
|
43
|
+
selectedConfig.signal?.throwIfAborted();
|
|
44
|
+
ctx.signal?.throwIfAborted();
|
|
45
|
+
const controller = new AbortController();
|
|
46
|
+
const signal = composeAbortSignals([
|
|
47
|
+
controller.signal,
|
|
48
|
+
...(selectedConfig.signal ? [selectedConfig.signal] : []),
|
|
49
|
+
...(ctx.signal ? [ctx.signal] : []),
|
|
50
|
+
]);
|
|
51
|
+
const generation = {
|
|
52
|
+
controller,
|
|
53
|
+
storage: new S3BlobStorage({ ...selectedConfig, signal }),
|
|
54
|
+
};
|
|
55
|
+
try {
|
|
56
|
+
signal.throwIfAborted();
|
|
57
|
+
ctx.provide(BlobStorageContractName, generation.storage);
|
|
58
|
+
signal.throwIfAborted();
|
|
59
|
+
activeGeneration = generation;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (!controller.signal.aborted) {
|
|
63
|
+
controller.abort(new DOMException("S3 blob extension setup failed.", "AbortError"));
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
generation.storage.close();
|
|
67
|
+
}
|
|
68
|
+
catch (rollbackError) {
|
|
69
|
+
retiringGeneration = generation;
|
|
70
|
+
throw new AggregateError([error, rollbackError], "ext-blob-s3 setup failed and resource rollback was incomplete");
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
ctx.logger.debug("[ext-blob-s3] BlobStorage registered");
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
// Diagnostics must not invalidate a successfully registered provider.
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
teardown() {
|
|
82
|
+
const generation = retiringGeneration ?? activeGeneration;
|
|
83
|
+
if (!generation)
|
|
84
|
+
return;
|
|
85
|
+
if (activeGeneration === generation) {
|
|
86
|
+
activeGeneration = undefined;
|
|
87
|
+
retiringGeneration = generation;
|
|
88
|
+
if (!generation.controller.signal.aborted) {
|
|
89
|
+
generation.controller.abort(new DOMException("S3 blob extension is shutting down.", "AbortError"));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
generation.storage.close();
|
|
93
|
+
if (retiringGeneration === generation)
|
|
94
|
+
retiringGeneration = undefined;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export default extBlobS3;
|
|
99
|
+
export { S3BlobStorage } from "./s3-storage.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { S3Client } from "@aws-sdk/client-s3";
|
|
2
|
+
export declare const MIN_MULTIPART_PART_SIZE: number;
|
|
3
|
+
export declare const DEFAULT_MULTIPART_PART_SIZE: number;
|
|
4
|
+
export declare const MAX_MULTIPART_PART_SIZE: number;
|
|
5
|
+
export declare const DEFAULT_MULTIPART_QUEUE_SIZE = 2;
|
|
6
|
+
export declare const MAX_MULTIPART_QUEUE_SIZE = 16;
|
|
7
|
+
export interface S3BlobStorageStreamUploadInput {
|
|
8
|
+
readonly bucket: string;
|
|
9
|
+
readonly key: string;
|
|
10
|
+
readonly stream: ReadableStream;
|
|
11
|
+
readonly mimeType: string;
|
|
12
|
+
readonly expiresAt?: Date;
|
|
13
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
14
|
+
readonly partSize: number;
|
|
15
|
+
readonly queueSize: number;
|
|
16
|
+
readonly signal?: AbortSignal;
|
|
17
|
+
}
|
|
18
|
+
export interface S3BlobStorageStreamUploader {
|
|
19
|
+
upload(input: S3BlobStorageStreamUploadInput): Promise<number>;
|
|
20
|
+
}
|
|
21
|
+
/** Create the official AWS multipart adapter for unknown-length Web streams. */
|
|
22
|
+
export declare function createS3BlobStorageStreamUploader(client: S3Client): S3BlobStorageStreamUploader;
|
|
23
|
+
//# sourceMappingURL=multipart-upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipart-upload.d.ts","sourceRoot":"","sources":["../src/multipart-upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK1E,eAAO,MAAM,uBAAuB,QAAkB,CAAC;AACvD,eAAO,MAAM,2BAA2B,QAAkB,CAAC;AAC3D,eAAO,MAAM,uBAAuB,QAAoB,CAAC;AACzD,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAC9C,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAE3C,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAChE;AA0JD,gFAAgF;AAChF,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,QAAQ,GAAG,2BAA2B,CAI/F"}
|