@backblaze-labs/b2-sdk 0.2.0 → 0.3.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 +42 -1
- package/README.md +20 -2
- package/dist/_virtual/_b2-sdk-version-json.cjs +1 -1
- package/dist/_virtual/_b2-sdk-version-json.js +1 -1
- package/dist/auth/file.cjs.map +1 -1
- package/dist/backup/client.cjs +206 -0
- package/dist/backup/client.cjs.map +1 -0
- package/dist/backup/client.d.cts +238 -0
- package/dist/backup/client.d.cts.map +1 -0
- package/dist/backup/client.d.ts +238 -0
- package/dist/backup/client.d.ts.map +1 -0
- package/dist/backup/client.js +206 -0
- package/dist/backup/client.js.map +1 -0
- package/dist/backup/index.cjs +15 -0
- package/dist/backup/index.d.cts +22 -0
- package/dist/backup/index.d.cts.map +1 -0
- package/dist/backup/index.d.ts +22 -0
- package/dist/backup/index.d.ts.map +1 -0
- package/dist/backup/index.js +7 -0
- package/dist/backup/raw.cjs +146 -0
- package/dist/backup/raw.cjs.map +1 -0
- package/dist/backup/raw.d.cts +122 -0
- package/dist/backup/raw.d.cts.map +1 -0
- package/dist/backup/raw.d.ts +122 -0
- package/dist/backup/raw.d.ts.map +1 -0
- package/dist/backup/raw.js +146 -0
- package/dist/backup/raw.js.map +1 -0
- package/dist/bucket.cjs +2 -1
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.js +2 -1
- package/dist/bucket.js.map +1 -1
- package/dist/copy/large.cjs +5 -3
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +5 -3
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +6 -2
- package/dist/download/checksum.cjs.map +1 -1
- package/dist/download/checksum.js +6 -2
- package/dist/download/checksum.js.map +1 -1
- package/dist/download/parallel.cjs +52 -15
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +8 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +8 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +52 -15
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +141 -6
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +141 -6
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +173 -3
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +119 -0
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +119 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +161 -4
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +1 -1
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.js +1 -1
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +61 -23
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +25 -3
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +25 -3
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +59 -22
- package/dist/http/transport.js.map +1 -1
- package/dist/index.cjs +25 -2
- package/dist/index.d.cts +6 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/object.cjs +1 -1
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +4 -2
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +4 -2
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +1 -1
- package/dist/object.js.map +1 -1
- package/dist/partner/account-info.d.cts +43 -0
- package/dist/partner/account-info.d.cts.map +1 -0
- package/dist/partner/account-info.d.ts +43 -0
- package/dist/partner/account-info.d.ts.map +1 -0
- package/dist/partner/auth-clone.cjs +64 -0
- package/dist/partner/auth-clone.cjs.map +1 -0
- package/dist/partner/auth-clone.d.cts +27 -0
- package/dist/partner/auth-clone.d.cts.map +1 -0
- package/dist/partner/auth-clone.d.ts +27 -0
- package/dist/partner/auth-clone.d.ts.map +1 -0
- package/dist/partner/auth-clone.js +63 -0
- package/dist/partner/auth-clone.js.map +1 -0
- package/dist/partner/auth-core.cjs +175 -0
- package/dist/partner/auth-core.cjs.map +1 -0
- package/dist/partner/auth-core.d.cts +111 -0
- package/dist/partner/auth-core.d.cts.map +1 -0
- package/dist/partner/auth-core.d.ts +111 -0
- package/dist/partner/auth-core.d.ts.map +1 -0
- package/dist/partner/auth-core.js +175 -0
- package/dist/partner/auth-core.js.map +1 -0
- package/dist/partner/auth-shape.cjs +36 -0
- package/dist/partner/auth-shape.cjs.map +1 -0
- package/dist/partner/auth-shape.d.cts +12 -0
- package/dist/partner/auth-shape.d.cts.map +1 -0
- package/dist/partner/auth-shape.d.ts +12 -0
- package/dist/partner/auth-shape.d.ts.map +1 -0
- package/dist/partner/auth-shape.js +36 -0
- package/dist/partner/auth-shape.js.map +1 -0
- package/dist/partner/client.cjs +255 -0
- package/dist/partner/client.cjs.map +1 -0
- package/dist/partner/client.d.cts +335 -0
- package/dist/partner/client.d.cts.map +1 -0
- package/dist/partner/client.d.ts +335 -0
- package/dist/partner/client.d.ts.map +1 -0
- package/dist/partner/client.js +255 -0
- package/dist/partner/client.js.map +1 -0
- package/dist/partner/endpoint-url.cjs +108 -0
- package/dist/partner/endpoint-url.cjs.map +1 -0
- package/dist/partner/endpoint-url.d.cts +72 -0
- package/dist/partner/endpoint-url.d.cts.map +1 -0
- package/dist/partner/endpoint-url.d.ts +72 -0
- package/dist/partner/endpoint-url.d.ts.map +1 -0
- package/dist/partner/endpoint-url.js +105 -0
- package/dist/partner/endpoint-url.js.map +1 -0
- package/dist/partner/in-memory.cjs +135 -0
- package/dist/partner/in-memory.cjs.map +1 -0
- package/dist/partner/in-memory.d.cts +99 -0
- package/dist/partner/in-memory.d.cts.map +1 -0
- package/dist/partner/in-memory.d.ts +99 -0
- package/dist/partner/in-memory.d.ts.map +1 -0
- package/dist/partner/in-memory.js +135 -0
- package/dist/partner/in-memory.js.map +1 -0
- package/dist/partner/index.cjs +18 -0
- package/dist/partner/index.d.cts +23 -0
- package/dist/partner/index.d.cts.map +1 -0
- package/dist/partner/index.d.ts +23 -0
- package/dist/partner/index.d.ts.map +1 -0
- package/dist/partner/index.js +7 -0
- package/dist/partner/raw.cjs +392 -0
- package/dist/partner/raw.cjs.map +1 -0
- package/dist/partner/raw.d.cts +223 -0
- package/dist/partner/raw.d.cts.map +1 -0
- package/dist/partner/raw.d.ts +223 -0
- package/dist/partner/raw.d.ts.map +1 -0
- package/dist/partner/raw.js +390 -0
- package/dist/partner/raw.js.map +1 -0
- package/dist/partner/redaction-placeholders.cjs +10 -0
- package/dist/partner/redaction-placeholders.cjs.map +1 -0
- package/dist/partner/redaction-placeholders.d.cts +5 -0
- package/dist/partner/redaction-placeholders.d.cts.map +1 -0
- package/dist/partner/redaction-placeholders.d.ts +5 -0
- package/dist/partner/redaction-placeholders.d.ts.map +1 -0
- package/dist/partner/redaction-placeholders.js +9 -0
- package/dist/partner/redaction-placeholders.js.map +1 -0
- package/dist/partner/redaction.cjs +267 -0
- package/dist/partner/redaction.cjs.map +1 -0
- package/dist/partner/redaction.d.cts +124 -0
- package/dist/partner/redaction.d.cts.map +1 -0
- package/dist/partner/redaction.d.ts +124 -0
- package/dist/partner/redaction.d.ts.map +1 -0
- package/dist/partner/redaction.js +257 -0
- package/dist/partner/redaction.js.map +1 -0
- package/dist/raw/index.cjs +81 -19
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +6 -2
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +6 -2
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +81 -19
- package/dist/raw/index.js.map +1 -1
- package/dist/raw/url.cjs +111 -0
- package/dist/raw/url.cjs.map +1 -0
- package/dist/raw/url.d.cts +41 -0
- package/dist/raw/url.d.cts.map +1 -0
- package/dist/raw/url.d.ts +41 -0
- package/dist/raw/url.d.ts.map +1 -0
- package/dist/raw/url.js +110 -0
- package/dist/raw/url.js.map +1 -0
- package/dist/s3/sigv4.cjs +15 -10
- package/dist/s3/sigv4.cjs.map +1 -1
- package/dist/s3/sigv4.js +15 -10
- package/dist/s3/sigv4.js.map +1 -1
- package/dist/simulator/index.cjs +1197 -206
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +109 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +109 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +1196 -209
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/partner.cjs +719 -0
- package/dist/simulator/partner.cjs.map +1 -0
- package/dist/simulator/partner.d.cts +183 -0
- package/dist/simulator/partner.d.cts.map +1 -0
- package/dist/simulator/partner.d.ts +183 -0
- package/dist/simulator/partner.d.ts.map +1 -0
- package/dist/simulator/partner.js +718 -0
- package/dist/simulator/partner.js.map +1 -0
- package/dist/simulator/validation.cjs +577 -0
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +117 -0
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +117 -0
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +563 -1
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/file-source.cjs +1 -1
- package/dist/streams/file-source.cjs.map +1 -1
- package/dist/streams/file-source.js +1 -1
- package/dist/streams/file-source.js.map +1 -1
- package/dist/streams/index.cjs +1 -1
- package/dist/streams/index.js +1 -1
- package/dist/streams/source.cjs +2 -1
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.js +2 -1
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +6 -2
- package/dist/sync/b2-sha1-reader.cjs.map +1 -1
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -1
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -1
- package/dist/sync/b2-sha1-reader.js +6 -2
- package/dist/sync/b2-sha1-reader.js.map +1 -1
- package/dist/sync/download-staging.cjs +11 -10
- package/dist/sync/download-staging.cjs.map +1 -1
- package/dist/sync/download-staging.d.cts +2 -1
- package/dist/sync/download-staging.d.cts.map +1 -1
- package/dist/sync/download-staging.d.ts +2 -1
- package/dist/sync/download-staging.d.ts.map +1 -1
- package/dist/sync/download-staging.js +11 -10
- package/dist/sync/download-staging.js.map +1 -1
- package/dist/sync/filters.cjs.map +1 -1
- package/dist/sync/filters.js.map +1 -1
- package/dist/sync/local-file-io.cjs +11 -6
- package/dist/sync/local-file-io.cjs.map +1 -1
- package/dist/sync/local-file-io.d.cts +1 -0
- package/dist/sync/local-file-io.d.cts.map +1 -1
- package/dist/sync/local-file-io.d.ts +1 -0
- package/dist/sync/local-file-io.d.ts.map +1 -1
- package/dist/sync/local-file-io.js +11 -6
- package/dist/sync/local-file-io.js.map +1 -1
- package/dist/sync/local-sha1.cjs +6 -15
- package/dist/sync/local-sha1.cjs.map +1 -1
- package/dist/sync/local-sha1.d.cts +0 -8
- package/dist/sync/local-sha1.d.cts.map +1 -1
- package/dist/sync/local-sha1.d.ts +0 -8
- package/dist/sync/local-sha1.d.ts.map +1 -1
- package/dist/sync/local-sha1.js +7 -15
- package/dist/sync/local-sha1.js.map +1 -1
- package/dist/sync/policies/compare.cjs +5 -3
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +6 -4
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +4 -10
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.js +4 -10
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/scanners/b2.cjs +2 -2
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.js +2 -2
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/synchronizer.cjs +3 -2
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.js +3 -2
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/types/auth.cjs +4 -0
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +4 -0
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +4 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +4 -0
- package/dist/types/auth.js.map +1 -1
- package/dist/types/backup.d.cts +80 -0
- package/dist/types/backup.d.cts.map +1 -0
- package/dist/types/backup.d.ts +80 -0
- package/dist/types/backup.d.ts.map +1 -0
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.d.cts +4 -2
- package/dist/types/bucket.d.cts.map +1 -1
- package/dist/types/bucket.d.ts +4 -2
- package/dist/types/bucket.d.ts.map +1 -1
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/download.cjs +62 -0
- package/dist/types/download.cjs.map +1 -0
- package/dist/types/download.d.cts +98 -0
- package/dist/types/download.d.cts.map +1 -1
- package/dist/types/download.d.ts +98 -0
- package/dist/types/download.d.ts.map +1 -1
- package/dist/types/download.js +61 -0
- package/dist/types/download.js.map +1 -0
- package/dist/types/encryption.cjs +58 -229
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +32 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +32 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +56 -229
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +9 -0
- package/dist/types/errors.cjs.map +1 -1
- package/dist/types/errors.d.cts +1 -1
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +1 -1
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +9 -0
- package/dist/types/errors.js.map +1 -1
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +15 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +15 -2
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +30 -0
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.d.cts +32 -0
- package/dist/types/ids.d.cts.map +1 -1
- package/dist/types/ids.d.ts +32 -0
- package/dist/types/ids.d.ts.map +1 -1
- package/dist/types/ids.js +28 -1
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +10 -6
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +10 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.d.cts +14 -0
- package/dist/types/lock.d.cts.map +1 -1
- package/dist/types/lock.d.ts +14 -0
- package/dist/types/lock.d.ts.map +1 -1
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +1 -1
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.d.cts +5 -3
- package/dist/types/notifications.d.cts.map +1 -1
- package/dist/types/notifications.d.ts +5 -3
- package/dist/types/notifications.d.ts.map +1 -1
- package/dist/types/notifications.js +1 -1
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/partner.cjs +32 -0
- package/dist/types/partner.cjs.map +1 -0
- package/dist/types/partner.d.cts +394 -0
- package/dist/types/partner.d.cts.map +1 -0
- package/dist/types/partner.d.ts +394 -0
- package/dist/types/partner.d.ts.map +1 -0
- package/dist/types/partner.js +29 -0
- package/dist/types/partner.js.map +1 -0
- package/dist/types/upload.d.cts +31 -18
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +31 -18
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +0 -45
- package/dist/upload/abort-scope.cjs.map +1 -1
- package/dist/upload/abort-scope.d.cts +0 -22
- package/dist/upload/abort-scope.d.cts.map +1 -1
- package/dist/upload/abort-scope.d.ts +0 -22
- package/dist/upload/abort-scope.d.ts.map +1 -1
- package/dist/upload/abort-scope.js +1 -44
- package/dist/upload/abort-scope.js.map +1 -1
- package/dist/upload/finish.cjs +3 -8
- package/dist/upload/finish.cjs.map +1 -1
- package/dist/upload/finish.d.cts.map +1 -1
- package/dist/upload/finish.d.ts.map +1 -1
- package/dist/upload/finish.js +1 -6
- package/dist/upload/finish.js.map +1 -1
- package/dist/upload/large.cjs +5 -1
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +16 -2
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +16 -2
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +5 -1
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs.map +1 -1
- package/dist/upload/options.d.cts +12 -0
- package/dist/upload/options.d.cts.map +1 -1
- package/dist/upload/options.d.ts +12 -0
- package/dist/upload/options.d.ts.map +1 -1
- package/dist/upload/options.js.map +1 -1
- package/dist/upload/resume.cjs +2 -1
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +3 -1
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +3 -1
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +2 -1
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +8 -3
- package/dist/upload/retry.cjs.map +1 -1
- package/dist/upload/retry.js +8 -3
- package/dist/upload/retry.js.map +1 -1
- package/dist/upload/single.cjs +2 -1
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +6 -0
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +6 -0
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +2 -1
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +6 -4
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +6 -0
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +6 -0
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +3 -1
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/abort.cjs +114 -0
- package/dist/util/abort.cjs.map +1 -0
- package/dist/util/abort.d.cts +65 -0
- package/dist/util/abort.d.cts.map +1 -0
- package/dist/util/abort.d.ts +65 -0
- package/dist/util/abort.d.ts.map +1 -0
- package/dist/util/abort.js +109 -0
- package/dist/util/abort.js.map +1 -0
- package/dist/util/defaults.cjs +3 -0
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.d.cts +2 -0
- package/dist/util/defaults.d.cts.map +1 -1
- package/dist/util/defaults.d.ts +2 -0
- package/dist/util/defaults.d.ts.map +1 -1
- package/dist/util/defaults.js +3 -1
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/md5.cjs +211 -0
- package/dist/util/md5.cjs.map +1 -0
- package/dist/util/md5.d.cts +43 -0
- package/dist/util/md5.d.cts.map +1 -0
- package/dist/util/md5.d.ts +43 -0
- package/dist/util/md5.d.ts.map +1 -0
- package/dist/util/md5.js +209 -0
- package/dist/util/md5.js.map +1 -0
- package/dist/util/normalize.cjs +5 -5
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.d.cts +7 -7
- package/dist/util/normalize.d.cts.map +1 -1
- package/dist/util/normalize.d.ts +7 -7
- package/dist/util/normalize.d.ts.map +1 -1
- package/dist/util/normalize.js +5 -5
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +7 -1
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.d.cts +3 -1
- package/dist/util/paginator.d.cts.map +1 -1
- package/dist/util/paginator.d.ts +3 -1
- package/dist/util/paginator.d.ts.map +1 -1
- package/dist/util/paginator.js +7 -1
- package/dist/util/paginator.js.map +1 -1
- package/package.json +38 -16
package/dist/object.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.cjs","names":[],"sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport {\n type DownloadResult,\n downloadById,\n downloadByName,\n type HeadResult,\n headById,\n headByName,\n} from './download/single.ts'\nimport type { RetryOptions } from './http/retry.ts'\nimport { mergeUploadRetryOptions } from './internal/upload-retry-options.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { BucketRetentionPolicy } from './types/bucket.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport {\n type B2ObjectUploadOptions,\n type B2ObjectWriteStreamOptions,\n rejectSmallResumeFileId,\n stripResumeOnlyOptions,\n} from './upload/options.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { createWriteStream, type UploadWriteHandle } from './upload/stream.ts'\n\ninterface BucketDefaultRetentionSnapshot {\n readonly retention?: BucketRetentionPolicy\n readonly unreadable: boolean\n}\n\nfunction bucketDefaultRetentionSnapshot(info: Bucket['info']): BucketDefaultRetentionSnapshot {\n const fileLock = info.fileLockConfiguration\n if (!fileLock.isClientAuthorizedToRead) return { unreadable: true }\n if (fileLock.value === null) return { unreadable: false }\n return { retention: fileLock.value.defaultRetention, unreadable: false }\n}\n\nfunction resumeNeedsFreshBucketDefaults(options: B2ObjectUploadOptions): boolean {\n const resumeRequested = options.resume === true || options.resumeFileId !== undefined\n return (\n resumeRequested &&\n (options.serverSideEncryption === undefined || options.fileRetention === undefined)\n )\n}\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n private readonly uploadRetryOptions: RetryOptions\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n * @param uploadRetryOptions - Resolved client upload retry defaults.\n *\n * @internal\n */\n constructor(\n client: B2Client,\n bucket: Bucket,\n fileName: string,\n uploadRetryOptions: RetryOptions,\n ) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n this.uploadRetryOptions = uploadRetryOptions\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: B2ObjectUploadOptions): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry)\n\n if (isLarge) {\n const bucketInfo = resumeNeedsFreshBucketDefaults(options)\n ? await this.fetchFreshBucketInfo()\n : this.bucket.info\n const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo)\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n ...options,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,\n ...(bucketDefaultRetention.retention !== undefined\n ? { bucketDefaultRetention: bucketDefaultRetention.retention }\n : {}),\n ...(bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}),\n })\n }\n rejectSmallResumeFileId(options, 'B2Object.upload')\n const smallOptions = stripResumeOnlyOptions(options)\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n ...smallOptions,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n private async fetchFreshBucketInfo(): Promise<Bucket['info']> {\n const fresh = await this.client.listBuckets({ bucketId: this.bucket.id })\n const found = fresh[0]\n if (!found) throw new Error(`Bucket ${this.bucket.id} not found`)\n return found.info\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 8 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle {\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry)\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n ...(options ?? {}),\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"mappings":";;;;;;;;AAkCA,SAAS,+BAA+B,MAAsD;CAC5F,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,SAAS,0BAA0B,OAAO,EAAE,YAAY,KAAK;CAClE,IAAI,SAAS,UAAU,MAAM,OAAO,EAAE,YAAY,MAAM;CACxD,OAAO;EAAE,WAAW,SAAS,MAAM;EAAkB,YAAY;CAAM;AACzE;AAEA,SAAS,+BAA+B,SAAyC;CAE/E,QADwB,QAAQ,WAAW,QAAQ,QAAQ,iBAAiB,KAAA,OAGzE,QAAQ,yBAAyB,KAAA,KAAa,QAAQ,kBAAkB,KAAA;AAE7E;;;;;;;;;;;;;;AA8DA,IAAa,WAAb,MAAsB;;CAE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kBAAkB,KAAK,UAAU,MAAM;CAC3D;;;;;;;;;;;;;;;;;;CAmBA,MAAM,aACJ,QACA,WACA,SACA;EACA,OAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,WAAW,OAAO;CAClF;;;;;;;;;;;;;;CAeA,MAAM,aAAa,QAAgB,WAA2B;EAC5D,OAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,SAAS;CACzE;AACF"}
|
|
1
|
+
{"version":3,"file":"object.cjs","names":[],"sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport {\n type DownloadResult,\n downloadById,\n downloadByName,\n type HeadResult,\n headById,\n headByName,\n} from './download/single.ts'\nimport type { RetryOptions } from './http/retry.ts'\nimport { mergeUploadRetryOptions } from './internal/upload-retry-options.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { BucketRetentionPolicy } from './types/bucket.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport {\n type B2ObjectUploadOptions,\n type B2ObjectWriteStreamOptions,\n rejectSmallResumeFileId,\n stripResumeOnlyOptions,\n} from './upload/options.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { createWriteStream, type UploadWriteHandle } from './upload/stream.ts'\n\ninterface BucketDefaultRetentionSnapshot {\n readonly retention?: BucketRetentionPolicy\n readonly unreadable: boolean\n}\n\nfunction bucketDefaultRetentionSnapshot(info: Bucket['info']): BucketDefaultRetentionSnapshot {\n const fileLock = info.fileLockConfiguration\n if (!fileLock.isClientAuthorizedToRead) return { unreadable: true }\n if (fileLock.value === null) return { unreadable: false }\n return { retention: fileLock.value.defaultRetention, unreadable: false }\n}\n\nfunction resumeNeedsFreshBucketDefaults(options: B2ObjectUploadOptions): boolean {\n const resumeRequested = options.resume === true || options.resumeFileId !== undefined\n return (\n resumeRequested &&\n (options.serverSideEncryption === undefined || options.fileRetention === undefined)\n )\n}\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n private readonly uploadRetryOptions: RetryOptions\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n * @param uploadRetryOptions - Resolved client upload retry defaults.\n *\n * @internal\n */\n constructor(\n client: B2Client,\n bucket: Bucket,\n fileName: string,\n uploadRetryOptions: RetryOptions,\n ) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n this.uploadRetryOptions = uploadRetryOptions\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: B2ObjectUploadOptions): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry)\n\n if (isLarge) {\n const bucketInfo = resumeNeedsFreshBucketDefaults(options)\n ? await this.fetchFreshBucketInfo()\n : this.bucket.info\n const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo)\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n ...options,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,\n ...(bucketDefaultRetention.retention !== undefined\n ? { bucketDefaultRetention: bucketDefaultRetention.retention }\n : {}),\n ...(bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}),\n })\n }\n rejectSmallResumeFileId(options, 'B2Object.upload')\n const smallOptions = stripResumeOnlyOptions(options)\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n ...smallOptions,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n private async fetchFreshBucketInfo(): Promise<Bucket['info']> {\n const fresh = await this.client.listBuckets({ bucketId: this.bucket.id })\n const found = fresh[0]\n if (!found) throw new Error(`Bucket ${this.bucket.id} not found`)\n return found.info\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, SSE-C decryption, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 10 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n serverSideEncryption?: SseCDownloadKey\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle {\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry)\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n ...(options ?? {}),\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"mappings":";;;;;;;;AAkCA,SAAS,+BAA+B,MAAsD;CAC5F,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,SAAS,0BAA0B,OAAO,EAAE,YAAY,KAAK;CAClE,IAAI,SAAS,UAAU,MAAM,OAAO,EAAE,YAAY,MAAM;CACxD,OAAO;EAAE,WAAW,SAAS,MAAM;EAAkB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KAAK,OAAO,YAAY,UAAU,GAClC,KAAK,OAAO,YAAY,aAAa,GACrC,EAAE,OAAO,CACX;CACF;;;;;;CAOA,MAAM,OAA6B;EACjC,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ;CAC3C;;;;;CAMA,MAAM,cAAc,QAA+B;EACjD,MAAM,KAAK,OAAO,kBAAkB,KAAK,UAAU,MAAM;CAC3D;;;;;;;;;;;;;;;;;;CAmBA,MAAM,aACJ,QACA,WACA,SACA;EACA,OAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,WAAW,OAAO;CAClF;;;;;;;;;;;;;;CAeA,MAAM,aAAa,QAAgB,WAA2B;EAC5D,OAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,SAAS;CACzE;AACF"}
|
package/dist/object.d.cts
CHANGED
|
@@ -135,15 +135,17 @@ export declare class B2Object {
|
|
|
135
135
|
* Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.
|
|
136
136
|
* @param fileId - The file version ID to download.
|
|
137
137
|
* @param totalSize - Total file size in bytes (needed to compute range boundaries).
|
|
138
|
-
* @param options - Concurrency, range size, and abort signal.
|
|
138
|
+
* @param options - Concurrency, range size, SSE-C decryption, and abort signal.
|
|
139
139
|
*
|
|
140
140
|
* @returns A Web ReadableStream of file data in sequential order.
|
|
141
141
|
*/
|
|
142
142
|
createReadStream(fileId: FileId, totalSize: number, options?: {
|
|
143
|
-
/** Size of each ranged GET request in bytes. Defaults to
|
|
143
|
+
/** Size of each ranged GET request in bytes. Defaults to 10 MB. */
|
|
144
144
|
rangeSize?: number;
|
|
145
145
|
/** Number of concurrent range requests. Defaults to 4. */
|
|
146
146
|
concurrency?: number;
|
|
147
|
+
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
148
|
+
serverSideEncryption?: SseCDownloadKey;
|
|
147
149
|
/** Abort signal for cancelling the download. */
|
|
148
150
|
signal?: AbortSignal;
|
|
149
151
|
}): ReadableStream<Uint8Array>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ist/object.d.ts
CHANGED
|
@@ -135,15 +135,17 @@ export declare class B2Object {
|
|
|
135
135
|
* Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.
|
|
136
136
|
* @param fileId - The file version ID to download.
|
|
137
137
|
* @param totalSize - Total file size in bytes (needed to compute range boundaries).
|
|
138
|
-
* @param options - Concurrency, range size, and abort signal.
|
|
138
|
+
* @param options - Concurrency, range size, SSE-C decryption, and abort signal.
|
|
139
139
|
*
|
|
140
140
|
* @returns A Web ReadableStream of file data in sequential order.
|
|
141
141
|
*/
|
|
142
142
|
createReadStream(fileId: FileId, totalSize: number, options?: {
|
|
143
|
-
/** Size of each ranged GET request in bytes. Defaults to
|
|
143
|
+
/** Size of each ranged GET request in bytes. Defaults to 10 MB. */
|
|
144
144
|
rangeSize?: number;
|
|
145
145
|
/** Number of concurrent range requests. Defaults to 4. */
|
|
146
146
|
concurrency?: number;
|
|
147
|
+
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
148
|
+
serverSideEncryption?: SseCDownloadKey;
|
|
147
149
|
/** Abort signal for cancelling the download. */
|
|
148
150
|
signal?: AbortSignal;
|
|
149
151
|
}): ReadableStream<Uint8Array>;
|
package/dist/object.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../src/object.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,OAAO,K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W,CAAC,EAAE,MAAM,CAAA;QACpB,iFAAiF;QACjF,oBAAoB,CAAC,EAAE,eAAe,CAAA;QACtC,gDAAgD;QAChD,MAAM,CAAC,EAAE,WAAW,CAAA;KACrB,GACA,cAAc,CAAC,UAAU,CAAC;IAQ7B;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,iBAAiB;IAU1E;;;;;OAKG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAQvD;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC;IAIlC;;;OAGG;IACG,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;;;;;;;;;;;;;;OAgBG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,kBAAkB,EAC7B,OAAO,CAAC,EAAE;QAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE;IAK1C;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc;CAG7D"}
|
package/dist/object.js
CHANGED
|
@@ -155,7 +155,7 @@ var B2Object = class {
|
|
|
155
155
|
* Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.
|
|
156
156
|
* @param fileId - The file version ID to download.
|
|
157
157
|
* @param totalSize - Total file size in bytes (needed to compute range boundaries).
|
|
158
|
-
* @param options - Concurrency, range size, and abort signal.
|
|
158
|
+
* @param options - Concurrency, range size, SSE-C decryption, and abort signal.
|
|
159
159
|
*
|
|
160
160
|
* @returns A Web ReadableStream of file data in sequential order.
|
|
161
161
|
*/
|
package/dist/object.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","names":[],"sources":["../src/object.ts"],"sourcesContent":["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport {\n type DownloadResult,\n downloadById,\n downloadByName,\n type HeadResult,\n headById,\n headByName,\n} from './download/single.ts'\nimport type { RetryOptions } from './http/retry.ts'\nimport { mergeUploadRetryOptions } from './internal/upload-retry-options.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { BucketRetentionPolicy } from './types/bucket.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport {\n type B2ObjectUploadOptions,\n type B2ObjectWriteStreamOptions,\n rejectSmallResumeFileId,\n stripResumeOnlyOptions,\n} from './upload/options.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { createWriteStream, type UploadWriteHandle } from './upload/stream.ts'\n\ninterface BucketDefaultRetentionSnapshot {\n readonly retention?: BucketRetentionPolicy\n readonly unreadable: boolean\n}\n\nfunction bucketDefaultRetentionSnapshot(info: Bucket['info']): BucketDefaultRetentionSnapshot {\n const fileLock = info.fileLockConfiguration\n if (!fileLock.isClientAuthorizedToRead) return { unreadable: true }\n if (fileLock.value === null) return { unreadable: false }\n return { retention: fileLock.value.defaultRetention, unreadable: false }\n}\n\nfunction resumeNeedsFreshBucketDefaults(options: B2ObjectUploadOptions): boolean {\n const resumeRequested = options.resume === true || options.resumeFileId !== undefined\n return (\n resumeRequested &&\n (options.serverSideEncryption === undefined || options.fileRetention === undefined)\n )\n}\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n private readonly uploadRetryOptions: RetryOptions\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n * @param uploadRetryOptions - Resolved client upload retry defaults.\n *\n * @internal\n */\n constructor(\n client: B2Client,\n bucket: Bucket,\n fileName: string,\n uploadRetryOptions: RetryOptions,\n ) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n this.uploadRetryOptions = uploadRetryOptions\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: B2ObjectUploadOptions): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry)\n\n if (isLarge) {\n const bucketInfo = resumeNeedsFreshBucketDefaults(options)\n ? await this.fetchFreshBucketInfo()\n : this.bucket.info\n const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo)\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n ...options,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,\n ...(bucketDefaultRetention.retention !== undefined\n ? { bucketDefaultRetention: bucketDefaultRetention.retention }\n : {}),\n ...(bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}),\n })\n }\n rejectSmallResumeFileId(options, 'B2Object.upload')\n const smallOptions = stripResumeOnlyOptions(options)\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n ...smallOptions,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n private async fetchFreshBucketInfo(): Promise<Bucket['info']> {\n const fresh = await this.client.listBuckets({ bucketId: this.bucket.id })\n const found = fresh[0]\n if (!found) throw new Error(`Bucket ${this.bucket.id} not found`)\n return found.info\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 8 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle {\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry)\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n ...(options ?? {}),\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"mappings":";;;;;;;;AAkCA,SAAS,+BAA+B,MAAsD;CAC5F,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,SAAS,0BAA0B,OAAO,EAAE,YAAY,KAAK;CAClE,IAAI,SAAS,UAAU,MAAM,OAAO,EAAE,YAAY,MAAM;CACxD,OAAO;EAAE,WAAW,SAAS,MAAM;EAAkB,YAAY;CAAM;AACzE;AAEA,SAAS,+BAA+B,SAAyC;CAE/E,QADwB,QAAQ,WAAW,QAAQ,QAAQ,iBAAiB,KAAA,OAGzE,QAAQ,yBAAyB,KAAA,KAAa,QAAQ,kBAAkB,KAAA;AAE7E;;;;;;;;;;;;;;AA8DA,IAAa,WAAb,MAAsB;;CAEpB;CACA;CACA;CACA;;;;;;;;;CAUA,YACE,QACA,QACA,UACA,oBACA;EACA,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,qBAAqB;CAC5B;;;;;;;CAQA,MAAM,OAAO,SAAsD;EACjE,MAAM,sBAAsB,KAAK,OAAO,YAAY,uBAAuB;EAC3E,MAAM,UAAU,QAAQ,OAAO,OAAO;EAC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["import type { Bucket } from './bucket.ts'\nimport type { B2Client } from './client.ts'\nimport { createParallelDownloadStream } from './download/parallel.ts'\nimport {\n type DownloadResult,\n downloadById,\n downloadByName,\n type HeadResult,\n headById,\n headByName,\n} from './download/single.ts'\nimport type { RetryOptions } from './http/retry.ts'\nimport { mergeUploadRetryOptions } from './internal/upload-retry-options.ts'\nimport type { SseCDownloadKey } from './raw/index.ts'\nimport type { ProgressListener } from './streams/progress.ts'\nimport type { BucketRetentionPolicy } from './types/bucket.ts'\nimport type { FileVersion } from './types/file.ts'\nimport type { FileId } from './types/ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './types/lock.ts'\nimport { uploadLargeFile } from './upload/large.ts'\nimport {\n type B2ObjectUploadOptions,\n type B2ObjectWriteStreamOptions,\n rejectSmallResumeFileId,\n stripResumeOnlyOptions,\n} from './upload/options.ts'\nimport { uploadSmallFile } from './upload/single.ts'\nimport { createWriteStream, type UploadWriteHandle } from './upload/stream.ts'\n\ninterface BucketDefaultRetentionSnapshot {\n readonly retention?: BucketRetentionPolicy\n readonly unreadable: boolean\n}\n\nfunction bucketDefaultRetentionSnapshot(info: Bucket['info']): BucketDefaultRetentionSnapshot {\n const fileLock = info.fileLockConfiguration\n if (!fileLock.isClientAuthorizedToRead) return { unreadable: true }\n if (fileLock.value === null) return { unreadable: false }\n return { retention: fileLock.value.defaultRetention, unreadable: false }\n}\n\nfunction resumeNeedsFreshBucketDefaults(options: B2ObjectUploadOptions): boolean {\n const resumeRequested = options.resume === true || options.resumeFileId !== undefined\n return (\n resumeRequested &&\n (options.serverSideEncryption === undefined || options.fileRetention === undefined)\n )\n}\n\n/** Options accepted by {@link B2Object.download} and {@link B2Object.downloadById}. */\nexport interface DownloadCallOptions {\n /**\n * HTTP method. Defaults to `'GET'`. Use `'HEAD'` to fetch only\n * response headers. Prefer the dedicated {@link B2Object.head} /\n * {@link Bucket.head} method over this option — those return a\n * body-less result so callers never have to remember to drain the\n * empty body of a HEAD response.\n */\n readonly method?: 'GET' | 'HEAD'\n /** HTTP Range header value (e.g., `\"bytes=0-999\"`). */\n readonly range?: string\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n readonly serverSideEncryption?: SseCDownloadKey\n /** Override the response `Content-Disposition` header. */\n readonly b2ContentDisposition?: string\n /** Override the response `Content-Language` header. */\n readonly b2ContentLanguage?: string\n /** Override the response `Content-Encoding` header. */\n readonly b2ContentEncoding?: string\n /** Override the response `Content-Type` header. */\n readonly b2ContentType?: string\n /** Override the response `Cache-Control` header. */\n readonly b2CacheControl?: string\n /** Override the response `Expires` header. */\n readonly b2Expires?: string\n /** Abort signal for cancelling the download. */\n readonly signal?: AbortSignal\n /**\n * Callback invoked as the response body is consumed.\n *\n * Progress is byte-driven, not request-driven: the callback fires per\n * chunk as the caller reads the returned `body` stream, and the final\n * `partsCompleted: 1` event only fires once the stream is read to\n * completion. Downloads that are dropped or aborted partway through\n * will NOT emit a `completePart()` event.\n */\n readonly onProgress?: ProgressListener\n}\n\n/**\n * Options accepted by {@link B2Object.head} / {@link Bucket.head}.\n * Same shape as {@link DownloadCallOptions} minus `method` (always\n * HEAD) and `onProgress` (no body to track).\n */\nexport type HeadCallOptions = Omit<DownloadCallOptions, 'method' | 'onProgress'>\n\n/**\n * Handle to a specific file (by name) within a B2 bucket.\n *\n * Provides file-scoped upload, download, and management operations.\n * Obtained via {@link Bucket.file}.\n *\n * @example\n * ```ts\n * const obj = bucket.file('photos/2026/sunset.jpg')\n * await obj.upload({ source: new BufferSource(data) })\n * const result = await obj.download()\n * ```\n */\nexport class B2Object {\n /** The file name (path) within the bucket. */\n readonly fileName: string\n private readonly client: B2Client\n private readonly bucket: Bucket\n private readonly uploadRetryOptions: RetryOptions\n\n /**\n * @param client - The parent B2Client instance.\n * @param bucket - The parent Bucket this object belongs to.\n * @param fileName - The file path within the bucket.\n * @param uploadRetryOptions - Resolved client upload retry defaults.\n *\n * @internal\n */\n constructor(\n client: B2Client,\n bucket: Bucket,\n fileName: string,\n uploadRetryOptions: RetryOptions,\n ) {\n this.client = client\n this.bucket = bucket\n this.fileName = fileName\n this.uploadRetryOptions = uploadRetryOptions\n }\n\n /**\n * Uploads data to this file name. Automatically uses multipart upload for large files.\n * @param options - Upload configuration including data source and optional settings.\n *\n * @returns Metadata for the uploaded file version.\n */\n async upload(options: B2ObjectUploadOptions): Promise<FileVersion> {\n const recommendedPartSize = this.client.accountInfo.getRecommendedPartSize()\n const isLarge = options.source.size > recommendedPartSize\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options.retry)\n\n if (isLarge) {\n const bucketInfo = resumeNeedsFreshBucketDefaults(options)\n ? await this.fetchFreshBucketInfo()\n : this.bucket.info\n const bucketDefaultRetention = bucketDefaultRetentionSnapshot(bucketInfo)\n return uploadLargeFile(this.client.raw, this.client.accountInfo, {\n ...options,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n bucketDefaultServerSideEncryption: bucketInfo.defaultServerSideEncryption,\n ...(bucketDefaultRetention.retention !== undefined\n ? { bucketDefaultRetention: bucketDefaultRetention.retention }\n : {}),\n ...(bucketDefaultRetention.unreadable ? { bucketDefaultRetentionUnreadable: true } : {}),\n })\n }\n rejectSmallResumeFileId(options, 'B2Object.upload')\n const smallOptions = stripResumeOnlyOptions(options)\n return uploadSmallFile(this.client.raw, this.client.accountInfo, {\n ...smallOptions,\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n private async fetchFreshBucketInfo(): Promise<Bucket['info']> {\n const fresh = await this.client.listBuckets({ bucketId: this.bucket.id })\n const found = fresh[0]\n if (!found) throw new Error(`Bucket ${this.bucket.id} not found`)\n return found.info\n }\n\n /**\n * Downloads this file by name. Pass `method: 'HEAD'` to fetch only the\n * response headers (file metadata) without streaming the body.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async download(options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for this file via HTTP HEAD. Returns a\n * body-less result so callers never have to drain the (logically\n * empty) HEAD body themselves.\n *\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal. Same shape as {@link B2Object.download}'s\n * options minus `method` (always HEAD) and `onProgress` (no body).\n *\n * @returns Parsed download headers (content type, SHA-1, file info, etc.).\n */\n async head(options?: HeadCallOptions): Promise<HeadResult> {\n return headByName(this.client.raw, this.client.accountInfo, {\n bucketName: this.bucket.name,\n fileName: this.fileName,\n ...options,\n })\n }\n\n /**\n * Downloads a specific version of this file by ID. Pass `method: 'HEAD'`\n * to fetch only the response headers (file metadata) without streaming the body.\n * @param fileId - The file version ID to download.\n * @param options - Optional method, range, SSE-C decryption, response-header overrides, and abort signal.\n *\n * @returns The download result with response headers and body stream.\n */\n async downloadById(fileId: FileId, options?: DownloadCallOptions): Promise<DownloadResult> {\n return downloadById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Fetches response headers for a specific version of this file by ID\n * via HTTP HEAD. Returns a body-less result so callers never have to\n * drain the (logically empty) HEAD body themselves.\n *\n * @param fileId - The file version ID to inspect.\n * @param options - Optional range, SSE-C decryption, response-header\n * overrides, and abort signal.\n *\n * @returns Parsed download headers.\n */\n async headById(fileId: FileId, options?: HeadCallOptions): Promise<HeadResult> {\n return headById(this.client.raw, this.client.accountInfo, {\n fileId,\n ...options,\n })\n }\n\n /**\n * Creates a parallel-download ReadableStream that fetches the file in concurrent ranged chunks.\n * @param fileId - The file version ID to download.\n * @param totalSize - Total file size in bytes (needed to compute range boundaries).\n * @param options - Concurrency, range size, SSE-C decryption, and abort signal.\n *\n * @returns A Web ReadableStream of file data in sequential order.\n */\n createReadStream(\n fileId: FileId,\n totalSize: number,\n options?: {\n /** Size of each ranged GET request in bytes. Defaults to 10 MB. */\n rangeSize?: number\n /** Number of concurrent range requests. Defaults to 4. */\n concurrency?: number\n /** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */\n serverSideEncryption?: SseCDownloadKey\n /** Abort signal for cancelling the download. */\n signal?: AbortSignal\n },\n ): ReadableStream<Uint8Array> {\n return createParallelDownloadStream(this.client.raw, this.client.accountInfo, {\n fileId,\n totalSize,\n ...options,\n })\n }\n\n /**\n * Creates a Web `WritableStream` that uploads streamed data into this file\n * using the multipart protocol. Pipe a `ReadableStream<Uint8Array>` into the\n * returned `writable` and await `done` to get the final {@link FileVersion}.\n *\n * Note: streaming uploads do not support resume because the size and per-part\n * hashes are not known in advance. Use {@link upload} with a buffered source\n * when resume is required.\n *\n * @param options - Streaming upload parameters (part size, concurrency, encryption).\n *\n * @returns A handle with the writable sink and a completion promise.\n */\n createWriteStream(options?: B2ObjectWriteStreamOptions): UploadWriteHandle {\n const uploadRetryOptions = mergeUploadRetryOptions(this.uploadRetryOptions, options?.retry)\n return createWriteStream(this.client.raw, this.client.accountInfo, {\n ...(options ?? {}),\n bucketId: this.bucket.id,\n fileName: this.fileName,\n retry: uploadRetryOptions,\n })\n }\n\n /**\n * Retrieves metadata for a specific file version.\n * @param fileId - The file version ID to look up.\n *\n * @returns The file version metadata.\n */\n async getFileInfo(fileId: FileId): Promise<FileVersion> {\n return this.client.raw.getFileInfo(\n this.client.accountInfo.getApiUrl(),\n this.client.accountInfo.getAuthToken(),\n { fileId },\n )\n }\n\n /**\n * Hides this file by creating a hide marker at this file name.\n *\n * @returns Metadata for the newly created hide marker.\n */\n async hide(): Promise<FileVersion> {\n return this.bucket.hideFile(this.fileName)\n }\n\n /**\n * Permanently deletes a specific version of this file.\n * @param fileId - The unique identifier of the file version to delete.\n */\n async deleteVersion(fileId: FileId): Promise<void> {\n await this.bucket.deleteFileVersion(this.fileName, fileId)\n }\n\n /**\n * Sets or updates the Object Lock retention policy on a specific file\n * version of this file.\n *\n * The bucket must have Object Lock enabled (`fileLockEnabled: true` at\n * creation time). Governance-mode retention can be shortened or removed\n * by passing `bypassGovernance: true` together with an application key\n * that carries the `bypassGovernance` capability; compliance-mode\n * retention cannot be shortened by anyone until the\n * `retainUntilTimestamp` elapses.\n *\n * @param fileId - The file version to apply the policy to.\n * @param retention - The retention policy to apply.\n * @param options - Optional flag for shortening governance-mode retention.\n *\n * @returns Metadata for the updated file version.\n */\n async setRetention(\n fileId: FileId,\n retention: FileRetentionValue,\n options?: { bypassGovernance?: boolean },\n ) {\n return this.bucket.updateFileRetention(this.fileName, fileId, retention, options)\n }\n\n /**\n * Toggles the legal hold flag on a specific file version of this file.\n *\n * Legal hold is independent of retention: a file can be on legal hold\n * without any retention policy, and vice versa. The bucket must have\n * Object Lock enabled, and any caller must hold the `writeFileLegalHolds`\n * capability.\n *\n * @param fileId - The file version to apply the flag to.\n * @param legalHold - `'on'` to apply the hold, `'off'` to remove it.\n *\n * @returns Metadata for the updated file version.\n */\n async setLegalHold(fileId: FileId, legalHold: LegalHoldValue) {\n return this.bucket.updateFileLegalHold(this.fileName, fileId, legalHold)\n }\n}\n"],"mappings":";;;;;;;;AAkCA,SAAS,+BAA+B,MAAsD;CAC5F,MAAM,WAAW,KAAK;CACtB,IAAI,CAAC,SAAS,0BAA0B,OAAO,EAAE,YAAY,KAAK;CAClE,IAAI,SAAS,UAAU,MAAM,OAAO,EAAE,YAAY,MAAM;CACxD,OAAO;EAAE,WAAW,SAAS,MAAM;EAAkB,YAAY;CAAM;AACzE;AAEA,SAAS,+BAA+B,SAAyC;CAE/E,QADwB,QAAQ,WAAW,QAAQ,QAAQ,iBAAiB,KAAA,OAGzE,QAAQ,yBAAyB,KAAA,KAAa,QAAQ,kBAAkB,KAAA;AAE7E;;;;;;;;;;;;;;AA8DA,IAAa,WAAb,MAAsB;;CAEpB;CACA;CACA;CACA;;;;;;;;;CAUA,YACE,QACA,QACA,UACA,oBACA;EACA,KAAK,SAAS;EACd,KAAK,SAAS;EACd,KAAK,WAAW;EAChB,KAAK,qBAA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C5D,OAAO,KAAK,OAAO,oBAAoB,KAAK,UAAU,QAAQ,SAAS;CACzE;AACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AccountId, PartnerToken } from '../types/ids.js';
|
|
2
|
+
import { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stores Partner API and Computer Backup authorization state between requests.
|
|
5
|
+
*
|
|
6
|
+
* Reauthorization follows the storage client's `RetryTransport.onReauth`
|
|
7
|
+
* contract: re-run `PartnerRawClient.authorizePartner` with the same Master
|
|
8
|
+
* Application Key credentials, store the fresh response with `setAuth`, then
|
|
9
|
+
* return `authorizationToken` to the retry transport.
|
|
10
|
+
*
|
|
11
|
+
* Partner authorize responses redact `authorizationToken` when passed to
|
|
12
|
+
* `JSON.stringify`, so do not persist `getAuth()` with direct JSON serialization.
|
|
13
|
+
* For trusted durable caches, serialize the output of
|
|
14
|
+
* `partnerAuthorizeResponseForPersistence(getAuth())` into encrypted or
|
|
15
|
+
* otherwise credential-grade storage, or store `authorizationToken` directly in
|
|
16
|
+
* secure storage with the rest of the authorize response metadata.
|
|
17
|
+
*/
|
|
18
|
+
export interface PartnerAccountInfo {
|
|
19
|
+
/** Store a fresh Partner authorization response, replacing any previous state. */
|
|
20
|
+
setAuth(auth: PartnerAuthorizeResponse): void;
|
|
21
|
+
/**
|
|
22
|
+
* Return the current Partner authorization response, or null if not authorized.
|
|
23
|
+
*
|
|
24
|
+
* The returned object remains directly reusable with `setAuth()`, but
|
|
25
|
+
* `JSON.stringify` redacts its token and is not a persistence format.
|
|
26
|
+
*/
|
|
27
|
+
getAuth(): PartnerAuthorizeResponse | null;
|
|
28
|
+
/** Discard all cached Partner authorization state. */
|
|
29
|
+
clear(): void;
|
|
30
|
+
/** Current Partner/Backup authorization token. */
|
|
31
|
+
getPartnerToken(): PartnerToken;
|
|
32
|
+
/** Base URL for Partner API calls, or null when the suite is unavailable. */
|
|
33
|
+
getGroupsApiUrl(): string | null;
|
|
34
|
+
/** Base URL for Computer Backup API calls, or null when the suite is unavailable. */
|
|
35
|
+
getBackupApiUrl(): string | null;
|
|
36
|
+
/** The authorized partner administrator account ID. */
|
|
37
|
+
getAccountId(): AccountId;
|
|
38
|
+
/** Capabilities granted for Partner API calls, or null when the suite is unavailable. */
|
|
39
|
+
getGroupsCapabilities(): readonly PartnerCapability[] | null;
|
|
40
|
+
/** Capabilities granted for Computer Backup API calls, or null when the suite is unavailable. */
|
|
41
|
+
getBackupCapabilities(): readonly PartnerCapability[] | null;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=account-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-info.d.ts","sourceRoot":"","sources":["../../src/partner/account-info.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IAC7C;;;;;OAKG;IACH,OAAO,IAAI,wBAAwB,GAAG,IAAI,CAAA;IAC1C,sDAAsD;IACtD,KAAK,IAAI,IAAI,CAAA;IAEb,kDAAkD;IAClD,eAAe,IAAI,YAAY,CAAA;IAC/B,6EAA6E;IAC7E,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,qFAAqF;IACrF,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,uDAAuD;IACvD,YAAY,IAAI,SAAS,CAAA;IACzB,yFAAyF;IACzF,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;IAC5D,iGAAiG;IACjG,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;CAC7D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AccountId, PartnerToken } from '../types/ids.js';
|
|
2
|
+
import { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.js';
|
|
3
|
+
/**
|
|
4
|
+
* Stores Partner API and Computer Backup authorization state between requests.
|
|
5
|
+
*
|
|
6
|
+
* Reauthorization follows the storage client's `RetryTransport.onReauth`
|
|
7
|
+
* contract: re-run `PartnerRawClient.authorizePartner` with the same Master
|
|
8
|
+
* Application Key credentials, store the fresh response with `setAuth`, then
|
|
9
|
+
* return `authorizationToken` to the retry transport.
|
|
10
|
+
*
|
|
11
|
+
* Partner authorize responses redact `authorizationToken` when passed to
|
|
12
|
+
* `JSON.stringify`, so do not persist `getAuth()` with direct JSON serialization.
|
|
13
|
+
* For trusted durable caches, serialize the output of
|
|
14
|
+
* `partnerAuthorizeResponseForPersistence(getAuth())` into encrypted or
|
|
15
|
+
* otherwise credential-grade storage, or store `authorizationToken` directly in
|
|
16
|
+
* secure storage with the rest of the authorize response metadata.
|
|
17
|
+
*/
|
|
18
|
+
export interface PartnerAccountInfo {
|
|
19
|
+
/** Store a fresh Partner authorization response, replacing any previous state. */
|
|
20
|
+
setAuth(auth: PartnerAuthorizeResponse): void;
|
|
21
|
+
/**
|
|
22
|
+
* Return the current Partner authorization response, or null if not authorized.
|
|
23
|
+
*
|
|
24
|
+
* The returned object remains directly reusable with `setAuth()`, but
|
|
25
|
+
* `JSON.stringify` redacts its token and is not a persistence format.
|
|
26
|
+
*/
|
|
27
|
+
getAuth(): PartnerAuthorizeResponse | null;
|
|
28
|
+
/** Discard all cached Partner authorization state. */
|
|
29
|
+
clear(): void;
|
|
30
|
+
/** Current Partner/Backup authorization token. */
|
|
31
|
+
getPartnerToken(): PartnerToken;
|
|
32
|
+
/** Base URL for Partner API calls, or null when the suite is unavailable. */
|
|
33
|
+
getGroupsApiUrl(): string | null;
|
|
34
|
+
/** Base URL for Computer Backup API calls, or null when the suite is unavailable. */
|
|
35
|
+
getBackupApiUrl(): string | null;
|
|
36
|
+
/** The authorized partner administrator account ID. */
|
|
37
|
+
getAccountId(): AccountId;
|
|
38
|
+
/** Capabilities granted for Partner API calls, or null when the suite is unavailable. */
|
|
39
|
+
getGroupsCapabilities(): readonly PartnerCapability[] | null;
|
|
40
|
+
/** Capabilities granted for Computer Backup API calls, or null when the suite is unavailable. */
|
|
41
|
+
getBackupCapabilities(): readonly PartnerCapability[] | null;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=account-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-info.d.ts","sourceRoot":"","sources":["../../src/partner/account-info.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEtF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,kBAAkB;IACjC,kFAAkF;IAClF,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IAC7C;;;;;OAKG;IACH,OAAO,IAAI,wBAAwB,GAAG,IAAI,CAAA;IAC1C,sDAAsD;IACtD,KAAK,IAAI,IAAI,CAAA;IAEb,kDAAkD;IAClD,eAAe,IAAI,YAAY,CAAA;IAC/B,6EAA6E;IAC7E,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,qFAAqF;IACrF,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,uDAAuD;IACvD,YAAY,IAAI,SAAS,CAAA;IACzB,yFAAyF;IACzF,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;IAC5D,iGAAiG;IACjG,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAAA;CAC7D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const require_auth_shape = require("./auth-shape.cjs");
|
|
2
|
+
//#region src/partner/auth-clone.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns a hook-free Partner authorize response copy.
|
|
5
|
+
*
|
|
6
|
+
* @param auth - Partner authorization response to clone.
|
|
7
|
+
*
|
|
8
|
+
* @returns A plain object preserving the live Partner token.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function clonePartnerAuthorizeResponse(auth) {
|
|
13
|
+
require_auth_shape.validatePartnerAuthorizeResponseShape(auth);
|
|
14
|
+
const storageApi = auth.apiInfo.storageApi;
|
|
15
|
+
const groupsApi = auth.apiInfo.groupsApi;
|
|
16
|
+
const backupApi = auth.apiInfo.backupApi;
|
|
17
|
+
return {
|
|
18
|
+
accountId: auth.accountId,
|
|
19
|
+
authorizationToken: auth.authorizationToken,
|
|
20
|
+
apiInfo: {
|
|
21
|
+
...storageApi !== void 0 ? { storageApi: {
|
|
22
|
+
...storageApi,
|
|
23
|
+
capabilities: [...storageApi.capabilities]
|
|
24
|
+
} } : {},
|
|
25
|
+
...groupsApi !== void 0 ? { groupsApi: {
|
|
26
|
+
...groupsApi,
|
|
27
|
+
capabilities: [...groupsApi.capabilities],
|
|
28
|
+
infoType: "groupsApi"
|
|
29
|
+
} } : {},
|
|
30
|
+
...backupApi !== void 0 ? { backupApi: {
|
|
31
|
+
...backupApi,
|
|
32
|
+
capabilities: [...backupApi.capabilities],
|
|
33
|
+
infoType: "backupApi"
|
|
34
|
+
} } : {}
|
|
35
|
+
},
|
|
36
|
+
...groupsApi !== void 0 ? { groupsApiUrl: groupsApi.groupsApiUrl } : {},
|
|
37
|
+
...backupApi !== void 0 ? { backupApiUrl: backupApi.backupApiUrl } : {},
|
|
38
|
+
...groupsApi !== void 0 ? { groupsCapabilities: [...groupsApi.capabilities] } : {},
|
|
39
|
+
...backupApi !== void 0 ? { backupCapabilities: [...backupApi.capabilities] } : {},
|
|
40
|
+
applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a plain Partner authorize response copy for trusted auth-cache persistence.
|
|
45
|
+
*
|
|
46
|
+
* Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
|
|
47
|
+
* result can be serialized, parsed, and passed back to
|
|
48
|
+
* `PartnerAccountInfo.setAuth()`.
|
|
49
|
+
*
|
|
50
|
+
* The returned value is raw bearer-token material. Store it only in encrypted
|
|
51
|
+
* or otherwise credential-grade durable storage, and never log it.
|
|
52
|
+
*
|
|
53
|
+
* @param auth - Partner authorization response to persist.
|
|
54
|
+
*
|
|
55
|
+
* @returns A plain object with the live Partner token preserved.
|
|
56
|
+
*/
|
|
57
|
+
function partnerAuthorizeResponseForPersistence(auth) {
|
|
58
|
+
return clonePartnerAuthorizeResponse(auth);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.clonePartnerAuthorizeResponse = clonePartnerAuthorizeResponse;
|
|
62
|
+
exports.partnerAuthorizeResponseForPersistence = partnerAuthorizeResponseForPersistence;
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=auth-clone.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-clone.cjs","names":[],"sources":["../../src/partner/auth-clone.ts"],"sourcesContent":["import type { PartnerAuthorizeResponse } from '../types/partner.ts'\nimport { validatePartnerAuthorizeResponseShape } from './auth-shape.ts'\n\n/**\n * Returns a hook-free Partner authorize response copy.\n *\n * @param auth - Partner authorization response to clone.\n *\n * @returns A plain object preserving the live Partner token.\n *\n * @internal\n */\nexport function clonePartnerAuthorizeResponse(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n validatePartnerAuthorizeResponseShape(auth)\n\n const storageApi = auth.apiInfo.storageApi\n const groupsApi = auth.apiInfo.groupsApi\n const backupApi = auth.apiInfo.backupApi\n\n return {\n accountId: auth.accountId,\n authorizationToken: auth.authorizationToken,\n apiInfo: {\n ...(storageApi !== undefined\n ? {\n storageApi: {\n ...storageApi,\n capabilities: [...storageApi.capabilities],\n },\n }\n : {}),\n ...(groupsApi !== undefined\n ? {\n groupsApi: {\n ...groupsApi,\n capabilities: [...groupsApi.capabilities],\n infoType: 'groupsApi' as const,\n },\n }\n : {}),\n ...(backupApi !== undefined\n ? {\n backupApi: {\n ...backupApi,\n capabilities: [...backupApi.capabilities],\n infoType: 'backupApi' as const,\n },\n }\n : {}),\n },\n ...(groupsApi !== undefined ? { groupsApiUrl: groupsApi.groupsApiUrl } : {}),\n ...(backupApi !== undefined ? { backupApiUrl: backupApi.backupApiUrl } : {}),\n ...(groupsApi !== undefined ? { groupsCapabilities: [...groupsApi.capabilities] } : {}),\n ...(backupApi !== undefined ? { backupCapabilities: [...backupApi.capabilities] } : {}),\n applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp,\n }\n}\n\n/**\n * Returns a plain Partner authorize response copy for trusted auth-cache persistence.\n *\n * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the\n * result can be serialized, parsed, and passed back to\n * `PartnerAccountInfo.setAuth()`.\n *\n * The returned value is raw bearer-token material. Store it only in encrypted\n * or otherwise credential-grade durable storage, and never log it.\n *\n * @param auth - Partner authorization response to persist.\n *\n * @returns A plain object with the live Partner token preserved.\n */\nexport function partnerAuthorizeResponseForPersistence(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n return clonePartnerAuthorizeResponse(auth)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,8BACd,MAC0B;CAC1B,mBAAA,sCAAsC,IAAI;CAE1C,MAAM,aAAa,KAAK,QAAQ;CAChC,MAAM,YAAY,KAAK,QAAQ;CAC/B,MAAM,YAAY,KAAK,QAAQ;CAE/B,OAAO;EACL,WAAW,KAAK;EAChB,oBAAoB,KAAK;EACzB,SAAS;GACP,GAAI,eAAe,KAAA,IACf,EACE,YAAY;IACV,GAAG;IACH,cAAc,CAAC,GAAG,WAAW,YAAY;GAC3C,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;EACP;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,mCAAmC,KAAK;CAC1C;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,uCACd,MAC0B;CAC1B,OAAO,8BAA8B,IAAI;AAC3C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PartnerAuthorizeResponse } from '../types/partner.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a hook-free Partner authorize response copy.
|
|
4
|
+
*
|
|
5
|
+
* @param auth - Partner authorization response to clone.
|
|
6
|
+
*
|
|
7
|
+
* @returns A plain object preserving the live Partner token.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function clonePartnerAuthorizeResponse(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a plain Partner authorize response copy for trusted auth-cache persistence.
|
|
14
|
+
*
|
|
15
|
+
* Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
|
|
16
|
+
* result can be serialized, parsed, and passed back to
|
|
17
|
+
* `PartnerAccountInfo.setAuth()`.
|
|
18
|
+
*
|
|
19
|
+
* The returned value is raw bearer-token material. Store it only in encrypted
|
|
20
|
+
* or otherwise credential-grade durable storage, and never log it.
|
|
21
|
+
*
|
|
22
|
+
* @param auth - Partner authorization response to persist.
|
|
23
|
+
*
|
|
24
|
+
* @returns A plain object with the live Partner token preserved.
|
|
25
|
+
*/
|
|
26
|
+
export declare function partnerAuthorizeResponseForPersistence(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
|
|
27
|
+
//# sourceMappingURL=auth-clone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-clone.d.ts","sourceRoot":"","sources":["../../src/partner/auth-clone.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CA4C1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CAE1B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PartnerAuthorizeResponse } from '../types/partner.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a hook-free Partner authorize response copy.
|
|
4
|
+
*
|
|
5
|
+
* @param auth - Partner authorization response to clone.
|
|
6
|
+
*
|
|
7
|
+
* @returns A plain object preserving the live Partner token.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function clonePartnerAuthorizeResponse(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
|
|
12
|
+
/**
|
|
13
|
+
* Returns a plain Partner authorize response copy for trusted auth-cache persistence.
|
|
14
|
+
*
|
|
15
|
+
* Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
|
|
16
|
+
* result can be serialized, parsed, and passed back to
|
|
17
|
+
* `PartnerAccountInfo.setAuth()`.
|
|
18
|
+
*
|
|
19
|
+
* The returned value is raw bearer-token material. Store it only in encrypted
|
|
20
|
+
* or otherwise credential-grade durable storage, and never log it.
|
|
21
|
+
*
|
|
22
|
+
* @param auth - Partner authorization response to persist.
|
|
23
|
+
*
|
|
24
|
+
* @returns A plain object with the live Partner token preserved.
|
|
25
|
+
*/
|
|
26
|
+
export declare function partnerAuthorizeResponseForPersistence(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse;
|
|
27
|
+
//# sourceMappingURL=auth-clone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-clone.d.ts","sourceRoot":"","sources":["../../src/partner/auth-clone.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CA4C1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,wBAAwB,GAC7B,wBAAwB,CAE1B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { validatePartnerAuthorizeResponseShape } from "./auth-shape.js";
|
|
2
|
+
//#region src/partner/auth-clone.ts
|
|
3
|
+
/**
|
|
4
|
+
* Returns a hook-free Partner authorize response copy.
|
|
5
|
+
*
|
|
6
|
+
* @param auth - Partner authorization response to clone.
|
|
7
|
+
*
|
|
8
|
+
* @returns A plain object preserving the live Partner token.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function clonePartnerAuthorizeResponse(auth) {
|
|
13
|
+
validatePartnerAuthorizeResponseShape(auth);
|
|
14
|
+
const storageApi = auth.apiInfo.storageApi;
|
|
15
|
+
const groupsApi = auth.apiInfo.groupsApi;
|
|
16
|
+
const backupApi = auth.apiInfo.backupApi;
|
|
17
|
+
return {
|
|
18
|
+
accountId: auth.accountId,
|
|
19
|
+
authorizationToken: auth.authorizationToken,
|
|
20
|
+
apiInfo: {
|
|
21
|
+
...storageApi !== void 0 ? { storageApi: {
|
|
22
|
+
...storageApi,
|
|
23
|
+
capabilities: [...storageApi.capabilities]
|
|
24
|
+
} } : {},
|
|
25
|
+
...groupsApi !== void 0 ? { groupsApi: {
|
|
26
|
+
...groupsApi,
|
|
27
|
+
capabilities: [...groupsApi.capabilities],
|
|
28
|
+
infoType: "groupsApi"
|
|
29
|
+
} } : {},
|
|
30
|
+
...backupApi !== void 0 ? { backupApi: {
|
|
31
|
+
...backupApi,
|
|
32
|
+
capabilities: [...backupApi.capabilities],
|
|
33
|
+
infoType: "backupApi"
|
|
34
|
+
} } : {}
|
|
35
|
+
},
|
|
36
|
+
...groupsApi !== void 0 ? { groupsApiUrl: groupsApi.groupsApiUrl } : {},
|
|
37
|
+
...backupApi !== void 0 ? { backupApiUrl: backupApi.backupApiUrl } : {},
|
|
38
|
+
...groupsApi !== void 0 ? { groupsCapabilities: [...groupsApi.capabilities] } : {},
|
|
39
|
+
...backupApi !== void 0 ? { backupCapabilities: [...backupApi.capabilities] } : {},
|
|
40
|
+
applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a plain Partner authorize response copy for trusted auth-cache persistence.
|
|
45
|
+
*
|
|
46
|
+
* Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the
|
|
47
|
+
* result can be serialized, parsed, and passed back to
|
|
48
|
+
* `PartnerAccountInfo.setAuth()`.
|
|
49
|
+
*
|
|
50
|
+
* The returned value is raw bearer-token material. Store it only in encrypted
|
|
51
|
+
* or otherwise credential-grade durable storage, and never log it.
|
|
52
|
+
*
|
|
53
|
+
* @param auth - Partner authorization response to persist.
|
|
54
|
+
*
|
|
55
|
+
* @returns A plain object with the live Partner token preserved.
|
|
56
|
+
*/
|
|
57
|
+
function partnerAuthorizeResponseForPersistence(auth) {
|
|
58
|
+
return clonePartnerAuthorizeResponse(auth);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { clonePartnerAuthorizeResponse, partnerAuthorizeResponseForPersistence };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=auth-clone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-clone.js","names":[],"sources":["../../src/partner/auth-clone.ts"],"sourcesContent":["import type { PartnerAuthorizeResponse } from '../types/partner.ts'\nimport { validatePartnerAuthorizeResponseShape } from './auth-shape.ts'\n\n/**\n * Returns a hook-free Partner authorize response copy.\n *\n * @param auth - Partner authorization response to clone.\n *\n * @returns A plain object preserving the live Partner token.\n *\n * @internal\n */\nexport function clonePartnerAuthorizeResponse(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n validatePartnerAuthorizeResponseShape(auth)\n\n const storageApi = auth.apiInfo.storageApi\n const groupsApi = auth.apiInfo.groupsApi\n const backupApi = auth.apiInfo.backupApi\n\n return {\n accountId: auth.accountId,\n authorizationToken: auth.authorizationToken,\n apiInfo: {\n ...(storageApi !== undefined\n ? {\n storageApi: {\n ...storageApi,\n capabilities: [...storageApi.capabilities],\n },\n }\n : {}),\n ...(groupsApi !== undefined\n ? {\n groupsApi: {\n ...groupsApi,\n capabilities: [...groupsApi.capabilities],\n infoType: 'groupsApi' as const,\n },\n }\n : {}),\n ...(backupApi !== undefined\n ? {\n backupApi: {\n ...backupApi,\n capabilities: [...backupApi.capabilities],\n infoType: 'backupApi' as const,\n },\n }\n : {}),\n },\n ...(groupsApi !== undefined ? { groupsApiUrl: groupsApi.groupsApiUrl } : {}),\n ...(backupApi !== undefined ? { backupApiUrl: backupApi.backupApiUrl } : {}),\n ...(groupsApi !== undefined ? { groupsCapabilities: [...groupsApi.capabilities] } : {}),\n ...(backupApi !== undefined ? { backupCapabilities: [...backupApi.capabilities] } : {}),\n applicationKeyExpirationTimestamp: auth.applicationKeyExpirationTimestamp,\n }\n}\n\n/**\n * Returns a plain Partner authorize response copy for trusted auth-cache persistence.\n *\n * Unlike `JSON.stringify(auth)`, this preserves `authorizationToken` so the\n * result can be serialized, parsed, and passed back to\n * `PartnerAccountInfo.setAuth()`.\n *\n * The returned value is raw bearer-token material. Store it only in encrypted\n * or otherwise credential-grade durable storage, and never log it.\n *\n * @param auth - Partner authorization response to persist.\n *\n * @returns A plain object with the live Partner token preserved.\n */\nexport function partnerAuthorizeResponseForPersistence(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n return clonePartnerAuthorizeResponse(auth)\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,8BACd,MAC0B;CAC1B,sCAAsC,IAAI;CAE1C,MAAM,aAAa,KAAK,QAAQ;CAChC,MAAM,YAAY,KAAK,QAAQ;CAC/B,MAAM,YAAY,KAAK,QAAQ;CAE/B,OAAO;EACL,WAAW,KAAK;EAChB,oBAAoB,KAAK;EACzB,SAAS;GACP,GAAI,eAAe,KAAA,IACf,EACE,YAAY;IACV,GAAG;IACH,cAAc,CAAC,GAAG,WAAW,YAAY;GAC3C,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;GACL,GAAI,cAAc,KAAA,IACd,EACE,WAAW;IACT,GAAG;IACH,cAAc,CAAC,GAAG,UAAU,YAAY;IACxC,UAAU;GACZ,EACF,IACA,CAAC;EACP;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,cAAc,UAAU,aAAa,IAAI,CAAC;EAC1E,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,GAAI,cAAc,KAAA,IAAY,EAAE,oBAAoB,CAAC,GAAG,UAAU,YAAY,EAAE,IAAI,CAAC;EACrF,mCAAmC,KAAK;CAC1C;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,uCACd,MAC0B;CAC1B,OAAO,8BAA8B,IAAI;AAC3C"}
|