@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,495 @@
|
|
|
1
|
+
import { HttpTransport } from '../http/transport.js';
|
|
2
|
+
import { FileVersion } from '../types/file.js';
|
|
3
|
+
import { EventNotificationRule } from '../types/notifications.js';
|
|
4
|
+
export { BUCKET_INFO_MAX_KEYS, BUCKET_INFO_VALUE_MAX, BUCKET_NAME_MAX, BUCKET_NAME_MIN, FILE_INFO_TOTAL_MAX, FILE_INFO_VALUE_MAX, FILE_NAME_MAX_BYTES, LIST_ENDPOINT_CAPS, } from './validation.js';
|
|
5
|
+
/** JSON response returned by {@link B2Simulator.handleRequest} and {@link B2Simulator.handleUpload}. */
|
|
6
|
+
export interface SimulatorJsonResponse {
|
|
7
|
+
/** HTTP status code. */
|
|
8
|
+
readonly status: number;
|
|
9
|
+
/** JSON response body. */
|
|
10
|
+
readonly body: unknown;
|
|
11
|
+
}
|
|
12
|
+
/** Download response returned by {@link B2Simulator.handleDownload}. */
|
|
13
|
+
export interface SimulatorDownloadResponse {
|
|
14
|
+
/** HTTP status code. */
|
|
15
|
+
readonly status: number;
|
|
16
|
+
/** B2 response headers (content type, SHA-1, file info, etc.). */
|
|
17
|
+
readonly headers: Record<string, string>;
|
|
18
|
+
/** Raw file bytes, or null if the file was not found. */
|
|
19
|
+
readonly data: Uint8Array | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Specification for a synthetic failure to return from the simulator's
|
|
23
|
+
* transport. See {@link B2Simulator.injectFailure}.
|
|
24
|
+
*/
|
|
25
|
+
export interface FaultSpec {
|
|
26
|
+
/**
|
|
27
|
+
* URL substring matched against `request.url`. The fault triggers on
|
|
28
|
+
* every request whose URL contains this substring. Typically a B2
|
|
29
|
+
* endpoint name like `'b2_upload_part'`, `'b2_authorize_account'`,
|
|
30
|
+
* `'b2_download_file_by_id'`, or `'/file/'` for download-by-name.
|
|
31
|
+
*/
|
|
32
|
+
readonly on: string;
|
|
33
|
+
/** HTTP status to return. Defaults to `503`. */
|
|
34
|
+
readonly status?: number;
|
|
35
|
+
/** B2 error code to return in the JSON body. Defaults to `'service_unavailable'`. */
|
|
36
|
+
readonly code?: string;
|
|
37
|
+
/** Human-readable message. Defaults to `'simulated failure'`. */
|
|
38
|
+
readonly message?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Number of matched requests to fail before the fault retires. Defaults
|
|
41
|
+
* to `Number.POSITIVE_INFINITY` (every matched request fails until
|
|
42
|
+
* cleared). Set to e.g. `3` to fail the next 3 matched requests then
|
|
43
|
+
* stop.
|
|
44
|
+
*/
|
|
45
|
+
readonly count?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Number of matched requests to let through before failures start.
|
|
48
|
+
* Defaults to `0` (fail from the first matched request). Set to e.g.
|
|
49
|
+
* `2` to let the first 2 succeed and start failing on the 3rd.
|
|
50
|
+
*/
|
|
51
|
+
readonly skip?: number;
|
|
52
|
+
/**
|
|
53
|
+
* If set, the synthetic response includes a `Retry-After: <n>` header
|
|
54
|
+
* (in seconds). Used to exercise the retry transport's
|
|
55
|
+
* `Retry-After`-respecting backoff path.
|
|
56
|
+
*/
|
|
57
|
+
readonly retryAfter?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Handle returned by {@link B2Simulator.injectFailure} so a specific
|
|
61
|
+
* fault registration can be torn down without affecting other faults.
|
|
62
|
+
*/
|
|
63
|
+
export interface FaultHandle {
|
|
64
|
+
/**
|
|
65
|
+
* Remove this fault registration. Idempotent: calling twice is a no-op.
|
|
66
|
+
* Faults whose `count` budget has already been exhausted retire
|
|
67
|
+
* automatically and do not need to be cleared explicitly.
|
|
68
|
+
*/
|
|
69
|
+
clear(): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for constructing a {@link B2Simulator}.
|
|
73
|
+
*/
|
|
74
|
+
export interface B2SimulatorOptions {
|
|
75
|
+
/**
|
|
76
|
+
* The minimum part size the simulator advertises in `b2_authorize_account`
|
|
77
|
+
* responses (`apiInfo.storageApi.absoluteMinimumPartSize`). Defaults to
|
|
78
|
+
* `5_000_000` to mirror production B2. Lower this in tests that exercise
|
|
79
|
+
* multipart control-flow branches but don't need realistic part sizes,
|
|
80
|
+
* because v8 coverage instrumentation pushes 5 MB+ part hashing past 60 s
|
|
81
|
+
* on the slowest CI runners, which trips vitest's IPC RPC timeout.
|
|
82
|
+
*/
|
|
83
|
+
minimumPartSize?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The recommended part size the simulator advertises in
|
|
86
|
+
* `b2_authorize_account` responses (`apiInfo.storageApi.recommendedPartSize`).
|
|
87
|
+
* Defaults to `100_000_000` to mirror production B2. Lower this when a test
|
|
88
|
+
* needs to exercise the SDK's "use the recommended size when the caller
|
|
89
|
+
* omits `partSize`" default-branch without uploading 100 MB of bytes.
|
|
90
|
+
*/
|
|
91
|
+
recommendedPartSize?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Pluggable hook: invoked after every successful upload, copy, or
|
|
94
|
+
* `finishLargeFile` on a bucket with a matching event-notification
|
|
95
|
+
* rule. Tests can register a hook to assert the SDK's webhook
|
|
96
|
+
* publishing path without spinning up a real HTTP listener.
|
|
97
|
+
*
|
|
98
|
+
* Receives the freshly-stored `FileVersion`, the bucket the upload
|
|
99
|
+
* landed in, and the rule that matched. Returns a promise so async
|
|
100
|
+
* hook implementations are allowed; the simulator never blocks on it
|
|
101
|
+
* (errors thrown from the hook are surfaced via `bestEffort` to
|
|
102
|
+
* avoid masking the underlying API call's success).
|
|
103
|
+
*/
|
|
104
|
+
onWebhookDeliver?: (event: {
|
|
105
|
+
rule: EventNotificationRule;
|
|
106
|
+
fileVersion: FileVersion;
|
|
107
|
+
bucketId: string;
|
|
108
|
+
}) => Promise<void> | void;
|
|
109
|
+
/**
|
|
110
|
+
* Pluggable hook: invoked after every successful upload on a bucket
|
|
111
|
+
* configured as a replication source. Receives the source `FileVersion`
|
|
112
|
+
* and the destination bucket ID. Tests can register a hook to
|
|
113
|
+
* verify replication intent without actually copying bytes inside
|
|
114
|
+
* the simulator.
|
|
115
|
+
*/
|
|
116
|
+
onReplicate?: (event: {
|
|
117
|
+
sourceFileVersion: FileVersion;
|
|
118
|
+
sourceBucketId: string;
|
|
119
|
+
destinationBucketId: string;
|
|
120
|
+
}) => Promise<void> | void;
|
|
121
|
+
/**
|
|
122
|
+
* Diagnostic hook: invoked with any error thrown or rejected by
|
|
123
|
+
* `onWebhookDeliver` / `onReplicate`. Without this, errors thrown by
|
|
124
|
+
* user-supplied hooks are silently swallowed (intentional: a buggy
|
|
125
|
+
* hook must not corrupt an otherwise-successful upload), which makes
|
|
126
|
+
* test debugging hard when a hook quietly stops firing. Register
|
|
127
|
+
* `onHookError` to surface what would otherwise be invisible.
|
|
128
|
+
*/
|
|
129
|
+
onHookError?: (event: {
|
|
130
|
+
kind: 'webhook' | 'replication';
|
|
131
|
+
error: Error;
|
|
132
|
+
}) => void;
|
|
133
|
+
/**
|
|
134
|
+
* When `true`, the simulator enforces application-key capability
|
|
135
|
+
* checks, bucket scoping, prefix scoping, and auth-token expiry on
|
|
136
|
+
* every request. The default `false` keeps the simulator permissive
|
|
137
|
+
* (matching its long-standing behaviour) so the existing test suite
|
|
138
|
+
* doesn't have to set up keys with the right capabilities.
|
|
139
|
+
*
|
|
140
|
+
* In strict mode:
|
|
141
|
+
*
|
|
142
|
+
* - Unknown auth tokens return HTTP 401 with code `bad_auth_token`.
|
|
143
|
+
* - Expired tokens (per {@link B2Simulator.advanceTime}) return HTTP 401 with code `expired_auth_token`.
|
|
144
|
+
* - Calls without the required capability for the endpoint return HTTP 403 `unauthorized`.
|
|
145
|
+
* - Calls outside the key's bucketId / namePrefix scope return HTTP 403 `unauthorized`.
|
|
146
|
+
*
|
|
147
|
+
* Each test can opt in: `new B2Simulator({ strictAuth: true })`.
|
|
148
|
+
*/
|
|
149
|
+
strictAuth?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* How long auth tokens issued via `b2_authorize_account` are valid
|
|
152
|
+
* for, in milliseconds. Defaults to 24 hours (real B2). Tests that
|
|
153
|
+
* want to exercise the 401/reauth retry path can lower this so a
|
|
154
|
+
* single call to {@link B2Simulator.advanceTime} expires the token.
|
|
155
|
+
*/
|
|
156
|
+
authTokenTtlMs?: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* In-memory B2 simulator for testing. Implements the B2 native API at the
|
|
160
|
+
* request/response level without any network I/O. Supports 25+ operations
|
|
161
|
+
* including buckets, files, large files, keys, and notifications.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const sim = new B2Simulator()
|
|
166
|
+
* const client = new B2Client({
|
|
167
|
+
* applicationKeyId: 'test-key-id',
|
|
168
|
+
* applicationKey: 'test-key',
|
|
169
|
+
* transport: sim.transport(),
|
|
170
|
+
* })
|
|
171
|
+
* await client.authorize()
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export declare class B2Simulator {
|
|
175
|
+
private readonly buckets;
|
|
176
|
+
private readonly accountId;
|
|
177
|
+
private readonly largeFiles;
|
|
178
|
+
private readonly keys;
|
|
179
|
+
private readonly notificationRules;
|
|
180
|
+
private readonly minimumPartSize;
|
|
181
|
+
private readonly recommendedPartSize;
|
|
182
|
+
private readonly faults;
|
|
183
|
+
private nextFaultId;
|
|
184
|
+
private readonly onWebhookDeliver?;
|
|
185
|
+
private readonly onReplicate?;
|
|
186
|
+
private readonly onHookError?;
|
|
187
|
+
private readonly strictAuth;
|
|
188
|
+
private readonly authTokenTtlMs;
|
|
189
|
+
/**
|
|
190
|
+
* Issued auth tokens with their associated grant scope + expiry. In
|
|
191
|
+
* permissive mode (`strictAuth: false`) this is still populated by
|
|
192
|
+
* `authorize` but never consulted on subsequent requests. In strict
|
|
193
|
+
* mode each request looks up its `Authorization` header here.
|
|
194
|
+
*/
|
|
195
|
+
private readonly issuedTokens;
|
|
196
|
+
/**
|
|
197
|
+
* Virtual-clock offset applied to `Date.now()` for expiry checks.
|
|
198
|
+
* Defaults to 0. Tests advance via {@link advanceTime} to fast-forward
|
|
199
|
+
* past auth-token expiry without sleeping.
|
|
200
|
+
*/
|
|
201
|
+
private clockOffsetMs;
|
|
202
|
+
/**
|
|
203
|
+
* Per-instance monotonic counter used to mint realistic-looking
|
|
204
|
+
* IDs (`b2_bucket_<24-hex>`, `4_z<24-hex>`, etc.) and auth tokens.
|
|
205
|
+
* Module-global previously, which leaked state across `B2Simulator`
|
|
206
|
+
* instances in the same Vitest worker — concurrent tests could see
|
|
207
|
+
* colliding tokens. Per-instance ensures determinism within a single
|
|
208
|
+
* simulator's lifetime.
|
|
209
|
+
*/
|
|
210
|
+
private nextId;
|
|
211
|
+
/**
|
|
212
|
+
* Last-issued upload timestamp. The simulator enforces strict
|
|
213
|
+
* monotonicity so version ordering is deterministic for tests; if
|
|
214
|
+
* two writes hit the same `Date.now()` millisecond, the second
|
|
215
|
+
* receives `lastTimestamp + 1`.
|
|
216
|
+
*/
|
|
217
|
+
private lastTimestamp;
|
|
218
|
+
/**
|
|
219
|
+
* Outstanding fire-and-forget hook invocations. Tracked so tests
|
|
220
|
+
* (and future {@link flushHooks} callers) can wait for every
|
|
221
|
+
* dispatched `onWebhookDeliver` / `onReplicate` callback to settle
|
|
222
|
+
* before asserting against observable side effects. The microtask
|
|
223
|
+
* dance in fidelity tests was previously brittle: positive cases
|
|
224
|
+
* flushed twice, negative cases flushed once, and any addition to
|
|
225
|
+
* the hook dispatch chain quietly broke the negative path.
|
|
226
|
+
*/
|
|
227
|
+
private readonly pendingHooks;
|
|
228
|
+
/**
|
|
229
|
+
* Constructs a new in-memory B2 simulator.
|
|
230
|
+
* @param options - Optional simulator overrides. See {@link B2SimulatorOptions}.
|
|
231
|
+
*/
|
|
232
|
+
constructor(options?: B2SimulatorOptions);
|
|
233
|
+
/**
|
|
234
|
+
* Advance the simulator's virtual clock by `ms` milliseconds. Used in
|
|
235
|
+
* conjunction with `strictAuth: true` + a finite `authTokenTtlMs` to
|
|
236
|
+
* force token expiry without `setTimeout`-based delays.
|
|
237
|
+
*
|
|
238
|
+
* @param ms - Milliseconds to advance. Negative values rewind (rarely useful).
|
|
239
|
+
*/
|
|
240
|
+
advanceTime(ms: number): void;
|
|
241
|
+
/**
|
|
242
|
+
* Current simulator time. Equal to `Date.now() + clockOffsetMs`.
|
|
243
|
+
*
|
|
244
|
+
* @returns Unix milliseconds.
|
|
245
|
+
*/
|
|
246
|
+
private now;
|
|
247
|
+
/**
|
|
248
|
+
* Generate a deterministic-but-realistic-looking B2 identifier of the
|
|
249
|
+
* shape `<prefix>_<24-hex-counter>`, which approximates the visual
|
|
250
|
+
* width of real B2 wire IDs. The counter is monotonic per instance
|
|
251
|
+
* so test fixtures are deterministic across runs of the same
|
|
252
|
+
* simulator.
|
|
253
|
+
*
|
|
254
|
+
* @param prefix - B2-style prefix (`'b2_bucket'`, `'4_z'`, etc.).
|
|
255
|
+
*
|
|
256
|
+
* @returns A simulator-issued identifier that looks like a B2 wire ID.
|
|
257
|
+
*/
|
|
258
|
+
private genId;
|
|
259
|
+
/**
|
|
260
|
+
* Return a strictly-increasing upload timestamp, even when multiple
|
|
261
|
+
* writes land in the same `Date.now()` millisecond. Tests rely on
|
|
262
|
+
* `uploadTimestamp` ordering to discriminate file versions; ties from
|
|
263
|
+
* coarse system-clock resolution would otherwise make version
|
|
264
|
+
* selection nondeterministic.
|
|
265
|
+
*
|
|
266
|
+
* @returns Unix milliseconds.
|
|
267
|
+
*/
|
|
268
|
+
private monotonicTimestamp;
|
|
269
|
+
/**
|
|
270
|
+
* Wait for every fire-and-forget hook (`onWebhookDeliver`,
|
|
271
|
+
* `onReplicate`) currently in flight to settle. Use in tests after
|
|
272
|
+
* an upload/copy/finish-large-file call to deterministically observe
|
|
273
|
+
* hook side effects without microtask-flush guesswork.
|
|
274
|
+
*
|
|
275
|
+
* @returns A promise that resolves once every pending hook callback
|
|
276
|
+
* has either resolved or rejected.
|
|
277
|
+
*/
|
|
278
|
+
flushHooks(): Promise<void>;
|
|
279
|
+
/**
|
|
280
|
+
* Authorize a request against the strict-auth bookkeeping. Returns
|
|
281
|
+
* a `SimulatorJsonResponse` error on failure or `null` on success.
|
|
282
|
+
* Only consulted when `strictAuth: true`.
|
|
283
|
+
*
|
|
284
|
+
* @param authToken - The `Authorization` header value from the request.
|
|
285
|
+
* @param endpoint - B2 endpoint name being invoked.
|
|
286
|
+
* @param bucketId - Optional bucket ID the request operates on, for scope check.
|
|
287
|
+
* @param fileName - Optional file name the request operates on, for prefix check.
|
|
288
|
+
*
|
|
289
|
+
* @returns `null` when the request is authorized, otherwise a 401/403 response.
|
|
290
|
+
*/
|
|
291
|
+
private authorizeRequest;
|
|
292
|
+
/**
|
|
293
|
+
* Look up the application key matching the `Authorization` header on
|
|
294
|
+
* an `authorize_account` request. The header is in the form
|
|
295
|
+
* `Basic base64(applicationKeyId:applicationKey)`.
|
|
296
|
+
*
|
|
297
|
+
* Returns `null` for the implicit master credential (anything that
|
|
298
|
+
* does not match a key minted via `b2_create_key`); in that case
|
|
299
|
+
* `authorize` grants the full master capability set.
|
|
300
|
+
*
|
|
301
|
+
* @param authzHeader - Raw HTTP `Authorization` header value.
|
|
302
|
+
*
|
|
303
|
+
* @returns The matching key's grant scope, or `null` for the master.
|
|
304
|
+
*/
|
|
305
|
+
private findKeyForAuthHeader;
|
|
306
|
+
/**
|
|
307
|
+
* Creates an {@link HttpTransport} that routes requests to this simulator.
|
|
308
|
+
* @returns A transport instance backed by this in-memory simulator.
|
|
309
|
+
*/
|
|
310
|
+
transport(): HttpTransport;
|
|
311
|
+
/**
|
|
312
|
+
* Register a synthetic failure to inject on requests whose URL contains
|
|
313
|
+
* `spec.on`. Use this to exercise retry / backoff / error-handling
|
|
314
|
+
* paths in tests without hand-rolling a wrapping `HttpTransport`. The
|
|
315
|
+
* fault is consumed in registration order on each matched request;
|
|
316
|
+
* once its `count` budget is exhausted it auto-retires.
|
|
317
|
+
*
|
|
318
|
+
* Faults are checked BEFORE the simulator's real handlers run, so a
|
|
319
|
+
* matched request never touches in-memory state — failed uploads
|
|
320
|
+
* don't create partial parts, failed deletes don't remove anything.
|
|
321
|
+
*
|
|
322
|
+
* @param spec - The failure to inject. See {@link FaultSpec}.
|
|
323
|
+
*
|
|
324
|
+
* @returns A handle whose `clear()` method removes this specific
|
|
325
|
+
* fault registration (other faults remain in effect).
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* // Fail the next 2 b2_upload_part calls with 503, then succeed.
|
|
330
|
+
* sim.injectFailure({ on: 'b2_upload_part', status: 503, count: 2 })
|
|
331
|
+
*
|
|
332
|
+
* // Fail every b2_authorize_account with 401 + Retry-After: 5.
|
|
333
|
+
* const handle = sim.injectFailure({
|
|
334
|
+
* on: 'b2_authorize_account',
|
|
335
|
+
* status: 401,
|
|
336
|
+
* code: 'expired_auth_token',
|
|
337
|
+
* retryAfter: 5,
|
|
338
|
+
* })
|
|
339
|
+
* // ... later
|
|
340
|
+
* handle.clear()
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
injectFailure(spec: FaultSpec): FaultHandle;
|
|
344
|
+
/**
|
|
345
|
+
* Remove every registered fault. Equivalent to calling `.clear()` on
|
|
346
|
+
* every handle returned by {@link injectFailure}, plus a defensive
|
|
347
|
+
* reset for tests that re-use a simulator across cases.
|
|
348
|
+
*/
|
|
349
|
+
clearFaults(): void;
|
|
350
|
+
/**
|
|
351
|
+
* Internal: checks the registered faults for a match on the given URL
|
|
352
|
+
* and consumes one if it should fire. Called from
|
|
353
|
+
* {@link SimulatorTransport.send} before any real handler runs.
|
|
354
|
+
*
|
|
355
|
+
* @param url - The request URL to match against each fault's `on`
|
|
356
|
+
* substring.
|
|
357
|
+
*
|
|
358
|
+
* @returns The fault to apply, or `null` if no fault should fire.
|
|
359
|
+
*
|
|
360
|
+
* @internal
|
|
361
|
+
*/
|
|
362
|
+
consumeMatchingFault(url: string): FaultSpec | null;
|
|
363
|
+
/**
|
|
364
|
+
* Dispatches a JSON API request to the appropriate handler.
|
|
365
|
+
* @param _method - The HTTP method (unused).
|
|
366
|
+
* @param path - The request URL path containing the B2 endpoint name.
|
|
367
|
+
* @param headers - The HTTP request headers; consulted by the
|
|
368
|
+
* strict-auth gate to look up the issued auth token.
|
|
369
|
+
* @param body - The parsed JSON request body.
|
|
370
|
+
*
|
|
371
|
+
* @returns An object with HTTP status and JSON response body.
|
|
372
|
+
*/
|
|
373
|
+
handleRequest(_method: string, path: string, headers: Record<string, string>, body: unknown): Promise<SimulatorJsonResponse>;
|
|
374
|
+
/**
|
|
375
|
+
* Handles file and part upload requests (`b2_upload_file`, `b2_upload_part`).
|
|
376
|
+
* Dispatches to the appropriate internal handler based on the URL.
|
|
377
|
+
* @param url - The upload endpoint URL used to determine the upload type.
|
|
378
|
+
* @param headers - The HTTP headers containing file metadata and authorization.
|
|
379
|
+
* @param data - The raw file or part content as bytes.
|
|
380
|
+
*
|
|
381
|
+
* @returns An object with HTTP status and JSON response body.
|
|
382
|
+
*/
|
|
383
|
+
handleUpload(url: string, headers: Record<string, string>, data: Uint8Array): SimulatorJsonResponse;
|
|
384
|
+
/**
|
|
385
|
+
* Handles file download requests (`b2_download_file_by_id`, `/file/` by name).
|
|
386
|
+
* Returns the file data along with B2 response headers.
|
|
387
|
+
* @param path - The request URL path identifying the file to download.
|
|
388
|
+
* @param headers - The HTTP request headers for range or authorization.
|
|
389
|
+
* @param method - The HTTP method; `'HEAD'` suppresses the response body.
|
|
390
|
+
*
|
|
391
|
+
* @returns The download response containing file data and B2 headers.
|
|
392
|
+
*/
|
|
393
|
+
handleDownload(path: string, headers: Record<string, string>, method?: 'GET' | 'HEAD'): SimulatorDownloadResponse;
|
|
394
|
+
/**
|
|
395
|
+
* Convert a synthetic JSON error body into a `SimulatorDownloadResponse`
|
|
396
|
+
* shape so the strict-auth gate on download paths can surface 401/403s
|
|
397
|
+
* through the same transport plumbing as a regular failed download.
|
|
398
|
+
*
|
|
399
|
+
* @param json - The JSON error from {@link authorizeRequest}.
|
|
400
|
+
*
|
|
401
|
+
* @returns A download-shaped response with the error body bytes inline.
|
|
402
|
+
*/
|
|
403
|
+
private errorAsDownload;
|
|
404
|
+
/**
|
|
405
|
+
* Applies HEAD-method body suppression and `b2Content*` response-header
|
|
406
|
+
* overrides parsed from the download URL's query string. Mirrors what the
|
|
407
|
+
* real B2 service does: any `b2Content*` query parameter is echoed back as
|
|
408
|
+
* the corresponding response header.
|
|
409
|
+
*
|
|
410
|
+
* @param response - The download response produced by {@link downloadById} or {@link downloadByName}.
|
|
411
|
+
* @param url - The parsed download URL (used to read `b2Content*` query params).
|
|
412
|
+
* @param method - The HTTP method of the originating request.
|
|
413
|
+
*
|
|
414
|
+
* @returns The response with overrides applied.
|
|
415
|
+
*/
|
|
416
|
+
private finalizeDownload;
|
|
417
|
+
private handleUploadFile;
|
|
418
|
+
private handleUploadPart;
|
|
419
|
+
private downloadById;
|
|
420
|
+
private downloadByName;
|
|
421
|
+
private serveFile;
|
|
422
|
+
private authorize;
|
|
423
|
+
private createBucket;
|
|
424
|
+
private listBuckets;
|
|
425
|
+
private deleteBucket;
|
|
426
|
+
private updateBucket;
|
|
427
|
+
private getUploadUrl;
|
|
428
|
+
private listFileNames;
|
|
429
|
+
private listFileVersions;
|
|
430
|
+
private getFileInfo;
|
|
431
|
+
private hideFile;
|
|
432
|
+
private deleteFileVersion;
|
|
433
|
+
private copyFile;
|
|
434
|
+
private startLargeFile;
|
|
435
|
+
private getUploadPartUrl;
|
|
436
|
+
private finishLargeFile;
|
|
437
|
+
private cancelLargeFile;
|
|
438
|
+
private listUnfinishedLargeFiles;
|
|
439
|
+
private listParts;
|
|
440
|
+
private copyPart;
|
|
441
|
+
private getDownloadAuthorization;
|
|
442
|
+
private createKey;
|
|
443
|
+
private listKeys;
|
|
444
|
+
private deleteKey;
|
|
445
|
+
private updateFileRetention;
|
|
446
|
+
private updateFileLegalHold;
|
|
447
|
+
private getBucketNotificationRules;
|
|
448
|
+
private setBucketNotificationRules;
|
|
449
|
+
/**
|
|
450
|
+
* Locates a stored file version by its `fileId`, scanning every bucket.
|
|
451
|
+
*
|
|
452
|
+
* Returns enough context to support read-only inspection (`stored`,
|
|
453
|
+
* `bucketId`) AND in-place mutation (`versions`, `index`) so callers
|
|
454
|
+
* that need to splice the version out can do so without re-scanning.
|
|
455
|
+
*
|
|
456
|
+
* Real B2 fileIds embed the bucketId, so production lookups are O(1);
|
|
457
|
+
* the simulator's flat ID generator (`this.genId('4_z')`) doesn't, so this
|
|
458
|
+
* is O(buckets × files × versions). Acceptable for tests.
|
|
459
|
+
*
|
|
460
|
+
* @param fileId - The file version ID to locate.
|
|
461
|
+
*
|
|
462
|
+
* @returns The location of the matching version, or `null` if not found.
|
|
463
|
+
*/
|
|
464
|
+
private findFile;
|
|
465
|
+
private makeFileVersion;
|
|
466
|
+
private error;
|
|
467
|
+
/**
|
|
468
|
+
* Fire the pluggable post-upload hooks for a file that just landed in
|
|
469
|
+
* a bucket: matching event-notification rules → `onWebhookDeliver`,
|
|
470
|
+
* configured replication source rules → `onReplicate`. Errors thrown
|
|
471
|
+
* from user-supplied hooks are swallowed so a buggy listener never
|
|
472
|
+
* masks an otherwise-successful API response.
|
|
473
|
+
*
|
|
474
|
+
* Fired-and-forgotten (no await) by the handler so the synthetic
|
|
475
|
+
* response is returned to the caller as fast as production B2 would
|
|
476
|
+
* acknowledge the write.
|
|
477
|
+
*
|
|
478
|
+
* @param fileVersion - The freshly-stored file metadata.
|
|
479
|
+
* @param bucketId - The bucket the upload landed in.
|
|
480
|
+
* @param eventType - The B2 event-type tag (e.g. `'b2:ObjectCreated:Upload'`)
|
|
481
|
+
* used to match against `EventNotificationRule.eventTypes` globs.
|
|
482
|
+
*/
|
|
483
|
+
private firePostUploadHooks;
|
|
484
|
+
/**
|
|
485
|
+
* Schedule a user-supplied hook callback. Errors are routed to
|
|
486
|
+
* `onHookError` if configured, swallowed otherwise. The returned
|
|
487
|
+
* promise is tracked in {@link pendingHooks} so `flushHooks()` can
|
|
488
|
+
* wait for every dispatched hook to settle.
|
|
489
|
+
*
|
|
490
|
+
* @param kind - Which hook this is (`'webhook'` or `'replication'`).
|
|
491
|
+
* @param fn - Thunk that performs the hook invocation.
|
|
492
|
+
*/
|
|
493
|
+
private dispatchHook;
|
|
494
|
+
}
|
|
495
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simulator/index.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAA6B,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAKpF,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAS/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAwGtE,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iBAAiB,CAAA;AAgCxB,wGAAwG;AACxG,MAAM,WAAW,qBAAqB;IACpC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,wEAAwE;AACxE,MAAM,WAAW,yBAAyB;IACxC,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;CACjC;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;;;OAKG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