@backblaze-labs/b2-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +110 -5
- package/README.md +144 -33
- package/dist/_virtual/_b2-sdk-version-json.cjs +4 -0
- package/dist/_virtual/_b2-sdk-version-json.js +4 -0
- package/dist/auth/account-info.d.cts +32 -0
- package/dist/auth/account-info.d.cts.map +1 -1
- package/dist/auth/account-info.d.ts +32 -0
- package/dist/auth/account-info.d.ts.map +1 -1
- package/dist/auth/file.cjs +408 -207
- package/dist/auth/file.cjs.map +1 -1
- package/dist/auth/file.d.cts +77 -3
- package/dist/auth/file.d.cts.map +1 -1
- package/dist/auth/file.d.ts +77 -3
- package/dist/auth/file.d.ts.map +1 -1
- package/dist/auth/file.js +407 -207
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/in-memory.cjs +212 -183
- package/dist/auth/in-memory.cjs.map +1 -1
- package/dist/auth/in-memory.d.cts +8 -0
- package/dist/auth/in-memory.d.cts.map +1 -1
- package/dist/auth/in-memory.d.ts +8 -0
- package/dist/auth/in-memory.d.ts.map +1 -1
- package/dist/auth/in-memory.js +211 -182
- package/dist/auth/in-memory.js.map +1 -1
- package/dist/auth/index.cjs +7 -9
- package/dist/auth/index.d.cts +3 -2
- package/dist/auth/index.d.cts.map +1 -1
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -8
- package/dist/auth/realms.cjs +80 -7
- package/dist/auth/realms.cjs.map +1 -1
- package/dist/auth/realms.d.cts +27 -4
- package/dist/auth/realms.d.cts.map +1 -1
- package/dist/auth/realms.d.ts +27 -4
- package/dist/auth/realms.d.ts.map +1 -1
- package/dist/auth/realms.js +80 -9
- package/dist/auth/realms.js.map +1 -1
- package/dist/auth/upload-url-pool.cjs +55 -51
- package/dist/auth/upload-url-pool.cjs.map +1 -1
- package/dist/auth/upload-url-pool.js +55 -51
- package/dist/auth/upload-url-pool.js.map +1 -1
- package/dist/bucket.cjs +785 -787
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.d.cts +35 -47
- package/dist/bucket.d.cts.map +1 -1
- package/dist/bucket.d.ts +35 -47
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +780 -782
- package/dist/bucket.js.map +1 -1
- package/dist/client.cjs +246 -228
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -17
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +25 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +243 -225
- package/dist/client.js.map +1 -1
- package/dist/copy/large.cjs +114 -71
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts +6 -0
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts +6 -0
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +112 -69
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +89 -0
- package/dist/download/checksum.cjs.map +1 -0
- package/dist/download/checksum.d.cts +40 -0
- package/dist/download/checksum.d.cts.map +1 -0
- package/dist/download/checksum.d.ts +40 -0
- package/dist/download/checksum.d.ts.map +1 -0
- package/dist/download/checksum.js +87 -0
- package/dist/download/checksum.js.map +1 -0
- package/dist/download/parallel.cjs +214 -118
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +5 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +5 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +212 -116
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +188 -97
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts +6 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts +6 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +186 -98
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +699 -243
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +285 -82
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +285 -82
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +678 -261
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +45 -28
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.d.cts +15 -2
- package/dist/http/retry.d.cts.map +1 -1
- package/dist/http/retry.d.ts +15 -2
- package/dist/http/retry.d.ts.map +1 -1
- package/dist/http/retry.js +46 -31
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +438 -140
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +21 -2
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +21 -2
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +437 -140
- package/dist/http/transport.js.map +1 -1
- package/dist/http/url-guard.cjs +154 -89
- package/dist/http/url-guard.cjs.map +1 -1
- package/dist/http/url-guard.d.cts +25 -3
- package/dist/http/url-guard.d.cts.map +1 -1
- package/dist/http/url-guard.d.ts +25 -3
- package/dist/http/url-guard.d.ts.map +1 -1
- package/dist/http/url-guard.js +152 -90
- package/dist/http/url-guard.js.map +1 -1
- package/dist/http/user-agent.cjs +84 -44
- package/dist/http/user-agent.cjs.map +1 -1
- package/dist/http/user-agent.js +84 -46
- package/dist/http/user-agent.js.map +1 -1
- package/dist/index.cjs +101 -77
- package/dist/index.d.cts +27 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +27 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -71
- package/dist/internal/b2-naming.cjs +66 -0
- package/dist/internal/b2-naming.cjs.map +1 -0
- package/dist/internal/b2-naming.d.cts +43 -0
- package/dist/internal/b2-naming.d.cts.map +1 -0
- package/dist/internal/b2-naming.d.ts +43 -0
- package/dist/internal/b2-naming.d.ts.map +1 -0
- package/dist/internal/b2-naming.js +60 -0
- package/dist/internal/b2-naming.js.map +1 -0
- package/dist/internal/upload-retry-options.cjs +21 -0
- package/dist/internal/upload-retry-options.cjs.map +1 -0
- package/dist/internal/upload-retry-options.d.cts +12 -0
- package/dist/internal/upload-retry-options.d.cts.map +1 -0
- package/dist/internal/upload-retry-options.d.ts +12 -0
- package/dist/internal/upload-retry-options.d.ts.map +1 -0
- package/dist/internal/upload-retry-options.js +21 -0
- package/dist/internal/upload-retry-options.js.map +1 -0
- package/dist/internal/url-redaction.cjs +31 -0
- package/dist/internal/url-redaction.cjs.map +1 -0
- package/dist/internal/url-redaction.d.cts +17 -0
- package/dist/internal/url-redaction.d.cts.map +1 -0
- package/dist/internal/url-redaction.d.ts +17 -0
- package/dist/internal/url-redaction.d.ts.map +1 -0
- package/dist/internal/url-redaction.js +31 -0
- package/dist/internal/url-redaction.js.map +1 -0
- package/dist/notifications/index.cjs +4 -6
- package/dist/notifications/index.d.cts +1 -1
- package/dist/notifications/index.d.cts.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +1 -6
- package/dist/notifications/webhook.cjs +195 -85
- package/dist/notifications/webhook.cjs.map +1 -1
- package/dist/notifications/webhook.d.cts.map +1 -1
- package/dist/notifications/webhook.d.ts.map +1 -1
- package/dist/notifications/webhook.js +195 -87
- package/dist/notifications/webhook.js.map +1 -1
- package/dist/object.cjs +253 -210
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +9 -55
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +9 -55
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +249 -206
- package/dist/object.js.map +1 -1
- package/dist/raw/encoding.cjs +74 -35
- package/dist/raw/encoding.cjs.map +1 -1
- package/dist/raw/encoding.js +74 -38
- package/dist/raw/encoding.js.map +1 -1
- package/dist/raw/index.cjs +678 -587
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +121 -18
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +121 -18
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +674 -589
- package/dist/raw/index.js.map +1 -1
- package/dist/s3/index.cjs +355 -18
- package/dist/s3/index.cjs.map +1 -1
- package/dist/s3/index.d.cts +233 -5
- package/dist/s3/index.d.cts.map +1 -1
- package/dist/s3/index.d.ts +233 -5
- package/dist/s3/index.d.ts.map +1 -1
- package/dist/s3/index.js +351 -22
- package/dist/s3/index.js.map +1 -1
- package/dist/s3/sigv4.cjs +149 -0
- package/dist/s3/sigv4.cjs.map +1 -0
- package/dist/s3/sigv4.d.cts +43 -0
- package/dist/s3/sigv4.d.cts.map +1 -0
- package/dist/s3/sigv4.d.ts +43 -0
- package/dist/s3/sigv4.d.ts.map +1 -0
- package/dist/s3/sigv4.js +148 -0
- package/dist/s3/sigv4.js.map +1 -0
- package/dist/s3/validation.cjs +69 -0
- package/dist/s3/validation.cjs.map +1 -0
- package/dist/s3/validation.d.cts +43 -0
- package/dist/s3/validation.d.cts.map +1 -0
- package/dist/s3/validation.d.ts +43 -0
- package/dist/s3/validation.d.ts.map +1 -0
- package/dist/s3/validation.js +66 -0
- package/dist/s3/validation.js.map +1 -0
- package/dist/simulator/capabilities.cjs +63 -48
- package/dist/simulator/capabilities.cjs.map +1 -1
- package/dist/simulator/capabilities.js +63 -49
- package/dist/simulator/capabilities.js.map +1 -1
- package/dist/simulator/index.cjs +2124 -1548
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +79 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +79 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2112 -1546
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/validation.cjs +191 -153
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +3 -21
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +3 -21
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +188 -162
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/collect.cjs +74 -24
- package/dist/streams/collect.cjs.map +1 -1
- package/dist/streams/collect.d.cts +14 -1
- package/dist/streams/collect.d.cts.map +1 -1
- package/dist/streams/collect.d.ts +14 -1
- package/dist/streams/collect.d.ts.map +1 -1
- package/dist/streams/collect.js +74 -25
- package/dist/streams/collect.js.map +1 -1
- package/dist/streams/file-source.cjs +287 -0
- package/dist/streams/file-source.cjs.map +1 -0
- package/dist/streams/file-source.d.cts +96 -0
- package/dist/streams/file-source.d.cts.map +1 -0
- package/dist/streams/file-source.d.ts +96 -0
- package/dist/streams/file-source.d.ts.map +1 -0
- package/dist/streams/file-source.js +286 -0
- package/dist/streams/file-source.js.map +1 -0
- package/dist/streams/hash.cjs +207 -115
- package/dist/streams/hash.cjs.map +1 -1
- package/dist/streams/hash.d.cts +5 -4
- package/dist/streams/hash.d.cts.map +1 -1
- package/dist/streams/hash.d.ts +5 -4
- package/dist/streams/hash.d.ts.map +1 -1
- package/dist/streams/hash.js +208 -95
- package/dist/streams/hash.js.map +1 -1
- package/dist/streams/index.cjs +12 -12
- package/dist/streams/index.d.cts +3 -3
- package/dist/streams/index.d.cts.map +1 -1
- package/dist/streams/index.d.ts +3 -3
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/index.js +2 -10
- package/dist/streams/progress.cjs +60 -46
- package/dist/streams/progress.cjs.map +1 -1
- package/dist/streams/progress.js +60 -46
- package/dist/streams/progress.js.map +1 -1
- package/dist/streams/source.cjs +316 -146
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.d.cts +56 -18
- package/dist/streams/source.d.cts.map +1 -1
- package/dist/streams/source.d.ts +56 -18
- package/dist/streams/source.d.ts.map +1 -1
- package/dist/streams/source.js +312 -149
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/actions/index.cjs +236 -184
- package/dist/sync/actions/index.cjs.map +1 -1
- package/dist/sync/actions/index.d.cts +29 -21
- package/dist/sync/actions/index.d.cts.map +1 -1
- package/dist/sync/actions/index.d.ts +29 -21
- package/dist/sync/actions/index.d.ts.map +1 -1
- package/dist/sync/actions/index.js +236 -190
- package/dist/sync/actions/index.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +148 -0
- package/dist/sync/b2-sha1-reader.cjs.map +1 -0
- package/dist/sync/b2-sha1-reader.d.cts +58 -0
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
- package/dist/sync/b2-sha1-reader.d.ts +58 -0
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
- package/dist/sync/b2-sha1-reader.js +145 -0
- package/dist/sync/b2-sha1-reader.js.map +1 -0
- package/dist/sync/download-staging.cjs +265 -0
- package/dist/sync/download-staging.cjs.map +1 -0
- package/dist/sync/download-staging.d.cts +54 -0
- package/dist/sync/download-staging.d.cts.map +1 -0
- package/dist/sync/download-staging.d.ts +54 -0
- package/dist/sync/download-staging.d.ts.map +1 -0
- package/dist/sync/download-staging.js +259 -0
- package/dist/sync/download-staging.js.map +1 -0
- package/dist/sync/filesystem-errors.cjs +32 -0
- package/dist/sync/filesystem-errors.cjs.map +1 -0
- package/dist/sync/filesystem-errors.d.cts +8 -0
- package/dist/sync/filesystem-errors.d.cts.map +1 -0
- package/dist/sync/filesystem-errors.d.ts +8 -0
- package/dist/sync/filesystem-errors.d.ts.map +1 -0
- package/dist/sync/filesystem-errors.js +32 -0
- package/dist/sync/filesystem-errors.js.map +1 -0
- package/dist/sync/filters.cjs +217 -0
- package/dist/sync/filters.cjs.map +1 -0
- package/dist/sync/filters.d.cts +51 -0
- package/dist/sync/filters.d.cts.map +1 -0
- package/dist/sync/filters.d.ts +51 -0
- package/dist/sync/filters.d.ts.map +1 -0
- package/dist/sync/filters.js +213 -0
- package/dist/sync/filters.js.map +1 -0
- package/dist/sync/index.cjs +39 -22
- package/dist/sync/index.d.cts +14 -9
- package/dist/sync/index.d.cts.map +1 -1
- package/dist/sync/index.d.ts +14 -9
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +9 -20
- package/dist/sync/local-file-identity.cjs +61 -0
- package/dist/sync/local-file-identity.cjs.map +1 -0
- package/dist/sync/local-file-identity.d.cts +37 -0
- package/dist/sync/local-file-identity.d.cts.map +1 -0
- package/dist/sync/local-file-identity.d.ts +37 -0
- package/dist/sync/local-file-identity.d.ts.map +1 -0
- package/dist/sync/local-file-identity.js +60 -0
- package/dist/sync/local-file-identity.js.map +1 -0
- package/dist/sync/local-file-io.cjs +364 -0
- package/dist/sync/local-file-io.cjs.map +1 -0
- package/dist/sync/local-file-io.d.cts +75 -0
- package/dist/sync/local-file-io.d.cts.map +1 -0
- package/dist/sync/local-file-io.d.ts +75 -0
- package/dist/sync/local-file-io.d.ts.map +1 -0
- package/dist/sync/local-file-io.js +360 -0
- package/dist/sync/local-file-io.js.map +1 -0
- package/dist/sync/local-filesystem-root.cjs +27 -0
- package/dist/sync/local-filesystem-root.cjs.map +1 -0
- package/dist/sync/local-filesystem-root.d.cts +18 -0
- package/dist/sync/local-filesystem-root.d.cts.map +1 -0
- package/dist/sync/local-filesystem-root.d.ts +18 -0
- package/dist/sync/local-filesystem-root.d.ts.map +1 -0
- package/dist/sync/local-filesystem-root.js +26 -0
- package/dist/sync/local-filesystem-root.js.map +1 -0
- package/dist/sync/local-sha1.cjs +119 -0
- package/dist/sync/local-sha1.cjs.map +1 -0
- package/dist/sync/local-sha1.d.cts +39 -0
- package/dist/sync/local-sha1.d.cts.map +1 -0
- package/dist/sync/local-sha1.d.ts +39 -0
- package/dist/sync/local-sha1.d.ts.map +1 -0
- package/dist/sync/local-sha1.js +117 -0
- package/dist/sync/local-sha1.js.map +1 -0
- package/dist/sync/pairing.cjs +118 -29
- package/dist/sync/pairing.cjs.map +1 -1
- package/dist/sync/pairing.d.cts +7 -2
- package/dist/sync/pairing.d.cts.map +1 -1
- package/dist/sync/pairing.d.ts +7 -2
- package/dist/sync/pairing.d.ts.map +1 -1
- package/dist/sync/pairing.js +120 -31
- package/dist/sync/pairing.js.map +1 -1
- package/dist/sync/path-order.cjs +30 -0
- package/dist/sync/path-order.cjs.map +1 -0
- package/dist/sync/path-order.d.cts +28 -0
- package/dist/sync/path-order.d.cts.map +1 -0
- package/dist/sync/path-order.d.ts +28 -0
- package/dist/sync/path-order.d.ts.map +1 -0
- package/dist/sync/path-order.js +29 -0
- package/dist/sync/path-order.js.map +1 -0
- package/dist/sync/path-safety.cjs +111 -0
- package/dist/sync/path-safety.cjs.map +1 -0
- package/dist/sync/path-safety.d.cts +78 -0
- package/dist/sync/path-safety.d.cts.map +1 -0
- package/dist/sync/path-safety.d.ts +78 -0
- package/dist/sync/path-safety.d.ts.map +1 -0
- package/dist/sync/path-safety.js +105 -0
- package/dist/sync/path-safety.js.map +1 -0
- package/dist/sync/paths.d.cts +19 -0
- package/dist/sync/paths.d.cts.map +1 -0
- package/dist/sync/paths.d.ts +19 -0
- package/dist/sync/paths.d.ts.map +1 -0
- package/dist/sync/policies/compare.cjs +389 -11
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts +100 -2
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts +100 -2
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +387 -13
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +76 -65
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.d.cts +35 -6
- package/dist/sync/policies/index.d.cts.map +1 -1
- package/dist/sync/policies/index.d.ts +35 -6
- package/dist/sync/policies/index.d.ts.map +1 -1
- package/dist/sync/policies/index.js +76 -65
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/prefix.cjs +96 -0
- package/dist/sync/prefix.cjs.map +1 -0
- package/dist/sync/prefix.d.cts +55 -0
- package/dist/sync/prefix.d.cts.map +1 -0
- package/dist/sync/prefix.d.ts +55 -0
- package/dist/sync/prefix.d.ts.map +1 -0
- package/dist/sync/prefix.js +92 -0
- package/dist/sync/prefix.js.map +1 -0
- package/dist/sync/regexp-safety.cjs +192 -0
- package/dist/sync/regexp-safety.cjs.map +1 -0
- package/dist/sync/regexp-safety.d.cts +29 -0
- package/dist/sync/regexp-safety.d.cts.map +1 -0
- package/dist/sync/regexp-safety.d.ts +29 -0
- package/dist/sync/regexp-safety.d.ts.map +1 -0
- package/dist/sync/regexp-safety.js +190 -0
- package/dist/sync/regexp-safety.js.map +1 -0
- package/dist/sync/scan-events.cjs +33 -0
- package/dist/sync/scan-events.cjs.map +1 -0
- package/dist/sync/scan-events.d.cts +17 -0
- package/dist/sync/scan-events.d.cts.map +1 -0
- package/dist/sync/scan-events.d.ts +17 -0
- package/dist/sync/scan-events.d.ts.map +1 -0
- package/dist/sync/scan-events.js +32 -0
- package/dist/sync/scan-events.js.map +1 -0
- package/dist/sync/scan-limit.cjs +33 -0
- package/dist/sync/scan-limit.cjs.map +1 -0
- package/dist/sync/scan-limit.d.cts +21 -0
- package/dist/sync/scan-limit.d.cts.map +1 -0
- package/dist/sync/scan-limit.d.ts +21 -0
- package/dist/sync/scan-limit.d.ts.map +1 -0
- package/dist/sync/scan-limit.js +31 -0
- package/dist/sync/scan-limit.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +239 -55
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.d.cts +26 -7
- package/dist/sync/scanners/b2.d.cts.map +1 -1
- package/dist/sync/scanners/b2.d.ts +26 -7
- package/dist/sync/scanners/b2.d.ts.map +1 -1
- package/dist/sync/scanners/b2.js +239 -55
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs +215 -56
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.d.cts +22 -7
- package/dist/sync/scanners/local.d.cts.map +1 -1
- package/dist/sync/scanners/local.d.ts +22 -7
- package/dist/sync/scanners/local.d.ts.map +1 -1
- package/dist/sync/scanners/local.js +216 -57
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/sha1-metadata.cjs +94 -0
- package/dist/sync/sha1-metadata.cjs.map +1 -0
- package/dist/sync/sha1-metadata.d.cts +82 -0
- package/dist/sync/sha1-metadata.d.cts.map +1 -0
- package/dist/sync/sha1-metadata.d.ts +82 -0
- package/dist/sync/sha1-metadata.d.ts.map +1 -0
- package/dist/sync/sha1-metadata.js +89 -0
- package/dist/sync/sha1-metadata.js.map +1 -0
- package/dist/sync/sha1-options.cjs +23 -0
- package/dist/sync/sha1-options.cjs.map +1 -0
- package/dist/sync/sha1-options.d.cts +14 -0
- package/dist/sync/sha1-options.d.cts.map +1 -0
- package/dist/sync/sha1-options.d.ts +14 -0
- package/dist/sync/sha1-options.d.ts.map +1 -0
- package/dist/sync/sha1-options.js +21 -0
- package/dist/sync/sha1-options.js.map +1 -0
- package/dist/sync/synchronizer.cjs +782 -197
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.d.cts +47 -1
- package/dist/sync/synchronizer.d.cts.map +1 -1
- package/dist/sync/synchronizer.d.ts +47 -1
- package/dist/sync/synchronizer.d.ts.map +1 -1
- package/dist/sync/synchronizer.js +779 -173
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/sync/types.d.cts +208 -16
- package/dist/sync/types.d.cts.map +1 -1
- package/dist/sync/types.d.ts +208 -16
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types/auth.cjs +76 -56
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +67 -9
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +67 -9
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +77 -57
- package/dist/types/auth.js.map +1 -1
- package/dist/types/bucket.cjs +74 -38
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.js +75 -41
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/encryption.cjs +364 -327
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +16 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +16 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +364 -310
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +47 -0
- package/dist/types/errors.cjs.map +1 -0
- package/dist/types/errors.d.cts +13 -4
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +47 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/file.cjs +36 -19
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +2 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +2 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js +37 -21
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +53 -9
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.js +54 -15
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +12 -11
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +12 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key.d.cts +44 -8
- package/dist/types/key.d.cts.map +1 -1
- package/dist/types/key.d.ts +44 -8
- package/dist/types/key.d.ts.map +1 -1
- package/dist/types/lock.cjs +33 -13
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.js +34 -15
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +44 -22
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.js +45 -23
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/upload.d.cts +39 -5
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +39 -5
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +91 -0
- package/dist/upload/abort-scope.cjs.map +1 -0
- package/dist/upload/abort-scope.d.cts +48 -0
- package/dist/upload/abort-scope.d.cts.map +1 -0
- package/dist/upload/abort-scope.d.ts +48 -0
- package/dist/upload/abort-scope.d.ts.map +1 -0
- package/dist/upload/abort-scope.js +88 -0
- package/dist/upload/abort-scope.js.map +1 -0
- package/dist/upload/cancel.cjs +183 -8
- package/dist/upload/cancel.cjs.map +1 -1
- package/dist/upload/cancel.d.cts +110 -2
- package/dist/upload/cancel.d.cts.map +1 -1
- package/dist/upload/cancel.d.ts +110 -2
- package/dist/upload/cancel.d.ts.map +1 -1
- package/dist/upload/cancel.js +178 -9
- package/dist/upload/cancel.js.map +1 -1
- package/dist/upload/concurrency.cjs +79 -52
- package/dist/upload/concurrency.cjs.map +1 -1
- package/dist/upload/concurrency.js +79 -53
- package/dist/upload/concurrency.js.map +1 -1
- package/dist/upload/finish.cjs +59 -0
- package/dist/upload/finish.cjs.map +1 -0
- package/dist/upload/finish.d.cts +26 -0
- package/dist/upload/finish.d.cts.map +1 -0
- package/dist/upload/finish.d.ts +26 -0
- package/dist/upload/finish.d.ts.map +1 -0
- package/dist/upload/finish.js +59 -0
- package/dist/upload/finish.js.map +1 -0
- package/dist/upload/large.cjs +301 -218
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +76 -9
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +76 -9
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +301 -218
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs +28 -0
- package/dist/upload/options.cjs.map +1 -0
- package/dist/upload/options.d.cts +104 -0
- package/dist/upload/options.d.cts.map +1 -0
- package/dist/upload/options.d.ts +104 -0
- package/dist/upload/options.d.ts.map +1 -0
- package/dist/upload/options.js +27 -0
- package/dist/upload/options.js.map +1 -0
- package/dist/upload/resume.cjs +333 -33
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +82 -12
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +82 -12
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +330 -33
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +186 -0
- package/dist/upload/retry.cjs.map +1 -0
- package/dist/upload/retry.d.cts +127 -0
- package/dist/upload/retry.d.cts.map +1 -0
- package/dist/upload/retry.d.ts +127 -0
- package/dist/upload/retry.d.ts.map +1 -0
- package/dist/upload/retry.js +182 -0
- package/dist/upload/retry.js.map +1 -0
- package/dist/upload/single.cjs +68 -44
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +2 -1
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +2 -1
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +68 -44
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +317 -193
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +3 -1
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +3 -1
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +316 -192
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/best-effort.cjs +42 -8
- package/dist/util/best-effort.cjs.map +1 -1
- package/dist/util/best-effort.d.cts +2 -1
- package/dist/util/best-effort.d.cts.map +1 -1
- package/dist/util/best-effort.d.ts +2 -1
- package/dist/util/best-effort.d.ts.map +1 -1
- package/dist/util/best-effort.js +43 -9
- package/dist/util/best-effort.js.map +1 -1
- package/dist/util/bytes.cjs +23 -0
- package/dist/util/bytes.cjs.map +1 -0
- package/dist/util/bytes.d.cts +15 -0
- package/dist/util/bytes.d.cts.map +1 -0
- package/dist/util/bytes.d.ts +15 -0
- package/dist/util/bytes.d.ts.map +1 -0
- package/dist/util/bytes.js +23 -0
- package/dist/util/bytes.js.map +1 -0
- package/dist/util/crypto.cjs +68 -0
- package/dist/util/crypto.cjs.map +1 -0
- package/dist/util/crypto.d.cts +26 -0
- package/dist/util/crypto.d.cts.map +1 -0
- package/dist/util/crypto.d.ts +26 -0
- package/dist/util/crypto.d.ts.map +1 -0
- package/dist/util/crypto.js +66 -0
- package/dist/util/crypto.js.map +1 -0
- package/dist/util/defaults.cjs +25 -9
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.js +26 -11
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/error-reason.cjs +41 -0
- package/dist/util/error-reason.cjs.map +1 -0
- package/dist/util/error-reason.d.cts +9 -0
- package/dist/util/error-reason.d.cts.map +1 -0
- package/dist/util/error-reason.d.ts +9 -0
- package/dist/util/error-reason.d.ts.map +1 -0
- package/dist/util/error-reason.js +41 -0
- package/dist/util/error-reason.js.map +1 -0
- package/dist/util/http.cjs +23 -0
- package/dist/util/http.cjs.map +1 -0
- package/dist/util/http.d.cts +13 -0
- package/dist/util/http.d.cts.map +1 -0
- package/dist/util/http.d.ts +13 -0
- package/dist/util/http.d.ts.map +1 -0
- package/dist/util/http.js +23 -0
- package/dist/util/http.js.map +1 -0
- package/dist/util/normalize.cjs +66 -7
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.js +67 -10
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +63 -14
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.js +64 -16
- package/dist/util/paginator.js.map +1 -1
- package/dist/util/plan-ranges.cjs +47 -22
- package/dist/util/plan-ranges.cjs.map +1 -1
- package/dist/util/plan-ranges.js +48 -24
- package/dist/util/plan-ranges.js.map +1 -1
- package/dist/util/sha1.cjs +27 -0
- package/dist/util/sha1.cjs.map +1 -0
- package/dist/util/sha1.d.cts +17 -0
- package/dist/util/sha1.d.cts.map +1 -0
- package/dist/util/sha1.d.ts +17 -0
- package/dist/util/sha1.d.ts.map +1 -0
- package/dist/util/sha1.js +26 -0
- package/dist/util/sha1.js.map +1 -0
- package/dist/util/text-codec.cjs +29 -5
- package/dist/util/text-codec.cjs.map +1 -1
- package/dist/util/text-codec.js +30 -7
- package/dist/util/text-codec.js.map +1 -1
- package/dist/util/to-error.cjs +18 -4
- package/dist/util/to-error.cjs.map +1 -1
- package/dist/util/to-error.js +19 -5
- package/dist/util/to-error.js.map +1 -1
- package/dist/version.cjs +17 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -3
- package/dist/version.d.ts +3 -3
- package/dist/version.js +19 -6
- package/dist/version.js.map +1 -1
- package/package.json +19 -16
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notifications/index.cjs.map +0 -1
- package/dist/notifications/index.js.map +0 -1
- package/dist/package.json.cjs +0 -9
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -9
- package/dist/package.json.js.map +0 -1
- package/dist/streams/index.cjs.map +0 -1
- package/dist/streams/index.js.map +0 -1
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.js.map +0 -1
package/dist/errors/index.js
CHANGED
|
@@ -1,268 +1,685 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
class
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
1
|
+
import { redactUrlForError } from "../internal/url-redaction.js";
|
|
2
|
+
import { KNOWN_B2_ERROR_CODES } from "../types/errors.js";
|
|
3
|
+
//#region src/errors/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Typed error hierarchy for B2 API failures.
|
|
6
|
+
*
|
|
7
|
+
* Every B2 error response maps to a specific {@link B2Error} subclass.
|
|
8
|
+
* Retry behavior is exposed through {@link B2Error.retryable}.
|
|
9
|
+
* Examples include {@link ExpiredAuthTokenError} and {@link CapExceededError}.
|
|
10
|
+
* Use {@link classifyError} to convert a raw error response into the
|
|
11
|
+
* appropriate subclass.
|
|
12
|
+
*
|
|
13
|
+
* Convention: most `B2Error` subclasses represent failures returned by the B2
|
|
14
|
+
* API. The client-side exception is {@link B2RealmConfigurationError}; it
|
|
15
|
+
* extends `B2Error` so realm-validation failures can be handled with the SDK
|
|
16
|
+
* error hierarchy before credentials are sent.
|
|
17
|
+
*
|
|
18
|
+
* Other programming errors and SDK preconditions, such as "not yet authorized",
|
|
19
|
+
* "stream consumed twice", or "called before init", use the native `Error`
|
|
20
|
+
* constructor instead. The direct `Error` outliers are
|
|
21
|
+
* {@link B2InsufficientCapabilityError}, {@link B2RedirectError},
|
|
22
|
+
* {@link B2SsrfError}, {@link NetworkError},
|
|
23
|
+
* {@link ResumeFileIdMismatchError}, {@link UploadResponseBodyError}, and
|
|
24
|
+
* {@link FinishLargeFileResponseBodyError}.
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
/** Thrown when an explicit resumeFileId is not compatible with the requested upload. */
|
|
29
|
+
var ResumeFileIdMismatchError = class extends Error {
|
|
30
|
+
/** Caller-supplied unfinished large file ID that failed verification. */
|
|
31
|
+
fileId;
|
|
32
|
+
/** Requested destination file name. */
|
|
33
|
+
fileName;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new resume-file ID mismatch error.
|
|
36
|
+
* @param fileId - Caller-supplied unfinished large file ID that failed verification.
|
|
37
|
+
* @param fileName - Requested destination file name.
|
|
38
|
+
*/
|
|
39
|
+
constructor(fileId, fileName) {
|
|
40
|
+
super(`uploadLargeFile: resumeFileId ${fileId} does not identify a compatible unfinished large file for ${fileName}.`);
|
|
41
|
+
this.name = "ResumeFileIdMismatchError";
|
|
42
|
+
this.fileId = fileId;
|
|
43
|
+
this.fileName = fileName;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Base error class for all B2 API errors.
|
|
48
|
+
* Contains the HTTP status, B2 error code, and retry metadata from the response.
|
|
49
|
+
*/
|
|
50
|
+
var B2Error = class extends Error {
|
|
51
|
+
/** HTTP status code returned by the B2 API. */
|
|
52
|
+
status;
|
|
53
|
+
/** B2 error code identifying the error type (e.g. `expired_auth_token`). */
|
|
54
|
+
code;
|
|
55
|
+
/** B2 request ID from the `X-Bz-Request-Id` response header, if present. */
|
|
56
|
+
requestId;
|
|
57
|
+
/** Retry delay in seconds from the `Retry-After` response header, if present. */
|
|
58
|
+
retryAfter;
|
|
59
|
+
/** Whether this error is transient and the request can be retried. */
|
|
60
|
+
retryable;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a new B2Error instance.
|
|
63
|
+
* @param response - Parsed B2 error response body.
|
|
64
|
+
* @param options - Optional retry and request metadata from response headers.
|
|
65
|
+
*/
|
|
66
|
+
constructor(response, options) {
|
|
67
|
+
super(response.message);
|
|
68
|
+
this.name = "B2Error";
|
|
69
|
+
this.status = response.status;
|
|
70
|
+
this.code = response.code;
|
|
71
|
+
if (options?.retryAfter !== void 0) this.retryAfter = options.retryAfter;
|
|
72
|
+
if (options?.requestId !== void 0) this.requestId = options.requestId;
|
|
73
|
+
this.retryable = isTransient(response.status, response.code);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/** Thrown when the auth token has expired. Triggers automatic re-authorization. */
|
|
77
|
+
var ExpiredAuthTokenError = class extends B2Error {
|
|
78
|
+
/**
|
|
79
|
+
* Creates a new ExpiredAuthTokenError instance.
|
|
80
|
+
* @param response - Parsed B2 error response body.
|
|
81
|
+
* @param options - Optional metadata from response headers.
|
|
82
|
+
*/
|
|
83
|
+
constructor(response, options) {
|
|
84
|
+
super(response, options);
|
|
85
|
+
this.name = "ExpiredAuthTokenError";
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
/** Thrown when the auth token is invalid or unauthorized. */
|
|
89
|
+
var BadAuthTokenError = class extends B2Error {
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new BadAuthTokenError instance.
|
|
92
|
+
* @param response - Parsed B2 error response body.
|
|
93
|
+
* @param options - Optional metadata from response headers.
|
|
94
|
+
*/
|
|
95
|
+
constructor(response, options) {
|
|
96
|
+
super(response, options);
|
|
97
|
+
this.name = "BadAuthTokenError";
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
/** Thrown when the B2 service is temporarily unavailable (HTTP 503). */
|
|
101
|
+
var ServiceUnavailableError = class extends B2Error {
|
|
102
|
+
/**
|
|
103
|
+
* Creates a new ServiceUnavailableError instance.
|
|
104
|
+
* @param response - Parsed B2 error response body.
|
|
105
|
+
* @param options - Optional metadata from response headers.
|
|
106
|
+
*/
|
|
107
|
+
constructor(response, options) {
|
|
108
|
+
super(response, options);
|
|
109
|
+
this.name = "ServiceUnavailableError";
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
/** Thrown when B2 reports an internal server error. */
|
|
113
|
+
var InternalError = class extends B2Error {
|
|
114
|
+
/**
|
|
115
|
+
* Creates a new InternalError instance.
|
|
116
|
+
* @param response - Parsed B2 error response body.
|
|
117
|
+
* @param options - Optional metadata from response headers.
|
|
118
|
+
*/
|
|
119
|
+
constructor(response, options) {
|
|
120
|
+
super(response, options);
|
|
121
|
+
this.name = "InternalError";
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
/** Thrown when a request times out on the server side (HTTP 408). */
|
|
125
|
+
var RequestTimeoutError = class extends B2Error {
|
|
126
|
+
/**
|
|
127
|
+
* Creates a new RequestTimeoutError instance.
|
|
128
|
+
* @param response - Parsed B2 error response body.
|
|
129
|
+
* @param options - Optional metadata from response headers.
|
|
130
|
+
*/
|
|
131
|
+
constructor(response, options) {
|
|
132
|
+
super(response, options);
|
|
133
|
+
this.name = "RequestTimeoutError";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
/** Thrown when the client has sent too many requests (HTTP 429). */
|
|
137
|
+
var TooManyRequestsError = class extends B2Error {
|
|
138
|
+
/**
|
|
139
|
+
* Creates a new TooManyRequestsError instance.
|
|
140
|
+
* @param response - Parsed B2 error response body.
|
|
141
|
+
* @param options - Optional metadata from response headers.
|
|
142
|
+
*/
|
|
143
|
+
constructor(response, options) {
|
|
144
|
+
super(response, options);
|
|
145
|
+
this.name = "TooManyRequestsError";
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
/** Thrown when the account has reached the maximum number of buckets. */
|
|
149
|
+
var TooManyBucketsError = class extends B2Error {
|
|
150
|
+
/**
|
|
151
|
+
* Creates a new TooManyBucketsError instance.
|
|
152
|
+
* @param response - Parsed B2 error response body.
|
|
153
|
+
* @param options - Optional metadata from response headers.
|
|
154
|
+
*/
|
|
155
|
+
constructor(response, options) {
|
|
156
|
+
super(response, options);
|
|
157
|
+
this.name = "TooManyBucketsError";
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
/** Thrown when the bucket or request has reached the maximum number of files. */
|
|
161
|
+
var TooManyFilesError = class extends B2Error {
|
|
162
|
+
/**
|
|
163
|
+
* Creates a new TooManyFilesError instance.
|
|
164
|
+
* @param response - Parsed B2 error response body.
|
|
165
|
+
* @param options - Optional metadata from response headers.
|
|
166
|
+
*/
|
|
167
|
+
constructor(response, options) {
|
|
168
|
+
super(response, options);
|
|
169
|
+
this.name = "TooManyFilesError";
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
/** Thrown when a storage, transaction, or download cap has been exceeded. */
|
|
173
|
+
var CapExceededError = class extends B2Error {
|
|
174
|
+
/**
|
|
175
|
+
* Creates a new CapExceededError instance.
|
|
176
|
+
* @param response - Parsed B2 error response body.
|
|
177
|
+
* @param options - Optional metadata from response headers.
|
|
178
|
+
*/
|
|
179
|
+
constructor(response, options) {
|
|
180
|
+
super(response, options);
|
|
181
|
+
this.name = "CapExceededError";
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
/** Thrown when the application key does not have permission for the requested operation. */
|
|
185
|
+
var AccessDeniedError = class extends B2Error {
|
|
186
|
+
/**
|
|
187
|
+
* Creates a new AccessDeniedError instance.
|
|
188
|
+
* @param response - Parsed B2 error response body.
|
|
189
|
+
* @param options - Optional metadata from response headers.
|
|
190
|
+
*/
|
|
191
|
+
constructor(response, options) {
|
|
192
|
+
super(response, options);
|
|
193
|
+
this.name = "AccessDeniedError";
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
/** Thrown when the requested file does not exist. */
|
|
197
|
+
var FileNotPresentError = class extends B2Error {
|
|
198
|
+
/**
|
|
199
|
+
* Creates a new FileNotPresentError instance.
|
|
200
|
+
* @param response - Parsed B2 error response body.
|
|
201
|
+
* @param options - Optional metadata from response headers.
|
|
202
|
+
*/
|
|
203
|
+
constructor(response, options) {
|
|
204
|
+
super(response, options);
|
|
205
|
+
this.name = "FileNotPresentError";
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
/** Thrown when a requested B2 resource does not exist. */
|
|
209
|
+
var NotFoundError = class extends B2Error {
|
|
210
|
+
/**
|
|
211
|
+
* Creates a new NotFoundError instance.
|
|
212
|
+
* @param response - Parsed B2 error response body.
|
|
213
|
+
* @param options - Optional metadata from response headers.
|
|
214
|
+
*/
|
|
215
|
+
constructor(response, options) {
|
|
216
|
+
super(response, options);
|
|
217
|
+
this.name = "NotFoundError";
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
/** Thrown when creating a bucket with a name that already exists in the account. */
|
|
221
|
+
var DuplicateBucketNameError = class extends B2Error {
|
|
222
|
+
/**
|
|
223
|
+
* Creates a new DuplicateBucketNameError instance.
|
|
224
|
+
* @param response - Parsed B2 error response body.
|
|
225
|
+
* @param options - Optional metadata from response headers.
|
|
226
|
+
*/
|
|
227
|
+
constructor(response, options) {
|
|
228
|
+
super(response, options);
|
|
229
|
+
this.name = "DuplicateBucketNameError";
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
/** Thrown when a bucket name is malformed, reserved, or otherwise rejected by B2. */
|
|
233
|
+
var InvalidBucketNameError = class extends B2Error {
|
|
234
|
+
/**
|
|
235
|
+
* Creates a new InvalidBucketNameError instance.
|
|
236
|
+
* @param response - Parsed B2 error response body.
|
|
237
|
+
* @param options - Optional metadata from response headers.
|
|
238
|
+
*/
|
|
239
|
+
constructor(response, options) {
|
|
240
|
+
super(response, options);
|
|
241
|
+
this.name = "InvalidBucketNameError";
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/** Thrown when bucket metadata fails B2 validation. */
|
|
245
|
+
var InvalidBucketInfoError = class extends B2Error {
|
|
246
|
+
/**
|
|
247
|
+
* Creates a new InvalidBucketInfoError instance.
|
|
248
|
+
* @param response - Parsed B2 error response body.
|
|
249
|
+
* @param options - Optional metadata from response headers.
|
|
250
|
+
*/
|
|
251
|
+
constructor(response, options) {
|
|
252
|
+
super(response, options);
|
|
253
|
+
this.name = "InvalidBucketInfoError";
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
/** Thrown when a bucket ID is malformed or does not identify a valid bucket. */
|
|
257
|
+
var BadBucketIdError = class extends B2Error {
|
|
258
|
+
/**
|
|
259
|
+
* Creates a new BadBucketIdError instance.
|
|
260
|
+
* @param response - Parsed B2 error response body.
|
|
261
|
+
* @param options - Optional metadata from response headers.
|
|
262
|
+
*/
|
|
263
|
+
constructor(response, options) {
|
|
264
|
+
super(response, options);
|
|
265
|
+
this.name = "BadBucketIdError";
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
/** Thrown when the B2 endpoint does not allow the request method. */
|
|
269
|
+
var MethodNotAllowedError = class extends B2Error {
|
|
270
|
+
/**
|
|
271
|
+
* Creates a new MethodNotAllowedError instance.
|
|
272
|
+
* @param response - Parsed B2 error response body.
|
|
273
|
+
* @param options - Optional metadata from response headers.
|
|
274
|
+
*/
|
|
275
|
+
constructor(response, options) {
|
|
276
|
+
super(response, options);
|
|
277
|
+
this.name = "MethodNotAllowedError";
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
/** Thrown when the request conflicts with current B2 resource state. */
|
|
281
|
+
var ConflictError = class extends B2Error {
|
|
282
|
+
/**
|
|
283
|
+
* Creates a new ConflictError instance.
|
|
284
|
+
* @param response - Parsed B2 error response body.
|
|
285
|
+
* @param options - Optional metadata from response headers.
|
|
286
|
+
*/
|
|
287
|
+
constructor(response, options) {
|
|
288
|
+
super(response, options);
|
|
289
|
+
this.name = "ConflictError";
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
/** Thrown for general bad request errors (HTTP 400) not covered by a more specific subclass. */
|
|
293
|
+
var BadRequestError = class extends B2Error {
|
|
294
|
+
/**
|
|
295
|
+
* Creates a new BadRequestError instance.
|
|
296
|
+
* @param response - Parsed B2 error response body.
|
|
297
|
+
* @param options - Optional metadata from response headers.
|
|
298
|
+
*/
|
|
299
|
+
constructor(response, options) {
|
|
300
|
+
super(response, options);
|
|
301
|
+
this.name = "BadRequestError";
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
/** Thrown when B2 cannot parse the JSON request body. */
|
|
305
|
+
var BadJsonError = class extends B2Error {
|
|
306
|
+
/**
|
|
307
|
+
* Creates a new BadJsonError instance.
|
|
308
|
+
* @param response - Parsed B2 error response body.
|
|
309
|
+
* @param options - Optional metadata from response headers.
|
|
310
|
+
*/
|
|
311
|
+
constructor(response, options) {
|
|
312
|
+
super(response, options);
|
|
313
|
+
this.name = "BadJsonError";
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
/** Thrown when a bucket ID has a valid shape but does not identify a usable bucket. */
|
|
317
|
+
var InvalidBucketIdError = class extends B2Error {
|
|
318
|
+
/**
|
|
319
|
+
* Creates a new InvalidBucketIdError instance.
|
|
320
|
+
* @param response - Parsed B2 error response body.
|
|
321
|
+
* @param options - Optional metadata from response headers.
|
|
322
|
+
*/
|
|
323
|
+
constructor(response, options) {
|
|
324
|
+
super(response, options);
|
|
325
|
+
this.name = "InvalidBucketIdError";
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
/** Thrown when a numeric request parameter is outside the allowed range. */
|
|
329
|
+
var OutOfRangeError = class extends B2Error {
|
|
330
|
+
/**
|
|
331
|
+
* Creates a new OutOfRangeError instance.
|
|
332
|
+
* @param response - Parsed B2 error response body.
|
|
333
|
+
* @param options - Optional metadata from response headers.
|
|
334
|
+
*/
|
|
335
|
+
constructor(response, options) {
|
|
336
|
+
super(response, options);
|
|
337
|
+
this.name = "OutOfRangeError";
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
/** Thrown when a requested byte range cannot be satisfied. */
|
|
341
|
+
var RangeNotSatisfiableError = class extends B2Error {
|
|
342
|
+
/**
|
|
343
|
+
* Creates a new RangeNotSatisfiableError instance.
|
|
344
|
+
* @param response - Parsed B2 error response body.
|
|
345
|
+
* @param options - Optional metadata from response headers.
|
|
346
|
+
*/
|
|
347
|
+
constructor(response, options) {
|
|
348
|
+
super(response, options);
|
|
349
|
+
this.name = "RangeNotSatisfiableError";
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
/** Thrown when a file name is malformed or otherwise rejected by B2. */
|
|
353
|
+
var InvalidFileNameError = class extends B2Error {
|
|
354
|
+
/**
|
|
355
|
+
* Creates a new InvalidFileNameError instance.
|
|
356
|
+
* @param response - Parsed B2 error response body.
|
|
357
|
+
* @param options - Optional metadata from response headers.
|
|
358
|
+
*/
|
|
359
|
+
constructor(response, options) {
|
|
360
|
+
super(response, options);
|
|
361
|
+
this.name = "InvalidFileNameError";
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
/** Thrown when file metadata fails B2 validation. */
|
|
365
|
+
var InvalidFileInfoError = class extends B2Error {
|
|
366
|
+
/**
|
|
367
|
+
* Creates a new InvalidFileInfoError instance.
|
|
368
|
+
* @param response - Parsed B2 error response body.
|
|
369
|
+
* @param options - Optional metadata from response headers.
|
|
370
|
+
*/
|
|
371
|
+
constructor(response, options) {
|
|
372
|
+
super(response, options);
|
|
373
|
+
this.name = "InvalidFileInfoError";
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
/** Thrown when a file ID is malformed or does not identify a valid file. */
|
|
377
|
+
var InvalidFileIdError = class extends B2Error {
|
|
378
|
+
/**
|
|
379
|
+
* Creates a new InvalidFileIdError instance.
|
|
380
|
+
* @param response - Parsed B2 error response body.
|
|
381
|
+
* @param options - Optional metadata from response headers.
|
|
382
|
+
*/
|
|
383
|
+
constructor(response, options) {
|
|
384
|
+
super(response, options);
|
|
385
|
+
this.name = "InvalidFileIdError";
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
/** Thrown when a multipart upload part number is invalid. */
|
|
389
|
+
var InvalidPartNumberError = class extends B2Error {
|
|
390
|
+
/**
|
|
391
|
+
* Creates a new InvalidPartNumberError instance.
|
|
392
|
+
* @param response - Parsed B2 error response body.
|
|
393
|
+
* @param options - Optional metadata from response headers.
|
|
394
|
+
*/
|
|
395
|
+
constructor(response, options) {
|
|
396
|
+
super(response, options);
|
|
397
|
+
this.name = "InvalidPartNumberError";
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Thrown when an upload URL is no longer valid and must be refreshed.
|
|
402
|
+
*
|
|
403
|
+
* Forward-compat insurance: B2 does not currently surface a distinct
|
|
404
|
+
* error code for this case, so {@link classifyError} never actually
|
|
405
|
+
* instantiates this class today. It's part of the public API so
|
|
406
|
+
* consumers can pre-write `instanceof` checks; when B2 documents a
|
|
407
|
+
* `bad_upload_url` (or similar) error code, the `classifyError`
|
|
408
|
+
* switch gets a matching case and existing consumer code starts
|
|
409
|
+
* catching the typed error without any changes on their side.
|
|
410
|
+
*
|
|
411
|
+
* Until then, expect `BadRequestError` for upload-URL invalidation
|
|
412
|
+
* scenarios — that's what B2 currently returns.
|
|
413
|
+
*/
|
|
414
|
+
var BadUploadUrlError = class extends B2Error {
|
|
415
|
+
/**
|
|
416
|
+
* Creates a new BadUploadUrlError instance.
|
|
417
|
+
* @param response - Parsed B2 error response body.
|
|
418
|
+
* @param options - Optional metadata from response headers.
|
|
419
|
+
*/
|
|
420
|
+
constructor(response, options) {
|
|
421
|
+
super(response, options);
|
|
422
|
+
this.name = "BadUploadUrlError";
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
/**
|
|
426
|
+
* Thrown when the uploaded file's SHA-1 checksum does not match the
|
|
427
|
+
* expected value.
|
|
428
|
+
*
|
|
429
|
+
* When B2 returns `bad_sha1_checksum`, {@link classifyError} instantiates
|
|
430
|
+
* this class so callers can handle checksum failures with `instanceof`.
|
|
431
|
+
* Generic `bad_request` checksum failures continue to classify as
|
|
432
|
+
* {@link BadRequestError}.
|
|
433
|
+
*/
|
|
434
|
+
var ChecksumMismatchError = class extends B2Error {
|
|
435
|
+
/**
|
|
436
|
+
* Creates a new ChecksumMismatchError instance.
|
|
437
|
+
* @param response - Parsed B2 error response body.
|
|
438
|
+
* @param options - Optional metadata from response headers.
|
|
439
|
+
*/
|
|
440
|
+
constructor(response, options) {
|
|
441
|
+
super(response, options);
|
|
442
|
+
this.name = "ChecksumMismatchError";
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
/**
|
|
446
|
+
* Thrown by client-side capability checks when the application key is missing
|
|
447
|
+
* capabilities required by an operation. Not raised by the server.
|
|
448
|
+
*/
|
|
449
|
+
var B2InsufficientCapabilityError = class extends Error {
|
|
450
|
+
/** Capabilities that were required for the operation. */
|
|
451
|
+
required;
|
|
452
|
+
/** Capabilities that the current key actually has. */
|
|
453
|
+
available;
|
|
454
|
+
/** Capabilities present in `required` but not in `available`. */
|
|
455
|
+
missing;
|
|
456
|
+
/**
|
|
457
|
+
* Creates a new B2InsufficientCapabilityError instance.
|
|
458
|
+
*
|
|
459
|
+
* @param required - Capabilities the operation requires.
|
|
460
|
+
* @param available - Capabilities the current key holds.
|
|
461
|
+
* @param missing - The subset of required that isn't available.
|
|
462
|
+
*/
|
|
463
|
+
constructor(required, available, missing) {
|
|
464
|
+
super(`Application key is missing capabilities: ${missing.join(", ")}`);
|
|
465
|
+
this.name = "B2InsufficientCapabilityError";
|
|
466
|
+
this.required = required;
|
|
467
|
+
this.available = available;
|
|
468
|
+
this.missing = missing;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Thrown when the SDK is asked to fetch a URL whose host is outside the
|
|
473
|
+
* authorized B2 realm. Defense against SSRF / URL-substitution attacks where
|
|
474
|
+
* a compromised or hostile B2 endpoint returns an upload URL pointing at an
|
|
475
|
+
* internal service (e.g. cloud metadata at `169.254.169.254`).
|
|
476
|
+
*
|
|
477
|
+
* Not retryable.
|
|
478
|
+
*/
|
|
479
|
+
var B2SsrfError = class extends Error {
|
|
480
|
+
/** Always `false` — this is a security failure, not transient. */
|
|
481
|
+
retryable = false;
|
|
482
|
+
/**
|
|
483
|
+
* Creates a new {@link B2SsrfError}.
|
|
484
|
+
*
|
|
485
|
+
* @param message - Human-readable description of which URL was rejected and why.
|
|
486
|
+
* @param url - The URL that was rejected. Stored as a sanitized URL.
|
|
487
|
+
*/
|
|
488
|
+
constructor(message, url) {
|
|
489
|
+
const safeUrl = redactUrlForError(url);
|
|
490
|
+
super(`${message.split(url).join(safeUrl)} (${safeUrl})`);
|
|
491
|
+
this.name = "B2SsrfError";
|
|
492
|
+
this.url = safeUrl;
|
|
493
|
+
}
|
|
494
|
+
/** Sanitized URL that was rejected. */
|
|
495
|
+
url;
|
|
496
|
+
};
|
|
497
|
+
/** Thrown when a configured auth realm cannot safely be used for authorization. */
|
|
498
|
+
var B2RealmConfigurationError = class extends B2Error {
|
|
499
|
+
/**
|
|
500
|
+
* Creates a new B2RealmConfigurationError instance.
|
|
501
|
+
*
|
|
502
|
+
* @param message - Human-readable description of the invalid realm setting.
|
|
503
|
+
*/
|
|
504
|
+
constructor(message) {
|
|
505
|
+
super({
|
|
506
|
+
status: 400,
|
|
507
|
+
code: "bad_request",
|
|
508
|
+
message
|
|
509
|
+
});
|
|
510
|
+
this.name = "B2RealmConfigurationError";
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
/** Thrown when the SDK refuses to follow an HTTP redirect automatically. */
|
|
514
|
+
var B2RedirectError = class extends Error {
|
|
515
|
+
/** Always `false` because a blocked redirect is deterministic. */
|
|
516
|
+
retryable = false;
|
|
517
|
+
/** Sanitized request URL whose response attempted to redirect. */
|
|
518
|
+
url;
|
|
519
|
+
/** HTTP redirect status code, or 0 for an opaque browser redirect. */
|
|
520
|
+
status;
|
|
521
|
+
/** Sanitized redirect target, or `null` when no Location header was present. */
|
|
522
|
+
location;
|
|
523
|
+
/**
|
|
524
|
+
* Creates a new B2RedirectError instance.
|
|
525
|
+
*
|
|
526
|
+
* @param url - Request URL whose response attempted to redirect. Stored as a sanitized URL.
|
|
527
|
+
* @param status - HTTP redirect status code.
|
|
528
|
+
* @param location - Redirect Location header, if present. Stored as a sanitized URL.
|
|
529
|
+
*/
|
|
530
|
+
constructor(url, status, location) {
|
|
531
|
+
const safeUrl = redactUrlForError(url);
|
|
532
|
+
const safeLocation = location !== null ? redactUrlForError(location, { baseUrl: url }) : null;
|
|
533
|
+
super(safeLocation !== null ? `HTTP ${status} redirect blocked for ${safeUrl} to ${safeLocation}` : `HTTP ${status} redirect blocked for ${safeUrl}`);
|
|
534
|
+
this.name = "B2RedirectError";
|
|
535
|
+
this.url = safeUrl;
|
|
536
|
+
this.status = status;
|
|
537
|
+
this.location = safeLocation;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
/** Thrown when a network-level failure occurs (DNS, TCP, TLS). Always retryable. */
|
|
541
|
+
var NetworkError = class extends Error {
|
|
542
|
+
cause;
|
|
543
|
+
/** Always `true` since network errors are transient. */
|
|
544
|
+
retryable = true;
|
|
545
|
+
/**
|
|
546
|
+
* Creates a new NetworkError instance.
|
|
547
|
+
* @param message - Human-readable description of the network failure.
|
|
548
|
+
* @param cause - The underlying error that caused this failure, if any.
|
|
549
|
+
*/
|
|
550
|
+
constructor(message, cause) {
|
|
551
|
+
super(message);
|
|
552
|
+
this.cause = cause;
|
|
553
|
+
this.name = "NetworkError";
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* Thrown when an upload POST returned a response but its body could not be
|
|
558
|
+
* read. The upload may already have been stored by B2, so retrying this error
|
|
559
|
+
* can create duplicate file versions or parts.
|
|
560
|
+
*/
|
|
561
|
+
var UploadResponseBodyError = class extends Error {
|
|
562
|
+
/** Underlying response body error, when available. */
|
|
563
|
+
cause;
|
|
564
|
+
/**
|
|
565
|
+
* Creates a new UploadResponseBodyError instance.
|
|
566
|
+
* @param message - Human-readable description of the response read failure.
|
|
567
|
+
* @param options - Optional cause.
|
|
568
|
+
*/
|
|
569
|
+
constructor(message, options = {}) {
|
|
570
|
+
super(message, { cause: options.cause });
|
|
571
|
+
this.name = "UploadResponseBodyError";
|
|
572
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* Thrown when `b2_finish_large_file` returned a response but its body could not
|
|
577
|
+
* be read. The large file may already be committed server-side, so high-level
|
|
578
|
+
* upload paths do not cancel the large file after this error.
|
|
579
|
+
*/
|
|
580
|
+
var FinishLargeFileResponseBodyError = class extends Error {
|
|
581
|
+
/** Ambiguous large file ID that may already be committed server-side. */
|
|
582
|
+
fileId;
|
|
583
|
+
/** Bucket requested by the high-level upload, when available. */
|
|
584
|
+
bucketId;
|
|
585
|
+
/** File name requested by the high-level upload, when available. */
|
|
586
|
+
fileName;
|
|
587
|
+
/**
|
|
588
|
+
* Creates a new FinishLargeFileResponseBodyError instance.
|
|
589
|
+
* @param message - Human-readable description of the response read failure.
|
|
590
|
+
* @param options - Optional cause and reconciliation metadata.
|
|
591
|
+
*/
|
|
592
|
+
constructor(message, options = {}) {
|
|
593
|
+
super(message, { cause: options.cause });
|
|
594
|
+
this.name = "FinishLargeFileResponseBodyError";
|
|
595
|
+
if (options.cause !== void 0) this.cause = options.cause;
|
|
596
|
+
if (options.fileId !== void 0) this.fileId = options.fileId;
|
|
597
|
+
if (options.bucketId !== void 0) this.bucketId = options.bucketId;
|
|
598
|
+
if (options.fileName !== void 0) this.fileName = options.fileName;
|
|
599
|
+
}
|
|
600
|
+
};
|
|
601
|
+
function isTransient(status, code) {
|
|
602
|
+
if (status === 408 || status === 429) return true;
|
|
603
|
+
if (status === 500 || status === 502 || status === 503 || status === 504) return true;
|
|
604
|
+
if (code === "expired_auth_token") return true;
|
|
605
|
+
if (code === "service_unavailable" || code === "request_timeout") return true;
|
|
606
|
+
return false;
|
|
158
607
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
/** Capabilities that the current key actually has. */
|
|
163
|
-
available;
|
|
164
|
-
/** Capabilities present in `required` but not in `available`. */
|
|
165
|
-
missing;
|
|
166
|
-
/**
|
|
167
|
-
* Creates a new B2InsufficientCapabilityError instance.
|
|
168
|
-
*
|
|
169
|
-
* @param required - Capabilities the operation requires.
|
|
170
|
-
* @param available - Capabilities the current key holds.
|
|
171
|
-
* @param missing - The subset of required that isn't available.
|
|
172
|
-
*/
|
|
173
|
-
constructor(required, available, missing) {
|
|
174
|
-
super(`Application key is missing capabilities: ${missing.join(", ")}`);
|
|
175
|
-
this.name = "B2InsufficientCapabilityError";
|
|
176
|
-
this.required = required;
|
|
177
|
-
this.available = available;
|
|
178
|
-
this.missing = missing;
|
|
179
|
-
}
|
|
608
|
+
var knownB2ErrorCodes = new Set(KNOWN_B2_ERROR_CODES);
|
|
609
|
+
function isKnownB2ErrorCode(code) {
|
|
610
|
+
return knownB2ErrorCodes.has(code);
|
|
180
611
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
* Creates a new {@link B2SsrfError}.
|
|
184
|
-
*
|
|
185
|
-
* @param message - Human-readable description of which URL was rejected and why.
|
|
186
|
-
* @param url - The full URL that was rejected.
|
|
187
|
-
*/
|
|
188
|
-
constructor(message, url) {
|
|
189
|
-
super(message);
|
|
190
|
-
this.url = url;
|
|
191
|
-
this.name = "B2SsrfError";
|
|
192
|
-
}
|
|
193
|
-
/** Always `false` — this is a security failure, not transient. */
|
|
194
|
-
retryable = false;
|
|
612
|
+
function assertNever(value) {
|
|
613
|
+
throw new Error(`Unhandled B2 error code: ${String(value)}`);
|
|
195
614
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
615
|
+
function classifyKnownError(response, code, options) {
|
|
616
|
+
switch (code) {
|
|
617
|
+
case "expired_auth_token": return new ExpiredAuthTokenError(response, options);
|
|
618
|
+
case "bad_auth_token":
|
|
619
|
+
case "unauthorized": return new BadAuthTokenError(response, options);
|
|
620
|
+
case "bad_request": return new BadRequestError(response, options);
|
|
621
|
+
case "bad_bucket_name":
|
|
622
|
+
case "invalid_bucket_name": return new InvalidBucketNameError(response, options);
|
|
623
|
+
case "bad_bucket_id": return new BadBucketIdError(response, options);
|
|
624
|
+
case "not_found": return new NotFoundError(response, options);
|
|
625
|
+
case "method_not_allowed": return new MethodNotAllowedError(response, options);
|
|
626
|
+
case "request_timeout": return new RequestTimeoutError(response, options);
|
|
627
|
+
case "too_many_requests": return new TooManyRequestsError(response, options);
|
|
628
|
+
case "conflict": return new ConflictError(response, options);
|
|
629
|
+
case "duplicate_bucket_name": return new DuplicateBucketNameError(response, options);
|
|
630
|
+
case "too_many_buckets": return new TooManyBucketsError(response, options);
|
|
631
|
+
case "too_many_files": return new TooManyFilesError(response, options);
|
|
632
|
+
case "cap_exceeded":
|
|
633
|
+
case "storage_cap_exceeded":
|
|
634
|
+
case "transaction_cap_exceeded":
|
|
635
|
+
case "download_cap_exceeded": return new CapExceededError(response, options);
|
|
636
|
+
case "access_denied": return new AccessDeniedError(response, options);
|
|
637
|
+
case "service_unavailable": return new ServiceUnavailableError(response, options);
|
|
638
|
+
case "internal_error": return new InternalError(response, options);
|
|
639
|
+
case "bad_json": return new BadJsonError(response, options);
|
|
640
|
+
case "invalid_bucket_id": return new InvalidBucketIdError(response, options);
|
|
641
|
+
case "invalid_bucket_info": return new InvalidBucketInfoError(response, options);
|
|
642
|
+
case "file_not_present":
|
|
643
|
+
case "no_such_file": return new FileNotPresentError(response, options);
|
|
644
|
+
case "out_of_range": return new OutOfRangeError(response, options);
|
|
645
|
+
case "range_not_satisfiable": return new RangeNotSatisfiableError(response, options);
|
|
646
|
+
case "invalid_file_id": return new InvalidFileIdError(response, options);
|
|
647
|
+
case "invalid_file_name": return new InvalidFileNameError(response, options);
|
|
648
|
+
case "invalid_file_info": return new InvalidFileInfoError(response, options);
|
|
649
|
+
case "invalid_part_number": return new InvalidPartNumberError(response, options);
|
|
650
|
+
case "bad_sha1_checksum": return new ChecksumMismatchError(response, options);
|
|
651
|
+
default: return assertNever(code);
|
|
652
|
+
}
|
|
209
653
|
}
|
|
210
|
-
function
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
654
|
+
function classifyUnknownError(response, options) {
|
|
655
|
+
if (response.status === 429) return new TooManyRequestsError(response, options);
|
|
656
|
+
if (response.status === 503) return new ServiceUnavailableError(response, options);
|
|
657
|
+
if (response.status === 408) return new RequestTimeoutError(response, options);
|
|
658
|
+
return new B2Error(response, options);
|
|
215
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* Maps a B2 error response to the appropriate {@link B2Error} subclass.
|
|
662
|
+
* Uses known error codes for exact matching, then falls back to HTTP status
|
|
663
|
+
* codes for unknown future B2 codes.
|
|
664
|
+
*
|
|
665
|
+
* Maintainer note: when B2 documents a new error code, add it to
|
|
666
|
+
* `KNOWN_B2_ERROR_CODES` in `src/types/errors.ts` and add a matching
|
|
667
|
+
* `classifyKnownError` switch case. Unknown codes fall through to the
|
|
668
|
+
* HTTP-status-based heuristic and finally to a generic `B2Error`, which is
|
|
669
|
+
* safe but loses semantic specificity (the caller can't `instanceof` against
|
|
670
|
+
* a precise subclass and the retry decision relies on status alone).
|
|
671
|
+
*
|
|
672
|
+
* @param response - Parsed B2 error response body.
|
|
673
|
+
* @param options - Optional retry and request metadata from response headers.
|
|
674
|
+
*
|
|
675
|
+
* @returns A typed B2Error subclass instance.
|
|
676
|
+
*/
|
|
216
677
|
function classifyError(response, options) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
case "bad_auth_token":
|
|
221
|
-
case "unauthorized":
|
|
222
|
-
return new BadAuthTokenError(response, options);
|
|
223
|
-
case "service_unavailable":
|
|
224
|
-
return new ServiceUnavailableError(response, options);
|
|
225
|
-
case "request_timeout":
|
|
226
|
-
return new RequestTimeoutError(response, options);
|
|
227
|
-
case "cap_exceeded":
|
|
228
|
-
case "storage_cap_exceeded":
|
|
229
|
-
case "transaction_cap_exceeded":
|
|
230
|
-
case "download_cap_exceeded":
|
|
231
|
-
return new CapExceededError(response, options);
|
|
232
|
-
case "access_denied":
|
|
233
|
-
return new AccessDeniedError(response, options);
|
|
234
|
-
case "file_not_present":
|
|
235
|
-
case "no_such_file":
|
|
236
|
-
return new FileNotPresentError(response, options);
|
|
237
|
-
case "duplicate_bucket_name":
|
|
238
|
-
return new DuplicateBucketNameError(response, options);
|
|
239
|
-
case "bad_sha1_checksum":
|
|
240
|
-
return new ChecksumMismatchError(response, options);
|
|
241
|
-
case "bad_request":
|
|
242
|
-
return new BadRequestError(response, options);
|
|
243
|
-
}
|
|
244
|
-
if (response.status === 429) return new TooManyRequestsError(response, options);
|
|
245
|
-
if (response.status === 503) return new ServiceUnavailableError(response, options);
|
|
246
|
-
if (response.status === 408) return new RequestTimeoutError(response, options);
|
|
247
|
-
return new B2Error(response, options);
|
|
678
|
+
if (response.code === "internal_error" && response.status !== 500) return classifyUnknownError(response, options);
|
|
679
|
+
if (isKnownB2ErrorCode(response.code)) return classifyKnownError(response, response.code, options);
|
|
680
|
+
return classifyUnknownError(response, options);
|
|
248
681
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
B2SsrfError,
|
|
254
|
-
BadAuthTokenError,
|
|
255
|
-
BadRequestError,
|
|
256
|
-
BadUploadUrlError,
|
|
257
|
-
CapExceededError,
|
|
258
|
-
ChecksumMismatchError,
|
|
259
|
-
DuplicateBucketNameError,
|
|
260
|
-
ExpiredAuthTokenError,
|
|
261
|
-
FileNotPresentError,
|
|
262
|
-
NetworkError,
|
|
263
|
-
RequestTimeoutError,
|
|
264
|
-
ServiceUnavailableError,
|
|
265
|
-
TooManyRequestsError,
|
|
266
|
-
classifyError
|
|
267
|
-
};
|
|
268
|
-
//# sourceMappingURL=index.js.map
|
|
682
|
+
//#endregion
|
|
683
|
+
export { AccessDeniedError, B2Error, B2InsufficientCapabilityError, B2RealmConfigurationError, B2RedirectError, B2SsrfError, BadAuthTokenError, BadBucketIdError, BadJsonError, BadRequestError, BadUploadUrlError, CapExceededError, ChecksumMismatchError, ConflictError, DuplicateBucketNameError, ExpiredAuthTokenError, FileNotPresentError, FinishLargeFileResponseBodyError, InternalError, InvalidBucketIdError, InvalidBucketInfoError, InvalidBucketNameError, InvalidFileIdError, InvalidFileInfoError, InvalidFileNameError, InvalidPartNumberError, MethodNotAllowedError, NetworkError, NotFoundError, OutOfRangeError, RangeNotSatisfiableError, RequestTimeoutError, ResumeFileIdMismatchError, ServiceUnavailableError, TooManyBucketsError, TooManyFilesError, TooManyRequestsError, UploadResponseBodyError, classifyError };
|
|
684
|
+
|
|
685
|
+
//# sourceMappingURL=index.js.map
|