@backblaze-labs/b2-sdk 0.3.0 → 0.4.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 +45 -1
- package/README.md +18 -5
- package/dist/_virtual/_b2-sdk-version-json.cjs +1 -1
- package/dist/_virtual/_b2-sdk-version-json.js +1 -1
- package/dist/auth/reauth-coalescer.cjs +65 -0
- package/dist/auth/reauth-coalescer.cjs.map +1 -0
- package/dist/auth/reauth-coalescer.d.cts +34 -0
- package/dist/auth/reauth-coalescer.d.cts.map +1 -0
- package/dist/auth/reauth-coalescer.d.ts +34 -0
- package/dist/auth/reauth-coalescer.d.ts.map +1 -0
- package/dist/auth/reauth-coalescer.js +65 -0
- package/dist/auth/reauth-coalescer.js.map +1 -0
- package/dist/backup/raw.cjs +37 -15
- package/dist/backup/raw.cjs.map +1 -1
- package/dist/backup/raw.d.cts +2 -2
- package/dist/backup/raw.d.cts.map +1 -1
- package/dist/backup/raw.d.ts +2 -2
- package/dist/backup/raw.d.ts.map +1 -1
- package/dist/backup/raw.js +37 -15
- package/dist/backup/raw.js.map +1 -1
- package/dist/bucket-validation.cjs +111 -0
- package/dist/bucket-validation.cjs.map +1 -0
- package/dist/bucket-validation.d.cts +27 -0
- package/dist/bucket-validation.d.cts.map +1 -0
- package/dist/bucket-validation.d.ts +27 -0
- package/dist/bucket-validation.d.ts.map +1 -0
- package/dist/bucket-validation.js +109 -0
- package/dist/bucket-validation.js.map +1 -0
- package/dist/bucket.cjs +123 -73
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.d.cts +156 -61
- package/dist/bucket.d.cts.map +1 -1
- package/dist/bucket.d.ts +156 -61
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +123 -73
- package/dist/bucket.js.map +1 -1
- package/dist/client.cjs +29 -8
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +30 -9
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +30 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -8
- package/dist/client.js.map +1 -1
- package/dist/download/single.cjs +38 -13
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts +10 -4
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts +10 -4
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +38 -13
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +27 -4
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +15 -0
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +15 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +27 -5
- package/dist/errors/index.js.map +1 -1
- package/dist/http/non-idempotent-mutations.cjs +38 -0
- package/dist/http/non-idempotent-mutations.cjs.map +1 -0
- package/dist/http/non-idempotent-mutations.d.cts +25 -0
- package/dist/http/non-idempotent-mutations.d.cts.map +1 -0
- package/dist/http/non-idempotent-mutations.d.ts +25 -0
- package/dist/http/non-idempotent-mutations.d.ts.map +1 -0
- package/dist/http/non-idempotent-mutations.js +35 -0
- package/dist/http/non-idempotent-mutations.js.map +1 -0
- package/dist/http/transport.cjs +9 -8
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +5 -0
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +5 -0
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +9 -8
- package/dist/http/transport.js.map +1 -1
- package/dist/http/user-agent.cjs +12 -1
- package/dist/http/user-agent.cjs.map +1 -1
- package/dist/http/user-agent.d.cts +8 -0
- package/dist/http/user-agent.d.cts.map +1 -1
- package/dist/http/user-agent.d.ts +8 -0
- package/dist/http/user-agent.d.ts.map +1 -1
- package/dist/http/user-agent.js +13 -3
- package/dist/http/user-agent.js.map +1 -1
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +10 -9
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -6
- package/dist/notifications/index.cjs +3 -0
- package/dist/notifications/index.d.cts +2 -0
- package/dist/notifications/index.d.cts.map +1 -1
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +2 -1
- package/dist/object.cjs +12 -1
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +7 -1
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +7 -1
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +12 -1
- package/dist/object.js.map +1 -1
- package/dist/partner/auth-core.cjs +4 -23
- package/dist/partner/auth-core.cjs.map +1 -1
- package/dist/partner/auth-core.d.cts +1 -1
- package/dist/partner/auth-core.d.cts.map +1 -1
- package/dist/partner/auth-core.d.ts +1 -1
- package/dist/partner/auth-core.d.ts.map +1 -1
- package/dist/partner/auth-core.js +5 -24
- package/dist/partner/auth-core.js.map +1 -1
- package/dist/partner/client.cjs +25 -10
- package/dist/partner/client.cjs.map +1 -1
- package/dist/partner/client.d.cts +32 -10
- package/dist/partner/client.d.cts.map +1 -1
- package/dist/partner/client.d.ts +32 -10
- package/dist/partner/client.d.ts.map +1 -1
- package/dist/partner/client.js +25 -10
- package/dist/partner/client.js.map +1 -1
- package/dist/partner/endpoint-url.cjs +1 -0
- package/dist/partner/endpoint-url.cjs.map +1 -1
- package/dist/partner/endpoint-url.d.cts +2 -0
- package/dist/partner/endpoint-url.d.cts.map +1 -1
- package/dist/partner/endpoint-url.d.ts +2 -0
- package/dist/partner/endpoint-url.d.ts.map +1 -1
- package/dist/partner/endpoint-url.js +1 -0
- package/dist/partner/endpoint-url.js.map +1 -1
- package/dist/partner/in-memory.cjs.map +1 -1
- package/dist/partner/in-memory.js.map +1 -1
- package/dist/partner/index.cjs +9 -0
- package/dist/partner/index.d.cts +11 -2
- package/dist/partner/index.d.cts.map +1 -1
- package/dist/partner/index.d.ts +11 -2
- package/dist/partner/index.d.ts.map +1 -1
- package/dist/partner/index.js +3 -1
- package/dist/partner/raw.cjs +52 -44
- package/dist/partner/raw.cjs.map +1 -1
- package/dist/partner/raw.d.cts +16 -19
- package/dist/partner/raw.d.cts.map +1 -1
- package/dist/partner/raw.d.ts +16 -19
- package/dist/partner/raw.d.ts.map +1 -1
- package/dist/partner/raw.js +52 -44
- package/dist/partner/raw.js.map +1 -1
- package/dist/partner/redaction.cjs +133 -108
- package/dist/partner/redaction.cjs.map +1 -1
- package/dist/partner/redaction.d.cts +47 -13
- package/dist/partner/redaction.d.cts.map +1 -1
- package/dist/partner/redaction.d.ts +47 -13
- package/dist/partner/redaction.d.ts.map +1 -1
- package/dist/partner/redaction.js +133 -109
- package/dist/partner/redaction.js.map +1 -1
- package/dist/raw/encoding.cjs +29 -10
- package/dist/raw/encoding.cjs.map +1 -1
- package/dist/raw/encoding.d.cts +3 -2
- package/dist/raw/encoding.d.cts.map +1 -1
- package/dist/raw/encoding.d.ts +3 -2
- package/dist/raw/encoding.d.ts.map +1 -1
- package/dist/raw/encoding.js +29 -10
- package/dist/raw/encoding.js.map +1 -1
- package/dist/raw/index.cjs +64 -39
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +21 -19
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +21 -19
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +47 -40
- package/dist/raw/index.js.map +1 -1
- package/dist/raw/url.cjs.map +1 -1
- package/dist/raw/url.d.cts +3 -3
- package/dist/raw/url.d.ts +3 -3
- package/dist/raw/url.js.map +1 -1
- package/dist/simulator/index.cjs +456 -125
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +16 -1
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +16 -1
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +449 -130
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/partner-capabilities.cjs +77 -0
- package/dist/simulator/partner-capabilities.cjs.map +1 -0
- package/dist/simulator/partner-capabilities.d.cts +53 -0
- package/dist/simulator/partner-capabilities.d.cts.map +1 -0
- package/dist/simulator/partner-capabilities.d.ts +53 -0
- package/dist/simulator/partner-capabilities.d.ts.map +1 -0
- package/dist/simulator/partner-capabilities.js +73 -0
- package/dist/simulator/partner-capabilities.js.map +1 -0
- package/dist/simulator/partner.cjs +55 -61
- package/dist/simulator/partner.cjs.map +1 -1
- package/dist/simulator/partner.d.cts +5 -2
- package/dist/simulator/partner.d.cts.map +1 -1
- package/dist/simulator/partner.d.ts +5 -2
- package/dist/simulator/partner.d.ts.map +1 -1
- package/dist/simulator/partner.js +56 -61
- package/dist/simulator/partner.js.map +1 -1
- package/dist/simulator/validation.cjs +160 -30
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +28 -6
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +28 -6
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +148 -31
- 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/hash.cjs +246 -13
- package/dist/streams/hash.cjs.map +1 -1
- package/dist/streams/hash.d.cts +37 -12
- package/dist/streams/hash.d.cts.map +1 -1
- package/dist/streams/hash.d.ts +37 -12
- package/dist/streams/hash.d.ts.map +1 -1
- package/dist/streams/hash.js +246 -15
- package/dist/streams/hash.js.map +1 -1
- package/dist/streams/index.cjs +2 -0
- package/dist/streams/index.d.cts +1 -1
- package/dist/streams/index.d.cts.map +1 -1
- package/dist/streams/index.d.ts +1 -1
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/index.js +2 -2
- package/dist/streams/progress.cjs +63 -4
- package/dist/streams/progress.cjs.map +1 -1
- package/dist/streams/progress.d.cts +28 -2
- package/dist/streams/progress.d.cts.map +1 -1
- package/dist/streams/progress.d.ts +28 -2
- package/dist/streams/progress.d.ts.map +1 -1
- package/dist/streams/progress.js +63 -4
- package/dist/streams/progress.js.map +1 -1
- package/dist/sync/download-staging.cjs +147 -35
- package/dist/sync/download-staging.cjs.map +1 -1
- package/dist/sync/download-staging.d.cts +25 -2
- package/dist/sync/download-staging.d.cts.map +1 -1
- package/dist/sync/download-staging.d.ts +25 -2
- package/dist/sync/download-staging.d.ts.map +1 -1
- package/dist/sync/download-staging.js +146 -36
- package/dist/sync/download-staging.js.map +1 -1
- package/dist/sync/index.d.cts +1 -1
- package/dist/sync/index.d.cts.map +1 -1
- package/dist/sync/index.d.ts +1 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/local-file-io.cjs +5 -1
- package/dist/sync/local-file-io.cjs.map +1 -1
- package/dist/sync/local-file-io.d.cts +2 -0
- package/dist/sync/local-file-io.d.cts.map +1 -1
- package/dist/sync/local-file-io.d.ts +2 -0
- package/dist/sync/local-file-io.d.ts.map +1 -1
- package/dist/sync/local-file-io.js +5 -1
- package/dist/sync/local-file-io.js.map +1 -1
- package/dist/sync/pairing.cjs +1 -0
- package/dist/sync/pairing.cjs.map +1 -1
- package/dist/sync/pairing.js +1 -0
- package/dist/sync/pairing.js.map +1 -1
- package/dist/sync/scanners/b2.cjs +2 -0
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.d.cts.map +1 -1
- package/dist/sync/scanners/b2.d.ts.map +1 -1
- package/dist/sync/scanners/b2.js +2 -0
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs +150 -33
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.d.cts +6 -0
- package/dist/sync/scanners/local.d.cts.map +1 -1
- package/dist/sync/scanners/local.d.ts +6 -0
- package/dist/sync/scanners/local.d.ts.map +1 -1
- package/dist/sync/scanners/local.js +150 -33
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/synchronizer.cjs +76 -29
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.d.cts +1 -0
- package/dist/sync/synchronizer.d.cts.map +1 -1
- package/dist/sync/synchronizer.d.ts +1 -0
- package/dist/sync/synchronizer.d.ts.map +1 -1
- package/dist/sync/synchronizer.js +76 -29
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/sync/types.d.cts +19 -3
- package/dist/sync/types.d.cts.map +1 -1
- package/dist/sync/types.d.ts +19 -3
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types/backup.d.cts +6 -1
- package/dist/types/backup.d.cts.map +1 -1
- package/dist/types/backup.d.ts +6 -1
- package/dist/types/backup.d.ts.map +1 -1
- package/dist/types/bucket.cjs +81 -11
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.d.cts +190 -39
- package/dist/types/bucket.d.cts.map +1 -1
- package/dist/types/bucket.d.ts +190 -39
- package/dist/types/bucket.d.ts.map +1 -1
- package/dist/types/bucket.js +67 -12
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/download.cjs.map +1 -1
- package/dist/types/download.d.cts +3 -17
- package/dist/types/download.d.cts.map +1 -1
- package/dist/types/download.d.ts +3 -17
- package/dist/types/download.d.ts.map +1 -1
- package/dist/types/download.js.map +1 -1
- package/dist/types/encryption.cjs +18 -0
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +21 -11
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +21 -11
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +18 -0
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/file.cjs +3 -0
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +125 -16
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +125 -16
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js +3 -1
- package/dist/types/file.js.map +1 -1
- package/dist/types/index.d.cts +7 -7
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key.d.cts +4 -3
- package/dist/types/key.d.cts.map +1 -1
- package/dist/types/key.d.ts +4 -3
- package/dist/types/key.d.ts.map +1 -1
- package/dist/types/notifications.cjs +30 -0
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.d.cts +26 -1
- package/dist/types/notifications.d.cts.map +1 -1
- package/dist/types/notifications.d.ts +26 -1
- package/dist/types/notifications.d.ts.map +1 -1
- package/dist/types/notifications.js +29 -1
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/partner.cjs.map +1 -1
- package/dist/types/partner.d.cts +28 -36
- package/dist/types/partner.d.cts.map +1 -1
- package/dist/types/partner.d.ts +28 -36
- package/dist/types/partner.d.ts.map +1 -1
- package/dist/types/partner.js.map +1 -1
- package/dist/types/upload.d.cts +4 -0
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +4 -0
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/large.cjs +10 -7
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +15 -6
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +15 -6
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +10 -7
- 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 +4 -3
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +6 -4
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +6 -4
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +4 -3
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +17 -10
- package/dist/upload/retry.cjs.map +1 -1
- package/dist/upload/retry.d.cts.map +1 -1
- package/dist/upload/retry.d.ts.map +1 -1
- package/dist/upload/retry.js +17 -10
- package/dist/upload/retry.js.map +1 -1
- package/dist/upload/single.cjs +35 -31
- 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 +35 -31
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +12 -1
- 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 +12 -1
- package/dist/upload/stream.js.map +1 -1
- package/dist/version.cjs +56 -4
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +53 -4
- package/dist/version.d.cts.map +1 -1
- package/dist/version.d.ts +53 -4
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +52 -5
- package/dist/version.js.map +1 -1
- package/package.json +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/types/download.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/types/download.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACvF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,E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,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,oEAAoE;IACpE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IACnC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,iDAAiD;IACjD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,8FAA8F;IAC9F,QAAQ,CAAC,oBAAoB,CAAC,EAAE,4BAA4B,CAAA;IAC5D,gFAAgF;IAChF,QAAQ,CAAC,aAAa,CAAC,EAAE,qBAAqB,CAAA;IAC9C,iFAAiF;IACjF,QAAQ,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAA;IACtC,gFAAgF;IAChF,QAAQ,CAAC,wBAAwB,CAAC,EAAE,SAAS,sCAAsC,EAAE,CAAA;IACrF,4FAA4F;IAC5F,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,wBAAwB,EAAE,CAAA;CACjE"}
|
package/dist/types/download.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SseB2Setting, SseCPublicSetting } from './encryption.js';
|
|
1
|
+
import { SseB2Setting, SseCKeyMaterial, SseCPublicSetting } from './encryption.js';
|
|
2
2
|
import { BucketId, FileId } from './ids.js';
|
|
3
3
|
import { ReadableFileRetention, ReadableLegalHold } from './lock.js';
|
|
4
4
|
/** HTTP response header names returned by B2 download endpoints. */
|
|
@@ -68,14 +68,7 @@ export interface DownloadByIdRequest {
|
|
|
68
68
|
/** Optional byte range to download (e.g., `'bytes=0-999'`). */
|
|
69
69
|
readonly range?: string;
|
|
70
70
|
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
71
|
-
readonly serverSideEncryption?:
|
|
72
|
-
/** Encryption algorithm. Always `'AES256'`. */
|
|
73
|
-
readonly algorithm: 'AES256';
|
|
74
|
-
/** Base64-encoded customer-provided decryption key. */
|
|
75
|
-
readonly customerKey: string;
|
|
76
|
-
/** Base64-encoded MD5 digest of the decryption key. */
|
|
77
|
-
readonly customerKeyMd5: string;
|
|
78
|
-
};
|
|
71
|
+
readonly serverSideEncryption?: SseCKeyMaterial;
|
|
79
72
|
/** Override the Content-Disposition header in the download response. */
|
|
80
73
|
readonly b2ContentDisposition?: string;
|
|
81
74
|
/** Override the Content-Language header in the download response. */
|
|
@@ -98,14 +91,7 @@ export interface DownloadByNameRequest {
|
|
|
98
91
|
/** Optional byte range to download (e.g., `'bytes=0-999'`). */
|
|
99
92
|
readonly range?: string;
|
|
100
93
|
/** SSE-C decryption parameters, required if the file was uploaded with SSE-C. */
|
|
101
|
-
readonly serverSideEncryption?:
|
|
102
|
-
/** Encryption algorithm. Always `'AES256'`. */
|
|
103
|
-
readonly algorithm: 'AES256';
|
|
104
|
-
/** Base64-encoded customer-provided decryption key. */
|
|
105
|
-
readonly customerKey: string;
|
|
106
|
-
/** Base64-encoded MD5 digest of the decryption key. */
|
|
107
|
-
readonly customerKeyMd5: string;
|
|
108
|
-
};
|
|
94
|
+
readonly serverSideEncryption?: SseCKeyMaterial;
|
|
109
95
|
/** Override the Content-Disposition header in the download response. */
|
|
110
96
|
readonly b2ContentDisposition?: string;
|
|
111
97
|
/** Override the Content-Language header in the download response. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/types/download.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"download.d.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ryption.ts'\nimport type { BucketId, FileId } from './ids.ts'\nimport type { ReadableFileRetention, ReadableLegalHold } from './lock.ts'\n\n/** HTTP response header names returned by B2 download endpoints. */\nexport const DownloadHeaderName = {\n /** Header carrying the response content disposition. */\n ContentDisposition: 'Content-Disposition',\n /** Header carrying the response content language. */\n ContentLanguage: 'Content-Language',\n /** Header carrying the response content encoding. */\n ContentEncoding: 'Content-Encoding',\n /** Header carrying the response content type. */\n ContentType: 'Content-Type',\n /** Header carrying the response cache policy. */\n CacheControl: 'Cache-Control',\n /** Header carrying the response expiration time. */\n Expires: 'Expires',\n /** Header carrying the byte range returned for partial downloads. */\n ContentRange: 'Content-Range',\n /** Header carrying the response content length. */\n ContentLength: 'Content-Length',\n /** Header carrying the B2 SHA-1 metadata value. */\n ContentSha1: 'X-Bz-Content-Sha1',\n /** Header carrying the downloaded file version ID. */\n FileId: 'X-Bz-File-Id',\n /** Header carrying the URL-encoded downloaded file name. */\n FileName: 'X-Bz-File-Name',\n /** Header carrying the file upload timestamp. */\n UploadTimestamp: 'X-Bz-Upload-Timestamp',\n /** Header carrying the B2-managed server-side encryption algorithm. */\n ServerSideEncryption: 'X-Bz-Server-Side-Encryption',\n /** Header carrying the SSE-C algorithm echo. */\n ServerSideEncryptionCustomerAlgorithm: 'X-Bz-Server-Side-Encryption-Customer-Algorithm',\n /** Header carrying the SSE-C customer-key MD5 echo. */\n ServerSideEncryptionCustomerKeyMd5: 'X-Bz-Server-Side-Encryption-Customer-Key-Md5',\n /** Header carrying the Object Lock retention mode. */\n FileRetentionMode: 'X-Bz-File-Retention-Mode',\n /** Header carrying the Object Lock retain-until timestamp. */\n FileRetentionRetainUntilTimestamp: 'X-Bz-File-Retention-Retain-Until-Timestamp',\n /** Header carrying the Object Lock legal-hold value. */\n FileLegalHold: 'X-Bz-File-Legal-Hold',\n /** Header carrying names of metadata headers hidden by missing capabilities. */\n ClientUnauthorizedToRead: 'X-Bz-Client-Unauthorized-To-Read',\n} as const\n\n/** HTTP response header name returned by B2 download endpoints. */\nexport type DownloadHeaderName = (typeof DownloadHeaderName)[keyof typeof DownloadHeaderName]\n\n/** Documented download metadata markers B2 may hide when the caller lacks read capabilities. */\nexport const DownloadClientUnauthorizedToReadMarker = {\n /** B2-managed encryption metadata is hidden. */\n ServerSideEncryption: DownloadHeaderName.ServerSideEncryption,\n /** SSE-C algorithm metadata is hidden. */\n ServerSideEncryptionCustomerAlgorithm: DownloadHeaderName.ServerSideEncryptionCustomerAlgorithm,\n /** SSE-C customer-key MD5 metadata is hidden. */\n ServerSideEncryptionCustomerKeyMd5: DownloadHeaderName.ServerSideEncryptionCustomerKeyMd5,\n /** Object Lock retention mode metadata is hidden. */\n FileRetentionMode: DownloadHeaderName.FileRetentionMode,\n /** Object Lock retain-until timestamp metadata is hidden. */\n FileRetentionRetainUntilTimestamp: DownloadHeaderName.FileRetentionRetainUntilTimestamp,\n /** Object Lock legal-hold metadata is hidden. */\n FileLegalHold: DownloadHeaderName.FileLegalHold,\n} as const\n\n/** Documented download metadata marker B2 may hide when the caller lacks read capabilities. */\nexport type DownloadClientUnauthorizedToReadMarker =\n (typeof DownloadClientUnauthorizedToReadMarker)[keyof typeof DownloadClientUnauthorizedToReadMarker]\n\n/** Request parameters for downloading a file by its ID via `b2_download_file_by_id`. */\nexport interface DownloadByIdRequest {\n /** ID of the file version to download. */\n readonly fileId: FileId\n /** Optional byte range to download (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?: {\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: 'AES256'\n /** Base64-encoded customer-provided decryption key. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the decryption key. */\n readonly customerKeyMd5: string\n }\n /** Override the Content-Disposition header in the download response. */\n readonly b2ContentDisposition?: string\n /** Override the Content-Language header in the download response. */\n readonly b2ContentLanguage?: string\n /** Override the Content-Encoding header in the download response. */\n readonly b2ContentEncoding?: string\n /** Override the Content-Type header in the download response. */\n readonly b2ContentType?: string\n /** Override the Cache-Control header in the download response. */\n readonly b2CacheControl?: string\n /** Override the Expires header in the download response. */\n readonly b2Expires?: string\n}\n\n/** Request parameters for downloading a file by bucket name and file name via `b2_download_file_by_name`. */\nexport interface DownloadByNameRequest {\n /** Name of the bucket containing the file. */\n readonly bucketName: string\n /** Full path and name of the file within the bucket. */\n readonly fileName: string\n /** Optional byte range to download (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?: {\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: 'AES256'\n /** Base64-encoded customer-provided decryption key. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the decryption key. */\n readonly customerKeyMd5: string\n }\n /** Override the Content-Disposition header in the download response. */\n readonly b2ContentDisposition?: string\n /** Override the Content-Language header in the download response. */\n readonly b2ContentLanguage?: string\n /** Override the Content-Encoding header in the download response. */\n readonly b2ContentEncoding?: string\n /** Override the Content-Type header in the download response. */\n readonly b2ContentType?: string\n /** Override the Cache-Control header in the download response. */\n readonly b2CacheControl?: string\n /** Override the Expires header in the download response. */\n readonly b2Expires?: string\n}\n\n/**\n * Request parameters for the `b2_get_download_authorization` API call.\n * Creates a time-limited token that authorizes downloads of files matching a prefix.\n */\nexport interface DownloadAuthorizationRequest {\n /** Bucket to authorize downloads from. */\n readonly bucketId: BucketId\n /** Only files with names starting with this prefix are authorized. */\n readonly fileNamePrefix: string\n /** Duration in seconds that the authorization token remains valid. */\n readonly validDurationInSeconds: number\n /** Override the Content-Disposition header in authorized download responses. */\n readonly b2ContentDisposition?: string\n /** Override the Content-Language header in authorized download responses. */\n readonly b2ContentLanguage?: string\n /** Override the Content-Encoding header in authorized download responses. */\n readonly b2ContentEncoding?: string\n /** Override the Content-Type header in authorized download responses. */\n readonly b2ContentType?: string\n /** Override the Cache-Control header in authorized download responses. */\n readonly b2CacheControl?: string\n /** Override the Expires header in authorized download responses. */\n readonly b2Expires?: string\n}\n\n/** Response from the `b2_get_download_authorization` API call. */\nexport interface DownloadAuthorizationResponse {\n /** Bucket the authorization applies to. */\n readonly bucketId: BucketId\n /** File name prefix the authorization is scoped to. */\n readonly fileNamePrefix: string\n /** Authorization token to include in download requests. */\n readonly authorizationToken: string\n}\n\n/** Customer-managed server-side encryption metadata echoed in B2 download response headers. */\nexport interface SseCDownloadSetting extends SseCPublicSetting {\n /** MD5 digest echoed by `X-Bz-Server-Side-Encryption-Customer-Key-Md5`. */\n readonly customerKeyMd5: string\n}\n\n/** Server-side encryption metadata echoed in B2 download response headers. */\nexport type DownloadServerSideEncryption = SseB2Setting | SseCDownloadSetting\n\n/** Diagnostic for a present download metadata header the SDK could not parse narrowly. */\nexport interface DownloadHeaderParseIssue {\n /** Header whose value could not be parsed into the current typed SDK model. */\n readonly headerName: DownloadHeaderName\n /** Raw header value that could not be parsed. */\n readonly value: string\n}\n\n/** Parsed headers from a B2 file download response. */\nexport interface DownloadHeaders {\n /** MIME type of the downloaded file content. */\n readonly contentType: string\n /** Size of the downloaded content in bytes. */\n readonly contentLength: number\n /** Content-Disposition value computed from upload metadata or the download request. */\n readonly contentDisposition?: string\n /** Content-Language value computed from upload metadata or the download request. */\n readonly contentLanguage?: string\n /** Content-Encoding value computed from upload metadata or the download request. */\n readonly contentEncoding?: string\n /** Cache-Control value computed from upload metadata, bucket defaults, or the download request. */\n readonly cacheControl?: string\n /** Expires value computed from upload metadata or the download request. */\n readonly expires?: string\n /** Content-Range value returned for satisfiable range downloads. */\n readonly contentRange?: string\n /** SHA-1 checksum of the full file content, or null for large files. */\n readonly contentSha1: string | null\n /** ID of the downloaded file version. */\n readonly fileId: FileId\n /** Full path and name of the downloaded file. */\n readonly fileName: string\n /** User-defined key-value metadata stored with the file. */\n readonly fileInfo: Record<string, string>\n /** UTC timestamp (milliseconds) when the file was uploaded. */\n readonly uploadTimestamp: number\n /** Server-side encryption metadata echoed by B2, when the caller is authorized to read it. */\n readonly serverSideEncryption?: DownloadServerSideEncryption\n /** Object Lock retention metadata, including whether the caller may read it. */\n readonly fileRetention?: ReadableFileRetention\n /** Object Lock legal hold metadata, including whether the caller may read it. */\n readonly legalHold?: ReadableLegalHold\n /** Header names B2 omitted because the caller lacks capability to read them. */\n readonly clientUnauthorizedToRead?: readonly DownloadClientUnauthorizedToReadMarker[]\n /** Present metadata headers the SDK could not parse into its current narrow typed model. */\n readonly headerParseIssues?: readonly DownloadHeaderParseIssue[]\n}\n"],"mappings":";;AAKA,IAAa,qBAAqB;;CAEhC,oBAAoB;;CAEpB,iBAAiB;;CAEjB,iBAAiB;;CAEjB,aAAa;;CAEb,cAAc;;CAEd,SAAS;;CAET,cAAc;;CAEd,eAAe;;CAEf,aAAa;;CAEb,QAAQ;;CAER,UAAU;;CAEV,iBAAiB;;CAEjB,sBAAsB;;CAEtB,uCAAuC;;CAEvC,oCAAoC;;CAEpC,mBAAmB;;CAEnB,mCAAmC;;CAEnC,eAAe;;CAEf,0BAA0B;AAC5B;;AAMA,IAAa,yCAAyC;;CAEpD,sBAAsB,mBAAmB;;CAEzC,uCAAuC,mBAAmB;;CAE1D,oCAAoC,mBAAmB;;CAEvD,mBAAmB,mBAAmB;;CAEtC,mCAAmC,mBAAmB;;CAEtD,eAAe,mBAAmB;AACpC"}
|
|
1
|
+
{"version":3,"file":"download.js","names":[],"sources":["../../src/types/download.ts"],"sourcesContent":["import type { SseB2Setting, SseCKeyMaterial, SseCPublicSetting } from './encryption.ts'\nimport type { BucketId, FileId } from './ids.ts'\nimport type { ReadableFileRetention, ReadableLegalHold } from './lock.ts'\n\n/** HTTP response header names returned by B2 download endpoints. */\nexport const DownloadHeaderName = {\n /** Header carrying the response content disposition. */\n ContentDisposition: 'Content-Disposition',\n /** Header carrying the response content language. */\n ContentLanguage: 'Content-Language',\n /** Header carrying the response content encoding. */\n ContentEncoding: 'Content-Encoding',\n /** Header carrying the response content type. */\n ContentType: 'Content-Type',\n /** Header carrying the response cache policy. */\n CacheControl: 'Cache-Control',\n /** Header carrying the response expiration time. */\n Expires: 'Expires',\n /** Header carrying the byte range returned for partial downloads. */\n ContentRange: 'Content-Range',\n /** Header carrying the response content length. */\n ContentLength: 'Content-Length',\n /** Header carrying the B2 SHA-1 metadata value. */\n ContentSha1: 'X-Bz-Content-Sha1',\n /** Header carrying the downloaded file version ID. */\n FileId: 'X-Bz-File-Id',\n /** Header carrying the URL-encoded downloaded file name. */\n FileName: 'X-Bz-File-Name',\n /** Header carrying the file upload timestamp. */\n UploadTimestamp: 'X-Bz-Upload-Timestamp',\n /** Header carrying the B2-managed server-side encryption algorithm. */\n ServerSideEncryption: 'X-Bz-Server-Side-Encryption',\n /** Header carrying the SSE-C algorithm echo. */\n ServerSideEncryptionCustomerAlgorithm: 'X-Bz-Server-Side-Encryption-Customer-Algorithm',\n /** Header carrying the SSE-C customer-key MD5 echo. */\n ServerSideEncryptionCustomerKeyMd5: 'X-Bz-Server-Side-Encryption-Customer-Key-Md5',\n /** Header carrying the Object Lock retention mode. */\n FileRetentionMode: 'X-Bz-File-Retention-Mode',\n /** Header carrying the Object Lock retain-until timestamp. */\n FileRetentionRetainUntilTimestamp: 'X-Bz-File-Retention-Retain-Until-Timestamp',\n /** Header carrying the Object Lock legal-hold value. */\n FileLegalHold: 'X-Bz-File-Legal-Hold',\n /** Header carrying names of metadata headers hidden by missing capabilities. */\n ClientUnauthorizedToRead: 'X-Bz-Client-Unauthorized-To-Read',\n} as const\n\n/** HTTP response header name returned by B2 download endpoints. */\nexport type DownloadHeaderName = (typeof DownloadHeaderName)[keyof typeof DownloadHeaderName]\n\n/** Documented download metadata markers B2 may hide when the caller lacks read capabilities. */\nexport const DownloadClientUnauthorizedToReadMarker = {\n /** B2-managed encryption metadata is hidden. */\n ServerSideEncryption: DownloadHeaderName.ServerSideEncryption,\n /** SSE-C algorithm metadata is hidden. */\n ServerSideEncryptionCustomerAlgorithm: DownloadHeaderName.ServerSideEncryptionCustomerAlgorithm,\n /** SSE-C customer-key MD5 metadata is hidden. */\n ServerSideEncryptionCustomerKeyMd5: DownloadHeaderName.ServerSideEncryptionCustomerKeyMd5,\n /** Object Lock retention mode metadata is hidden. */\n FileRetentionMode: DownloadHeaderName.FileRetentionMode,\n /** Object Lock retain-until timestamp metadata is hidden. */\n FileRetentionRetainUntilTimestamp: DownloadHeaderName.FileRetentionRetainUntilTimestamp,\n /** Object Lock legal-hold metadata is hidden. */\n FileLegalHold: DownloadHeaderName.FileLegalHold,\n} as const\n\n/** Documented download metadata marker B2 may hide when the caller lacks read capabilities. */\nexport type DownloadClientUnauthorizedToReadMarker =\n (typeof DownloadClientUnauthorizedToReadMarker)[keyof typeof DownloadClientUnauthorizedToReadMarker]\n\n/** Request parameters for downloading a file by its ID via `b2_download_file_by_id`. */\nexport interface DownloadByIdRequest {\n /** ID of the file version to download. */\n readonly fileId: FileId\n /** Optional byte range to download (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?: SseCKeyMaterial\n /** Override the Content-Disposition header in the download response. */\n readonly b2ContentDisposition?: string\n /** Override the Content-Language header in the download response. */\n readonly b2ContentLanguage?: string\n /** Override the Content-Encoding header in the download response. */\n readonly b2ContentEncoding?: string\n /** Override the Content-Type header in the download response. */\n readonly b2ContentType?: string\n /** Override the Cache-Control header in the download response. */\n readonly b2CacheControl?: string\n /** Override the Expires header in the download response. */\n readonly b2Expires?: string\n}\n\n/** Request parameters for downloading a file by bucket name and file name via `b2_download_file_by_name`. */\nexport interface DownloadByNameRequest {\n /** Name of the bucket containing the file. */\n readonly bucketName: string\n /** Full path and name of the file within the bucket. */\n readonly fileName: string\n /** Optional byte range to download (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?: SseCKeyMaterial\n /** Override the Content-Disposition header in the download response. */\n readonly b2ContentDisposition?: string\n /** Override the Content-Language header in the download response. */\n readonly b2ContentLanguage?: string\n /** Override the Content-Encoding header in the download response. */\n readonly b2ContentEncoding?: string\n /** Override the Content-Type header in the download response. */\n readonly b2ContentType?: string\n /** Override the Cache-Control header in the download response. */\n readonly b2CacheControl?: string\n /** Override the Expires header in the download response. */\n readonly b2Expires?: string\n}\n\n/**\n * Request parameters for the `b2_get_download_authorization` API call.\n * Creates a time-limited token that authorizes downloads of files matching a prefix.\n */\nexport interface DownloadAuthorizationRequest {\n /** Bucket to authorize downloads from. */\n readonly bucketId: BucketId\n /** Only files with names starting with this prefix are authorized. */\n readonly fileNamePrefix: string\n /** Duration in seconds that the authorization token remains valid. */\n readonly validDurationInSeconds: number\n /** Override the Content-Disposition header in authorized download responses. */\n readonly b2ContentDisposition?: string\n /** Override the Content-Language header in authorized download responses. */\n readonly b2ContentLanguage?: string\n /** Override the Content-Encoding header in authorized download responses. */\n readonly b2ContentEncoding?: string\n /** Override the Content-Type header in authorized download responses. */\n readonly b2ContentType?: string\n /** Override the Cache-Control header in authorized download responses. */\n readonly b2CacheControl?: string\n /** Override the Expires header in authorized download responses. */\n readonly b2Expires?: string\n}\n\n/** Response from the `b2_get_download_authorization` API call. */\nexport interface DownloadAuthorizationResponse {\n /** Bucket the authorization applies to. */\n readonly bucketId: BucketId\n /** File name prefix the authorization is scoped to. */\n readonly fileNamePrefix: string\n /** Authorization token to include in download requests. */\n readonly authorizationToken: string\n}\n\n/** Customer-managed server-side encryption metadata echoed in B2 download response headers. */\nexport interface SseCDownloadSetting extends SseCPublicSetting {\n /** MD5 digest echoed by `X-Bz-Server-Side-Encryption-Customer-Key-Md5`. */\n readonly customerKeyMd5: string\n}\n\n/** Server-side encryption metadata echoed in B2 download response headers. */\nexport type DownloadServerSideEncryption = SseB2Setting | SseCDownloadSetting\n\n/** Diagnostic for a present download metadata header the SDK could not parse narrowly. */\nexport interface DownloadHeaderParseIssue {\n /** Header whose value could not be parsed into the current typed SDK model. */\n readonly headerName: DownloadHeaderName\n /** Raw header value that could not be parsed. */\n readonly value: string\n}\n\n/** Parsed headers from a B2 file download response. */\nexport interface DownloadHeaders {\n /** MIME type of the downloaded file content. */\n readonly contentType: string\n /** Size of the downloaded content in bytes. */\n readonly contentLength: number\n /** Content-Disposition value computed from upload metadata or the download request. */\n readonly contentDisposition?: string\n /** Content-Language value computed from upload metadata or the download request. */\n readonly contentLanguage?: string\n /** Content-Encoding value computed from upload metadata or the download request. */\n readonly contentEncoding?: string\n /** Cache-Control value computed from upload metadata, bucket defaults, or the download request. */\n readonly cacheControl?: string\n /** Expires value computed from upload metadata or the download request. */\n readonly expires?: string\n /** Content-Range value returned for satisfiable range downloads. */\n readonly contentRange?: string\n /** SHA-1 checksum of the full file content, or null for large files. */\n readonly contentSha1: string | null\n /** ID of the downloaded file version. */\n readonly fileId: FileId\n /** Full path and name of the downloaded file. */\n readonly fileName: string\n /** User-defined key-value metadata stored with the file. */\n readonly fileInfo: Record<string, string>\n /** UTC timestamp (milliseconds) when the file was uploaded. */\n readonly uploadTimestamp: number\n /** Server-side encryption metadata echoed by B2, when the caller is authorized to read it. */\n readonly serverSideEncryption?: DownloadServerSideEncryption\n /** Object Lock retention metadata, including whether the caller may read it. */\n readonly fileRetention?: ReadableFileRetention\n /** Object Lock legal hold metadata, including whether the caller may read it. */\n readonly legalHold?: ReadableLegalHold\n /** Header names B2 omitted because the caller lacks capability to read them. */\n readonly clientUnauthorizedToRead?: readonly DownloadClientUnauthorizedToReadMarker[]\n /** Present metadata headers the SDK could not parse into its current narrow typed model. */\n readonly headerParseIssues?: readonly DownloadHeaderParseIssue[]\n}\n"],"mappings":";;AAKA,IAAa,qBAAqB;;CAEhC,oBAAoB;;CAEpB,iBAAiB;;CAEjB,iBAAiB;;CAEjB,aAAa;;CAEb,cAAc;;CAEd,SAAS;;CAET,cAAc;;CAEd,eAAe;;CAEf,aAAa;;CAEb,QAAQ;;CAER,UAAU;;CAEV,iBAAiB;;CAEjB,sBAAsB;;CAEtB,uCAAuC;;CAEvC,oCAAoC;;CAEpC,mBAAmB;;CAEnB,mCAAmC;;CAEnC,eAAe;;CAEf,0BAA0B;AAC5B;;AAMA,IAAa,yCAAyC;;CAEpD,sBAAsB,mBAAmB;;CAEzC,uCAAuC,mBAAmB;;CAE1D,oCAAoC,mBAAmB;;CAEvD,mBAAmB,mBAAmB;;CAEtC,mCAAmC,mBAAmB;;CAEtD,eAAe,mBAAmB;AACpC"}
|
|
@@ -140,6 +140,16 @@ var EncryptionKey = class EncryptionKey {
|
|
|
140
140
|
this.customerKeyMd5 = customerKeyMd5;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
+
* Generates a random 32-byte (256-bit) SSE-C key.
|
|
144
|
+
*
|
|
145
|
+
* @returns A safely-wrapped EncryptionKey ready for upload/download.
|
|
146
|
+
*/
|
|
147
|
+
static async generate() {
|
|
148
|
+
const rawKey = /* @__PURE__ */ new Uint8Array(32);
|
|
149
|
+
getRandomValues(rawKey);
|
|
150
|
+
return EncryptionKey.fromBytes(rawKey);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
143
153
|
* Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the
|
|
144
154
|
* required base64 MD5 digest internally.
|
|
145
155
|
*
|
|
@@ -196,6 +206,14 @@ var EncryptionKey = class EncryptionKey {
|
|
|
196
206
|
return this.toString();
|
|
197
207
|
}
|
|
198
208
|
};
|
|
209
|
+
function getRandomValues(bytes) {
|
|
210
|
+
const cryptoLike = globalThis.crypto;
|
|
211
|
+
if (cryptoLike !== void 0) {
|
|
212
|
+
cryptoLike.getRandomValues(bytes);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
throw new Error("EncryptionKey.generate requires crypto.getRandomValues.");
|
|
216
|
+
}
|
|
199
217
|
//#endregion
|
|
200
218
|
exports.EncryptionAlgorithm = EncryptionAlgorithm;
|
|
201
219
|
exports.EncryptionKey = EncryptionKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.cjs","names":[],"sources":["../../src/types/encryption.ts"],"sourcesContent":["import { md5Base64 } from '../util/md5.ts'\n\n/** Named constants for the supported server-side encryption algorithms. */\nexport const EncryptionAlgorithm = {\n /** AES with a 256-bit key. The only algorithm B2 currently supports. */\n Aes256: 'AES256',\n} as const\n\n/** Supported server-side encryption algorithm. Derived from {@link EncryptionAlgorithm}. */\nexport type EncryptionAlgorithm = (typeof EncryptionAlgorithm)[keyof typeof EncryptionAlgorithm]\n\n/**\n * Named constants for the server-side encryption mode used by a file.\n *\n * Most callers should use the {@link SSE_B2}, {@link SSE_NONE}, and\n * {@link sseCustomer} helpers below which return complete\n * {@link EncryptionSetting} objects. These constants are useful when you\n * need the bare mode discriminator (e.g., when introspecting a file's\n * current encryption setting).\n */\nexport const EncryptionMode = {\n /** B2-managed encryption keys. */\n SseB2: 'SSE-B2',\n /** Customer-provided encryption keys. */\n SseC: 'SSE-C',\n /** No encryption. */\n None: 'none',\n} as const\n\n/** Server-side encryption mode for files stored in B2. Derived from {@link EncryptionMode}. */\nexport type EncryptionMode = (typeof EncryptionMode)[keyof typeof EncryptionMode]\n\n/** Server-side encryption using B2-managed keys (SSE-B2). */\nexport interface SseB2Setting {\n /** Encryption mode discriminator. Always `'SSE-B2'`. */\n readonly mode: 'SSE-B2'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Server-side encryption using customer-provided keys (SSE-C). */\nexport interface SseCCustomerSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n /** Base64-encoded 256-bit encryption key provided by the customer. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */\n readonly customerKeyMd5: string\n}\n\n/** Server-side encryption using customer-provided keys as returned by B2 responses. */\nexport interface SseCPublicSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Indicates no server-side encryption is applied. */\nexport interface NoEncryption {\n /** Encryption mode discriminator. Always `'none'`. */\n readonly mode: 'none'\n}\n\n/** No-encryption shape returned by B2 response objects. */\nexport interface NoEncryptionWireSetting {\n /** Encryption mode discriminator. B2 response payloads use null for no encryption. */\n readonly mode: null\n /** Encryption algorithm. B2 response payloads use null when no encryption is applied. */\n readonly algorithm: null\n}\n\n/** Union of all server-side encryption settings: B2-managed, customer-provided, or none. */\nexport type EncryptionSetting = SseB2Setting | SseCCustomerSetting | NoEncryption\n\n/** Server-side encryption setting returned by B2 response objects. */\nexport type PublicEncryptionSetting =\n | SseB2Setting\n | SseCPublicSetting\n | NoEncryption\n | NoEncryptionWireSetting\n\n/** Pre-built SSE-B2 encryption setting using AES-256. */\nexport const SSE_B2: SseB2Setting = { mode: 'SSE-B2', algorithm: 'AES256' }\n\n/** Pre-built setting indicating no server-side encryption. */\nexport const SSE_NONE: NoEncryption = { mode: 'none' }\n\n/**\n * Creates an SSE-C encryption setting with a customer-provided key.\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns An SSE-C encryption setting ready to pass to upload or download calls.\n */\nexport function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting {\n return { mode: 'SSE-C', algorithm: 'AES256', customerKey, customerKeyMd5 }\n}\n\n/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n // Prefer Node's Buffer when available (faster), but degrade to btoa() in\n // browsers / Deno / Workers where Buffer isn't a global. We access via\n // globalThis to avoid a hard reference to a Node-only symbol — that would\n // break the type-check in non-Node runtimes (Deno, browser-mode Vitest).\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) {\n return g.Buffer.from(bytes).toString('base64')\n }\n let binary = ''\n for (const b of bytes) binary += String.fromCharCode(b)\n return btoa(binary)\n}\n\nexport const SSE_C_KEY_REDACTION = '[redacted SSE-C key]'\n\nconst NODE_INSPECT_CUSTOM = Symbol.for('nodejs.util.inspect.custom')\n\ninterface SseCKeyMaterial {\n readonly algorithm: EncryptionAlgorithm\n readonly customerKey: string\n readonly customerKeyMd5: string\n}\n\ninterface SseCKeyRedactionOptions {\n readonly label: string\n readonly mode?: 'SSE-C'\n}\n\ninterface RedactedSseCKeyJson {\n readonly mode?: 'SSE-C'\n readonly algorithm: EncryptionAlgorithm\n readonly customerKey: string\n readonly customerKeyMd5: string\n}\n\nfunction sseCKeyRedactedJson(\n key: SseCKeyMaterial,\n options: SseCKeyRedactionOptions,\n): RedactedSseCKeyJson {\n return {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n customerKey: SSE_C_KEY_REDACTION,\n // The MD5 is not secret key material, but it is still derived from a\n // customer-provided key. Keep logged key views fully opaque by default.\n customerKeyMd5: SSE_C_KEY_REDACTION,\n }\n}\n\nfunction sseCKeyRedactedString(options: SseCKeyRedactionOptions): string {\n return `[${options.label} ${SSE_C_KEY_REDACTION}]`\n}\n\n/**\n * Wraps SSE-C key material so diagnostic stringification redacts key fields.\n *\n * The returned object keeps `customerKey` and `customerKeyMd5` readable by\n * property access for request header construction, but makes them\n * non-enumerable so object spread and generic serializers do not copy them.\n * Callers that need wire headers must read those fields directly.\n *\n * @param key - SSE-C key material to wrap.\n * @param options - Redaction label and optional encryption mode discriminator.\n *\n * @returns A redacted view with the same readable key fields.\n */\nexport function redactSseCKeyMaterial<T extends SseCKeyMaterial>(\n key: T,\n options: SseCKeyRedactionOptions,\n): T {\n const redacted = {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n } as T & {\n toJSON(): RedactedSseCKeyJson\n toString(): string\n }\n\n Object.defineProperties(redacted, {\n customerKey: { value: key.customerKey, enumerable: false },\n customerKeyMd5: { value: key.customerKeyMd5, enumerable: false },\n toJSON: { value: () => sseCKeyRedactedJson(key, options), enumerable: false },\n toString: { value: () => sseCKeyRedactedString(options), enumerable: false },\n })\n Object.defineProperty(redacted, NODE_INSPECT_CUSTOM, {\n value: () => sseCKeyRedactedString(options),\n enumerable: false,\n })\n\n return redacted\n}\n\n/**\n * Safe wrapper around an SSE-C customer key. Hides the key bytes from\n * `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}\n * to construct one from a raw 32-byte key; the MD5 digest is computed internally.\n */\nexport class EncryptionKey {\n /** Encryption mode discriminant. Always `'SSE-C'` for this class. */\n readonly mode = 'SSE-C' as const\n /** Encryption algorithm. B2's S3-compatible API only supports AES-256. */\n readonly algorithm: EncryptionAlgorithm = 'AES256'\n /** Base64-encoded 256-bit customer key. Logged as `[redacted SSE-C key]` via `toJSON` / `toString`. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification. */\n readonly customerKeyMd5: string\n\n /**\n * Internal constructor. Use {@link EncryptionKey.fromBytes} or\n * {@link EncryptionKey.fromBase64} instead.\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @internal\n */\n private constructor(customerKey: string, customerKeyMd5: string) {\n this.customerKey = customerKey\n this.customerKeyMd5 = customerKeyMd5\n }\n\n /**\n * Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the\n * required base64 MD5 digest internally.\n *\n * @param rawKey - The raw 256-bit key as bytes. Must be exactly 32 bytes.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n *\n * @throws If the key is not exactly 32 bytes.\n */\n static async fromBytes(rawKey: Uint8Array): Promise<EncryptionKey> {\n if (rawKey.byteLength !== 32) {\n throw new Error(`SSE-C key must be exactly 32 bytes (256 bits); got ${rawKey.byteLength}.`)\n }\n const customerKey = bytesToBase64(rawKey)\n const customerKeyMd5 = await md5Base64(rawKey)\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Builds an EncryptionKey from precomputed base64 strings. Use this in\n * environments where MD5 must be computed externally (e.g., browsers).\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static fromBase64(customerKey: string, customerKeyMd5: string): EncryptionKey {\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Hides the key bytes from `JSON.stringify`.\n *\n * @returns A redacted shape: same mode and algorithm, but the key and MD5\n * replaced with a placeholder string.\n */\n toJSON(): {\n /** Encryption mode discriminant. */\n mode: 'SSE-C'\n /** Encryption algorithm. */\n algorithm: EncryptionAlgorithm\n /** Always the literal redaction placeholder; the real key never leaves the instance. */\n customerKey: string\n /** Always the literal redaction placeholder; the real MD5 never leaves the instance. */\n customerKeyMd5: string\n } {\n return sseCKeyRedactedJson(this, { label: 'EncryptionKey SSE-C', mode: this.mode }) as {\n mode: 'SSE-C'\n algorithm: EncryptionAlgorithm\n customerKey: string\n customerKeyMd5: string\n }\n }\n\n /**\n * Hides the key bytes from default `toString()`.\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n toString(): string {\n return sseCKeyRedactedString({ label: 'EncryptionKey SSE-C' })\n }\n\n /**\n * Hides the key bytes from Node's `util.inspect` (and therefore `console.log`).\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n [NODE_INSPECT_CUSTOM](): string {\n return this.toString()\n }\n}\n"],"mappings":";;;AAGA,IAAa,sBAAsB;;AAEjC,QAAQ,SACV;;;;;;;;;;AAcA,IAAa,iBAAiB;;CAE5B,OAAO;;CAEP,MAAM;;CAEN,MAAM;AACR;;AA0DA,IAAa,SAAuB;CAAE,MAAM;CAAU,WAAW;AAAS;;AAG1E,IAAa,WAAyB,EAAE,MAA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B;;CAEhB,YAA0C;;CAE1C;;CAEA;;;;;;;;;;CAWA,YAAoB,aAAqB,gBAAwB;EAC/D,KAAK,cAAc;EACnB,KAAK,iBAAiB;CACxB;;;;;;;;;;;CAYA,aAAa,UAAU,QAA4C;EACjE,IAAI,OAAO,eAAe,IACxB,MAAM,IAAI,MAAM,sDAAsD,OAAO,WAAW,EAAE;EAE5F,MAAM,cAAc,cAAc,MAAM;EACxC,MAAM,iBAAiB,MAAM,YAAA,UAAU,MAAM;EAC7C,OAAO,IAAI,cAAc,aAAa,cAAc;CACtD;;;;;;;;;;CAWA,OAAO,WAAW,aAAqB,gBAAuC;EAC5E,OAAO,IAAI,cAAc,aAAa,cAAc;CACtD;;;;;;;CAQA,SASE;EACA,OAAO,oBAAoB,MAAM;GAAE,OAAO;GAAuB,MAAM,KAAK;EAAK,CAAC;CAMpF;;;;;;CAOA,WAAmB;EACjB,OAAO,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;CAC/D;;;;;;CAOA,CAAC,uBAA+B;EAC9B,OAAO,KAAK,SAAS;CACvB;AACF"}
|
|
1
|
+
{"version":3,"file":"encryption.cjs","names":[],"sources":["../../src/types/encryption.ts"],"sourcesContent":["import { md5Base64 } from '../util/md5.ts'\n\n/** Named constants for the supported server-side encryption algorithms. */\nexport const EncryptionAlgorithm = {\n /** AES with a 256-bit key. The only algorithm B2 currently supports. */\n Aes256: 'AES256',\n} as const\n\n/** Supported server-side encryption algorithm. Derived from {@link EncryptionAlgorithm}. */\nexport type EncryptionAlgorithm = (typeof EncryptionAlgorithm)[keyof typeof EncryptionAlgorithm]\n\n/**\n * Named constants for the server-side encryption mode used by a file.\n *\n * Most callers should use the {@link SSE_B2}, {@link SSE_NONE}, and\n * {@link sseCustomer} helpers below which return complete\n * {@link EncryptionSetting} objects. These constants are useful when you\n * need the bare mode discriminator (e.g., when introspecting a file's\n * current encryption setting).\n */\nexport const EncryptionMode = {\n /** B2-managed encryption keys. */\n SseB2: 'SSE-B2',\n /** Customer-provided encryption keys. */\n SseC: 'SSE-C',\n /** No encryption. */\n None: 'none',\n} as const\n\n/** Server-side encryption mode for files stored in B2. Derived from {@link EncryptionMode}. */\nexport type EncryptionMode = (typeof EncryptionMode)[keyof typeof EncryptionMode]\n\n/** Server-side encryption using B2-managed keys (SSE-B2). */\nexport interface SseB2Setting {\n /** Encryption mode discriminator. Always `'SSE-B2'`. */\n readonly mode: 'SSE-B2'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Shared customer-provided SSE-C key material used by uploads and downloads. */\nexport interface SseCKeyMaterial {\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n /**\n * Base64-encoded 256-bit encryption key provided by the customer.\n *\n * This is secret key material. Native B2 SSE-C requests send it as an\n * HTTP request header, so custom transports and middleware must redact\n * request headers before logging them.\n */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */\n readonly customerKeyMd5: string\n}\n\n/** Server-side encryption using customer-provided keys (SSE-C). */\nexport interface SseCCustomerSetting extends SseCKeyMaterial {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n}\n\n/** Server-side encryption using customer-provided keys as returned by B2 responses. */\nexport interface SseCPublicSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Indicates no server-side encryption is applied. */\nexport interface NoEncryption {\n /** Encryption mode discriminator. Always `'none'`. */\n readonly mode: 'none'\n}\n\n/** No-encryption shape returned by B2 response objects. */\nexport interface NoEncryptionWireSetting {\n /** Encryption mode discriminator. B2 response payloads use null for no encryption. */\n readonly mode: null\n /** Encryption algorithm. B2 response payloads use null when no encryption is applied. */\n readonly algorithm: null\n}\n\n/** Union of all server-side encryption settings: B2-managed, customer-provided, or none. */\nexport type EncryptionSetting = SseB2Setting | SseCCustomerSetting | NoEncryption\n\n/** Server-side encryption setting returned by B2 response objects. */\nexport type PublicEncryptionSetting =\n | SseB2Setting\n | SseCPublicSetting\n | NoEncryption\n | NoEncryptionWireSetting\n\n/** Pre-built SSE-B2 encryption setting using AES-256. */\nexport const SSE_B2: SseB2Setting = { mode: 'SSE-B2', algorithm: 'AES256' }\n\n/** Pre-built setting indicating no server-side encryption. */\nexport const SSE_NONE: NoEncryption = { mode: 'none' }\n\n/**\n * Creates an SSE-C encryption setting with a customer-provided key.\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns An SSE-C encryption setting ready to pass to upload or download calls.\n */\nexport function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting {\n return { mode: 'SSE-C', algorithm: 'AES256', customerKey, customerKeyMd5 }\n}\n\n/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n // Prefer Node's Buffer when available (faster), but degrade to btoa() in\n // browsers / Deno / Workers where Buffer isn't a global. We access via\n // globalThis to avoid a hard reference to a Node-only symbol — that would\n // break the type-check in non-Node runtimes (Deno, browser-mode Vitest).\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) {\n return g.Buffer.from(bytes).toString('base64')\n }\n let binary = ''\n for (const b of bytes) binary += String.fromCharCode(b)\n return btoa(binary)\n}\n\nexport const SSE_C_KEY_REDACTION = '[redacted SSE-C key]'\n\nconst NODE_INSPECT_CUSTOM = Symbol.for('nodejs.util.inspect.custom')\n\ninterface SseCKeyRedactionOptions {\n readonly label: string\n readonly mode?: 'SSE-C'\n}\n\ninterface RedactedSseCKeyJson {\n readonly mode?: 'SSE-C'\n readonly algorithm: EncryptionAlgorithm\n readonly customerKey: string\n readonly customerKeyMd5: string\n}\n\nfunction sseCKeyRedactedJson(\n key: SseCKeyMaterial,\n options: SseCKeyRedactionOptions,\n): RedactedSseCKeyJson {\n return {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n customerKey: SSE_C_KEY_REDACTION,\n // The MD5 is not secret key material, but it is still derived from a\n // customer-provided key. Keep logged key views fully opaque by default.\n customerKeyMd5: SSE_C_KEY_REDACTION,\n }\n}\n\nfunction sseCKeyRedactedString(options: SseCKeyRedactionOptions): string {\n return `[${options.label} ${SSE_C_KEY_REDACTION}]`\n}\n\n/**\n * Wraps SSE-C key material so diagnostic stringification redacts key fields.\n *\n * The returned object keeps `customerKey` and `customerKeyMd5` readable by\n * property access for request header construction, but makes them\n * non-enumerable so object spread and generic serializers do not copy them.\n * Callers that need wire headers must read those fields directly.\n *\n * @param key - SSE-C key material to wrap.\n * @param options - Redaction label and optional encryption mode discriminator.\n *\n * @returns A redacted view with the same readable key fields.\n */\nexport function redactSseCKeyMaterial<T extends SseCKeyMaterial>(\n key: T,\n options: SseCKeyRedactionOptions,\n): T {\n const redacted = {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n } as T & {\n toJSON(): RedactedSseCKeyJson\n toString(): string\n }\n\n Object.defineProperties(redacted, {\n customerKey: { value: key.customerKey, enumerable: false },\n customerKeyMd5: { value: key.customerKeyMd5, enumerable: false },\n toJSON: { value: () => sseCKeyRedactedJson(key, options), enumerable: false },\n toString: { value: () => sseCKeyRedactedString(options), enumerable: false },\n })\n Object.defineProperty(redacted, NODE_INSPECT_CUSTOM, {\n value: () => sseCKeyRedactedString(options),\n enumerable: false,\n })\n\n return redacted\n}\n\n/**\n * Safe wrapper around an SSE-C customer key. Hides the key bytes from\n * `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}\n * to construct one from a raw 32-byte key; the MD5 digest is computed internally.\n */\nexport class EncryptionKey implements SseCCustomerSetting {\n /** Encryption mode discriminant. Always `'SSE-C'` for this class. */\n readonly mode = 'SSE-C' as const\n /** Encryption algorithm. B2's S3-compatible API only supports AES-256. */\n readonly algorithm: EncryptionAlgorithm = 'AES256'\n /** Base64-encoded 256-bit customer key. Logged as `[redacted SSE-C key]` via `toJSON` / `toString`. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification. */\n readonly customerKeyMd5: string\n\n /**\n * Internal constructor. Use {@link EncryptionKey.fromBytes} or\n * {@link EncryptionKey.fromBase64} instead.\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @internal\n */\n private constructor(customerKey: string, customerKeyMd5: string) {\n this.customerKey = customerKey\n this.customerKeyMd5 = customerKeyMd5\n }\n\n /**\n * Generates a random 32-byte (256-bit) SSE-C key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static async generate(): Promise<EncryptionKey> {\n const rawKey = new Uint8Array(32)\n getRandomValues(rawKey)\n return EncryptionKey.fromBytes(rawKey)\n }\n\n /**\n * Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the\n * required base64 MD5 digest internally.\n *\n * @param rawKey - The raw 256-bit key as bytes. Must be exactly 32 bytes.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n *\n * @throws If the key is not exactly 32 bytes.\n */\n static async fromBytes(rawKey: Uint8Array): Promise<EncryptionKey> {\n if (rawKey.byteLength !== 32) {\n throw new Error(`SSE-C key must be exactly 32 bytes (256 bits); got ${rawKey.byteLength}.`)\n }\n const customerKey = bytesToBase64(rawKey)\n const customerKeyMd5 = await md5Base64(rawKey)\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Builds an EncryptionKey from precomputed base64 strings. Use this in\n * environments where MD5 must be computed externally (e.g., browsers).\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static fromBase64(customerKey: string, customerKeyMd5: string): EncryptionKey {\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Hides the key bytes from `JSON.stringify`.\n *\n * @returns A redacted shape: same mode and algorithm, but the key and MD5\n * replaced with a placeholder string.\n */\n toJSON(): {\n /** Encryption mode discriminant. */\n mode: 'SSE-C'\n /** Encryption algorithm. */\n algorithm: EncryptionAlgorithm\n /** Always the literal redaction placeholder; the real key never leaves the instance. */\n customerKey: string\n /** Always the literal redaction placeholder; the real MD5 never leaves the instance. */\n customerKeyMd5: string\n } {\n return sseCKeyRedactedJson(this, { label: 'EncryptionKey SSE-C', mode: this.mode }) as {\n mode: 'SSE-C'\n algorithm: EncryptionAlgorithm\n customerKey: string\n customerKeyMd5: string\n }\n }\n\n /**\n * Hides the key bytes from default `toString()`.\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n toString(): string {\n return sseCKeyRedactedString({ label: 'EncryptionKey SSE-C' })\n }\n\n /**\n * Hides the key bytes from Node's `util.inspect` (and therefore `console.log`).\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n [NODE_INSPECT_CUSTOM](): string {\n return this.toString()\n }\n}\n\nfunction getRandomValues(bytes: Uint8Array): void {\n const cryptoLike = globalThis.crypto as\n | { getRandomValues<T extends Uint8Array>(array: T): T }\n | undefined\n if (cryptoLike !== undefined) {\n cryptoLike.getRandomValues(bytes)\n return\n }\n\n throw new Error('EncryptionKey.generate requires crypto.getRandomValues.')\n}\n"],"mappings":";;;AAGA,IAAa,sBAAsB;;AAEjC,QAAQ,SACV;;;;;;;;;;AAcA,IAAa,iBAAiB;;CAE5B,OAAO;;CAEP,MAAM;;CAEN,MAAM;AACR;;AAoEA,IAAa,SAAuB;CAAE,MAAM;CAAU,WAAW;AAAS;;AAG1E,IAAa,WAAyB,EAAE,MAAM,OAAO;;;;;;;;AASrD,SAAgB,YAAY,aAAqB,gBAA6C;CAC5F,OAAO;EAAE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B;EAC/D,KAAK,cAAc;EACnB,KAAK,iBAAiB;CACxB;;;;;;CAOA,aAAa,WAAmC;EAC9C,MAAM,yBAAS,IAAI,WAAW,EAAE;EAChC,gBAAgB,MAAM;EACtB,OAAO,cAAc,UAAU,MAAM;CACvC;;;;;;;;;;;CAYA,aAAa,UAAU,QAA4C;EACjE,IAAI,OAAO,eAAe,IACxB,MAAM,IAAI,MAAM,sDAAsD,OAAO,WAAW,EAAE;EAE5F,MAAM,cAAc,cAAc,MAAM;EACxC,MAAM,iBAAiB,MAAM,YAAA,UAAU,MAAM;EAC7C,OAAO,IAAI,cAAc,aAAa,cAAc;CACtD;;;;;;;;;;CAWA,OAAO,WAAW,aAAqB,gBAAuC;EAC5E,OAAO,IAAI,cAAc,aAAa,cAAc;CACtD;;;;;;;CAQA,SASE;EACA,OAAO,oBAAoB,MAAM;GAAE,OAAO;GAAuB,MAAM,KAAK;EAAK,CAAC;CAMpF;;;;;;CAOA,WAAmB;EACjB,OAAO,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;CAC/D;;;;;;CAOA,CAAC,uBAA+B;EAC9B,OAAO,KAAK,SAAS;CACvB;AACF;AAEA,SAAS,gBAAgB,OAAyB;CAChD,MAAM,aAAa,WAAW;CAG9B,IAAI,eAAe,KAAA,GAAW;EAC5B,WAAW,gBAAgB,KAAK;EAChC;CACF;CAEA,MAAM,IAAI,MAAM,yDAAyD;AAC3E"}
|
|
@@ -31,17 +31,26 @@ export interface SseB2Setting {
|
|
|
31
31
|
/** Encryption algorithm. Always `'AES256'`. */
|
|
32
32
|
readonly algorithm: EncryptionAlgorithm;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
export interface
|
|
36
|
-
/** Encryption mode discriminator. Always `'SSE-C'`. */
|
|
37
|
-
readonly mode: 'SSE-C';
|
|
34
|
+
/** Shared customer-provided SSE-C key material used by uploads and downloads. */
|
|
35
|
+
export interface SseCKeyMaterial {
|
|
38
36
|
/** Encryption algorithm. Always `'AES256'`. */
|
|
39
37
|
readonly algorithm: EncryptionAlgorithm;
|
|
40
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Base64-encoded 256-bit encryption key provided by the customer.
|
|
40
|
+
*
|
|
41
|
+
* This is secret key material. Native B2 SSE-C requests send it as an
|
|
42
|
+
* HTTP request header, so custom transports and middleware must redact
|
|
43
|
+
* request headers before logging them.
|
|
44
|
+
*/
|
|
41
45
|
readonly customerKey: string;
|
|
42
46
|
/** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */
|
|
43
47
|
readonly customerKeyMd5: string;
|
|
44
48
|
}
|
|
49
|
+
/** Server-side encryption using customer-provided keys (SSE-C). */
|
|
50
|
+
export interface SseCCustomerSetting extends SseCKeyMaterial {
|
|
51
|
+
/** Encryption mode discriminator. Always `'SSE-C'`. */
|
|
52
|
+
readonly mode: 'SSE-C';
|
|
53
|
+
}
|
|
45
54
|
/** Server-side encryption using customer-provided keys as returned by B2 responses. */
|
|
46
55
|
export interface SseCPublicSetting {
|
|
47
56
|
/** Encryption mode discriminator. Always `'SSE-C'`. */
|
|
@@ -79,11 +88,6 @@ export declare const SSE_NONE: NoEncryption;
|
|
|
79
88
|
export declare function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting;
|
|
80
89
|
export declare const SSE_C_KEY_REDACTION = "[redacted SSE-C key]";
|
|
81
90
|
declare const NODE_INSPECT_CUSTOM: unique symbol;
|
|
82
|
-
interface SseCKeyMaterial {
|
|
83
|
-
readonly algorithm: EncryptionAlgorithm;
|
|
84
|
-
readonly customerKey: string;
|
|
85
|
-
readonly customerKeyMd5: string;
|
|
86
|
-
}
|
|
87
91
|
interface SseCKeyRedactionOptions {
|
|
88
92
|
readonly label: string;
|
|
89
93
|
readonly mode?: 'SSE-C';
|
|
@@ -107,7 +111,7 @@ export declare function redactSseCKeyMaterial<T extends SseCKeyMaterial>(key: T,
|
|
|
107
111
|
* `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}
|
|
108
112
|
* to construct one from a raw 32-byte key; the MD5 digest is computed internally.
|
|
109
113
|
*/
|
|
110
|
-
export declare class EncryptionKey {
|
|
114
|
+
export declare class EncryptionKey implements SseCCustomerSetting {
|
|
111
115
|
/** Encryption mode discriminant. Always `'SSE-C'` for this class. */
|
|
112
116
|
readonly mode: "SSE-C";
|
|
113
117
|
/** Encryption algorithm. B2's S3-compatible API only supports AES-256. */
|
|
@@ -126,6 +130,12 @@ export declare class EncryptionKey {
|
|
|
126
130
|
* @internal
|
|
127
131
|
*/
|
|
128
132
|
private constructor();
|
|
133
|
+
/**
|
|
134
|
+
* Generates a random 32-byte (256-bit) SSE-C key.
|
|
135
|
+
*
|
|
136
|
+
* @returns A safely-wrapped EncryptionKey ready for upload/download.
|
|
137
|
+
*/
|
|
138
|
+
static generate(): Promise<EncryptionKey>;
|
|
129
139
|
/**
|
|
130
140
|
* Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the
|
|
131
141
|
* required base64 MD5 digest internally.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/types/encryption.js"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB;IAC9B,wEAAwE;;CAEhE,CAAA;AAEV,4FAA4F;AAC5F,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAA;AAEhG;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;IACzB,kCAAkC;;IAElC,yCAAyC;;IAEzC,qBAAqB;;CAEb,CAAA;AAEV,+FAA+F;AAC/F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAA;AAEjF,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IAC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MAAM,CAAA;IAC5B,gGAAgG;IAChG,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAE/B;;;;;;;;OAQG;IACH,OAAO;IAKP;;;;OAIG;WACU,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAM/C;;;;;;;;;OASG;WACU,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IASlE;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,aAAa;IAI7E;;;;;OAKG;IACH,MAAM,IAAI;QACR,oCAAoC;QACpC,IAAI,EAAE,OAAO,CAAA;QACb,4BAA4B;QAC5B,SAAS,EAAE,mBAAmB,CAAA;QAC9B,wFAAwF;QACxF,WAAW,EAAE,MAAM,CAAA;QACnB,wFAAwF;QACxF,cAAc,EAAE,MAAM,CAAA;KACvB;IASD;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,CAAC,mBAAmB,CAAC,IAAI,MAAM;CAGhC"}
|
|
@@ -31,17 +31,26 @@ export interface SseB2Setting {
|
|
|
31
31
|
/** Encryption algorithm. Always `'AES256'`. */
|
|
32
32
|
readonly algorithm: EncryptionAlgorithm;
|
|
33
33
|
}
|
|
34
|
-
/**
|
|
35
|
-
export interface
|
|
36
|
-
/** Encryption mode discriminator. Always `'SSE-C'`. */
|
|
37
|
-
readonly mode: 'SSE-C';
|
|
34
|
+
/** Shared customer-provided SSE-C key material used by uploads and downloads. */
|
|
35
|
+
export interface SseCKeyMaterial {
|
|
38
36
|
/** Encryption algorithm. Always `'AES256'`. */
|
|
39
37
|
readonly algorithm: EncryptionAlgorithm;
|
|
40
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Base64-encoded 256-bit encryption key provided by the customer.
|
|
40
|
+
*
|
|
41
|
+
* This is secret key material. Native B2 SSE-C requests send it as an
|
|
42
|
+
* HTTP request header, so custom transports and middleware must redact
|
|
43
|
+
* request headers before logging them.
|
|
44
|
+
*/
|
|
41
45
|
readonly customerKey: string;
|
|
42
46
|
/** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */
|
|
43
47
|
readonly customerKeyMd5: string;
|
|
44
48
|
}
|
|
49
|
+
/** Server-side encryption using customer-provided keys (SSE-C). */
|
|
50
|
+
export interface SseCCustomerSetting extends SseCKeyMaterial {
|
|
51
|
+
/** Encryption mode discriminator. Always `'SSE-C'`. */
|
|
52
|
+
readonly mode: 'SSE-C';
|
|
53
|
+
}
|
|
45
54
|
/** Server-side encryption using customer-provided keys as returned by B2 responses. */
|
|
46
55
|
export interface SseCPublicSetting {
|
|
47
56
|
/** Encryption mode discriminator. Always `'SSE-C'`. */
|
|
@@ -79,11 +88,6 @@ export declare const SSE_NONE: NoEncryption;
|
|
|
79
88
|
export declare function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting;
|
|
80
89
|
export declare const SSE_C_KEY_REDACTION = "[redacted SSE-C key]";
|
|
81
90
|
declare const NODE_INSPECT_CUSTOM: unique symbol;
|
|
82
|
-
interface SseCKeyMaterial {
|
|
83
|
-
readonly algorithm: EncryptionAlgorithm;
|
|
84
|
-
readonly customerKey: string;
|
|
85
|
-
readonly customerKeyMd5: string;
|
|
86
|
-
}
|
|
87
91
|
interface SseCKeyRedactionOptions {
|
|
88
92
|
readonly label: string;
|
|
89
93
|
readonly mode?: 'SSE-C';
|
|
@@ -107,7 +111,7 @@ export declare function redactSseCKeyMaterial<T extends SseCKeyMaterial>(key: T,
|
|
|
107
111
|
* `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}
|
|
108
112
|
* to construct one from a raw 32-byte key; the MD5 digest is computed internally.
|
|
109
113
|
*/
|
|
110
|
-
export declare class EncryptionKey {
|
|
114
|
+
export declare class EncryptionKey implements SseCCustomerSetting {
|
|
111
115
|
/** Encryption mode discriminant. Always `'SSE-C'` for this class. */
|
|
112
116
|
readonly mode: "SSE-C";
|
|
113
117
|
/** Encryption algorithm. B2's S3-compatible API only supports AES-256. */
|
|
@@ -126,6 +130,12 @@ export declare class EncryptionKey {
|
|
|
126
130
|
* @internal
|
|
127
131
|
*/
|
|
128
132
|
private constructor();
|
|
133
|
+
/**
|
|
134
|
+
* Generates a random 32-byte (256-bit) SSE-C key.
|
|
135
|
+
*
|
|
136
|
+
* @returns A safely-wrapped EncryptionKey ready for upload/download.
|
|
137
|
+
*/
|
|
138
|
+
static generate(): Promise<EncryptionKey>;
|
|
129
139
|
/**
|
|
130
140
|
* Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the
|
|
131
141
|
* required base64 MD5 digest internally.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/types/encryption.js"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB;IAC9B,wEAAwE;;CAEhE,CAAA;AAEV,4FAA4F;AAC5F,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAA;AAEhG;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc;IACzB,kCAAkC;;IAElC,yCAAyC;;IAEzC,qBAAqB;;CAEb,CAAA;AAEV,+FAA+F;AAC/F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAA;AAEjF,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAA;CACxC;AAED,
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../src/types/encryption.js"],"names":[],"mappings":"AAEA,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB;IAC9B,wEAAw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EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;IASlE;;;;;;;;OAQG;IACH,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,aAAa;IAI7E;;;;;OAKG;IACH,MAAM,IAAI;QACR,oCAAoC;QACpC,IAAI,EAAE,OAAO,CAAA;QACb,4BAA4B;QAC5B,SAAS,EAAE,mBAAmB,CAAA;QAC9B,wFAAwF;QACxF,WAAW,EAAE,MAAM,CAAA;QACnB,wFAAwF;QACxF,cAAc,EAAE,MAAM,CAAA;KACvB;IASD;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,CAAC,mBAAmB,CAAC,IAAI,MAAM;CAGhC"}
|
package/dist/types/encryption.js
CHANGED
|
@@ -140,6 +140,16 @@ var EncryptionKey = class EncryptionKey {
|
|
|
140
140
|
this.customerKeyMd5 = customerKeyMd5;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
+
* Generates a random 32-byte (256-bit) SSE-C key.
|
|
144
|
+
*
|
|
145
|
+
* @returns A safely-wrapped EncryptionKey ready for upload/download.
|
|
146
|
+
*/
|
|
147
|
+
static async generate() {
|
|
148
|
+
const rawKey = /* @__PURE__ */ new Uint8Array(32);
|
|
149
|
+
getRandomValues(rawKey);
|
|
150
|
+
return EncryptionKey.fromBytes(rawKey);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
143
153
|
* Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the
|
|
144
154
|
* required base64 MD5 digest internally.
|
|
145
155
|
*
|
|
@@ -196,6 +206,14 @@ var EncryptionKey = class EncryptionKey {
|
|
|
196
206
|
return this.toString();
|
|
197
207
|
}
|
|
198
208
|
};
|
|
209
|
+
function getRandomValues(bytes) {
|
|
210
|
+
const cryptoLike = globalThis.crypto;
|
|
211
|
+
if (cryptoLike !== void 0) {
|
|
212
|
+
cryptoLike.getRandomValues(bytes);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
throw new Error("EncryptionKey.generate requires crypto.getRandomValues.");
|
|
216
|
+
}
|
|
199
217
|
//#endregion
|
|
200
218
|
export { EncryptionAlgorithm, EncryptionKey, EncryptionMode, SSE_B2, SSE_C_KEY_REDACTION, SSE_NONE, redactSseCKeyMaterial, sseCustomer };
|
|
201
219
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encryption.js","names":[],"sources":["../../src/types/encryption.ts"],"sourcesContent":["import { md5Base64 } from '../util/md5.ts'\n\n/** Named constants for the supported server-side encryption algorithms. */\nexport const EncryptionAlgorithm = {\n /** AES with a 256-bit key. The only algorithm B2 currently supports. */\n Aes256: 'AES256',\n} as const\n\n/** Supported server-side encryption algorithm. Derived from {@link EncryptionAlgorithm}. */\nexport type EncryptionAlgorithm = (typeof EncryptionAlgorithm)[keyof typeof EncryptionAlgorithm]\n\n/**\n * Named constants for the server-side encryption mode used by a file.\n *\n * Most callers should use the {@link SSE_B2}, {@link SSE_NONE}, and\n * {@link sseCustomer} helpers below which return complete\n * {@link EncryptionSetting} objects. These constants are useful when you\n * need the bare mode discriminator (e.g., when introspecting a file's\n * current encryption setting).\n */\nexport const EncryptionMode = {\n /** B2-managed encryption keys. */\n SseB2: 'SSE-B2',\n /** Customer-provided encryption keys. */\n SseC: 'SSE-C',\n /** No encryption. */\n None: 'none',\n} as const\n\n/** Server-side encryption mode for files stored in B2. Derived from {@link EncryptionMode}. */\nexport type EncryptionMode = (typeof EncryptionMode)[keyof typeof EncryptionMode]\n\n/** Server-side encryption using B2-managed keys (SSE-B2). */\nexport interface SseB2Setting {\n /** Encryption mode discriminator. Always `'SSE-B2'`. */\n readonly mode: 'SSE-B2'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Server-side encryption using customer-provided keys (SSE-C). */\nexport interface SseCCustomerSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n /** Base64-encoded 256-bit encryption key provided by the customer. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */\n readonly customerKeyMd5: string\n}\n\n/** Server-side encryption using customer-provided keys as returned by B2 responses. */\nexport interface SseCPublicSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Indicates no server-side encryption is applied. */\nexport interface NoEncryption {\n /** Encryption mode discriminator. Always `'none'`. */\n readonly mode: 'none'\n}\n\n/** No-encryption shape returned by B2 response objects. */\nexport interface NoEncryptionWireSetting {\n /** Encryption mode discriminator. B2 response payloads use null for no encryption. */\n readonly mode: null\n /** Encryption algorithm. B2 response payloads use null when no encryption is applied. */\n readonly algorithm: null\n}\n\n/** Union of all server-side encryption settings: B2-managed, customer-provided, or none. */\nexport type EncryptionSetting = SseB2Setting | SseCCustomerSetting | NoEncryption\n\n/** Server-side encryption setting returned by B2 response objects. */\nexport type PublicEncryptionSetting =\n | SseB2Setting\n | SseCPublicSetting\n | NoEncryption\n | NoEncryptionWireSetting\n\n/** Pre-built SSE-B2 encryption setting using AES-256. */\nexport const SSE_B2: SseB2Setting = { mode: 'SSE-B2', algorithm: 'AES256' }\n\n/** Pre-built setting indicating no server-side encryption. */\nexport const SSE_NONE: NoEncryption = { mode: 'none' }\n\n/**\n * Creates an SSE-C encryption setting with a customer-provided key.\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns An SSE-C encryption setting ready to pass to upload or download calls.\n */\nexport function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting {\n return { mode: 'SSE-C', algorithm: 'AES256', customerKey, customerKeyMd5 }\n}\n\n/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n // Prefer Node's Buffer when available (faster), but degrade to btoa() in\n // browsers / Deno / Workers where Buffer isn't a global. We access via\n // globalThis to avoid a hard reference to a Node-only symbol — that would\n // break the type-check in non-Node runtimes (Deno, browser-mode Vitest).\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) {\n return g.Buffer.from(bytes).toString('base64')\n }\n let binary = ''\n for (const b of bytes) binary += String.fromCharCode(b)\n return btoa(binary)\n}\n\nexport const SSE_C_KEY_REDACTION = '[redacted SSE-C key]'\n\nconst NODE_INSPECT_CUSTOM = Symbol.for('nodejs.util.inspect.custom')\n\ninterface SseCKeyMaterial {\n readonly algorithm: EncryptionAlgorithm\n readonly customerKey: string\n readonly customerKeyMd5: string\n}\n\ninterface SseCKeyRedactionOptions {\n readonly label: string\n readonly mode?: 'SSE-C'\n}\n\ninterface RedactedSseCKeyJson {\n readonly mode?: 'SSE-C'\n readonly algorithm: EncryptionAlgorithm\n readonly customerKey: string\n readonly customerKeyMd5: string\n}\n\nfunction sseCKeyRedactedJson(\n key: SseCKeyMaterial,\n options: SseCKeyRedactionOptions,\n): RedactedSseCKeyJson {\n return {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n customerKey: SSE_C_KEY_REDACTION,\n // The MD5 is not secret key material, but it is still derived from a\n // customer-provided key. Keep logged key views fully opaque by default.\n customerKeyMd5: SSE_C_KEY_REDACTION,\n }\n}\n\nfunction sseCKeyRedactedString(options: SseCKeyRedactionOptions): string {\n return `[${options.label} ${SSE_C_KEY_REDACTION}]`\n}\n\n/**\n * Wraps SSE-C key material so diagnostic stringification redacts key fields.\n *\n * The returned object keeps `customerKey` and `customerKeyMd5` readable by\n * property access for request header construction, but makes them\n * non-enumerable so object spread and generic serializers do not copy them.\n * Callers that need wire headers must read those fields directly.\n *\n * @param key - SSE-C key material to wrap.\n * @param options - Redaction label and optional encryption mode discriminator.\n *\n * @returns A redacted view with the same readable key fields.\n */\nexport function redactSseCKeyMaterial<T extends SseCKeyMaterial>(\n key: T,\n options: SseCKeyRedactionOptions,\n): T {\n const redacted = {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n } as T & {\n toJSON(): RedactedSseCKeyJson\n toString(): string\n }\n\n Object.defineProperties(redacted, {\n customerKey: { value: key.customerKey, enumerable: false },\n customerKeyMd5: { value: key.customerKeyMd5, enumerable: false },\n toJSON: { value: () => sseCKeyRedactedJson(key, options), enumerable: false },\n toString: { value: () => sseCKeyRedactedString(options), enumerable: false },\n })\n Object.defineProperty(redacted, NODE_INSPECT_CUSTOM, {\n value: () => sseCKeyRedactedString(options),\n enumerable: false,\n })\n\n return redacted\n}\n\n/**\n * Safe wrapper around an SSE-C customer key. Hides the key bytes from\n * `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}\n * to construct one from a raw 32-byte key; the MD5 digest is computed internally.\n */\nexport class EncryptionKey {\n /** Encryption mode discriminant. Always `'SSE-C'` for this class. */\n readonly mode = 'SSE-C' as const\n /** Encryption algorithm. B2's S3-compatible API only supports AES-256. */\n readonly algorithm: EncryptionAlgorithm = 'AES256'\n /** Base64-encoded 256-bit customer key. Logged as `[redacted SSE-C key]` via `toJSON` / `toString`. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification. */\n readonly customerKeyMd5: string\n\n /**\n * Internal constructor. Use {@link EncryptionKey.fromBytes} or\n * {@link EncryptionKey.fromBase64} instead.\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @internal\n */\n private constructor(customerKey: string, customerKeyMd5: string) {\n this.customerKey = customerKey\n this.customerKeyMd5 = customerKeyMd5\n }\n\n /**\n * Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the\n * required base64 MD5 digest internally.\n *\n * @param rawKey - The raw 256-bit key as bytes. Must be exactly 32 bytes.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n *\n * @throws If the key is not exactly 32 bytes.\n */\n static async fromBytes(rawKey: Uint8Array): Promise<EncryptionKey> {\n if (rawKey.byteLength !== 32) {\n throw new Error(`SSE-C key must be exactly 32 bytes (256 bits); got ${rawKey.byteLength}.`)\n }\n const customerKey = bytesToBase64(rawKey)\n const customerKeyMd5 = await md5Base64(rawKey)\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Builds an EncryptionKey from precomputed base64 strings. Use this in\n * environments where MD5 must be computed externally (e.g., browsers).\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static fromBase64(customerKey: string, customerKeyMd5: string): EncryptionKey {\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Hides the key bytes from `JSON.stringify`.\n *\n * @returns A redacted shape: same mode and algorithm, but the key and MD5\n * replaced with a placeholder string.\n */\n toJSON(): {\n /** Encryption mode discriminant. */\n mode: 'SSE-C'\n /** Encryption algorithm. */\n algorithm: EncryptionAlgorithm\n /** Always the literal redaction placeholder; the real key never leaves the instance. */\n customerKey: string\n /** Always the literal redaction placeholder; the real MD5 never leaves the instance. */\n customerKeyMd5: string\n } {\n return sseCKeyRedactedJson(this, { label: 'EncryptionKey SSE-C', mode: this.mode }) as {\n mode: 'SSE-C'\n algorithm: EncryptionAlgorithm\n customerKey: string\n customerKeyMd5: string\n }\n }\n\n /**\n * Hides the key bytes from default `toString()`.\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n toString(): string {\n return sseCKeyRedactedString({ label: 'EncryptionKey SSE-C' })\n }\n\n /**\n * Hides the key bytes from Node's `util.inspect` (and therefore `console.log`).\n *\n * @returns A short opaque label indicating this is an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;GAAE,aAAa,oBAAoB,KAAK,OAAO;GAAG,YAAY;EAAM;EAC5E,UAAU;GAAE,aAAa,sBAAsB,OAAO;GAAG,YAAY;EAAM;CAC7E,CAAC;CACD,OAAO,eAAe,UAAU,qBAAqB;EACnD,aAAa,sBAAsB,OAAO;EAC1C,YAAY;CACd,CAAC;CAED,OAAO;AACT;;;;;;AAOA,IAAa,gBAAb,MAAa,cAAc;;CAEzB,OAAgB;;CAEhB,YAA0C;;CAE1C;;CAEA;;;;;;;;;;CAWA,YAAoB,aAAqB,gBAAwB;EAC/D,KAAK,cAAc;EACnB,KAAK,iBAAiB;CACxB;;;;;;;;;;;CAYA,aAAa,UAAU,QAA4C;EACjE,IAAI,OAAO,eAAe,IACxB,MAAM,IAAI,MAAM,sDAAsD,OAAO,WAAW,EAAE;EAE5F,MAAM,cAAc,cAAc,MAAM;EACxC,MAAM,iBAAiB,MAAM,UAAU,MAAM;EAC7C,OAAO,IAAI,cAAc,aAAa,cAAc;CACtD;;;;;;;;;;CAWA,OAAO,WAAW,aAAqB,gBAAuC;EAC5E,OAAO,IAAI,cAAc,aAAa,cAAc;CACtD;;;;;;;CAQA,SASE;EACA,OAAO,oBAAoB,MAAM;GAAE,OAAO;GAAuB,MAAM,KAAK;EAAK,CAAC;CAMpF;;;;;;CAOA,WAAmB;EACjB,OAAO,sBAAsB,EAAE,OAAO,sBAAsB,CAAC;CAC/D;;;;;;CAOA,CAAC,uBAA+B;EAC9B,OAAO,KAAK,SAAS;CACvB;AACF"}
|
|
1
|
+
{"version":3,"file":"encryption.js","names":[],"sources":["../../src/types/encryption.ts"],"sourcesContent":["import { md5Base64 } from '../util/md5.ts'\n\n/** Named constants for the supported server-side encryption algorithms. */\nexport const EncryptionAlgorithm = {\n /** AES with a 256-bit key. The only algorithm B2 currently supports. */\n Aes256: 'AES256',\n} as const\n\n/** Supported server-side encryption algorithm. Derived from {@link EncryptionAlgorithm}. */\nexport type EncryptionAlgorithm = (typeof EncryptionAlgorithm)[keyof typeof EncryptionAlgorithm]\n\n/**\n * Named constants for the server-side encryption mode used by a file.\n *\n * Most callers should use the {@link SSE_B2}, {@link SSE_NONE}, and\n * {@link sseCustomer} helpers below which return complete\n * {@link EncryptionSetting} objects. These constants are useful when you\n * need the bare mode discriminator (e.g., when introspecting a file's\n * current encryption setting).\n */\nexport const EncryptionMode = {\n /** B2-managed encryption keys. */\n SseB2: 'SSE-B2',\n /** Customer-provided encryption keys. */\n SseC: 'SSE-C',\n /** No encryption. */\n None: 'none',\n} as const\n\n/** Server-side encryption mode for files stored in B2. Derived from {@link EncryptionMode}. */\nexport type EncryptionMode = (typeof EncryptionMode)[keyof typeof EncryptionMode]\n\n/** Server-side encryption using B2-managed keys (SSE-B2). */\nexport interface SseB2Setting {\n /** Encryption mode discriminator. Always `'SSE-B2'`. */\n readonly mode: 'SSE-B2'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Shared customer-provided SSE-C key material used by uploads and downloads. */\nexport interface SseCKeyMaterial {\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n /**\n * Base64-encoded 256-bit encryption key provided by the customer.\n *\n * This is secret key material. Native B2 SSE-C requests send it as an\n * HTTP request header, so custom transports and middleware must redact\n * request headers before logging them.\n */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer-provided key, used for integrity verification. */\n readonly customerKeyMd5: string\n}\n\n/** Server-side encryption using customer-provided keys (SSE-C). */\nexport interface SseCCustomerSetting extends SseCKeyMaterial {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n}\n\n/** Server-side encryption using customer-provided keys as returned by B2 responses. */\nexport interface SseCPublicSetting {\n /** Encryption mode discriminator. Always `'SSE-C'`. */\n readonly mode: 'SSE-C'\n /** Encryption algorithm. Always `'AES256'`. */\n readonly algorithm: EncryptionAlgorithm\n}\n\n/** Indicates no server-side encryption is applied. */\nexport interface NoEncryption {\n /** Encryption mode discriminator. Always `'none'`. */\n readonly mode: 'none'\n}\n\n/** No-encryption shape returned by B2 response objects. */\nexport interface NoEncryptionWireSetting {\n /** Encryption mode discriminator. B2 response payloads use null for no encryption. */\n readonly mode: null\n /** Encryption algorithm. B2 response payloads use null when no encryption is applied. */\n readonly algorithm: null\n}\n\n/** Union of all server-side encryption settings: B2-managed, customer-provided, or none. */\nexport type EncryptionSetting = SseB2Setting | SseCCustomerSetting | NoEncryption\n\n/** Server-side encryption setting returned by B2 response objects. */\nexport type PublicEncryptionSetting =\n | SseB2Setting\n | SseCPublicSetting\n | NoEncryption\n | NoEncryptionWireSetting\n\n/** Pre-built SSE-B2 encryption setting using AES-256. */\nexport const SSE_B2: SseB2Setting = { mode: 'SSE-B2', algorithm: 'AES256' }\n\n/** Pre-built setting indicating no server-side encryption. */\nexport const SSE_NONE: NoEncryption = { mode: 'none' }\n\n/**\n * Creates an SSE-C encryption setting with a customer-provided key.\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns An SSE-C encryption setting ready to pass to upload or download calls.\n */\nexport function sseCustomer(customerKey: string, customerKeyMd5: string): SseCCustomerSetting {\n return { mode: 'SSE-C', algorithm: 'AES256', customerKey, customerKeyMd5 }\n}\n\n/**\n * Encodes raw bytes as base64 in an isomorphic way (Node Buffer fallback to btoa).\n *\n * @param bytes - The raw bytes to encode.\n *\n * @returns The base64-encoded string.\n */\nfunction bytesToBase64(bytes: Uint8Array): string {\n // Prefer Node's Buffer when available (faster), but degrade to btoa() in\n // browsers / Deno / Workers where Buffer isn't a global. We access via\n // globalThis to avoid a hard reference to a Node-only symbol — that would\n // break the type-check in non-Node runtimes (Deno, browser-mode Vitest).\n const g = globalThis as {\n Buffer?: { from(b: Uint8Array): { toString(encoding: string): string } }\n }\n if (g.Buffer) {\n return g.Buffer.from(bytes).toString('base64')\n }\n let binary = ''\n for (const b of bytes) binary += String.fromCharCode(b)\n return btoa(binary)\n}\n\nexport const SSE_C_KEY_REDACTION = '[redacted SSE-C key]'\n\nconst NODE_INSPECT_CUSTOM = Symbol.for('nodejs.util.inspect.custom')\n\ninterface SseCKeyRedactionOptions {\n readonly label: string\n readonly mode?: 'SSE-C'\n}\n\ninterface RedactedSseCKeyJson {\n readonly mode?: 'SSE-C'\n readonly algorithm: EncryptionAlgorithm\n readonly customerKey: string\n readonly customerKeyMd5: string\n}\n\nfunction sseCKeyRedactedJson(\n key: SseCKeyMaterial,\n options: SseCKeyRedactionOptions,\n): RedactedSseCKeyJson {\n return {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n customerKey: SSE_C_KEY_REDACTION,\n // The MD5 is not secret key material, but it is still derived from a\n // customer-provided key. Keep logged key views fully opaque by default.\n customerKeyMd5: SSE_C_KEY_REDACTION,\n }\n}\n\nfunction sseCKeyRedactedString(options: SseCKeyRedactionOptions): string {\n return `[${options.label} ${SSE_C_KEY_REDACTION}]`\n}\n\n/**\n * Wraps SSE-C key material so diagnostic stringification redacts key fields.\n *\n * The returned object keeps `customerKey` and `customerKeyMd5` readable by\n * property access for request header construction, but makes them\n * non-enumerable so object spread and generic serializers do not copy them.\n * Callers that need wire headers must read those fields directly.\n *\n * @param key - SSE-C key material to wrap.\n * @param options - Redaction label and optional encryption mode discriminator.\n *\n * @returns A redacted view with the same readable key fields.\n */\nexport function redactSseCKeyMaterial<T extends SseCKeyMaterial>(\n key: T,\n options: SseCKeyRedactionOptions,\n): T {\n const redacted = {\n ...(options.mode !== undefined ? { mode: options.mode } : {}),\n algorithm: key.algorithm,\n } as T & {\n toJSON(): RedactedSseCKeyJson\n toString(): string\n }\n\n Object.defineProperties(redacted, {\n customerKey: { value: key.customerKey, enumerable: false },\n customerKeyMd5: { value: key.customerKeyMd5, enumerable: false },\n toJSON: { value: () => sseCKeyRedactedJson(key, options), enumerable: false },\n toString: { value: () => sseCKeyRedactedString(options), enumerable: false },\n })\n Object.defineProperty(redacted, NODE_INSPECT_CUSTOM, {\n value: () => sseCKeyRedactedString(options),\n enumerable: false,\n })\n\n return redacted\n}\n\n/**\n * Safe wrapper around an SSE-C customer key. Hides the key bytes from\n * `JSON.stringify`, `console.log`, and Node's `util.inspect`. Use {@link EncryptionKey.fromBytes}\n * to construct one from a raw 32-byte key; the MD5 digest is computed internally.\n */\nexport class EncryptionKey implements SseCCustomerSetting {\n /** Encryption mode discriminant. Always `'SSE-C'` for this class. */\n readonly mode = 'SSE-C' as const\n /** Encryption algorithm. B2's S3-compatible API only supports AES-256. */\n readonly algorithm: EncryptionAlgorithm = 'AES256'\n /** Base64-encoded 256-bit customer key. Logged as `[redacted SSE-C key]` via `toJSON` / `toString`. */\n readonly customerKey: string\n /** Base64-encoded MD5 digest of the customer key. Required by B2 for integrity verification. */\n readonly customerKeyMd5: string\n\n /**\n * Internal constructor. Use {@link EncryptionKey.fromBytes} or\n * {@link EncryptionKey.fromBase64} instead.\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @internal\n */\n private constructor(customerKey: string, customerKeyMd5: string) {\n this.customerKey = customerKey\n this.customerKeyMd5 = customerKeyMd5\n }\n\n /**\n * Generates a random 32-byte (256-bit) SSE-C key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static async generate(): Promise<EncryptionKey> {\n const rawKey = new Uint8Array(32)\n getRandomValues(rawKey)\n return EncryptionKey.fromBytes(rawKey)\n }\n\n /**\n * Builds an EncryptionKey from a raw 32-byte (256-bit) key. Computes the\n * required base64 MD5 digest internally.\n *\n * @param rawKey - The raw 256-bit key as bytes. Must be exactly 32 bytes.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n *\n * @throws If the key is not exactly 32 bytes.\n */\n static async fromBytes(rawKey: Uint8Array): Promise<EncryptionKey> {\n if (rawKey.byteLength !== 32) {\n throw new Error(`SSE-C key must be exactly 32 bytes (256 bits); got ${rawKey.byteLength}.`)\n }\n const customerKey = bytesToBase64(rawKey)\n const customerKeyMd5 = await md5Base64(rawKey)\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Builds an EncryptionKey from precomputed base64 strings. Use this in\n * environments where MD5 must be computed externally (e.g., browsers).\n *\n * @param customerKey - Base64-encoded 256-bit encryption key.\n * @param customerKeyMd5 - Base64-encoded MD5 digest of the key.\n *\n * @returns A safely-wrapped EncryptionKey ready for upload/download.\n */\n static fromBase64(customerKey: string, customerKeyMd5: string): EncryptionKey {\n return new EncryptionKey(customerKey, customerKeyMd5)\n }\n\n /**\n * Hides the key bytes from `JSON.stringify`.\n *\n * @returns A redacted shape: same mode and algorithm, but the key and MD5\n * replaced with a placeholder string.\n */\n toJSON(): {\n /** Encryption mode discriminant. */\n mode: 'SSE-C'\n /** Encryption algorithm. */\n algorithm: EncryptionAlgorithm\n /** Always the literal redaction placeholder; the real key never leaves the instance. */\n customerKey: string\n /** Always the literal redaction placeholder; the real MD5 never leaves the instance. */\n customerKeyMd5: string\n } {\n return sseCKeyRedactedJson(this, { label: 'EncryptionKey SSE-C', mode: this.mode }) as {\n mode: 'SSE-C'\n algorithm: EncryptionAlgorithm\n customerKey: string\n customerKeyMd5: string\n }\n }\n\n /**\n * Hides the key bytes from default `toString()`.\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n toString(): string {\n return sseCKeyRedactedString({ label: 'EncryptionKey SSE-C' })\n }\n\n /**\n * Hides the key bytes from Node's `util.inspect` (and therefore `console.log`).\n *\n * @returns A short opaque label indicating this is an SSE-C key.\n */\n [NODE_INSPECT_CUSTOM](): string {\n return this.toString()\n }\n}\n\nfunction getRandomValues(bytes: Uint8Array): void {\n const cryptoLike = globalThis.crypto as\n | { getRandomValues<T extends Uint8Array>(array: T): T }\n | undefined\n if (cryptoLike !== undefined) {\n cryptoLike.getRandomValues(bytes)\n return\n }\n\n throw new Error('EncryptionKey.generate requires crypto.getRandomValues.')\n}\n"],"mappings":";;;AAGA,I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20
|
Copy: "copy"
|
|
21
21
|
};
|
|
22
|
+
/** MIME type B2 returns for hide-marker rows in `b2_list_file_versions`. */
|
|
23
|
+
var HIDE_MARKER_CONTENT_TYPE = "application/x-bz-hide-marker";
|
|
22
24
|
/**
|
|
23
25
|
* Named constants for how metadata is handled during a file copy.
|
|
24
26
|
*
|
|
@@ -35,6 +37,7 @@ var MetadataDirective = {
|
|
|
35
37
|
};
|
|
36
38
|
//#endregion
|
|
37
39
|
exports.FileAction = FileAction;
|
|
40
|
+
exports.HIDE_MARKER_CONTENT_TYPE = HIDE_MARKER_CONTENT_TYPE;
|
|
38
41
|
exports.MetadataDirective = MetadataDirective;
|
|
39
42
|
|
|
40
43
|
//# sourceMappingURL=file.cjs.map
|
package/dist/types/file.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.cjs","names":[],"sources":["../../src/types/file.ts"],"sourcesContent":["import type { EncryptionSetting, PublicEncryptionSetting } from './encryption.ts'\nimport type { AccountId, BucketId, FileId } from './ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './lock.ts'\n\n/**\n * Named constants for the action that created a file version.\n *\n * @example\n * ```ts\n * if (file.action === FileAction.Hide) { ... }\n * ```\n */\nexport const FileAction = {\n /** Large file upload started but not yet finished. */\n Start: 'start',\n /** Normal upload (small or finished large file). */\n Upload: 'upload',\n /** Hide marker (soft delete). */\n Hide: 'hide',\n /** Virtual folder marker. */\n Folder: 'folder',\n /** Created via server-side copy. */\n Copy: 'copy',\n} as const\n\n/**\n * The action that created a file version. Derived from {@link FileAction}.\n *\n * - `'start'`: large file upload started but not yet finished.\n * - `'upload'`: file was uploaded normally.\n * - `'hide'`: file was hidden (soft-deleted).\n * - `'folder'`: virtual folder marker.\n * - `'copy'`: file was created via server-side copy.\n */\nexport type FileAction = (typeof FileAction)[keyof typeof FileAction]\n\n/**\n * Replication status for a file version or unfinished large file.\n *\n * B2 returns these uppercase wire values as-is and omits the containing\n * `replicationStatus` field when the file is not covered by a replication rule.\n */\nexport type ReplicationStatus = 'PENDING' | 'COMPLETED' | 'FAILED' | 'REPLICA'\n\n/**\n * Complete metadata for a single file version in B2.\n * Returned by `b2_get_file_info`, `b2_list_file_names`, `b2_list_file_versions`,\n * `b2_upload_file`, `b2_copy_file`, and other file-related endpoints.\n */\nexport interface FileVersion {\n /** Account that owns this file. */\n readonly accountId: AccountId\n /** Action that created this file version. */\n readonly action: FileAction\n /** Bucket containing this file. */\n readonly bucketId: BucketId\n /** Size of the file content in bytes. */\n readonly contentLength: number\n /** MD5 checksum of the content, or null if not available. */\n readonly contentMd5: string | null\n /** SHA-1 checksum of the content, or null if not available (e.g., large files). */\n readonly contentSha1: string | null\n /** MIME type of the file content. */\n readonly contentType: string\n /** Unique identifier for this file version. */\n readonly fileId: FileId\n /** User-defined key-value metadata stored with the file. */\n readonly fileInfo: Record<string, string>\n /** Full path and name of the file within the bucket. */\n readonly fileName: string\n /** Object Lock retention settings for this file version. */\n readonly fileRetention: {\n /** Whether the caller is authorized to read retention settings. */\n readonly isClientAuthorizedToRead: boolean\n /** Retention settings, or null if the caller lacks read authorization. */\n readonly value: FileRetentionValue | null\n }\n /** Legal hold status for this file version. */\n readonly legalHold: {\n /** Whether the caller is authorized to read legal hold status. */\n readonly isClientAuthorizedToRead: boolean\n /** Legal hold value, or null if the caller lacks read authorization. */\n readonly value: LegalHoldValue | null\n }\n /** Replication status when this file is covered by a replication rule. */\n readonly replicationStatus?: ReplicationStatus\n /** Server-side encryption settings applied to this file version. */\n readonly serverSideEncryption: PublicEncryptionSetting\n /** UTC timestamp (milliseconds) when this version was uploaded. */\n readonly uploadTimestamp: number\n}\n\n/** Request parameters for the `b2_list_file_names` API call. Lists the most recent version of each file in a bucket. */\nexport interface ListFileNamesRequest {\n /** Bucket to list files from. */\n readonly bucketId: BucketId\n /** Return files starting after this name (exclusive). Used for pagination. */\n readonly startFileName?: string\n /** Maximum number of files to return (1 to 10000). */\n readonly maxFileCount?: number\n /** Only return files whose names start with this prefix. */\n readonly prefix?: string\n /** Delimiter for virtual folder grouping (typically `'/'`). */\n readonly delimiter?: string\n}\n\n/** Response from the `b2_list_file_names` API call. */\nexport interface ListFileNamesResponse {\n /** Array of file versions matching the request. */\n readonly files: readonly FileVersion[]\n /** Next file name to use for pagination, or null if all files have been listed. */\n readonly nextFileName: string | null\n}\n\n/** Request parameters for the `b2_list_file_versions` API call. Lists all versions of files in a bucket. */\nexport interface ListFileVersionsRequest {\n /** Bucket to list file versions from. */\n readonly bucketId: BucketId\n /** Return files starting after this name (exclusive). Used for pagination. */\n readonly startFileName?: string\n /** Return file versions starting after this ID. Used with startFileName for pagination. */\n readonly startFileId?: FileId\n /** Maximum number of file versions to return (1 to 10000). */\n readonly maxFileCount?: number\n /** Only return files whose names start with this prefix. */\n readonly prefix?: string\n /** Delimiter for virtual folder grouping (typically `'/'`). */\n readonly delimiter?: string\n}\n\n/** Response from the `b2_list_file_versions` API call. */\nexport interface ListFileVersionsResponse {\n /** Array of file versions matching the request. */\n readonly files: readonly FileVersion[]\n /** Next file name to use for pagination, or null if all versions have been listed. */\n readonly nextFileName: string | null\n /** Next file ID to use for pagination, or null if all versions have been listed. */\n readonly nextFileId: FileId | null\n}\n\n/** Request parameters for the `b2_get_file_info` API call. */\nexport interface GetFileInfoRequest {\n /** ID of the file version to retrieve info for. */\n readonly fileId: FileId\n}\n\n/** Request parameters for the `b2_hide_file` API call. Hides a file so it no longer appears in `b2_list_file_names`. */\nexport interface HideFileRequest {\n /** Bucket containing the file to hide. */\n readonly bucketId: BucketId\n /** Name of the file to hide. */\n readonly fileName: string\n}\n\n/** Request parameters for the `b2_delete_file_version` API call. */\nexport interface DeleteFileVersionRequest {\n /** Name of the file version to delete. */\n readonly fileName: string\n /** ID of the file version to delete. */\n readonly fileId: FileId\n /** If true, bypass governance-mode retention. Requires the `bypassGovernance` capability. */\n readonly bypassGovernance?: boolean\n}\n\n/** Response from the `b2_delete_file_version` API call. */\nexport interface DeleteFileVersionResponse {\n /** ID of the deleted file version. */\n readonly fileId: FileId\n /** Name of the deleted file. */\n readonly fileName: string\n}\n\n/**\n * Named constants for how metadata is handled during a file copy.\n *\n * @example\n * ```ts\n * await bucket.copyFile({ ..., metadataDirective: MetadataDirective.Replace })\n * ```\n */\nexport const MetadataDirective = {\n /** Preserve the source file's contentType and fileInfo. */\n Copy: 'COPY',\n /** Use the values provided in the copy request. */\n Replace: 'REPLACE',\n} as const\n\n/** Controls how metadata is handled during a file copy. Derived from {@link MetadataDirective}. */\nexport type MetadataDirective = (typeof MetadataDirective)[keyof typeof MetadataDirective]\n\n/** Request parameters for the `b2_copy_file` API call. Performs a server-side file copy. */\nexport interface CopyFileRequest {\n /** ID of the source file version to copy from. */\n readonly sourceFileId: FileId\n /** Destination bucket ID. Defaults to the source bucket if omitted. */\n readonly destinationBucketId?: BucketId\n /** Name for the destination file. */\n readonly fileName: string\n /** Byte range to copy (e.g., `'bytes=0-999'`). Omit to copy the entire file. */\n readonly range?: string\n /** Whether to copy or replace the source file's metadata. */\n readonly metadataDirective?: MetadataDirective\n /** MIME type for the destination file (only used when metadataDirective is `'REPLACE'`). */\n readonly contentType?: string\n /** User-defined metadata for the destination file (only used when metadataDirective is `'REPLACE'`). */\n readonly fileInfo?: Record<string, string>\n /** Object Lock retention for the destination file. */\n readonly fileRetention?: FileRetentionValue\n /** Legal hold for the destination file. */\n readonly legalHold?: LegalHoldValue\n /** SSE-C settings for reading the source file, if the source is encrypted with SSE-C. */\n readonly sourceServerSideEncryption?: EncryptionSetting\n /** Server-side encryption to apply to the destination file. */\n readonly destinationServerSideEncryption?: EncryptionSetting\n}\n\n/** Request parameters for the `b2_copy_part` API call. Copies a byte range into a large file part. */\nexport interface CopyPartRequest {\n /** ID of the source file version to copy from. */\n readonly sourceFileId: FileId\n /** ID of the large file being assembled. */\n readonly largeFileId: FileId\n /** Part number (1-based) for this part within the large file. */\n readonly partNumber: number\n /** Byte range to copy from the source (e.g., `'bytes=0-999'`). Omit to copy the entire source. */\n readonly range?: string\n /** SSE-C settings for reading the source file, if the source is encrypted with SSE-C. */\n readonly sourceServerSideEncryption?: EncryptionSetting\n /** Server-side encryption to apply to the destination part. */\n readonly destinationServerSideEncryption?: EncryptionSetting\n}\n\n/** Response from the `b2_copy_part` API call. */\nexport interface CopyPartResponse {\n /** ID of the large file this part belongs to. */\n readonly fileId: FileId\n /** Part number within the large file. */\n readonly partNumber: number\n /** Size of the copied part in bytes. */\n readonly contentLength: number\n /** SHA-1 checksum of the copied part content. */\n readonly contentSha1: string\n /** MD5 checksum of the copied part content, or null if not available. */\n readonly contentMd5: string | null\n /** Server-side encryption applied to this copied part. */\n readonly serverSideEncryption: PublicEncryptionSetting\n /** UTC timestamp (milliseconds) when this part was copied. */\n readonly uploadTimestamp: number\n}\n"],"mappings":";;;;;;;;;AAYA,IAAa,aAAa;;CAExB,OAAO;;CAEP,QAAQ;;CAER,MAAM;;CAEN,QAAQ;;CAER,MAAM;AACR;;;;;;;;;AA6JA,IAAa,oBAAoB;;CAE/B,MAAM;;CAEN,SAAS;AACX"}
|
|
1
|
+
{"version":3,"file":"file.cjs","names":[],"sources":["../../src/types/file.ts"],"sourcesContent":["import type { EncryptionSetting, PublicEncryptionSetting } from './encryption.ts'\nimport type { AccountId, BucketId, FileId } from './ids.ts'\nimport type { FileRetentionValue, LegalHoldValue } from './lock.ts'\n\n/**\n * Named constants for the action that created a file version.\n *\n * @example\n * ```ts\n * if (file.action === FileAction.Hide) { ... }\n * ```\n */\nexport const FileAction = {\n /** Large file upload started but not yet finished. */\n Start: 'start',\n /** Normal upload (small or finished large file). */\n Upload: 'upload',\n /** Hide marker (soft delete). */\n Hide: 'hide',\n /** Virtual folder marker. */\n Folder: 'folder',\n /** Created via server-side copy. */\n Copy: 'copy',\n} as const\n\n/** MIME type B2 returns for hide-marker rows in `b2_list_file_versions`. */\nexport const HIDE_MARKER_CONTENT_TYPE = 'application/x-bz-hide-marker' as const\n\n/**\n * The action that created a file version. Derived from {@link FileAction}.\n *\n * - `'start'`: large file upload started but not yet finished.\n * - `'upload'`: file was uploaded normally.\n * - `'hide'`: file was hidden (soft-deleted).\n * - `'folder'`: virtual folder marker.\n * - `'copy'`: file was created via server-side copy.\n */\nexport type FileAction = (typeof FileAction)[keyof typeof FileAction]\n\n/** File actions that represent concrete file versions with a B2 file ID. */\nexport type ConcreteFileAction = Exclude<FileAction, typeof FileAction.Folder>\n\n/** File actions that represent listed concrete versions with file metadata. */\nexport type ListedFileAction = Exclude<ConcreteFileAction, typeof FileAction.Hide>\n\n/**\n * Replication status for a file version or unfinished large file.\n *\n * B2 returns these uppercase wire values as-is and omits the containing\n * `replicationStatus` field when the file is not covered by a replication rule.\n */\nexport type ReplicationStatus = 'PENDING' | 'COMPLETED' | 'FAILED' | 'REPLICA'\n\n/**\n * Complete metadata for a concrete file version in B2. Returned by\n * `b2_get_file_info`, `b2_upload_file`, `b2_copy_file`, `b2_hide_file`, and\n * other file-related endpoints. List endpoints return\n * {@link ListedFileVersion} for file-name listings and\n * {@link ListedConcreteFileVersion} for file-version listings unless a\n * delimiter is requested, in which case file-name listings return\n * {@link FileNameListEntry} and file-version listings return\n * {@link FileVersionListEntry}.\n */\nexport interface FileVersion {\n /** Account that owns this file. */\n readonly accountId: AccountId\n /** Action that created this file version. */\n readonly action: ConcreteFileAction\n /** Bucket containing this file. */\n readonly bucketId: BucketId\n /** Size of the file content in bytes. */\n readonly contentLength: number\n /** MD5 checksum of the content, or null if not available. */\n readonly contentMd5: string | null\n /** SHA-1 checksum of the content, or null if not available (e.g., large files). */\n readonly contentSha1: string | null\n /** MIME type of the file content. */\n readonly contentType: string\n /** Unique identifier for this file version. */\n readonly fileId: FileId\n /** User-defined key-value metadata stored with the file. */\n readonly fileInfo: Record<string, string>\n /** Full path and name of the file within the bucket. */\n readonly fileName: string\n /** Object Lock retention settings for this file version. */\n readonly fileRetention: {\n /** Whether the caller is authorized to read retention settings. */\n readonly isClientAuthorizedToRead: boolean\n /** Retention settings, or null if the caller lacks read authorization. */\n readonly value: FileRetentionValue | null\n }\n /** Legal hold status for this file version. */\n readonly legalHold: {\n /** Whether the caller is authorized to read legal hold status. */\n readonly isClientAuthorizedToRead: boolean\n /** Legal hold value, or null if the caller lacks read authorization. */\n readonly value: LegalHoldValue | null\n }\n /** Replication status when this file is covered by a replication rule. */\n readonly replicationStatus?: ReplicationStatus\n /** Server-side encryption settings applied to this file version. */\n readonly serverSideEncryption: PublicEncryptionSetting\n /** UTC timestamp (milliseconds) when this version was uploaded. */\n readonly uploadTimestamp: number\n}\n\n/** Concrete non-hide file version as returned from list endpoints. */\nexport interface ListedFileVersion extends Omit<FileVersion, 'action'> {\n /** Non-hide action with full file metadata. */\n readonly action: ListedFileAction\n}\n\n/** Hide marker as returned from list endpoints when B2 omits metadata fields. */\nexport interface ListedHideFileVersion\n extends Omit<\n FileVersion,\n 'action' | 'contentType' | 'fileRetention' | 'legalHold' | 'serverSideEncryption'\n > {\n /** Hide marker (soft delete). */\n readonly action: typeof FileAction.Hide\n /** B2 list APIs return the documented hide-marker MIME type. */\n readonly contentType: typeof HIDE_MARKER_CONTENT_TYPE\n}\n\n/** Virtual folder row returned by list endpoints when a delimiter groups file names. */\nexport interface FolderFileVersion {\n /** Account that owns this bucket. */\n readonly accountId: AccountId\n /** Virtual folder marker. */\n readonly action: typeof FileAction.Folder\n /** Bucket containing the grouped files. */\n readonly bucketId: BucketId\n /** Always 0 for virtual folder rows. */\n readonly contentLength: 0\n /** Always null for virtual folder rows. */\n readonly contentMd5: null\n /** Always null for virtual folder rows. */\n readonly contentSha1: null\n /** Always null for virtual folder rows. */\n readonly contentType: null\n /** Always null for virtual folder rows. */\n readonly fileId: null\n /** Virtual folder rows do not carry file metadata. */\n readonly fileInfo: Record<string, string>\n /** Folder name, including the delimiter suffix. */\n readonly fileName: string\n /** Always 0 for virtual folder rows. */\n readonly uploadTimestamp: 0\n}\n\n/** Concrete file-version entry returned by list endpoints. */\nexport type ListedConcreteFileVersion = ListedFileVersion | ListedHideFileVersion\n\n/** Entry returned by `b2_list_file_names` when a delimiter groups file names. */\nexport type FileNameListEntry = ListedFileVersion | FolderFileVersion\n\n/** Entry returned by `b2_list_file_names` and `b2_list_file_versions`. */\nexport type FileVersionListEntry = ListedConcreteFileVersion | FolderFileVersion\n\n/**\n * Request parameters shared by `b2_list_file_names` calls.\n */\nexport interface ListFileNamesBaseRequest {\n /** Bucket to list files from. */\n readonly bucketId: BucketId\n /** Return files starting after this name (exclusive). Used for pagination. */\n readonly startFileName?: string\n /** Maximum number of files to return (1 to 10000). */\n readonly maxFileCount?: number\n /** Only return files whose names start with this prefix. */\n readonly prefix?: string\n}\n\n/**\n * Request parameters for the non-delimiter `b2_list_file_names` API call.\n * Lists visible latest file versions in a bucket without hide markers or\n * virtual folder rows. Use {@link ListFileNamesWithDelimiterRequest} when\n * sending a `delimiter`.\n */\nexport interface ListFileNamesRequest extends ListFileNamesBaseRequest {\n /** Omit delimiter to receive only visible concrete file-version entries. */\n readonly delimiter?: undefined\n}\n\n/** Request parameters for delimiter-grouped `b2_list_file_names` calls. */\nexport interface ListFileNamesWithDelimiterRequest extends ListFileNamesBaseRequest {\n /** Delimiter for virtual folder grouping (typically `'/'`). */\n readonly delimiter: string\n}\n\n/** Request parameters for callers that dynamically include a delimiter. */\nexport interface ListFileNamesMaybeDelimiterRequest extends ListFileNamesBaseRequest {\n /** Optional delimiter for virtual folder grouping. */\n readonly delimiter?: string | undefined\n}\n\n/** Response from non-delimiter `b2_list_file_names` calls. */\nexport interface ListFileNamesResponse {\n /** Array of visible concrete file-version entries matching the request. */\n readonly files: readonly ListedFileVersion[]\n /** Next file name to use for pagination, or null if all files have been listed. */\n readonly nextFileName: string | null\n}\n\n/** Response from delimiter-grouped `b2_list_file_names` calls. */\nexport interface ListFileNamesWithDelimiterResponse {\n /** Array of visible concrete file-version or virtual-folder entries. */\n readonly files: readonly FileNameListEntry[]\n /** Next file name to use for pagination, or null if all files have been listed. */\n readonly nextFileName: string | null\n}\n\n/**\n * Request parameters shared by `b2_list_file_versions` calls.\n */\nexport interface ListFileVersionsBaseRequest {\n /** Bucket to list file versions from. */\n readonly bucketId: BucketId\n /** Return files starting after this name (exclusive). Used for pagination. */\n readonly startFileName?: string\n /** Return file versions starting after this ID. Used with startFileName for pagination. */\n readonly startFileId?: FileId\n /** Maximum number of file versions to return (1 to 10000). */\n readonly maxFileCount?: number\n /** Only return files whose names start with this prefix. */\n readonly prefix?: string\n}\n\n/**\n * Request parameters for the non-delimiter `b2_list_file_versions` API call.\n * Lists all versions of files in a bucket without virtual folder rows. Use\n * {@link ListFileVersionsWithDelimiterRequest} when sending a `delimiter`.\n */\nexport interface ListFileVersionsRequest extends ListFileVersionsBaseRequest {\n /** Omit delimiter to receive only concrete file-version entries. */\n readonly delimiter?: undefined\n}\n\n/** Request parameters for delimiter-grouped `b2_list_file_versions` calls. */\nexport interface ListFileVersionsWithDelimiterRequest extends ListFileVersionsBaseRequest {\n /** Delimiter for virtual folder grouping (typically `'/'`). */\n readonly delimiter: string\n}\n\n/** Request parameters for callers that dynamically include a delimiter. */\nexport interface ListFileVersionsMaybeDelimiterRequest extends ListFileVersionsBaseRequest {\n /** Optional delimiter for virtual folder grouping. */\n readonly delimiter?: string | undefined\n}\n\n/** Response from non-delimiter `b2_list_file_versions` calls. */\nexport interface ListFileVersionsResponse {\n /** Array of concrete file-version entries matching the request. */\n readonly files: readonly ListedConcreteFileVersion[]\n /** Next file name to use for pagination, or null if all versions have been listed. */\n readonly nextFileName: string | null\n /** Next file ID to use for pagination, or null if all versions have been listed. */\n readonly nextFileId: FileId | null\n}\n\n/** Response from delimiter-grouped `b2_list_file_versions` calls. */\nexport interface ListFileVersionsWithDelimiterResponse {\n /** Array of concrete file-version or virtual-folder entries matching the request. */\n readonly files: readonly FileVersionListEntry[]\n /** Next file name to use for pagination, or null if all versions have been listed. */\n readonly nextFileName: string | null\n /** Next file ID to use for pagination, or null if all versions have been listed. */\n readonly nextFileId: FileId | null\n}\n\n/** Request parameters for the `b2_get_file_info` API call. */\nexport interface GetFileInfoRequest {\n /** ID of the file version to retrieve info for. */\n readonly fileId: FileId\n}\n\n/** Request parameters for the `b2_hide_file` API call. Hides a file so it no longer appears in `b2_list_file_names`. */\nexport interface HideFileRequest {\n /** Bucket containing the file to hide. */\n readonly bucketId: BucketId\n /** Name of the file to hide. */\n readonly fileName: string\n}\n\n/** Request parameters for the `b2_delete_file_version` API call. */\nexport interface DeleteFileVersionRequest {\n /** Name of the file version to delete. */\n readonly fileName: string\n /** ID of the file version to delete. */\n readonly fileId: FileId\n /** If true, bypass governance-mode retention. Requires the `bypassGovernance` capability. */\n readonly bypassGovernance?: boolean\n}\n\n/** Response from the `b2_delete_file_version` API call. */\nexport interface DeleteFileVersionResponse {\n /** ID of the deleted file version. */\n readonly fileId: FileId\n /** Name of the deleted file. */\n readonly fileName: string\n}\n\n/**\n * Named constants for how metadata is handled during a file copy.\n *\n * @example\n * ```ts\n * await bucket.copyFile({ ..., metadataDirective: MetadataDirective.Replace })\n * ```\n */\nexport const MetadataDirective = {\n /** Preserve the source file's contentType and fileInfo. */\n Copy: 'COPY',\n /** Use the values provided in the copy request. */\n Replace: 'REPLACE',\n} as const\n\n/** Controls how metadata is handled during a file copy. Derived from {@link MetadataDirective}. */\nexport type MetadataDirective = (typeof MetadataDirective)[keyof typeof MetadataDirective]\n\n/** Request parameters for the `b2_copy_file` API call. Performs a server-side file copy. */\nexport interface CopyFileRequest {\n /** ID of the source file version to copy from. */\n readonly sourceFileId: FileId\n /** Destination bucket ID. Defaults to the source bucket if omitted. */\n readonly destinationBucketId?: BucketId\n /** Name for the destination file. */\n readonly fileName: string\n /** Byte range to copy (e.g., `'bytes=0-999'`). Omit to copy the entire file. */\n readonly range?: string\n /** Whether to copy or replace the source file's metadata. */\n readonly metadataDirective?: MetadataDirective\n /** MIME type for the destination file (only used when metadataDirective is `'REPLACE'`). */\n readonly contentType?: string\n /** User-defined metadata for the destination file (only used when metadataDirective is `'REPLACE'`). */\n readonly fileInfo?: Record<string, string>\n /** Object Lock retention for the destination file. */\n readonly fileRetention?: FileRetentionValue\n /** Legal hold for the destination file. */\n readonly legalHold?: LegalHoldValue\n /** SSE-C settings for reading the source file, if the source is encrypted with SSE-C. */\n readonly sourceServerSideEncryption?: EncryptionSetting\n /** Server-side encryption to apply to the destination file. */\n readonly destinationServerSideEncryption?: EncryptionSetting\n}\n\n/** Request parameters for the `b2_copy_part` API call. Copies a byte range into a large file part. */\nexport interface CopyPartRequest {\n /** ID of the source file version to copy from. */\n readonly sourceFileId: FileId\n /** ID of the large file being assembled. */\n readonly largeFileId: FileId\n /** Part number (1-based) for this part within the large file. */\n readonly partNumber: number\n /** Byte range to copy from the source (e.g., `'bytes=0-999'`). Omit to copy the entire source. */\n readonly range?: string\n /** SSE-C settings for reading the source file, if the source is encrypted with SSE-C. */\n readonly sourceServerSideEncryption?: EncryptionSetting\n /** Server-side encryption to apply to the destination part. */\n readonly destinationServerSideEncryption?: EncryptionSetting\n}\n\n/** Response from the `b2_copy_part` API call. */\nexport interface CopyPartResponse {\n /** ID of the large file this part belongs to. */\n readonly fileId: FileId\n /** Part number within the large file. */\n readonly partNumber: number\n /** Size of the copied part in bytes. */\n readonly contentLength: number\n /** SHA-1 checksum of the copied part content. */\n readonly contentSha1: string\n /** MD5 checksum of the copied part content, or null if not available. */\n readonly contentMd5: string | null\n /** Server-side encryption applied to this copied part. */\n readonly serverSideEncryption: PublicEncryptionSetting\n /** UTC timestamp (milliseconds) when this part was copied. */\n readonly uploadTimestamp: number\n}\n"],"mappings":";;;;;;;;;AAYA,IAAa,aAAa;;CAExB,OAAO;;CAEP,QAAQ;;CAER,MAAM;;CAEN,QAAQ;;CAER,MAAM;AACR;;AAGA,IAAa,2BAA2B;;;;;;;;;AA4RxC,IAAa,oBAAoB;;CAE/B,MAAM;;CAEN,SAAS;AACX"}
|