@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,210 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { InMemoryAccountInfo } from "./in-memory.js";
|
|
4
|
+
class FileAccountInfo {
|
|
5
|
+
/**
|
|
6
|
+
* Constructs a `FileAccountInfo` bound to a JSON file on disk. The file is
|
|
7
|
+
* created on the first `setAuth` write; reading it back happens via
|
|
8
|
+
* {@link load}.
|
|
9
|
+
*
|
|
10
|
+
* @param path - Absolute path to the JSON file that backs this account info.
|
|
11
|
+
*/
|
|
12
|
+
constructor(path) {
|
|
13
|
+
this.path = path;
|
|
14
|
+
}
|
|
15
|
+
inner = new InMemoryAccountInfo();
|
|
16
|
+
writeQueue = Promise.resolve();
|
|
17
|
+
/**
|
|
18
|
+
* Reads the JSON file at the configured path and populates in-memory state.
|
|
19
|
+
* If the file is missing or contains invalid JSON, leaves state empty and
|
|
20
|
+
* returns silently (a re-auth is expected next).
|
|
21
|
+
*
|
|
22
|
+
* @returns A promise that resolves when load is complete.
|
|
23
|
+
*/
|
|
24
|
+
async load() {
|
|
25
|
+
try {
|
|
26
|
+
const text = await readFile(this.path, "utf8");
|
|
27
|
+
const parsed = JSON.parse(text);
|
|
28
|
+
this.inner.setAuth(parsed);
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Persists the current auth response to the file. Atomically queues writes
|
|
34
|
+
* so concurrent updates serialize.
|
|
35
|
+
*
|
|
36
|
+
* @returns A promise that resolves when the write completes.
|
|
37
|
+
*/
|
|
38
|
+
flush() {
|
|
39
|
+
const auth = this.inner.getAuth();
|
|
40
|
+
const next = this.writeQueue.then(async () => {
|
|
41
|
+
if (auth === null) {
|
|
42
|
+
try {
|
|
43
|
+
await writeFile(this.path, "", "utf8");
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
await mkdir(dirname(this.path), { recursive: true });
|
|
49
|
+
await writeFile(this.path, JSON.stringify(auth), "utf8");
|
|
50
|
+
});
|
|
51
|
+
this.writeQueue = next.catch(() => {
|
|
52
|
+
});
|
|
53
|
+
return next;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Stores the given authorization response and triggers an async write to disk.
|
|
57
|
+
*
|
|
58
|
+
* @param auth - The authorize-account response to persist.
|
|
59
|
+
*/
|
|
60
|
+
setAuth(auth) {
|
|
61
|
+
this.inner.setAuth(auth);
|
|
62
|
+
void this.flush();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the currently cached authorization response, or `null` if none.
|
|
66
|
+
*
|
|
67
|
+
* @returns The cached authorization response, or `null` if not authorized.
|
|
68
|
+
*/
|
|
69
|
+
getAuth() {
|
|
70
|
+
return this.inner.getAuth();
|
|
71
|
+
}
|
|
72
|
+
/** Discards in-memory state and clears the on-disk file. */
|
|
73
|
+
clear() {
|
|
74
|
+
this.inner.clear();
|
|
75
|
+
void this.flush();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns the cached B2 API URL.
|
|
79
|
+
*
|
|
80
|
+
* @returns The base URL for B2 API calls.
|
|
81
|
+
*/
|
|
82
|
+
getApiUrl() {
|
|
83
|
+
return this.inner.getApiUrl();
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns the cached file-download URL.
|
|
87
|
+
*
|
|
88
|
+
* @returns The base URL for file downloads.
|
|
89
|
+
*/
|
|
90
|
+
getDownloadUrl() {
|
|
91
|
+
return this.inner.getDownloadUrl();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Returns the cached session authorization token.
|
|
95
|
+
*
|
|
96
|
+
* @returns The current authorization token.
|
|
97
|
+
*/
|
|
98
|
+
getAuthToken() {
|
|
99
|
+
return this.inner.getAuthToken();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Returns the cached account identifier.
|
|
103
|
+
*
|
|
104
|
+
* @returns The authorized account ID.
|
|
105
|
+
*/
|
|
106
|
+
getAccountId() {
|
|
107
|
+
return this.inner.getAccountId();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the server-recommended part size for multipart uploads.
|
|
111
|
+
*
|
|
112
|
+
* @returns The recommended part size in bytes.
|
|
113
|
+
*/
|
|
114
|
+
getRecommendedPartSize() {
|
|
115
|
+
return this.inner.getRecommendedPartSize();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the server-enforced minimum part size for multipart uploads.
|
|
119
|
+
*
|
|
120
|
+
* @returns The absolute minimum part size in bytes.
|
|
121
|
+
*/
|
|
122
|
+
getAbsoluteMinimumPartSize() {
|
|
123
|
+
return this.inner.getAbsoluteMinimumPartSize();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Returns the cached S3-compatible API URL.
|
|
127
|
+
*
|
|
128
|
+
* @returns The base URL for the S3-compatible API.
|
|
129
|
+
*/
|
|
130
|
+
getS3ApiUrl() {
|
|
131
|
+
return this.inner.getS3ApiUrl();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Returns the bucket the key is restricted to, if any.
|
|
135
|
+
*
|
|
136
|
+
* @returns The restricted bucket ID, or `null` if the key is unrestricted.
|
|
137
|
+
*/
|
|
138
|
+
getAllowedBucketId() {
|
|
139
|
+
return this.inner.getAllowedBucketId();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Takes an upload URL from the in-memory pool for the given bucket.
|
|
143
|
+
*
|
|
144
|
+
* @param bucketId - Bucket to check out an upload URL for.
|
|
145
|
+
*
|
|
146
|
+
* @returns A reusable upload URL entry, or `null` if none are pooled.
|
|
147
|
+
*/
|
|
148
|
+
checkoutUploadUrl(bucketId) {
|
|
149
|
+
return this.inner.checkoutUploadUrl(bucketId);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Returns a still-valid upload URL to the pool for reuse.
|
|
153
|
+
*
|
|
154
|
+
* @param bucketId - Bucket the upload URL belongs to.
|
|
155
|
+
* @param entry - Upload URL entry to return.
|
|
156
|
+
*/
|
|
157
|
+
returnUploadUrl(bucketId, entry) {
|
|
158
|
+
this.inner.returnUploadUrl(bucketId, entry);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Removes an upload URL from the pool after an upload error.
|
|
162
|
+
*
|
|
163
|
+
* @param bucketId - Bucket the failed upload URL belongs to.
|
|
164
|
+
* @param entry - Upload URL entry to evict.
|
|
165
|
+
*/
|
|
166
|
+
evictUploadUrl(bucketId, entry) {
|
|
167
|
+
this.inner.evictUploadUrl(bucketId, entry);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Takes a large-file part upload URL from the in-memory pool.
|
|
171
|
+
*
|
|
172
|
+
* @param fileId - Large file to check out a part upload URL for.
|
|
173
|
+
*
|
|
174
|
+
* @returns A reusable part upload URL entry, or `null` if none are pooled.
|
|
175
|
+
*/
|
|
176
|
+
checkoutPartUploadUrl(fileId) {
|
|
177
|
+
return this.inner.checkoutPartUploadUrl(fileId);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Returns a still-valid part upload URL to the pool for reuse.
|
|
181
|
+
*
|
|
182
|
+
* @param fileId - Large file the part upload URL belongs to.
|
|
183
|
+
* @param entry - Part upload URL entry to return.
|
|
184
|
+
*/
|
|
185
|
+
returnPartUploadUrl(fileId, entry) {
|
|
186
|
+
this.inner.returnPartUploadUrl(fileId, entry);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Removes a part upload URL from the pool after an error.
|
|
190
|
+
*
|
|
191
|
+
* @param fileId - Large file the failed part upload URL belongs to.
|
|
192
|
+
* @param entry - Part upload URL entry to evict.
|
|
193
|
+
*/
|
|
194
|
+
evictPartUploadUrl(fileId, entry) {
|
|
195
|
+
this.inner.evictPartUploadUrl(fileId, entry);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Awaits any pending disk writes. Call before process exit to ensure the
|
|
199
|
+
* latest state is persisted.
|
|
200
|
+
*
|
|
201
|
+
* @returns A promise that resolves once all queued writes are flushed.
|
|
202
|
+
*/
|
|
203
|
+
async flushed() {
|
|
204
|
+
await this.writeQueue;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export {
|
|
208
|
+
FileAccountInfo
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","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":[],"mappings":";;;AAmBO,MAAM,gBAAuC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWlD,YAA4B,MAAc;AAAd,SAAA,OAAA;AAAA,EAAe;AAAA,EAV1B,QAAQ,IAAI,oBAAA;AAAA,EACrB,aAA4B,QAAQ,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAkB5C,MAAM,OAAsB;AAC1B,QAAI;AACF,YAAM,OAAO,MAAM,SAAS,KAAK,MAAM,MAAM;AAC7C,YAAM,SAAS,KAAK,MAAM,IAAI;AAC9B,WAAK,MAAM,QAAQ,MAAM;AAAA,IAC3B,QAAQ;AAAA,IAER;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,QAAuB;AAC7B,UAAM,OAAO,KAAK,MAAM,QAAA;AACxB,UAAM,OAAO,KAAK,WAAW,KAAK,YAAY;AAC5C,UAAI,SAAS,MAAM;AACjB,YAAI;AACF,gBAAM,UAAU,KAAK,MAAM,IAAI,MAAM;AAAA,QACvC,QAAQ;AAAA,QAER;AACA;AAAA,MACF;AACA,YAAM,MAAM,QAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,MAAM;AACnD,YAAM,UAAU,KAAK,MAAM,KAAK,UAAU,IAAI,GAAG,MAAM;AAAA,IACzD,CAAC;AACD,SAAK,aAAa,KAAK,MAAM,MAAM;AAAA,IAAC,CAAC;AACrC,WAAO;AAAA,EACT;AAAA;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/D,SAAK,MAAM,gBAAgB,UAAU,KAAK;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,UAAoB,OAA6B;AAC9D,SAAK,MAAM,eAAe,UAAU,KAAK;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,sBAAsB,QAAuC;AAC3D,WAAO,KAAK,MAAM,sBAAsB,MAAM;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,oBAAoB,QAAgB,OAA6B;AAC/D,SAAK,MAAM,oBAAoB,QAAQ,KAAK;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,QAAgB,OAA6B;AAC9D,SAAK,MAAM,mBAAmB,QAAQ,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAyB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const uploadUrlPool = require("./upload-url-pool.cjs");
|
|
4
|
+
class InMemoryAccountInfo {
|
|
5
|
+
/** Cached authorization response, or null before authorize() is called. */
|
|
6
|
+
auth = null;
|
|
7
|
+
/** Pool of reusable small-file upload URLs, keyed by bucket ID. */
|
|
8
|
+
uploadUrls = new uploadUrlPool.UploadUrlPool();
|
|
9
|
+
/** Pool of reusable large-file part upload URLs, keyed by file ID. */
|
|
10
|
+
partUploadUrls = new uploadUrlPool.UploadUrlPool();
|
|
11
|
+
/**
|
|
12
|
+
* Store a fresh authorization response, replacing any previous state.
|
|
13
|
+
*
|
|
14
|
+
* @param auth - The authorize account response to store.
|
|
15
|
+
*/
|
|
16
|
+
setAuth(auth) {
|
|
17
|
+
this.auth = auth;
|
|
18
|
+
this.uploadUrls.clear();
|
|
19
|
+
this.partUploadUrls.clear();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Return the current authorization response, or null if not authorized.
|
|
23
|
+
*
|
|
24
|
+
* @returns The cached authorization response, or null if not yet authorized.
|
|
25
|
+
*/
|
|
26
|
+
getAuth() {
|
|
27
|
+
return this.auth;
|
|
28
|
+
}
|
|
29
|
+
/** Discard all cached authorization state and upload URLs. */
|
|
30
|
+
clear() {
|
|
31
|
+
this.auth = null;
|
|
32
|
+
this.uploadUrls.clear();
|
|
33
|
+
this.partUploadUrls.clear();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Base URL for B2 API calls.
|
|
37
|
+
*
|
|
38
|
+
* @returns The base URL for B2 API calls.
|
|
39
|
+
*
|
|
40
|
+
* @throws Error if not yet authorized.
|
|
41
|
+
*/
|
|
42
|
+
getApiUrl() {
|
|
43
|
+
return this.requireAuth().apiInfo.storageApi.apiUrl;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Base URL for file downloads.
|
|
47
|
+
*
|
|
48
|
+
* @returns The base URL for file downloads.
|
|
49
|
+
*
|
|
50
|
+
* @throws Error if not yet authorized.
|
|
51
|
+
*/
|
|
52
|
+
getDownloadUrl() {
|
|
53
|
+
return this.requireAuth().apiInfo.storageApi.downloadUrl;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Current authorization token.
|
|
57
|
+
*
|
|
58
|
+
* @returns The current authorization token.
|
|
59
|
+
*
|
|
60
|
+
* @throws Error if not yet authorized.
|
|
61
|
+
*/
|
|
62
|
+
getAuthToken() {
|
|
63
|
+
return this.requireAuth().authorizationToken;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The authorized account ID.
|
|
67
|
+
*
|
|
68
|
+
* @returns The authorized account identifier.
|
|
69
|
+
*
|
|
70
|
+
* @throws Error if not yet authorized.
|
|
71
|
+
*/
|
|
72
|
+
getAccountId() {
|
|
73
|
+
return this.requireAuth().accountId;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Server-recommended part size for large file uploads, in bytes.
|
|
77
|
+
*
|
|
78
|
+
* @returns The server-recommended part size in bytes.
|
|
79
|
+
*
|
|
80
|
+
* @throws Error if not yet authorized.
|
|
81
|
+
*/
|
|
82
|
+
getRecommendedPartSize() {
|
|
83
|
+
return this.requireAuth().apiInfo.storageApi.recommendedPartSize;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Smallest allowed part size for large file uploads, in bytes.
|
|
87
|
+
*
|
|
88
|
+
* @returns The smallest allowed part size in bytes.
|
|
89
|
+
*
|
|
90
|
+
* @throws Error if not yet authorized.
|
|
91
|
+
*/
|
|
92
|
+
getAbsoluteMinimumPartSize() {
|
|
93
|
+
return this.requireAuth().apiInfo.storageApi.absoluteMinimumPartSize;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Base URL for the S3-compatible API.
|
|
97
|
+
*
|
|
98
|
+
* @returns The base URL for the S3-compatible API.
|
|
99
|
+
*
|
|
100
|
+
* @throws Error if not yet authorized.
|
|
101
|
+
*/
|
|
102
|
+
getS3ApiUrl() {
|
|
103
|
+
return this.requireAuth().apiInfo.storageApi.s3ApiUrl;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Bucket ID the key is restricted to, or null if unrestricted.
|
|
107
|
+
*
|
|
108
|
+
* @returns The restricted bucket identifier, or null if the key is unrestricted.
|
|
109
|
+
*
|
|
110
|
+
* @throws Error if not yet authorized.
|
|
111
|
+
*/
|
|
112
|
+
getAllowedBucketId() {
|
|
113
|
+
return this.requireAuth().apiInfo.storageApi.allowed.bucketId ?? null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Take an upload URL from the pool for the given bucket, or null if none available.
|
|
117
|
+
*
|
|
118
|
+
* @param bucketId - The bucket to check out an upload URL for.
|
|
119
|
+
*
|
|
120
|
+
* @returns A reusable upload URL entry, or null if none are available.
|
|
121
|
+
*/
|
|
122
|
+
checkoutUploadUrl(bucketId) {
|
|
123
|
+
return this.uploadUrls.checkout(bucketId);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Return a still-valid upload URL to the pool for reuse.
|
|
127
|
+
*
|
|
128
|
+
* @param bucketId - The bucket the upload URL belongs to.
|
|
129
|
+
* @param entry - The upload URL entry to return to the pool.
|
|
130
|
+
*/
|
|
131
|
+
returnUploadUrl(bucketId, entry) {
|
|
132
|
+
this.uploadUrls.checkin(bucketId, entry);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Remove an upload URL from the pool after an upload error.
|
|
136
|
+
*
|
|
137
|
+
* @param bucketId - The bucket the failed upload URL belongs to.
|
|
138
|
+
* @param entry - The upload URL entry to remove from the pool.
|
|
139
|
+
*/
|
|
140
|
+
evictUploadUrl(bucketId, entry) {
|
|
141
|
+
this.uploadUrls.evict(bucketId, entry);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Take a large-file part upload URL from the pool, or null if none available.
|
|
145
|
+
*
|
|
146
|
+
* @param fileId - The large file to check out a part upload URL for.
|
|
147
|
+
*
|
|
148
|
+
* @returns A reusable part upload URL entry, or null if none are available.
|
|
149
|
+
*/
|
|
150
|
+
checkoutPartUploadUrl(fileId) {
|
|
151
|
+
return this.partUploadUrls.checkout(fileId);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Return a still-valid part upload URL to the pool for reuse.
|
|
155
|
+
*
|
|
156
|
+
* @param fileId - The large file the part upload URL belongs to.
|
|
157
|
+
* @param entry - The part upload URL entry to return to the pool.
|
|
158
|
+
*/
|
|
159
|
+
returnPartUploadUrl(fileId, entry) {
|
|
160
|
+
this.partUploadUrls.checkin(fileId, entry);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Remove a part upload URL from the pool after an error.
|
|
164
|
+
*
|
|
165
|
+
* @param fileId - The large file the failed part upload URL belongs to.
|
|
166
|
+
* @param entry - The part upload URL entry to remove from the pool.
|
|
167
|
+
*/
|
|
168
|
+
evictPartUploadUrl(fileId, entry) {
|
|
169
|
+
this.partUploadUrls.evict(fileId, entry);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Retrieve the cached auth response or throw if not yet authorized.
|
|
173
|
+
*
|
|
174
|
+
* @returns The cached authorization response.
|
|
175
|
+
*
|
|
176
|
+
* @throws Error if authorize() has not been called.
|
|
177
|
+
*/
|
|
178
|
+
requireAuth() {
|
|
179
|
+
if (!this.auth) throw new Error("Not authorized. Call authorize() first.");
|
|
180
|
+
return this.auth;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.InMemoryAccountInfo = InMemoryAccountInfo;
|
|
184
|
+
//# sourceMappingURL=in-memory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.cjs","sources":["../../src/auth/in-memory.ts"],"sourcesContent":["import type { AuthorizeAccountResponse } from '../types/auth.ts'\nimport type { BucketId } from '../types/ids.ts'\nimport type { AccountInfo, UploadUrlEntry } from './account-info.ts'\nimport { UploadUrlPool } from './upload-url-pool.ts'\n\n/**\n * In-memory implementation of {@link AccountInfo}.\n * Stores the authorization response and upload URL pools in plain object fields.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryAccountInfo implements AccountInfo {\n /** Cached authorization response, or null before authorize() is called. */\n private auth: AuthorizeAccountResponse | null = null\n /** Pool of reusable small-file upload URLs, keyed by bucket ID. */\n private readonly uploadUrls = new UploadUrlPool()\n /** Pool of reusable large-file part upload URLs, keyed by file ID. */\n private readonly partUploadUrls = new UploadUrlPool()\n\n /**\n * Store a fresh authorization response, replacing any previous state.\n *\n * @param auth - The authorize account response to store.\n */\n setAuth(auth: AuthorizeAccountResponse): void {\n this.auth = auth\n this.uploadUrls.clear()\n this.partUploadUrls.clear()\n }\n\n /**\n * Return the current authorization response, or null if not authorized.\n *\n * @returns The cached authorization response, or null if not yet authorized.\n */\n getAuth(): AuthorizeAccountResponse | null {\n return this.auth\n }\n\n /** Discard all cached authorization state and upload URLs. */\n clear(): void {\n this.auth = null\n this.uploadUrls.clear()\n this.partUploadUrls.clear()\n }\n\n /**\n * Base URL for B2 API calls.\n *\n * @returns The base URL for B2 API calls.\n *\n * @throws Error if not yet authorized.\n */\n getApiUrl(): string {\n return this.requireAuth().apiInfo.storageApi.apiUrl\n }\n\n /**\n * Base URL for file downloads.\n *\n * @returns The base URL for file downloads.\n *\n * @throws Error if not yet authorized.\n */\n getDownloadUrl(): string {\n return this.requireAuth().apiInfo.storageApi.downloadUrl\n }\n\n /**\n * Current authorization token.\n *\n * @returns The current authorization token.\n *\n * @throws Error if not yet authorized.\n */\n getAuthToken(): string {\n return this.requireAuth().authorizationToken as string\n }\n\n /**\n * The authorized account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws Error if not yet authorized.\n */\n getAccountId(): string {\n return this.requireAuth().accountId as string\n }\n\n /**\n * Server-recommended part size for large file uploads, in bytes.\n *\n * @returns The server-recommended part size in bytes.\n *\n * @throws Error if not yet authorized.\n */\n getRecommendedPartSize(): number {\n return this.requireAuth().apiInfo.storageApi.recommendedPartSize\n }\n\n /**\n * Smallest allowed part size for large file uploads, in bytes.\n *\n * @returns The smallest allowed part size in bytes.\n *\n * @throws Error if not yet authorized.\n */\n getAbsoluteMinimumPartSize(): number {\n return this.requireAuth().apiInfo.storageApi.absoluteMinimumPartSize\n }\n\n /**\n * Base URL for the S3-compatible API.\n *\n * @returns The base URL for the S3-compatible API.\n *\n * @throws Error if not yet authorized.\n */\n getS3ApiUrl(): string {\n return this.requireAuth().apiInfo.storageApi.s3ApiUrl\n }\n\n /**\n * Bucket ID the key is restricted to, or null if unrestricted.\n *\n * @returns The restricted bucket identifier, or null if the key is unrestricted.\n *\n * @throws Error if not yet authorized.\n */\n getAllowedBucketId(): BucketId | null {\n return this.requireAuth().apiInfo.storageApi.allowed.bucketId ?? null\n }\n\n /**\n * Take an upload URL from the pool for the given bucket, or null if none available.\n *\n * @param bucketId - The bucket to check out an upload URL for.\n *\n * @returns A reusable upload URL entry, or null if none are available.\n */\n checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null {\n return this.uploadUrls.checkout(bucketId as string)\n }\n\n /**\n * Return a still-valid upload URL to the pool for reuse.\n *\n * @param bucketId - The bucket the upload URL belongs to.\n * @param entry - The upload URL entry to return to the pool.\n */\n returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.uploadUrls.checkin(bucketId as string, entry)\n }\n\n /**\n * Remove an upload URL from the pool after an upload error.\n *\n * @param bucketId - The bucket the failed upload URL belongs to.\n * @param entry - The upload URL entry to remove from the pool.\n */\n evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void {\n this.uploadUrls.evict(bucketId as string, entry)\n }\n\n /**\n * Take a large-file part upload URL from the pool, or null if none available.\n *\n * @param fileId - The large file to check out a part upload URL for.\n *\n * @returns A reusable part upload URL entry, or null if none are available.\n */\n checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null {\n return this.partUploadUrls.checkout(fileId)\n }\n\n /**\n * Return a still-valid part upload URL to the pool for reuse.\n *\n * @param fileId - The large file the part upload URL belongs to.\n * @param entry - The part upload URL entry to return to the pool.\n */\n returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.partUploadUrls.checkin(fileId, entry)\n }\n\n /**\n * Remove a part upload URL from the pool after an error.\n *\n * @param fileId - The large file the failed part upload URL belongs to.\n * @param entry - The part upload URL entry to remove from the pool.\n */\n evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void {\n this.partUploadUrls.evict(fileId, entry)\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws Error if authorize() has not been called.\n */\n private requireAuth(): AuthorizeAccountResponse {\n if (!this.auth) throw new Error('Not authorized. Call authorize() first.')\n return this.auth\n }\n}\n"],"names":["UploadUrlPool"],"mappings":";;;AAU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AC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,qBAAsC;AACpC,WAAO,KAAK,cAAc,QAAQ,WAAW,QAAQ,YAAY;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,kBAAkB,UAA2C;AAC3D,WAAO,KAAK,WAAW,SAAS,QAAkB;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,gBAAgB,UAAoB,OAA6B;AAC/D,SAAK,WAAW,QAAQ,UAAoB,KAAK;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,eAAe,UAAoB,OAA6B;AAC9D,SAAK,WAAW,MAAM,UAAoB,KAAK;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,sBAAsB,QAAuC;AAC3D,WAAO,KAAK,eAAe,SAAS,MAAM;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,oBAAoB,QAAgB,OAA6B;AAC/D,SAAK,eAAe,QAAQ,QAAQ,KAAK;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,mBAAmB,QAAgB,OAA6B;AAC9D,SAAK,eAAe,MAAM,QAAQ,KAAK;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASQ,cAAwC;AAC9C,QAAI,CAAC,KAAK,KAAM,OAAM,IAAI,MAAM,yCAAyC;AACzE,WAAO,KAAK;AAAA,EACd;AACF;;"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { AuthorizeAccountResponse } from '../types/auth.js';
|
|
2
|
+
import { BucketId } from '../types/ids.js';
|
|
3
|
+
import { AccountInfo, UploadUrlEntry } from './account-info.js';
|
|
4
|
+
/**
|
|
5
|
+
* In-memory implementation of {@link AccountInfo}.
|
|
6
|
+
* Stores the authorization response and upload URL pools in plain object fields.
|
|
7
|
+
* Suitable for short-lived processes or tests; state is lost when the process exits.
|
|
8
|
+
*/
|
|
9
|
+
export declare class InMemoryAccountInfo implements AccountInfo {
|
|
10
|
+
/** Cached authorization response, or null before authorize() is called. */
|
|
11
|
+
private auth;
|
|
12
|
+
/** Pool of reusable small-file upload URLs, keyed by bucket ID. */
|
|
13
|
+
private readonly uploadUrls;
|
|
14
|
+
/** Pool of reusable large-file part upload URLs, keyed by file ID. */
|
|
15
|
+
private readonly partUploadUrls;
|
|
16
|
+
/**
|
|
17
|
+
* Store a fresh authorization response, replacing any previous state.
|
|
18
|
+
*
|
|
19
|
+
* @param auth - The authorize account response to store.
|
|
20
|
+
*/
|
|
21
|
+
setAuth(auth: AuthorizeAccountResponse): void;
|
|
22
|
+
/**
|
|
23
|
+
* Return the current authorization response, or null if not authorized.
|
|
24
|
+
*
|
|
25
|
+
* @returns The cached authorization response, or null if not yet authorized.
|
|
26
|
+
*/
|
|
27
|
+
getAuth(): AuthorizeAccountResponse | null;
|
|
28
|
+
/** Discard all cached authorization state and upload URLs. */
|
|
29
|
+
clear(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Base URL for B2 API calls.
|
|
32
|
+
*
|
|
33
|
+
* @returns The base URL for B2 API calls.
|
|
34
|
+
*
|
|
35
|
+
* @throws Error if not yet authorized.
|
|
36
|
+
*/
|
|
37
|
+
getApiUrl(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Base URL for file downloads.
|
|
40
|
+
*
|
|
41
|
+
* @returns The base URL for file downloads.
|
|
42
|
+
*
|
|
43
|
+
* @throws Error if not yet authorized.
|
|
44
|
+
*/
|
|
45
|
+
getDownloadUrl(): string;
|
|
46
|
+
/**
|
|
47
|
+
* Current authorization token.
|
|
48
|
+
*
|
|
49
|
+
* @returns The current authorization token.
|
|
50
|
+
*
|
|
51
|
+
* @throws Error if not yet authorized.
|
|
52
|
+
*/
|
|
53
|
+
getAuthToken(): string;
|
|
54
|
+
/**
|
|
55
|
+
* The authorized account ID.
|
|
56
|
+
*
|
|
57
|
+
* @returns The authorized account identifier.
|
|
58
|
+
*
|
|
59
|
+
* @throws Error if not yet authorized.
|
|
60
|
+
*/
|
|
61
|
+
getAccountId(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Server-recommended part size for large file uploads, in bytes.
|
|
64
|
+
*
|
|
65
|
+
* @returns The server-recommended part size in bytes.
|
|
66
|
+
*
|
|
67
|
+
* @throws Error if not yet authorized.
|
|
68
|
+
*/
|
|
69
|
+
getRecommendedPartSize(): number;
|
|
70
|
+
/**
|
|
71
|
+
* Smallest allowed part size for large file uploads, in bytes.
|
|
72
|
+
*
|
|
73
|
+
* @returns The smallest allowed part size in bytes.
|
|
74
|
+
*
|
|
75
|
+
* @throws Error if not yet authorized.
|
|
76
|
+
*/
|
|
77
|
+
getAbsoluteMinimumPartSize(): number;
|
|
78
|
+
/**
|
|
79
|
+
* Base URL for the S3-compatible API.
|
|
80
|
+
*
|
|
81
|
+
* @returns The base URL for the S3-compatible API.
|
|
82
|
+
*
|
|
83
|
+
* @throws Error if not yet authorized.
|
|
84
|
+
*/
|
|
85
|
+
getS3ApiUrl(): string;
|
|
86
|
+
/**
|
|
87
|
+
* Bucket ID the key is restricted to, or null if unrestricted.
|
|
88
|
+
*
|
|
89
|
+
* @returns The restricted bucket identifier, or null if the key is unrestricted.
|
|
90
|
+
*
|
|
91
|
+
* @throws Error if not yet authorized.
|
|
92
|
+
*/
|
|
93
|
+
getAllowedBucketId(): BucketId | null;
|
|
94
|
+
/**
|
|
95
|
+
* Take an upload URL from the pool for the given bucket, or null if none available.
|
|
96
|
+
*
|
|
97
|
+
* @param bucketId - The bucket to check out an upload URL for.
|
|
98
|
+
*
|
|
99
|
+
* @returns A reusable upload URL entry, or null if none are available.
|
|
100
|
+
*/
|
|
101
|
+
checkoutUploadUrl(bucketId: BucketId): UploadUrlEntry | null;
|
|
102
|
+
/**
|
|
103
|
+
* Return a still-valid upload URL to the pool for reuse.
|
|
104
|
+
*
|
|
105
|
+
* @param bucketId - The bucket the upload URL belongs to.
|
|
106
|
+
* @param entry - The upload URL entry to return to the pool.
|
|
107
|
+
*/
|
|
108
|
+
returnUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
109
|
+
/**
|
|
110
|
+
* Remove an upload URL from the pool after an upload error.
|
|
111
|
+
*
|
|
112
|
+
* @param bucketId - The bucket the failed upload URL belongs to.
|
|
113
|
+
* @param entry - The upload URL entry to remove from the pool.
|
|
114
|
+
*/
|
|
115
|
+
evictUploadUrl(bucketId: BucketId, entry: UploadUrlEntry): void;
|
|
116
|
+
/**
|
|
117
|
+
* Take a large-file part upload URL from the pool, or null if none available.
|
|
118
|
+
*
|
|
119
|
+
* @param fileId - The large file to check out a part upload URL for.
|
|
120
|
+
*
|
|
121
|
+
* @returns A reusable part upload URL entry, or null if none are available.
|
|
122
|
+
*/
|
|
123
|
+
checkoutPartUploadUrl(fileId: string): UploadUrlEntry | null;
|
|
124
|
+
/**
|
|
125
|
+
* Return a still-valid part upload URL to the pool for reuse.
|
|
126
|
+
*
|
|
127
|
+
* @param fileId - The large file the part upload URL belongs to.
|
|
128
|
+
* @param entry - The part upload URL entry to return to the pool.
|
|
129
|
+
*/
|
|
130
|
+
returnPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
131
|
+
/**
|
|
132
|
+
* Remove a part upload URL from the pool after an error.
|
|
133
|
+
*
|
|
134
|
+
* @param fileId - The large file the failed part upload URL belongs to.
|
|
135
|
+
* @param entry - The part upload URL entry to remove from the pool.
|
|
136
|
+
*/
|
|
137
|
+
evictPartUploadUrl(fileId: string, entry: UploadUrlEntry): void;
|
|
138
|
+
/**
|
|
139
|
+
* Retrieve the cached auth response or throw if not yet authorized.
|
|
140
|
+
*
|
|
141
|
+
* @returns The cached authorization response.
|
|
142
|
+
*
|
|
143
|
+
* @throws Error if authorize() has not been called.
|
|
144
|
+
*/
|
|
145
|
+
private requireAuth;
|
|
146
|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