@usehenri/s3 0.0.0 → 1.2.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/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ # @usehenri/s3
2
+
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#407](https://github.com/usehenri/henri/pull/407) [`de1c1e0`](https://github.com/usehenri/henri/commit/de1c1e02ed83d13dcfeb8e44012f309eb663f03e) Thanks [@reel](https://github.com/reel)! - Uploads that survive a second machine: an object store, signed urls and variants
8
+
9
+ `@usehenri/uploads` shipped one backend — the local disk — and said `url()`
10
+ was allowed to answer `null` forever. Two application processes on two
11
+ machines therefore did not share uploads at all, a link to a stored file
12
+ meant writing a controller and a route for every one of them, and a
13
+ thumbnail meant leaving the framework entirely. All three are closed here.
14
+
15
+ **`@usehenri/s3`, a new package.** `config.uploads.storage` takes an object
16
+ now (`{ "adapter": "s3", "bucket": "…", "region": "…" }`, the shape
17
+ `config.shared` and a store already have) and `s3` resolves the package from
18
+ the application. One backend speaks to S3, R2, Spaces, MinIO and GCS's
19
+ interoperability mode; what tells them apart is an endpoint and a region. It
20
+ carries no dependency but `debug` — AWS Signature Version 4 is two hundred
21
+ lines of `node:crypto`, checked against the vectors AWS publishes. Every
22
+ safety property survives the move: the key is generated and refused if it is
23
+ not, the type still comes from the bytes and becomes the object's
24
+ `Content-Type`, the original name is metadata, and a part still lands on a
25
+ private local file that only `store()` promotes.
26
+
27
+ **Signed urls.** `henri.uploads.url(record, { expiresIn, disposition,
28
+ filename, type })` is one call whatever the backend: the provider's own
29
+ signature on an object store, henri's own (an HMAC over the key, the expiry,
30
+ the disposition, the name and the type, verified by a route it mounts) on
31
+ the local disk. Neither can be edited to name another object, widened, or
32
+ replayed past its expiry. Until then a signed url **is** a bearer
33
+ capability, so `config.uploads.urls` is off by default and `url()` refuses
34
+ with `HENRI_UPLOAD_URLS_DISABLED` rather than answering `null`.
35
+ `uploads.urls.cdn` puts a cache in front of henri's own, whose signature
36
+ deliberately does not cover the host.
37
+
38
+ **Variants.** `config.uploads.variants` declares them by name and
39
+ `henri.uploads.variant(record, 'thumb')` answers a record like any other.
40
+ The key is the source's plus a digest of the variant's terms, so the work
41
+ happens once, on demand, and never in the request that uploaded. `sharp` is
42
+ an **optional peer dependency** resolved from the application: without it
43
+ `variant()` refuses with `HENRI_UPLOAD_NO_IMAGE_LIBRARY` and the install
44
+ line rather than quietly answering the original, and `henri doctor` reports
45
+ it. A name never comes from a request, an SVG is refused, a source is
46
+ bounded at fifty megapixels and one frame, no metadata is carried forward,
47
+ and what the resize produced is sniffed before it is stored.
48
+
49
+ New configuration: `uploads.storage` in its object form, `uploads.urls`
50
+ (`expiresIn`, `path`, `cdn`) and `uploads.variants`. New codes:
51
+ `HENRI_UPLOAD_NO_IMAGE_LIBRARY`, `HENRI_UPLOAD_STORAGE_FAILED`,
52
+ `HENRI_UPLOAD_STORAGE_MISCONFIGURED`, `HENRI_UPLOAD_URLS_DISABLED`,
53
+ `HENRI_UPLOAD_URL_EXPIRED`, `HENRI_UPLOAD_URL_INVALID`,
54
+ `HENRI_UPLOAD_VARIANT_FAILED`, `HENRI_UPLOAD_VARIANT_UNKNOWN`,
55
+ `HENRI_UPLOAD_VARIANT_UNSUPPORTED`. `henri doctor` asks for
56
+ `@usehenri/s3` and `sharp` when the configuration names them.
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [[`68fe3af`](https://github.com/usehenri/henri/commit/68fe3afa8bdaa6d9a95d0e60858fd4abe28028b2), [`1a86acb`](https://github.com/usehenri/henri/commit/1a86acbf15e4a43e5fb81277bb22e101c06e77a4), [`de1c1e0`](https://github.com/usehenri/henri/commit/de1c1e02ed83d13dcfeb8e44012f309eb663f03e)]:
61
+ - @usehenri/uploads@1.2.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present, Félix-Antoine Paradis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,10 @@
1
+ <!-- generated by scripts/prepublish.js -->
2
+
1
3
  # @usehenri/s3
2
4
 
3
- Placeholder release. Install a real version: see https://usehenri.io.
5
+ Henri uploads on an object store: one S3-compatible backend for S3, R2, Spaces and MinIO, with presigned urls.
6
+
7
+ Part of [henri](https://usehenri.io), the Rails-like React framework for
8
+ Node.js: [documentation](https://usehenri.io),
9
+ [source and issues](https://github.com/usehenri/henri),
10
+ [changelog](https://github.com/usehenri/henri/blob/master/packages/s3/CHANGELOG.md).
package/index.js ADDED
@@ -0,0 +1,36 @@
1
+ /**
2
+ * `@usehenri/s3`: uploads on an object store.
3
+ *
4
+ * ```json
5
+ * {
6
+ * "uploads": {
7
+ * "storage": {
8
+ * "adapter": "s3",
9
+ * "bucket": "henri-uploads",
10
+ * "region": "us-east-1"
11
+ * }
12
+ * }
13
+ * }
14
+ * ```
15
+ *
16
+ * `@usehenri/uploads` resolves this package from the application the way
17
+ * core resolves `@usehenri/redis` for `config.shared`, and constructs the
18
+ * default export with the block. One backend speaks to S3, R2, Spaces,
19
+ * MinIO and GCS's interoperability mode: what tells them apart is the
20
+ * endpoint and the region.
21
+ *
22
+ * See https://usehenri.io/guides/uploads/
23
+ */
24
+ const S3Storage = require('./src/storage');
25
+
26
+ const { S3Client } = require('./src/client');
27
+ const { StorageError, coded } = require('./src/errors');
28
+ const { presign, sign } = require('./src/signature');
29
+
30
+ module.exports = S3Storage;
31
+ module.exports.S3Client = S3Client;
32
+ module.exports.S3Storage = S3Storage;
33
+ module.exports.StorageError = StorageError;
34
+ module.exports.coded = coded;
35
+ module.exports.presign = presign;
36
+ module.exports.sign = sign;
package/package.json CHANGED
@@ -1,15 +1,47 @@
1
1
  {
2
- "description": "Placeholder creating @usehenri/s3 on npm; the first real version is published by the henri release workflow",
3
- "homepage": "https://usehenri.io",
4
- "license": "MIT",
5
2
  "name": "@usehenri/s3",
6
- "publishConfig": {
7
- "access": "public"
8
- },
3
+ "version": "1.2.0",
4
+ "description": "henri uploads on an object store: one S3-compatible backend for S3, R2, Spaces and MinIO, with presigned urls",
5
+ "license": "MIT",
6
+ "author": "Felix-Antoine Paradis",
7
+ "homepage": "https://usehenri.io",
9
8
  "repository": {
10
- "directory": "packages/s3",
11
9
  "type": "git",
12
- "url": "git+https://github.com/usehenri/henri.git"
10
+ "url": "git+https://github.com/usehenri/henri.git",
11
+ "directory": "packages/s3"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/usehenri/henri/issues"
15
+ },
16
+ "keywords": [
17
+ "henri",
18
+ "uploads",
19
+ "s3",
20
+ "storage",
21
+ "r2",
22
+ "minio",
23
+ "presigned"
24
+ ],
25
+ "main": "index.js",
26
+ "files": [
27
+ "index.js",
28
+ "src",
29
+ "CHANGELOG.md"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public",
33
+ "provenance": true
34
+ },
35
+ "engines": {
36
+ "node": ">=22"
37
+ },
38
+ "dependencies": {
39
+ "debug": "^4.4.3"
40
+ },
41
+ "peerDependencies": {
42
+ "@usehenri/uploads": "^1.2.0"
13
43
  },
14
- "version": "0.0.0"
15
- }
44
+ "devDependencies": {
45
+ "@usehenri/uploads": "^1.2.0"
46
+ }
47
+ }