@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,51 @@
|
|
|
1
|
+
import { AuthorizeAccountResponse } from '../types/auth.js';
|
|
2
|
+
import { BucketId } from '../types/ids.js';
|
|
3
|
+
/** A pre-authorized upload URL paired with its authorization token. */
|
|
4
|
+
export interface UploadUrlEntry {
|
|
5
|
+
/** The URL to POST file data to. */
|
|
6
|
+
readonly uploadUrl: string;
|
|
7
|
+
/** Authorization token to include with the upload request. */
|
|
8
|
+
readonly authorizationToken: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Stores B2 authorization state between requests.
|
|
12
|
+
* Implementations cache the authorize-account response and manage
|
|
13
|
+
* pools of reusable upload URLs (checkout/checkin/evict pattern).
|
|
14
|
+
*/
|
|
15
|
+
export interface AccountInfo {
|
|
16
|
+
/** Store a fresh authorization response, replacing any previous state. */
|
|
17
|
+
setAuth(auth: AuthorizeAccountResponse): void;
|
|
18
|
+
/** Return the current authorization response, or null if not authorized. */
|
|
19
|
+
getAuth(): AuthorizeAccountResponse | null;
|
|
20
|
+
/** Discard all cached authorization state and upload URLs. */
|
|
21
|
+
clear(): void;
|
|
22
|
+
/** Base URL for B2 API calls. */
|
|
23
|
+
getApiUrl(): string;
|
|
24
|
+
/** Base URL for file downloads. */
|
|
25
|
+
getDownloadUrl(): string;
|
|
26
|
+
/** Current authorization token. */
|
|
27
|
+
getAuthToken(): string;
|
|
28
|
+
/** The authorized account ID. */
|
|
29
|
+
getAccountId(): string;
|
|
30
|
+
/** Server-recommended part size for large file uploads, in bytes. */
|
|
31
|
+
getRecommendedPartSize(): number;
|
|
32
|
+
/** Smallest allowed part size for large file uploads, in bytes. */
|
|
33
|
+
getAbsoluteMinimumPartSize(): number;
|
|
34
|
+
/** Base URL for the S3-compatible API. */
|
|
35
|
+
getS3ApiUrl(): string;
|
|
36
|
+
/** Bucket ID the key is restricted to, or null if unrestricted. */
|
|
37
|
+
getAllowedBucketId(): BucketId | null;
|
|
38
|
+
/** Take an upload URL from the pool for the given bucket, or null if none available. */
|
|
39
|
+
checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null;
|
|
40
|
+
/** Return a still-valid upload URL to the pool for reuse. */
|
|
41
|
+
returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
42
|
+
/** Remove an upload URL from the pool (e.g. after an upload error). */
|
|
43
|
+
evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
44
|
+
/** Take a large-file part upload URL from the pool, or null if none available. */
|
|
45
|
+
checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null;
|
|
46
|
+
/** Return a still-valid part upload URL to the pool for reuse. */
|
|
47
|
+
returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
48
|
+
/** Remove a part upload URL from the pool after an error. */
|
|
49
|
+
evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=account-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-info.d.ts","sourceRoot":"","sources":["../../src/auth/account-info.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IAC7C,4EAA4E;IAC5E,OAAO,IAAI,wBAAwB,GAAG,IAAI,CAAA;IAC1C,8DAA8D;IAC9D,KAAK,IAAI,IAAI,CAAA;IAEb,iCAAiC;IACjC,SAAS,IAAI,MAAM,CAAA;IACnB,mCAAmC;IACnC,cAAc,IAAI,MAAM,CAAA;IACxB,mCAAmC;IACnC,YAAY,IAAI,MAAM,CAAA;IACtB,iCAAiC;IACjC,YAAY,IAAI,MAAM,CAAA;IACtB,qEAAqE;IACrE,sBAAsB,IAAI,MAAM,CAAA;IAChC,mEAAmE;IACnE,0BAA0B,IAAI,MAAM,CAAA;IACpC,0CAA0C;IAC1C,WAAW,IAAI,MAAM,CAAA;IACrB,mEAAmE;IACnE,kBAAkB,IAAI,QAAQ,GAAG,IAAI,CAAA;IAErC,wFAAwF;IACxF,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,IAAI,CAAA;IAC5D,6DAA6D;IAC7D,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAChE,uEAAuE;IACvE,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAE/D,kFAAkF;IAClF,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAAA;IAC5D,kEAAkE;IAClE,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAChE,6DAA6D;IAC7D,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAChE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AuthorizeAccountResponse } from '../types/auth.js';
|
|
2
|
+
import { BucketId } from '../types/ids.js';
|
|
3
|
+
/** A pre-authorized upload URL paired with its authorization token. */
|
|
4
|
+
export interface UploadUrlEntry {
|
|
5
|
+
/** The URL to POST file data to. */
|
|
6
|
+
readonly uploadUrl: string;
|
|
7
|
+
/** Authorization token to include with the upload request. */
|
|
8
|
+
readonly authorizationToken: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Stores B2 authorization state between requests.
|
|
12
|
+
* Implementations cache the authorize-account response and manage
|
|
13
|
+
* pools of reusable upload URLs (checkout/checkin/evict pattern).
|
|
14
|
+
*/
|
|
15
|
+
export interface AccountInfo {
|
|
16
|
+
/** Store a fresh authorization response, replacing any previous state. */
|
|
17
|
+
setAuth(auth: AuthorizeAccountResponse): void;
|
|
18
|
+
/** Return the current authorization response, or null if not authorized. */
|
|
19
|
+
getAuth(): AuthorizeAccountResponse | null;
|
|
20
|
+
/** Discard all cached authorization state and upload URLs. */
|
|
21
|
+
clear(): void;
|
|
22
|
+
/** Base URL for B2 API calls. */
|
|
23
|
+
getApiUrl(): string;
|
|
24
|
+
/** Base URL for file downloads. */
|
|
25
|
+
getDownloadUrl(): string;
|
|
26
|
+
/** Current authorization token. */
|
|
27
|
+
getAuthToken(): string;
|
|
28
|
+
/** The authorized account ID. */
|
|
29
|
+
getAccountId(): string;
|
|
30
|
+
/** Server-recommended part size for large file uploads, in bytes. */
|
|
31
|
+
getRecommendedPartSize(): number;
|
|
32
|
+
/** Smallest allowed part size for large file uploads, in bytes. */
|
|
33
|
+
getAbsoluteMinimumPartSize(): number;
|
|
34
|
+
/** Base URL for the S3-compatible API. */
|
|
35
|
+
getS3ApiUrl(): string;
|
|
36
|
+
/** Bucket ID the key is restricted to, or null if unrestricted. */
|
|
37
|
+
getAllowedBucketId(): BucketId | null;
|
|
38
|
+
/** Take an upload URL from the pool for the given bucket, or null if none available. */
|
|
39
|
+
checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null;
|
|
40
|
+
/** Return a still-valid upload URL to the pool for reuse. */
|
|
41
|
+
returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
42
|
+
/** Remove an upload URL from the pool (e.g. after an upload error). */
|
|
43
|
+
evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
44
|
+
/** Take a large-file part upload URL from the pool, or null if none available. */
|
|
45
|
+
checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null;
|
|
46
|
+
/** Return a still-valid part upload URL to the pool for reuse. */
|
|
47
|
+
returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
48
|
+
/** Remove a part upload URL from the pool after an error. */
|
|
49
|
+
evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=account-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-info.d.ts","sourceRoot":"","sources":["../../src/auth/account-info.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE/C,uEAAuE;AACvE,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CACpC;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,0EAA0E;IAC1E,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IAC7C,4EAA4E;IAC5E,OAAO,IAAI,wBAAwB,GAAG,IAAI,CAAA;IAC1C,8DAA8D;IAC9D,KAAK,IAAI,IAAI,CAAA;IAEb,iCAAiC;IACjC,SAAS,IAAI,MAAM,CAAA;IACnB,mCAAmC;IACnC,cAAc,IAAI,MAAM,CAAA;IACxB,mCAAmC;IACnC,YAAY,IAAI,MAAM,CAAA;IACtB,iCAAiC;IACjC,YAAY,IAAI,MAAM,CAAA;IACtB,qEAAqE;IACrE,sBAAsB,IAAI,MAAM,CAAA;IAChC,mEAAmE;IACnE,0BAA0B,IAAI,MAAM,CAAA;IACpC,0CAA0C;IAC1C,WAAW,IAAI,MAAM,CAAA;IACrB,mEAAmE;IACnE,kBAAkB,IAAI,QAAQ,GAAG,IAAI,CAAA;IAErC,wFAAwF;IACxF,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,GAAG,IAAI,CAAA;IAC5D,6DAA6D;IAC7D,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAChE,uEAAuE;IACvE,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAE/D,kFAAkF;IAClF,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAAA;IAC5D,kEAAkE;IAClE,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;IAChE,6DAA6D;IAC7D,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;CAChE"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const promises = require("node:fs/promises");
|
|
4
|
+
const node_path = require("node:path");
|
|
5
|
+
const inMemory = require("./in-memory.cjs");
|
|
6
|
+
class FileAccountInfo {
|
|
7
|
+
/**
|
|
8
|
+
* Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is
|
|
9
|
+
* created on the first `setAuth` write; reading it back happens via
|
|
10
|
+
* {@link load}.
|
|
11
|
+
*
|
|
12
|
+
* @param path - Absolute path to the JSON file that backs this account info.
|
|
13
|
+
*/
|
|
14
|
+
constructor(path) {
|
|
15
|
+
this.path = path;
|
|
16
|
+
}
|
|
17
|
+
inner = new inMemory.InMemoryAccountInfo();
|
|
18
|
+
writeQueue = Promise.resolve();
|
|
19
|
+
/**
|
|
20
|
+
* Reads the JSON file at the configured path and populates in-memory state.
|
|
21
|
+
* If the file is missing or contains invalid JSON, leaves state empty and
|
|
22
|
+
* returns silently (a re-auth is expected next).
|
|
23
|
+
*
|
|
24
|
+
* @returns A promise that resolves when load is complete.
|
|
25
|
+
*/
|
|
26
|
+
async load() {
|
|
27
|
+
try {
|
|
28
|
+
const text = await promises.readFile(this.path, "utf8");
|
|
29
|
+
const parsed = JSON.parse(text);
|
|
30
|
+
this.inner.setAuth(parsed);
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Persists the current auth response to the file. Atomically queues writes
|
|
36
|
+
* so concurrent updates serialize.
|
|
37
|
+
*
|
|
38
|
+
* @returns A promise that resolves when the write completes.
|
|
39
|
+
*/
|
|
40
|
+
flush() {
|
|
41
|
+
const auth = this.inner.getAuth();
|
|
42
|
+
const next = this.writeQueue.then(async () => {
|
|
43
|
+
if (auth === null) {
|
|
44
|
+
try {
|
|
45
|
+
await promises.writeFile(this.path, "", "utf8");
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
await promises.mkdir(node_path.dirname(this.path), { recursive: true });
|
|
51
|
+
await promises.writeFile(this.path, JSON.stringify(auth), "utf8");
|
|
52
|
+
});
|
|
53
|
+
this.writeQueue = next.catch(() => {
|
|
54
|
+
});
|
|
55
|
+
return next;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Stores the given authorization response and triggers an async write to disk.
|
|
59
|
+
*
|
|
60
|
+
* @param auth - The authorize-account response to persist.
|
|
61
|
+
*/
|
|
62
|
+
setAuth(auth) {
|
|
63
|
+
this.inner.setAuth(auth);
|
|
64
|
+
void this.flush();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns the currently cached authorization response, or `null` if none.
|
|
68
|
+
*
|
|
69
|
+
* @returns The cached authorization response, or `null` if not authorized.
|
|
70
|
+
*/
|
|
71
|
+
getAuth() {
|
|
72
|
+
return this.inner.getAuth();
|
|
73
|
+
}
|
|
74
|
+
/** Discards in-memory state and clears the on-disk file. */
|
|
75
|
+
clear() {
|
|
76
|
+
this.inner.clear();
|
|
77
|
+
void this.flush();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Returns the cached B2 API URL.
|
|
81
|
+
*
|
|
82
|
+
* @returns The base URL for B2 API calls.
|
|
83
|
+
*/
|
|
84
|
+
getApiUrl() {
|
|
85
|
+
return this.inner.getApiUrl();
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns the cached file-download URL.
|
|
89
|
+
*
|
|
90
|
+
* @returns The base URL for file downloads.
|
|
91
|
+
*/
|
|
92
|
+
getDownloadUrl() {
|
|
93
|
+
return this.inner.getDownloadUrl();
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Returns the cached session authorization token.
|
|
97
|
+
*
|
|
98
|
+
* @returns The current authorization token.
|
|
99
|
+
*/
|
|
100
|
+
getAuthToken() {
|
|
101
|
+
return this.inner.getAuthToken();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the cached account identifier.
|
|
105
|
+
*
|
|
106
|
+
* @returns The authorized account ID.
|
|
107
|
+
*/
|
|
108
|
+
getAccountId() {
|
|
109
|
+
return this.inner.getAccountId();
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the server-recommended part size for multipart uploads.
|
|
113
|
+
*
|
|
114
|
+
* @returns The recommended part size in bytes.
|
|
115
|
+
*/
|
|
116
|
+
getRecommendedPartSize() {
|
|
117
|
+
return this.inner.getRecommendedPartSize();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Returns the server-enforced minimum part size for multipart uploads.
|
|
121
|
+
*
|
|
122
|
+
* @returns The absolute minimum part size in bytes.
|
|
123
|
+
*/
|
|
124
|
+
getAbsoluteMinimumPartSize() {
|
|
125
|
+
return this.inner.getAbsoluteMinimumPartSize();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Returns the cached S3-compatible API URL.
|
|
129
|
+
*
|
|
130
|
+
* @returns The base URL for the S3-compatible API.
|
|
131
|
+
*/
|
|
132
|
+
getS3ApiUrl() {
|
|
133
|
+
return this.inner.getS3ApiUrl();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns the bucket the key is restricted to, if any.
|
|
137
|
+
*
|
|
138
|
+
* @returns The restricted bucket ID, or `null` if the key is unrestricted.
|
|
139
|
+
*/
|
|
140
|
+
getAllowedBucketId() {
|
|
141
|
+
return this.inner.getAllowedBucketId();
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Takes an upload URL from the in-memory pool for the given bucket.
|
|
145
|
+
*
|
|
146
|
+
* @param bucketId - Bucket to check out an upload URL for.
|
|
147
|
+
*
|
|
148
|
+
* @returns A reusable upload URL entry, or `null` if none are pooled.
|
|
149
|
+
*/
|
|
150
|
+
checkoutUploadUrl(bucketId) {
|
|
151
|
+
return this.inner.checkoutUploadUrl(bucketId);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Returns a still-valid upload URL to the pool for reuse.
|
|
155
|
+
*
|
|
156
|
+
* @param bucketId - Bucket the upload URL belongs to.
|
|
157
|
+
* @param entry - Upload URL entry to return.
|
|
158
|
+
*/
|
|
159
|
+
returnUploadUrl(bucketId, entry) {
|
|
160
|
+
this.inner.returnUploadUrl(bucketId, entry);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Removes an upload URL from the pool after an upload error.
|
|
164
|
+
*
|
|
165
|
+
* @param bucketId - Bucket the failed upload URL belongs to.
|
|
166
|
+
* @param entry - Upload URL entry to evict.
|
|
167
|
+
*/
|
|
168
|
+
evictUploadUrl(bucketId, entry) {
|
|
169
|
+
this.inner.evictUploadUrl(bucketId, entry);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Takes a large-file part upload URL from the in-memory pool.
|
|
173
|
+
*
|
|
174
|
+
* @param fileId - Large file to check out a part upload URL for.
|
|
175
|
+
*
|
|
176
|
+
* @returns A reusable part upload URL entry, or `null` if none are pooled.
|
|
177
|
+
*/
|
|
178
|
+
checkoutPartUploadUrl(fileId) {
|
|
179
|
+
return this.inner.checkoutPartUploadUrl(fileId);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Returns a still-valid part upload URL to the pool for reuse.
|
|
183
|
+
*
|
|
184
|
+
* @param fileId - Large file the part upload URL belongs to.
|
|
185
|
+
* @param entry - Part upload URL entry to return.
|
|
186
|
+
*/
|
|
187
|
+
returnPartUploadUrl(fileId, entry) {
|
|
188
|
+
this.inner.returnPartUploadUrl(fileId, entry);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Removes a part upload URL from the pool after an error.
|
|
192
|
+
*
|
|
193
|
+
* @param fileId - Large file the failed part upload URL belongs to.
|
|
194
|
+
* @param entry - Part upload URL entry to evict.
|
|
195
|
+
*/
|
|
196
|
+
evictPartUploadUrl(fileId, entry) {
|
|
197
|
+
this.inner.evictPartUploadUrl(fileId, entry);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Awaits any pending disk writes. Call before process exit to ensure the
|
|
201
|
+
* latest state is persisted.
|
|
202
|
+
*
|
|
203
|
+
* @returns A promise that resolves once all queued writes are flushed.
|
|
204
|
+
*/
|
|
205
|
+
async flushed() {
|
|
206
|
+
await this.writeQueue;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.FileAccountInfo = FileAccountInfo;
|
|
210
|
+
//# sourceMappingURL=file.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.cjs","sources":["../../src/auth/file.ts"],"sourcesContent":["import { mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport type { AuthorizeAccountResponse } from '../types/auth.ts'\nimport type { BucketId } from '../types/ids.ts'\nimport type { AccountInfo, UploadUrlEntry } from './account-info.ts'\nimport { InMemoryAccountInfo } from './in-memory.ts'\n\n/**\n * Node-only {@link AccountInfo} backend that persists the authorization\n * response to a JSON file. Upload URL pools remain in memory because URLs are\n * short-lived and shouldn't be shared across processes.\n *\n * On instantiation, call {@link FileAccountInfo.load} to populate state from\n * disk (or start fresh if the file is missing or corrupt). The authorization\n * response is written back to disk on every {@link setAuth} or {@link clear}\n * call so a process restart can resume without re-authorizing.\n *\n * This module imports `node:fs/promises`; do not load it in browser bundles.\n */\nexport class FileAccountInfo implements AccountInfo {\n private readonly inner = new InMemoryAccountInfo()\n private writeQueue: Promise<void> = Promise.resolve()\n\n /**\n * Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is\n * created on the first `setAuth` write; reading it back happens via\n * {@link load}.\n *\n * @param path - Absolute path to the JSON file that backs this account info.\n */\n constructor(public readonly path: string) {}\n\n /**\n * Reads the JSON file at the configured path and populates in-memory state.\n * If the file is missing or contains invalid JSON, leaves state empty and\n * returns silently (a re-auth is expected next).\n *\n * @returns A promise that resolves when load is complete.\n */\n async load(): Promise<void> {\n try {\n const text = await readFile(this.path, 'utf8')\n const parsed = JSON.parse(text) as AuthorizeAccountResponse\n this.inner.setAuth(parsed)\n } catch {\n // Missing file, invalid JSON, or permission denied: start empty.\n }\n }\n\n /**\n * Persists the current auth response to the file. Atomically queues writes\n * so concurrent updates serialize.\n *\n * @returns A promise that resolves when the write completes.\n */\n private flush(): Promise<void> {\n const auth = this.inner.getAuth()\n const next = this.writeQueue.then(async () => {\n if (auth === null) {\n try {\n await writeFile(this.path, '', 'utf8')\n } catch {\n // Best-effort\n }\n return\n }\n await mkdir(dirname(this.path), { recursive: true })\n await writeFile(this.path, JSON.stringify(auth), 'utf8')\n })\n this.writeQueue = next.catch(() => {})\n return next\n }\n\n /**\n * Stores the given authorization response and triggers an async write to disk.\n *\n * @param auth - The authorize-account response to persist.\n */\n setAuth(auth: AuthorizeAccountResponse): void {\n this.inner.setAuth(auth)\n void this.flush()\n }\n\n /**\n * Returns the currently cached authorization response, or `null` if none.\n *\n * @returns The cached authorization response, or `null` if not authorized.\n */\n getAuth(): AuthorizeAccountResponse | null {\n return this.inner.getAuth()\n }\n\n /** Discards in-memory state and clears the on-disk file. */\n clear(): void {\n this.inner.clear()\n void this.flush()\n }\n\n /**\n * Returns the cached B2 API URL.\n *\n * @returns The base URL for B2 API calls.\n */\n getApiUrl(): string {\n return this.inner.getApiUrl()\n }\n\n /**\n * Returns the cached file-download URL.\n *\n * @returns The base URL for file downloads.\n */\n getDownloadUrl(): string {\n return this.inner.getDownloadUrl()\n }\n\n /**\n * Returns the cached session authorization token.\n *\n * @returns The current authorization token.\n */\n getAuthToken(): string {\n return this.inner.getAuthToken()\n }\n\n /**\n * Returns the cached account identifier.\n *\n * @returns The authorized account ID.\n */\n getAccountId(): string {\n return this.inner.getAccountId()\n }\n\n /**\n * Returns the server-recommended part size for multipart uploads.\n *\n * @returns The recommended part size in bytes.\n */\n getRecommendedPartSize(): number {\n return this.inner.getRecommendedPartSize()\n }\n\n /**\n * Returns the server-enforced minimum part size for multipart uploads.\n *\n * @returns The absolute minimum part size in bytes.\n */\n getAbsoluteMinimumPartSize(): number {\n return this.inner.getAbsoluteMinimumPartSize()\n }\n\n /**\n * Returns the cached S3-compatible API URL.\n *\n * @returns The base URL for the S3-compatible API.\n */\n getS3ApiUrl(): string {\n return this.inner.getS3ApiUrl()\n }\n\n /**\n * Returns the bucket the key is restricted to, if any.\n *\n * @returns The restricted bucket ID, or `null` if the key is unrestricted.\n */\n getAllowedBucketId(): BucketId | null {\n return this.inner.getAllowedBucketId()\n }\n\n /**\n * Takes an upload URL from the in-memory pool for the given bucket.\n *\n * @param bucketId - Bucket to check out an upload URL for.\n *\n * @returns A reusable upload URL entry, or `null` if none are pooled.\n */\n checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null {\n return this.inner.checkoutUploadUrl(bucketId)\n }\n\n /**\n * Returns a still-valid upload URL to the pool for reuse.\n *\n * @param bucketId - Bucket the upload URL belongs to.\n * @param entry - Upload URL entry to return.\n */\n returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.inner.returnUploadUrl(bucketId, entry)\n }\n\n /**\n * Removes an upload URL from the pool after an upload error.\n *\n * @param bucketId - Bucket the failed upload URL belongs to.\n * @param entry - Upload URL entry to evict.\n */\n evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.inner.evictUploadUrl(bucketId, entry)\n }\n\n /**\n * Takes a large-file part upload URL from the in-memory pool.\n *\n * @param fileId - Large file to check out a part upload URL for.\n *\n * @returns A reusable part upload URL entry, or `null` if none are pooled.\n */\n checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null {\n return this.inner.checkoutPartUploadUrl(fileId)\n }\n\n /**\n * Returns a still-valid part upload URL to the pool for reuse.\n *\n * @param fileId - Large file the part upload URL belongs to.\n * @param entry - Part upload URL entry to return.\n */\n returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.inner.returnPartUploadUrl(fileId, entry)\n }\n\n /**\n * Removes a part upload URL from the pool after an error.\n *\n * @param fileId - Large file the failed part upload URL belongs to.\n * @param entry - Part upload URL entry to evict.\n */\n evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.inner.evictPartUploadUrl(fileId, entry)\n }\n\n /**\n * Awaits any pending disk writes. Call before process exit to ensure the\n * latest state is persisted.\n *\n * @returns A promise that resolves once all queued writes are flushed.\n */\n async flushed(): Promise<void> {\n await this.writeQueue\n }\n}\n"],"names":["InMemoryAccountInfo","readFile","writeFile","mkdir","dirname"],"mappings":";;;;;AAmBO,MAAM,gBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,YAA4B,MAAc;AAAd,SAAA,OAAA;AAAA,EAAe;AAAA,EAV1B,QAAQ,IAAIA,SAAAA,oBAAA;AAAA,EACrB,aAA4B,QAAQ,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA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,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAyB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;;"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { AuthorizeAccountResponse } from '../types/auth.js';
|
|
2
|
+
import { BucketId } from '../types/ids.js';
|
|
3
|
+
import { AccountInfo, UploadUrlEntry } from './account-info.js';
|
|
4
|
+
/**
|
|
5
|
+
* Node-only {@link AccountInfo} backend that persists the authorization
|
|
6
|
+
* response to a JSON file. Upload URL pools remain in memory because URLs are
|
|
7
|
+
* short-lived and shouldn't be shared across processes.
|
|
8
|
+
*
|
|
9
|
+
* On instantiation, call {@link FileAccountInfo.load} to populate state from
|
|
10
|
+
* disk (or start fresh if the file is missing or corrupt). The authorization
|
|
11
|
+
* response is written back to disk on every {@link setAuth} or {@link clear}
|
|
12
|
+
* call so a process restart can resume without re-authorizing.
|
|
13
|
+
*
|
|
14
|
+
* This module imports `node:fs/promises`; do not load it in browser bundles.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FileAccountInfo implements AccountInfo {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
private readonly inner;
|
|
19
|
+
private writeQueue;
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is
|
|
22
|
+
* created on the first `setAuth` write; reading it back happens via
|
|
23
|
+
* {@link load}.
|
|
24
|
+
*
|
|
25
|
+
* @param path - Absolute path to the JSON file that backs this account info.
|
|
26
|
+
*/
|
|
27
|
+
constructor(path: string);
|
|
28
|
+
/**
|
|
29
|
+
* Reads the JSON file at the configured path and populates in-memory state.
|
|
30
|
+
* If the file is missing or contains invalid JSON, leaves state empty and
|
|
31
|
+
* returns silently (a re-auth is expected next).
|
|
32
|
+
*
|
|
33
|
+
* @returns A promise that resolves when load is complete.
|
|
34
|
+
*/
|
|
35
|
+
load(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Persists the current auth response to the file. Atomically queues writes
|
|
38
|
+
* so concurrent updates serialize.
|
|
39
|
+
*
|
|
40
|
+
* @returns A promise that resolves when the write completes.
|
|
41
|
+
*/
|
|
42
|
+
private flush;
|
|
43
|
+
/**
|
|
44
|
+
* Stores the given authorization response and triggers an async write to disk.
|
|
45
|
+
*
|
|
46
|
+
* @param auth - The authorize-account response to persist.
|
|
47
|
+
*/
|
|
48
|
+
setAuth(auth: AuthorizeAccountResponse): void;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the currently cached authorization response, or `null` if none.
|
|
51
|
+
*
|
|
52
|
+
* @returns The cached authorization response, or `null` if not authorized.
|
|
53
|
+
*/
|
|
54
|
+
getAuth(): AuthorizeAccountResponse | null;
|
|
55
|
+
/** Discards in-memory state and clears the on-disk file. */
|
|
56
|
+
clear(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the cached B2 API URL.
|
|
59
|
+
*
|
|
60
|
+
* @returns The base URL for B2 API calls.
|
|
61
|
+
*/
|
|
62
|
+
getApiUrl(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the cached file-download URL.
|
|
65
|
+
*
|
|
66
|
+
* @returns The base URL for file downloads.
|
|
67
|
+
*/
|
|
68
|
+
getDownloadUrl(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the cached session authorization token.
|
|
71
|
+
*
|
|
72
|
+
* @returns The current authorization token.
|
|
73
|
+
*/
|
|
74
|
+
getAuthToken(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the cached account identifier.
|
|
77
|
+
*
|
|
78
|
+
* @returns The authorized account ID.
|
|
79
|
+
*/
|
|
80
|
+
getAccountId(): string;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the server-recommended part size for multipart uploads.
|
|
83
|
+
*
|
|
84
|
+
* @returns The recommended part size in bytes.
|
|
85
|
+
*/
|
|
86
|
+
getRecommendedPartSize(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the server-enforced minimum part size for multipart uploads.
|
|
89
|
+
*
|
|
90
|
+
* @returns The absolute minimum part size in bytes.
|
|
91
|
+
*/
|
|
92
|
+
getAbsoluteMinimumPartSize(): number;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the cached S3-compatible API URL.
|
|
95
|
+
*
|
|
96
|
+
* @returns The base URL for the S3-compatible API.
|
|
97
|
+
*/
|
|
98
|
+
getS3ApiUrl(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Returns the bucket the key is restricted to, if any.
|
|
101
|
+
*
|
|
102
|
+
* @returns The restricted bucket ID, or `null` if the key is unrestricted.
|
|
103
|
+
*/
|
|
104
|
+
getAllowedBucketId(): BucketId | null;
|
|
105
|
+
/**
|
|
106
|
+
* Takes an upload URL from the in-memory pool for the given bucket.
|
|
107
|
+
*
|
|
108
|
+
* @param bucketId - Bucket to check out an upload URL for.
|
|
109
|
+
*
|
|
110
|
+
* @returns A reusable upload URL entry, or `null` if none are pooled.
|
|
111
|
+
*/
|
|
112
|
+
checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null;
|
|
113
|
+
/**
|
|
114
|
+
* Returns a still-valid upload URL to the pool for reuse.
|
|
115
|
+
*
|
|
116
|
+
* @param bucketId - Bucket the upload URL belongs to.
|
|
117
|
+
* @param entry - Upload URL entry to return.
|
|
118
|
+
*/
|
|
119
|
+
returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
120
|
+
/**
|
|
121
|
+
* Removes an upload URL from the pool after an upload error.
|
|
122
|
+
*
|
|
123
|
+
* @param bucketId - Bucket the failed upload URL belongs to.
|
|
124
|
+
* @param entry - Upload URL entry to evict.
|
|
125
|
+
*/
|
|
126
|
+
evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
127
|
+
/**
|
|
128
|
+
* Takes a large-file part upload URL from the in-memory pool.
|
|
129
|
+
*
|
|
130
|
+
* @param fileId - Large file to check out a part upload URL for.
|
|
131
|
+
*
|
|
132
|
+
* @returns A reusable part upload URL entry, or `null` if none are pooled.
|
|
133
|
+
*/
|
|
134
|
+
checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null;
|
|
135
|
+
/**
|
|
136
|
+
* Returns a still-valid part upload URL to the pool for reuse.
|
|
137
|
+
*
|
|
138
|
+
* @param fileId - Large file the part upload URL belongs to.
|
|
139
|
+
* @param entry - Part upload URL entry to return.
|
|
140
|
+
*/
|
|
141
|
+
returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
142
|
+
/**
|
|
143
|
+
* Removes a part upload URL from the pool after an error.
|
|
144
|
+
*
|
|
145
|
+
* @param fileId - Large file the failed part upload URL belongs to.
|
|
146
|
+
* @param entry - Part upload URL entry to evict.
|
|
147
|
+
*/
|
|
148
|
+
evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
149
|
+
/**
|
|
150
|
+
* Awaits any pending disk writes. Call before process exit to ensure the
|
|
151
|
+
* latest state is persisted.
|
|
152
|
+
*
|
|
153
|
+
* @returns A promise that resolves once all queued writes are flushed.
|
|
154
|
+
*/
|
|
155
|
+
flushed(): Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/auth/file.js"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGpE;;;;;;;;;;;GAWG;AACH,qBAAa,eAAgB,YAAW,WAAW;aAWrB,IAAI,EAAE,MAAM;IAVxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;IAClD,OAAO,CAAC,UAAU,CAAmC;IAErD;;;;;;OAMG;gBACyB,IAAI,EAAE,MAAM;IAExC;;;;;;OAM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} from '../types/auth.js';
|
|
2
|
+
import { BucketId } from '../types/ids.js';
|
|
3
|
+
import { AccountInfo, UploadUrlEntry } from './account-info.js';
|
|
4
|
+
/**
|
|
5
|
+
* Node-only {@link AccountInfo} backend that persists the authorization
|
|
6
|
+
* response to a JSON file. Upload URL pools remain in memory because URLs are
|
|
7
|
+
* short-lived and shouldn't be shared across processes.
|
|
8
|
+
*
|
|
9
|
+
* On instantiation, call {@link FileAccountInfo.load} to populate state from
|
|
10
|
+
* disk (or start fresh if the file is missing or corrupt). The authorization
|
|
11
|
+
* response is written back to disk on every {@link setAuth} or {@link clear}
|
|
12
|
+
* call so a process restart can resume without re-authorizing.
|
|
13
|
+
*
|
|
14
|
+
* This module imports `node:fs/promises`; do not load it in browser bundles.
|
|
15
|
+
*/
|
|
16
|
+
export declare class FileAccountInfo implements AccountInfo {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
private readonly inner;
|
|
19
|
+
private writeQueue;
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is
|
|
22
|
+
* created on the first `setAuth` write; reading it back happens via
|
|
23
|
+
* {@link load}.
|
|
24
|
+
*
|
|
25
|
+
* @param path - Absolute path to the JSON file that backs this account info.
|
|
26
|
+
*/
|
|
27
|
+
constructor(path: string);
|
|
28
|
+
/**
|
|
29
|
+
* Reads the JSON file at the configured path and populates in-memory state.
|
|
30
|
+
* If the file is missing or contains invalid JSON, leaves state empty and
|
|
31
|
+
* returns silently (a re-auth is expected next).
|
|
32
|
+
*
|
|
33
|
+
* @returns A promise that resolves when load is complete.
|
|
34
|
+
*/
|
|
35
|
+
load(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Persists the current auth response to the file. Atomically queues writes
|
|
38
|
+
* so concurrent updates serialize.
|
|
39
|
+
*
|
|
40
|
+
* @returns A promise that resolves when the write completes.
|
|
41
|
+
*/
|
|
42
|
+
private flush;
|
|
43
|
+
/**
|
|
44
|
+
* Stores the given authorization response and triggers an async write to disk.
|
|
45
|
+
*
|
|
46
|
+
* @param auth - The authorize-account response to persist.
|
|
47
|
+
*/
|
|
48
|
+
setAuth(auth: AuthorizeAccountResponse): void;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the currently cached authorization response, or `null` if none.
|
|
51
|
+
*
|
|
52
|
+
* @returns The cached authorization response, or `null` if not authorized.
|
|
53
|
+
*/
|
|
54
|
+
getAuth(): AuthorizeAccountResponse | null;
|
|
55
|
+
/** Discards in-memory state and clears the on-disk file. */
|
|
56
|
+
clear(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the cached B2 API URL.
|
|
59
|
+
*
|
|
60
|
+
* @returns The base URL for B2 API calls.
|
|
61
|
+
*/
|
|
62
|
+
getApiUrl(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the cached file-download URL.
|
|
65
|
+
*
|
|
66
|
+
* @returns The base URL for file downloads.
|
|
67
|
+
*/
|
|
68
|
+
getDownloadUrl(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the cached session authorization token.
|
|
71
|
+
*
|
|
72
|
+
* @returns The current authorization token.
|
|
73
|
+
*/
|
|
74
|
+
getAuthToken(): string;
|
|
75
|
+
/**
|
|
76
|
+
* Returns the cached account identifier.
|
|
77
|
+
*
|
|
78
|
+
* @returns The authorized account ID.
|
|
79
|
+
*/
|
|
80
|
+
getAccountId(): string;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the server-recommended part size for multipart uploads.
|
|
83
|
+
*
|
|
84
|
+
* @returns The recommended part size in bytes.
|
|
85
|
+
*/
|
|
86
|
+
getRecommendedPartSize(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the server-enforced minimum part size for multipart uploads.
|
|
89
|
+
*
|
|
90
|
+
* @returns The absolute minimum part size in bytes.
|
|
91
|
+
*/
|
|
92
|
+
getAbsoluteMinimumPartSize(): number;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the cached S3-compatible API URL.
|
|
95
|
+
*
|
|
96
|
+
* @returns The base URL for the S3-compatible API.
|
|
97
|
+
*/
|
|
98
|
+
getS3ApiUrl(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Returns the bucket the key is restricted to, if any.
|
|
101
|
+
*
|
|
102
|
+
* @returns The restricted bucket ID, or `null` if the key is unrestricted.
|
|
103
|
+
*/
|
|
104
|
+
getAllowedBucketId(): BucketId | null;
|
|
105
|
+
/**
|
|
106
|
+
* Takes an upload URL from the in-memory pool for the given bucket.
|
|
107
|
+
*
|
|
108
|
+
* @param bucketId - Bucket to check out an upload URL for.
|
|
109
|
+
*
|
|
110
|
+
* @returns A reusable upload URL entry, or `null` if none are pooled.
|
|
111
|
+
*/
|
|
112
|
+
checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null;
|
|
113
|
+
/**
|
|
114
|
+
* Returns a still-valid upload URL to the pool for reuse.
|
|
115
|
+
*
|
|
116
|
+
* @param bucketId - Bucket the upload URL belongs to.
|
|
117
|
+
* @param entry - Upload URL entry to return.
|
|
118
|
+
*/
|
|
119
|
+
returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
120
|
+
/**
|
|
121
|
+
* Removes an upload URL from the pool after an upload error.
|
|
122
|
+
*
|
|
123
|
+
* @param bucketId - Bucket the failed upload URL belongs to.
|
|
124
|
+
* @param entry - Upload URL entry to evict.
|
|
125
|
+
*/
|
|
126
|
+
evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
127
|
+
/**
|
|
128
|
+
* Takes a large-file part upload URL from the in-memory pool.
|
|
129
|
+
*
|
|
130
|
+
* @param fileId - Large file to check out a part upload URL for.
|
|
131
|
+
*
|
|
132
|
+
* @returns A reusable part upload URL entry, or `null` if none are pooled.
|
|
133
|
+
*/
|
|
134
|
+
checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null;
|
|
135
|
+
/**
|
|
136
|
+
* Returns a still-valid part upload URL to the pool for reuse.
|
|
137
|
+
*
|
|
138
|
+
* @param fileId - Large file the part upload URL belongs to.
|
|
139
|
+
* @param entry - Part upload URL entry to return.
|
|
140
|
+
*/
|
|
141
|
+
returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
142
|
+
/**
|
|
143
|
+
* Removes a part upload URL from the pool after an error.
|
|
144
|
+
*
|
|
145
|
+
* @param fileId - Large file the failed part upload URL belongs to.
|
|
146
|
+
* @param entry - Part upload URL entry to evict.
|
|
147
|
+
*/
|
|
148
|
+
evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
149
|
+
/**
|
|
150
|
+
* Awaits any pending disk writes. Call before process exit to ensure the
|
|
151
|
+
* latest state is persisted.
|
|
152
|
+
*
|
|
153
|
+
* @returns A promise that resolves once all queued writes are flushed.
|
|
154
|
+
*/
|
|
155
|
+
flushed(): Promise<void>;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/auth/file.js"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGpE;;;;;;;;;;;GAWG;AACH,qBAAa,eAAgB,YAAW,WAAW;aAWrB,IAAI,EAAE,MAAM;IAVxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;IAClD,OAAO,CAAC,UAAU,CAAmC;IAErD;;;;;;OAMG;gBACyB,IAAI,EAAE,MAAM;IAExC;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAU3B;;;;;OAKG;IACH,OAAO,CAAC,KAAK;IAkBb;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI;IAK7C;;;;OAIG;IACH,OAAO,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