@backblaze-labs/b2-sdk 0.1.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 +121 -0
- package/LICENSE +21 -0
- package/README.md +664 -0
- package/dist/auth/account-info.d.cts +51 -0
- package/dist/auth/account-info.d.cts.map +1 -0
- package/dist/auth/account-info.d.ts +51 -0
- package/dist/auth/account-info.d.ts.map +1 -0
- package/dist/auth/file.cjs +210 -0
- package/dist/auth/file.cjs.map +1 -0
- package/dist/auth/file.d.cts +157 -0
- package/dist/auth/file.d.cts.map +1 -0
- package/dist/auth/file.d.ts +157 -0
- package/dist/auth/file.d.ts.map +1 -0
- package/dist/auth/file.js +210 -0
- package/dist/auth/file.js.map +1 -0
- package/dist/auth/in-memory.cjs +184 -0
- package/dist/auth/in-memory.cjs.map +1 -0
- package/dist/auth/in-memory.d.cts +147 -0
- package/dist/auth/in-memory.d.cts.map +1 -0
- package/dist/auth/in-memory.d.ts +147 -0
- package/dist/auth/in-memory.d.ts.map +1 -0
- package/dist/auth/in-memory.js +184 -0
- package/dist/auth/in-memory.js.map +1 -0
- package/dist/auth/index.cjs +10 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +6 -0
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +10 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/realms.cjs +12 -0
- package/dist/auth/realms.cjs.map +1 -0
- package/dist/auth/realms.d.cts +12 -0
- package/dist/auth/realms.d.cts.map +1 -0
- package/dist/auth/realms.d.ts +12 -0
- package/dist/auth/realms.d.ts.map +1 -0
- package/dist/auth/realms.js +12 -0
- package/dist/auth/realms.js.map +1 -0
- package/dist/auth/upload-url-pool.cjs +52 -0
- package/dist/auth/upload-url-pool.cjs.map +1 -0
- package/dist/auth/upload-url-pool.d.cts +35 -0
- package/dist/auth/upload-url-pool.d.cts.map +1 -0
- package/dist/auth/upload-url-pool.d.ts +35 -0
- package/dist/auth/upload-url-pool.d.ts.map +1 -0
- package/dist/auth/upload-url-pool.js +52 -0
- package/dist/auth/upload-url-pool.js.map +1 -0
- package/dist/bucket.cjs +789 -0
- package/dist/bucket.cjs.map +1 -0
- package/dist/bucket.d.cts +659 -0
- package/dist/bucket.d.cts.map +1 -0
- package/dist/bucket.d.ts +659 -0
- package/dist/bucket.d.ts.map +1 -0
- package/dist/bucket.js +789 -0
- package/dist/bucket.js.map +1 -0
- package/dist/client.cjs +230 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +222 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +222 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +230 -0
- package/dist/client.js.map +1 -0
- package/dist/copy/large.cjs +74 -0
- package/dist/copy/large.cjs.map +1 -0
- package/dist/copy/large.d.cts +53 -0
- package/dist/copy/large.d.cts.map +1 -0
- package/dist/copy/large.d.ts +53 -0
- package/dist/copy/large.d.ts.map +1 -0
- package/dist/copy/large.js +74 -0
- package/dist/copy/large.js.map +1 -0
- package/dist/download/parallel.cjs +122 -0
- package/dist/download/parallel.cjs.map +1 -0
- package/dist/download/parallel.d.cts +42 -0
- package/dist/download/parallel.d.cts.map +1 -0
- package/dist/download/parallel.d.ts +42 -0
- package/dist/download/parallel.d.ts.map +1 -0
- package/dist/download/parallel.js +122 -0
- package/dist/download/parallel.js.map +1 -0
- package/dist/download/single.cjs +117 -0
- package/dist/download/single.cjs.map +1 -0
- package/dist/download/single.d.cts +152 -0
- package/dist/download/single.d.cts.map +1 -0
- package/dist/download/single.d.ts +152 -0
- package/dist/download/single.d.ts.map +1 -0
- package/dist/download/single.js +117 -0
- package/dist/download/single.js.map +1 -0
- package/dist/errors/index.cjs +268 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +264 -0
- package/dist/errors/index.d.cts.map +1 -0
- package/dist/errors/index.d.ts +264 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +268 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/http/retry.cjs +36 -0
- package/dist/http/retry.cjs.map +1 -0
- package/dist/http/retry.d.cts +34 -0
- package/dist/http/retry.d.cts.map +1 -0
- package/dist/http/retry.d.ts +34 -0
- package/dist/http/retry.d.ts.map +1 -0
- package/dist/http/retry.js +36 -0
- package/dist/http/retry.js.map +1 -0
- package/dist/http/transport.cjs +143 -0
- package/dist/http/transport.cjs.map +1 -0
- package/dist/http/transport.d.cts +122 -0
- package/dist/http/transport.d.cts.map +1 -0
- package/dist/http/transport.d.ts +122 -0
- package/dist/http/transport.d.ts.map +1 -0
- package/dist/http/transport.js +143 -0
- package/dist/http/transport.js.map +1 -0
- package/dist/http/url-guard.cjs +97 -0
- package/dist/http/url-guard.cjs.map +1 -0
- package/dist/http/url-guard.d.cts +88 -0
- package/dist/http/url-guard.d.cts.map +1 -0
- package/dist/http/url-guard.d.ts +88 -0
- package/dist/http/url-guard.d.ts.map +1 -0
- package/dist/http/url-guard.js +97 -0
- package/dist/http/url-guard.js.map +1 -0
- package/dist/http/user-agent.cjs +51 -0
- package/dist/http/user-agent.cjs.map +1 -0
- package/dist/http/user-agent.d.cts +28 -0
- package/dist/http/user-agent.d.cts.map +1 -0
- package/dist/http/user-agent.d.ts +28 -0
- package/dist/http/user-agent.d.ts.map +1 -0
- package/dist/http/user-agent.js +51 -0
- package/dist/http/user-agent.js.map +1 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications/index.cjs +7 -0
- package/dist/notifications/index.cjs.map +1 -0
- package/dist/notifications/index.d.cts +3 -0
- package/dist/notifications/index.d.cts.map +1 -0
- package/dist/notifications/index.d.ts +3 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +7 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/webhook.cjs +106 -0
- package/dist/notifications/webhook.cjs.map +1 -0
- package/dist/notifications/webhook.d.cts +146 -0
- package/dist/notifications/webhook.d.cts.map +1 -0
- package/dist/notifications/webhook.d.ts +146 -0
- package/dist/notifications/webhook.d.ts.map +1 -0
- package/dist/notifications/webhook.js +106 -0
- package/dist/notifications/webhook.js.map +1 -0
- package/dist/object.cjs +212 -0
- package/dist/object.cjs.map +1 -0
- package/dist/object.d.cts +263 -0
- package/dist/object.d.cts.map +1 -0
- package/dist/object.d.ts +263 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/object.js +212 -0
- package/dist/object.js.map +1 -0
- package/dist/package.json.cjs +9 -0
- package/dist/package.json.cjs.map +1 -0
- package/dist/package.json.js +9 -0
- package/dist/package.json.js.map +1 -0
- package/dist/raw/encoding.cjs +47 -0
- package/dist/raw/encoding.cjs.map +1 -0
- package/dist/raw/encoding.d.cts +46 -0
- package/dist/raw/encoding.d.cts.map +1 -0
- package/dist/raw/encoding.d.ts +46 -0
- package/dist/raw/encoding.d.ts.map +1 -0
- package/dist/raw/encoding.js +47 -0
- package/dist/raw/encoding.js.map +1 -0
- package/dist/raw/index.cjs +600 -0
- package/dist/raw/index.cjs.map +1 -0
- package/dist/raw/index.d.cts +381 -0
- package/dist/raw/index.d.cts.map +1 -0
- package/dist/raw/index.d.ts +381 -0
- package/dist/raw/index.d.ts.map +1 -0
- package/dist/raw/index.js +601 -0
- package/dist/raw/index.js.map +1 -0
- package/dist/s3/index.cjs +23 -0
- package/dist/s3/index.cjs.map +1 -0
- package/dist/s3/index.d.cts +74 -0
- package/dist/s3/index.d.cts.map +1 -0
- package/dist/s3/index.d.ts +74 -0
- package/dist/s3/index.d.ts.map +1 -0
- package/dist/s3/index.js +23 -0
- package/dist/s3/index.js.map +1 -0
- package/dist/simulator/capabilities.cjs +53 -0
- package/dist/simulator/capabilities.cjs.map +1 -0
- package/dist/simulator/capabilities.d.cts +15 -0
- package/dist/simulator/capabilities.d.cts.map +1 -0
- package/dist/simulator/capabilities.d.ts +15 -0
- package/dist/simulator/capabilities.d.ts.map +1 -0
- package/dist/simulator/capabilities.js +53 -0
- package/dist/simulator/capabilities.js.map +1 -0
- package/dist/simulator/index.cjs +1559 -0
- package/dist/simulator/index.cjs.map +1 -0
- package/dist/simulator/index.d.cts +495 -0
- package/dist/simulator/index.d.cts.map +1 -0
- package/dist/simulator/index.d.ts +495 -0
- package/dist/simulator/index.d.ts.map +1 -0
- package/dist/simulator/index.js +1560 -0
- package/dist/simulator/index.js.map +1 -0
- package/dist/simulator/validation.cjs +174 -0
- package/dist/simulator/validation.cjs.map +1 -0
- package/dist/simulator/validation.d.cts +104 -0
- package/dist/simulator/validation.d.cts.map +1 -0
- package/dist/simulator/validation.d.ts +104 -0
- package/dist/simulator/validation.d.ts.map +1 -0
- package/dist/simulator/validation.js +174 -0
- package/dist/simulator/validation.js.map +1 -0
- package/dist/streams/collect.cjs +26 -0
- package/dist/streams/collect.cjs.map +1 -0
- package/dist/streams/collect.d.cts +18 -0
- package/dist/streams/collect.d.cts.map +1 -0
- package/dist/streams/collect.d.ts +18 -0
- package/dist/streams/collect.d.ts.map +1 -0
- package/dist/streams/collect.js +26 -0
- package/dist/streams/collect.js.map +1 -0
- package/dist/streams/hash.cjs +123 -0
- package/dist/streams/hash.cjs.map +1 -0
- package/dist/streams/hash.d.cts +42 -0
- package/dist/streams/hash.d.cts.map +1 -0
- package/dist/streams/hash.d.ts +42 -0
- package/dist/streams/hash.d.ts.map +1 -0
- package/dist/streams/hash.js +101 -0
- package/dist/streams/hash.js.map +1 -0
- package/dist/streams/index.cjs +13 -0
- package/dist/streams/index.cjs.map +1 -0
- package/dist/streams/index.d.cts +7 -0
- package/dist/streams/index.d.cts.map +1 -0
- package/dist/streams/index.d.ts +7 -0
- package/dist/streams/index.d.ts.map +1 -0
- package/dist/streams/index.js +13 -0
- package/dist/streams/index.js.map +1 -0
- package/dist/streams/progress.cjs +47 -0
- package/dist/streams/progress.cjs.map +1 -0
- package/dist/streams/progress.d.cts +53 -0
- package/dist/streams/progress.d.cts.map +1 -0
- package/dist/streams/progress.d.ts +53 -0
- package/dist/streams/progress.d.ts.map +1 -0
- package/dist/streams/progress.js +47 -0
- package/dist/streams/progress.js.map +1 -0
- package/dist/streams/source.cjs +155 -0
- package/dist/streams/source.cjs.map +1 -0
- package/dist/streams/source.d.cts +140 -0
- package/dist/streams/source.d.cts.map +1 -0
- package/dist/streams/source.d.ts +140 -0
- package/dist/streams/source.d.ts.map +1 -0
- package/dist/streams/source.js +155 -0
- package/dist/streams/source.js.map +1 -0
- package/dist/sync/actions/index.cjs +191 -0
- package/dist/sync/actions/index.cjs.map +1 -0
- package/dist/sync/actions/index.d.cts +167 -0
- package/dist/sync/actions/index.d.cts.map +1 -0
- package/dist/sync/actions/index.d.ts +167 -0
- package/dist/sync/actions/index.d.ts.map +1 -0
- package/dist/sync/actions/index.js +191 -0
- package/dist/sync/actions/index.js.map +1 -0
- package/dist/sync/index.cjs +23 -0
- package/dist/sync/index.cjs.map +1 -0
- package/dist/sync/index.d.cts +21 -0
- package/dist/sync/index.d.cts.map +1 -0
- package/dist/sync/index.d.ts +21 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +23 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/pairing.cjs +31 -0
- package/dist/sync/pairing.cjs.map +1 -0
- package/dist/sync/pairing.d.cts +13 -0
- package/dist/sync/pairing.d.cts.map +1 -0
- package/dist/sync/pairing.d.ts +13 -0
- package/dist/sync/pairing.d.ts.map +1 -0
- package/dist/sync/pairing.js +31 -0
- package/dist/sync/pairing.js.map +1 -0
- package/dist/sync/policies/compare.cjs +14 -0
- package/dist/sync/policies/compare.cjs.map +1 -0
- package/dist/sync/policies/compare.d.cts +13 -0
- package/dist/sync/policies/compare.d.cts.map +1 -0
- package/dist/sync/policies/compare.d.ts +13 -0
- package/dist/sync/policies/compare.d.ts.map +1 -0
- package/dist/sync/policies/compare.js +14 -0
- package/dist/sync/policies/compare.js.map +1 -0
- package/dist/sync/policies/index.cjs +74 -0
- package/dist/sync/policies/index.cjs.map +1 -0
- package/dist/sync/policies/index.d.cts +42 -0
- package/dist/sync/policies/index.d.cts.map +1 -0
- package/dist/sync/policies/index.d.ts +42 -0
- package/dist/sync/policies/index.d.ts.map +1 -0
- package/dist/sync/policies/index.js +74 -0
- package/dist/sync/policies/index.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +57 -0
- package/dist/sync/scanners/b2.cjs.map +1 -0
- package/dist/sync/scanners/b2.d.cts +20 -0
- package/dist/sync/scanners/b2.d.cts.map +1 -0
- package/dist/sync/scanners/b2.d.ts +20 -0
- package/dist/sync/scanners/b2.d.ts.map +1 -0
- package/dist/sync/scanners/b2.js +57 -0
- package/dist/sync/scanners/b2.js.map +1 -0
- package/dist/sync/scanners/local.cjs +58 -0
- package/dist/sync/scanners/local.cjs.map +1 -0
- package/dist/sync/scanners/local.d.cts +24 -0
- package/dist/sync/scanners/local.d.cts.map +1 -0
- package/dist/sync/scanners/local.d.ts +24 -0
- package/dist/sync/scanners/local.d.ts.map +1 -0
- package/dist/sync/scanners/local.js +58 -0
- package/dist/sync/scanners/local.js.map +1 -0
- package/dist/sync/synchronizer.cjs +203 -0
- package/dist/sync/synchronizer.cjs.map +1 -0
- package/dist/sync/synchronizer.d.cts +52 -0
- package/dist/sync/synchronizer.d.cts.map +1 -0
- package/dist/sync/synchronizer.d.ts +52 -0
- package/dist/sync/synchronizer.d.ts.map +1 -0
- package/dist/sync/synchronizer.js +181 -0
- package/dist/sync/synchronizer.js.map +1 -0
- package/dist/sync/types.d.cts +121 -0
- package/dist/sync/types.d.cts.map +1 -0
- package/dist/sync/types.d.ts +121 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/types/auth.cjs +58 -0
- package/dist/types/auth.cjs.map +1 -0
- package/dist/types/auth.d.cts +150 -0
- package/dist/types/auth.d.cts.map +1 -0
- package/dist/types/auth.d.ts +150 -0
- package/dist/types/auth.d.ts.map +1 -0
- package/dist/types/auth.js +58 -0
- package/dist/types/auth.js.map +1 -0
- package/dist/types/bucket.cjs +44 -0
- package/dist/types/bucket.cjs.map +1 -0
- package/dist/types/bucket.d.cts +245 -0
- package/dist/types/bucket.d.cts.map +1 -0
- package/dist/types/bucket.d.ts +245 -0
- package/dist/types/bucket.d.ts.map +1 -0
- package/dist/types/bucket.js +44 -0
- package/dist/types/bucket.js.map +1 -0
- package/dist/types/download.d.cts +110 -0
- package/dist/types/download.d.cts.map +1 -0
- package/dist/types/download.d.ts +110 -0
- package/dist/types/download.d.ts.map +1 -0
- package/dist/types/encryption.cjs +343 -0
- package/dist/types/encryption.cjs.map +1 -0
- package/dist/types/encryption.d.cts +132 -0
- package/dist/types/encryption.d.cts.map +1 -0
- package/dist/types/encryption.d.ts +132 -0
- package/dist/types/encryption.d.ts.map +1 -0
- package/dist/types/encryption.js +321 -0
- package/dist/types/encryption.js.map +1 -0
- package/dist/types/errors.d.cts +16 -0
- package/dist/types/errors.d.cts.map +1 -0
- package/dist/types/errors.d.ts +16 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/file.cjs +23 -0
- package/dist/types/file.cjs.map +1 -0
- package/dist/types/file.d.cts +220 -0
- package/dist/types/file.d.cts.map +1 -0
- package/dist/types/file.d.ts +220 -0
- package/dist/types/file.d.ts.map +1 -0
- package/dist/types/file.js +23 -0
- package/dist/types/file.js.map +1 -0
- package/dist/types/ids.cjs +27 -0
- package/dist/types/ids.cjs.map +1 -0
- package/dist/types/ids.d.cts +84 -0
- package/dist/types/ids.d.cts.map +1 -0
- package/dist/types/ids.d.ts +84 -0
- package/dist/types/ids.d.ts.map +1 -0
- package/dist/types/ids.js +27 -0
- package/dist/types/ids.js.map +1 -0
- package/dist/types/index.d.cts +25 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/key.d.cts +84 -0
- package/dist/types/key.d.cts.map +1 -0
- package/dist/types/key.d.ts +84 -0
- package/dist/types/key.d.ts.map +1 -0
- package/dist/types/lock.cjs +17 -0
- package/dist/types/lock.cjs.map +1 -0
- package/dist/types/lock.d.cts +92 -0
- package/dist/types/lock.d.cts.map +1 -0
- package/dist/types/lock.d.ts +92 -0
- package/dist/types/lock.d.ts.map +1 -0
- package/dist/types/lock.js +17 -0
- package/dist/types/lock.js.map +1 -0
- package/dist/types/notifications.cjs +24 -0
- package/dist/types/notifications.cjs.map +1 -0
- package/dist/types/notifications.d.cts +97 -0
- package/dist/types/notifications.d.cts.map +1 -0
- package/dist/types/notifications.d.ts +97 -0
- package/dist/types/notifications.d.ts.map +1 -0
- package/dist/types/notifications.js +24 -0
- package/dist/types/notifications.js.map +1 -0
- package/dist/types/replication.d.cts +42 -0
- package/dist/types/replication.d.cts.map +1 -0
- package/dist/types/replication.d.ts +42 -0
- package/dist/types/replication.d.ts.map +1 -0
- package/dist/types/upload.d.cts +219 -0
- package/dist/types/upload.d.cts.map +1 -0
- package/dist/types/upload.d.ts +219 -0
- package/dist/types/upload.d.ts.map +1 -0
- package/dist/upload/cancel.cjs +10 -0
- package/dist/upload/cancel.cjs.map +1 -0
- package/dist/upload/cancel.d.cts +23 -0
- package/dist/upload/cancel.d.cts.map +1 -0
- package/dist/upload/cancel.d.ts +23 -0
- package/dist/upload/cancel.d.ts.map +1 -0
- package/dist/upload/cancel.js +10 -0
- package/dist/upload/cancel.js.map +1 -0
- package/dist/upload/concurrency.cjs +54 -0
- package/dist/upload/concurrency.cjs.map +1 -0
- package/dist/upload/concurrency.d.cts +46 -0
- package/dist/upload/concurrency.d.cts.map +1 -0
- package/dist/upload/concurrency.d.ts +46 -0
- package/dist/upload/concurrency.d.ts.map +1 -0
- package/dist/upload/concurrency.js +54 -0
- package/dist/upload/concurrency.js.map +1 -0
- package/dist/upload/large.cjs +222 -0
- package/dist/upload/large.cjs.map +1 -0
- package/dist/upload/large.d.cts +71 -0
- package/dist/upload/large.d.cts.map +1 -0
- package/dist/upload/large.d.ts +71 -0
- package/dist/upload/large.d.ts.map +1 -0
- package/dist/upload/large.js +222 -0
- package/dist/upload/large.js.map +1 -0
- package/dist/upload/resume.cjs +34 -0
- package/dist/upload/resume.cjs.map +1 -0
- package/dist/upload/resume.d.cts +33 -0
- package/dist/upload/resume.d.cts.map +1 -0
- package/dist/upload/resume.d.ts +33 -0
- package/dist/upload/resume.d.ts.map +1 -0
- package/dist/upload/resume.js +34 -0
- package/dist/upload/resume.js.map +1 -0
- package/dist/upload/single.cjs +47 -0
- package/dist/upload/single.cjs.map +1 -0
- package/dist/upload/single.d.cts +51 -0
- package/dist/upload/single.d.cts.map +1 -0
- package/dist/upload/single.d.ts +51 -0
- package/dist/upload/single.d.ts.map +1 -0
- package/dist/upload/single.js +47 -0
- package/dist/upload/single.js.map +1 -0
- package/dist/upload/stream.cjs +198 -0
- package/dist/upload/stream.cjs.map +1 -0
- package/dist/upload/stream.d.cts +61 -0
- package/dist/upload/stream.d.cts.map +1 -0
- package/dist/upload/stream.d.ts +61 -0
- package/dist/upload/stream.d.ts.map +1 -0
- package/dist/upload/stream.js +198 -0
- package/dist/upload/stream.js.map +1 -0
- package/dist/util/best-effort.cjs +10 -0
- package/dist/util/best-effort.cjs.map +1 -0
- package/dist/util/best-effort.d.cts +31 -0
- package/dist/util/best-effort.d.cts.map +1 -0
- package/dist/util/best-effort.d.ts +31 -0
- package/dist/util/best-effort.d.ts.map +1 -0
- package/dist/util/best-effort.js +10 -0
- package/dist/util/best-effort.js.map +1 -0
- package/dist/util/defaults.cjs +11 -0
- package/dist/util/defaults.cjs.map +1 -0
- package/dist/util/defaults.d.cts +54 -0
- package/dist/util/defaults.d.cts.map +1 -0
- package/dist/util/defaults.d.ts +54 -0
- package/dist/util/defaults.d.ts.map +1 -0
- package/dist/util/defaults.js +11 -0
- package/dist/util/defaults.js.map +1 -0
- package/dist/util/normalize.cjs +16 -0
- package/dist/util/normalize.cjs.map +1 -0
- package/dist/util/normalize.d.cts +62 -0
- package/dist/util/normalize.d.cts.map +1 -0
- package/dist/util/normalize.d.ts +62 -0
- package/dist/util/normalize.d.ts.map +1 -0
- package/dist/util/normalize.js +16 -0
- package/dist/util/normalize.js.map +1 -0
- package/dist/util/paginator.cjs +20 -0
- package/dist/util/paginator.cjs.map +1 -0
- package/dist/util/paginator.d.cts +120 -0
- package/dist/util/paginator.d.cts.map +1 -0
- package/dist/util/paginator.d.ts +120 -0
- package/dist/util/paginator.d.ts.map +1 -0
- package/dist/util/paginator.js +20 -0
- package/dist/util/paginator.js.map +1 -0
- package/dist/util/plan-ranges.cjs +28 -0
- package/dist/util/plan-ranges.cjs.map +1 -0
- package/dist/util/plan-ranges.d.cts +56 -0
- package/dist/util/plan-ranges.d.cts.map +1 -0
- package/dist/util/plan-ranges.d.ts +56 -0
- package/dist/util/plan-ranges.d.ts.map +1 -0
- package/dist/util/plan-ranges.js +28 -0
- package/dist/util/plan-ranges.js.map +1 -0
- package/dist/util/text-codec.cjs +7 -0
- package/dist/util/text-codec.cjs.map +1 -0
- package/dist/util/text-codec.d.cts +26 -0
- package/dist/util/text-codec.d.cts.map +1 -0
- package/dist/util/text-codec.d.ts +26 -0
- package/dist/util/text-codec.d.ts.map +1 -0
- package/dist/util/text-codec.js +7 -0
- package/dist/util/text-codec.js.map +1 -0
- package/dist/util/to-error.cjs +7 -0
- package/dist/util/to-error.cjs.map +1 -0
- package/dist/util/to-error.d.cts +15 -0
- package/dist/util/to-error.d.cts.map +1 -0
- package/dist/util/to-error.d.ts +15 -0
- package/dist/util/to-error.d.ts.map +1 -0
- package/dist/util/to-error.js +7 -0
- package/dist/util/to-error.js.map +1 -0
- package/dist/version.cjs +6 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.cts +14 -0
- package/dist/version.d.cts.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +198 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { BucketId, FileId } from './ids.js';
|
|
2
|
+
/** Request parameters for downloading a file by its ID via `b2_download_file_by_id`. */
|
|
3
|
+
export interface DownloadByIdRequest {
|
|
4
|
+
/** ID of the file version to download. */
|
|
5
|
+
readonly fileId: FileId;
|
|
6
|
+
/** Optional byte range to download (e.g., `'bytes=0-999'`). */
|
|
7
|
+
readonly range?: string;
|
|
8
|
+
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
9
|
+
readonly serverSideEncryption?: {
|
|
10
|
+
/** Encryption algorithm. Always `'AES256'`. */
|
|
11
|
+
readonly algorithm: 'AES256';
|
|
12
|
+
/** Base64-encoded customer-provided decryption key. */
|
|
13
|
+
readonly customerKey: string;
|
|
14
|
+
/** Base64-encoded MD5 digest of the decryption key. */
|
|
15
|
+
readonly customerKeyMd5: string;
|
|
16
|
+
};
|
|
17
|
+
/** Override the Content-Disposition header in the download response. */
|
|
18
|
+
readonly b2ContentDisposition?: string;
|
|
19
|
+
/** Override the Content-Language header in the download response. */
|
|
20
|
+
readonly b2ContentLanguage?: string;
|
|
21
|
+
/** Override the Content-Encoding header in the download response. */
|
|
22
|
+
readonly b2ContentEncoding?: string;
|
|
23
|
+
/** Override the Content-Type header in the download response. */
|
|
24
|
+
readonly b2ContentType?: string;
|
|
25
|
+
/** Override the Cache-Control header in the download response. */
|
|
26
|
+
readonly b2CacheControl?: string;
|
|
27
|
+
/** Override the Expires header in the download response. */
|
|
28
|
+
readonly b2Expires?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Request parameters for downloading a file by bucket name and file name via `b2_download_file_by_name`. */
|
|
31
|
+
export interface DownloadByNameRequest {
|
|
32
|
+
/** Name of the bucket containing the file. */
|
|
33
|
+
readonly bucketName: string;
|
|
34
|
+
/** Full path and name of the file within the bucket. */
|
|
35
|
+
readonly fileName: string;
|
|
36
|
+
/** Optional byte range to download (e.g., `'bytes=0-999'`). */
|
|
37
|
+
readonly range?: string;
|
|
38
|
+
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
39
|
+
readonly serverSideEncryption?: {
|
|
40
|
+
/** Encryption algorithm. Always `'AES256'`. */
|
|
41
|
+
readonly algorithm: 'AES256';
|
|
42
|
+
/** Base64-encoded customer-provided decryption key. */
|
|
43
|
+
readonly customerKey: string;
|
|
44
|
+
/** Base64-encoded MD5 digest of the decryption key. */
|
|
45
|
+
readonly customerKeyMd5: string;
|
|
46
|
+
};
|
|
47
|
+
/** Override the Content-Disposition header in the download response. */
|
|
48
|
+
readonly b2ContentDisposition?: string;
|
|
49
|
+
/** Override the Content-Language header in the download response. */
|
|
50
|
+
readonly b2ContentLanguage?: string;
|
|
51
|
+
/** Override the Content-Encoding header in the download response. */
|
|
52
|
+
readonly b2ContentEncoding?: string;
|
|
53
|
+
/** Override the Content-Type header in the download response. */
|
|
54
|
+
readonly b2ContentType?: string;
|
|
55
|
+
/** Override the Cache-Control header in the download response. */
|
|
56
|
+
readonly b2CacheControl?: string;
|
|
57
|
+
/** Override the Expires header in the download response. */
|
|
58
|
+
readonly b2Expires?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Request parameters for the `b2_get_download_authorization` API call.
|
|
62
|
+
* Creates a time-limited token that authorizes downloads of files matching a prefix.
|
|
63
|
+
*/
|
|
64
|
+
export interface DownloadAuthorizationRequest {
|
|
65
|
+
/** Bucket to authorize downloads from. */
|
|
66
|
+
readonly bucketId: BucketId;
|
|
67
|
+
/** Only files with names starting with this prefix are authorized. */
|
|
68
|
+
readonly fileNamePrefix: string;
|
|
69
|
+
/** Duration in seconds that the authorization token remains valid. */
|
|
70
|
+
readonly validDurationInSeconds: number;
|
|
71
|
+
/** Override the Content-Disposition header in authorized download responses. */
|
|
72
|
+
readonly b2ContentDisposition?: string;
|
|
73
|
+
/** Override the Content-Language header in authorized download responses. */
|
|
74
|
+
readonly b2ContentLanguage?: string;
|
|
75
|
+
/** Override the Content-Encoding header in authorized download responses. */
|
|
76
|
+
readonly b2ContentEncoding?: string;
|
|
77
|
+
/** Override the Content-Type header in authorized download responses. */
|
|
78
|
+
readonly b2ContentType?: string;
|
|
79
|
+
/** Override the Cache-Control header in authorized download responses. */
|
|
80
|
+
readonly b2CacheControl?: string;
|
|
81
|
+
/** Override the Expires header in authorized download responses. */
|
|
82
|
+
readonly b2Expires?: string;
|
|
83
|
+
}
|
|
84
|
+
/** Response from the `b2_get_download_authorization` API call. */
|
|
85
|
+
export interface DownloadAuthorizationResponse {
|
|
86
|
+
/** Bucket the authorization applies to. */
|
|
87
|
+
readonly bucketId: BucketId;
|
|
88
|
+
/** File name prefix the authorization is scoped to. */
|
|
89
|
+
readonly fileNamePrefix: string;
|
|
90
|
+
/** Authorization token to include in download requests. */
|
|
91
|
+
readonly authorizationToken: string;
|
|
92
|
+
}
|
|
93
|
+
/** Parsed headers from a B2 file download response. */
|
|
94
|
+
export interface DownloadHeaders {
|
|
95
|
+
/** MIME type of the downloaded file content. */
|
|
96
|
+
readonly contentType: string;
|
|
97
|
+
/** Size of the downloaded content in bytes. */
|
|
98
|
+
readonly contentLength: number;
|
|
99
|
+
/** SHA-1 checksum of the full file content, or null for large files. */
|
|
100
|
+
readonly contentSha1: string | null;
|
|
101
|
+
/** ID of the downloaded file version. */
|
|
102
|
+
readonly fileId: FileId;
|
|
103
|
+
/** Full path and name of the downloaded file. */
|
|
104
|
+
readonly fileName: string;
|
|
105
|
+
/** User-defined key-value metadata stored with the file. */
|
|
106
|
+
readonly fileInfo: Record<string, string>;
|
|
107
|
+
/** UTC timestamp (milliseconds) when the file was uploaded. */
|
|
108
|
+
readonly uploadTimestamp: number;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","s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;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,uDAAuD;IACvD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,2DAA2D;IAC3D,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CACpC;AAED,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,+CAA+C;IAC/C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACjC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { BucketId, FileId } from './ids.js';
|
|
2
|
+
/** Request parameters for downloading a file by its ID via `b2_download_file_by_id`. */
|
|
3
|
+
export interface DownloadByIdRequest {
|
|
4
|
+
/** ID of the file version to download. */
|
|
5
|
+
readonly fileId: FileId;
|
|
6
|
+
/** Optional byte range to download (e.g., `'bytes=0-999'`). */
|
|
7
|
+
readonly range?: string;
|
|
8
|
+
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
9
|
+
readonly serverSideEncryption?: {
|
|
10
|
+
/** Encryption algorithm. Always `'AES256'`. */
|
|
11
|
+
readonly algorithm: 'AES256';
|
|
12
|
+
/** Base64-encoded customer-provided decryption key. */
|
|
13
|
+
readonly customerKey: string;
|
|
14
|
+
/** Base64-encoded MD5 digest of the decryption key. */
|
|
15
|
+
readonly customerKeyMd5: string;
|
|
16
|
+
};
|
|
17
|
+
/** Override the Content-Disposition header in the download response. */
|
|
18
|
+
readonly b2ContentDisposition?: string;
|
|
19
|
+
/** Override the Content-Language header in the download response. */
|
|
20
|
+
readonly b2ContentLanguage?: string;
|
|
21
|
+
/** Override the Content-Encoding header in the download response. */
|
|
22
|
+
readonly b2ContentEncoding?: string;
|
|
23
|
+
/** Override the Content-Type header in the download response. */
|
|
24
|
+
readonly b2ContentType?: string;
|
|
25
|
+
/** Override the Cache-Control header in the download response. */
|
|
26
|
+
readonly b2CacheControl?: string;
|
|
27
|
+
/** Override the Expires header in the download response. */
|
|
28
|
+
readonly b2Expires?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Request parameters for downloading a file by bucket name and file name via `b2_download_file_by_name`. */
|
|
31
|
+
export interface DownloadByNameRequest {
|
|
32
|
+
/** Name of the bucket containing the file. */
|
|
33
|
+
readonly bucketName: string;
|
|
34
|
+
/** Full path and name of the file within the bucket. */
|
|
35
|
+
readonly fileName: string;
|
|
36
|
+
/** Optional byte range to download (e.g., `'bytes=0-999'`). */
|
|
37
|
+
readonly range?: string;
|
|
38
|
+
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
39
|
+
readonly serverSideEncryption?: {
|
|
40
|
+
/** Encryption algorithm. Always `'AES256'`. */
|
|
41
|
+
readonly algorithm: 'AES256';
|
|
42
|
+
/** Base64-encoded customer-provided decryption key. */
|
|
43
|
+
readonly customerKey: string;
|
|
44
|
+
/** Base64-encoded MD5 digest of the decryption key. */
|
|
45
|
+
readonly customerKeyMd5: string;
|
|
46
|
+
};
|
|
47
|
+
/** Override the Content-Disposition header in the download response. */
|
|
48
|
+
readonly b2ContentDisposition?: string;
|
|
49
|
+
/** Override the Content-Language header in the download response. */
|
|
50
|
+
readonly b2ContentLanguage?: string;
|
|
51
|
+
/** Override the Content-Encoding header in the download response. */
|
|
52
|
+
readonly b2ContentEncoding?: string;
|
|
53
|
+
/** Override the Content-Type header in the download response. */
|
|
54
|
+
readonly b2ContentType?: string;
|
|
55
|
+
/** Override the Cache-Control header in the download response. */
|
|
56
|
+
readonly b2CacheControl?: string;
|
|
57
|
+
/** Override the Expires header in the download response. */
|
|
58
|
+
readonly b2Expires?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Request parameters for the `b2_get_download_authorization` API call.
|
|
62
|
+
* Creates a time-limited token that authorizes downloads of files matching a prefix.
|
|
63
|
+
*/
|
|
64
|
+
export interface DownloadAuthorizationRequest {
|
|
65
|
+
/** Bucket to authorize downloads from. */
|
|
66
|
+
readonly bucketId: BucketId;
|
|
67
|
+
/** Only files with names starting with this prefix are authorized. */
|
|
68
|
+
readonly fileNamePrefix: string;
|
|
69
|
+
/** Duration in seconds that the authorization token remains valid. */
|
|
70
|
+
readonly validDurationInSeconds: number;
|
|
71
|
+
/** Override the Content-Disposition header in authorized download responses. */
|
|
72
|
+
readonly b2ContentDisposition?: string;
|
|
73
|
+
/** Override the Content-Language header in authorized download responses. */
|
|
74
|
+
readonly b2ContentLanguage?: string;
|
|
75
|
+
/** Override the Content-Encoding header in authorized download responses. */
|
|
76
|
+
readonly b2ContentEncoding?: string;
|
|
77
|
+
/** Override the Content-Type header in authorized download responses. */
|
|
78
|
+
readonly b2ContentType?: string;
|
|
79
|
+
/** Override the Cache-Control header in authorized download responses. */
|
|
80
|
+
readonly b2CacheControl?: string;
|
|
81
|
+
/** Override the Expires header in authorized download responses. */
|
|
82
|
+
readonly b2Expires?: string;
|
|
83
|
+
}
|
|
84
|
+
/** Response from the `b2_get_download_authorization` API call. */
|
|
85
|
+
export interface DownloadAuthorizationResponse {
|
|
86
|
+
/** Bucket the authorization applies to. */
|
|
87
|
+
readonly bucketId: BucketId;
|
|
88
|
+
/** File name prefix the authorization is scoped to. */
|
|
89
|
+
readonly fileNamePrefix: string;
|
|
90
|
+
/** Authorization token to include in download requests. */
|
|
91
|
+
readonly authorizationToken: string;
|
|
92
|
+
}
|
|
93
|
+
/** Parsed headers from a B2 file download response. */
|
|
94
|
+
export interface DownloadHeaders {
|
|
95
|
+
/** MIME type of the downloaded file content. */
|
|
96
|
+
readonly contentType: string;
|
|
97
|
+
/** Size of the downloaded content in bytes. */
|
|
98
|
+
readonly contentLength: number;
|
|
99
|
+
/** SHA-1 checksum of the full file content, or null for large files. */
|
|
100
|
+
readonly contentSha1: string | null;
|
|
101
|
+
/** ID of the downloaded file version. */
|
|
102
|
+
readonly fileId: FileId;
|
|
103
|
+
/** Full path and name of the downloaded file. */
|
|
104
|
+
readonly fileName: string;
|
|
105
|
+
/** User-defined key-value metadata stored with the file. */
|
|
106
|
+
readonly fileInfo: Record<string, string>;
|
|
107
|
+
/** UTC timestamp (milliseconds) when the file was uploaded. */
|
|
108
|
+
readonly uploadTimestamp: number;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/types/download.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEhD,wFAAwF;AACxF,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,iFAAiF;IACjF,QAAQ,CAAC,oBAAoB,CAAC,EAAE;QAC9B,+CAA+C;QAC/C,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAA;QAC5B,uDAAuD;QACvD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;QAC5B,uDAAuD;QACvD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;KAChC,CAAA;IACD,wEAAwE;IACxE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAA;IACtC,qEAAqE;IACrE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,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eAAe,EAAE,MAAM,CAAA;CACjC"}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
const EncryptionAlgorithm = {
|
|
26
|
+
/** AES with a 256-bit key. The only algorithm B2 currently supports. */
|
|
27
|
+
Aes256: "AES256"
|
|
28
|
+
};
|
|
29
|
+
const EncryptionMode = {
|
|
30
|
+
/** B2-managed encryption keys. */
|
|
31
|
+
SseB2: "SSE-B2",
|
|
32
|
+
/** Customer-provided encryption keys. */
|
|
33
|
+
SseC: "SSE-C",
|
|
34
|
+
/** No encryption. */
|
|
35
|
+
None: "none"
|
|
36
|
+
};
|
|
37
|
+
const SSE_B2 = { mode: "SSE-B2", algorithm: "AES256" };
|
|
38
|
+
const SSE_NONE = { mode: "none" };
|
|
39
|
+
function sseCustomer(customerKey, customerKeyMd5) {
|
|
40
|
+
return { mode: "SSE-C", algorithm: "AES256", customerKey, customerKeyMd5 };
|
|
41
|
+
}
|
|
42
|
+
function bytesToBase64(bytes) {
|
|
43
|
+
const g = globalThis;
|
|
44
|
+
if (g.Buffer) {
|
|
45
|
+
return g.Buffer.from(bytes).toString("base64");
|
|
46
|
+
}
|
|
47
|
+
let binary = "";
|
|
48
|
+
for (const b of bytes) binary += String.fromCharCode(b);
|
|
49
|
+
return btoa(binary);
|
|
50
|
+
}
|
|
51
|
+
async function md5Base64(bytes) {
|
|
52
|
+
try {
|
|
53
|
+
const { createHash } = await import("node:crypto");
|
|
54
|
+
if (typeof createHash !== "function") throw new Error("createHash unavailable");
|
|
55
|
+
return createHash("md5").update(bytes).digest("base64");
|
|
56
|
+
} catch {
|
|
57
|
+
return bytesToBase64(md5Bytes(bytes));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function md5Bytes(data) {
|
|
61
|
+
const originalBitLength = data.byteLength * 8;
|
|
62
|
+
const padLength = (data.byteLength + 8 >>> 6) + 1;
|
|
63
|
+
const padded = new Uint8Array(padLength * 64);
|
|
64
|
+
padded.set(data);
|
|
65
|
+
padded[data.byteLength] = 128;
|
|
66
|
+
const lowBits = originalBitLength >>> 0;
|
|
67
|
+
const highBits = Math.floor(originalBitLength / 4294967296) >>> 0;
|
|
68
|
+
const lengthView = new DataView(padded.buffer, padded.byteLength - 8, 8);
|
|
69
|
+
lengthView.setUint32(0, lowBits, true);
|
|
70
|
+
lengthView.setUint32(4, highBits, true);
|
|
71
|
+
const s = [
|
|
72
|
+
7,
|
|
73
|
+
12,
|
|
74
|
+
17,
|
|
75
|
+
22,
|
|
76
|
+
7,
|
|
77
|
+
12,
|
|
78
|
+
17,
|
|
79
|
+
22,
|
|
80
|
+
7,
|
|
81
|
+
12,
|
|
82
|
+
17,
|
|
83
|
+
22,
|
|
84
|
+
7,
|
|
85
|
+
12,
|
|
86
|
+
17,
|
|
87
|
+
22,
|
|
88
|
+
5,
|
|
89
|
+
9,
|
|
90
|
+
14,
|
|
91
|
+
20,
|
|
92
|
+
5,
|
|
93
|
+
9,
|
|
94
|
+
14,
|
|
95
|
+
20,
|
|
96
|
+
5,
|
|
97
|
+
9,
|
|
98
|
+
14,
|
|
99
|
+
20,
|
|
100
|
+
5,
|
|
101
|
+
9,
|
|
102
|
+
14,
|
|
103
|
+
20,
|
|
104
|
+
4,
|
|
105
|
+
11,
|
|
106
|
+
16,
|
|
107
|
+
23,
|
|
108
|
+
4,
|
|
109
|
+
11,
|
|
110
|
+
16,
|
|
111
|
+
23,
|
|
112
|
+
4,
|
|
113
|
+
11,
|
|
114
|
+
16,
|
|
115
|
+
23,
|
|
116
|
+
4,
|
|
117
|
+
11,
|
|
118
|
+
16,
|
|
119
|
+
23,
|
|
120
|
+
6,
|
|
121
|
+
10,
|
|
122
|
+
15,
|
|
123
|
+
21,
|
|
124
|
+
6,
|
|
125
|
+
10,
|
|
126
|
+
15,
|
|
127
|
+
21,
|
|
128
|
+
6,
|
|
129
|
+
10,
|
|
130
|
+
15,
|
|
131
|
+
21,
|
|
132
|
+
6,
|
|
133
|
+
10,
|
|
134
|
+
15,
|
|
135
|
+
21
|
|
136
|
+
];
|
|
137
|
+
const k = new Uint32Array([
|
|
138
|
+
3614090360,
|
|
139
|
+
3905402710,
|
|
140
|
+
606105819,
|
|
141
|
+
3250441966,
|
|
142
|
+
4118548399,
|
|
143
|
+
1200080426,
|
|
144
|
+
2821735955,
|
|
145
|
+
4249261313,
|
|
146
|
+
1770035416,
|
|
147
|
+
2336552879,
|
|
148
|
+
4294925233,
|
|
149
|
+
2304563134,
|
|
150
|
+
1804603682,
|
|
151
|
+
4254626195,
|
|
152
|
+
2792965006,
|
|
153
|
+
1236535329,
|
|
154
|
+
4129170786,
|
|
155
|
+
3225465664,
|
|
156
|
+
643717713,
|
|
157
|
+
3921069994,
|
|
158
|
+
3593408605,
|
|
159
|
+
38016083,
|
|
160
|
+
3634488961,
|
|
161
|
+
3889429448,
|
|
162
|
+
568446438,
|
|
163
|
+
3275163606,
|
|
164
|
+
4107603335,
|
|
165
|
+
1163531501,
|
|
166
|
+
2850285829,
|
|
167
|
+
4243563512,
|
|
168
|
+
1735328473,
|
|
169
|
+
2368359562,
|
|
170
|
+
4294588738,
|
|
171
|
+
2272392833,
|
|
172
|
+
1839030562,
|
|
173
|
+
4259657740,
|
|
174
|
+
2763975236,
|
|
175
|
+
1272893353,
|
|
176
|
+
4139469664,
|
|
177
|
+
3200236656,
|
|
178
|
+
681279174,
|
|
179
|
+
3936430074,
|
|
180
|
+
3572445317,
|
|
181
|
+
76029189,
|
|
182
|
+
3654602809,
|
|
183
|
+
3873151461,
|
|
184
|
+
530742520,
|
|
185
|
+
3299628645,
|
|
186
|
+
4096336452,
|
|
187
|
+
1126891415,
|
|
188
|
+
2878612391,
|
|
189
|
+
4237533241,
|
|
190
|
+
1700485571,
|
|
191
|
+
2399980690,
|
|
192
|
+
4293915773,
|
|
193
|
+
2240044497,
|
|
194
|
+
1873313359,
|
|
195
|
+
4264355552,
|
|
196
|
+
2734768916,
|
|
197
|
+
1309151649,
|
|
198
|
+
4149444226,
|
|
199
|
+
3174756917,
|
|
200
|
+
718787259,
|
|
201
|
+
3951481745
|
|
202
|
+
]);
|
|
203
|
+
let a0 = 1732584193;
|
|
204
|
+
let b0 = 4023233417;
|
|
205
|
+
let c0 = 2562383102;
|
|
206
|
+
let d0 = 271733878;
|
|
207
|
+
const m = new Uint32Array(16);
|
|
208
|
+
const view = new DataView(padded.buffer);
|
|
209
|
+
for (let block = 0; block < padded.byteLength; block += 64) {
|
|
210
|
+
for (let i = 0; i < 16; i++) m[i] = view.getUint32(block + i * 4, true);
|
|
211
|
+
let A = a0;
|
|
212
|
+
let B = b0;
|
|
213
|
+
let C = c0;
|
|
214
|
+
let D = d0;
|
|
215
|
+
for (let i = 0; i < 64; i++) {
|
|
216
|
+
let f;
|
|
217
|
+
let g;
|
|
218
|
+
if (i < 16) {
|
|
219
|
+
f = B & C | ~B & D;
|
|
220
|
+
g = i;
|
|
221
|
+
} else if (i < 32) {
|
|
222
|
+
f = D & B | ~D & C;
|
|
223
|
+
g = (5 * i + 1) % 16;
|
|
224
|
+
} else if (i < 48) {
|
|
225
|
+
f = B ^ C ^ D;
|
|
226
|
+
g = (3 * i + 5) % 16;
|
|
227
|
+
} else {
|
|
228
|
+
f = C ^ (B | ~D);
|
|
229
|
+
g = 7 * i % 16;
|
|
230
|
+
}
|
|
231
|
+
const temp = D;
|
|
232
|
+
D = C;
|
|
233
|
+
C = B;
|
|
234
|
+
const sum = A + f + (k[i] ?? 0) + (m[g] ?? 0) >>> 0;
|
|
235
|
+
const shift = s[i] ?? 0;
|
|
236
|
+
const rotated = (sum << shift | sum >>> 32 - shift) >>> 0;
|
|
237
|
+
B = B + rotated >>> 0;
|
|
238
|
+
A = temp;
|
|
239
|
+
}
|
|
240
|
+
a0 = a0 + A >>> 0;
|
|
241
|
+
b0 = b0 + B >>> 0;
|
|
242
|
+
c0 = c0 + C >>> 0;
|
|
243
|
+
d0 = d0 + D >>> 0;
|
|
244
|
+
}
|
|
245
|
+
const out = new Uint8Array(16);
|
|
246
|
+
const outView = new DataView(out.buffer);
|
|
247
|
+
outView.setUint32(0, a0, true);
|
|
248
|
+
outView.setUint32(4, b0, true);
|
|
249
|
+
outView.setUint32(8, c0, true);
|
|
250
|
+
outView.setUint32(12, d0, true);
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
const KEY_REDACTED = "[redacted SSE-C key]";
|
|
254
|
+
class EncryptionKey {
|
|
255
|
+
/** Encryption mode discriminant. Always `'SSE-C'` for this class. */
|
|
256
|
+
mode = "SSE-C";
|
|
257
|
+
/** Encryption algorithm. B2's S3-compatible API only supports AES-256. */
|
|
258
|
+
algorithm = "AES256";
|
|
259
|
+
/** Base64-encoded 256-bit customer key. Logged as `[redacted SSE-C key]` via `toJSON` / `toString`. */
|
|
260
|
+
customerKey;
|
|
261
|
+
/** Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification. */
|
|
262
|
+
customerKeyMd5;
|
|
263
|
+
/**
|
|
264
|
+
* Internal constructor. Use {@link EncryptionKey.fromBytes} or
|
|
265
|
+
* {@link EncryptionKey.fromBase64} instead.
|
|
266
|
+
*
|
|
267
|
+
* @param customerKey - Base64-encoded 256-bit encryption key.
|
|
268
|
+
* @param customerKeyMd5 - Base64-encoded MD5 digest of the key.
|
|
269
|
+
*
|
|
270
|
+
* @internal
|
|
271
|
+
*/
|
|
272
|
+
constructor(customerKey, customerKeyMd5) {
|
|
273
|
+
this.customerKey = customerKey;
|
|
274
|
+
this.customerKeyMd5 = customerKeyMd5;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the
|
|
278
|
+
* required base64 MD5 digest internally.
|
|
279
|
+
*
|
|
280
|
+
* @param rawKey - The raw 256-bit key as bytes. Must be exactly 32 bytes.
|
|
281
|
+
*
|
|
282
|
+
* @returns A safely-wrapped EncryptionKey ready for upload/download.
|
|
283
|
+
*
|
|
284
|
+
* @throws If the key is not exactly 32 bytes.
|
|
285
|
+
*/
|
|
286
|
+
static async fromBytes(rawKey) {
|
|
287
|
+
if (rawKey.byteLength !== 32) {
|
|
288
|
+
throw new Error(`SSE-C key must be exactly 32 bytes (256 bits); got ${rawKey.byteLength}.`);
|
|
289
|
+
}
|
|
290
|
+
const customerKey = bytesToBase64(rawKey);
|
|
291
|
+
const customerKeyMd5 = await md5Base64(rawKey);
|
|
292
|
+
return new EncryptionKey(customerKey, customerKeyMd5);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Builds an EncryptionKey from precomputed base64 strings. Use this in
|
|
296
|
+
* environments where MD5 must be computed externally (e.g., browsers).
|
|
297
|
+
*
|
|
298
|
+
* @param customerKey - Base64-encoded 256-bit encryption key.
|
|
299
|
+
* @param customerKeyMd5 - Base64-encoded MD5 digest of the key.
|
|
300
|
+
*
|
|
301
|
+
* @returns A safely-wrapped EncryptionKey ready for upload/download.
|
|
302
|
+
*/
|
|
303
|
+
static fromBase64(customerKey, customerKeyMd5) {
|
|
304
|
+
return new EncryptionKey(customerKey, customerKeyMd5);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Hides the key bytes from `JSON.stringify`.
|
|
308
|
+
*
|
|
309
|
+
* @returns A redacted shape: same mode and algorithm, but the key and MD5
|
|
310
|
+
* replaced with a placeholder string.
|
|
311
|
+
*/
|
|
312
|
+
toJSON() {
|
|
313
|
+
return {
|
|
314
|
+
mode: this.mode,
|
|
315
|
+
algorithm: this.algorithm,
|
|
316
|
+
customerKey: KEY_REDACTED,
|
|
317
|
+
customerKeyMd5: KEY_REDACTED
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Hides the key bytes from default `toString()`.
|
|
322
|
+
*
|
|
323
|
+
* @returns A short opaque label indicating this is an SSE-C key.
|
|
324
|
+
*/
|
|
325
|
+
toString() {
|
|
326
|
+
return `[EncryptionKey SSE-C ${KEY_REDACTED}]`;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Hides the key bytes from Node's `util.inspect` (and therefore `console.log`).
|
|
330
|
+
*
|
|
331
|
+
* @returns A short opaque label indicating this is an SSE-C key.
|
|
332
|
+
*/
|
|
333
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
334
|
+
return this.toString();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
exports.EncryptionAlgorithm = EncryptionAlgorithm;
|
|
338
|
+
exports.EncryptionKey = EncryptionKey;
|
|
339
|
+
exports.EncryptionMode = EncryptionMode;
|
|
340
|
+
exports.SSE_B2 = SSE_B2;
|
|
341
|
+
exports.SSE_NONE = SSE_NONE;
|
|
342
|
+
exports.sseCustomer = sseCustomer;
|
|
343
|
+
//# sourceMappingURL=encryption.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.cjs","sources":["../../src/types/encryption.ts"],"sourcesContent":["/** Named constants for the supported server-side encryption algorithms. */\nexport const EncryptionAlgorithm = {\n /** AES with a 256-bit key. The only algorithm B2 currently supports. */\n Aes256: 'AES256',\n} as const\n\n/** Supported server-side encryption algorithm. Derived from {@link EncryptionAlgorithm}. */\nexport type EncryptionAlgorithm = (typeof EncryptionAlgorithm)[keyof typeof EncryptionAlgorithm]\n\n/**\n * Named constants for the server-side encryption mode used by a file.\n *\n * Most callers should use the {@link SSE_B2}, {@link SSE_NONE}, and\n * {@link sseCustomer} helpers below which return complete\n * {@link EncryptionSetting} objects. These constants are useful when you\n * need the bare mode discriminator (e.g., when introspecting a file's\n * current encryption setting).\n */\nexport const EncryptionMode = {\n /** B2-managed encryption keys. */\n SseB2: 'SSE-B2',\n /** Customer-provided encryption keys. */\n SseC: 'SSE-C',\n /** No encryption. */\n None: 'none',\n} as const\n\n/** Server-side encryption mode for files stored in B2. Derived from {@link EncryptionMode}. */\nexport type EncryptionMode = (typeof EncryptionMode)[keyof typeof EncryptionMode]\n\n/** Server-side encryption using B2-managed keys (SSE-B2). */\nexport interface SseB2Setting {\n /** Encryption mode discriminator. Always `'SSE-B2'`. */\n readonly mode: 'SSE-B2'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Server-side encryption using customer-provided keys (SSE-C). */\nexport interface SseCCustomerSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n /** Base64-encoded 256-bit encryption key provided by the customer. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */\n readonly customerKeyMd5: string\n}\n\n/** Indicates no server-side encryption is applied. */\nexport interface NoEncryption {\n /** Encryption mode discriminator. Always `'none'`. */\n readonly mode: 'none'\n}\n\n/** Union of all server-side encryption settings: B2-managed, customer-provided, or none. */\nexport type EncryptionSetting = SseB2Setting | SseCCustomerSetting | NoEncryption\n\n/** Pre-built SSE-B2 encryption setting using AES-256. */\nexport const SSE_B2: SseB2Setting = { mode: 'SSE-B2', algorithm: 'AES256' }\n\n/** Pre-built setting indicating no server-side encryption. */\nexport const SSE_NONE: NoEncryption = { mode: 'none' }\n\n/**\n * Creates an SSE-C encryption setting with a customer-provided key.\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns An SSE-C encryption setting ready to pass to upload or download calls.\n */\nexport function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting {\n return { mode: 'SSE-C', algorithm: 'AES256', customerKey, customerKeyMd5 }\n}\n\n/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n // Prefer Node's Buffer when available (faster), but degrade to btoa() in\n // browsers / Deno / Workers where Buffer isn't a global. We access via\n // globalThis to avoid a hard reference to a Node-only symbol — that would\n // break the type-check in non-Node runtimes (Deno, browser-mode Vitest).\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) {\n return g.Buffer.from(bytes).toString('base64')\n }\n let binary = ''\n for (const b of bytes) binary += String.fromCharCode(b)\n return btoa(binary)\n}\n\n/**\n * Computes the MD5 digest of the given bytes as a base64 string. Prefers\n * `node:crypto` for native speed when available; falls back to a pure-JS\n * implementation in browser / edge runtimes because WebCrypto's\n * `crypto.subtle.digest` deliberately does not support MD5.\n *\n * MD5 is used here only for SSE-C key integrity (matching the B2 wire\n * protocol). It is **not** a security boundary; the customer key itself is\n * the secret. Bundling a pure-JS fallback keeps `EncryptionKey.fromBytes`\n * isomorphic.\n *\n * @param bytes - The bytes to digest.\n *\n * @returns The base64-encoded MD5 digest.\n */\nasync function md5Base64(bytes: Uint8Array): Promise<string> {\n try {\n const { createHash } = await import('node:crypto')\n // Vite's browser shim resolves the import but does not implement\n // `createHash`. Probe explicitly so we fall through to the pure-JS path.\n if (typeof createHash !== 'function') throw new Error('createHash unavailable')\n return createHash('md5').update(bytes).digest('base64')\n /* v8 ignore next 3 -- fallback only reachable in non-Node runtimes */\n } catch {\n return bytesToBase64(md5Bytes(bytes))\n }\n}\n\n/**\n * Pure-JS MD5 implementation per RFC 1321. Returns the 16-byte digest of the\n * input. Used as a browser fallback for SSE-C key MD5 computation; not\n * intended for security-sensitive purposes (MD5 is broken cryptographically).\n *\n * @param data - The bytes to hash.\n *\n * @returns The 16-byte MD5 digest.\n */\nfunction md5Bytes(data: Uint8Array): Uint8Array {\n // Padding: append 0x80, then zeros, then the original length in bits as a\n // little-endian 64-bit integer, so the total length is a multiple of 64.\n const originalBitLength = data.byteLength * 8\n const padLength = ((data.byteLength + 8) >>> 6) + 1\n const padded = new Uint8Array(padLength * 64)\n padded.set(data)\n padded[data.byteLength] = 0x80\n // Write the 64-bit length (little-endian). JS bitwise ops are 32-bit, so\n // split into low/high halves.\n const lowBits = originalBitLength >>> 0\n const highBits = Math.floor(originalBitLength / 0x1_0000_0000) >>> 0\n const lengthView = new DataView(padded.buffer, padded.byteLength - 8, 8)\n lengthView.setUint32(0, lowBits, true)\n lengthView.setUint32(4, highBits, true)\n\n // Per-round shift amounts.\n const s = [\n 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9,\n 14, 20, 5, 9, 14, 20, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 6, 10, 15, 21,\n 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21,\n ]\n // Per-round sine-derived constants K[i] = floor(2^32 * abs(sin(i + 1))).\n const k = new Uint32Array([\n 0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,\n 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,\n 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8,\n 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,\n 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,\n 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x04881d05, 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,\n 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,\n 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391,\n ])\n\n let a0 = 0x67452301\n let b0 = 0xefcdab89\n let c0 = 0x98badcfe\n let d0 = 0x10325476\n\n const m = new Uint32Array(16)\n const view = new DataView(padded.buffer)\n for (let block = 0; block < padded.byteLength; block += 64) {\n for (let i = 0; i < 16; i++) m[i] = view.getUint32(block + i * 4, true)\n let A = a0\n let B = b0\n let C = c0\n let D = d0\n for (let i = 0; i < 64; i++) {\n let f: number\n let g: number\n if (i < 16) {\n f = (B & C) | (~B & D)\n g = i\n } else if (i < 32) {\n f = (D & B) | (~D & C)\n g = (5 * i + 1) % 16\n } else if (i < 48) {\n f = B ^ C ^ D\n g = (3 * i + 5) % 16\n } else {\n f = C ^ (B | ~D)\n g = (7 * i) % 16\n }\n const temp = D\n D = C\n C = B\n const sum = (A + f + (k[i] ?? 0) + (m[g] ?? 0)) >>> 0\n const shift = s[i] ?? 0\n const rotated = ((sum << shift) | (sum >>> (32 - shift))) >>> 0\n B = (B + rotated) >>> 0\n A = temp\n }\n a0 = (a0 + A) >>> 0\n b0 = (b0 + B) >>> 0\n c0 = (c0 + C) >>> 0\n d0 = (d0 + D) >>> 0\n }\n\n const out = new Uint8Array(16)\n const outView = new DataView(out.buffer)\n outView.setUint32(0, a0, true)\n outView.setUint32(4, b0, true)\n outView.setUint32(8, c0, true)\n outView.setUint32(12, d0, true)\n return out\n}\n\nconst KEY_REDACTED = '[redacted SSE-C key]'\n\n/**\n * Safe wrapper around an SSE-C customer key. Hides the key bytes from\n * `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}\n * to construct one from a raw 32-byte key; the MD5 digest is computed internally.\n */\nexport class EncryptionKey {\n /** Encryption mode discriminant. Always `'SSE-C'` for this class. */\n readonly mode = 'SSE-C' as const\n /** Encryption algorithm. B2's S3-compatible API only supports AES-256. */\n readonly algorithm: EncryptionAlgorithm = 'AES256'\n /** Base64-encoded 256-bit customer key. Logged as `[redacted SSE-C key]` via `toJSON` / `toString`. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification. */\n readonly customerKeyMd5: string\n\n /**\n * Internal constructor. Use {@link EncryptionKey.fromBytes} or\n * {@link EncryptionKey.fromBase64} instead.\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @internal\n */\n private constructor(customerKey: string, customerKeyMd5: string) {\n this.customerKey = customerKey\n this.customerKeyMd5 = customerKeyMd5\n }\n\n /**\n * Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the\n * required base64 MD5 digest internally.\n *\n * @param rawKey - The raw 256-bit key as bytes. Must be exactly 32 bytes.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n *\n * @throws If the key is not exactly 32 bytes.\n */\n static async fromBytes(rawKey: Uint8Array): Promise<EncryptionKey> {\n if (rawKey.byteLength !== 32) {\n throw new Error(`SSE-C key must be exactly 32 bytes (256 bits); got ${rawKey.byteLength}.`)\n }\n const customerKey = bytesToBase64(rawKey)\n const customerKeyMd5 = await md5Base64(rawKey)\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Builds an EncryptionKey from precomputed base64 strings. Use this in\n * environments where MD5 must be computed externally (e.g., browsers).\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static fromBase64(customerKey: string, customerKeyMd5: string): EncryptionKey {\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Hides the key bytes from `JSON.stringify`.\n *\n * @returns A redacted shape: same mode and algorithm, but the key and MD5\n * replaced with a placeholder string.\n */\n toJSON(): {\n /** Encryption mode discriminant. */\n mode: 'SSE-C'\n /** Encryption algorithm. */\n algorithm: EncryptionAlgorithm\n /** Always the literal redaction placeholder; the real key never leaves the instance. */\n customerKey: string\n /** Always the literal redaction placeholder; the real MD5 never leaves the instance. */\n customerKeyMd5: string\n } {\n return {\n mode: this.mode,\n algorithm: this.algorithm,\n customerKey: KEY_REDACTED,\n customerKeyMd5: KEY_REDACTED,\n }\n }\n\n /**\n * Hides the key bytes from default `toString()`.\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n toString(): string {\n return `[EncryptionKey SSE-C ${KEY_REDACTED}]`\n }\n\n /**\n * Hides the key bytes from Node's `util.inspect` (and therefore `console.log`).\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n}\n"],"names":[],"mappings":";;;;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