@gusto/baerly-storage 0.5.0 → 0.6.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/dist/API.md +3 -2
- package/dist/CHANGELOG.md +82 -0
- package/dist/THIRD-PARTY-LICENSES.txt +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/aws4fetch.esm-CXE5ZbAa.js +460 -0
- package/dist/aws4fetch.esm-CXE5ZbAa.js.map +1 -0
- package/dist/baerly.js +10 -10
- package/dist/baerly.spec.json +1 -1
- package/dist/client-react.d.ts +2 -2
- package/dist/{client-Fe8CwB73.d.ts → client-ypCm3zjt.d.ts} +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/{cloudflare-DzKBrUlg.js → cloudflare-wrVYf4bb.js} +457 -56
- package/dist/cloudflare-wrVYf4bb.js.map +1 -0
- package/dist/cloudflare.d.ts +3 -3
- package/dist/cloudflare.js +5 -5
- package/dist/{config-1tv0-Yzm.js → config-B6nTy8e2.js} +435 -33
- package/dist/config-B6nTy8e2.js.map +1 -0
- package/dist/constants-CfeMWQWk.js.map +1 -1
- package/dist/{cost-DSMIVqzL.js → cost-_SE_SVgZ.js} +4 -4
- package/dist/{cost-DSMIVqzL.js.map → cost-_SE_SVgZ.js.map} +1 -1
- package/dist/{db-DsPkOVEH.d.ts → db-DjjthkTi.d.ts} +2 -2
- package/dist/{deploy-DonTr-CV.js → deploy-Di_Q01qx.js} +5 -5
- package/dist/deploy-Di_Q01qx.js.map +1 -0
- package/dist/dev-vite.d.ts +31 -27
- package/dist/dev-vite.js +60 -30
- package/dist/dev-vite.js.map +1 -1
- package/dist/dev.d.ts +1 -1
- package/dist/doctor-RWVRpvat.js +102 -0
- package/dist/doctor-RWVRpvat.js.map +1 -0
- package/dist/{dump-Bh5k26VQ.js → dump-m2vEYDNY.js} +4 -4
- package/dist/{dump-Bh5k26VQ.js.map → dump-m2vEYDNY.js.map} +1 -1
- package/dist/{export-DtF5tDIM.js → export-DenKwEQu.js} +4 -4
- package/dist/{export-DtF5tDIM.js.map → export-DenKwEQu.js.map} +1 -1
- package/dist/{fsck-D_djMO5D.js → fsck-2Vq-7-e2.js} +5 -5
- package/dist/{fsck-D_djMO5D.js.map → fsck-2Vq-7-e2.js.map} +1 -1
- package/dist/gcs-admin-Bx6xSNJj.d.ts +123 -0
- package/dist/gcs.d.ts +18 -0
- package/dist/gcs.js +2 -0
- package/dist/goog4-signer-Z7KnJ1su.js +321 -0
- package/dist/goog4-signer-Z7KnJ1su.js.map +1 -0
- package/dist/{http-DGd5tbNs.js → http-7zT29K3P.js} +4 -4
- package/dist/{http-DGd5tbNs.js.map → http-7zT29K3P.js.map} +1 -1
- package/dist/{aws4fetch.esm-p7eEzLCs.js → http-transport-BTgVCY5r.js} +24 -476
- package/dist/http-transport-BTgVCY5r.js.map +1 -0
- package/dist/http.d.ts +2 -2
- package/dist/http.js +2 -2
- package/dist/{index-BNRh23K9.d.ts → index-BHz92Acj.d.ts} +2 -2
- package/dist/{index-BYk9oCNf.d.ts → index-CEZKQsKt.d.ts} +3 -2
- package/dist/{index-CuA9Mi3K.d.ts → index-DP3ClvcA.d.ts} +7 -7
- package/dist/{index-0rZcMBwy.d.ts → index-uE-w2dgj.d.ts} +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{inspect-6WZ-pC7-.js → inspect-BpYbH1DM.js} +5 -5
- package/dist/{inspect-6WZ-pC7-.js.map → inspect-BpYbH1DM.js.map} +1 -1
- package/dist/{log-tail-D98U1JBo.js → log-tail-QWU4wlu-.js} +3 -11
- package/dist/log-tail-QWU4wlu-.js.map +1 -0
- package/dist/{maintenance-B_e0T99L.d.ts → maintenance-BGHGt2Yg.d.ts} +2 -2
- package/dist/{maintenance-B4Dki6Ig.js → maintenance-DULFcpd1.js} +4 -17
- package/dist/maintenance-DULFcpd1.js.map +1 -0
- package/dist/{maintenance-C7coQp4c.js → maintenance-fEi-UZ2o.js} +5 -11
- package/dist/maintenance-fEi-UZ2o.js.map +1 -0
- package/dist/maintenance.d.ts +1 -1
- package/dist/maintenance.js +1 -1
- package/dist/node.d.ts +21 -60
- package/dist/node.js +4 -3
- package/dist/{observability-BmflLCdF.js → observability-Ch-VQJyE.js} +38 -16
- package/dist/{observability-BmflLCdF.js.map → observability-Ch-VQJyE.js.map} +1 -1
- package/dist/observability.d.ts +2 -2
- package/dist/observability.js +1 -1
- package/dist/{plan-a7PJHBCy.js → plan-C4qgiXSg.js} +2 -2
- package/dist/{plan-a7PJHBCy.js.map → plan-C4qgiXSg.js.map} +1 -1
- package/dist/{query-rAtXNQQB.js → query-C43r-6ib.js} +2 -2
- package/dist/{query-rAtXNQQB.js.map → query-C43r-6ib.js.map} +1 -1
- package/dist/{rebuild-index-BVzQSZlm.js → rebuild-index-BH1dc1p6.js} +4 -4
- package/dist/{rebuild-index-BVzQSZlm.js.map → rebuild-index-BH1dc1p6.js.map} +1 -1
- package/dist/{restore-R-4rbciV.js → restore-D0VYWzfP.js} +5 -5
- package/dist/{restore-R-4rbciV.js.map → restore-D0VYWzfP.js.map} +1 -1
- package/dist/{runtime-spec-Dsw2-n8S.js → runtime-spec--LykAdl1.js} +2 -2
- package/dist/{runtime-spec-Dsw2-n8S.js.map → runtime-spec--LykAdl1.js.map} +1 -1
- package/dist/{s3-http-B-z8th6O.d.ts → s3-http-DD5gDc7t.d.ts} +6 -4
- package/dist/s3.d.ts +1 -1
- package/dist/s3.js +1 -1
- package/dist/sha256-CqcKTjw9.js +22 -0
- package/dist/sha256-CqcKTjw9.js.map +1 -0
- package/dist/{src-BL_JoPTn.js → src-BMFfDUI2.js} +68 -28
- package/dist/{src-BL_JoPTn.js.map → src-BMFfDUI2.js.map} +1 -1
- package/dist/{src-CYHFDrKz.js → src-DvbTEya2.js} +3 -3
- package/dist/{src-CYHFDrKz.js.map → src-DvbTEya2.js.map} +1 -1
- package/dist/{subcommand-DoDA-K7d.js → subcommand-BV68pqwJ.js} +2 -2
- package/dist/{subcommand-DoDA-K7d.js.map → subcommand-BV68pqwJ.js.map} +1 -1
- package/dist/{usage-DBV1eQHC.js → usage-BMZR8o6U.js} +3 -3
- package/dist/{usage-DBV1eQHC.js.map → usage-BMZR8o6U.js.map} +1 -1
- package/package.json +10 -4
- package/dist/aws4fetch.esm-p7eEzLCs.js.map +0 -1
- package/dist/cloudflare-DzKBrUlg.js.map +0 -1
- package/dist/config-1tv0-Yzm.js.map +0 -1
- package/dist/deploy-DonTr-CV.js.map +0 -1
- package/dist/doctor-DSIyCDg_.js +0 -346
- package/dist/doctor-DSIyCDg_.js.map +0 -1
- package/dist/log-tail-D98U1JBo.js.map +0 -1
- package/dist/maintenance-B4Dki6Ig.js.map +0 -1
- package/dist/maintenance-C7coQp4c.js.map +0 -1
package/dist/API.md
CHANGED
|
@@ -749,8 +749,9 @@ export default baerlyWorker(() => ({ config }));
|
|
|
749
749
|
|
|
750
750
|
`s3Storage` / `r2Storage` / `minioStorage` / `gcsStorage` from
|
|
751
751
|
`@gusto/baerly-storage/node` are re-exports of one factory family — same
|
|
752
|
-
shape (bucket + credentials), all hide
|
|
753
|
-
behind the package
|
|
752
|
+
shape (bucket + credentials), all hide their request signer (SigV4 for
|
|
753
|
+
S3/R2/MinIO, GOOG4-HMAC for GCS) and XML parsing behind the package
|
|
754
|
+
boundary.
|
|
754
755
|
|
|
755
756
|
### Verifier presets
|
|
756
757
|
|
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,87 @@
|
|
|
1
1
|
# @gusto/baerly-storage
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c806852: `baerlyDev` can now load `baerly.config` itself instead of requiring the caller
|
|
8
|
+
to import it and pass the object.
|
|
9
|
+
|
|
10
|
+
`BaerlyDevOptions.config` is now optional; two new resolution modes:
|
|
11
|
+
|
|
12
|
+
- `configPath` — absolute path to the config module, loaded lazily at
|
|
13
|
+
dev-server startup via Vite's `ssrLoadModule`.
|
|
14
|
+
- **convention** (nothing passed) — loads `<viteRoot>/src/baerly.config.ts`,
|
|
15
|
+
mirroring how `reactRouter()` loads `react-router.config.ts`.
|
|
16
|
+
|
|
17
|
+
Passing an explicit `config` object still works and is unchanged, including
|
|
18
|
+
fail-fast verifier resolution at factory time.
|
|
19
|
+
|
|
20
|
+
**Why:** when an app's `vite.config.ts` imports its `baerly.config` to pass the
|
|
21
|
+
object in, Nx's `@nx/vite` / `@nx/vitest` inference plugins bundle that config
|
|
22
|
+
during project-graph creation, dragging the config module's transitive imports
|
|
23
|
+
(`@gusto/baerly-storage/config`, `zod`) into the config bundle. Those fail to
|
|
24
|
+
resolve in CI and crash graph creation, forcing every baerly app into the root
|
|
25
|
+
`nx.json` inference-plugin exclusion lists — a global edit that marks the whole
|
|
26
|
+
monorepo affected. Letting `baerlyDev` load the config itself keeps the caller's
|
|
27
|
+
`vite.config` import-free, so the exclusion is no longer needed.
|
|
28
|
+
|
|
29
|
+
- 6336a06: Native Google Cloud Storage adapter: `gcsStorage` now drives GCS's own
|
|
30
|
+
generation-precondition conditional writes over the native XML API
|
|
31
|
+
(`x-goog-if-generation-match`), promoting GCS to a Tier-1 backend.
|
|
32
|
+
|
|
33
|
+
**Migration.** The `gcsStorage({ bucket, credentials })` signature is
|
|
34
|
+
unchanged, so existing callers keep compiling. What changes is the wire
|
|
35
|
+
behavior: the factory previously produced an S3-interop client whose
|
|
36
|
+
conditional headers GCS silently ignored on writes (it could not
|
|
37
|
+
linearize the commit log and was unsupported); it now speaks the native
|
|
38
|
+
GCS XML API and gains real create-if-absent + CAS, returning `412` →
|
|
39
|
+
`Conflict` on a lost write. Credentials remain GCS HMAC interop keys
|
|
40
|
+
(`accessKeyId` / `secretAccessKey`). Node host only — no Worker `/gcs`
|
|
41
|
+
subpath and no GCP deploy target in v1.
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 8322ce2: Canonical HTTP log lines now classify by wire status alone: any 4xx is
|
|
46
|
+
`warn`, not `error`, even when a structured error is attached. Previously
|
|
47
|
+
an attached error forced `error` level regardless of status, so a
|
|
48
|
+
`409 Conflict` logged at `error`.
|
|
49
|
+
|
|
50
|
+
**Why:** a 4xx is the caller's fault, not a server fault. The reachable
|
|
51
|
+
409 is a duplicate-`_id` insert (a reused id or a double-submitted POST);
|
|
52
|
+
ordinary storage write contention is absorbed internally by the log
|
|
53
|
+
forward-probe and never reaches the client as a 409. Logging these at
|
|
54
|
+
`error` polluted error budgets and could page on-call for normal
|
|
55
|
+
operation. `error` is now reserved for genuine server faults: 5xx, a
|
|
56
|
+
2xx/3xx that anomalously carries an error, or a thrown error with no wire
|
|
57
|
+
status to classify by. The line still carries the structured
|
|
58
|
+
`{ code, message }` on the failure path; only the stack (unneeded for a
|
|
59
|
+
routine client error) drops off at `warn`.
|
|
60
|
+
|
|
61
|
+
- a1cd0a3: Bump `@logtape/logtape` 2.2.2 → 2.2.4 to pick up the upstream fix for the
|
|
62
|
+
`configure()` process exit-listener leak ([dahlia/logtape#192](https://github.com/dahlia/logtape/issues/192)).
|
|
63
|
+
Previously each `configure()` registered a new `process.on("exit", …)` hook
|
|
64
|
+
without removing the prior one; 2.2.4 unregisters the previous dispose hook
|
|
65
|
+
before registering a new one. Production adapters call `configureObservability`
|
|
66
|
+
once so nothing shipped broken, but repeated reconfiguration in one process
|
|
67
|
+
(test suites, hot-reload) no longer leaks listeners. No public API changes.
|
|
68
|
+
|
|
69
|
+
- 3387380: S3/GCS adapter `delete()` now surfaces an unexpected non-2xx/404 status
|
|
70
|
+
as an error instead of silently treating it as success. `200`/`204`/`404`
|
|
71
|
+
stay a success (delete is idempotent; a `404` is a no-op); anything else
|
|
72
|
+
maps through the shared classifier (`403` → `AccessDenied`; `429` and
|
|
73
|
+
`≥500` → retryable `NetworkError`; anything else → `InvalidResponse`).
|
|
74
|
+
|
|
75
|
+
**Why:** the previous inline path swallowed every non-2xx as success, so
|
|
76
|
+
a `403` on delete during GC/compaction looked like it removed an object
|
|
77
|
+
it never touched — the bucket would grow while maintenance reported
|
|
78
|
+
success. Surfacing the status is a correctness fix. It is safe on the
|
|
79
|
+
write path: GC deletes in parallel and a thrown delete aborts only the
|
|
80
|
+
rest of that sweep (landed deletes are durable, `pending.json` is
|
|
81
|
+
CAS-merged), and the maintenance runner already swallows every
|
|
82
|
+
non-`Conflict` throw after counting + logging it, so a delete error never
|
|
83
|
+
propagates to crash a write-tick.
|
|
84
|
+
|
|
3
85
|
## 0.5.0
|
|
4
86
|
|
|
5
87
|
### Minor Changes
|
|
@@ -36,7 +36,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
36
36
|
SOFTWARE.
|
|
37
37
|
|
|
38
38
|
==============================================================================
|
|
39
|
-
@logtape/logtape@2.2.
|
|
39
|
+
@logtape/logtape@2.2.4
|
|
40
40
|
License: MIT
|
|
41
41
|
Repository: git+https://github.com/dahlia/logtape.git
|
|
42
42
|
|
package/dist/auth.d.ts
CHANGED
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
import { g as RATE_LIMIT_BACKOFF_MILLIS } from "./constants-CfeMWQWk.js";
|
|
2
|
+
import { t as BaerlyError } from "./errors-Dfa3p78c.js";
|
|
3
|
+
import { t as assertValidStorageKey } from "./key-Di6yyxFu.js";
|
|
4
|
+
import { t as delay } from "./time-DUqvFMHq.js";
|
|
5
|
+
import { i as retryAfterCause, n as parseRetryAfter, o as parseListObjectsV2CommandOutput, r as retry, t as mapStorageError } from "./http-transport-BTgVCY5r.js";
|
|
6
|
+
//#region packages/adapter-node/src/s3-http.ts
|
|
7
|
+
/**
|
|
8
|
+
* `Storage` impl that speaks the S3 REST API directly. Works against
|
|
9
|
+
* any S3-compatible endpoint — AWS S3, R2 (S3-compat), Minio. Does not
|
|
10
|
+
* depend on any AWS SDK. GCS is NOT supported over this S3-interop path
|
|
11
|
+
* (its conditional-write semantics can't linearize the commit log); use
|
|
12
|
+
* the native `GcsHttpStorage` adapter instead.
|
|
13
|
+
*
|
|
14
|
+
* Authentication is plugged in via the `sign` callback; this class
|
|
15
|
+
* itself does no SigV4. For Cloudflare Workers, the R2 binding fast
|
|
16
|
+
* path lives in `@baerly/adapter-cloudflare`.
|
|
17
|
+
*/
|
|
18
|
+
var S3HttpStorage = class {
|
|
19
|
+
#endpoint;
|
|
20
|
+
#bucket;
|
|
21
|
+
#fetch;
|
|
22
|
+
#sign;
|
|
23
|
+
#retries;
|
|
24
|
+
#backoffMs;
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.#endpoint = options.endpoint.replace(/\/+$/, "");
|
|
27
|
+
this.#bucket = options.bucket;
|
|
28
|
+
this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
29
|
+
this.#sign = options.sign;
|
|
30
|
+
this.#retries = options.retries ?? 8;
|
|
31
|
+
this.#backoffMs = options.backoffMs ?? 100;
|
|
32
|
+
}
|
|
33
|
+
#objectUrl(key, versionId) {
|
|
34
|
+
assertValidStorageKey(key);
|
|
35
|
+
const base = `${this.#endpoint}/${this.#bucket}/${encodeURIComponent(key)}`;
|
|
36
|
+
return versionId !== void 0 ? `${base}?versionId=${encodeURIComponent(versionId)}` : base;
|
|
37
|
+
}
|
|
38
|
+
async #dispatch(req) {
|
|
39
|
+
const signed = this.#sign ? await this.#sign(req) : req;
|
|
40
|
+
try {
|
|
41
|
+
return await this.#fetch(signed);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
if (error instanceof BaerlyError) throw error;
|
|
44
|
+
throw new BaerlyError("NetworkError", error instanceof Error ? error.message : String(error), error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
#retry(fn) {
|
|
48
|
+
return retry(fn, {
|
|
49
|
+
retries: this.#retries,
|
|
50
|
+
backoffMs: this.#backoffMs
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async get(key, opts) {
|
|
54
|
+
opts?.signal?.throwIfAborted();
|
|
55
|
+
const url = this.#objectUrl(key, opts?.versionId);
|
|
56
|
+
const headers = new Headers();
|
|
57
|
+
if (opts?.ifNoneMatch !== void 0) headers.set("If-None-Match", opts.ifNoneMatch);
|
|
58
|
+
return this.#retry(async () => {
|
|
59
|
+
const res = await this.#dispatch(new Request(url, {
|
|
60
|
+
method: "GET",
|
|
61
|
+
headers,
|
|
62
|
+
signal: opts?.signal ?? null
|
|
63
|
+
}));
|
|
64
|
+
switch (res.status) {
|
|
65
|
+
case 200: {
|
|
66
|
+
const etag = res.headers.get("ETag");
|
|
67
|
+
if (etag === null) throw new BaerlyError("InvalidResponse", `GET ${key}: missing ETag`);
|
|
68
|
+
const body = new Uint8Array(await res.arrayBuffer());
|
|
69
|
+
const versionId = res.headers.get("x-amz-version-id") ?? void 0;
|
|
70
|
+
return versionId !== void 0 ? {
|
|
71
|
+
body,
|
|
72
|
+
etag,
|
|
73
|
+
versionId
|
|
74
|
+
} : {
|
|
75
|
+
body,
|
|
76
|
+
etag
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
case 304:
|
|
80
|
+
case 404: return null;
|
|
81
|
+
default: throw await mapStorageError(res, "GET", key);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async put(key, body, opts) {
|
|
86
|
+
opts?.signal?.throwIfAborted();
|
|
87
|
+
const url = this.#objectUrl(key);
|
|
88
|
+
const headers = new Headers();
|
|
89
|
+
headers.set("Content-Type", opts?.contentType ?? "application/octet-stream");
|
|
90
|
+
if (opts?.ifMatch !== void 0) headers.set("If-Match", opts.ifMatch);
|
|
91
|
+
if (opts?.ifNoneMatch === "*") headers.set("If-None-Match", "*");
|
|
92
|
+
return this.#retry(async () => {
|
|
93
|
+
const res = await this.#dispatch(new Request(url, {
|
|
94
|
+
method: "PUT",
|
|
95
|
+
headers,
|
|
96
|
+
body,
|
|
97
|
+
signal: opts?.signal ?? null
|
|
98
|
+
}));
|
|
99
|
+
if (res.status === 412) throw new BaerlyError("Conflict", `PUT ${key}: precondition failed`);
|
|
100
|
+
if (res.status === 409 && opts?.ifNoneMatch === "*") throw new BaerlyError("NetworkError", `PUT ${key}: 409 ConditionalRequestConflict (contended conditional create; retryable)`, {
|
|
101
|
+
status: res.status,
|
|
102
|
+
...retryAfterCause(res)
|
|
103
|
+
});
|
|
104
|
+
if (res.status === 404 && opts?.ifMatch !== void 0) throw new BaerlyError("Conflict", `PUT ${key}: precondition failed (ifMatch=${opts.ifMatch} but key does not exist)`);
|
|
105
|
+
if (res.status !== 200 && res.status !== 204) throw await mapStorageError(res, "PUT", key);
|
|
106
|
+
const etag = res.headers.get("ETag");
|
|
107
|
+
if (etag === null) throw new BaerlyError("InvalidResponse", `PUT ${key}: missing ETag`);
|
|
108
|
+
const dateStr = res.headers.get("Date");
|
|
109
|
+
const versionId = res.headers.get("x-amz-version-id") ?? void 0;
|
|
110
|
+
const result = { etag };
|
|
111
|
+
if (dateStr !== null) result.serverDate = new Date(dateStr);
|
|
112
|
+
if (versionId !== void 0) result.versionId = versionId;
|
|
113
|
+
return result;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async delete(key, opts) {
|
|
117
|
+
opts?.signal?.throwIfAborted();
|
|
118
|
+
const url = this.#objectUrl(key);
|
|
119
|
+
await this.#retry(async () => {
|
|
120
|
+
const res = await this.#dispatch(new Request(url, {
|
|
121
|
+
method: "DELETE",
|
|
122
|
+
signal: opts?.signal ?? null
|
|
123
|
+
}));
|
|
124
|
+
if (res.status !== 200 && res.status !== 204 && res.status !== 404) throw await mapStorageError(res, "DELETE", key);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
async *list(prefix, opts) {
|
|
128
|
+
opts?.signal?.throwIfAborted();
|
|
129
|
+
let yielded = 0;
|
|
130
|
+
let continuationToken;
|
|
131
|
+
const startAfter = opts?.startAfter ?? "";
|
|
132
|
+
while (true) {
|
|
133
|
+
opts?.signal?.throwIfAborted();
|
|
134
|
+
const params = new URLSearchParams();
|
|
135
|
+
params.set("list-type", "2");
|
|
136
|
+
params.set("prefix", prefix);
|
|
137
|
+
params.set("encoding-type", "url");
|
|
138
|
+
if (continuationToken !== void 0) params.set("continuation-token", continuationToken);
|
|
139
|
+
else if (startAfter !== "") params.set("start-after", startAfter);
|
|
140
|
+
if (opts?.maxKeys !== void 0) {
|
|
141
|
+
const remaining = opts.maxKeys - yielded;
|
|
142
|
+
params.set("max-keys", String(Math.min(remaining, 1e3)));
|
|
143
|
+
}
|
|
144
|
+
const url = `${this.#endpoint}/${this.#bucket}/?${params.toString()}`;
|
|
145
|
+
let parsed;
|
|
146
|
+
let lastHint;
|
|
147
|
+
for (let attempt = 0; attempt < 10; attempt++) {
|
|
148
|
+
const outcome = await this.#retry(async () => {
|
|
149
|
+
const res = await this.#dispatch(new Request(url, {
|
|
150
|
+
method: "GET",
|
|
151
|
+
signal: opts?.signal ?? null
|
|
152
|
+
}));
|
|
153
|
+
if (res.status === 200) return {
|
|
154
|
+
kind: "ok",
|
|
155
|
+
body: await res.text()
|
|
156
|
+
};
|
|
157
|
+
if (res.status === 429) return {
|
|
158
|
+
kind: "ratelimited",
|
|
159
|
+
retryAfterSeconds: parseRetryAfter(res.headers.get("Retry-After"))
|
|
160
|
+
};
|
|
161
|
+
throw await mapStorageError(res, "LIST", prefix);
|
|
162
|
+
});
|
|
163
|
+
if (outcome.kind === "ok") {
|
|
164
|
+
parsed = parseListObjectsV2CommandOutput(outcome.body);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
lastHint = outcome.retryAfterSeconds;
|
|
168
|
+
const hintMs = outcome.retryAfterSeconds !== void 0 ? outcome.retryAfterSeconds * 1e3 : 0;
|
|
169
|
+
await delay(Math.max(hintMs, RATE_LIMIT_BACKOFF_MILLIS));
|
|
170
|
+
}
|
|
171
|
+
if (parsed === void 0) throw new BaerlyError("NetworkError", `LIST ${prefix}: rate-limited`, {
|
|
172
|
+
status: 429,
|
|
173
|
+
...lastHint !== void 0 ? { retryAfterSeconds: lastHint } : {}
|
|
174
|
+
});
|
|
175
|
+
for (const entry of parsed.Contents ?? []) {
|
|
176
|
+
if (entry.Key === void 0) continue;
|
|
177
|
+
yield {
|
|
178
|
+
key: entry.Key,
|
|
179
|
+
etag: entry.ETag ?? "",
|
|
180
|
+
...entry.LastModified !== void 0 && { lastModified: entry.LastModified }
|
|
181
|
+
};
|
|
182
|
+
yielded += 1;
|
|
183
|
+
if (opts?.maxKeys !== void 0 && yielded >= opts.maxKeys) return;
|
|
184
|
+
}
|
|
185
|
+
continuationToken = parsed.NextContinuationToken;
|
|
186
|
+
if (continuationToken === void 0 || continuationToken === "") return;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region node_modules/.pnpm/aws4fetch@1.0.20/node_modules/aws4fetch/dist/aws4fetch.esm.mjs
|
|
192
|
+
/**
|
|
193
|
+
* @license MIT <https://opensource.org/licenses/MIT>
|
|
194
|
+
* @copyright Michael Hart 2024
|
|
195
|
+
*/
|
|
196
|
+
const encoder = new TextEncoder();
|
|
197
|
+
const HOST_SERVICES = {
|
|
198
|
+
appstream2: "appstream",
|
|
199
|
+
cloudhsmv2: "cloudhsm",
|
|
200
|
+
email: "ses",
|
|
201
|
+
marketplace: "aws-marketplace",
|
|
202
|
+
mobile: "AWSMobileHubService",
|
|
203
|
+
pinpoint: "mobiletargeting",
|
|
204
|
+
queue: "sqs",
|
|
205
|
+
"git-codecommit": "codecommit",
|
|
206
|
+
"mturk-requester-sandbox": "mturk-requester",
|
|
207
|
+
"personalize-runtime": "personalize"
|
|
208
|
+
};
|
|
209
|
+
const UNSIGNABLE_HEADERS = /* @__PURE__ */ new Set([
|
|
210
|
+
"authorization",
|
|
211
|
+
"content-type",
|
|
212
|
+
"content-length",
|
|
213
|
+
"user-agent",
|
|
214
|
+
"presigned-expires",
|
|
215
|
+
"expect",
|
|
216
|
+
"x-amzn-trace-id",
|
|
217
|
+
"range",
|
|
218
|
+
"connection"
|
|
219
|
+
]);
|
|
220
|
+
var AwsClient = class {
|
|
221
|
+
constructor({ accessKeyId, secretAccessKey, sessionToken, service, region, cache, retries, initRetryMs }) {
|
|
222
|
+
if (accessKeyId == null) throw new TypeError("accessKeyId is a required option");
|
|
223
|
+
if (secretAccessKey == null) throw new TypeError("secretAccessKey is a required option");
|
|
224
|
+
this.accessKeyId = accessKeyId;
|
|
225
|
+
this.secretAccessKey = secretAccessKey;
|
|
226
|
+
this.sessionToken = sessionToken;
|
|
227
|
+
this.service = service;
|
|
228
|
+
this.region = region;
|
|
229
|
+
this.cache = cache || /* @__PURE__ */ new Map();
|
|
230
|
+
this.retries = retries != null ? retries : 10;
|
|
231
|
+
this.initRetryMs = initRetryMs || 50;
|
|
232
|
+
}
|
|
233
|
+
async sign(input, init) {
|
|
234
|
+
if (input instanceof Request) {
|
|
235
|
+
const { method, url, headers, body } = input;
|
|
236
|
+
init = Object.assign({
|
|
237
|
+
method,
|
|
238
|
+
url,
|
|
239
|
+
headers
|
|
240
|
+
}, init);
|
|
241
|
+
if (init.body == null && headers.has("Content-Type")) init.body = body != null && headers.has("X-Amz-Content-Sha256") ? body : await input.clone().arrayBuffer();
|
|
242
|
+
input = url;
|
|
243
|
+
}
|
|
244
|
+
const signer = new AwsV4Signer(Object.assign({ url: input.toString() }, init, this, init && init.aws));
|
|
245
|
+
const signed = Object.assign({}, init, await signer.sign());
|
|
246
|
+
delete signed.aws;
|
|
247
|
+
try {
|
|
248
|
+
return new Request(signed.url.toString(), signed);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
if (e instanceof TypeError) return new Request(signed.url.toString(), Object.assign({ duplex: "half" }, signed));
|
|
251
|
+
throw e;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
async fetch(input, init) {
|
|
255
|
+
for (let i = 0; i <= this.retries; i++) {
|
|
256
|
+
const fetched = fetch(await this.sign(input, init));
|
|
257
|
+
if (i === this.retries) return fetched;
|
|
258
|
+
const res = await fetched;
|
|
259
|
+
if (res.status < 500 && res.status !== 429) return res;
|
|
260
|
+
await new Promise((resolve) => setTimeout(resolve, Math.random() * this.initRetryMs * Math.pow(2, i)));
|
|
261
|
+
}
|
|
262
|
+
throw new Error("An unknown error occurred, ensure retries is not negative");
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
var AwsV4Signer = class {
|
|
266
|
+
constructor({ method, url, headers, body, accessKeyId, secretAccessKey, sessionToken, service, region, cache, datetime, signQuery, appendSessionToken, allHeaders, singleEncode }) {
|
|
267
|
+
if (url == null) throw new TypeError("url is a required option");
|
|
268
|
+
if (accessKeyId == null) throw new TypeError("accessKeyId is a required option");
|
|
269
|
+
if (secretAccessKey == null) throw new TypeError("secretAccessKey is a required option");
|
|
270
|
+
this.method = method || (body ? "POST" : "GET");
|
|
271
|
+
this.url = new URL(url);
|
|
272
|
+
this.headers = new Headers(headers || {});
|
|
273
|
+
this.body = body;
|
|
274
|
+
this.accessKeyId = accessKeyId;
|
|
275
|
+
this.secretAccessKey = secretAccessKey;
|
|
276
|
+
this.sessionToken = sessionToken;
|
|
277
|
+
let guessedService, guessedRegion;
|
|
278
|
+
if (!service || !region) [guessedService, guessedRegion] = guessServiceRegion(this.url, this.headers);
|
|
279
|
+
this.service = service || guessedService || "";
|
|
280
|
+
this.region = region || guessedRegion || "us-east-1";
|
|
281
|
+
this.cache = cache || /* @__PURE__ */ new Map();
|
|
282
|
+
this.datetime = datetime || (/* @__PURE__ */ new Date()).toISOString().replace(/[:-]|\.\d{3}/g, "");
|
|
283
|
+
this.signQuery = signQuery;
|
|
284
|
+
this.appendSessionToken = appendSessionToken || this.service === "iotdevicegateway";
|
|
285
|
+
this.headers.delete("Host");
|
|
286
|
+
if (this.service === "s3" && !this.signQuery && !this.headers.has("X-Amz-Content-Sha256")) this.headers.set("X-Amz-Content-Sha256", "UNSIGNED-PAYLOAD");
|
|
287
|
+
const params = this.signQuery ? this.url.searchParams : this.headers;
|
|
288
|
+
params.set("X-Amz-Date", this.datetime);
|
|
289
|
+
if (this.sessionToken && !this.appendSessionToken) params.set("X-Amz-Security-Token", this.sessionToken);
|
|
290
|
+
this.signableHeaders = ["host", ...this.headers.keys()].filter((header) => allHeaders || !UNSIGNABLE_HEADERS.has(header)).sort();
|
|
291
|
+
this.signedHeaders = this.signableHeaders.join(";");
|
|
292
|
+
this.canonicalHeaders = this.signableHeaders.map((header) => header + ":" + (header === "host" ? this.url.host : (this.headers.get(header) || "").replace(/\s+/g, " "))).join("\n");
|
|
293
|
+
this.credentialString = [
|
|
294
|
+
this.datetime.slice(0, 8),
|
|
295
|
+
this.region,
|
|
296
|
+
this.service,
|
|
297
|
+
"aws4_request"
|
|
298
|
+
].join("/");
|
|
299
|
+
if (this.signQuery) {
|
|
300
|
+
if (this.service === "s3" && !params.has("X-Amz-Expires")) params.set("X-Amz-Expires", "86400");
|
|
301
|
+
params.set("X-Amz-Algorithm", "AWS4-HMAC-SHA256");
|
|
302
|
+
params.set("X-Amz-Credential", this.accessKeyId + "/" + this.credentialString);
|
|
303
|
+
params.set("X-Amz-SignedHeaders", this.signedHeaders);
|
|
304
|
+
}
|
|
305
|
+
if (this.service === "s3") try {
|
|
306
|
+
this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\+/g, " "));
|
|
307
|
+
} catch (e) {
|
|
308
|
+
this.encodedPath = this.url.pathname;
|
|
309
|
+
}
|
|
310
|
+
else this.encodedPath = this.url.pathname.replace(/\/+/g, "/");
|
|
311
|
+
if (!singleEncode) this.encodedPath = encodeURIComponent(this.encodedPath).replace(/%2F/g, "/");
|
|
312
|
+
this.encodedPath = encodeRfc3986(this.encodedPath);
|
|
313
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
314
|
+
this.encodedSearch = [...this.url.searchParams].filter(([k]) => {
|
|
315
|
+
if (!k) return false;
|
|
316
|
+
if (this.service === "s3") {
|
|
317
|
+
if (seenKeys.has(k)) return false;
|
|
318
|
+
seenKeys.add(k);
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
}).map((pair) => pair.map((p) => encodeRfc3986(encodeURIComponent(p)))).sort(([k1, v1], [k2, v2]) => k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : v1 > v2 ? 1 : 0).map((pair) => pair.join("=")).join("&");
|
|
322
|
+
}
|
|
323
|
+
async sign() {
|
|
324
|
+
if (this.signQuery) {
|
|
325
|
+
this.url.searchParams.set("X-Amz-Signature", await this.signature());
|
|
326
|
+
if (this.sessionToken && this.appendSessionToken) this.url.searchParams.set("X-Amz-Security-Token", this.sessionToken);
|
|
327
|
+
} else this.headers.set("Authorization", await this.authHeader());
|
|
328
|
+
return {
|
|
329
|
+
method: this.method,
|
|
330
|
+
url: this.url,
|
|
331
|
+
headers: this.headers,
|
|
332
|
+
body: this.body
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
async authHeader() {
|
|
336
|
+
return [
|
|
337
|
+
"AWS4-HMAC-SHA256 Credential=" + this.accessKeyId + "/" + this.credentialString,
|
|
338
|
+
"SignedHeaders=" + this.signedHeaders,
|
|
339
|
+
"Signature=" + await this.signature()
|
|
340
|
+
].join(", ");
|
|
341
|
+
}
|
|
342
|
+
async signature() {
|
|
343
|
+
const date = this.datetime.slice(0, 8);
|
|
344
|
+
const cacheKey = [
|
|
345
|
+
this.secretAccessKey,
|
|
346
|
+
date,
|
|
347
|
+
this.region,
|
|
348
|
+
this.service
|
|
349
|
+
].join();
|
|
350
|
+
let kCredentials = this.cache.get(cacheKey);
|
|
351
|
+
if (!kCredentials) {
|
|
352
|
+
kCredentials = await hmac(await hmac(await hmac(await hmac("AWS4" + this.secretAccessKey, date), this.region), this.service), "aws4_request");
|
|
353
|
+
this.cache.set(cacheKey, kCredentials);
|
|
354
|
+
}
|
|
355
|
+
return buf2hex(await hmac(kCredentials, await this.stringToSign()));
|
|
356
|
+
}
|
|
357
|
+
async stringToSign() {
|
|
358
|
+
return [
|
|
359
|
+
"AWS4-HMAC-SHA256",
|
|
360
|
+
this.datetime,
|
|
361
|
+
this.credentialString,
|
|
362
|
+
buf2hex(await hash(await this.canonicalString()))
|
|
363
|
+
].join("\n");
|
|
364
|
+
}
|
|
365
|
+
async canonicalString() {
|
|
366
|
+
return [
|
|
367
|
+
this.method.toUpperCase(),
|
|
368
|
+
this.encodedPath,
|
|
369
|
+
this.encodedSearch,
|
|
370
|
+
this.canonicalHeaders + "\n",
|
|
371
|
+
this.signedHeaders,
|
|
372
|
+
await this.hexBodyHash()
|
|
373
|
+
].join("\n");
|
|
374
|
+
}
|
|
375
|
+
async hexBodyHash() {
|
|
376
|
+
let hashHeader = this.headers.get("X-Amz-Content-Sha256") || (this.service === "s3" && this.signQuery ? "UNSIGNED-PAYLOAD" : null);
|
|
377
|
+
if (hashHeader == null) {
|
|
378
|
+
if (this.body && typeof this.body !== "string" && !("byteLength" in this.body)) throw new Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");
|
|
379
|
+
hashHeader = buf2hex(await hash(this.body || ""));
|
|
380
|
+
}
|
|
381
|
+
return hashHeader;
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
async function hmac(key, string) {
|
|
385
|
+
const cryptoKey = await crypto.subtle.importKey("raw", typeof key === "string" ? encoder.encode(key) : key, {
|
|
386
|
+
name: "HMAC",
|
|
387
|
+
hash: { name: "SHA-256" }
|
|
388
|
+
}, false, ["sign"]);
|
|
389
|
+
return crypto.subtle.sign("HMAC", cryptoKey, encoder.encode(string));
|
|
390
|
+
}
|
|
391
|
+
async function hash(content) {
|
|
392
|
+
return crypto.subtle.digest("SHA-256", typeof content === "string" ? encoder.encode(content) : content);
|
|
393
|
+
}
|
|
394
|
+
const HEX_CHARS = [
|
|
395
|
+
"0",
|
|
396
|
+
"1",
|
|
397
|
+
"2",
|
|
398
|
+
"3",
|
|
399
|
+
"4",
|
|
400
|
+
"5",
|
|
401
|
+
"6",
|
|
402
|
+
"7",
|
|
403
|
+
"8",
|
|
404
|
+
"9",
|
|
405
|
+
"a",
|
|
406
|
+
"b",
|
|
407
|
+
"c",
|
|
408
|
+
"d",
|
|
409
|
+
"e",
|
|
410
|
+
"f"
|
|
411
|
+
];
|
|
412
|
+
function buf2hex(arrayBuffer) {
|
|
413
|
+
const buffer = new Uint8Array(arrayBuffer);
|
|
414
|
+
let out = "";
|
|
415
|
+
for (let idx = 0; idx < buffer.length; idx++) {
|
|
416
|
+
const n = buffer[idx];
|
|
417
|
+
out += HEX_CHARS[n >>> 4 & 15];
|
|
418
|
+
out += HEX_CHARS[n & 15];
|
|
419
|
+
}
|
|
420
|
+
return out;
|
|
421
|
+
}
|
|
422
|
+
function encodeRfc3986(urlEncodedStr) {
|
|
423
|
+
return urlEncodedStr.replace(/[!'()*]/g, (c) => "%" + c.charCodeAt(0).toString(16).toUpperCase());
|
|
424
|
+
}
|
|
425
|
+
function guessServiceRegion(url, headers) {
|
|
426
|
+
const { hostname, pathname } = url;
|
|
427
|
+
if (hostname.endsWith(".on.aws")) {
|
|
428
|
+
const match = hostname.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);
|
|
429
|
+
return match != null ? ["lambda", match[1] || ""] : ["", ""];
|
|
430
|
+
}
|
|
431
|
+
if (hostname.endsWith(".r2.cloudflarestorage.com")) return ["s3", "auto"];
|
|
432
|
+
if (hostname.endsWith(".backblazeb2.com")) {
|
|
433
|
+
const match = hostname.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);
|
|
434
|
+
return match != null ? ["s3", match[1] || ""] : ["", ""];
|
|
435
|
+
}
|
|
436
|
+
const match = hostname.replace("dualstack.", "").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/);
|
|
437
|
+
let service = match && match[1] || "";
|
|
438
|
+
let region = match && match[2];
|
|
439
|
+
if (region === "us-gov") region = "us-gov-west-1";
|
|
440
|
+
else if (region === "s3" || region === "s3-accelerate") {
|
|
441
|
+
region = "us-east-1";
|
|
442
|
+
service = "s3";
|
|
443
|
+
} else if (service === "iot") if (hostname.startsWith("iot.")) service = "execute-api";
|
|
444
|
+
else if (hostname.startsWith("data.jobs.iot.")) service = "iot-jobs-data";
|
|
445
|
+
else service = pathname === "/mqtt" ? "iotdevicegateway" : "iotdata";
|
|
446
|
+
else if (service === "autoscaling") {
|
|
447
|
+
const targetPrefix = (headers.get("X-Amz-Target") || "").split(".")[0];
|
|
448
|
+
if (targetPrefix === "AnyScaleFrontendService") service = "application-autoscaling";
|
|
449
|
+
else if (targetPrefix === "AnyScaleScalingPlannerFrontendService") service = "autoscaling-plans";
|
|
450
|
+
} else if (region == null && service.startsWith("s3-")) {
|
|
451
|
+
region = service.slice(3).replace(/^fips-|^external-1/, "");
|
|
452
|
+
service = "s3";
|
|
453
|
+
} else if (service.endsWith("-fips")) service = service.slice(0, -5);
|
|
454
|
+
else if (region && /-\d$/.test(service) && !/-\d$/.test(region)) [service, region] = [region, service];
|
|
455
|
+
return [HOST_SERVICES[service] || service, region || ""];
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
export { S3HttpStorage as n, AwsClient as t };
|
|
459
|
+
|
|
460
|
+
//# sourceMappingURL=aws4fetch.esm-CXE5ZbAa.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aws4fetch.esm-CXE5ZbAa.js","names":["#endpoint","#bucket","#fetch","#sign","#retries","#backoffMs","#dispatch","#objectUrl","#retry"],"sources":["../packages/adapter-node/src/s3-http.ts","../node_modules/.pnpm/aws4fetch@1.0.20/node_modules/aws4fetch/dist/aws4fetch.esm.mjs"],"sourcesContent":["import {\n BaerlyError,\n LIST_OBJECT_MAX_RETRIES,\n RATE_LIMIT_BACKOFF_MILLIS,\n S3_REQUEST_MAX_RETRIES,\n assertValidStorageKey,\n delay,\n type Storage,\n type StorageGetOptions,\n type StorageGetResult,\n type StorageListEntry,\n type StoragePutOptions,\n type StoragePutResult,\n} from \"@baerly/protocol\";\nimport { mapStorageError, parseRetryAfter, retry, retryAfterCause } from \"./http-transport.ts\";\nimport { parseListObjectsV2CommandOutput } from \"./xml.ts\";\n\n/**\n * Construction-time options for {@link S3HttpStorage}. Everything is\n * optional except `endpoint` and `bucket`; the consumer chooses how\n * to satisfy `fetch` (browser/Node global vs. injected) and `sign`\n * (anonymous Minio vs. SigV4-signed via aws4fetch).\n */\nexport interface S3HttpStorageOptions {\n /**\n * S3 endpoint URL, e.g. `https://s3.us-east-1.amazonaws.com` or\n * `http://127.0.0.1:9102` (Minio). Trailing slashes are trimmed.\n */\n endpoint: string;\n /** S3 bucket name. */\n bucket: string;\n /**\n * `fetch` implementation. Defaults to `globalThis.fetch.bind(globalThis)`.\n * Tests pass a `vi.fn()` stub.\n */\n fetch?: typeof fetch;\n /**\n * Signs requests before send. Pass `undefined` for anonymous\n * (Minio without creds). The seam is `(req) => Promise<req>` so\n * SigV4 implementations like `aws4fetch.AwsClient.sign` plug in\n * directly.\n */\n sign?: (req: Request) => Promise<Request>;\n /** Max retries for transient (non-permanent) failures. */\n retries?: number;\n /** Initial backoff in ms. */\n backoffMs?: number;\n}\n\n/**\n * `Storage` impl that speaks the S3 REST API directly. Works against\n * any S3-compatible endpoint — AWS S3, R2 (S3-compat), Minio. Does not\n * depend on any AWS SDK. GCS is NOT supported over this S3-interop path\n * (its conditional-write semantics can't linearize the commit log); use\n * the native `GcsHttpStorage` adapter instead.\n *\n * Authentication is plugged in via the `sign` callback; this class\n * itself does no SigV4. For Cloudflare Workers, the R2 binding fast\n * path lives in `@baerly/adapter-cloudflare`.\n */\nexport class S3HttpStorage implements Storage {\n readonly #endpoint: string;\n readonly #bucket: string;\n readonly #fetch: typeof fetch;\n readonly #sign?: (req: Request) => Promise<Request>;\n readonly #retries: number;\n readonly #backoffMs: number;\n\n constructor(options: S3HttpStorageOptions) {\n this.#endpoint = options.endpoint.replace(/\\/+$/, \"\");\n this.#bucket = options.bucket;\n this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);\n this.#sign = options.sign;\n this.#retries = options.retries ?? S3_REQUEST_MAX_RETRIES;\n this.#backoffMs = options.backoffMs ?? 100;\n }\n\n #objectUrl(key: string, versionId?: string): string {\n // Choke point for every key-addressing verb — reject unaddressable\n // `.`/`..`/empty keys before URL normalization turns them into a\n // bucket-root 403. @see storage-compatibility.md \"Key namespace\".\n assertValidStorageKey(key);\n const base = `${this.#endpoint}/${this.#bucket}/${encodeURIComponent(key)}`;\n return versionId !== undefined ? `${base}?versionId=${encodeURIComponent(versionId)}` : base;\n }\n\n async #dispatch(req: Request): Promise<Response> {\n const signed = this.#sign ? await this.#sign(req) : req;\n try {\n return await this.#fetch(signed);\n } catch (error) {\n if (error instanceof BaerlyError) {\n throw error;\n }\n const msg = error instanceof Error ? error.message : String(error);\n throw new BaerlyError(\"NetworkError\", msg, error);\n }\n }\n\n #retry<T>(fn: () => Promise<T>): Promise<T> {\n return retry(fn, { retries: this.#retries, backoffMs: this.#backoffMs });\n }\n\n async get(key: string, opts?: StorageGetOptions): Promise<StorageGetResult | null> {\n opts?.signal?.throwIfAborted();\n const url = this.#objectUrl(key, opts?.versionId);\n const headers = new Headers();\n if (opts?.ifNoneMatch !== undefined) {\n headers.set(\"If-None-Match\", opts.ifNoneMatch);\n }\n return this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, { method: \"GET\", headers, signal: opts?.signal ?? null }),\n );\n switch (res.status) {\n case 200: {\n const etag = res.headers.get(\"ETag\");\n if (etag === null) {\n throw new BaerlyError(\"InvalidResponse\", `GET ${key}: missing ETag`);\n }\n const body = new Uint8Array(await res.arrayBuffer());\n const versionId = res.headers.get(\"x-amz-version-id\") ?? undefined;\n return versionId !== undefined ? { body, etag, versionId } : { body, etag };\n }\n case 304:\n case 404: {\n return null;\n }\n default: {\n throw await mapStorageError(res, \"GET\", key);\n }\n }\n });\n }\n\n async put(key: string, body: Uint8Array, opts?: StoragePutOptions): Promise<StoragePutResult> {\n opts?.signal?.throwIfAborted();\n const url = this.#objectUrl(key);\n const headers = new Headers();\n headers.set(\"Content-Type\", opts?.contentType ?? \"application/octet-stream\");\n if (opts?.ifMatch !== undefined) {\n headers.set(\"If-Match\", opts.ifMatch);\n }\n if (opts?.ifNoneMatch === \"*\") {\n headers.set(\"If-None-Match\", \"*\");\n }\n return this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, {\n method: \"PUT\",\n headers,\n // TS lib.dom narrows BodyInit and a generic `Uint8Array<ArrayBufferLike>`\n // is not assignable; the runtime accepts it.\n body: body as BodyInit,\n signal: opts?.signal ?? null,\n }),\n );\n if (res.status === 412) {\n throw new BaerlyError(\"Conflict\", `PUT ${key}: precondition failed`);\n }\n // AWS S3 returns 409 ConditionalRequestConflict when a concurrent\n // conditional create (If-None-Match:\"*\") races; Minio returns 412.\n // 409 means the write was contended and may NOT have landed, so it\n // maps to a retryable NetworkError — the single-write-commit writer\n // re-issues the same-seq PUT, which resolves deterministically to 200\n // (we win) or 412 (key now present → Conflict → adopt/re-probe). A\n // direct Conflict here would adopt-read a possibly-absent entry.\n if (res.status === 409 && opts?.ifNoneMatch === \"*\") {\n throw new BaerlyError(\n \"NetworkError\",\n `PUT ${key}: 409 ConditionalRequestConflict (contended conditional create; retryable)`,\n { status: res.status, ...retryAfterCause(res) },\n );\n }\n // S3-compatible servers diverge on `If-Match` against a missing\n // key: AWS S3 returns 412, Minio returns 404 (NoSuchKey). Map\n // 404-with-ifMatch to the same `Conflict` semantic so consumers\n // don't have to special-case the wire reply.\n if (res.status === 404 && opts?.ifMatch !== undefined) {\n throw new BaerlyError(\n \"Conflict\",\n `PUT ${key}: precondition failed (ifMatch=${opts.ifMatch} but key does not exist)`,\n );\n }\n if (res.status !== 200 && res.status !== 204) {\n throw await mapStorageError(res, \"PUT\", key);\n }\n const etag = res.headers.get(\"ETag\");\n if (etag === null) {\n throw new BaerlyError(\"InvalidResponse\", `PUT ${key}: missing ETag`);\n }\n const dateStr = res.headers.get(\"Date\");\n const versionId = res.headers.get(\"x-amz-version-id\") ?? undefined;\n const result: { etag: string; serverDate?: Date; versionId?: string } = { etag };\n if (dateStr !== null) {\n result.serverDate = new Date(dateStr);\n }\n if (versionId !== undefined) {\n result.versionId = versionId;\n }\n return result;\n });\n }\n\n async delete(key: string, opts?: { signal?: AbortSignal }): Promise<void> {\n opts?.signal?.throwIfAborted();\n const url = this.#objectUrl(key);\n await this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, { method: \"DELETE\", signal: opts?.signal ?? null }),\n );\n // 200 / 204 / 404 → success (idempotent); any other status is a real\n // failure (403 → AccessDenied, 429/≥500 → retryable NetworkError, else\n // InvalidResponse) rather than a silently-swallowed non-2xx.\n if (res.status !== 200 && res.status !== 204 && res.status !== 404) {\n throw await mapStorageError(res, \"DELETE\", key);\n }\n });\n }\n\n async *list(\n prefix: string,\n opts?: { startAfter?: string; maxKeys?: number; signal?: AbortSignal },\n ): AsyncIterable<StorageListEntry> {\n opts?.signal?.throwIfAborted();\n let yielded = 0;\n let continuationToken: string | undefined;\n const startAfter = opts?.startAfter ?? \"\";\n while (true) {\n opts?.signal?.throwIfAborted();\n const params = new URLSearchParams();\n params.set(\"list-type\", \"2\");\n params.set(\"prefix\", prefix);\n // Force S3 to URL-encode object keys in the response so keys\n // containing XML-hostile or whitespace bytes survive the round trip.\n // The XML parser (`xmlVal` in ./xml.ts) reverses this on `Key`; only\n // the key family (Key/Prefix/Delimiter/StartAfter) is encoded — ETag\n // and NextContinuationToken come back verbatim.\n params.set(\"encoding-type\", \"url\");\n if (continuationToken !== undefined) {\n params.set(\"continuation-token\", continuationToken);\n } else if (startAfter !== \"\") {\n params.set(\"start-after\", startAfter);\n }\n if (opts?.maxKeys !== undefined) {\n const remaining = opts.maxKeys - yielded;\n params.set(\"max-keys\", String(Math.min(remaining, 1000)));\n }\n const url = `${this.#endpoint}/${this.#bucket}/?${params.toString()}`;\n\n // Per-page 429 retry budget separate from the inner #retry budget:\n // 429 means \"rate-limited, back off and retry the same page\", and\n // a single hot page shouldn't burn the overall transient-failure\n // budget.\n let parsed: Awaited<ReturnType<typeof parseListObjectsV2CommandOutput>> | undefined;\n let lastHint: number | undefined;\n for (let attempt = 0; attempt < LIST_OBJECT_MAX_RETRIES; attempt++) {\n const outcome = await this.#retry(async () => {\n const res = await this.#dispatch(\n new Request(url, { method: \"GET\", signal: opts?.signal ?? null }),\n );\n if (res.status === 200) {\n return { kind: \"ok\" as const, body: await res.text() };\n }\n if (res.status === 429) {\n return {\n kind: \"ratelimited\" as const,\n retryAfterSeconds: parseRetryAfter(res.headers.get(\"Retry-After\")),\n };\n }\n throw await mapStorageError(res, \"LIST\", prefix);\n });\n if (outcome.kind === \"ok\") {\n parsed = parseListObjectsV2CommandOutput(outcome.body);\n break;\n }\n lastHint = outcome.retryAfterSeconds;\n const hintMs =\n outcome.retryAfterSeconds !== undefined ? outcome.retryAfterSeconds * 1000 : 0;\n await delay(Math.max(hintMs, RATE_LIMIT_BACKOFF_MILLIS));\n }\n if (parsed === undefined) {\n throw new BaerlyError(\"NetworkError\", `LIST ${prefix}: rate-limited`, {\n status: 429,\n ...(lastHint !== undefined ? { retryAfterSeconds: lastHint } : {}),\n });\n }\n\n for (const entry of parsed.Contents ?? []) {\n if (entry.Key === undefined) {\n continue;\n }\n yield {\n key: entry.Key,\n etag: entry.ETag ?? \"\",\n ...(entry.LastModified !== undefined && { lastModified: entry.LastModified }),\n };\n yielded += 1;\n if (opts?.maxKeys !== undefined && yielded >= opts.maxKeys) {\n return;\n }\n }\n continuationToken = parsed.NextContinuationToken;\n if (continuationToken === undefined || continuationToken === \"\") {\n return;\n }\n }\n }\n}\n","/**\n * @license MIT <https://opensource.org/licenses/MIT>\n * @copyright Michael Hart 2024\n */\nconst encoder = new TextEncoder();\nconst HOST_SERVICES = {\n appstream2: 'appstream',\n cloudhsmv2: 'cloudhsm',\n email: 'ses',\n marketplace: 'aws-marketplace',\n mobile: 'AWSMobileHubService',\n pinpoint: 'mobiletargeting',\n queue: 'sqs',\n 'git-codecommit': 'codecommit',\n 'mturk-requester-sandbox': 'mturk-requester',\n 'personalize-runtime': 'personalize',\n};\nconst UNSIGNABLE_HEADERS = new Set([\n 'authorization',\n 'content-type',\n 'content-length',\n 'user-agent',\n 'presigned-expires',\n 'expect',\n 'x-amzn-trace-id',\n 'range',\n 'connection',\n]);\nclass AwsClient {\n constructor({ accessKeyId, secretAccessKey, sessionToken, service, region, cache, retries, initRetryMs }) {\n if (accessKeyId == null) throw new TypeError('accessKeyId is a required option')\n if (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option')\n this.accessKeyId = accessKeyId;\n this.secretAccessKey = secretAccessKey;\n this.sessionToken = sessionToken;\n this.service = service;\n this.region = region;\n this.cache = cache || new Map();\n this.retries = retries != null ? retries : 10;\n this.initRetryMs = initRetryMs || 50;\n }\n async sign(input, init) {\n if (input instanceof Request) {\n const { method, url, headers, body } = input;\n init = Object.assign({ method, url, headers }, init);\n if (init.body == null && headers.has('Content-Type')) {\n init.body = body != null && headers.has('X-Amz-Content-Sha256') ? body : await input.clone().arrayBuffer();\n }\n input = url;\n }\n const signer = new AwsV4Signer(Object.assign({ url: input.toString() }, init, this, init && init.aws));\n const signed = Object.assign({}, init, await signer.sign());\n delete signed.aws;\n try {\n return new Request(signed.url.toString(), signed)\n } catch (e) {\n if (e instanceof TypeError) {\n return new Request(signed.url.toString(), Object.assign({ duplex: 'half' }, signed))\n }\n throw e\n }\n }\n async fetch(input, init) {\n for (let i = 0; i <= this.retries; i++) {\n const fetched = fetch(await this.sign(input, init));\n if (i === this.retries) {\n return fetched\n }\n const res = await fetched;\n if (res.status < 500 && res.status !== 429) {\n return res\n }\n await new Promise(resolve => setTimeout(resolve, Math.random() * this.initRetryMs * Math.pow(2, i)));\n }\n throw new Error('An unknown error occurred, ensure retries is not negative')\n }\n}\nclass AwsV4Signer {\n constructor({ method, url, headers, body, accessKeyId, secretAccessKey, sessionToken, service, region, cache, datetime, signQuery, appendSessionToken, allHeaders, singleEncode }) {\n if (url == null) throw new TypeError('url is a required option')\n if (accessKeyId == null) throw new TypeError('accessKeyId is a required option')\n if (secretAccessKey == null) throw new TypeError('secretAccessKey is a required option')\n this.method = method || (body ? 'POST' : 'GET');\n this.url = new URL(url);\n this.headers = new Headers(headers || {});\n this.body = body;\n this.accessKeyId = accessKeyId;\n this.secretAccessKey = secretAccessKey;\n this.sessionToken = sessionToken;\n let guessedService, guessedRegion;\n if (!service || !region) {\n[guessedService, guessedRegion] = guessServiceRegion(this.url, this.headers);\n }\n this.service = service || guessedService || '';\n this.region = region || guessedRegion || 'us-east-1';\n this.cache = cache || new Map();\n this.datetime = datetime || new Date().toISOString().replace(/[:-]|\\.\\d{3}/g, '');\n this.signQuery = signQuery;\n this.appendSessionToken = appendSessionToken || this.service === 'iotdevicegateway';\n this.headers.delete('Host');\n if (this.service === 's3' && !this.signQuery && !this.headers.has('X-Amz-Content-Sha256')) {\n this.headers.set('X-Amz-Content-Sha256', 'UNSIGNED-PAYLOAD');\n }\n const params = this.signQuery ? this.url.searchParams : this.headers;\n params.set('X-Amz-Date', this.datetime);\n if (this.sessionToken && !this.appendSessionToken) {\n params.set('X-Amz-Security-Token', this.sessionToken);\n }\n this.signableHeaders = ['host', ...this.headers.keys()]\n .filter(header => allHeaders || !UNSIGNABLE_HEADERS.has(header))\n .sort();\n this.signedHeaders = this.signableHeaders.join(';');\n this.canonicalHeaders = this.signableHeaders\n .map(header => header + ':' + (header === 'host' ? this.url.host : (this.headers.get(header) || '').replace(/\\s+/g, ' ')))\n .join('\\n');\n this.credentialString = [this.datetime.slice(0, 8), this.region, this.service, 'aws4_request'].join('/');\n if (this.signQuery) {\n if (this.service === 's3' && !params.has('X-Amz-Expires')) {\n params.set('X-Amz-Expires', '86400');\n }\n params.set('X-Amz-Algorithm', 'AWS4-HMAC-SHA256');\n params.set('X-Amz-Credential', this.accessKeyId + '/' + this.credentialString);\n params.set('X-Amz-SignedHeaders', this.signedHeaders);\n }\n if (this.service === 's3') {\n try {\n this.encodedPath = decodeURIComponent(this.url.pathname.replace(/\\+/g, ' '));\n } catch (e) {\n this.encodedPath = this.url.pathname;\n }\n } else {\n this.encodedPath = this.url.pathname.replace(/\\/+/g, '/');\n }\n if (!singleEncode) {\n this.encodedPath = encodeURIComponent(this.encodedPath).replace(/%2F/g, '/');\n }\n this.encodedPath = encodeRfc3986(this.encodedPath);\n const seenKeys = new Set();\n this.encodedSearch = [...this.url.searchParams]\n .filter(([k]) => {\n if (!k) return false\n if (this.service === 's3') {\n if (seenKeys.has(k)) return false\n seenKeys.add(k);\n }\n return true\n })\n .map(pair => pair.map(p => encodeRfc3986(encodeURIComponent(p))))\n .sort(([k1, v1], [k2, v2]) => k1 < k2 ? -1 : k1 > k2 ? 1 : v1 < v2 ? -1 : v1 > v2 ? 1 : 0)\n .map(pair => pair.join('='))\n .join('&');\n }\n async sign() {\n if (this.signQuery) {\n this.url.searchParams.set('X-Amz-Signature', await this.signature());\n if (this.sessionToken && this.appendSessionToken) {\n this.url.searchParams.set('X-Amz-Security-Token', this.sessionToken);\n }\n } else {\n this.headers.set('Authorization', await this.authHeader());\n }\n return {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n }\n }\n async authHeader() {\n return [\n 'AWS4-HMAC-SHA256 Credential=' + this.accessKeyId + '/' + this.credentialString,\n 'SignedHeaders=' + this.signedHeaders,\n 'Signature=' + (await this.signature()),\n ].join(', ')\n }\n async signature() {\n const date = this.datetime.slice(0, 8);\n const cacheKey = [this.secretAccessKey, date, this.region, this.service].join();\n let kCredentials = this.cache.get(cacheKey);\n if (!kCredentials) {\n const kDate = await hmac('AWS4' + this.secretAccessKey, date);\n const kRegion = await hmac(kDate, this.region);\n const kService = await hmac(kRegion, this.service);\n kCredentials = await hmac(kService, 'aws4_request');\n this.cache.set(cacheKey, kCredentials);\n }\n return buf2hex(await hmac(kCredentials, await this.stringToSign()))\n }\n async stringToSign() {\n return [\n 'AWS4-HMAC-SHA256',\n this.datetime,\n this.credentialString,\n buf2hex(await hash(await this.canonicalString())),\n ].join('\\n')\n }\n async canonicalString() {\n return [\n this.method.toUpperCase(),\n this.encodedPath,\n this.encodedSearch,\n this.canonicalHeaders + '\\n',\n this.signedHeaders,\n await this.hexBodyHash(),\n ].join('\\n')\n }\n async hexBodyHash() {\n let hashHeader = this.headers.get('X-Amz-Content-Sha256') || (this.service === 's3' && this.signQuery ? 'UNSIGNED-PAYLOAD' : null);\n if (hashHeader == null) {\n if (this.body && typeof this.body !== 'string' && !('byteLength' in this.body)) {\n throw new Error('body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header')\n }\n hashHeader = buf2hex(await hash(this.body || ''));\n }\n return hashHeader\n }\n}\nasync function hmac(key, string) {\n const cryptoKey = await crypto.subtle.importKey(\n 'raw',\n typeof key === 'string' ? encoder.encode(key) : key,\n { name: 'HMAC', hash: { name: 'SHA-256' } },\n false,\n ['sign'],\n );\n return crypto.subtle.sign('HMAC', cryptoKey, encoder.encode(string))\n}\nasync function hash(content) {\n return crypto.subtle.digest('SHA-256', typeof content === 'string' ? encoder.encode(content) : content)\n}\nconst HEX_CHARS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];\nfunction buf2hex(arrayBuffer) {\n const buffer = new Uint8Array(arrayBuffer);\n let out = '';\n for (let idx = 0; idx < buffer.length; idx++) {\n const n = buffer[idx];\n out += HEX_CHARS[(n >>> 4) & 0xF];\n out += HEX_CHARS[n & 0xF];\n }\n return out\n}\nfunction encodeRfc3986(urlEncodedStr) {\n return urlEncodedStr.replace(/[!'()*]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase())\n}\nfunction guessServiceRegion(url, headers) {\n const { hostname, pathname } = url;\n if (hostname.endsWith('.on.aws')) {\n const match = hostname.match(/^[^.]{1,63}\\.lambda-url\\.([^.]{1,63})\\.on\\.aws$/);\n return match != null ? ['lambda', match[1] || ''] : ['', '']\n }\n if (hostname.endsWith('.r2.cloudflarestorage.com')) {\n return ['s3', 'auto']\n }\n if (hostname.endsWith('.backblazeb2.com')) {\n const match = hostname.match(/^(?:[^.]{1,63}\\.)?s3\\.([^.]{1,63})\\.backblazeb2\\.com$/);\n return match != null ? ['s3', match[1] || ''] : ['', '']\n }\n const match = hostname.replace('dualstack.', '').match(/([^.]{1,63})\\.(?:([^.]{0,63})\\.)?amazonaws\\.com(?:\\.cn)?$/);\n let service = (match && match[1]) || '';\n let region = match && match[2];\n if (region === 'us-gov') {\n region = 'us-gov-west-1';\n } else if (region === 's3' || region === 's3-accelerate') {\n region = 'us-east-1';\n service = 's3';\n } else if (service === 'iot') {\n if (hostname.startsWith('iot.')) {\n service = 'execute-api';\n } else if (hostname.startsWith('data.jobs.iot.')) {\n service = 'iot-jobs-data';\n } else {\n service = pathname === '/mqtt' ? 'iotdevicegateway' : 'iotdata';\n }\n } else if (service === 'autoscaling') {\n const targetPrefix = (headers.get('X-Amz-Target') || '').split('.')[0];\n if (targetPrefix === 'AnyScaleFrontendService') {\n service = 'application-autoscaling';\n } else if (targetPrefix === 'AnyScaleScalingPlannerFrontendService') {\n service = 'autoscaling-plans';\n }\n } else if (region == null && service.startsWith('s3-')) {\n region = service.slice(3).replace(/^fips-|^external-1/, '');\n service = 's3';\n } else if (service.endsWith('-fips')) {\n service = service.slice(0, -5);\n } else if (region && /-\\d$/.test(service) && !/-\\d$/.test(region)) {\n[service, region] = [region, service];\n }\n return [HOST_SERVICES[service] || service, region || '']\n}\n\nexport { AwsClient, AwsV4Signer };\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;;;;;;;AA4DA,IAAa,gBAAb,MAA8C;CAC5C;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA+B;EACzC,KAAKA,YAAY,QAAQ,SAAS,QAAQ,QAAQ,EAAE;EACpD,KAAKC,UAAU,QAAQ;EACvB,KAAKC,SAAS,QAAQ,SAAS,WAAW,MAAM,KAAK,UAAU;EAC/D,KAAKC,QAAQ,QA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