@softistx/s3 0.0.0-stage → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +609 -2
- package/dist/bucket/bind-bucket.d.ts +42 -0
- package/dist/bucket/bind-bucket.d.ts.map +1 -0
- package/dist/bucket/bound-bucket.d.ts +119 -0
- package/dist/bucket/bound-bucket.d.ts.map +1 -0
- package/dist/bucket/context.d.ts +55 -0
- package/dist/bucket/context.d.ts.map +1 -0
- package/dist/bucket/define-bucket.d.ts +16 -0
- package/dist/bucket/define-bucket.d.ts.map +1 -0
- package/dist/bucket/disposition.d.ts +9 -0
- package/dist/bucket/disposition.d.ts.map +1 -0
- package/dist/bucket/guards.d.ts +38 -0
- package/dist/bucket/guards.d.ts.map +1 -0
- package/dist/bucket/operations/counted-stream.d.ts +26 -0
- package/dist/bucket/operations/counted-stream.d.ts.map +1 -0
- package/dist/bucket/operations/deadline.d.ts +21 -0
- package/dist/bucket/operations/deadline.d.ts.map +1 -0
- package/dist/bucket/operations/fetch-object.d.ts +68 -0
- package/dist/bucket/operations/fetch-object.d.ts.map +1 -0
- package/dist/bucket/operations/list-xml.d.ts +18 -0
- package/dist/bucket/operations/list-xml.d.ts.map +1 -0
- package/dist/bucket/operations/list.d.ts +12 -0
- package/dist/bucket/operations/list.d.ts.map +1 -0
- package/dist/bucket/operations/open-answer.d.ts +5 -0
- package/dist/bucket/operations/open-answer.d.ts.map +1 -0
- package/dist/bucket/operations/open-range.d.ts +10 -0
- package/dist/bucket/operations/open-range.d.ts.map +1 -0
- package/dist/bucket/operations/open-relay.d.ts +8 -0
- package/dist/bucket/operations/open-relay.d.ts.map +1 -0
- package/dist/bucket/operations/open.d.ts +4 -0
- package/dist/bucket/operations/open.d.ts.map +1 -0
- package/dist/bucket/operations/post-policy.d.ts +77 -0
- package/dist/bucket/operations/post-policy.d.ts.map +1 -0
- package/dist/bucket/operations/post-signer.d.ts +21 -0
- package/dist/bucket/operations/post-signer.d.ts.map +1 -0
- package/dist/bucket/operations/presign-post.d.ts +44 -0
- package/dist/bucket/operations/presign-post.d.ts.map +1 -0
- package/dist/bucket/operations/presign.d.ts +34 -0
- package/dist/bucket/operations/presign.d.ts.map +1 -0
- package/dist/bucket/operations/put-body.d.ts +13 -0
- package/dist/bucket/operations/put-body.d.ts.map +1 -0
- package/dist/bucket/operations/query-sign.d.ts +15 -0
- package/dist/bucket/operations/query-sign.d.ts.map +1 -0
- package/dist/bucket/operations/reads.d.ts +8 -0
- package/dist/bucket/operations/reads.d.ts.map +1 -0
- package/dist/bucket/operations/sized-body.d.ts +24 -0
- package/dist/bucket/operations/sized-body.d.ts.map +1 -0
- package/dist/bucket/operations/slice.d.ts +4 -0
- package/dist/bucket/operations/slice.d.ts.map +1 -0
- package/dist/bucket/operations/writes.d.ts +10 -0
- package/dist/bucket/operations/writes.d.ts.map +1 -0
- package/dist/bucket/shape.d.ts +6 -0
- package/dist/bucket/shape.d.ts.map +1 -0
- package/dist/bucket/types.d.ts +164 -0
- package/dist/bucket/types.d.ts.map +1 -0
- package/dist/chunks/index-jgjey570.js +118 -0
- package/dist/chunks/index-jgjey570.js.map +13 -0
- package/dist/errors/is-bucket-unavailable.d.ts +18 -0
- package/dist/errors/is-bucket-unavailable.d.ts.map +1 -0
- package/dist/errors/s3-error.d.ts +80 -0
- package/dist/errors/s3-error.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1288 -0
- package/dist/index.js.map +32 -0
- package/dist/testing/fetch-archive.d.ts +8 -0
- package/dist/testing/fetch-archive.d.ts.map +1 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +416 -0
- package/dist/testing/index.js.map +16 -0
- package/dist/testing/ports.d.ts +15 -0
- package/dist/testing/ports.d.ts.map +1 -0
- package/dist/testing/ready.d.ts +49 -0
- package/dist/testing/ready.d.ts.map +1 -0
- package/dist/testing/reaper.d.ts +4 -0
- package/dist/testing/reaper.d.ts.map +1 -0
- package/dist/testing/seaweedfs.d.ts +64 -0
- package/dist/testing/seaweedfs.d.ts.map +1 -0
- package/dist/testing/test-s3.d.ts +35 -0
- package/dist/testing/test-s3.d.ts.map +1 -0
- package/dist/testing/weed.d.ts +17 -0
- package/dist/testing/weed.d.ts.map +1 -0
- package/docs/README.md +17 -0
- package/docs/guide/buckets.md +220 -0
- package/docs/guide/presigned-urls.md +403 -0
- package/docs/guide/reads.md +417 -0
- package/docs/guide/testing.md +151 -0
- package/docs/guide/writes.md +374 -0
- package/docs/roadmap.md +116 -0
- package/docs/troubleshooting.md +982 -0
- package/package.json +61 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/bucket/bind-bucket.ts", "../src/bucket/operations/fetch-object.ts", "../src/bucket/operations/list-xml.ts", "../src/bucket/operations/post-policy.ts", "../src/bucket/operations/post-signer.ts", "../src/bucket/operations/query-sign.ts", "../src/bucket/operations/list.ts", "../src/bucket/operations/open-range.ts", "../src/bucket/operations/open-relay.ts", "../src/bucket/operations/open-answer.ts", "../src/bucket/operations/open.ts", "../src/bucket/disposition.ts", "../src/bucket/guards.ts", "../src/bucket/operations/presign.ts", "../src/bucket/operations/presign-post.ts", "../src/bucket/operations/reads.ts", "../src/bucket/operations/slice.ts", "../src/bucket/operations/counted-stream.ts", "../src/bucket/operations/put-body.ts", "../src/bucket/operations/sized-body.ts", "../src/bucket/operations/writes.ts", "../src/bucket/define-bucket.ts", "../src/errors/is-bucket-unavailable.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { S3Client, type S3Options } from 'bun';\nimport type { BoundBucket } from './bound-bucket';\nimport { bucketContext, keyOf, parseKeyOf } from './context';\nimport { isWholeMs } from './operations/deadline';\nimport { listObjects } from './operations/list';\nimport { openObject } from './operations/open';\nimport {\n\ttype PresignGetOptions,\n\ttype PresignOptions,\n\tpresignGetUrl,\n\tpresignPutUrl,\n} from './operations/presign';\nimport {\n\ttype PresignedPost,\n\ttype PresignPostOptions,\n\tpresignPostForm,\n} from './operations/presign-post';\nimport {\n\tobjectExists,\n\treadBytes,\n\treadText,\n\tstatObject,\n} from './operations/reads';\nimport { sliceObject } from './operations/slice';\nimport { deleteObject, putObject } from './operations/writes';\nimport { shapeOf } from './shape';\nimport type { BucketDefinition, CallOptions } from './types';\n\n/**\n * Bun's own `S3Options` without `bucket`, plus the bucket's default\n * `timeoutMs` for `put`, `bytes`, `slice`, `text`, `exists`, `stat`, `delete` and\n * `list`. A call's own `timeoutMs` wins. It never reaches the `S3Client`.\n * It bounds a whole `put`, an upload included: give a large one its own.\n */\nexport type BindOptions = Omit<S3Options, 'bucket'> &\n\tCallOptions & {\n\t\t/**\n\t\t * The origin browsers reach the service at, when it is not `endpoint`\n\t\t * (`https://media.example.com` in front of `http://minio:9000`).\n\t\t * `presignGet`, `presignPut` and `presignPost` are signed for it; every\n\t\t * other call goes to `endpoint`, so the server does not hairpin through\n\t\t * the proxy. Left out, everything uses `endpoint`. It never reaches the\n\t\t * `S3Client`. Anything that is not an absolute URL is a `TypeError`.\n\t\t */\n\t\tpublicEndpoint?: string | undefined;\n\t};\n\nexport type {\n\tBoundBucket,\n\tPresignedPost,\n\tPresignGetOptions,\n\tPresignOptions,\n\tPresignPostOptions,\n};\n\n/** An endpoint without trailing slashes, so `https://x/` equals `https://x`. */\nconst trimmed = (endpoint: string | undefined) => endpoint?.replace(/\\/+$/, '');\n\n/**\n * Binds a bucket definition to credentials.\n *\n * ```ts\n * const store = bindBucket(avatars, {\n * \tendpoint: process.env.S3_ENDPOINT,\n * \taccessKeyId: process.env.S3_KEY,\n * \tsecretAccessKey: process.env.S3_SECRET,\n * });\n * await store.put({ userId: 'u1' }, png, { type: 'image/png' });\n * ```\n *\n * Given no options, Bun reads its own `S3_*` / `AWS_*` environment variables.\n *\n * Each bound bucket holds an `S3Client` of its own. S3 is stateless HTTP —\n * there is no connection to share, and nothing to close.\n */\nexport function bindBucket<P>(\n\tdefinition: BucketDefinition<P>,\n\toptions: BindOptions = {},\n): BoundBucket<P> {\n\tconst { timeoutMs, publicEndpoint, ...clientOptions } = options;\n\t// Wiring, not a request: a bare `TypeError`, like the other definition-time\n\t// refusals. Only the per-call value, which can come from a request, is coded.\n\tif (timeoutMs !== undefined && !isWholeMs(timeoutMs)) {\n\t\tthrow new TypeError(\n\t\t\t`bindBucket on \"${definition.bucket}\": timeoutMs is a whole number of ` +\n\t\t\t\t`milliseconds, 1 or more; got ${shapeOf(timeoutMs)}`,\n\t\t);\n\t}\n\tif (publicEndpoint !== undefined && !URL.canParse(publicEndpoint)) {\n\t\tthrow new TypeError(\n\t\t\t`bindBucket on \"${definition.bucket}\": publicEndpoint is an absolute ` +\n\t\t\t\t`URL such as https://media.example.com; got ${shapeOf(publicEndpoint)}`,\n\t\t);\n\t}\n\tconst deadline = timeoutMs;\n\tconst client = new S3Client({ ...clientOptions, bucket: definition.bucket });\n\t// A presigned URL is bound to the host it was signed for, and the browser\n\t// opens it: it needs the public origin, while the server's own calls keep\n\t// the internal one.\n\tconst presignClient =\n\t\tpublicEndpoint === undefined ||\n\t\ttrimmed(publicEndpoint) === trimmed(options.endpoint)\n\t\t\t? client\n\t\t\t: new S3Client({\n\t\t\t\t\t...clientOptions,\n\t\t\t\t\tendpoint: publicEndpoint,\n\t\t\t\t\tbucket: definition.bucket,\n\t\t\t\t});\n\tconst context = bucketContext(\n\t\tclient,\n\t\tdefinition,\n\t\toptions.secretAccessKey,\n\t\tdeadline,\n\t\tpresignClient,\n\t);\n\treturn {\n\t\tclient,\n\t\tkeyFor: (params) => keyOf(context, params),\n\t\tparseKey: (key) => parseKeyOf(context, key),\n\t\tfile: (params) => client.file(keyOf(context, params)),\n\t\tput: (putObject<P>).bind(null, context) as BoundBucket<P>['put'],\n\t\tbytes: (params, callOptions) => readBytes(context, params, callOptions),\n\t\tslice: (params, range, callOptions) =>\n\t\t\tsliceObject(context, params, range, callOptions),\n\t\topen: (params, openOptions) => openObject(context, params, openOptions),\n\t\ttext: (params, callOptions) => readText(context, params, callOptions),\n\t\texists: (params, callOptions) => objectExists(context, params, callOptions),\n\t\tstat: (params, callOptions) => statObject(context, params, callOptions),\n\t\tdelete: (params, callOptions) => deleteObject(context, params, callOptions),\n\t\tlist: (listOptions) => listObjects(context, listOptions),\n\t\tpresignGet: (params, presignOptions) =>\n\t\t\tpresignGetUrl(context, params, presignOptions),\n\t\tpresignPut: (params, presignOptions) =>\n\t\t\tpresignPutUrl(context, params, presignOptions),\n\t\tpresignPost: (params, postOptions) =>\n\t\t\tpresignPostForm(context, params, postOptions),\n\t};\n}\n",
|
|
6
|
+
"import type { S3Stats } from 'bun';\nimport type { BucketContext } from '../context';\nimport type { PutOptions } from '../types';\n\ntype Verb = 'HEAD' | 'GET' | 'DELETE' | 'PUT';\n\n/** What Bun names a failed connection, by what `fetch` calls it. */\nexport const BUN_CODES: Record<string, string> = {\n\tECONNREFUSED: 'ConnectionRefused',\n\tConnectionRefused: 'ConnectionRefused',\n\tECONNRESET: 'ConnectionClosed',\n\tConnectionClosed: 'ConnectionClosed',\n\tENOTFOUND: 'DNSResolveFailed',\n\tDNSResolveFailed: 'DNSResolveFailed',\n\tEPIPE: 'ConnectionClosed',\n\tUND_ERR_SOCKET: 'ConnectionClosed',\n};\n\n/** An `Error` named `S3Error`, as Bun throws for a failed S3 request. */\nexport function s3Error(code: string, key: string, message: string): Error {\n\tconst error = new Error(message) as Error & { code: string; path: string };\n\terror.name = 'S3Error';\n\terror.code = code;\n\terror.path = key;\n\treturn error;\n}\n\n/**\n * What a call adds to the bare verb: a URL already signed (a listing's), or\n * the options Bun must **sign** into the query (a PUT's `acl` and\n * `storageClass`), a body and plain request headers.\n */\ntype Request = {\n\turl?: string;\n\tsigned?: {\n\t\tacl?: NonNullable<PutOptions['acl']>;\n\t\tstorageClass?: NonNullable<PutOptions['storageClass']>;\n\t};\n\tbody?: BodyInit;\n\theaders?: Record<string, string>;\n};\n\n/**\n * What a failed connection or a failed body read becomes. The runtime's\n * errors carry the signed URL in their `path`, so nothing of them is kept:\n * the shape Bun gives the same failure, with the key.\n */\nexport function readFailure(reason: unknown, key: string): Error {\n\tconst code = (reason as { code?: unknown } | null)?.code;\n\treturn s3Error(\n\t\t(typeof code === 'string' && BUN_CODES[code]) || 'ConnectionClosed',\n\t\tkey,\n\t\t'an unexpected error has occurred',\n\t);\n}\n\nexport type Exchange = {\n\tstatus: number;\n\tok: boolean;\n\theaders: Headers;\n\tbody: Uint8Array;\n};\n\n/**\n * Bun's own S3 calls ignore an `AbortSignal` (measured on 1.4.3: still\n * pending seconds after an abort against a socket that never answers), but\n * `fetch` honours one. So a call with a deadline signs a URL with Bun and\n * sends it with `fetch`, and reads the whole body inside the same `try`.\n *\n * The signed URL is a credential, and the runtime's connection errors carry\n * it in their `path` (measured: a reset mid-body on 1.4.3). So nothing of a\n * non-abort failure is kept: it is rethrown in the shape Bun gives the same\n * failure without a deadline — name `S3Error`, Bun's code, `path` the key.\n */\nasync function send<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tmethod: Verb,\n\tsignal: AbortSignal,\n\trequest: Request = {},\n): Promise<Exchange> {\n\tconst url =\n\t\trequest.url ??\n\t\tcontext.client.presign(key, { method, expiresIn: 60, ...request.signed });\n\ttry {\n\t\tconst response = await fetch(url, {\n\t\t\tmethod,\n\t\t\tsignal,\n\t\t\t...(request.body === undefined ? {} : { body: request.body }),\n\t\t\t...(request.headers ? { headers: request.headers } : {}),\n\t\t});\n\t\tconst body =\n\t\t\tmethod === 'HEAD'\n\t\t\t\t? new Uint8Array()\n\t\t\t\t: new Uint8Array(await response.arrayBuffer());\n\t\treturn {\n\t\t\tstatus: response.status,\n\t\t\tok: response.ok,\n\t\t\theaders: response.headers,\n\t\t\tbody,\n\t\t};\n\t} catch (reason) {\n\t\tif (signal.aborted) throw reason;\n\t\tthrow readFailure(reason, key);\n\t}\n}\n\n/** What Bun throws for a failed request: an `Error` named `S3Error`. */\nexport function failure(response: Exchange, key: string): Error {\n\t// A HEAD has no body (read as empty): Bun itself says only that it was\n\t// unexpected.\n\tconst body = new TextDecoder().decode(response.body);\n\tconst field = (tag: string) =>\n\t\tnew RegExp(`<${tag}>([^<]*)</${tag}>`).exec(body)?.[1];\n\t// Measured: Bun reads a 404 with no S3 body (a proxy's) as `NoSuchKey`.\n\tconst missing = response.status === 404;\n\treturn s3Error(\n\t\tfield('Code') ?? (missing ? 'NoSuchKey' : 'UnknownError'),\n\t\tkey,\n\t\tfield('Message') ??\n\t\t\t(missing\n\t\t\t\t? 'The specified key does not exist.'\n\t\t\t\t: 'an unexpected error has occurred'),\n\t);\n}\n\n/** HEAD: the stats Bun gives, or `undefined` when there is no such object. */\nexport async function headObject<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tsignal: AbortSignal,\n): Promise<S3Stats | undefined> {\n\tconst response = await send(context, key, 'HEAD', signal);\n\tif (response.status === 404) return undefined;\n\tif (!response.ok) throw failure(response, key);\n\tconst { headers } = response;\n\treturn {\n\t\tsize: Number(headers.get('content-length') ?? 0),\n\t\tlastModified: new Date(headers.get('last-modified') ?? 0),\n\t\tetag: headers.get('etag') ?? '',\n\t\ttype: headers.get('content-type') ?? '',\n\t};\n}\n\n/** GET: the bytes, or `undefined` when there is no such object. */\nexport async function getObject<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tsignal: AbortSignal,\n): Promise<Uint8Array | undefined> {\n\tconst response = await send(context, key, 'GET', signal);\n\tif (response.ok) return response.body;\n\tconst error = failure(response, key);\n\tif ((error as { code?: string }).code === 'NoSuchKey') return undefined;\n\tthrow error;\n}\n\n/**\n * GET with a `Range` header: bytes [start, end) as a plain request header\n * (not signed, which the service accepts). `undefined` when there is no such\n * object. A start at or past the object's end (S3 answers 416) is empty, and\n * an end past it is cut by the service. A service that ignores `Range` and\n * answers 200 with the whole object is cut here.\n */\nexport async function getRange<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\trange: { start: number; end: number },\n\tsignal: AbortSignal,\n): Promise<Uint8Array | undefined> {\n\tconst response = await send(context, key, 'GET', signal, {\n\t\theaders: { Range: `bytes=${range.start}-${range.end - 1}` },\n\t});\n\tif (response.status === 206) return response.body;\n\tif (response.status === 200)\n\t\treturn response.body.slice(range.start, range.end);\n\tif (response.status === 416) return new Uint8Array();\n\tconst error = failure(response, key);\n\tif ((error as { code?: string }).code === 'NoSuchKey') return undefined;\n\tthrow error;\n}\n\n/** DELETE: S3 answers the same for an object that was not there. */\nexport async function removeObject<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tsignal: AbortSignal,\n): Promise<void> {\n\tconst response = await send(context, key, 'DELETE', signal);\n\tif (!response.ok) throw failure(response, key);\n}\n\n/** What a listing sends: the request is signed as a whole, as a URL. */\nexport async function getListing<P>(\n\tcontext: BucketContext<P>,\n\turl: string,\n\tsignal: AbortSignal,\n): Promise<string> {\n\tconst response = await send(context, '', 'GET', signal, { url });\n\tif (!response.ok) throw failure(response, '');\n\treturn new TextDecoder().decode(response.body);\n}\n\n/** What a PUT carries beyond the key: the body and the headers it is served with. */\nexport type PutRequest = {\n\tbody: BodyInit;\n\theaders: Record<string, string>;\n\tsigned: NonNullable<Request['signed']>;\n};\n\n/**\n * PUT: stores the body. `acl` and `storageClass` are signed into the URL by\n * Bun; the type, disposition and encoding are plain headers, which SeaweedFS\n * stores although they are not signed (measured on 4.47, see the spec).\n */\nexport async function storeObject<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\trequest: PutRequest,\n\tsignal: AbortSignal,\n): Promise<void> {\n\tconst response = await send(context, key, 'PUT', signal, request);\n\tif (!response.ok) throw failure(response, key);\n}\n",
|
|
7
|
+
"import { s3Error } from './fetch-object';\n\n/**\n * What a ListObjectsV2 answer says, read without an XML parser: the answer is\n * flat and S3's own, and a key can hold anything, so the text is unescaped\n * once and only after it has been cut out.\n */\n\nexport interface ListedObject {\n\tkey: string;\n\tsize: number | undefined;\n\tlastModified: string | undefined;\n\teTag: string | undefined;\n}\n\nexport interface ListAnswer {\n\tcontents: ListedObject[];\n\tisTruncated: boolean;\n\tnextContinuationToken: string | undefined;\n}\n\nconst ENTITIES: Record<string, string> = {\n\tamp: '&',\n\tlt: '<',\n\tgt: '>',\n\tquot: '\"',\n\tapos: \"'\",\n};\n\n/** What XML 1.0 allows as a character: not 0, nor most controls, nor lone surrogates. */\nconst allowed = (code: number): boolean =>\n\tcode === 0x9 ||\n\tcode === 0xa ||\n\tcode === 0xd ||\n\t(code >= 0x20 && code <= 0xd7ff) ||\n\t(code >= 0xe000 && code <= 0xfffd) ||\n\t(code >= 0x10000 && code <= 0x10ffff);\n\nconst malformed = () =>\n\ts3Error(\n\t\t'InvalidResponse',\n\t\t'',\n\t\t'ListObjectsV2 response is not a well-formed <ListBucketResult> document',\n\t);\n\n/** One pass, so `&lt;` is `<` and not `<`. A reference XML forbids is a malformed answer. */\nfunction unescapeXml(text: string): string {\n\treturn text.replace(\n\t\t/&(#x[0-9a-f]+|#\\d+|amp|lt|gt|quot|apos);/gi,\n\t\t(whole, name: string) => {\n\t\t\tif (!name.startsWith('#')) return ENTITIES[name.toLowerCase()] ?? whole;\n\t\t\tconst code =\n\t\t\t\tname[1] === 'x' || name[1] === 'X'\n\t\t\t\t\t? Number.parseInt(name.slice(2), 16)\n\t\t\t\t\t: Number.parseInt(name.slice(1), 10);\n\t\t\tif (!allowed(code)) throw malformed();\n\t\t\treturn String.fromCodePoint(code);\n\t\t},\n\t);\n}\n\n/** Text with its CDATA sections as they are, and the rest unescaped. */\nfunction textOf(raw: string): string {\n\treturn raw\n\t\t.split(/<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>/)\n\t\t.map((part, at) => (at % 2 ? part : unescapeXml(part)))\n\t\t.join('');\n}\n\nfunction field(xml: string, tag: string): string | undefined {\n\tconst found = new RegExp(`<${tag}>([\\\\s\\\\S]*?)</${tag}>`).exec(xml)?.[1];\n\treturn found === undefined ? undefined : textOf(found);\n}\n\n/** The root must be a `ListBucketResult`, after an optional XML declaration. */\nconst ROOT = /^\\uFEFF?\\s*(?:<\\?xml[^>]*\\?>\\s*)?<ListBucketResult[\\s>]/;\n\nexport function parseListing(xml: string): ListAnswer {\n\tif (!ROOT.test(xml)) throw malformed();\n\tconst contents: ListedObject[] = [];\n\t// Everything outside the `<Contents>` blocks: a key that spells a tag is\n\t// escaped, but cutting the blocks out first means it is never looked at.\n\tconst rest = xml.replace(\n\t\t/<Contents>([\\s\\S]*?)<\\/Contents>/g,\n\t\t(_, entry: string) => {\n\t\t\tconst size = field(entry, 'Size');\n\t\t\tcontents.push({\n\t\t\t\tkey: field(entry, 'Key') ?? '',\n\t\t\t\tsize:\n\t\t\t\t\tsize !== undefined && Number.isFinite(Number(size))\n\t\t\t\t\t\t? Number(size)\n\t\t\t\t\t\t: undefined,\n\t\t\t\tlastModified: field(entry, 'LastModified'),\n\t\t\t\teTag: field(entry, 'ETag'),\n\t\t\t});\n\t\t\treturn '';\n\t\t},\n\t);\n\treturn {\n\t\tcontents,\n\t\tisTruncated: field(rest, 'IsTruncated') === 'true',\n\t\tnextContinuationToken: field(rest, 'NextContinuationToken'),\n\t};\n}\n",
|
|
8
|
+
"import { createHash, createHmac } from 'node:crypto';\n\n/**\n * An S3 POST policy and its SigV4 signature, with nothing but `node:crypto`.\n *\n * Bun's `S3Client` signs a GET, a PUT, a HEAD and a DELETE, and has no POST\n * presigning at all; this file is that one missing signature. It is pure —\n * no client, no clock of its own — so its spec pins it at a fixed date.\n *\n * The algorithm is AWS's \"browser-based upload\" one: the policy is JSON,\n * base64-encoded, and the signature is the HMAC-SHA256 of **that base64\n * string** under the usual SigV4 signing key. Nothing about the request —\n * not its headers, not its body — is signed; the policy's conditions are\n * what the service holds the form to.\n */\n\n/** One condition of a policy, in the forms S3 documents. */\nexport type PolicyCondition =\n\t| Readonly<Record<string, string>>\n\t| readonly ['eq' | 'starts-with', string, string]\n\t| readonly ['content-length-range', number, number];\n\n/** Who signs, and where the form goes. */\nexport interface PostSigner {\n\t/** The bucket's own URL, which the form is posted to. */\n\treadonly url: string;\n\treadonly bucket: string;\n\treadonly accessKeyId: string;\n\treadonly secretAccessKey: string;\n\t/** As Bun signs it: `us-east-1`, `eu-west-3`, or `auto` off AWS. */\n\treadonly region: string;\n\t/** Temporary credentials: posted as `x-amz-security-token`. */\n\treadonly sessionToken?: string | undefined;\n}\n\n/** What the policy fixes, and until when. */\nexport interface PostPolicy {\n\t/**\n\t * The form's own fields — `key`, `Content-Type`, `acl` — each one fixed\n\t * by an `eq` condition, so the browser posts exactly these.\n\t */\n\treadonly fields: Readonly<Record<string, string>>;\n\t/** The rest: `content-length-range`, a `starts-with`. */\n\treadonly conditions: readonly PolicyCondition[];\n\t/** Seconds from `now` until the service refuses the form. */\n\treadonly expiresIn: number;\n\treadonly now: Date;\n}\n\n/** The form a browser posts: the file goes **after** every one of `fields`. */\nexport interface PresignedPost {\n\turl: string;\n\tfields: Record<string, string>;\n}\n\nconst ALGORITHM = 'AWS4-HMAC-SHA256';\n\n/** `20151229T000000Z`: SigV4's own date, with no separators and no millis. */\nexport function amzDateOf(now: Date): string {\n\treturn now\n\t\t.toISOString()\n\t\t.replace(/[-:]/g, '')\n\t\t.replace(/\\.\\d{3}/, '');\n}\n\nconst hmac = (key: string | Buffer, data: string): Buffer =>\n\tcreateHmac('sha256', key).update(data).digest();\n\n/**\n * SigV4's signing key: four HMACs, from the secret down to `aws4_request`.\n * The service is a parameter only so the spec can pin this against AWS's\n * own documented vector, which is for `iam`.\n */\nexport function signingKey(\n\tsecretAccessKey: string,\n\tday: string,\n\tregion: string,\n\tservice = 's3',\n): Buffer {\n\tconst date = hmac(`AWS4${secretAccessKey}`, day);\n\treturn hmac(hmac(hmac(date, region), service), 'aws4_request');\n}\n\n/**\n * The query as it was sent, each value decoded once — or `undefined` when a\n * value is not a valid escape. Not `URLSearchParams`, which reads a `+` as a\n * space: Bun leaves the access key id unencoded, so a key with a `+` in it\n * would come back as another key, and a `%` in it as a malformed escape.\n */\nexport function rawQueryOf(\n\tpairs: readonly string[],\n): Map<string, string> | undefined {\n\tconst query = new Map<string, string>();\n\tfor (const pair of pairs) {\n\t\tconst at = pair.indexOf('=');\n\t\ttry {\n\t\t\tquery.set(pair.slice(0, at), decodeURIComponent(pair.slice(at + 1)));\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn query;\n}\n\n/**\n * The signature a SigV4 presigned URL should carry, recomputed with this\n * secret: the one way to tell whether it is the secret the URL was signed\n * with, since the URL never carries the secret itself.\n *\n * The canonical query is the query **as it was sent**, sorted, without\n * `X-Amz-Signature` — not decoded and re-encoded. Measured on bun 1.4.2, Bun\n * writes an access key id into `X-Amz-Credential` unencoded, so a key with a\n * `+` or a `/` re-encodes to other bytes than the ones Bun signed; taken as\n * sent, all eleven shapes tried match Bun's own signature (ports, a base\n * path, virtual-hosted style, a session token, a dotted bucket, such keys).\n * A presigned URL signs no payload, and `host` is its one signed header.\n */\nexport function presignedSignature(\n\turl: URL,\n\tmethod: string,\n\tsecretAccessKey: string,\n): string {\n\tconst pairs = url.search\n\t\t.slice(1)\n\t\t.split('&')\n\t\t.filter((pair) => !pair.startsWith('X-Amz-Signature='))\n\t\t.sort();\n\tconst canonical = [\n\t\tmethod,\n\t\turl.pathname,\n\t\tpairs.join('&'),\n\t\t`host:${url.host}`,\n\t\t'',\n\t\t'host',\n\t\t'UNSIGNED-PAYLOAD',\n\t].join('\\n');\n\t// A malformed escape signs as no scope at all, which matches nothing.\n\tconst query = rawQueryOf(pairs) ?? new Map<string, string>();\n\tconst scope = (query.get('X-Amz-Credential') ?? '').split('/').slice(-4);\n\tconst toSign = [\n\t\tALGORITHM,\n\t\tquery.get('X-Amz-Date') ?? '',\n\t\tscope.join('/'),\n\t\tcreateHash('sha256').update(canonical).digest('hex'),\n\t].join('\\n');\n\tconst key = signingKey(secretAccessKey, scope[0] ?? '', scope[1] ?? '');\n\treturn createHmac('sha256', key).update(toSign).digest('hex');\n}\n\n/** Signs a policy, and gives back the whole form but the file. */\nexport function signPostPolicy(\n\tsigner: PostSigner,\n\tpolicy: PostPolicy,\n): PresignedPost {\n\tconst amzDate = amzDateOf(policy.now);\n\tconst day = amzDate.slice(0, 8);\n\tconst signing: Record<string, string> = {\n\t\t'x-amz-algorithm': ALGORITHM,\n\t\t'x-amz-credential': `${signer.accessKeyId}/${day}/${signer.region}/s3/aws4_request`,\n\t\t'x-amz-date': amzDate,\n\t};\n\tif (signer.sessionToken) {\n\t\tsigning['x-amz-security-token'] = signer.sessionToken;\n\t}\n\tconst fields = { ...policy.fields, ...signing };\n\tconst document = {\n\t\texpiration: new Date(\n\t\t\tpolicy.now.getTime() + policy.expiresIn * 1000,\n\t\t).toISOString(),\n\t\tconditions: [\n\t\t\t{ bucket: signer.bucket },\n\t\t\t...Object.entries(fields).map(([name, value]) => [\n\t\t\t\t'eq',\n\t\t\t\t`$${name}`,\n\t\t\t\tvalue,\n\t\t\t]),\n\t\t\t...policy.conditions,\n\t\t],\n\t};\n\tconst encoded = Buffer.from(JSON.stringify(document)).toString('base64');\n\tconst signature = createHmac(\n\t\t'sha256',\n\t\tsigningKey(signer.secretAccessKey, day, signer.region),\n\t)\n\t\t.update(encoded)\n\t\t.digest('hex');\n\treturn {\n\t\turl: signer.url,\n\t\tfields: { ...fields, policy: encoded, 'x-amz-signature': signature },\n\t};\n}\n",
|
|
9
|
+
"import { type BucketContext, callOf, secretOf } from '../context';\nimport { type PostSigner, presignedSignature, rawQueryOf } from './post-policy';\n\n/**\n * Where Bun would send this bucket's requests, and as whom.\n *\n * Read off a URL Bun itself signs, rather than worked out again here:\n * measured on bun 1.4.2, Bun signs for region `auto` at any endpoint that is\n * not AWS's, reads the region out of an AWS hostname, falls back to\n * `us-east-1`, and puts the bucket in the path or the host by\n * `virtualHostedStyle`. A second copy of those rules would drift from the\n * first; this way a POST goes wherever a presigned PUT goes. The probe key is\n * signed and thrown away — nothing is sent.\n */\nexport const PROBE = 'nxgt-probe';\n\n/** `accessKeyId/20260923/us-east-1/s3/aws4_request`, as its five parts. */\nconst SCOPE_PARTS = 5;\n\n/** The query of a URL Bun signed, or `undefined` when it cannot be read. */\nconst queryOf = (url: URL) => rawQueryOf(url.search.slice(1).split('&'));\n\n/**\n * The secret this bucket signs with — **the one Bun signs with**, or a\n * refusal.\n *\n * The context resolves it from the option, then `S3_SECRET_ACCESS_KEY`, then\n * `AWS_SECRET_ACCESS_KEY`, as Bun documents — but Bun reads those variables\n * **once, when the process starts** (measured by the review of this code),\n * and the context reads them when the bucket is bound. A variable changed or\n * deleted in between gives the two different secrets: the form would be\n * signed with one and refused by the service only when a browser posts it.\n * So the secret is checked against the signature Bun put on the probe.\n */\nfunction checkedSecret<P>(\n\tcontext: BucketContext<P>,\n\tprobe: URL,\n\twhere: string,\n\tthing: string,\n): string {\n\tconst secret = secretOf(context);\n\tif (!secret) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: no secret access key to sign with, while Bun has one. ` +\n\t\t\t\t'Bun reads S3_SECRET_ACCESS_KEY and AWS_SECRET_ACCESS_KEY when the ' +\n\t\t\t\t'process starts; one removed since is still Bun’s, and no longer ' +\n\t\t\t\t'this package’s. Pass `secretAccessKey` to bindBucket',\n\t\t);\n\t}\n\tconst signed = queryOf(probe)?.get('X-Amz-Signature');\n\tif (presignedSignature(probe, 'PUT', secret) !== signed) {\n\t\tthrow new TypeError(\n\t\t\t`${where}: the secret access key this package would sign with is not ` +\n\t\t\t\t'the one Bun signs with, so the service would refuse the ' +\n\t\t\t\t`${thing}. Bun ` +\n\t\t\t\t'reads S3_SECRET_ACCESS_KEY and AWS_SECRET_ACCESS_KEY when the ' +\n\t\t\t\t'process starts; one changed since is not the one Bun uses. Pass ' +\n\t\t\t\t'`secretAccessKey` to bindBucket',\n\t\t);\n\t}\n\treturn secret;\n}\n\n/**\n * Who signs and where, for the call named `call` (`presignPost` or `list`):\n * the refusals below name it, so a failed listing does not read as a failed\n * form. The listing signs its own GET with the same signer.\n */\nexport function signerOf<P>(\n\tcontext: BucketContext<P>,\n\tcall = 'presignPost',\n): PostSigner {\n\tconst where = callOf(context, call);\n\tconst thing = call === 'presignPost' ? 'form' : 'request';\n\t// Bun's own `ERR_S3_MISSING_CREDENTIALS` comes out of here when Bun has no\n\t// credentials at all, as it does for `presignPut`.\n\tconst probe = new URL(\n\t\t(call === 'presignPost' ? context.presignClient : context.client).presign(\n\t\t\tPROBE,\n\t\t\t{ method: 'PUT', expiresIn: 1 },\n\t\t),\n\t);\n\tconst query = queryOf(probe);\n\tconst scope = (query?.get('X-Amz-Credential') ?? '').split('/');\n\tif (!query || scope.length < SCOPE_PARTS || !probe.pathname.endsWith(PROBE)) {\n\t\t// Only a Bun that signs differently from 1.4.2 reaches this — or an\n\t\t// access key id with a `%` Bun left unescaped: better a refusal than a\n\t\t// form posted to the wrong place or signed as nobody.\n\t\tthrow new Error(\n\t\t\t`${where}: the URL Bun signed has no ` +\n\t\t\t\t'credential scope, or not the key at the end of its path, so there ' +\n\t\t\t\t`is nowhere to ${thing === 'form' ? 'post the form' : 'send the request'}. ` +\n\t\t\t\t'This Bun signs differently from the one this package was measured on',\n\t\t);\n\t}\n\treturn {\n\t\turl: `${probe.origin}${probe.pathname.slice(0, -PROBE.length)}`,\n\t\tbucket: context.definition.bucket,\n\t\taccessKeyId: scope.slice(0, -4).join('/'),\n\t\tregion: scope.at(-3) as string,\n\t\tsecretAccessKey: checkedSecret(context, probe, where, thing),\n\t\tsessionToken: query.get('X-Amz-Security-Token'),\n\t};\n}\n",
|
|
10
|
+
"import { amzDateOf, type PostSigner, presignedSignature } from './post-policy';\n\n/** RFC 3986's unreserved set only: `encodeURIComponent` leaves `!'()*`. */\nconst encode = (value: string): string =>\n\tencodeURIComponent(value).replace(\n\t\t/[!'()*]/g,\n\t\t(char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`,\n\t);\n\n/**\n * A GET on the bucket's root, signed in its query (SigV4 \"presigned URL\"),\n * for the one request Bun cannot presign: a bucket-level one, such as a\n * listing.\n *\n * It signs nothing of its own: the URL is written without a signature and\n * `presignedSignature` — the function `signerOf` checks the secret with\n * against Bun's own signature, so it is known to match Bun's canonical form\n * — computes it, and it is appended. The canonical query is the pairs as\n * sent, sorted, so the values are encoded here once, RFC 3986-style, and sent\n * exactly so. `host` is the one signed header and no payload is signed.\n */\nexport function signedBucketGet(\n\tsigner: PostSigner,\n\tquery: Readonly<Record<string, string>>,\n\tnow: Date = new Date(),\n\texpiresIn = 60,\n): string {\n\tconst amzDate = amzDateOf(now);\n\tconst signing: Record<string, string> = {\n\t\t'X-Amz-Algorithm': 'AWS4-HMAC-SHA256',\n\t\t'X-Amz-Credential': `${signer.accessKeyId}/${amzDate.slice(0, 8)}/${signer.region}/s3/aws4_request`,\n\t\t'X-Amz-Date': amzDate,\n\t\t'X-Amz-Expires': String(expiresIn),\n\t\t'X-Amz-SignedHeaders': 'host',\n\t};\n\tif (signer.sessionToken) {\n\t\tsigning['X-Amz-Security-Token'] = signer.sessionToken;\n\t}\n\tconst pairs = Object.entries({ ...query, ...signing })\n\t\t.map(([name, value]) => [encode(name), encode(value)] as const)\n\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\t\t.map(([name, value]) => `${name}=${value}`);\n\tconst unsigned = new URL(`${signer.url}?${pairs.join('&')}`);\n\tconst signature = presignedSignature(unsigned, 'GET', signer.secretAccessKey);\n\treturn `${unsigned.href}&X-Amz-Signature=${signature}`;\n}\n",
|
|
11
|
+
"import type { S3ListObjectsOptions, S3ListObjectsResponse } from 'bun';\nimport type { BucketContext } from '../context';\nimport type { CallOptions, ObjectPage, StoredObject } from '../types';\nimport { deadlineOf, withDeadline } from './deadline';\nimport { getListing } from './fetch-object';\nimport { type ListAnswer, parseListing } from './list-xml';\nimport { signerOf } from './post-signer';\nimport { signedBucketGet } from './query-sign';\n\ntype ListOptions = {\n\tprefix?: string;\n\tlimit?: number;\n\tcursor?: string | null;\n\tstartAfter?: string;\n} & CallOptions;\n\n/** One page of the bucket, in this repository's cursor shape. */\nexport async function listObjects<P>(\n\tcontext: BucketContext<P>,\n\toptions: ListOptions = {},\n): Promise<ObjectPage> {\n\tconst timeoutMs = deadlineOf(context, '', 'list', options);\n\tif (timeoutMs === undefined) return pageOf(await viaBun(context, options));\n\t// Bun's `list` ignores a signal like the rest of its calls, so a listing\n\t// under a deadline is a GET this package signs itself (Bun cannot presign\n\t// a bucket-level request) and sends with `fetch`.\n\tconst query: Record<string, string> = { 'list-type': '2' };\n\tif (options.prefix !== undefined) query['prefix'] = options.prefix;\n\tif (options.limit !== undefined) query['max-keys'] = String(options.limit);\n\tif (options.cursor != null) query['continuation-token'] = options.cursor;\n\tif (options.startAfter !== undefined)\n\t\tquery['start-after'] = options.startAfter;\n\tconst url = signedBucketGet(signerOf(context, 'list'), query);\n\treturn withDeadline(context, '', 'list', timeoutMs, async (signal) =>\n\t\tpageOf(parseListing(await getListing(context, url, signal))),\n\t);\n}\n\nasync function viaBun<P>(\n\tcontext: BucketContext<P>,\n\toptions: ListOptions,\n): Promise<ListAnswer> {\n\tconst request: S3ListObjectsOptions = {};\n\tif (options.prefix !== undefined) request.prefix = options.prefix;\n\tif (options.limit !== undefined) request.maxKeys = options.limit;\n\tif (options.cursor != null) request.continuationToken = options.cursor;\n\tif (options.startAfter !== undefined) request.startAfter = options.startAfter;\n\tconst answer = await context.client.list(request);\n\tconst contents: NonNullable<S3ListObjectsResponse['contents']> =\n\t\tanswer.contents ?? [];\n\treturn {\n\t\tcontents: contents.map((found) => ({\n\t\t\tkey: found.key,\n\t\t\tsize: found.size,\n\t\t\tlastModified: found.lastModified,\n\t\t\teTag: found.eTag,\n\t\t})),\n\t\tisTruncated: answer.isTruncated === true,\n\t\tnextContinuationToken: answer.nextContinuationToken,\n\t};\n}\n\n/** Either path's answer as the page: one mapping, so the two cannot differ. */\nfunction pageOf(answer: ListAnswer): ObjectPage {\n\tconst items: StoredObject[] = answer.contents.map((found) => ({\n\t\tkey: found.key,\n\t\tsize: found.size,\n\t\tlastModified: found.lastModified ? new Date(found.lastModified) : undefined,\n\t\teTag: found.eTag,\n\t}));\n\t// `isTruncated` is what says there is more, and it is the only thing that\n\t// does: a service that sends a token on the last page anyway would page\n\t// for ever if the token alone decided. `null` is this repository's\n\t// \"no next page\".\n\tconst next = answer.isTruncated\n\t\t? (answer.nextContinuationToken ?? null)\n\t\t: null;\n\treturn { items, nextCursor: next };\n}\n",
|
|
12
|
+
"import { S3Error } from '../../errors/s3-error';\nimport { type BucketContext, callOf } from '../context';\nimport { shapeOf } from '../shape';\n\nconst isOffset = (value: unknown): value is number =>\n\ttypeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\n\n/** The `Range` header for a range, after refusing one that is not whole numbers. */\nexport function rangeHeader<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\trange: unknown,\n): string {\n\tconst bad = (what: string) =>\n\t\tnew S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`range is { start, end? } with 0 <= start < end, or { suffix } with ` +\n\t\t\t\t`suffix >= 1, as whole numbers; ${what} (${callOf(context, 'open')})`,\n\t\t);\n\tif (typeof range !== 'object' || range === null || Array.isArray(range)) {\n\t\tthrow bad(`got ${shapeOf(range)}`);\n\t}\n\tconst { start, end, suffix } = range as {\n\t\tstart?: unknown;\n\t\tend?: unknown;\n\t\tsuffix?: unknown;\n\t};\n\tif (suffix !== undefined) {\n\t\tif (start !== undefined || end !== undefined) {\n\t\t\tthrow bad('got a suffix together with a start or an end');\n\t\t}\n\t\tif (!isOffset(suffix) || suffix < 1) {\n\t\t\tthrow bad(`got suffix ${shapeOf(suffix)}`);\n\t\t}\n\t\treturn `bytes=-${suffix}`;\n\t}\n\tif (\n\t\t!isOffset(start) ||\n\t\t(end !== undefined && (!isOffset(end) || end <= start))\n\t) {\n\t\tthrow bad(`got start ${shapeOf(start)}, end ${shapeOf(end)}`);\n\t}\n\treturn `bytes=${start}-${end === undefined ? '' : end - 1}`;\n}\n\n/** `bytes a-b/total` to its three numbers, or `undefined`. */\nexport function parseContentRange(header: string | null) {\n\tconst match = /^bytes (\\d+)-(\\d+)\\/(\\d+)$/.exec(header ?? '');\n\tif (!match) return undefined;\n\treturn {\n\t\tfirst: Number(match[1]),\n\t\tlast: Number(match[2]),\n\t\ttotal: Number(match[3]),\n\t};\n}\n",
|
|
13
|
+
"import { readFailure } from './fetch-object';\n\n/**\n * The response body, re-exposed so that a failure reading it is rethrown\n * without the signed URL, and cancelling it aborts the request. `skip` and\n * `take` cut a body from a service that answered a range with the whole\n * object.\n */\nexport function relay(\n\tkey: string,\n\tbody: ReadableStream<Uint8Array> | null,\n\tcancel: AbortController,\n\tskip = 0,\n\ttake = Number.POSITIVE_INFINITY,\n): ReadableStream<Uint8Array> {\n\tconst reader = body?.getReader();\n\tlet toSkip = skip;\n\tlet toTake = take;\n\treturn new ReadableStream<Uint8Array>({\n\t\tasync pull(controller) {\n\t\t\tif (!reader || toTake <= 0) {\n\t\t\t\tcontroller.close();\n\t\t\t\tcancel.abort();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfor (;;) {\n\t\t\t\t\tconst next = await reader.read();\n\t\t\t\t\tif (next.done) return controller.close();\n\t\t\t\t\tlet chunk = next.value;\n\t\t\t\t\tif (toSkip > 0) {\n\t\t\t\t\t\tconst dropped = Math.min(toSkip, chunk.length);\n\t\t\t\t\t\ttoSkip -= dropped;\n\t\t\t\t\t\tchunk = chunk.subarray(dropped);\n\t\t\t\t\t}\n\t\t\t\t\tif (chunk.length === 0) continue;\n\t\t\t\t\tif (chunk.length > toTake) chunk = chunk.subarray(0, toTake);\n\t\t\t\t\ttoTake -= chunk.length;\n\t\t\t\t\tcontroller.enqueue(chunk);\n\t\t\t\t\tif (toTake <= 0) cancel.abort();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch (reason) {\n\t\t\t\tif (cancel.signal.aborted && toTake <= 0) return controller.close();\n\t\t\t\tcontroller.error(readFailure(reason, key));\n\t\t\t}\n\t\t},\n\t\tcancel: async (reason) => {\n\t\t\tcancel.abort();\n\t\t\tawait reader?.cancel(reason).catch(() => undefined);\n\t\t},\n\t});\n}\n",
|
|
14
|
+
"import { S3Error } from '../../errors/s3-error';\nimport { type BucketContext, callOf } from '../context';\nimport type { OpenedObject } from '../types';\nimport { failure, readFailure } from './fetch-object';\nimport { parseContentRange } from './open-range';\nimport { relay } from './open-relay';\n\n/** Drops the body of a response that is not going to be read. */\nasync function discard(response: Response, signal: AbortSignal) {\n\ttry {\n\t\tawait response.body?.cancel();\n\t} catch (reason) {\n\t\tif (signal.aborted) throw reason;\n\t\t// The body is not wanted: a failure closing it changes nothing.\n\t}\n}\n\nfunction unsatisfiable(\n\tcontext: BucketContext<unknown>,\n\tkey: string,\n\tobjectSize: number | undefined,\n): S3Error {\n\treturn new S3Error(\n\t\t'RANGE_NOT_SATISFIABLE',\n\t\tkey,\n\t\t`${callOf(context, 'open')}: the range starts at or past the end of the object` +\n\t\t\t(objectSize === undefined ? '' : ` (${objectSize} bytes)`),\n\t\t{ ...(objectSize === undefined ? {} : { objectSize }) },\n\t);\n}\n\n/** A non-2xx answer: `undefined` for a missing object, else a thrown error. */\nasync function refuse(\n\tcontext: BucketContext<unknown>,\n\tkey: string,\n\tresponse: Response,\n\tsignal: AbortSignal,\n): Promise<undefined> {\n\tconst { headers, status } = response;\n\tif (status === 416) {\n\t\tawait discard(response, signal);\n\t\tconst size = /^bytes \\*\\/(\\d+)$/.exec(\n\t\t\theaders.get('content-range') ?? '',\n\t\t)?.[1];\n\t\tthrow unsatisfiable(\n\t\t\tcontext,\n\t\t\tkey,\n\t\t\tsize === undefined ? undefined : Number(size),\n\t\t);\n\t}\n\tlet body: Uint8Array;\n\ttry {\n\t\tbody = new Uint8Array(await response.arrayBuffer());\n\t} catch (reason) {\n\t\tif (signal.aborted) throw reason;\n\t\tthrow readFailure(reason, key);\n\t}\n\tconst error = failure({ status, ok: false, headers, body }, key);\n\tif ((error as { code?: string }).code === 'NoSuchKey') return undefined;\n\tthrow error;\n}\n\n/** The whole-number header `name`, or `undefined` when absent or not one. */\nfunction numberHeader(headers: Headers, name: string): number | undefined {\n\tconst value = headers.get(name);\n\treturn value !== null && /^\\d+$/.test(value) ? Number(value) : undefined;\n}\n\n/** What the headers say about the object, whatever the status. */\nfunction described(headers: Headers) {\n\tconst modified = headers.get('last-modified');\n\tconst date = modified === null ? undefined : new Date(modified);\n\treturn {\n\t\tcontentType: headers.get('content-type') ?? undefined,\n\t\tcontentEncoding: headers.get('content-encoding') ?? undefined,\n\t\tcontentDisposition: headers.get('content-disposition') ?? undefined,\n\t\tcacheControl: headers.get('cache-control') ?? undefined,\n\t\teTag: headers.get('etag') ?? undefined,\n\t\tlastModified: date && !Number.isNaN(date.getTime()) ? date : undefined,\n\t};\n}\n\n/**\n * A service that ignores `Range` and answers 200 with the whole object: the\n * range is cut here, so the caller gets 206 semantics regardless. With no\n * `Content-Length` a `{ start, end? }` range is cut while streaming, and a\n * suffix, which needs the length, is refused.\n */\nasync function cutLocally(\n\tcontext: BucketContext<unknown>,\n\tkey: string,\n\trange: string,\n\tresponse: Response,\n\tcancel: AbortController,\n): Promise<OpenedObject> {\n\tconst size = numberHeader(response.headers, 'content-length');\n\tconst common = described(response.headers);\n\tif (size === undefined) {\n\t\tconst [, from = '', to = ''] = /^bytes=(\\d*)-(\\d*)$/.exec(range) ?? [];\n\t\tif (from === '') {\n\t\t\tawait discard(response, cancel.signal);\n\t\t\tthrow new S3Error(\n\t\t\t\t'RANGE_NOT_SATISFIABLE',\n\t\t\t\tkey,\n\t\t\t\t`${callOf(context, 'open')}: the service ignored the range and gave no ` +\n\t\t\t\t\t'Content-Length, so a suffix range cannot be cut: the end of the ' +\n\t\t\t\t\t'object is not known',\n\t\t\t);\n\t\t}\n\t\tconst start = Number(from);\n\t\tconst length = to === '' ? undefined : Number(to) - start + 1;\n\t\treturn {\n\t\t\t...common,\n\t\t\tstream: relay(key, response.body, cancel, start, length),\n\t\t\tsize: undefined,\n\t\t\tcontentLength: length,\n\t\t\tcontentRange: undefined,\n\t\t};\n\t}\n\tconst [, from = '', to = ''] = /^bytes=(\\d*)-(\\d*)$/.exec(range) ?? [];\n\tconst first = from === '' ? Math.max(0, size - Number(to)) : Number(from);\n\tconst last =\n\t\tfrom === '' || to === '' ? size - 1 : Math.min(Number(to), size - 1);\n\tif (first >= size) {\n\t\tawait discard(response, cancel.signal);\n\t\tthrow unsatisfiable(context, key, size);\n\t}\n\treturn {\n\t\t...common,\n\t\tstream: relay(key, response.body, cancel, first, last - first + 1),\n\t\tsize,\n\t\tcontentLength: last - first + 1,\n\t\tcontentRange: `bytes ${first}-${last}/${size}`,\n\t};\n}\n\n/** Turns an answer with headers into the opened object (or a refusal). */\nexport async function answer(\n\tcontext: BucketContext<unknown>,\n\tkey: string,\n\trange: string | undefined,\n\tresponse: Response,\n\tsignal: AbortSignal,\n\tcancel: AbortController,\n): Promise<OpenedObject | undefined> {\n\tconst { headers, status } = response;\n\tif (!response.ok) return refuse(context, key, response, signal);\n\tconst common = described(headers);\n\tconst length = numberHeader(headers, 'content-length');\n\tconst stream = () => relay(key, response.body, cancel);\n\tif (status === 206) {\n\t\tconst parsed = parseContentRange(headers.get('content-range'));\n\t\treturn {\n\t\t\t...common,\n\t\t\tstream: stream(),\n\t\t\tsize: parsed?.total,\n\t\t\tcontentLength: parsed ? parsed.last - parsed.first + 1 : length,\n\t\t\tcontentRange: headers.get('content-range') ?? undefined,\n\t\t};\n\t}\n\tif (range === undefined) {\n\t\treturn {\n\t\t\t...common,\n\t\t\tstream: stream(),\n\t\t\tsize: length,\n\t\t\tcontentLength: length,\n\t\t\tcontentRange: undefined,\n\t\t};\n\t}\n\treturn cutLocally(context, key, range, response, cancel);\n}\n",
|
|
15
|
+
"import type { BucketContext } from '../context';\nimport { keyOf } from '../context';\nimport type { OpenedObject, OpenOptions } from '../types';\nimport { deadlineOf, withDeadline } from './deadline';\nimport { readFailure } from './fetch-object';\nimport { answer } from './open-answer';\nimport { rangeHeader } from './open-range';\n\n/**\n * GET up to the response headers. `decompress: false`: the bytes are the\n * ones stored, whatever `Content-Encoding` they were stored with, and\n * `contentLength` and `Content-Range` count those bytes.\n */\nasync function send(\n\tcontext: BucketContext<unknown>,\n\tkey: string,\n\trange: string | undefined,\n\tsignal: AbortSignal,\n): Promise<Response> {\n\tconst url = context.client.presign(key, { method: 'GET', expiresIn: 60 });\n\ttry {\n\t\treturn await fetch(url, {\n\t\t\tmethod: 'GET',\n\t\t\tsignal,\n\t\t\tdecompress: false,\n\t\t\t...(range ? { headers: { Range: range } } : {}),\n\t\t});\n\t} catch (reason) {\n\t\tif (signal.aborted) throw reason;\n\t\tthrow readFailure(reason, key);\n\t}\n}\n\nasync function request(\n\tcontext: BucketContext<unknown>,\n\tkey: string,\n\trange: string | undefined,\n\tsignal: AbortSignal,\n\tcancel: AbortController,\n): Promise<OpenedObject | undefined> {\n\tconst response = await send(context, key, range, signal);\n\treturn answer(context, key, range, response, signal, cancel);\n}\n\nexport async function openObject<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: OpenOptions,\n): Promise<OpenedObject | undefined> {\n\tconst key = keyOf(context, params);\n\tconst range =\n\t\toptions?.range === undefined\n\t\t\t? undefined\n\t\t\t: rangeHeader(context, key, options.range);\n\tconst timeoutMs = deadlineOf(context, key, 'open', options);\n\tconst cancel = new AbortController();\n\tconst bare = context as BucketContext<unknown>;\n\ttry {\n\t\tif (timeoutMs === undefined) {\n\t\t\treturn await request(bare, key, range, cancel.signal, cancel);\n\t\t}\n\t\t// The timer stops when `request` returns, that is at the headers.\n\t\treturn await withDeadline(context, key, 'open', timeoutMs, (signal) =>\n\t\t\trequest(\n\t\t\t\tbare,\n\t\t\t\tkey,\n\t\t\t\trange,\n\t\t\t\tAbortSignal.any([signal, cancel.signal]),\n\t\t\t\tcancel,\n\t\t\t),\n\t\t);\n\t} catch (reason) {\n\t\tcancel.abort();\n\t\tthrow reason;\n\t}\n}\n",
|
|
16
|
+
"import { S3Error } from '../errors/s3-error';\nimport { shapeOf } from './shape';\n\n/** Printable ASCII, space to tilde: no CR, LF, NUL, tab or other control. */\nconst PRINTABLE_ASCII = /^[\\x20-\\x7E]+$/;\n\n/**\n * Refuses a `contentDisposition` that could not be one header value: a\n * non-empty string of printable ASCII. A line break in it would split the\n * header it ends up in, and RFC 6266 spells a non-ASCII filename as\n * `filename*=UTF-8''...`, percent-encoded, so ASCII loses nothing. The value\n * is reported by its shape, never quoted: it may have come off a request.\n */\nexport function checkDisposition(\n\tkey: string,\n\tvalue: unknown,\n\twhere: string,\n): void {\n\tif (typeof value === 'string' && PRINTABLE_ASCII.test(value)) return;\n\tthrow new S3Error(\n\t\t'WRONG_OPTION',\n\t\tkey,\n\t\t'contentDisposition must be a non-empty string of printable ASCII, ' +\n\t\t\t'with no line break or control character (spell a non-ASCII filename ' +\n\t\t\t`as filename*=UTF-8''...); got ${\n\t\t\t\ttypeof value === 'string' && value !== ''\n\t\t\t\t\t? 'a string with other characters'\n\t\t\t\t\t: shapeOf(value)\n\t\t\t} (${where})`,\n\t);\n}\n",
|
|
17
|
+
"import { S3Error } from '../errors/s3-error';\nimport type { BucketContext } from './context';\nimport { checkDisposition } from './disposition';\nimport type { PresignOptions } from './operations/presign';\nimport { shapeOf } from './shape';\nimport type { PutBody, PutOptions } from './types';\n\n/**\n * A content type without its parameters, lower-cased: `text/plain` from\n * `text/plain;charset=utf-8`.\n *\n * Both sides of the comparison go through this, because the type a body\n * carries is rarely the bare one a definition names — `Bun.file('a.json')`\n * reports `application/json;charset=utf-8` (measured on bun 1.4.2), and an\n * explicit `IMAGE/PNG` is the same type as `image/png`.\n */\nexport function essenceOf(type: string): string {\n\treturn (type.split(';')[0] ?? '').trim().toLowerCase();\n}\n\n/**\n * The type a write would carry: the one the caller named, or the one the\n * body knows about itself. One function, so the type `check` approves and\n * the type `put` sends can never be two different answers.\n */\nexport function effectiveType(\n\tbody: unknown,\n\tnamed: string | undefined,\n): string | undefined {\n\t// A Blob carries its own type; anything else has to be told.\n\treturn named ?? (body instanceof Blob ? body.type || undefined : undefined);\n}\n\n/** The body's size, or `undefined` when it cannot be known before sending. */\nexport function sizeOf(body: PutBody): number | undefined {\n\tif (typeof body === 'string') return Buffer.byteLength(body, 'utf8');\n\t// An `S3File` **is** a `Blob` — measured on bun 1.4.2 — and its `size` is\n\t// `NaN`, because nothing has asked the service yet. Returning that would\n\t// pass the guard silently: `NaN > maxSize` is false, whatever `maxSize` is.\n\tif (body instanceof Blob) {\n\t\treturn Number.isFinite(body.size) ? body.size : undefined;\n\t}\n\tif (body instanceof ArrayBuffer) return body.byteLength;\n\tif (ArrayBuffer.isView(body)) return body.byteLength;\n\t// A stream, a `Response`: nothing says how long it is until it has been\n\t// read, which is what `UNMEASURABLE` is about.\n\treturn undefined;\n}\n\n/**\n * ` (put on \"avatars\")`: the call and the bucket, after the searchable lead,\n * so every refusal names both and the lead still reads the same in a log.\n */\nconst named = (where: string) => ` (${where})`;\n\n/**\n * Refuses a type the bucket does not accept. Shared by `put` and\n * `presignPost`; `where` is `callOf`'s, the call and the bucket. The type\n * itself is never quoted: for a presigned POST it came off a request.\n */\nexport function checkType<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\ttype: string | undefined,\n\twhere: string,\n): void {\n\tconst { accepted } = context;\n\tif (!accepted) return;\n\tconst list = accepted.join(', ');\n\tconst suffix = named(where);\n\tif (!type) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_TYPE',\n\t\t\tkey,\n\t\t\t`\"${context.definition.bucket}\" accepts ${list}, and no content type ` +\n\t\t\t\t`was named. Pass \\`type\\`${suffix}`,\n\t\t);\n\t}\n\tif (!accepted.some((one) => essenceOf(one) === essenceOf(type))) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_TYPE',\n\t\t\tkey,\n\t\t\t`\"${context.definition.bucket}\" accepts ${list}, not the type given${suffix}`,\n\t\t);\n\t}\n}\n\n/** Refuses a body the bucket does not accept, before anything is sent. */\nexport function checkSize<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tbody: PutBody,\n\twhere: string,\n): void {\n\tconst { maxSize, bucket } = context.definition;\n\tif (maxSize === undefined) return;\n\tconst size = sizeOf(body);\n\tif (size === undefined) {\n\t\tthrow new S3Error(\n\t\t\t'UNMEASURABLE',\n\t\t\tkey,\n\t\t\t`\"${bucket}\" has a maxSize, and this body's size cannot be known ` +\n\t\t\t\t'before sending it. Read it into memory first, or drop `maxSize` ' +\n\t\t\t\t`and let the service refuse it${named(where)}`,\n\t\t);\n\t}\n\tif (size > maxSize) {\n\t\tthrow new S3Error(\n\t\t\t'TOO_LARGE',\n\t\t\tkey,\n\t\t\t`\"${bucket}\" accepts ${maxSize} bytes at most, and this body is ` +\n\t\t\t\t`${size}${named(where)}`,\n\t\t);\n\t}\n}\n\n/**\n * The values the service accepts for the two options that have a fixed set,\n * listed so this package refuses a wrong one itself.\n *\n * Bun checks them too, and refuses with a plain `TypeError` — measured on\n * bun 1.4.2, `name` is `\"TypeError\"`. Every other refusal of the same call\n * is an `S3Error` with a code, so a caller had to catch two classes for one\n * `put`, and read message text for one of them. Checking here gives every\n * refusal of a write one class and one code.\n *\n * The exhaustiveness lines below are the ones `PASSED` carries in `writes.ts`,\n * for the values rather than the keys: a value Bun adds or drops fails the\n * build here instead of silently widening or narrowing what this package\n * accepts.\n */\nconst ACLS = [\n\t'private',\n\t'public-read',\n\t'public-read-write',\n\t'aws-exec-read',\n\t'authenticated-read',\n\t'bucket-owner-read',\n\t'bucket-owner-full-control',\n\t'log-delivery-write',\n] as const satisfies readonly NonNullable<PutOptions['acl']>[];\n\nconst STORAGE_CLASSES = [\n\t'STANDARD',\n\t'DEEP_ARCHIVE',\n\t'EXPRESS_ONEZONE',\n\t'GLACIER',\n\t'GLACIER_IR',\n\t'INTELLIGENT_TIERING',\n\t'ONEZONE_IA',\n\t'OUTPOSTS',\n\t'REDUCED_REDUNDANCY',\n\t'SNOW',\n\t'STANDARD_IA',\n] as const satisfies readonly NonNullable<PutOptions['storageClass']>[];\n\ntype UnlistedAcl = Exclude<\n\tNonNullable<PutOptions['acl']>,\n\t(typeof ACLS)[number]\n>;\nconst _everyAclListed: [UnlistedAcl] extends [never] ? true : UnlistedAcl =\n\ttrue;\nvoid _everyAclListed;\n\ntype UnlistedClass = Exclude<\n\tNonNullable<PutOptions['storageClass']>,\n\t(typeof STORAGE_CLASSES)[number]\n>;\nconst _everyClassListed: [UnlistedClass] extends [never]\n\t? true\n\t: UnlistedClass = true;\nvoid _everyClassListed;\n\nconst ALLOWED = {\n\tacl: ACLS,\n\tstorageClass: STORAGE_CLASSES,\n} as const satisfies Partial<\n\tRecord<keyof PutOptions | keyof PresignOptions, readonly string[]>\n>;\n\n/**\n * The longest a presigned URL can live: SigV4's own limit, seven days.\n *\n * Measured on bun 1.4.2: the client refuses `0` and below with a `TypeError`\n * of its own, and **signs** an `expiresIn` of `1e12` happily — a URL the\n * service then rejects at use time, which is the one thing this package\n * exists not to do.\n */\nconst MAX_EXPIRES_IN = 604_800;\n\n/**\n * Refuses a value the service does not accept for `acl`, `storageClass`,\n * `expiresIn` or `contentDisposition`.\n * Shared by `put` and the three presigned calls, so the same wrong `acl` is\n * the same error whichever one a caller reached for; `where` is `callOf`'s,\n * the call and the bucket. An option with no fixed set passes. The value is\n * reported by its shape, never quoted.\n */\nexport function checkOption(\n\tkey: string,\n\tname: string,\n\tvalue: unknown,\n\twhere: string,\n): void {\n\tif (value === undefined) return;\n\tif (name === 'expiresIn') {\n\t\tcheckExpiresIn(key, value, where);\n\t\treturn;\n\t}\n\tif (name === 'contentDisposition') {\n\t\tcheckDisposition(key, value, where);\n\t\treturn;\n\t}\n\tconst allowed = (ALLOWED as Record<string, readonly string[] | undefined>)[\n\t\tname\n\t];\n\tif (!allowed) return;\n\tif (!allowed.includes(value as string)) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`${name} must be one of ${allowed.join(', ')}; got ` +\n\t\t\t\t`${typeof value === 'string' ? 'another string' : shapeOf(value)}` +\n\t\t\t\tnamed(where),\n\t\t);\n\t}\n}\n\nfunction checkExpiresIn(key: string, value: unknown, where: string): void {\n\tif (\n\t\ttypeof value !== 'number' ||\n\t\t!Number.isFinite(value) ||\n\t\tvalue <= 0 ||\n\t\tvalue > MAX_EXPIRES_IN\n\t) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`expiresIn is seconds, and must be above 0 and at most ` +\n\t\t\t\t`${MAX_EXPIRES_IN} (seven days, which is S3's own limit); ` +\n\t\t\t\t`got ${tooLong(value) ? 'a number above that' : shapeOf(value)}` +\n\t\t\t\tnamed(where),\n\t\t);\n\t}\n}\n\nconst tooLong = (value: unknown) =>\n\ttypeof value === 'number' && Number.isFinite(value) && value > MAX_EXPIRES_IN;\n",
|
|
18
|
+
"import type { S3Options } from 'bun';\nimport { type BucketContext, callOf, keyOf } from '../context';\nimport { checkOption } from '../guards';\n\n/** How a presigned URL is asked for. `expiresIn` is **seconds**, as S3's is. */\nexport interface PresignOptions {\n\t/** Seconds until it expires. Bun's default is a day; give one. */\n\texpiresIn?: number | undefined;\n\t/** `public-read` and the rest, when the service honours it. */\n\tacl?: S3Options['acl'];\n}\n\n/** What a signed GET may add: how the download is presented. */\nexport interface PresignGetOptions extends PresignOptions {\n\t/**\n\t * Signs `response-content-disposition`: the service answers this URL with\n\t * that `Content-Disposition`, whatever the object stored. A download link\n\t * with a filename: `attachment; filename*=UTF-8''report.pdf`. Printable\n\t * ASCII only. A `presignPut` takes none: the header would mean nothing\n\t * to a write.\n\t */\n\tcontentDisposition?: string | undefined;\n}\n\n/** What is signed: the options a caller gave, none of them `undefined`. */\ntype Signed<O> = {\n\t[K in keyof O]?: Exclude<O[K], undefined>;\n};\n\n/**\n * The options this package signs with, and only those.\n *\n * The same rule as a write's, for the same measured reason: Bun's second\n * parameter extends `S3Options`, so a value carrying extra keys at run time —\n * an options bag off a request body, anything that is not a fresh object\n * literal — **redirects the signed URL**. Measured: a `bucket` key signs a\n * URL for another bucket, and a credential key signs it against another\n * endpoint entirely. The types refuse both; a value that never met the types\n * does not.\n */\nconst SIGNED_PUT = [\n\t'expiresIn',\n\t'acl',\n] as const satisfies readonly (keyof PresignOptions)[];\n\n/** A GET signs the same, and `contentDisposition` besides. */\nconst SIGNED_GET = [\n\t'expiresIn',\n\t'acl',\n\t'contentDisposition',\n] as const satisfies readonly (keyof PresignGetOptions)[];\n\ntype UnsignedPut = Exclude<keyof PresignOptions, (typeof SIGNED_PUT)[number]>;\nconst _putForgotten: [UnsignedPut] extends [never] ? true : UnsignedPut = true;\nvoid _putForgotten;\n\ntype UnsignedGet = Exclude<\n\tkeyof PresignGetOptions,\n\t(typeof SIGNED_GET)[number]\n>;\nconst _getForgotten: [UnsignedGet] extends [never] ? true : UnsignedGet = true;\nvoid _getForgotten;\n\nfunction signed<O extends PresignOptions>(\n\tkey: string,\n\toptions: O | undefined,\n\tnames: readonly (keyof O & string)[],\n\twhere: string,\n): Signed<O> {\n\tconst forwarded: Record<string, unknown> = {};\n\tfor (const name of names) {\n\t\tconst value = options?.[name];\n\t\tif (value === undefined) continue;\n\t\t// The same allowlist a `put` is held to: a wrong `acl` is an `S3Error`\n\t\t// with `WRONG_OPTION` whichever of the two a caller reached for, rather\n\t\t// than an `S3Error` here and Bun's own `TypeError` there.\n\t\tcheckOption(key, name, value, where);\n\t\tforwarded[name] = value;\n\t}\n\treturn forwarded as Signed<O>;\n}\n\nexport function presignGetUrl<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: PresignGetOptions,\n): string {\n\tconst key = keyOf(context, params);\n\treturn context.presignClient.presign(key, {\n\t\t...signed(key, options, SIGNED_GET, callOf(context, 'presignGet')),\n\t\tmethod: 'GET',\n\t});\n}\n\n/**\n * A URL that writes this object, signed.\n *\n * It carries **no content type**, and takes none. Measured on bun 1.4.2:\n * `presign`'s `type` only adds `response-content-type`, S3's override for\n * what a *download* is labelled; `X-Amz-SignedHeaders` stays `host`, so the\n * `Content-Type` the uploader sends is not signed and not constrained. A PUT\n * signed for a `text/csv` bucket stores an `application/zip` body happily —\n * measured against this package's own test service, status 200. Naming a type\n * here would only look like a guarantee.\n */\nexport function presignPutUrl<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: PresignOptions,\n): string {\n\tconst key = keyOf(context, params);\n\treturn context.presignClient.presign(key, {\n\t\t...signed(key, options, SIGNED_PUT, callOf(context, 'presignPut')),\n\t\tmethod: 'PUT',\n\t});\n}\n",
|
|
19
|
+
"import type { S3Options } from 'bun';\nimport { S3Error } from '../../errors/s3-error';\nimport { type BucketContext, callOf, keyOf } from '../context';\nimport { checkOption, checkType } from '../guards';\nimport { shapeOf } from '../shape';\nimport {\n\ttype PolicyCondition,\n\ttype PresignedPost,\n\tsignPostPolicy,\n} from './post-policy';\nimport { signerOf } from './post-signer';\n\nexport type { PresignedPost };\n\n/**\n * How a presigned POST is asked for. Every bound here is one the **service**\n * holds the upload to — measured against SeaweedFS 4.47, a body over\n * `maxSize` is refused with `400 EntityTooLarge` and a wrong type with\n * `403 AccessDenied`.\n */\nexport interface PresignPostOptions {\n\t/** Seconds until the form expires: above 0, at most 604800. A day when left out. */\n\texpiresIn?: number;\n\t/**\n\t * The biggest body, in bytes. Defaults to the bucket's own `maxSize`, and\n\t * cannot be above it; a bucket without one requires it.\n\t */\n\tmaxSize?: number;\n\t/** The smallest body, in bytes. `0` when left out. */\n\tminSize?: number;\n\t/**\n\t * The one content type the form may carry, or a prefix of it. Defaults to\n\t * the bucket's `contentType` when that is a single type. A prefix is for\n\t * a bucket that names no type: the page's code then appends its own\n\t * `Content-Type` field before the file.\n\t */\n\ttype?: string | { startsWith: string };\n\t/** `public-read` and the rest, fixed by the policy. */\n\tacl?: S3Options['acl'];\n\t/**\n\t * The `Content-Disposition` the object is stored with, fixed by the\n\t * policy: the browser posts exactly this field. Printable ASCII only.\n\t */\n\tcontentDisposition?: string | undefined;\n}\n\n/** Bun's own default for a presigned URL, a day, so all three agree. */\nconst DEFAULT_EXPIRES_IN = 86_400;\n\nconst callOn = <P>(context: BucketContext<P>) => callOf(context, 'presignPost');\n\nfunction checkBytes<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tname: 'maxSize' | 'minSize',\n\tvalue: unknown,\n\tleast: number,\n): asserts value is number {\n\tif (typeof value === 'number' && Number.isSafeInteger(value)) {\n\t\tif (value >= least) return;\n\t}\n\tthrow new S3Error(\n\t\t'WRONG_OPTION',\n\t\tkey,\n\t\t`${callOn(context)}: ${name} is a whole number of bytes, at least ` +\n\t\t\t`${least}; got ${shapeOf(value)}`,\n\t);\n}\n\n/** `content-length-range`, which is the point of a POST over a PUT. */\nfunction sizeRange<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\toptions: PresignPostOptions | undefined,\n): PolicyCondition {\n\tconst bound = context.definition.maxSize;\n\tconst max = options?.maxSize ?? bound;\n\tif (max === undefined) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`${callOn(context)}: this bucket has no maxSize, and a presigned POST ` +\n\t\t\t\t'is a bound on what a browser uploads. Pass `maxSize`, in bytes',\n\t\t);\n\t}\n\tcheckBytes(context, key, 'maxSize', max, 1);\n\tif (bound !== undefined && max > bound) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`${callOn(context)}: maxSize cannot be above the bucket's own ` +\n\t\t\t\t`${bound} bytes; got a larger number`,\n\t\t);\n\t}\n\tconst min = options?.minSize ?? 0;\n\tcheckBytes(context, key, 'minSize', min, 0);\n\tif (min > max) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`${callOn(context)}: minSize is above maxSize, so no body could be posted`,\n\t\t);\n\t}\n\treturn ['content-length-range', min, max];\n}\n\n/** Either a `Content-Type` field fixed by `eq`, or a `starts-with`. */\ntype TypeRule = { field: string } | { condition: PolicyCondition };\n\nfunction isPrefix(type: unknown): type is { startsWith: string } {\n\treturn (\n\t\ttypeof type === 'object' &&\n\t\ttype !== null &&\n\t\ttypeof (type as { startsWith?: unknown }).startsWith === 'string'\n\t);\n}\n\nfunction typeRule<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\ttype: unknown,\n): TypeRule {\n\tconst { accepted } = context;\n\tif (type === undefined) {\n\t\t// A browser may set its own type only when a condition names it.\n\t\tif (!accepted) return { condition: ['starts-with', '$Content-Type', ''] };\n\t\tif (accepted.length === 1) return { field: accepted[0] as string };\n\t\tcheckType(context, key, undefined, callOn(context));\n\t}\n\tif (typeof type === 'string' && type.length > 0) {\n\t\tcheckType(context, key, type, callOn(context));\n\t\treturn { field: type };\n\t}\n\tif (isPrefix(type)) {\n\t\tif (accepted) {\n\t\t\tthrow new S3Error(\n\t\t\t\t'WRONG_TYPE',\n\t\t\t\tkey,\n\t\t\t\t`${callOn(context)}: this bucket accepts ${accepted.join(', ')}, ` +\n\t\t\t\t\t'and a prefix would let another type through. Pass one of them ' +\n\t\t\t\t\t'as `type`',\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tcondition: ['starts-with', '$Content-Type', type.startsWith],\n\t\t};\n\t}\n\tthrow new S3Error(\n\t\t'WRONG_OPTION',\n\t\tkey,\n\t\t`${callOn(context)}: type is a content type ` +\n\t\t\t`or { startsWith }; got ${shapeOf(type)}`,\n\t);\n}\n\n/**\n * The form a browser posts to upload this object: the key fixed, the size\n * held to a range, the content type fixed or held to a prefix — all by the\n * service. `now` is for the spec; a caller never passes it.\n */\nexport function presignPostForm<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: PresignPostOptions,\n\tnow: Date = new Date(),\n): PresignedPost {\n\tconst key = keyOf(context, params);\n\tconst expiresIn = options?.expiresIn ?? DEFAULT_EXPIRES_IN;\n\tcheckOption(key, 'expiresIn', expiresIn, callOn(context));\n\tconst range = sizeRange(context, key, options);\n\tconst rule = typeRule(context, key, options?.type);\n\tconst fields: Record<string, string> = { key };\n\tif ('field' in rule) fields['Content-Type'] = rule.field;\n\tif (options?.acl !== undefined) {\n\t\tcheckOption(key, 'acl', options.acl, callOn(context));\n\t\tfields['acl'] = options.acl;\n\t}\n\tif (options?.contentDisposition !== undefined) {\n\t\tcheckOption(\n\t\t\tkey,\n\t\t\t'contentDisposition',\n\t\t\toptions.contentDisposition,\n\t\t\tcallOn(context),\n\t\t);\n\t\tfields['Content-Disposition'] = options.contentDisposition;\n\t}\n\treturn signPostPolicy(signerOf(context), {\n\t\tfields,\n\t\tconditions: 'condition' in rule ? [range, rule.condition] : [range],\n\t\texpiresIn,\n\t\tnow,\n\t});\n}\n",
|
|
20
|
+
"import type { S3File, S3Stats } from 'bun';\nimport { type BucketContext, keyOf } from '../context';\nimport type { CallOptions } from '../types';\nimport { deadlineOf, withDeadline } from './deadline';\nimport { getObject, headObject } from './fetch-object';\n\n/**\n * `undefined` rather than a throw when the object is simply not there.\n *\n * It reads straight away and catches the service's own `NoSuchKey`, rather\n * than asking `exists` first: one round trip instead of two, and no window in\n * which an object deleted between the two turns a promised `undefined` into a\n * throw. `stat` is itself a HEAD, so asking first bought nothing at all.\n */\nasync function whenPresent<P, T>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\tread: (file: S3File) => Promise<T>,\n): Promise<T | undefined> {\n\ttry {\n\t\treturn await read(context.client.file(keyOf(context, params)));\n\t} catch (reason) {\n\t\t// Bun names its own S3 failures `S3Error` too, and carries S3's code.\n\t\tif ((reason as { code?: unknown }).code === 'NoSuchKey') return undefined;\n\t\tthrow reason;\n\t}\n}\n\nexport async function readBytes<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: CallOptions,\n): Promise<Uint8Array | undefined> {\n\tconst key = keyOf(context, params);\n\tconst timeoutMs = deadlineOf(context, key, 'bytes', options);\n\tif (timeoutMs === undefined) {\n\t\treturn whenPresent(context, params, (file) => file.bytes());\n\t}\n\treturn withDeadline(context, key, 'bytes', timeoutMs, (signal) =>\n\t\tgetObject(context, key, signal),\n\t);\n}\n\nexport async function readText<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: CallOptions,\n): Promise<string | undefined> {\n\tconst key = keyOf(context, params);\n\tconst timeoutMs = deadlineOf(context, key, 'text', options);\n\tif (timeoutMs === undefined) {\n\t\treturn whenPresent(context, params, (file) => file.text());\n\t}\n\treturn withDeadline(context, key, 'text', timeoutMs, async (signal) => {\n\t\tconst found = await getObject(context, key, signal);\n\t\treturn found && new TextDecoder().decode(found);\n\t});\n}\n\nexport async function statObject<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: CallOptions,\n): Promise<S3Stats | undefined> {\n\tconst key = keyOf(context, params);\n\tconst timeoutMs = deadlineOf(context, key, 'stat', options);\n\tif (timeoutMs === undefined) {\n\t\treturn whenPresent(context, params, (file) => file.stat());\n\t}\n\treturn withDeadline(context, key, 'stat', timeoutMs, (signal) =>\n\t\theadObject(context, key, signal),\n\t);\n}\n\nexport async function objectExists<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: CallOptions,\n): Promise<boolean> {\n\tconst key = keyOf(context, params);\n\tconst timeoutMs = deadlineOf(context, key, 'exists', options);\n\tif (timeoutMs === undefined) return context.client.exists(key);\n\treturn withDeadline(\n\t\tcontext,\n\t\tkey,\n\t\t'exists',\n\t\ttimeoutMs,\n\t\tasync (signal) => (await headObject(context, key, signal)) !== undefined,\n\t);\n}\n",
|
|
21
|
+
"import { S3Error } from '../../errors/s3-error';\nimport { type BucketContext, callOf, keyOf } from '../context';\nimport { shapeOf } from '../shape';\nimport type { ByteRange, CallOptions } from '../types';\nimport { deadlineOf, withDeadline } from './deadline';\nimport { getRange, headObject } from './fetch-object';\n\nconst isOffset = (value: unknown): value is number =>\n\ttypeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\n\n/** Refuses a range that is not whole numbers with `0 <= start <= end`. */\nfunction checkRange<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\trange: ByteRange,\n): void {\n\tconst { start, end } = (range ?? {}) as Partial<ByteRange>;\n\tif (!isOffset(start) || !isOffset(end) || end < start) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`range is { start, end } as whole numbers with 0 <= start <= end; ` +\n\t\t\t\t`got start ${shapeOf(start)}, end ${shapeOf(end)} (${callOf(context, 'slice')})`,\n\t\t);\n\t}\n}\n\nconst streamOf = (bytes: Uint8Array): ReadableStream<Uint8Array> =>\n\tnew ReadableStream({\n\t\tstart(controller) {\n\t\t\tif (bytes.length > 0) controller.enqueue(bytes);\n\t\t\tcontroller.close();\n\t\t},\n\t});\n\n/**\n * Bun's lazy stream fails on first read when the object is missing, so the\n * first chunk is read here: `undefined` for `NoSuchKey`, otherwise a stream\n * that replays that chunk and carries on.\n */\nasync function bunSlice<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\t{ start, end }: ByteRange,\n): Promise<ReadableStream<Uint8Array> | undefined> {\n\tconst file = context.client.file(key);\n\tif (start === end)\n\t\treturn (await file.exists()) ? streamOf(new Uint8Array()) : undefined;\n\tconst reader = file.slice(start, end).stream().getReader();\n\tlet first: Awaited<ReturnType<typeof reader.read>>;\n\ttry {\n\t\tfirst = await reader.read();\n\t} catch (reason) {\n\t\tconst { code } = reason as { code?: unknown };\n\t\tif (code === 'NoSuchKey') return undefined;\n\t\t// The service refuses a start at or past the end: nothing to read.\n\t\tif (code === 'InvalidRange') return streamOf(new Uint8Array());\n\t\tthrow reason;\n\t}\n\treturn new ReadableStream<Uint8Array>({\n\t\tstart(controller) {\n\t\t\tif (first.done) controller.close();\n\t\t\telse controller.enqueue(first.value);\n\t\t},\n\t\tasync pull(controller) {\n\t\t\tif (first.done) return;\n\t\t\tconst next = await reader.read();\n\t\t\tif (next.done) controller.close();\n\t\t\telse controller.enqueue(next.value);\n\t\t},\n\t\tcancel: (reason) => reader.cancel(reason),\n\t});\n}\n\nexport async function sliceObject<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\trange: ByteRange,\n\toptions?: CallOptions,\n): Promise<ReadableStream<Uint8Array> | undefined> {\n\tconst key = keyOf(context, params);\n\tcheckRange(context, key, range);\n\tconst timeoutMs = deadlineOf(context, key, 'slice', options);\n\tif (timeoutMs === undefined) return bunSlice(context, key, range);\n\treturn withDeadline(context, key, 'slice', timeoutMs, async (signal) => {\n\t\tif (range.start === range.end) {\n\t\t\treturn (\n\t\t\t\t(await headObject(context, key, signal)) && streamOf(new Uint8Array())\n\t\t\t);\n\t\t}\n\t\tconst bytes = await getRange(context, key, range, signal);\n\t\treturn bytes && streamOf(bytes);\n\t});\n}\n",
|
|
22
|
+
"import { S3Error } from '../../errors/s3-error';\nimport { shapeOf } from '../shape';\nimport type { StreamBody } from '../types';\n\n/** The stream the transfer reads, and the failure it found, if any. */\nexport interface Counted {\n\tbody: ReadableStream<Uint8Array>;\n\t/** Set once the source ended short, ran long or failed; the transfer is aborted. */\n\tfailure(): S3Error | undefined;\n}\n\ntype Read = { done: true } | { done: false; value: Uint8Array };\n\n/**\n * The source as a stream that gives exactly `size` bytes, pulled one chunk at\n * a time (nothing is held beyond the chunk in flight and the one read ahead).\n *\n * The last chunk is held back until the source has been read once more and\n * has said it is done: a source with more to give raises `SIZE_MISMATCH`\n * before that chunk is sent, so a body that is too long is never completed.\n * A source that ends short is `SIZE_MISMATCH` too; one that throws, or gives\n * something that is not bytes, is `SOURCE_FAILED` with its error as `cause`.\n * The source is cancelled on any of them, and when the transfer is.\n *\n * `watch(true)` is called whenever the transfer waits on someone else (the\n * source's next chunk, the service taking a chunk, the service's answer after\n * the last one) and `watch(false)` when that wait is over: the caller's idle\n * deadline.\n */\nexport function countedStream(\n\tsource: StreamBody,\n\tsize: number,\n\tkey: string,\n\twhere: string,\n\twatch: (waiting: boolean) => void = () => {},\n): Counted {\n\tlet reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n\tlet iterator: AsyncIterator<Uint8Array> | undefined;\n\ttry {\n\t\tif (source instanceof ReadableStream) reader = source.getReader();\n\t\telse iterator = source[Symbol.asyncIterator]();\n\t} catch (reason) {\n\t\t// A locked stream, or an iterable that cannot start: the source's fault.\n\t\tthrow sourceFailed(key, where, 0, 'could not be read', reason);\n\t}\n\tconst state: CountState = {\n\t\treader,\n\t\titerator,\n\t\tkey,\n\t\twhere,\n\t\tsize,\n\t\tsent: 0,\n\t\tahead: undefined,\n\t\tfailure: undefined,\n\t\twatch,\n\t};\n\tconst body = new ReadableStream<Uint8Array>(\n\t\t{\n\t\t\tpull: (controller) => pullStep(state, controller),\n\t\t\tcancel: (reason) => stopSource(state, reason),\n\t\t},\n\t\t{ highWaterMark: 0 },\n\t);\n\treturn { body, failure: () => state.failure };\n}\n\n/** What a counted transfer knows: data only, the steps below act on it. */\ninterface CountState {\n\treadonly reader: ReadableStreamDefaultReader<Uint8Array> | undefined;\n\treadonly iterator: AsyncIterator<Uint8Array> | undefined;\n\treadonly key: string;\n\treadonly where: string;\n\treadonly size: number;\n\treadonly watch: (waiting: boolean) => void;\n\tsent: number;\n\t/** The read made after the last chunk, to learn whether the source is done. */\n\tahead: Read | undefined;\n\tfailure: S3Error | undefined;\n}\n\nfunction mismatch(\n\tkey: string,\n\twhere: string,\n\tsize: number,\n\twhat: string,\n): S3Error {\n\treturn new S3Error(\n\t\t'SIZE_MISMATCH',\n\t\tkey,\n\t\t`the stream ${what} the declared size of ${size} bytes; the upload ` +\n\t\t\t`was aborted and nothing is stored (${where})`,\n\t);\n}\n\nfunction sourceFailed(\n\tkey: string,\n\twhere: string,\n\tsent: number,\n\twhat: string,\n\tcause?: unknown,\n): S3Error {\n\treturn new S3Error(\n\t\t'SOURCE_FAILED',\n\t\tkey,\n\t\t`the stream ${what} after ${sent} bytes; the upload was aborted and ` +\n\t\t\t`nothing is stored (${where})`,\n\t\t{ cause },\n\t);\n}\n\n/** Never awaited: a source that is stuck must not hold the transfer's end. */\nfunction stopSource(state: CountState, reason?: unknown): void {\n\ttry {\n\t\tconst ended = state.reader\n\t\t\t? state.reader.cancel(reason)\n\t\t\t: state.iterator?.return?.();\n\t\tvoid Promise.resolve(ended).catch(() => {});\n\t} catch {\n\t\t// The source is being abandoned; its own failure changes nothing.\n\t}\n}\n\n/** The next chunk with bytes in it, or `done`. Empty chunks are skipped. */\nasync function readChunk(state: CountState): Promise<Read> {\n\tfor (;;) {\n\t\tconst step = state.reader\n\t\t\t? await state.reader.read()\n\t\t\t: await state.iterator?.next();\n\t\tif (!step || step.done) return { done: true };\n\t\tif (!(step.value instanceof Uint8Array)) {\n\t\t\tthrow sourceFailed(\n\t\t\t\tstate.key,\n\t\t\t\tstate.where,\n\t\t\t\tstate.sent,\n\t\t\t\t`gave ${shapeOf(step.value)}, not bytes`,\n\t\t\t);\n\t\t}\n\t\tif (step.value.byteLength > 0) return { done: false, value: step.value };\n\t}\n}\n\n/** One pull of the transfer: a chunk to the service, or its end, or a failure. */\nasync function pullStep(\n\tstate: CountState,\n\tcontroller: ReadableStreamDefaultController<Uint8Array>,\n): Promise<void> {\n\tconst { key, where, size, watch } = state;\n\twatch(true);\n\ttry {\n\t\tconst current = state.ahead ?? (await readChunk(state));\n\t\tstate.ahead = undefined;\n\t\tif (current.done) {\n\t\t\tif (state.sent !== size) {\n\t\t\t\tthrow mismatch(\n\t\t\t\t\tkey,\n\t\t\t\t\twhere,\n\t\t\t\t\tsize,\n\t\t\t\t\t`ended after ${state.sent} bytes, short of`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcontroller.close();\n\t\t\t// Only the service's answer is left to wait for.\n\t\t\twatch(true);\n\t\t\treturn;\n\t\t}\n\t\tstate.sent += current.value.byteLength;\n\t\tif (state.sent > size)\n\t\t\tthrow mismatch(key, where, size, 'has more bytes than');\n\t\tif (state.sent === size) {\n\t\t\t// The last chunk waits for the source to say it is done.\n\t\t\tstate.ahead = await readChunk(state);\n\t\t\tif (!state.ahead.done) {\n\t\t\t\tthrow mismatch(key, where, size, 'has more bytes than');\n\t\t\t}\n\t\t}\n\t\tcontroller.enqueue(current.value);\n\t\t// Waiting for the service to take it and ask for the next.\n\t\twatch(true);\n\t} catch (reason) {\n\t\tconst error =\n\t\t\treason instanceof S3Error\n\t\t\t\t? reason\n\t\t\t\t: sourceFailed(key, where, state.sent, 'failed', reason);\n\t\tstate.failure = error;\n\t\tstopSource(state);\n\t\tcontroller.error(error);\n\t}\n}\n",
|
|
23
|
+
"import type { BunFile } from 'bun';\nimport type { PutBody } from '../types';\n\n/**\n * What `fetch` can send as it is: it sets `Content-Length` itself for these.\n * An `S3File` is a `Blob` whose `size` is `NaN` (nothing has asked the\n * service), so it is not one of them.\n */\nfunction sendable(body: PutBody): boolean {\n\tif (typeof body === 'string') return true;\n\tif (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) return true;\n\treturn body instanceof Blob && Number.isFinite(body.size);\n}\n\n/**\n * A `Bun.file` that is not there, refused as Bun's own `write` refuses it:\n * an `Error` with code `ENOENT` and the file's path, never the signed URL.\n * Without this, `fetch` reports the missing file as a failed connection.\n * A `Bun.file` is a `Blob` with a finite size and an `exists` — an `S3File`'s\n * size is `NaN`, and a plain `Blob` has no `exists`.\n */\nasync function checkFileThere(body: PutBody): Promise<void> {\n\tif (!(body instanceof Blob) || !Number.isFinite(body.size)) return;\n\tconst file = body as Partial<BunFile>;\n\tif (typeof file.exists !== 'function' || (await file.exists())) return;\n\tconst path = file.name ?? '';\n\tconst error = new Error(\n\t\t`ENOENT: no such file or directory, open '${path}'`,\n\t) as Error & { code: string; path: string; errno: number; syscall: string };\n\terror.code = 'ENOENT';\n\terror.path = path;\n\terror.errno = -2;\n\terror.syscall = 'open';\n\tthrow error;\n}\n\n/** The body as a stream to read, or `undefined` when it has no bytes. */\nfunction streamOf(body: PutBody): ReadableStream<Uint8Array> | undefined {\n\t// `new Response(response)` would store \"[object Response]\" and\n\t// `new Response(s3File)` reads as empty (measured on Bun 1.4.3), so a body\n\t// that can give a stream is asked for it. An `S3File`'s `.stream()` is\n\t// Bun's own download, and cancelling it stops that download (measured: the\n\t// server saw the cancel and sent no more).\n\tif (body instanceof ReadableStream) return body;\n\tif (body instanceof Response || body instanceof Request) {\n\t\treturn body.body ?? undefined;\n\t}\n\tif (body instanceof Blob) return body.stream();\n\treturn new Response(body as BodyInit).body ?? undefined;\n}\n\n/**\n * Reads a stream whole, and **cancels it** when the deadline passes: the\n * source's `cancel` runs and nothing more is pulled (measured on Bun 1.4.3,\n * a read only raced against the signal kept pulling, and held the process\n * open, long after the rejection).\n */\nasync function gather(\n\tstream: ReadableStream<Uint8Array>,\n\tsignal: AbortSignal,\n): Promise<Uint8Array<ArrayBuffer>> {\n\tconst reader = stream.getReader();\n\tconst onAbort = () => void reader.cancel(signal.reason).catch(() => {});\n\tif (signal.aborted) onAbort();\n\telse signal.addEventListener('abort', onAbort, { once: true });\n\tconst chunks: Uint8Array[] = [];\n\tlet length = 0;\n\ttry {\n\t\tfor (;;) {\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (signal.aborted) throw signal.reason;\n\t\t\tif (done) break;\n\t\t\tchunks.push(value);\n\t\t\tlength += value.byteLength;\n\t\t}\n\t} finally {\n\t\tsignal.removeEventListener('abort', onAbort);\n\t}\n\tconst whole = new Uint8Array(length);\n\tlet at = 0;\n\tfor (const chunk of chunks) {\n\t\twhole.set(chunk, at);\n\t\tat += chunk.byteLength;\n\t}\n\treturn whole;\n}\n\n/**\n * The body as `fetch` sends it under a deadline.\n *\n * A string, bytes or a `Blob` of known size go as they are. Anything else —\n * a `ReadableStream`, a `Response`, an `S3File` — is **read into memory\n * first**, inside the deadline: S3 refuses a chunked PUT, which is what\n * `fetch` would send for a stream with no length. A bucket with a `maxSize`\n * has already refused these (`UNMEASURABLE`), so this reaches a bucket\n * without one, and the body's size costs memory there.\n */\nexport async function fetchBody(\n\tbody: PutBody,\n\tsignal: AbortSignal,\n): Promise<BodyInit> {\n\tawait checkFileThere(body);\n\tif (sendable(body)) return body as BodyInit;\n\tconst stream = streamOf(body);\n\treturn stream ? gather(stream, signal) : new Uint8Array(0);\n}\n",
|
|
24
|
+
"import { S3Error } from '../../errors/s3-error';\nimport type { BucketContext } from '../context';\nimport { shapeOf } from '../shape';\nimport type { PutBody, StreamBody } from '../types';\n\n/** A body that streams: it needs a `size`, and a `size` needs it. */\nexport function isStreamBody(body: unknown): body is StreamBody {\n\treturn (\n\t\tbody instanceof ReadableStream ||\n\t\t(typeof body === 'object' &&\n\t\t\tbody !== null &&\n\t\t\ttypeof (body as AsyncIterable<unknown>)[Symbol.asyncIterator] ===\n\t\t\t\t'function')\n\t);\n}\n\n/** A write the caller sized: a stream, and its exact length. */\nexport type SizedBody = { body: StreamBody; size: number };\n/** A write that is not sized: the body goes the way it always did. */\nexport type PlainBody = { body: PutBody; size?: undefined };\n\n/**\n * Sorts a write into sized or plain, and refuses a `size` that is not a whole\n * number of bytes, 0 or more, or that comes with a body which is not a stream\n * (a string, bytes or a `Blob` know their own length), and an `AsyncIterable`\n * that comes without one. Before anything is sent.\n */\nexport function classify(\n\tkey: string,\n\tbody: PutBody | StreamBody,\n\tsize: unknown,\n\twhere: string,\n): SizedBody | PlainBody {\n\tconst streams = isStreamBody(body);\n\tif (size === undefined) {\n\t\tif (streams && !(body instanceof ReadableStream)) {\n\t\t\tthrow new S3Error(\n\t\t\t\t'WRONG_OPTION',\n\t\t\t\tkey,\n\t\t\t\t`an AsyncIterable body needs \\`size\\`, the number of bytes it will give (${where})`,\n\t\t\t);\n\t\t}\n\t\t// An `AsyncIterable` that is not a `ReadableStream` was refused above,\n\t\t// and `PutBody` already holds the stream.\n\t\treturn { body: body as PutBody };\n\t}\n\tif (typeof size !== 'number' || !Number.isSafeInteger(size) || size < 0) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`size is a whole number of bytes, 0 or more; got ${shapeOf(size)} (${where})`,\n\t\t);\n\t}\n\tif (!streams) {\n\t\tthrow new S3Error(\n\t\t\t'WRONG_OPTION',\n\t\t\tkey,\n\t\t\t`size goes with a ReadableStream or an AsyncIterable body; this body ` +\n\t\t\t\t`knows its own length (${where})`,\n\t\t);\n\t}\n\treturn { body, size };\n}\n\n/** Refuses a declared `size` above the bucket's `maxSize`, before any read. */\nexport function checkDeclaredSize<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tsize: number,\n\twhere: string,\n): void {\n\tconst { maxSize, bucket } = context.definition;\n\tif (maxSize !== undefined && size > maxSize) {\n\t\tthrow new S3Error(\n\t\t\t'TOO_LARGE',\n\t\t\tkey,\n\t\t\t`\"${bucket}\" accepts ${maxSize} bytes at most, and this body is ` +\n\t\t\t\t`${size} (${where})`,\n\t\t);\n\t}\n}\n",
|
|
25
|
+
"import { S3Error } from '../../errors/s3-error';\nimport { type BucketContext, callOf, keyOf } from '../context';\nimport { checkOption, checkSize, checkType, effectiveType } from '../guards';\nimport type {\n\tCallOptions,\n\tPutBody,\n\tPutOptions,\n\tStreamBody,\n\tStreamOptions,\n} from '../types';\nimport { type Counted, countedStream } from './counted-stream';\nimport { checkTimeout, deadlineOf, withDeadline } from './deadline';\nimport { type PutRequest, removeObject, storeObject } from './fetch-object';\nimport { fetchBody } from './put-body';\nimport { checkDeclaredSize, classify } from './sized-body';\n\n/**\n * Writes it, once the bucket's content type and size have accepted it. Both\n * guards run before `write` is called, so a refused body is never sent.\n */\nexport async function putObject<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\tbody: PutBody | StreamBody,\n\toptions: PutOptions & CallOptions & StreamOptions = {},\n): Promise<void> {\n\tconst key = keyOf(context, params);\n\tconst where = callOf(context, 'put');\n\tconst write = classify(key, body, options.size, where);\n\tconst type = effectiveType(write.body, options.type);\n\tcheckType(context, key, type, where);\n\tif (write.size === undefined) checkSize(context, key, write.body, where);\n\telse checkDeclaredSize(context, key, write.size, where);\n\t// Refused here with the other two, so every guard on this call answers\n\t// before anything is sent, and every one of them is an `S3Error`.\n\tconst forwarded = passed(key, options, where);\n\tif (write.size !== undefined) {\n\t\tawait putStream(\n\t\t\tcontext,\n\t\t\tkey,\n\t\t\twrite.body,\n\t\t\twrite.size,\n\t\t\ttype,\n\t\t\tforwarded,\n\t\t\t// Only the call's own: the bucket's default is sized for whole\n\t\t\t// requests, and does not apply to a transfer that is idle-bound.\n\t\t\tcheckTimeout(key, options.timeoutMs, where),\n\t\t\twhere,\n\t\t);\n\t\treturn;\n\t}\n\tconst timeoutMs = deadlineOf(context, key, 'put', options);\n\tif (timeoutMs !== undefined) {\n\t\tawait withDeadline(context, key, 'put', timeoutMs, async (signal) =>\n\t\t\tstoreObject(\n\t\t\t\tcontext,\n\t\t\t\tkey,\n\t\t\t\t{\n\t\t\t\t\t...headOf(type, forwarded),\n\t\t\t\t\tbody: await fetchBody(write.body, signal),\n\t\t\t\t},\n\t\t\t\tsignal,\n\t\t\t),\n\t\t);\n\t\treturn;\n\t}\n\t// The very type `checkType` approved, and nothing else: `type` is not one\n\t// of the keys `passed` forwards, so no option can carry a second one in\n\t// beside it.\n\tawait context.client.write(key, write.body, {\n\t\t...forwarded,\n\t\t...(type ? { type } : {}),\n\t});\n}\n\n/**\n * A streamed PUT: the declared `size` goes as `Content-Length` and the body\n * is counted as it is read, so nothing is held whole and a short or long\n * stream aborts the transfer. Always over `fetch`, with or without a\n * deadline, since Bun's own `write` neither takes a length nor honours a signal.\n *\n * `timeoutMs` is an **idle** deadline: it bounds each wait, for the source's\n * next chunk, for the service to take it, and for the service's answer after\n * the last byte, and starts over after each. A slow transfer that keeps\n * moving is never cut; a stall is `TIMEOUT`.\n */\nasync function putStream<P>(\n\tcontext: BucketContext<P>,\n\tkey: string,\n\tsource: StreamBody,\n\tsize: number,\n\ttype: string | undefined,\n\tforwarded: PutOptions,\n\ttimeoutMs: number | undefined,\n\twhere: string,\n): Promise<void> {\n\tconst controller = new AbortController();\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst watch = (waiting: boolean) => {\n\t\tclearTimeout(timer);\n\t\ttimer =\n\t\t\twaiting && timeoutMs !== undefined\n\t\t\t\t? setTimeout(() => controller.abort(), timeoutMs)\n\t\t\t\t: undefined;\n\t};\n\tconst counted: Counted = countedStream(source, size, key, where, watch);\n\tconst head = headOf(type, forwarded);\n\tconst request = {\n\t\t...head,\n\t\tbody: counted.body,\n\t\theaders: { ...head.headers, 'Content-Length': String(size) },\n\t};\n\ttry {\n\t\t// Waiting on the connection counts: `fetch` pulls nothing until it is up.\n\t\twatch(true);\n\t\tawait storeObject(context, key, request, controller.signal);\n\t} catch (reason) {\n\t\t// The deadline first: aborting cancels the source, and a source that\n\t\t// is cancelled looks like one that ended short.\n\t\tif (!controller.signal.aborted) throw counted.failure() ?? reason;\n\t\tthrow new S3Error(\n\t\t\t'TIMEOUT',\n\t\t\tkey,\n\t\t\t`${where}: nothing moved in ${timeoutMs}ms`,\n\t\t);\n\t} finally {\n\t\twatch(false);\n\t}\n}\n\n/**\n * What a PUT under a deadline sends: `acl` and `storageClass` signed into\n * the URL (Bun signs both into the query), and the rest as plain headers —\n * measured on SeaweedFS 4.47, a presigned PUT stores an unsigned\n * `Content-Type`, `Content-Disposition` and `Content-Encoding`. Never given\n * to `presign`, which would write the type and disposition as GET response\n * overrides. A type is always named: `fetch` would otherwise guess one from a\n * string or a `Blob`, where Bun's own `write` stores `application/octet-stream`.\n * The body is added by the caller: read inside the deadline when it has to be.\n */\nfunction headOf(\n\ttype: string | undefined,\n\toptions: PutOptions,\n): Required<Pick<PutRequest, 'headers' | 'signed'>> {\n\t// Bun's own rule for the type it stores, measured: the type as a `Blob`\n\t// normalises it (lower case, `;charset=utf-8` on a text type).\n\tconst headers: Record<string, string> = {\n\t\t'Content-Type': new Blob([], { type: type ?? 'application/octet-stream' })\n\t\t\t.type,\n\t};\n\tif (options.contentDisposition) {\n\t\theaders['Content-Disposition'] = options.contentDisposition;\n\t}\n\tif (options.contentEncoding) {\n\t\theaders['Content-Encoding'] = options.contentEncoding;\n\t}\n\tconst signed: NonNullable<PutRequest['signed']> = {};\n\tif (options.acl) signed.acl = options.acl;\n\tif (options.storageClass) signed.storageClass = options.storageClass;\n\treturn { headers, signed };\n}\n\n/**\n * The options this package forwards, and only those.\n *\n * `PutOptions` refuses the rest at compile time, and that is not enough:\n * measured, spreading the caller's object straight through let a `bucket`\n * key **redirect the write to another bucket** — the object was stored\n * somewhere the definition never described, and the call reported success.\n * Options that arrive from outside a handler are not typed, so the list is\n * applied at run time as well. A key that is not here is dropped, never sent.\n */\ntype Forwardable = Exclude<keyof PutOptions, 'type'>;\n\nconst PASSED = [\n\t'acl',\n\t'storageClass',\n\t'contentDisposition',\n\t'contentEncoding',\n] as const satisfies readonly Forwardable[];\n\n/**\n * `satisfies` proves every key listed is real; it proves nothing about one\n * that is **missing**. Widen `PutOptions` and forget to list the new key\n * here, and the type would advertise an option the run time silently drops —\n * which is the failure this allowlist exists to prevent, in the other\n * direction. This line is what fails the build instead.\n */\ntype Unforwarded = Exclude<Forwardable, (typeof PASSED)[number]>;\nconst _nothingForgotten: [Unforwarded] extends [never] ? true : Unforwarded =\n\ttrue;\nvoid _nothingForgotten;\n\nfunction passed(key: string, options: PutOptions, where: string): PutOptions {\n\tconst forwarded: Record<string, unknown> = {};\n\tfor (const name of PASSED) {\n\t\tconst value = options[name];\n\t\tif (value === undefined) continue;\n\t\tcheckOption(key, name, value, where);\n\t\tforwarded[name] = value;\n\t}\n\treturn forwarded as PutOptions;\n}\n\n/** Removes it. S3 does not say whether anything was there, and nor does this. */\nexport async function deleteObject<P>(\n\tcontext: BucketContext<P>,\n\tparams: P,\n\toptions?: CallOptions,\n): Promise<void> {\n\tconst key = keyOf(context, params);\n\tconst timeoutMs = deadlineOf(context, key, 'delete', options);\n\tif (timeoutMs === undefined) {\n\t\tawait context.client.delete(key);\n\t\treturn;\n\t}\n\tawait withDeadline(context, key, 'delete', timeoutMs, (signal) =>\n\t\tremoveObject(context, key, signal),\n\t);\n}\n",
|
|
26
|
+
"import type { BucketDefinition } from './types';\n\n/**\n * Describes a bucket. It talks to nothing: `bindBucket` is what needs\n * credentials.\n *\n * ```ts\n * export const avatars = defineBucket({\n * \tbucket: 'avatars',\n * \tkey: (p: { userId: string }) => `${p.userId}.png`,\n * \tcontentType: ['image/png', 'image/jpeg'],\n * \tmaxSize: 2 * 1024 * 1024,\n * });\n * ```\n */\nexport function defineBucket<P>(\n\tdefinition: BucketDefinition<P>,\n): BucketDefinition<P> {\n\tif (definition.bucket.length === 0) {\n\t\tthrow new TypeError('defineBucket: a bucket definition needs a bucket');\n\t}\n\tif (definition.maxSize !== undefined) {\n\t\tconst { maxSize } = definition;\n\t\tif (!Number.isFinite(maxSize) || maxSize <= 0) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`defineBucket: \"${definition.bucket}\" has a maxSize of ${maxSize}; ` +\n\t\t\t\t\t'it is a number of bytes, and must be above zero',\n\t\t\t);\n\t\t}\n\t}\n\tconst types = definition.contentType;\n\tif (Array.isArray(types) && types.length === 0) {\n\t\tthrow new TypeError(\n\t\t\t`defineBucket: \"${definition.bucket}\" accepts an empty list of ` +\n\t\t\t\t'content types, so nothing could ever be written. Leave ' +\n\t\t\t\t'`contentType` out to accept anything',\n\t\t);\n\t}\n\treturn Object.freeze({ ...definition });\n}\n",
|
|
27
|
+
"/**\n * Codes that mean the bucket cannot be used from here, rather than that the\n * request was wrong: Bun and Node network failures, this package's own\n * `TIMEOUT`, and the S3 service codes Bun's client surfaces for a\n * deployment problem (credentials, missing bucket, an unhealthy or throttling\n * service). `NoSuchKey` and the other per-request codes are not in it.\n */\nconst UNAVAILABLE_CODES: ReadonlySet<string> = new Set([\n\t// this package's code raised when a request got no answer (RANGE_NOT_SATISFIABLE is raised after one, but is the caller's range)\n\t'TIMEOUT',\n\t// Bun and Node network failures\n\t'ConnectionRefused',\n\t'ConnectionClosed',\n\t'DNSResolveFailed',\n\t'ECONNREFUSED',\n\t'ECONNRESET',\n\t'ECONNABORTED',\n\t'ETIMEDOUT',\n\t'EHOSTUNREACH',\n\t'ENETUNREACH',\n\t'ENOTFOUND',\n\t'EAI_AGAIN',\n\t'EPIPE',\n\t// S3 service codes: the deployment cannot use the bucket\n\t'AccessDenied',\n\t'InvalidAccessKeyId',\n\t'SignatureDoesNotMatch',\n\t'NoSuchBucket',\n\t'ExpiredToken',\n\t'InternalError',\n\t'ServiceUnavailable',\n\t'SlowDown',\n]);\n\n/**\n * Whether a failure means the bucket is unavailable, so a route can answer\n * 503. Reads the `code` of an `Error` only, never its name or message.\n *\n * `true` for: this package's `S3Error` with code `TIMEOUT`; a Bun or Node\n * network code (`ConnectionRefused`, `ECONNREFUSED`, `ETIMEDOUT`, …); and an\n * S3 service code meaning the deployment cannot use the bucket\n * (`AccessDenied`, `InvalidAccessKeyId`, `SignatureDoesNotMatch`,\n * `NoSuchBucket`, `ExpiredToken`, `InternalError`, `ServiceUnavailable`,\n * `SlowDown`).\n *\n * `false` for this package's refusals of the caller's input (`WRONG_TYPE`,\n * `TOO_LARGE`, `UNMEASURABLE`, `WRONG_OPTION`), which stay the caller's\n * (4xx); for per-request codes such as `NoSuchKey`; and for anything that is\n * not an `Error` with a string `code`.\n */\nexport function isBucketUnavailable(error: unknown): boolean {\n\tif (!(error instanceof Error)) return false;\n\tconst { code } = error as { code?: unknown };\n\treturn typeof code === 'string' && UNAVAILABLE_CODES.has(code);\n}\n"
|
|
28
|
+
],
|
|
29
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;;ACOO,IAAM,YAAoC;AAAA,EAChD,cAAc;AAAA,EACd,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,OAAO;AAAA,EACP,gBAAgB;AACjB;AAGO,SAAS,OAAO,CAAC,MAAc,KAAa,SAAwB;AAAA,EAC1E,MAAM,Q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AY,kBAAkB,IAAI,IAAI;AAAA;",
|
|
30
|
+
"debugId": "F9795A19D400B5C464756E2164756E21",
|
|
31
|
+
"names": []
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface FetchRetryOptions {
|
|
2
|
+
fetch?: typeof fetch;
|
|
3
|
+
attempts?: number;
|
|
4
|
+
delay?: (ms: number) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
/** Fetches and reads the whole archive, retrying transient failures with a growing pause. */
|
|
7
|
+
export declare function fetchWithRetry(url: string, deps: FetchRetryOptions): Promise<Uint8Array>;
|
|
8
|
+
//# sourceMappingURL=fetch-archive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-archive.d.ts","sourceRoot":"","sources":["../../src/testing/fetch-archive.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC;AA8BD,6FAA6F;AAC7F,wBAAsB,cAAc,CACnC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC,UAAU,CAAC,CAcrB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { DeadlineOptions } from './ready.js';
|
|
2
|
+
export type { SeaweedfsOptions } from './seaweedfs.js';
|
|
3
|
+
export { seaweedfsBinary, TEST_SEAWEEDFS_VERSION } from './seaweedfs.js';
|
|
4
|
+
export type { TestS3, TestS3Options } from './test-s3.js';
|
|
5
|
+
export { startTestS3 } from './test-s3.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACtE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|