@backblaze-labs/b2-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -5
- package/README.md +144 -33
- package/dist/_virtual/_b2-sdk-version-json.cjs +4 -0
- package/dist/_virtual/_b2-sdk-version-json.js +4 -0
- package/dist/auth/account-info.d.cts +32 -0
- package/dist/auth/account-info.d.cts.map +1 -1
- package/dist/auth/account-info.d.ts +32 -0
- package/dist/auth/account-info.d.ts.map +1 -1
- package/dist/auth/file.cjs +408 -207
- package/dist/auth/file.cjs.map +1 -1
- package/dist/auth/file.d.cts +77 -3
- package/dist/auth/file.d.cts.map +1 -1
- package/dist/auth/file.d.ts +77 -3
- package/dist/auth/file.d.ts.map +1 -1
- package/dist/auth/file.js +407 -207
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/in-memory.cjs +212 -183
- package/dist/auth/in-memory.cjs.map +1 -1
- package/dist/auth/in-memory.d.cts +8 -0
- package/dist/auth/in-memory.d.cts.map +1 -1
- package/dist/auth/in-memory.d.ts +8 -0
- package/dist/auth/in-memory.d.ts.map +1 -1
- package/dist/auth/in-memory.js +211 -182
- package/dist/auth/in-memory.js.map +1 -1
- package/dist/auth/index.cjs +7 -9
- package/dist/auth/index.d.cts +3 -2
- package/dist/auth/index.d.cts.map +1 -1
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -8
- package/dist/auth/realms.cjs +80 -7
- package/dist/auth/realms.cjs.map +1 -1
- package/dist/auth/realms.d.cts +27 -4
- package/dist/auth/realms.d.cts.map +1 -1
- package/dist/auth/realms.d.ts +27 -4
- package/dist/auth/realms.d.ts.map +1 -1
- package/dist/auth/realms.js +80 -9
- package/dist/auth/realms.js.map +1 -1
- package/dist/auth/upload-url-pool.cjs +55 -51
- package/dist/auth/upload-url-pool.cjs.map +1 -1
- package/dist/auth/upload-url-pool.js +55 -51
- package/dist/auth/upload-url-pool.js.map +1 -1
- package/dist/bucket.cjs +785 -787
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.d.cts +35 -47
- package/dist/bucket.d.cts.map +1 -1
- package/dist/bucket.d.ts +35 -47
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +780 -782
- package/dist/bucket.js.map +1 -1
- package/dist/client.cjs +246 -228
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -17
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +25 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +243 -225
- package/dist/client.js.map +1 -1
- package/dist/copy/large.cjs +114 -71
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts +6 -0
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts +6 -0
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +112 -69
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +89 -0
- package/dist/download/checksum.cjs.map +1 -0
- package/dist/download/checksum.d.cts +40 -0
- package/dist/download/checksum.d.cts.map +1 -0
- package/dist/download/checksum.d.ts +40 -0
- package/dist/download/checksum.d.ts.map +1 -0
- package/dist/download/checksum.js +87 -0
- package/dist/download/checksum.js.map +1 -0
- package/dist/download/parallel.cjs +214 -118
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +5 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +5 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +212 -116
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +188 -97
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts +6 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts +6 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +186 -98
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +699 -243
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +285 -82
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +285 -82
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +678 -261
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +45 -28
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.d.cts +15 -2
- package/dist/http/retry.d.cts.map +1 -1
- package/dist/http/retry.d.ts +15 -2
- package/dist/http/retry.d.ts.map +1 -1
- package/dist/http/retry.js +46 -31
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +438 -140
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +21 -2
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +21 -2
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +437 -140
- package/dist/http/transport.js.map +1 -1
- package/dist/http/url-guard.cjs +154 -89
- package/dist/http/url-guard.cjs.map +1 -1
- package/dist/http/url-guard.d.cts +25 -3
- package/dist/http/url-guard.d.cts.map +1 -1
- package/dist/http/url-guard.d.ts +25 -3
- package/dist/http/url-guard.d.ts.map +1 -1
- package/dist/http/url-guard.js +152 -90
- package/dist/http/url-guard.js.map +1 -1
- package/dist/http/user-agent.cjs +84 -44
- package/dist/http/user-agent.cjs.map +1 -1
- package/dist/http/user-agent.js +84 -46
- package/dist/http/user-agent.js.map +1 -1
- package/dist/index.cjs +101 -77
- package/dist/index.d.cts +27 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +27 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -71
- package/dist/internal/b2-naming.cjs +66 -0
- package/dist/internal/b2-naming.cjs.map +1 -0
- package/dist/internal/b2-naming.d.cts +43 -0
- package/dist/internal/b2-naming.d.cts.map +1 -0
- package/dist/internal/b2-naming.d.ts +43 -0
- package/dist/internal/b2-naming.d.ts.map +1 -0
- package/dist/internal/b2-naming.js +60 -0
- package/dist/internal/b2-naming.js.map +1 -0
- package/dist/internal/upload-retry-options.cjs +21 -0
- package/dist/internal/upload-retry-options.cjs.map +1 -0
- package/dist/internal/upload-retry-options.d.cts +12 -0
- package/dist/internal/upload-retry-options.d.cts.map +1 -0
- package/dist/internal/upload-retry-options.d.ts +12 -0
- package/dist/internal/upload-retry-options.d.ts.map +1 -0
- package/dist/internal/upload-retry-options.js +21 -0
- package/dist/internal/upload-retry-options.js.map +1 -0
- package/dist/internal/url-redaction.cjs +31 -0
- package/dist/internal/url-redaction.cjs.map +1 -0
- package/dist/internal/url-redaction.d.cts +17 -0
- package/dist/internal/url-redaction.d.cts.map +1 -0
- package/dist/internal/url-redaction.d.ts +17 -0
- package/dist/internal/url-redaction.d.ts.map +1 -0
- package/dist/internal/url-redaction.js +31 -0
- package/dist/internal/url-redaction.js.map +1 -0
- package/dist/notifications/index.cjs +4 -6
- package/dist/notifications/index.d.cts +1 -1
- package/dist/notifications/index.d.cts.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +1 -6
- package/dist/notifications/webhook.cjs +195 -85
- package/dist/notifications/webhook.cjs.map +1 -1
- package/dist/notifications/webhook.d.cts.map +1 -1
- package/dist/notifications/webhook.d.ts.map +1 -1
- package/dist/notifications/webhook.js +195 -87
- package/dist/notifications/webhook.js.map +1 -1
- package/dist/object.cjs +253 -210
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +9 -55
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +9 -55
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +249 -206
- package/dist/object.js.map +1 -1
- package/dist/raw/encoding.cjs +74 -35
- package/dist/raw/encoding.cjs.map +1 -1
- package/dist/raw/encoding.js +74 -38
- package/dist/raw/encoding.js.map +1 -1
- package/dist/raw/index.cjs +678 -587
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +121 -18
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +121 -18
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +674 -589
- package/dist/raw/index.js.map +1 -1
- package/dist/s3/index.cjs +355 -18
- package/dist/s3/index.cjs.map +1 -1
- package/dist/s3/index.d.cts +233 -5
- package/dist/s3/index.d.cts.map +1 -1
- package/dist/s3/index.d.ts +233 -5
- package/dist/s3/index.d.ts.map +1 -1
- package/dist/s3/index.js +351 -22
- package/dist/s3/index.js.map +1 -1
- package/dist/s3/sigv4.cjs +149 -0
- package/dist/s3/sigv4.cjs.map +1 -0
- package/dist/s3/sigv4.d.cts +43 -0
- package/dist/s3/sigv4.d.cts.map +1 -0
- package/dist/s3/sigv4.d.ts +43 -0
- package/dist/s3/sigv4.d.ts.map +1 -0
- package/dist/s3/sigv4.js +148 -0
- package/dist/s3/sigv4.js.map +1 -0
- package/dist/s3/validation.cjs +69 -0
- package/dist/s3/validation.cjs.map +1 -0
- package/dist/s3/validation.d.cts +43 -0
- package/dist/s3/validation.d.cts.map +1 -0
- package/dist/s3/validation.d.ts +43 -0
- package/dist/s3/validation.d.ts.map +1 -0
- package/dist/s3/validation.js +66 -0
- package/dist/s3/validation.js.map +1 -0
- package/dist/simulator/capabilities.cjs +63 -48
- package/dist/simulator/capabilities.cjs.map +1 -1
- package/dist/simulator/capabilities.js +63 -49
- package/dist/simulator/capabilities.js.map +1 -1
- package/dist/simulator/index.cjs +2124 -1548
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +79 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +79 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2112 -1546
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/validation.cjs +191 -153
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +3 -21
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +3 -21
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +188 -162
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/collect.cjs +74 -24
- package/dist/streams/collect.cjs.map +1 -1
- package/dist/streams/collect.d.cts +14 -1
- package/dist/streams/collect.d.cts.map +1 -1
- package/dist/streams/collect.d.ts +14 -1
- package/dist/streams/collect.d.ts.map +1 -1
- package/dist/streams/collect.js +74 -25
- package/dist/streams/collect.js.map +1 -1
- package/dist/streams/file-source.cjs +287 -0
- package/dist/streams/file-source.cjs.map +1 -0
- package/dist/streams/file-source.d.cts +96 -0
- package/dist/streams/file-source.d.cts.map +1 -0
- package/dist/streams/file-source.d.ts +96 -0
- package/dist/streams/file-source.d.ts.map +1 -0
- package/dist/streams/file-source.js +286 -0
- package/dist/streams/file-source.js.map +1 -0
- package/dist/streams/hash.cjs +207 -115
- package/dist/streams/hash.cjs.map +1 -1
- package/dist/streams/hash.d.cts +5 -4
- package/dist/streams/hash.d.cts.map +1 -1
- package/dist/streams/hash.d.ts +5 -4
- package/dist/streams/hash.d.ts.map +1 -1
- package/dist/streams/hash.js +208 -95
- package/dist/streams/hash.js.map +1 -1
- package/dist/streams/index.cjs +12 -12
- package/dist/streams/index.d.cts +3 -3
- package/dist/streams/index.d.cts.map +1 -1
- package/dist/streams/index.d.ts +3 -3
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/index.js +2 -10
- package/dist/streams/progress.cjs +60 -46
- package/dist/streams/progress.cjs.map +1 -1
- package/dist/streams/progress.js +60 -46
- package/dist/streams/progress.js.map +1 -1
- package/dist/streams/source.cjs +316 -146
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.d.cts +56 -18
- package/dist/streams/source.d.cts.map +1 -1
- package/dist/streams/source.d.ts +56 -18
- package/dist/streams/source.d.ts.map +1 -1
- package/dist/streams/source.js +312 -149
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/actions/index.cjs +236 -184
- package/dist/sync/actions/index.cjs.map +1 -1
- package/dist/sync/actions/index.d.cts +29 -21
- package/dist/sync/actions/index.d.cts.map +1 -1
- package/dist/sync/actions/index.d.ts +29 -21
- package/dist/sync/actions/index.d.ts.map +1 -1
- package/dist/sync/actions/index.js +236 -190
- package/dist/sync/actions/index.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +148 -0
- package/dist/sync/b2-sha1-reader.cjs.map +1 -0
- package/dist/sync/b2-sha1-reader.d.cts +58 -0
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
- package/dist/sync/b2-sha1-reader.d.ts +58 -0
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
- package/dist/sync/b2-sha1-reader.js +145 -0
- package/dist/sync/b2-sha1-reader.js.map +1 -0
- package/dist/sync/download-staging.cjs +265 -0
- package/dist/sync/download-staging.cjs.map +1 -0
- package/dist/sync/download-staging.d.cts +54 -0
- package/dist/sync/download-staging.d.cts.map +1 -0
- package/dist/sync/download-staging.d.ts +54 -0
- package/dist/sync/download-staging.d.ts.map +1 -0
- package/dist/sync/download-staging.js +259 -0
- package/dist/sync/download-staging.js.map +1 -0
- package/dist/sync/filesystem-errors.cjs +32 -0
- package/dist/sync/filesystem-errors.cjs.map +1 -0
- package/dist/sync/filesystem-errors.d.cts +8 -0
- package/dist/sync/filesystem-errors.d.cts.map +1 -0
- package/dist/sync/filesystem-errors.d.ts +8 -0
- package/dist/sync/filesystem-errors.d.ts.map +1 -0
- package/dist/sync/filesystem-errors.js +32 -0
- package/dist/sync/filesystem-errors.js.map +1 -0
- package/dist/sync/filters.cjs +217 -0
- package/dist/sync/filters.cjs.map +1 -0
- package/dist/sync/filters.d.cts +51 -0
- package/dist/sync/filters.d.cts.map +1 -0
- package/dist/sync/filters.d.ts +51 -0
- package/dist/sync/filters.d.ts.map +1 -0
- package/dist/sync/filters.js +213 -0
- package/dist/sync/filters.js.map +1 -0
- package/dist/sync/index.cjs +39 -22
- package/dist/sync/index.d.cts +14 -9
- package/dist/sync/index.d.cts.map +1 -1
- package/dist/sync/index.d.ts +14 -9
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +9 -20
- package/dist/sync/local-file-identity.cjs +61 -0
- package/dist/sync/local-file-identity.cjs.map +1 -0
- package/dist/sync/local-file-identity.d.cts +37 -0
- package/dist/sync/local-file-identity.d.cts.map +1 -0
- package/dist/sync/local-file-identity.d.ts +37 -0
- package/dist/sync/local-file-identity.d.ts.map +1 -0
- package/dist/sync/local-file-identity.js +60 -0
- package/dist/sync/local-file-identity.js.map +1 -0
- package/dist/sync/local-file-io.cjs +364 -0
- package/dist/sync/local-file-io.cjs.map +1 -0
- package/dist/sync/local-file-io.d.cts +75 -0
- package/dist/sync/local-file-io.d.cts.map +1 -0
- package/dist/sync/local-file-io.d.ts +75 -0
- package/dist/sync/local-file-io.d.ts.map +1 -0
- package/dist/sync/local-file-io.js +360 -0
- package/dist/sync/local-file-io.js.map +1 -0
- package/dist/sync/local-filesystem-root.cjs +27 -0
- package/dist/sync/local-filesystem-root.cjs.map +1 -0
- package/dist/sync/local-filesystem-root.d.cts +18 -0
- package/dist/sync/local-filesystem-root.d.cts.map +1 -0
- package/dist/sync/local-filesystem-root.d.ts +18 -0
- package/dist/sync/local-filesystem-root.d.ts.map +1 -0
- package/dist/sync/local-filesystem-root.js +26 -0
- package/dist/sync/local-filesystem-root.js.map +1 -0
- package/dist/sync/local-sha1.cjs +119 -0
- package/dist/sync/local-sha1.cjs.map +1 -0
- package/dist/sync/local-sha1.d.cts +39 -0
- package/dist/sync/local-sha1.d.cts.map +1 -0
- package/dist/sync/local-sha1.d.ts +39 -0
- package/dist/sync/local-sha1.d.ts.map +1 -0
- package/dist/sync/local-sha1.js +117 -0
- package/dist/sync/local-sha1.js.map +1 -0
- package/dist/sync/pairing.cjs +118 -29
- package/dist/sync/pairing.cjs.map +1 -1
- package/dist/sync/pairing.d.cts +7 -2
- package/dist/sync/pairing.d.cts.map +1 -1
- package/dist/sync/pairing.d.ts +7 -2
- package/dist/sync/pairing.d.ts.map +1 -1
- package/dist/sync/pairing.js +120 -31
- package/dist/sync/pairing.js.map +1 -1
- package/dist/sync/path-order.cjs +30 -0
- package/dist/sync/path-order.cjs.map +1 -0
- package/dist/sync/path-order.d.cts +28 -0
- package/dist/sync/path-order.d.cts.map +1 -0
- package/dist/sync/path-order.d.ts +28 -0
- package/dist/sync/path-order.d.ts.map +1 -0
- package/dist/sync/path-order.js +29 -0
- package/dist/sync/path-order.js.map +1 -0
- package/dist/sync/path-safety.cjs +111 -0
- package/dist/sync/path-safety.cjs.map +1 -0
- package/dist/sync/path-safety.d.cts +78 -0
- package/dist/sync/path-safety.d.cts.map +1 -0
- package/dist/sync/path-safety.d.ts +78 -0
- package/dist/sync/path-safety.d.ts.map +1 -0
- package/dist/sync/path-safety.js +105 -0
- package/dist/sync/path-safety.js.map +1 -0
- package/dist/sync/paths.d.cts +19 -0
- package/dist/sync/paths.d.cts.map +1 -0
- package/dist/sync/paths.d.ts +19 -0
- package/dist/sync/paths.d.ts.map +1 -0
- package/dist/sync/policies/compare.cjs +389 -11
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts +100 -2
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts +100 -2
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +387 -13
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +76 -65
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.d.cts +35 -6
- package/dist/sync/policies/index.d.cts.map +1 -1
- package/dist/sync/policies/index.d.ts +35 -6
- package/dist/sync/policies/index.d.ts.map +1 -1
- package/dist/sync/policies/index.js +76 -65
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/prefix.cjs +96 -0
- package/dist/sync/prefix.cjs.map +1 -0
- package/dist/sync/prefix.d.cts +55 -0
- package/dist/sync/prefix.d.cts.map +1 -0
- package/dist/sync/prefix.d.ts +55 -0
- package/dist/sync/prefix.d.ts.map +1 -0
- package/dist/sync/prefix.js +92 -0
- package/dist/sync/prefix.js.map +1 -0
- package/dist/sync/regexp-safety.cjs +192 -0
- package/dist/sync/regexp-safety.cjs.map +1 -0
- package/dist/sync/regexp-safety.d.cts +29 -0
- package/dist/sync/regexp-safety.d.cts.map +1 -0
- package/dist/sync/regexp-safety.d.ts +29 -0
- package/dist/sync/regexp-safety.d.ts.map +1 -0
- package/dist/sync/regexp-safety.js +190 -0
- package/dist/sync/regexp-safety.js.map +1 -0
- package/dist/sync/scan-events.cjs +33 -0
- package/dist/sync/scan-events.cjs.map +1 -0
- package/dist/sync/scan-events.d.cts +17 -0
- package/dist/sync/scan-events.d.cts.map +1 -0
- package/dist/sync/scan-events.d.ts +17 -0
- package/dist/sync/scan-events.d.ts.map +1 -0
- package/dist/sync/scan-events.js +32 -0
- package/dist/sync/scan-events.js.map +1 -0
- package/dist/sync/scan-limit.cjs +33 -0
- package/dist/sync/scan-limit.cjs.map +1 -0
- package/dist/sync/scan-limit.d.cts +21 -0
- package/dist/sync/scan-limit.d.cts.map +1 -0
- package/dist/sync/scan-limit.d.ts +21 -0
- package/dist/sync/scan-limit.d.ts.map +1 -0
- package/dist/sync/scan-limit.js +31 -0
- package/dist/sync/scan-limit.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +239 -55
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.d.cts +26 -7
- package/dist/sync/scanners/b2.d.cts.map +1 -1
- package/dist/sync/scanners/b2.d.ts +26 -7
- package/dist/sync/scanners/b2.d.ts.map +1 -1
- package/dist/sync/scanners/b2.js +239 -55
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs +215 -56
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.d.cts +22 -7
- package/dist/sync/scanners/local.d.cts.map +1 -1
- package/dist/sync/scanners/local.d.ts +22 -7
- package/dist/sync/scanners/local.d.ts.map +1 -1
- package/dist/sync/scanners/local.js +216 -57
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/sha1-metadata.cjs +94 -0
- package/dist/sync/sha1-metadata.cjs.map +1 -0
- package/dist/sync/sha1-metadata.d.cts +82 -0
- package/dist/sync/sha1-metadata.d.cts.map +1 -0
- package/dist/sync/sha1-metadata.d.ts +82 -0
- package/dist/sync/sha1-metadata.d.ts.map +1 -0
- package/dist/sync/sha1-metadata.js +89 -0
- package/dist/sync/sha1-metadata.js.map +1 -0
- package/dist/sync/sha1-options.cjs +23 -0
- package/dist/sync/sha1-options.cjs.map +1 -0
- package/dist/sync/sha1-options.d.cts +14 -0
- package/dist/sync/sha1-options.d.cts.map +1 -0
- package/dist/sync/sha1-options.d.ts +14 -0
- package/dist/sync/sha1-options.d.ts.map +1 -0
- package/dist/sync/sha1-options.js +21 -0
- package/dist/sync/sha1-options.js.map +1 -0
- package/dist/sync/synchronizer.cjs +782 -197
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.d.cts +47 -1
- package/dist/sync/synchronizer.d.cts.map +1 -1
- package/dist/sync/synchronizer.d.ts +47 -1
- package/dist/sync/synchronizer.d.ts.map +1 -1
- package/dist/sync/synchronizer.js +779 -173
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/sync/types.d.cts +208 -16
- package/dist/sync/types.d.cts.map +1 -1
- package/dist/sync/types.d.ts +208 -16
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types/auth.cjs +76 -56
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +67 -9
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +67 -9
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +77 -57
- package/dist/types/auth.js.map +1 -1
- package/dist/types/bucket.cjs +74 -38
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.js +75 -41
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/encryption.cjs +364 -327
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +16 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +16 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +364 -310
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +47 -0
- package/dist/types/errors.cjs.map +1 -0
- package/dist/types/errors.d.cts +13 -4
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +47 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/file.cjs +36 -19
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +2 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +2 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js +37 -21
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +53 -9
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.js +54 -15
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +12 -11
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +12 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key.d.cts +44 -8
- package/dist/types/key.d.cts.map +1 -1
- package/dist/types/key.d.ts +44 -8
- package/dist/types/key.d.ts.map +1 -1
- package/dist/types/lock.cjs +33 -13
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.js +34 -15
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +44 -22
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.js +45 -23
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/upload.d.cts +39 -5
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +39 -5
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +91 -0
- package/dist/upload/abort-scope.cjs.map +1 -0
- package/dist/upload/abort-scope.d.cts +48 -0
- package/dist/upload/abort-scope.d.cts.map +1 -0
- package/dist/upload/abort-scope.d.ts +48 -0
- package/dist/upload/abort-scope.d.ts.map +1 -0
- package/dist/upload/abort-scope.js +88 -0
- package/dist/upload/abort-scope.js.map +1 -0
- package/dist/upload/cancel.cjs +183 -8
- package/dist/upload/cancel.cjs.map +1 -1
- package/dist/upload/cancel.d.cts +110 -2
- package/dist/upload/cancel.d.cts.map +1 -1
- package/dist/upload/cancel.d.ts +110 -2
- package/dist/upload/cancel.d.ts.map +1 -1
- package/dist/upload/cancel.js +178 -9
- package/dist/upload/cancel.js.map +1 -1
- package/dist/upload/concurrency.cjs +79 -52
- package/dist/upload/concurrency.cjs.map +1 -1
- package/dist/upload/concurrency.js +79 -53
- package/dist/upload/concurrency.js.map +1 -1
- package/dist/upload/finish.cjs +59 -0
- package/dist/upload/finish.cjs.map +1 -0
- package/dist/upload/finish.d.cts +26 -0
- package/dist/upload/finish.d.cts.map +1 -0
- package/dist/upload/finish.d.ts +26 -0
- package/dist/upload/finish.d.ts.map +1 -0
- package/dist/upload/finish.js +59 -0
- package/dist/upload/finish.js.map +1 -0
- package/dist/upload/large.cjs +301 -218
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +76 -9
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +76 -9
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +301 -218
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs +28 -0
- package/dist/upload/options.cjs.map +1 -0
- package/dist/upload/options.d.cts +104 -0
- package/dist/upload/options.d.cts.map +1 -0
- package/dist/upload/options.d.ts +104 -0
- package/dist/upload/options.d.ts.map +1 -0
- package/dist/upload/options.js +27 -0
- package/dist/upload/options.js.map +1 -0
- package/dist/upload/resume.cjs +333 -33
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +82 -12
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +82 -12
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +330 -33
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +186 -0
- package/dist/upload/retry.cjs.map +1 -0
- package/dist/upload/retry.d.cts +127 -0
- package/dist/upload/retry.d.cts.map +1 -0
- package/dist/upload/retry.d.ts +127 -0
- package/dist/upload/retry.d.ts.map +1 -0
- package/dist/upload/retry.js +182 -0
- package/dist/upload/retry.js.map +1 -0
- package/dist/upload/single.cjs +68 -44
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +2 -1
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +2 -1
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +68 -44
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +317 -193
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +3 -1
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +3 -1
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +316 -192
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/best-effort.cjs +42 -8
- package/dist/util/best-effort.cjs.map +1 -1
- package/dist/util/best-effort.d.cts +2 -1
- package/dist/util/best-effort.d.cts.map +1 -1
- package/dist/util/best-effort.d.ts +2 -1
- package/dist/util/best-effort.d.ts.map +1 -1
- package/dist/util/best-effort.js +43 -9
- package/dist/util/best-effort.js.map +1 -1
- package/dist/util/bytes.cjs +23 -0
- package/dist/util/bytes.cjs.map +1 -0
- package/dist/util/bytes.d.cts +15 -0
- package/dist/util/bytes.d.cts.map +1 -0
- package/dist/util/bytes.d.ts +15 -0
- package/dist/util/bytes.d.ts.map +1 -0
- package/dist/util/bytes.js +23 -0
- package/dist/util/bytes.js.map +1 -0
- package/dist/util/crypto.cjs +68 -0
- package/dist/util/crypto.cjs.map +1 -0
- package/dist/util/crypto.d.cts +26 -0
- package/dist/util/crypto.d.cts.map +1 -0
- package/dist/util/crypto.d.ts +26 -0
- package/dist/util/crypto.d.ts.map +1 -0
- package/dist/util/crypto.js +66 -0
- package/dist/util/crypto.js.map +1 -0
- package/dist/util/defaults.cjs +25 -9
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.js +26 -11
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/error-reason.cjs +41 -0
- package/dist/util/error-reason.cjs.map +1 -0
- package/dist/util/error-reason.d.cts +9 -0
- package/dist/util/error-reason.d.cts.map +1 -0
- package/dist/util/error-reason.d.ts +9 -0
- package/dist/util/error-reason.d.ts.map +1 -0
- package/dist/util/error-reason.js +41 -0
- package/dist/util/error-reason.js.map +1 -0
- package/dist/util/http.cjs +23 -0
- package/dist/util/http.cjs.map +1 -0
- package/dist/util/http.d.cts +13 -0
- package/dist/util/http.d.cts.map +1 -0
- package/dist/util/http.d.ts +13 -0
- package/dist/util/http.d.ts.map +1 -0
- package/dist/util/http.js +23 -0
- package/dist/util/http.js.map +1 -0
- package/dist/util/normalize.cjs +66 -7
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.js +67 -10
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +63 -14
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.js +64 -16
- package/dist/util/paginator.js.map +1 -1
- package/dist/util/plan-ranges.cjs +47 -22
- package/dist/util/plan-ranges.cjs.map +1 -1
- package/dist/util/plan-ranges.js +48 -24
- package/dist/util/plan-ranges.js.map +1 -1
- package/dist/util/sha1.cjs +27 -0
- package/dist/util/sha1.cjs.map +1 -0
- package/dist/util/sha1.d.cts +17 -0
- package/dist/util/sha1.d.cts.map +1 -0
- package/dist/util/sha1.d.ts +17 -0
- package/dist/util/sha1.d.ts.map +1 -0
- package/dist/util/sha1.js +26 -0
- package/dist/util/sha1.js.map +1 -0
- package/dist/util/text-codec.cjs +29 -5
- package/dist/util/text-codec.cjs.map +1 -1
- package/dist/util/text-codec.js +30 -7
- package/dist/util/text-codec.js.map +1 -1
- package/dist/util/to-error.cjs +18 -4
- package/dist/util/to-error.cjs.map +1 -1
- package/dist/util/to-error.js +19 -5
- package/dist/util/to-error.js.map +1 -1
- package/dist/version.cjs +17 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -3
- package/dist/version.d.ts +3 -3
- package/dist/version.js +19 -6
- package/dist/version.js.map +1 -1
- package/package.json +19 -16
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notifications/index.cjs.map +0 -1
- package/dist/notifications/index.js.map +0 -1
- package/dist/package.json.cjs +0 -9
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -9
- package/dist/package.json.js.map +0 -1
- package/dist/streams/index.cjs.map +0 -1
- package/dist/streams/index.js.map +0 -1
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.js.map +0 -1
package/dist/s3/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/s3/index.ts"],"sourcesContent":["/**\n * S3-compatible helpers for using B2 with the AWS SDK.\n *\n * Provides {@link createS3ClientConfig} to derive endpoint, region, and\n * credentials from B2 authorization state, plus {@link presignGetObjectUrl}\n * for generating download URLs using B2 native download authorization.\n *\n * @packageDocumentation\n */\n\nimport type { AccountInfo } from '../auth/account-info.ts'\n\n/**\n * Configuration for deriving S3-compatible client settings from B2 auth state.\n *\n * Per B2's S3-compatible API contract, the S3 `accessKeyId` is the\n * `applicationKeyId` and the S3 `secretAccessKey` is the\n * `applicationKey`. These are NOT the native `accountId` /\n * `authorizationToken` returned by `b2_authorize_account` — those won't\n * authenticate against the S3 endpoint. Both must be supplied here\n * because `AccountInfo` doesn't retain the application key after\n * authorization for security reasons.\n *\n * @see https://www.backblaze.com/apidocs/s3-compatible-api\n */\nexport interface B2S3Config {\n /** The authorized AccountInfo containing the S3 endpoint URL. */\n readonly accountInfo: AccountInfo\n /** B2 application key ID. Used as the S3 `accessKeyId`. */\n readonly applicationKeyId: string\n /** B2 application key (secret). Used as the S3 `secretAccessKey`. */\n readonly applicationKey: string\n /** Override the S3 region. If omitted, extracted from the S3 API URL. */\n readonly region?: string\n}\n\n/** Configuration object compatible with `@aws-sdk/client-s3`'s S3Client constructor. */\nexport interface S3ClientConfig {\n /** The S3-compatible endpoint URL (e.g., `https://s3.us-west-004.backblazeb2.com`). */\n readonly endpoint: string\n /** The S3 region identifier (e.g., `us-west-004`). */\n readonly region: string\n /** AWS-style credentials — the B2 application key pair. */\n readonly credentials: {\n /** The B2 application key ID, used as the S3 access key ID. */\n readonly accessKeyId: string\n /** The B2 application key (secret), used as the S3 secret access key. */\n readonly secretAccessKey: string\n }\n /** Always `true` for B2, which requires path-style bucket addressing. */\n readonly forcePathStyle: boolean\n}\n\n/**\n * Derives an S3-compatible client configuration from B2 authorization state.\n * Pass the result to `new S3Client(config)` from `@aws-sdk/client-s3`.\n *\n * @param config - B2 auth state, application key credentials, and optional region override.\n *\n * @returns Configuration ready for the AWS S3 SDK.\n *\n * @example\n * ```ts\n * const { B2_APPLICATION_KEY_ID, B2_APPLICATION_KEY } = process.env\n * if (!B2_APPLICATION_KEY_ID || !B2_APPLICATION_KEY) throw new Error('Missing B2 credentials')\n * const s3 = new S3Client(createS3ClientConfig({\n * accountInfo: client.accountInfo,\n * applicationKeyId: B2_APPLICATION_KEY_ID,\n * applicationKey: B2_APPLICATION_KEY,\n * }))\n * ```\n */\nexport function createS3ClientConfig(config: B2S3Config): S3ClientConfig {\n const s3Url = config.accountInfo.getS3ApiUrl()\n const regionMatch = s3Url.match(/s3\\.([^.]+)\\.backblazeb2\\.com/)\n const region = config.region ?? regionMatch?.[1] ?? 'us-west-004'\n\n return {\n endpoint: s3Url,\n region,\n credentials: {\n accessKeyId: config.applicationKeyId,\n secretAccessKey: config.applicationKey,\n },\n forcePathStyle: true,\n }\n}\n\n/**\n * Constructs a presigned download URL using B2's native download authorization.\n * This is not a standard S3 presigned URL but works for B2 download endpoints.\n *\n * @param downloadUrl - The B2 download URL from authorization (e.g., `https://f004.backblazeb2.com`).\n * @param bucketName - The bucket containing the file.\n * @param fileName - The file name (path) to download.\n * @param authorizationToken - A download authorization token from `b2_get_download_authorization`.\n * @param validDurationInSeconds - URL validity duration in seconds. Defaults to 3600 (1 hour).\n *\n * @returns The presigned download URL string.\n */\nexport function presignGetObjectUrl(\n downloadUrl: string,\n bucketName: string,\n fileName: string,\n authorizationToken: string,\n validDurationInSeconds = 3600,\n): string {\n const expires = Math.floor(Date.now() / 1000) + validDurationInSeconds\n return `${downloadUrl}/file/${encodeURIComponent(bucketName)}/${encodeURIComponent(fileName)}?Authorization=${encodeURIComponent(authorizationToken)}&expires=${expires}`\n}\n"],"names":[],"mappings":";;AAwEO,SAAS,qBAAqB,QAAoC;AACvE,QAAM,QAAQ,OAAO,YAAY,YAAA;AACjC,QAAM,cAAc,MAAM,MAAM,+BAA+B;AAC/D,QAAM,SAAS,OAAO,UAAU,cAAc,CAAC,KAAK;AAEpD,SAAO;AAAA,IACL,UAAU;AAAA,IACV;AAAA,IACA,aAAa;AAAA,MACX,aAAa,OAAO;AAAA,MACpB,iBAAiB,OAAO;AAAA,IAAA;AAAA,IAE1B,gBAAgB;AAAA,EAAA;AAEpB;AAcO,SAAS,oBACd,aACA,YACA,UACA,oBACA,yBAAyB,MACjB;AACR,QAAM,UAAU,KAAK,MAAM,KAAK,IAAA,IAAQ,GAAI,IAAI;AAChD,SAAO,GAAG,WAAW,SAAS,mBAAmB,UAAU,CAAC,IAAI,mBAAmB,QAAQ,CAAC,kBAAkB,mBAAmB,kBAAkB,CAAC,YAAY,OAAO;AACzK;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/s3/index.ts"],"sourcesContent":["/**\n * S3-compatible helpers for using B2 with the AWS SDK and S3 clients.\n *\n * Provides {@link createS3ClientConfig} to derive endpoint, region, and\n * credentials from B2 authorization state, plus {@link presignS3GetObjectUrl}\n * and {@link presignS3PutObjectUrl} for generating AWS Signature Version 4\n * presigned URLs against B2's S3-compatible API.\n *\n * @packageDocumentation\n */\n\nimport type { AccountInfo } from '../auth/account-info.ts'\nimport { hostMatchesAllowedSuffix } from '../http/url-guard.ts'\nimport { redactUrlForError } from '../internal/url-redaction.ts'\nimport { encodeFileName } from '../raw/encoding.ts'\nimport { hasHttpHeaderControlCharacter } from '../util/http.ts'\nimport {\n presignS3Request,\n type QueryParam,\n type SignedHeader,\n type SigV4PresignRequestOptions,\n} from './sigv4.ts'\nimport { assertNativeDownloadFileName, assertSafeBucketName } from './validation.ts'\n\nconst HTTP_HEADER_TOKEN = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/\nconst HTTP_MEDIA_TYPE = /^[!#$%&'*+\\-.^_`|~0-9A-Za-z]+\\/[!#$%&'*+\\-.^_`|~0-9A-Za-z]+$/\nconst DEFAULT_NATIVE_DOWNLOAD_URL_EXPIRES_IN = 3600\nconst TRUSTED_NATIVE_DOWNLOAD_HOST_SUFFIXES = [\n 'backblazeb2.com',\n 'backblaze.com',\n 'backblaze.net',\n 'b2-staging.io',\n] as const\nconst BROWSER_EXECUTABLE_CONTENT_TYPES = new Set([\n 'text/html',\n 'application/xhtml+xml',\n 'image/svg+xml',\n 'application/javascript',\n 'text/javascript',\n 'application/x-javascript',\n 'text/x-javascript',\n 'application/ecmascript',\n 'text/ecmascript',\n 'application/x-ecmascript',\n 'text/x-ecmascript',\n 'text/xml',\n 'application/xml',\n])\n\n/**\n * Trusted server-side token for intentionally allowing active-content S3 presign options.\n *\n * Plain objects and JSON payloads cannot satisfy the runtime identity check\n * for this token. Pass this exported value only from trusted application code\n * after applying your own content and response-header policy.\n */\nexport interface TrustedUnsafeS3PresignOptIn {\n /**\n * Internal marker used only by the runtime identity check.\n *\n * @internal\n */\n readonly __trustedUnsafeS3PresignOptIn: 'trustedUnsafeS3PresignOptIn'\n}\n\nconst trustedUnsafeS3PresignOptInValue: TrustedUnsafeS3PresignOptIn = Object.freeze({\n __trustedUnsafeS3PresignOptIn: 'trustedUnsafeS3PresignOptIn',\n})\n\n/**\n * Server-side opt-in token for unsafe S3 presign options.\n *\n * Use this token as the value for `allowBrowserExecutableContentType`,\n * `allowBrowserExecutableResponseContentType`, or\n * `allowInlineResponseContentDisposition` only when active content or inline\n * rendering from the storage origin is intentional and trusted.\n */\nexport const trustedUnsafeS3PresignOptIn: TrustedUnsafeS3PresignOptIn =\n trustedUnsafeS3PresignOptInValue\n\n/**\n * Configuration for deriving S3-compatible client settings from B2 auth state.\n *\n * Per B2's S3-compatible API contract, the S3 `accessKeyId` is the\n * `applicationKeyId` and the S3 `secretAccessKey` is the\n * `applicationKey`. These are NOT the native `accountId` /\n * `authorizationToken` returned by `b2_authorize_account` — those won't\n * authenticate against the S3 endpoint. Both must be supplied here\n * because `AccountInfo` doesn't retain the application key after\n * authorization for security reasons.\n *\n * @see https://www.backblaze.com/apidocs/s3-compatible-api\n */\nexport interface B2S3Config {\n /** The authorized AccountInfo containing the S3 endpoint URL. */\n readonly accountInfo: AccountInfo\n /** B2 application key ID. Used as the S3 `accessKeyId`. */\n readonly applicationKeyId: string\n /** B2 application key (secret). Used as the S3 `secretAccessKey`. */\n readonly applicationKey: string\n /** Override the S3 region. If omitted, extracted from the S3 API URL. */\n readonly region?: string\n}\n\n/** Configuration object compatible with `@aws-sdk/client-s3`'s S3Client constructor. */\nexport interface S3ClientConfig {\n /** The S3-compatible endpoint URL (e.g., `https://s3.us-west-004.backblazeb2.com`). */\n readonly endpoint: string\n /** The S3 region identifier (e.g., `us-west-004`). */\n readonly region: string\n /** AWS-style credentials — the B2 application key pair. */\n readonly credentials: {\n /** The B2 application key ID, used as the S3 access key ID. */\n readonly accessKeyId: string\n /** The B2 application key (secret), used as the S3 secret access key. */\n readonly secretAccessKey: string\n }\n /** Always `true` for B2, which requires path-style bucket addressing. */\n readonly forcePathStyle: boolean\n}\n\n/** Common options for S3-compatible presigned object URLs. */\nexport interface S3PresignObjectUrlOptions extends B2S3Config {\n /** Bucket containing the object. */\n readonly bucketName: string\n /**\n * Object key / B2 file name to sign. Keys with path segments exactly `.`\n * or `..` cannot be presigned safely because common URL parsers normalize\n * them before sending the request.\n */\n readonly fileName: string\n /**\n * URL validity duration in seconds. Defaults to 3600. Must be an integer\n * from 1 to 604800 (7 days), the AWS Signature Version 4 presign maximum.\n * A presigned URL is a bearer credential for the signed operation; keep\n * this as short as the calling workflow allows.\n */\n readonly expiresIn?: number\n}\n\n/** Options for {@link presignS3GetObjectUrl}. */\nexport interface PresignS3GetObjectUrlOptions extends S3PresignObjectUrlOptions {\n /** Optional S3 version ID to include in the signed GET request. */\n readonly versionId?: string\n /**\n * Override the response Cache-Control header. Response overrides control\n * headers served from the storage origin; do not populate them from\n * untrusted input without an allow-list.\n */\n readonly responseCacheControl?: string\n /**\n * Override the response Content-Disposition header. Prefer a safe\n * attachment disposition when this value can be influenced by users. The\n * helper rejects `inline` response dispositions by default because they can\n * make stored bytes render from the storage origin.\n */\n readonly responseContentDisposition?: string\n /**\n * Permit an `inline` response Content-Disposition override. Set only when\n * the object bytes and response headers are trusted to render from the\n * storage origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans\n * from request JSON are intentionally ignored by the runtime guard.\n */\n readonly allowInlineResponseContentDisposition?: TrustedUnsafeS3PresignOptIn\n /**\n * Override the response Content-Encoding header. Do not populate this from\n * untrusted input without an allow-list.\n */\n readonly responseContentEncoding?: string\n /**\n * Override the response Content-Language header. Do not populate this from\n * untrusted input without an allow-list.\n */\n readonly responseContentLanguage?: string\n /**\n * Override the response Content-Type header. If attacker-controlled, this\n * can make stored bytes render as active content from the storage origin.\n * Restrict it to known-safe values before signing. The helper's built-in\n * rejection of known browser-executable and sniffable XML/JavaScript media\n * types is best-effort and does not replace an application allow-list.\n */\n readonly responseContentType?: string\n /**\n * Permit browser-executable `responseContentType` overrides such as\n * `text/html`, JavaScript, SVG, or XML media types. Leave this unset unless\n * the served object is intentionally meant to render active content from the\n * storage origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans\n * from request JSON are intentionally ignored by the runtime guard.\n */\n readonly allowBrowserExecutableResponseContentType?: TrustedUnsafeS3PresignOptIn\n /**\n * Override the response Expires header. Do not populate this from\n * untrusted input without an allow-list.\n */\n readonly responseExpires?: Date\n}\n\n/** Options for {@link presignS3PutObjectUrl}. */\nexport interface PresignS3PutObjectUrlOptions extends S3PresignObjectUrlOptions {\n /**\n * Optional content type for the uploaded object. When supplied, the generated\n * URL signs the Content-Type header, so upload clients must send the same\n * value. Browser-executable and sniffable XML/JavaScript types are rejected\n * by default as a best-effort guard; callers accepting untrusted uploads\n * should still enforce their own allow-list.\n */\n readonly contentType?: string\n /**\n * Permit browser-executable `contentType` values such as `text/html`,\n * JavaScript, SVG, or XML media types. Leave this unset unless the uploaded\n * object is intentionally meant to render active content from the storage\n * origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans from\n * request JSON are intentionally ignored by the runtime guard.\n */\n readonly allowBrowserExecutableContentType?: TrustedUnsafeS3PresignOptIn\n /**\n * Optional content length. Must be a non-negative safe integer. When\n * supplied, the generated URL signs the Content-Length header, so upload\n * clients must send the same value.\n */\n readonly contentLength?: number\n /**\n * Optional user metadata to attach to the object. The generated URL signs\n * matching `x-amz-meta-*` headers, so upload clients must send the same values.\n * Pass bare metadata keys; the helper adds the `x-amz-meta-` prefix. Metadata\n * keys must be valid HTTP header tokens and must not differ only by case.\n */\n readonly metadata?: Record<string, string>\n}\n\n/**\n * Options for {@link presignPutObjectUrl}.\n *\n * @deprecated Use {@link PresignS3PutObjectUrlOptions}.\n */\nexport type PresignPutObjectUrlOptions = PresignS3PutObjectUrlOptions\n\n/**\n * Derives an S3-compatible client configuration from B2 authorization state.\n * Pass the result to `new S3Client(config)` from `@aws-sdk/client-s3`.\n *\n * Non-standard, custom, or proxied endpoints require an explicit `region`; set\n * it before deploying this SDK to those endpoints. The SDK no longer falls back\n * to `us-west-004` because that can mis-sign requests.\n *\n * @param config - B2 auth state, application key credentials, and optional region override.\n *\n * @returns Configuration ready for the AWS S3 SDK.\n *\n * @example\n * ```ts\n * const { B2_APPLICATION_KEY_ID, B2_APPLICATION_KEY } = process.env\n * if (!B2_APPLICATION_KEY_ID || !B2_APPLICATION_KEY) throw new Error('Missing B2 credentials')\n * const s3 = new S3Client(createS3ClientConfig({\n * accountInfo: client.accountInfo,\n * applicationKeyId: B2_APPLICATION_KEY_ID,\n * applicationKey: B2_APPLICATION_KEY,\n * }))\n * ```\n */\nexport function createS3ClientConfig(config: B2S3Config): S3ClientConfig {\n const s3Url = config.accountInfo.getS3ApiUrl()\n const region = config.region ?? deriveRequiredS3Region(s3Url)\n assertNonEmptyStringOption('applicationKeyId', config.applicationKeyId)\n assertNonEmptyStringOption('applicationKey', config.applicationKey)\n assertNonEmptyStringOption('region', region)\n assertSigV4CredentialScopeComponent('applicationKeyId', config.applicationKeyId)\n assertSigV4CredentialScopeComponent('region', region)\n\n return {\n endpoint: s3Url,\n region,\n credentials: {\n accessKeyId: config.applicationKeyId,\n secretAccessKey: config.applicationKey,\n },\n forcePathStyle: true,\n }\n}\n\n/**\n * Extracts the B2 S3 region from a standard B2 S3 endpoint.\n *\n * Custom endpoints cannot be inferred safely. Pass `region` explicitly to\n * {@link createS3ClientConfig}, {@link presignS3GetObjectUrl}, or\n * {@link presignS3PutObjectUrl} when this returns `null`.\n *\n * @param endpoint - The S3 endpoint URL.\n *\n * @returns The derived region, or `null` when the endpoint is not a standard B2 S3 URL.\n */\nexport function deriveS3RegionFromEndpoint(endpoint: string): string | null {\n let hostname: string\n try {\n hostname = new URL(endpoint).hostname.toLowerCase()\n } catch {\n return null\n }\n\n const match = /^s3\\.([a-z0-9-]+)\\.backblazeb2\\.com$/.exec(hostname)\n return match?.[1] ?? null\n}\n\n// S3 SigV4 presign helpers.\n\n/**\n * Generates an AWS Signature Version 4 presigned GET URL for B2's S3-compatible API.\n *\n * This helper signs internally and does not pass the B2 application key to\n * runtime peer dependencies. Response override options are signed into the URL\n * and control headers served from the storage origin; do not populate them from\n * untrusted input without an allow-list. Presign success does not prove the URL\n * will be accepted later; keep URL-generating hosts clock-synchronized and\n * check clock skew when downstream use returns SigV4 403 errors.\n *\n * @param options - B2 auth state, S3 credentials, target object, and signing options.\n *\n * @returns The presigned URL string.\n */\nexport async function presignS3GetObjectUrl(\n options: PresignS3GetObjectUrlOptions,\n): Promise<string> {\n const query: QueryParam[] = [['x-id', 'GetObject']]\n if (options.versionId !== undefined) {\n assertSafeQueryValue('versionId', options.versionId)\n query.push(['versionId', options.versionId])\n }\n if (options.responseCacheControl !== undefined) {\n assertSafeResponseOverride('responseCacheControl', options.responseCacheControl)\n query.push(['response-cache-control', options.responseCacheControl])\n }\n if (options.responseContentDisposition !== undefined) {\n assertSafeResponseContentDisposition(\n options.responseContentDisposition,\n isTrustedUnsafeS3PresignOptIn(options.allowInlineResponseContentDisposition),\n )\n query.push(['response-content-disposition', options.responseContentDisposition])\n }\n if (options.responseContentEncoding !== undefined) {\n assertSafeResponseOverride('responseContentEncoding', options.responseContentEncoding)\n query.push(['response-content-encoding', options.responseContentEncoding])\n }\n if (options.responseContentLanguage !== undefined) {\n assertSafeResponseOverride('responseContentLanguage', options.responseContentLanguage)\n query.push(['response-content-language', options.responseContentLanguage])\n }\n if (options.responseContentType !== undefined) {\n if (isTrustedUnsafeS3PresignOptIn(options.allowBrowserExecutableResponseContentType)) {\n assertSafeContentTypeValue(\n 'responseContentType',\n options.responseContentType,\n 'response header value',\n )\n } else {\n assertSafeResponseContentType(options.responseContentType)\n }\n query.push(['response-content-type', options.responseContentType])\n }\n if (options.responseExpires !== undefined) {\n query.push(['response-expires', normalizeResponseExpires(options.responseExpires)])\n }\n\n return await presignS3Request('GET', createSigV4PresignOptions(options), query, [])\n}\n\n/**\n * Returns a B2-native download-authorization URL, not an S3 presigned URL.\n *\n * This deprecated helper preserves the legacy positional output contract where\n * the whole file name is encoded as one URL component, including `/` as `%2F`.\n * It keeps the legacy string-building contract for callers that relied on\n * custom/local download URLs or permissive inputs. Use\n * {@link createNativeDownloadAuthorizationUrl} for strict validation.\n *\n * @param downloadUrl - The B2 download URL from authorization.\n * @param bucketName - The bucket containing the file.\n * @param fileName - The file name (path) to download.\n * @param authorizationToken - A download authorization token from `b2_get_download_authorization`.\n * @param validDurationInSeconds - Compatibility-only value for the non-authoritative `expires` query.\n *\n * @returns The B2 native download-authorization URL string.\n *\n * @deprecated Use {@link createNativeDownloadAuthorizationUrl} for B2 native\n * download-token URLs, or {@link presignS3GetObjectUrl} for real S3-compatible\n * AWS Signature Version 4 presigned GET URLs.\n */\nexport function presignGetObjectUrl(\n downloadUrl: string,\n bucketName: string,\n fileName: string,\n authorizationToken: string,\n validDurationInSeconds?: number,\n): string {\n const expires =\n Math.floor(Date.now() / 1000) +\n (validDurationInSeconds ?? DEFAULT_NATIVE_DOWNLOAD_URL_EXPIRES_IN)\n return `${downloadUrl}/file/${encodeURIComponent(bucketName)}/${encodeURIComponent(fileName)}?Authorization=${encodeURIComponent(authorizationToken)}&expires=${expires}`\n}\n\n/**\n * Generates an AWS Signature Version 4 presigned PUT URL for browser or\n * third-party uploads through B2's S3-compatible API.\n *\n * This helper signs internally and does not pass the B2 application key to\n * runtime peer dependencies. A presigned PUT URL is a replayable bearer\n * credential for writing one key until expiry. Retried PUTs can create\n * duplicate B2 file versions when a response is lost after B2 stored the object.\n * Use unique keys or reconcile uploaded file IDs/checksums, and configure\n * lifecycle/version cleanup where duplicate versions must be removed\n * automatically. If `contentType` and `contentLength` are omitted, the holder\n * can choose any content type, including browser-executable types, and any size\n * accepted by B2; bind both values before handing URLs to untrusted uploaders\n * to limit financial-DoS and content-type smuggling risk.\n *\n * @param options - B2 auth state, S3 credentials, target object, and signing options.\n *\n * @returns The presigned URL string.\n */\nexport async function presignS3PutObjectUrl(\n options: PresignS3PutObjectUrlOptions,\n): Promise<string> {\n const headers: SignedHeader[] = []\n if (options.contentType !== undefined) {\n if (isTrustedUnsafeS3PresignOptIn(options.allowBrowserExecutableContentType)) {\n assertSafeContentTypeValue('contentType', options.contentType, 'stored object Content-Type')\n } else {\n assertSafePutContentType(options.contentType)\n }\n headers.push(['content-type', options.contentType])\n }\n if (options.contentLength !== undefined) {\n headers.push(['content-length', normalizeContentLength(options.contentLength)])\n }\n headers.push(...normalizeMetadataHeaders(options.metadata))\n\n return await presignS3Request(\n 'PUT',\n createSigV4PresignOptions(options),\n [['x-id', 'PutObject']],\n headers,\n )\n}\n\n/**\n * Generates an AWS Signature Version 4 presigned PUT URL for B2's\n * S3-compatible API.\n *\n * @param options - B2 auth state, S3 credentials, target object, and signing options.\n *\n * @returns The presigned URL string.\n *\n * @deprecated Use {@link presignS3PutObjectUrl}; this alias is retained for\n * pre-release callers that adopted the shorter name.\n */\nexport async function presignPutObjectUrl(options: PresignPutObjectUrlOptions): Promise<string> {\n return await presignS3PutObjectUrl(options)\n}\n\n// B2-native download authorization helper.\n\n/**\n * Constructs a B2-native download URL using a token from `b2_get_download_authorization`.\n * This is not an S3 presigned URL.\n *\n * The token lifetime is fixed when `b2_get_download_authorization` creates the\n * token. `validDurationInSeconds` is retained only for compatibility with the\n * legacy `presignGetObjectUrl` helper's decorative `expires` query parameter;\n * changing it here does not shorten or extend access.\n * Because the returned URL carries a bearer token, `downloadUrl` must be an\n * HTTPS Backblaze download origin without userinfo, path, query, or fragment.\n *\n * @param downloadUrl - The B2 download URL from authorization (e.g., `https://f004.backblazeb2.com`).\n * @param bucketName - The bucket containing the file.\n * @param fileName - The file name (path) to download.\n * @param authorizationToken - A download authorization token from `b2_get_download_authorization`.\n * @param validDurationInSeconds - Compatibility-only value for the non-authoritative `expires` query.\n *\n * @returns The B2 native download-authorization URL string, not an S3 presigned URL.\n */\nexport function createNativeDownloadAuthorizationUrl(\n downloadUrl: string,\n bucketName: string,\n fileName: string,\n authorizationToken: string,\n validDurationInSeconds = DEFAULT_NATIVE_DOWNLOAD_URL_EXPIRES_IN,\n): string {\n return buildNativeDownloadAuthorizationUrl(\n downloadUrl,\n bucketName,\n fileName,\n authorizationToken,\n validDurationInSeconds,\n encodeFileName,\n assertNativeDownloadFileName,\n )\n}\n\nfunction deriveRequiredS3Region(endpoint: string): string {\n const region = deriveS3RegionFromEndpoint(endpoint)\n if (region !== null) return region\n\n throw new Error(\n `Unable to derive B2 S3 region from endpoint \"${redactUrlForError(endpoint, {\n invalidUrlLabel: '<invalid S3 endpoint URL>',\n })}\". Pass an explicit \\`region\\` option before deploying custom or proxied endpoints.`,\n )\n}\n\nfunction createSigV4PresignOptions(options: S3PresignObjectUrlOptions): SigV4PresignRequestOptions {\n const clientConfig = createS3ClientConfig(options)\n return {\n endpoint: clientConfig.endpoint,\n region: clientConfig.region,\n accessKeyId: clientConfig.credentials.accessKeyId,\n secretAccessKey: clientConfig.credentials.secretAccessKey,\n bucketName: options.bucketName,\n fileName: options.fileName,\n ...(options.expiresIn !== undefined ? { expiresIn: options.expiresIn } : {}),\n }\n}\n\nfunction normalizeContentLength(contentLength: number): string {\n if (!Number.isSafeInteger(contentLength) || contentLength < 0) {\n throw new RangeError(\n `contentLength must be a non-negative safe integer; received ${String(contentLength)}.`,\n )\n }\n\n return String(contentLength)\n}\n\nfunction normalizeValidDurationInSeconds(validDurationInSeconds: number): number {\n if (!Number.isSafeInteger(validDurationInSeconds) || validDurationInSeconds < 0) {\n throw new RangeError(\n `validDurationInSeconds must be a non-negative safe integer; received ${String(\n validDurationInSeconds,\n )}.`,\n )\n }\n\n return validDurationInSeconds\n}\n\nfunction assertNonEmptyStringOption(name: string, value: unknown): asserts value is string {\n if (typeof value !== 'string' || value.trim().length === 0) {\n throw new TypeError(`${name} must be a non-empty string.`)\n }\n}\n\nfunction assertSigV4CredentialScopeComponent(name: string, value: string): void {\n if (/[\\s/]/u.test(value) || hasHttpHeaderControlCharacter(value)) {\n throw new TypeError(\n `${name} must not contain whitespace, control characters, or \"/\" because it is embedded in the SigV4 credential scope.`,\n )\n }\n}\n\nfunction isTrustedUnsafeS3PresignOptIn(value: unknown): value is TrustedUnsafeS3PresignOptIn {\n return value === trustedUnsafeS3PresignOptIn\n}\n\nfunction buildNativeDownloadAuthorizationUrl(\n downloadUrl: string,\n bucketName: string,\n fileName: string,\n authorizationToken: string,\n validDurationInSeconds: number,\n encodeFileNameForUrl: (fileName: string) => string,\n assertFileName: (fileName: string) => void,\n): string {\n const baseUrl = parseNativeDownloadBaseUrl(downloadUrl)\n assertSafeBucketName(bucketName)\n assertFileName(fileName)\n const expires =\n Math.floor(Date.now() / 1000) + normalizeValidDurationInSeconds(validDurationInSeconds)\n return `${baseUrl}/file/${encodeURIComponent(bucketName)}/${encodeFileNameForUrl(fileName)}?Authorization=${encodeURIComponent(authorizationToken)}&expires=${expires}`\n}\n\nfunction parseNativeDownloadBaseUrl(downloadUrl: string): string {\n let base: URL\n try {\n base = new URL(downloadUrl)\n } catch {\n throw new TypeError(\n `Native download-authorization URLs require a valid https: downloadUrl; received \"${redactUrlForError(\n downloadUrl,\n { invalidUrlLabel: '<invalid downloadUrl>' },\n )}\".`,\n )\n }\n\n if (base.protocol !== 'https:') {\n throw new TypeError(\n `Native download-authorization URLs require an https: downloadUrl; received \"${redactUrlForError(\n base,\n )}\".`,\n )\n }\n if (base.username !== '' || base.password !== '') {\n throw new TypeError('Native download-authorization URLs must not include userinfo.')\n }\n if (base.search !== '' || base.hash !== '') {\n throw new TypeError('Native download-authorization URLs must not include query or fragment.')\n }\n if (base.pathname !== '' && base.pathname !== '/') {\n throw new TypeError('Native download-authorization URLs must not include a path.')\n }\n if (!isTrustedNativeDownloadHost(base.hostname)) {\n throw new TypeError(\n `Native download-authorization URLs require a Backblaze download host; received \"${redactUrlForError(\n base,\n )}\".`,\n )\n }\n\n return base.origin\n}\n\nfunction normalizeMetadataHeaders(metadata: Record<string, string> | undefined): SignedHeader[] {\n const headers: SignedHeader[] = []\n const seenKeys = new Set<string>()\n\n for (const [key, value] of Object.entries(metadata ?? {})) {\n if (!HTTP_HEADER_TOKEN.test(key)) {\n throw new TypeError(`metadata key \"${key}\" must be a non-empty valid HTTP header token.`)\n }\n if (typeof value !== 'string') {\n throw new TypeError(`metadata value for \"${key}\" must be a string.`)\n }\n\n const lowerKey = key.toLowerCase()\n if (seenKeys.has(lowerKey)) {\n throw new TypeError(`metadata key \"${key}\" must not differ only by case.`)\n }\n\n seenKeys.add(lowerKey)\n headers.push([`x-amz-meta-${lowerKey}`, value])\n }\n\n return headers\n}\n\nfunction normalizeResponseExpires(responseExpires: Date): string {\n if (!Number.isFinite(responseExpires.getTime())) {\n throw new RangeError('responseExpires must be a valid Date.')\n }\n\n return responseExpires.toUTCString()\n}\n\nfunction assertSafeResponseOverride(name: string, value: string): void {\n assertSafeHeaderValue(name, value, 'response header value')\n}\n\nfunction assertSafeQueryValue(name: string, value: string): void {\n if (hasHttpHeaderControlCharacter(value)) {\n throw new TypeError(\n `${name} must not contain control characters because it becomes a query parameter.`,\n )\n }\n}\n\nfunction assertSafeHeaderValue(name: string, value: string, target: string): void {\n if (hasHttpHeaderControlCharacter(value)) {\n throw new TypeError(\n `${name} must not contain control characters because it becomes a ${target}.`,\n )\n }\n}\n\nfunction assertSafeResponseContentType(contentType: string): void {\n assertNonExecutableContentType(\n 'responseContentType',\n contentType,\n 'response header value',\n 'allow-list a safe content type before signing response overrides',\n )\n}\n\nfunction assertSafePutContentType(contentType: string): void {\n assertNonExecutableContentType(\n 'contentType',\n contentType,\n 'stored object Content-Type',\n 'pass allowBrowserExecutableContentType only when active content is intentional',\n )\n}\n\nfunction assertSafeResponseContentDisposition(\n contentDisposition: string,\n allowInline: boolean,\n): void {\n assertSafeResponseOverride('responseContentDisposition', contentDisposition)\n\n const disposition = contentDisposition.split(';', 1)[0]?.trim().toLowerCase()\n if (!allowInline && disposition === 'inline') {\n throw new TypeError(\n 'responseContentDisposition must not force inline rendering; use an attachment disposition for response overrides.',\n )\n }\n}\n\nfunction mediaTypeFor(contentType: string): string {\n return contentType.split(';', 1)[0]?.trim().toLowerCase() ?? ''\n}\n\nfunction assertSafeContentTypeValue(name: string, contentType: string, target: string): string {\n assertSafeHeaderValue(name, contentType, target)\n\n const mediaType = mediaTypeFor(contentType)\n if (mediaType.length === 0) {\n throw new TypeError(`${name} must include a non-empty media type.`)\n }\n if (!HTTP_MEDIA_TYPE.test(mediaType)) {\n throw new TypeError(`${name} must include a valid media type.`)\n }\n\n return mediaType\n}\n\nfunction assertNonExecutableContentType(\n name: string,\n contentType: string,\n target: string,\n guidance: string,\n): void {\n const mediaType = assertSafeContentTypeValue(name, contentType, target)\n if (isBrowserExecutableContentType(mediaType)) {\n throw new TypeError(`${name} \"${mediaType}\" can execute in browsers; ${guidance}.`)\n }\n}\n\nfunction isBrowserExecutableContentType(mediaType: string): boolean {\n return BROWSER_EXECUTABLE_CONTENT_TYPES.has(mediaType) || mediaType.endsWith('+xml')\n}\n\nfunction isTrustedNativeDownloadHost(hostname: string): boolean {\n return TRUSTED_NATIVE_DOWNLOAD_HOST_SUFFIXES.some((suffix) =>\n hostMatchesAllowedSuffix(hostname, suffix),\n )\n}\n"],"mappings":";;;;;;;;AAwBA,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AACxB,IAAM,yCAAyC;AAC/C,IAAM,wCAAwC;CAC5C;CACA;CACA;CACA;AACF;AACA,IAAM,mDAAmC,IAAI,IAAI;CAC/C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;AA8BD,IAAa,8BAZyD,OAAO,OAAO,EAClF,+BAA+B,8BACjC,CAWE;;;;;;;;;;;;;;;;;;;;;;;;AAsLF,SAAgB,qBAAqB,QAAoC;CACvE,MAAM,QAAQ,OAAO,YAAY,YAAY;CAC7C,MAAM,SAAS,OAAO,UAAU,uBAA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,MAAM,IAAI,UACR,mHACF;AAEJ;AAEA,SAAS,aAAa,aAA6B;CACjD,OAAO,YAAY,MAAM,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,YAAY,KAAK;AAC/D;AAEA,SAAS,2BAA2B,MAAc,aAAqB,QAAwB;CAC7F,sBAAsB,MAAM,aAAa,MAAM;CAE/C,MAAM,YAAY,aAAa,WAAW;CAC1C,IAAI,UAAU,WAAW,GACvB,MAAM,IAAI,UAAU,GAAG,KAAK,sCAAsC;CAEpE,IAAI,CAAC,gBAAgB,KAAK,SAAS,GACjC,MAAM,IAAI,UAAU,GAAG,KAAK,kCAAkC;CAGhE,OAAO;AACT;AAEA,SAAS,+BACP,MACA,aACA,QACA,UACM;CACN,MAAM,YAAY,2BAA2B,MAAM,aAAa,MAAM;CACtE,IAAI,+BAA+B,SAAS,GAC1C,MAAM,IAAI,UAAU,GAAG,KAAK,IAAI,UAAU,6BAA6B,SAAS,EAAE;AAEtF;AAEA,SAAS,+BAA+B,WAA4B;CAClE,OAAO,iCAAiC,IAAI,SAAS,KAAK,UAAU,SAAS,MAAM;AACrF;AAEA,SAAS,4BAA4B,UAA2B;CAC9D,OAAO,sCAAsC,MAAM,WACjD,kBAAA,yBAAyB,UAAU,MAAM,CAC3C;AACF"}
|
package/dist/s3/index.d.cts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { AccountInfo } from '../auth/account-info.js';
|
|
2
|
+
/**
|
|
3
|
+
* Trusted server-side token for intentionally allowing active-content S3 presign options.
|
|
4
|
+
*
|
|
5
|
+
* Plain objects and JSON payloads cannot satisfy the runtime identity check
|
|
6
|
+
* for this token. Pass this exported value only from trusted application code
|
|
7
|
+
* after applying your own content and response-header policy.
|
|
8
|
+
*/
|
|
9
|
+
export interface TrustedUnsafeS3PresignOptIn {
|
|
10
|
+
/**
|
|
11
|
+
* Internal marker used only by the runtime identity check.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
readonly __trustedUnsafeS3PresignOptIn: 'trustedUnsafeS3PresignOptIn';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Server-side opt-in token for unsafe S3 presign options.
|
|
19
|
+
*
|
|
20
|
+
* Use this token as the value for `allowBrowserExecutableContentType`,
|
|
21
|
+
* `allowBrowserExecutableResponseContentType`, or
|
|
22
|
+
* `allowInlineResponseContentDisposition` only when active content or inline
|
|
23
|
+
* rendering from the storage origin is intentional and trusted.
|
|
24
|
+
*/
|
|
25
|
+
export declare const trustedUnsafeS3PresignOptIn: TrustedUnsafeS3PresignOptIn;
|
|
2
26
|
/**
|
|
3
27
|
* Configuration for deriving S3-compatible client settings from B2 auth state.
|
|
4
28
|
*
|
|
@@ -38,10 +62,126 @@ export interface S3ClientConfig {
|
|
|
38
62
|
/** Always `true` for B2, which requires path-style bucket addressing. */
|
|
39
63
|
readonly forcePathStyle: boolean;
|
|
40
64
|
}
|
|
65
|
+
/** Common options for S3-compatible presigned object URLs. */
|
|
66
|
+
export interface S3PresignObjectUrlOptions extends B2S3Config {
|
|
67
|
+
/** Bucket containing the object. */
|
|
68
|
+
readonly bucketName: string;
|
|
69
|
+
/**
|
|
70
|
+
* Object key / B2 file name to sign. Keys with path segments exactly `.`
|
|
71
|
+
* or `..` cannot be presigned safely because common URL parsers normalize
|
|
72
|
+
* them before sending the request.
|
|
73
|
+
*/
|
|
74
|
+
readonly fileName: string;
|
|
75
|
+
/**
|
|
76
|
+
* URL validity duration in seconds. Defaults to 3600. Must be an integer
|
|
77
|
+
* from 1 to 604800 (7 days), the AWS Signature Version 4 presign maximum.
|
|
78
|
+
* A presigned URL is a bearer credential for the signed operation; keep
|
|
79
|
+
* this as short as the calling workflow allows.
|
|
80
|
+
*/
|
|
81
|
+
readonly expiresIn?: number;
|
|
82
|
+
}
|
|
83
|
+
/** Options for {@link presignS3GetObjectUrl}. */
|
|
84
|
+
export interface PresignS3GetObjectUrlOptions extends S3PresignObjectUrlOptions {
|
|
85
|
+
/** Optional S3 version ID to include in the signed GET request. */
|
|
86
|
+
readonly versionId?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Override the response Cache-Control header. Response overrides control
|
|
89
|
+
* headers served from the storage origin; do not populate them from
|
|
90
|
+
* untrusted input without an allow-list.
|
|
91
|
+
*/
|
|
92
|
+
readonly responseCacheControl?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Override the response Content-Disposition header. Prefer a safe
|
|
95
|
+
* attachment disposition when this value can be influenced by users. The
|
|
96
|
+
* helper rejects `inline` response dispositions by default because they can
|
|
97
|
+
* make stored bytes render from the storage origin.
|
|
98
|
+
*/
|
|
99
|
+
readonly responseContentDisposition?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Permit an `inline` response Content-Disposition override. Set only when
|
|
102
|
+
* the object bytes and response headers are trusted to render from the
|
|
103
|
+
* storage origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans
|
|
104
|
+
* from request JSON are intentionally ignored by the runtime guard.
|
|
105
|
+
*/
|
|
106
|
+
readonly allowInlineResponseContentDisposition?: TrustedUnsafeS3PresignOptIn;
|
|
107
|
+
/**
|
|
108
|
+
* Override the response Content-Encoding header. Do not populate this from
|
|
109
|
+
* untrusted input without an allow-list.
|
|
110
|
+
*/
|
|
111
|
+
readonly responseContentEncoding?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Override the response Content-Language header. Do not populate this from
|
|
114
|
+
* untrusted input without an allow-list.
|
|
115
|
+
*/
|
|
116
|
+
readonly responseContentLanguage?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Override the response Content-Type header. If attacker-controlled, this
|
|
119
|
+
* can make stored bytes render as active content from the storage origin.
|
|
120
|
+
* Restrict it to known-safe values before signing. The helper's built-in
|
|
121
|
+
* rejection of known browser-executable and sniffable XML/JavaScript media
|
|
122
|
+
* types is best-effort and does not replace an application allow-list.
|
|
123
|
+
*/
|
|
124
|
+
readonly responseContentType?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Permit browser-executable `responseContentType` overrides such as
|
|
127
|
+
* `text/html`, JavaScript, SVG, or XML media types. Leave this unset unless
|
|
128
|
+
* the served object is intentionally meant to render active content from the
|
|
129
|
+
* storage origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans
|
|
130
|
+
* from request JSON are intentionally ignored by the runtime guard.
|
|
131
|
+
*/
|
|
132
|
+
readonly allowBrowserExecutableResponseContentType?: TrustedUnsafeS3PresignOptIn;
|
|
133
|
+
/**
|
|
134
|
+
* Override the response Expires header. Do not populate this from
|
|
135
|
+
* untrusted input without an allow-list.
|
|
136
|
+
*/
|
|
137
|
+
readonly responseExpires?: Date;
|
|
138
|
+
}
|
|
139
|
+
/** Options for {@link presignS3PutObjectUrl}. */
|
|
140
|
+
export interface PresignS3PutObjectUrlOptions extends S3PresignObjectUrlOptions {
|
|
141
|
+
/**
|
|
142
|
+
* Optional content type for the uploaded object. When supplied, the generated
|
|
143
|
+
* URL signs the Content-Type header, so upload clients must send the same
|
|
144
|
+
* value. Browser-executable and sniffable XML/JavaScript types are rejected
|
|
145
|
+
* by default as a best-effort guard; callers accepting untrusted uploads
|
|
146
|
+
* should still enforce their own allow-list.
|
|
147
|
+
*/
|
|
148
|
+
readonly contentType?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Permit browser-executable `contentType` values such as `text/html`,
|
|
151
|
+
* JavaScript, SVG, or XML media types. Leave this unset unless the uploaded
|
|
152
|
+
* object is intentionally meant to render active content from the storage
|
|
153
|
+
* origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans from
|
|
154
|
+
* request JSON are intentionally ignored by the runtime guard.
|
|
155
|
+
*/
|
|
156
|
+
readonly allowBrowserExecutableContentType?: TrustedUnsafeS3PresignOptIn;
|
|
157
|
+
/**
|
|
158
|
+
* Optional content length. Must be a non-negative safe integer. When
|
|
159
|
+
* supplied, the generated URL signs the Content-Length header, so upload
|
|
160
|
+
* clients must send the same value.
|
|
161
|
+
*/
|
|
162
|
+
readonly contentLength?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Optional user metadata to attach to the object. The generated URL signs
|
|
165
|
+
* matching `x-amz-meta-*` headers, so upload clients must send the same values.
|
|
166
|
+
* Pass bare metadata keys; the helper adds the `x-amz-meta-` prefix. Metadata
|
|
167
|
+
* keys must be valid HTTP header tokens and must not differ only by case.
|
|
168
|
+
*/
|
|
169
|
+
readonly metadata?: Record<string, string>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Options for {@link presignPutObjectUrl}.
|
|
173
|
+
*
|
|
174
|
+
* @deprecated Use {@link PresignS3PutObjectUrlOptions}.
|
|
175
|
+
*/
|
|
176
|
+
export type PresignPutObjectUrlOptions = PresignS3PutObjectUrlOptions;
|
|
41
177
|
/**
|
|
42
178
|
* Derives an S3-compatible client configuration from B2 authorization state.
|
|
43
179
|
* Pass the result to `new S3Client(config)` from `@aws-sdk/client-s3`.
|
|
44
180
|
*
|
|
181
|
+
* Non-standard, custom, or proxied endpoints require an explicit `region`; set
|
|
182
|
+
* it before deploying this SDK to those endpoints. The SDK no longer falls back
|
|
183
|
+
* to `us-west-004` because that can mis-sign requests.
|
|
184
|
+
*
|
|
45
185
|
* @param config - B2 auth state, application key credentials, and optional region override.
|
|
46
186
|
*
|
|
47
187
|
* @returns Configuration ready for the AWS S3 SDK.
|
|
@@ -59,16 +199,104 @@ export interface S3ClientConfig {
|
|
|
59
199
|
*/
|
|
60
200
|
export declare function createS3ClientConfig(config: B2S3Config): S3ClientConfig;
|
|
61
201
|
/**
|
|
62
|
-
*
|
|
63
|
-
* This is not a standard S3 presigned URL but works for B2 download endpoints.
|
|
202
|
+
* Extracts the B2 S3 region from a standard B2 S3 endpoint.
|
|
64
203
|
*
|
|
65
|
-
*
|
|
204
|
+
* Custom endpoints cannot be inferred safely. Pass `region` explicitly to
|
|
205
|
+
* {@link createS3ClientConfig}, {@link presignS3GetObjectUrl}, or
|
|
206
|
+
* {@link presignS3PutObjectUrl} when this returns `null`.
|
|
207
|
+
*
|
|
208
|
+
* @param endpoint - The S3 endpoint URL.
|
|
209
|
+
*
|
|
210
|
+
* @returns The derived region, or `null` when the endpoint is not a standard B2 S3 URL.
|
|
211
|
+
*/
|
|
212
|
+
export declare function deriveS3RegionFromEndpoint(endpoint: string): string | null;
|
|
213
|
+
/**
|
|
214
|
+
* Generates an AWS Signature Version 4 presigned GET URL for B2's S3-compatible API.
|
|
215
|
+
*
|
|
216
|
+
* This helper signs internally and does not pass the B2 application key to
|
|
217
|
+
* runtime peer dependencies. Response override options are signed into the URL
|
|
218
|
+
* and control headers served from the storage origin; do not populate them from
|
|
219
|
+
* untrusted input without an allow-list. Presign success does not prove the URL
|
|
220
|
+
* will be accepted later; keep URL-generating hosts clock-synchronized and
|
|
221
|
+
* check clock skew when downstream use returns SigV4 403 errors.
|
|
222
|
+
*
|
|
223
|
+
* @param options - B2 auth state, S3 credentials, target object, and signing options.
|
|
224
|
+
*
|
|
225
|
+
* @returns The presigned URL string.
|
|
226
|
+
*/
|
|
227
|
+
export declare function presignS3GetObjectUrl(options: PresignS3GetObjectUrlOptions): Promise<string>;
|
|
228
|
+
/**
|
|
229
|
+
* Returns a B2-native download-authorization URL, not an S3 presigned URL.
|
|
230
|
+
*
|
|
231
|
+
* This deprecated helper preserves the legacy positional output contract where
|
|
232
|
+
* the whole file name is encoded as one URL component, including `/` as `%2F`.
|
|
233
|
+
* It keeps the legacy string-building contract for callers that relied on
|
|
234
|
+
* custom/local download URLs or permissive inputs. Use
|
|
235
|
+
* {@link createNativeDownloadAuthorizationUrl} for strict validation.
|
|
236
|
+
*
|
|
237
|
+
* @param downloadUrl - The B2 download URL from authorization.
|
|
66
238
|
* @param bucketName - The bucket containing the file.
|
|
67
239
|
* @param fileName - The file name (path) to download.
|
|
68
240
|
* @param authorizationToken - A download authorization token from `b2_get_download_authorization`.
|
|
69
|
-
* @param validDurationInSeconds -
|
|
241
|
+
* @param validDurationInSeconds - Compatibility-only value for the non-authoritative `expires` query.
|
|
70
242
|
*
|
|
71
|
-
* @returns The
|
|
243
|
+
* @returns The B2 native download-authorization URL string.
|
|
244
|
+
*
|
|
245
|
+
* @deprecated Use {@link createNativeDownloadAuthorizationUrl} for B2 native
|
|
246
|
+
* download-token URLs, or {@link presignS3GetObjectUrl} for real S3-compatible
|
|
247
|
+
* AWS Signature Version 4 presigned GET URLs.
|
|
72
248
|
*/
|
|
73
249
|
export declare function presignGetObjectUrl(downloadUrl: string, bucketName: string, fileName: string, authorizationToken: string, validDurationInSeconds?: number): string;
|
|
250
|
+
/**
|
|
251
|
+
* Generates an AWS Signature Version 4 presigned PUT URL for browser or
|
|
252
|
+
* third-party uploads through B2's S3-compatible API.
|
|
253
|
+
*
|
|
254
|
+
* This helper signs internally and does not pass the B2 application key to
|
|
255
|
+
* runtime peer dependencies. A presigned PUT URL is a replayable bearer
|
|
256
|
+
* credential for writing one key until expiry. Retried PUTs can create
|
|
257
|
+
* duplicate B2 file versions when a response is lost after B2 stored the object.
|
|
258
|
+
* Use unique keys or reconcile uploaded file IDs/checksums, and configure
|
|
259
|
+
* lifecycle/version cleanup where duplicate versions must be removed
|
|
260
|
+
* automatically. If `contentType` and `contentLength` are omitted, the holder
|
|
261
|
+
* can choose any content type, including browser-executable types, and any size
|
|
262
|
+
* accepted by B2; bind both values before handing URLs to untrusted uploaders
|
|
263
|
+
* to limit financial-DoS and content-type smuggling risk.
|
|
264
|
+
*
|
|
265
|
+
* @param options - B2 auth state, S3 credentials, target object, and signing options.
|
|
266
|
+
*
|
|
267
|
+
* @returns The presigned URL string.
|
|
268
|
+
*/
|
|
269
|
+
export declare function presignS3PutObjectUrl(options: PresignS3PutObjectUrlOptions): Promise<string>;
|
|
270
|
+
/**
|
|
271
|
+
* Generates an AWS Signature Version 4 presigned PUT URL for B2's
|
|
272
|
+
* S3-compatible API.
|
|
273
|
+
*
|
|
274
|
+
* @param options - B2 auth state, S3 credentials, target object, and signing options.
|
|
275
|
+
*
|
|
276
|
+
* @returns The presigned URL string.
|
|
277
|
+
*
|
|
278
|
+
* @deprecated Use {@link presignS3PutObjectUrl}; this alias is retained for
|
|
279
|
+
* pre-release callers that adopted the shorter name.
|
|
280
|
+
*/
|
|
281
|
+
export declare function presignPutObjectUrl(options: PresignPutObjectUrlOptions): Promise<string>;
|
|
282
|
+
/**
|
|
283
|
+
* Constructs a B2-native download URL using a token from `b2_get_download_authorization`.
|
|
284
|
+
* This is not an S3 presigned URL.
|
|
285
|
+
*
|
|
286
|
+
* The token lifetime is fixed when `b2_get_download_authorization` creates the
|
|
287
|
+
* token. `validDurationInSeconds` is retained only for compatibility with the
|
|
288
|
+
* legacy `presignGetObjectUrl` helper's decorative `expires` query parameter;
|
|
289
|
+
* changing it here does not shorten or extend access.
|
|
290
|
+
* Because the returned URL carries a bearer token, `downloadUrl` must be an
|
|
291
|
+
* HTTPS Backblaze download origin without userinfo, path, query, or fragment.
|
|
292
|
+
*
|
|
293
|
+
* @param downloadUrl - The B2 download URL from authorization (e.g., `https://f004.backblazeb2.com`).
|
|
294
|
+
* @param bucketName - The bucket containing the file.
|
|
295
|
+
* @param fileName - The file name (path) to download.
|
|
296
|
+
* @param authorizationToken - A download authorization token from `b2_get_download_authorization`.
|
|
297
|
+
* @param validDurationInSeconds - Compatibility-only value for the non-authoritative `expires` query.
|
|
298
|
+
*
|
|
299
|
+
* @returns The B2 native download-authorization URL string, not an S3 presigned URL.
|
|
300
|
+
*/
|
|
301
|
+
export declare function createNativeDownloadAuthorizationUrl(downloadUrl: string, bucketName: string, fileName: string, authorizationToken: string, validDurationInSeconds?: number): string;
|
|
74
302
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/s3/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/s3/index.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/s3/index.js"],"names":[],"mappings":"AAAA;;;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AAI,CAU1E;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,MAAM,CAAC,CA0CjB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAC1B,sBAAsB,CAAC,EAAE,MAAM,GAC9B,MAAM,CAKR;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,MAAM,CAAC,CAqBjB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,MAAM,CAAC,CAE9F;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oCAAoC,CAClD,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAC1B,sBAAsB,SAAyC,GAC9D,MAAM,CAUR"}
|
package/dist/s3/index.d.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { AccountInfo } from '../auth/account-info.js';
|
|
2
|
+
/**
|
|
3
|
+
* Trusted server-side token for intentionally allowing active-content S3 presign options.
|
|
4
|
+
*
|
|
5
|
+
* Plain objects and JSON payloads cannot satisfy the runtime identity check
|
|
6
|
+
* for this token. Pass this exported value only from trusted application code
|
|
7
|
+
* after applying your own content and response-header policy.
|
|
8
|
+
*/
|
|
9
|
+
export interface TrustedUnsafeS3PresignOptIn {
|
|
10
|
+
/**
|
|
11
|
+
* Internal marker used only by the runtime identity check.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
readonly __trustedUnsafeS3PresignOptIn: 'trustedUnsafeS3PresignOptIn';
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Server-side opt-in token for unsafe S3 presign options.
|
|
19
|
+
*
|
|
20
|
+
* Use this token as the value for `allowBrowserExecutableContentType`,
|
|
21
|
+
* `allowBrowserExecutableResponseContentType`, or
|
|
22
|
+
* `allowInlineResponseContentDisposition` only when active content or inline
|
|
23
|
+
* rendering from the storage origin is intentional and trusted.
|
|
24
|
+
*/
|
|
25
|
+
export declare const trustedUnsafeS3PresignOptIn: TrustedUnsafeS3PresignOptIn;
|
|
2
26
|
/**
|
|
3
27
|
* Configuration for deriving S3-compatible client settings from B2 auth state.
|
|
4
28
|
*
|
|
@@ -38,10 +62,126 @@ export interface S3ClientConfig {
|
|
|
38
62
|
/** Always `true` for B2, which requires path-style bucket addressing. */
|
|
39
63
|
readonly forcePathStyle: boolean;
|
|
40
64
|
}
|
|
65
|
+
/** Common options for S3-compatible presigned object URLs. */
|
|
66
|
+
export interface S3PresignObjectUrlOptions extends B2S3Config {
|
|
67
|
+
/** Bucket containing the object. */
|
|
68
|
+
readonly bucketName: string;
|
|
69
|
+
/**
|
|
70
|
+
* Object key / B2 file name to sign. Keys with path segments exactly `.`
|
|
71
|
+
* or `..` cannot be presigned safely because common URL parsers normalize
|
|
72
|
+
* them before sending the request.
|
|
73
|
+
*/
|
|
74
|
+
readonly fileName: string;
|
|
75
|
+
/**
|
|
76
|
+
* URL validity duration in seconds. Defaults to 3600. Must be an integer
|
|
77
|
+
* from 1 to 604800 (7 days), the AWS Signature Version 4 presign maximum.
|
|
78
|
+
* A presigned URL is a bearer credential for the signed operation; keep
|
|
79
|
+
* this as short as the calling workflow allows.
|
|
80
|
+
*/
|
|
81
|
+
readonly expiresIn?: number;
|
|
82
|
+
}
|
|
83
|
+
/** Options for {@link presignS3GetObjectUrl}. */
|
|
84
|
+
export interface PresignS3GetObjectUrlOptions extends S3PresignObjectUrlOptions {
|
|
85
|
+
/** Optional S3 version ID to include in the signed GET request. */
|
|
86
|
+
readonly versionId?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Override the response Cache-Control header. Response overrides control
|
|
89
|
+
* headers served from the storage origin; do not populate them from
|
|
90
|
+
* untrusted input without an allow-list.
|
|
91
|
+
*/
|
|
92
|
+
readonly responseCacheControl?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Override the response Content-Disposition header. Prefer a safe
|
|
95
|
+
* attachment disposition when this value can be influenced by users. The
|
|
96
|
+
* helper rejects `inline` response dispositions by default because they can
|
|
97
|
+
* make stored bytes render from the storage origin.
|
|
98
|
+
*/
|
|
99
|
+
readonly responseContentDisposition?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Permit an `inline` response Content-Disposition override. Set only when
|
|
102
|
+
* the object bytes and response headers are trusted to render from the
|
|
103
|
+
* storage origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans
|
|
104
|
+
* from request JSON are intentionally ignored by the runtime guard.
|
|
105
|
+
*/
|
|
106
|
+
readonly allowInlineResponseContentDisposition?: TrustedUnsafeS3PresignOptIn;
|
|
107
|
+
/**
|
|
108
|
+
* Override the response Content-Encoding header. Do not populate this from
|
|
109
|
+
* untrusted input without an allow-list.
|
|
110
|
+
*/
|
|
111
|
+
readonly responseContentEncoding?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Override the response Content-Language header. Do not populate this from
|
|
114
|
+
* untrusted input without an allow-list.
|
|
115
|
+
*/
|
|
116
|
+
readonly responseContentLanguage?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Override the response Content-Type header. If attacker-controlled, this
|
|
119
|
+
* can make stored bytes render as active content from the storage origin.
|
|
120
|
+
* Restrict it to known-safe values before signing. The helper's built-in
|
|
121
|
+
* rejection of known browser-executable and sniffable XML/JavaScript media
|
|
122
|
+
* types is best-effort and does not replace an application allow-list.
|
|
123
|
+
*/
|
|
124
|
+
readonly responseContentType?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Permit browser-executable `responseContentType` overrides such as
|
|
127
|
+
* `text/html`, JavaScript, SVG, or XML media types. Leave this unset unless
|
|
128
|
+
* the served object is intentionally meant to render active content from the
|
|
129
|
+
* storage origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans
|
|
130
|
+
* from request JSON are intentionally ignored by the runtime guard.
|
|
131
|
+
*/
|
|
132
|
+
readonly allowBrowserExecutableResponseContentType?: TrustedUnsafeS3PresignOptIn;
|
|
133
|
+
/**
|
|
134
|
+
* Override the response Expires header. Do not populate this from
|
|
135
|
+
* untrusted input without an allow-list.
|
|
136
|
+
*/
|
|
137
|
+
readonly responseExpires?: Date;
|
|
138
|
+
}
|
|
139
|
+
/** Options for {@link presignS3PutObjectUrl}. */
|
|
140
|
+
export interface PresignS3PutObjectUrlOptions extends S3PresignObjectUrlOptions {
|
|
141
|
+
/**
|
|
142
|
+
* Optional content type for the uploaded object. When supplied, the generated
|
|
143
|
+
* URL signs the Content-Type header, so upload clients must send the same
|
|
144
|
+
* value. Browser-executable and sniffable XML/JavaScript types are rejected
|
|
145
|
+
* by default as a best-effort guard; callers accepting untrusted uploads
|
|
146
|
+
* should still enforce their own allow-list.
|
|
147
|
+
*/
|
|
148
|
+
readonly contentType?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Permit browser-executable `contentType` values such as `text/html`,
|
|
151
|
+
* JavaScript, SVG, or XML media types. Leave this unset unless the uploaded
|
|
152
|
+
* object is intentionally meant to render active content from the storage
|
|
153
|
+
* origin. Pass {@link trustedUnsafeS3PresignOptIn}; plain booleans from
|
|
154
|
+
* request JSON are intentionally ignored by the runtime guard.
|
|
155
|
+
*/
|
|
156
|
+
readonly allowBrowserExecutableContentType?: TrustedUnsafeS3PresignOptIn;
|
|
157
|
+
/**
|
|
158
|
+
* Optional content length. Must be a non-negative safe integer. When
|
|
159
|
+
* supplied, the generated URL signs the Content-Length header, so upload
|
|
160
|
+
* clients must send the same value.
|
|
161
|
+
*/
|
|
162
|
+
readonly contentLength?: number;
|
|
163
|
+
/**
|
|
164
|
+
* Optional user metadata to attach to the object. The generated URL signs
|
|
165
|
+
* matching `x-amz-meta-*` headers, so upload clients must send the same values.
|
|
166
|
+
* Pass bare metadata keys; the helper adds the `x-amz-meta-` prefix. Metadata
|
|
167
|
+
* keys must be valid HTTP header tokens and must not differ only by case.
|
|
168
|
+
*/
|
|
169
|
+
readonly metadata?: Record<string, string>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Options for {@link presignPutObjectUrl}.
|
|
173
|
+
*
|
|
174
|
+
* @deprecated Use {@link PresignS3PutObjectUrlOptions}.
|
|
175
|
+
*/
|
|
176
|
+
export type PresignPutObjectUrlOptions = PresignS3PutObjectUrlOptions;
|
|
41
177
|
/**
|
|
42
178
|
* Derives an S3-compatible client configuration from B2 authorization state.
|
|
43
179
|
* Pass the result to `new S3Client(config)` from `@aws-sdk/client-s3`.
|
|
44
180
|
*
|
|
181
|
+
* Non-standard, custom, or proxied endpoints require an explicit `region`; set
|
|
182
|
+
* it before deploying this SDK to those endpoints. The SDK no longer falls back
|
|
183
|
+
* to `us-west-004` because that can mis-sign requests.
|
|
184
|
+
*
|
|
45
185
|
* @param config - B2 auth state, application key credentials, and optional region override.
|
|
46
186
|
*
|
|
47
187
|
* @returns Configuration ready for the AWS S3 SDK.
|
|
@@ -59,16 +199,104 @@ export interface S3ClientConfig {
|
|
|
59
199
|
*/
|
|
60
200
|
export declare function createS3ClientConfig(config: B2S3Config): S3ClientConfig;
|
|
61
201
|
/**
|
|
62
|
-
*
|
|
63
|
-
* This is not a standard S3 presigned URL but works for B2 download endpoints.
|
|
202
|
+
* Extracts the B2 S3 region from a standard B2 S3 endpoint.
|
|
64
203
|
*
|
|
65
|
-
*
|
|
204
|
+
* Custom endpoints cannot be inferred safely. Pass `region` explicitly to
|
|
205
|
+
* {@link createS3ClientConfig}, {@link presignS3GetObjectUrl}, or
|
|
206
|
+
* {@link presignS3PutObjectUrl} when this returns `null`.
|
|
207
|
+
*
|
|
208
|
+
* @param endpoint - The S3 endpoint URL.
|
|
209
|
+
*
|
|
210
|
+
* @returns The derived region, or `null` when the endpoint is not a standard B2 S3 URL.
|
|
211
|
+
*/
|
|
212
|
+
export declare function deriveS3RegionFromEndpoint(endpoint: string): string | null;
|
|
213
|
+
/**
|
|
214
|
+
* Generates an AWS Signature Version 4 presigned GET URL for B2's S3-compatible API.
|
|
215
|
+
*
|
|
216
|
+
* This helper signs internally and does not pass the B2 application key to
|
|
217
|
+
* runtime peer dependencies. Response override options are signed into the URL
|
|
218
|
+
* and control headers served from the storage origin; do not populate them from
|
|
219
|
+
* untrusted input without an allow-list. Presign success does not prove the URL
|
|
220
|
+
* will be accepted later; keep URL-generating hosts clock-synchronized and
|
|
221
|
+
* check clock skew when downstream use returns SigV4 403 errors.
|
|
222
|
+
*
|
|
223
|
+
* @param options - B2 auth state, S3 credentials, target object, and signing options.
|
|
224
|
+
*
|
|
225
|
+
* @returns The presigned URL string.
|
|
226
|
+
*/
|
|
227
|
+
export declare function presignS3GetObjectUrl(options: PresignS3GetObjectUrlOptions): Promise<string>;
|
|
228
|
+
/**
|
|
229
|
+
* Returns a B2-native download-authorization URL, not an S3 presigned URL.
|
|
230
|
+
*
|
|
231
|
+
* This deprecated helper preserves the legacy positional output contract where
|
|
232
|
+
* the whole file name is encoded as one URL component, including `/` as `%2F`.
|
|
233
|
+
* It keeps the legacy string-building contract for callers that relied on
|
|
234
|
+
* custom/local download URLs or permissive inputs. Use
|
|
235
|
+
* {@link createNativeDownloadAuthorizationUrl} for strict validation.
|
|
236
|
+
*
|
|
237
|
+
* @param downloadUrl - The B2 download URL from authorization.
|
|
66
238
|
* @param bucketName - The bucket containing the file.
|
|
67
239
|
* @param fileName - The file name (path) to download.
|
|
68
240
|
* @param authorizationToken - A download authorization token from `b2_get_download_authorization`.
|
|
69
|
-
* @param validDurationInSeconds -
|
|
241
|
+
* @param validDurationInSeconds - Compatibility-only value for the non-authoritative `expires` query.
|
|
70
242
|
*
|
|
71
|
-
* @returns The
|
|
243
|
+
* @returns The B2 native download-authorization URL string.
|
|
244
|
+
*
|
|
245
|
+
* @deprecated Use {@link createNativeDownloadAuthorizationUrl} for B2 native
|
|
246
|
+
* download-token URLs, or {@link presignS3GetObjectUrl} for real S3-compatible
|
|
247
|
+
* AWS Signature Version 4 presigned GET URLs.
|
|
72
248
|
*/
|
|
73
249
|
export declare function presignGetObjectUrl(downloadUrl: string, bucketName: string, fileName: string, authorizationToken: string, validDurationInSeconds?: number): string;
|
|
250
|
+
/**
|
|
251
|
+
* Generates an AWS Signature Version 4 presigned PUT URL for browser or
|
|
252
|
+
* third-party uploads through B2's S3-compatible API.
|
|
253
|
+
*
|
|
254
|
+
* This helper signs internally and does not pass the B2 application key to
|
|
255
|
+
* runtime peer dependencies. A presigned PUT URL is a replayable bearer
|
|
256
|
+
* credential for writing one key until expiry. Retried PUTs can create
|
|
257
|
+
* duplicate B2 file versions when a response is lost after B2 stored the object.
|
|
258
|
+
* Use unique keys or reconcile uploaded file IDs/checksums, and configure
|
|
259
|
+
* lifecycle/version cleanup where duplicate versions must be removed
|
|
260
|
+
* automatically. If `contentType` and `contentLength` are omitted, the holder
|
|
261
|
+
* can choose any content type, including browser-executable types, and any size
|
|
262
|
+
* accepted by B2; bind both values before handing URLs to untrusted uploaders
|
|
263
|
+
* to limit financial-DoS and content-type smuggling risk.
|
|
264
|
+
*
|
|
265
|
+
* @param options - B2 auth state, S3 credentials, target object, and signing options.
|
|
266
|
+
*
|
|
267
|
+
* @returns The presigned URL string.
|
|
268
|
+
*/
|
|
269
|
+
export declare function presignS3PutObjectUrl(options: PresignS3PutObjectUrlOptions): Promise<string>;
|
|
270
|
+
/**
|
|
271
|
+
* Generates an AWS Signature Version 4 presigned PUT URL for B2's
|
|
272
|
+
* S3-compatible API.
|
|
273
|
+
*
|
|
274
|
+
* @param options - B2 auth state, S3 credentials, target object, and signing options.
|
|
275
|
+
*
|
|
276
|
+
* @returns The presigned URL string.
|
|
277
|
+
*
|
|
278
|
+
* @deprecated Use {@link presignS3PutObjectUrl}; this alias is retained for
|
|
279
|
+
* pre-release callers that adopted the shorter name.
|
|
280
|
+
*/
|
|
281
|
+
export declare function presignPutObjectUrl(options: PresignPutObjectUrlOptions): Promise<string>;
|
|
282
|
+
/**
|
|
283
|
+
* Constructs a B2-native download URL using a token from `b2_get_download_authorization`.
|
|
284
|
+
* This is not an S3 presigned URL.
|
|
285
|
+
*
|
|
286
|
+
* The token lifetime is fixed when `b2_get_download_authorization` creates the
|
|
287
|
+
* token. `validDurationInSeconds` is retained only for compatibility with the
|
|
288
|
+
* legacy `presignGetObjectUrl` helper's decorative `expires` query parameter;
|
|
289
|
+
* changing it here does not shorten or extend access.
|
|
290
|
+
* Because the returned URL carries a bearer token, `downloadUrl` must be an
|
|
291
|
+
* HTTPS Backblaze download origin without userinfo, path, query, or fragment.
|
|
292
|
+
*
|
|
293
|
+
* @param downloadUrl - The B2 download URL from authorization (e.g., `https://f004.backblazeb2.com`).
|
|
294
|
+
* @param bucketName - The bucket containing the file.
|
|
295
|
+
* @param fileName - The file name (path) to download.
|
|
296
|
+
* @param authorizationToken - A download authorization token from `b2_get_download_authorization`.
|
|
297
|
+
* @param validDurationInSeconds - Compatibility-only value for the non-authoritative `expires` query.
|
|
298
|
+
*
|
|
299
|
+
* @returns The B2 native download-authorization URL string, not an S3 presigned URL.
|
|
300
|
+
*/
|
|
301
|
+
export declare function createNativeDownloadAuthorizationUrl(downloadUrl: string, bucketName: string, fileName: string, authorizationToken: string, validDurationInSeconds?: number): string;
|
|
74
302
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/s3/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/s3/index.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/s3/index.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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