@backblaze-labs/b2-sdk 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +151 -5
- package/README.md +163 -34
- package/dist/_virtual/_b2-sdk-version-json.cjs +4 -0
- package/dist/_virtual/_b2-sdk-version-json.js +4 -0
- package/dist/auth/account-info.d.cts +32 -0
- package/dist/auth/account-info.d.cts.map +1 -1
- package/dist/auth/account-info.d.ts +32 -0
- package/dist/auth/account-info.d.ts.map +1 -1
- package/dist/auth/file.cjs +408 -207
- package/dist/auth/file.cjs.map +1 -1
- package/dist/auth/file.d.cts +77 -3
- package/dist/auth/file.d.cts.map +1 -1
- package/dist/auth/file.d.ts +77 -3
- package/dist/auth/file.d.ts.map +1 -1
- package/dist/auth/file.js +407 -207
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/in-memory.cjs +212 -183
- package/dist/auth/in-memory.cjs.map +1 -1
- package/dist/auth/in-memory.d.cts +8 -0
- package/dist/auth/in-memory.d.cts.map +1 -1
- package/dist/auth/in-memory.d.ts +8 -0
- package/dist/auth/in-memory.d.ts.map +1 -1
- package/dist/auth/in-memory.js +211 -182
- package/dist/auth/in-memory.js.map +1 -1
- package/dist/auth/index.cjs +7 -9
- package/dist/auth/index.d.cts +3 -2
- package/dist/auth/index.d.cts.map +1 -1
- package/dist/auth/index.d.ts +3 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +2 -8
- package/dist/auth/realms.cjs +80 -7
- package/dist/auth/realms.cjs.map +1 -1
- package/dist/auth/realms.d.cts +27 -4
- package/dist/auth/realms.d.cts.map +1 -1
- package/dist/auth/realms.d.ts +27 -4
- package/dist/auth/realms.d.ts.map +1 -1
- package/dist/auth/realms.js +80 -9
- package/dist/auth/realms.js.map +1 -1
- package/dist/auth/upload-url-pool.cjs +55 -51
- package/dist/auth/upload-url-pool.cjs.map +1 -1
- package/dist/auth/upload-url-pool.js +55 -51
- package/dist/auth/upload-url-pool.js.map +1 -1
- package/dist/backup/client.cjs +206 -0
- package/dist/backup/client.cjs.map +1 -0
- package/dist/backup/client.d.cts +238 -0
- package/dist/backup/client.d.cts.map +1 -0
- package/dist/backup/client.d.ts +238 -0
- package/dist/backup/client.d.ts.map +1 -0
- package/dist/backup/client.js +206 -0
- package/dist/backup/client.js.map +1 -0
- package/dist/backup/index.cjs +15 -0
- package/dist/backup/index.d.cts +22 -0
- package/dist/backup/index.d.cts.map +1 -0
- package/dist/backup/index.d.ts +22 -0
- package/dist/backup/index.d.ts.map +1 -0
- package/dist/backup/index.js +7 -0
- package/dist/backup/raw.cjs +146 -0
- package/dist/backup/raw.cjs.map +1 -0
- package/dist/backup/raw.d.cts +122 -0
- package/dist/backup/raw.d.cts.map +1 -0
- package/dist/backup/raw.d.ts +122 -0
- package/dist/backup/raw.d.ts.map +1 -0
- package/dist/backup/raw.js +146 -0
- package/dist/backup/raw.js.map +1 -0
- package/dist/bucket.cjs +786 -787
- package/dist/bucket.cjs.map +1 -1
- package/dist/bucket.d.cts +35 -47
- package/dist/bucket.d.cts.map +1 -1
- package/dist/bucket.d.ts +35 -47
- package/dist/bucket.d.ts.map +1 -1
- package/dist/bucket.js +781 -782
- package/dist/bucket.js.map +1 -1
- package/dist/client.cjs +246 -228
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -17
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts +25 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +243 -225
- package/dist/client.js.map +1 -1
- package/dist/copy/large.cjs +116 -71
- package/dist/copy/large.cjs.map +1 -1
- package/dist/copy/large.d.cts +6 -0
- package/dist/copy/large.d.cts.map +1 -1
- package/dist/copy/large.d.ts +6 -0
- package/dist/copy/large.d.ts.map +1 -1
- package/dist/copy/large.js +114 -69
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +93 -0
- package/dist/download/checksum.cjs.map +1 -0
- package/dist/download/checksum.d.cts +40 -0
- package/dist/download/checksum.d.cts.map +1 -0
- package/dist/download/checksum.d.ts +40 -0
- package/dist/download/checksum.d.ts.map +1 -0
- package/dist/download/checksum.js +91 -0
- package/dist/download/checksum.js.map +1 -0
- package/dist/download/parallel.cjs +251 -118
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +13 -2
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +13 -2
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +249 -116
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +323 -97
- package/dist/download/single.cjs.map +1 -1
- package/dist/download/single.d.cts +6 -1
- package/dist/download/single.d.cts.map +1 -1
- package/dist/download/single.d.ts +6 -1
- package/dist/download/single.d.ts.map +1 -1
- package/dist/download/single.js +322 -99
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +869 -243
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +404 -82
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +404 -82
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +835 -261
- package/dist/errors/index.js.map +1 -1
- package/dist/http/retry.cjs +45 -28
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.d.cts +15 -2
- package/dist/http/retry.d.cts.map +1 -1
- package/dist/http/retry.d.ts +15 -2
- package/dist/http/retry.d.ts.map +1 -1
- package/dist/http/retry.js +46 -31
- package/dist/http/retry.js.map +1 -1
- package/dist/http/transport.cjs +476 -140
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +46 -5
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +46 -5
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +474 -140
- package/dist/http/transport.js.map +1 -1
- package/dist/http/url-guard.cjs +154 -89
- package/dist/http/url-guard.cjs.map +1 -1
- package/dist/http/url-guard.d.cts +25 -3
- package/dist/http/url-guard.d.cts.map +1 -1
- package/dist/http/url-guard.d.ts +25 -3
- package/dist/http/url-guard.d.ts.map +1 -1
- package/dist/http/url-guard.js +152 -90
- package/dist/http/url-guard.js.map +1 -1
- package/dist/http/user-agent.cjs +84 -44
- package/dist/http/user-agent.cjs.map +1 -1
- package/dist/http/user-agent.js +84 -46
- package/dist/http/user-agent.js.map +1 -1
- package/dist/index.cjs +124 -77
- package/dist/index.d.cts +29 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +29 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -72
- package/dist/internal/b2-naming.cjs +66 -0
- package/dist/internal/b2-naming.cjs.map +1 -0
- package/dist/internal/b2-naming.d.cts +43 -0
- package/dist/internal/b2-naming.d.cts.map +1 -0
- package/dist/internal/b2-naming.d.ts +43 -0
- package/dist/internal/b2-naming.d.ts.map +1 -0
- package/dist/internal/b2-naming.js +60 -0
- package/dist/internal/b2-naming.js.map +1 -0
- package/dist/internal/upload-retry-options.cjs +21 -0
- package/dist/internal/upload-retry-options.cjs.map +1 -0
- package/dist/internal/upload-retry-options.d.cts +12 -0
- package/dist/internal/upload-retry-options.d.cts.map +1 -0
- package/dist/internal/upload-retry-options.d.ts +12 -0
- package/dist/internal/upload-retry-options.d.ts.map +1 -0
- package/dist/internal/upload-retry-options.js +21 -0
- package/dist/internal/upload-retry-options.js.map +1 -0
- package/dist/internal/url-redaction.cjs +31 -0
- package/dist/internal/url-redaction.cjs.map +1 -0
- package/dist/internal/url-redaction.d.cts +17 -0
- package/dist/internal/url-redaction.d.cts.map +1 -0
- package/dist/internal/url-redaction.d.ts +17 -0
- package/dist/internal/url-redaction.d.ts.map +1 -0
- package/dist/internal/url-redaction.js +31 -0
- package/dist/internal/url-redaction.js.map +1 -0
- package/dist/notifications/index.cjs +4 -6
- package/dist/notifications/index.d.cts +1 -1
- package/dist/notifications/index.d.cts.map +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +1 -6
- package/dist/notifications/webhook.cjs +195 -85
- package/dist/notifications/webhook.cjs.map +1 -1
- package/dist/notifications/webhook.d.cts.map +1 -1
- package/dist/notifications/webhook.d.ts.map +1 -1
- package/dist/notifications/webhook.js +195 -87
- package/dist/notifications/webhook.js.map +1 -1
- package/dist/object.cjs +253 -210
- package/dist/object.cjs.map +1 -1
- package/dist/object.d.cts +13 -57
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +13 -57
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +249 -206
- package/dist/object.js.map +1 -1
- package/dist/partner/account-info.d.cts +43 -0
- package/dist/partner/account-info.d.cts.map +1 -0
- package/dist/partner/account-info.d.ts +43 -0
- package/dist/partner/account-info.d.ts.map +1 -0
- package/dist/partner/auth-clone.cjs +64 -0
- package/dist/partner/auth-clone.cjs.map +1 -0
- package/dist/partner/auth-clone.d.cts +27 -0
- package/dist/partner/auth-clone.d.cts.map +1 -0
- package/dist/partner/auth-clone.d.ts +27 -0
- package/dist/partner/auth-clone.d.ts.map +1 -0
- package/dist/partner/auth-clone.js +63 -0
- package/dist/partner/auth-clone.js.map +1 -0
- package/dist/partner/auth-core.cjs +175 -0
- package/dist/partner/auth-core.cjs.map +1 -0
- package/dist/partner/auth-core.d.cts +111 -0
- package/dist/partner/auth-core.d.cts.map +1 -0
- package/dist/partner/auth-core.d.ts +111 -0
- package/dist/partner/auth-core.d.ts.map +1 -0
- package/dist/partner/auth-core.js +175 -0
- package/dist/partner/auth-core.js.map +1 -0
- package/dist/partner/auth-shape.cjs +36 -0
- package/dist/partner/auth-shape.cjs.map +1 -0
- package/dist/partner/auth-shape.d.cts +12 -0
- package/dist/partner/auth-shape.d.cts.map +1 -0
- package/dist/partner/auth-shape.d.ts +12 -0
- package/dist/partner/auth-shape.d.ts.map +1 -0
- package/dist/partner/auth-shape.js +36 -0
- package/dist/partner/auth-shape.js.map +1 -0
- package/dist/partner/client.cjs +255 -0
- package/dist/partner/client.cjs.map +1 -0
- package/dist/partner/client.d.cts +335 -0
- package/dist/partner/client.d.cts.map +1 -0
- package/dist/partner/client.d.ts +335 -0
- package/dist/partner/client.d.ts.map +1 -0
- package/dist/partner/client.js +255 -0
- package/dist/partner/client.js.map +1 -0
- package/dist/partner/endpoint-url.cjs +108 -0
- package/dist/partner/endpoint-url.cjs.map +1 -0
- package/dist/partner/endpoint-url.d.cts +72 -0
- package/dist/partner/endpoint-url.d.cts.map +1 -0
- package/dist/partner/endpoint-url.d.ts +72 -0
- package/dist/partner/endpoint-url.d.ts.map +1 -0
- package/dist/partner/endpoint-url.js +105 -0
- package/dist/partner/endpoint-url.js.map +1 -0
- package/dist/partner/in-memory.cjs +135 -0
- package/dist/partner/in-memory.cjs.map +1 -0
- package/dist/partner/in-memory.d.cts +99 -0
- package/dist/partner/in-memory.d.cts.map +1 -0
- package/dist/partner/in-memory.d.ts +99 -0
- package/dist/partner/in-memory.d.ts.map +1 -0
- package/dist/partner/in-memory.js +135 -0
- package/dist/partner/in-memory.js.map +1 -0
- package/dist/partner/index.cjs +18 -0
- package/dist/partner/index.d.cts +23 -0
- package/dist/partner/index.d.cts.map +1 -0
- package/dist/partner/index.d.ts +23 -0
- package/dist/partner/index.d.ts.map +1 -0
- package/dist/partner/index.js +7 -0
- package/dist/partner/raw.cjs +392 -0
- package/dist/partner/raw.cjs.map +1 -0
- package/dist/partner/raw.d.cts +223 -0
- package/dist/partner/raw.d.cts.map +1 -0
- package/dist/partner/raw.d.ts +223 -0
- package/dist/partner/raw.d.ts.map +1 -0
- package/dist/partner/raw.js +390 -0
- package/dist/partner/raw.js.map +1 -0
- package/dist/partner/redaction-placeholders.cjs +10 -0
- package/dist/partner/redaction-placeholders.cjs.map +1 -0
- package/dist/partner/redaction-placeholders.d.cts +5 -0
- package/dist/partner/redaction-placeholders.d.cts.map +1 -0
- package/dist/partner/redaction-placeholders.d.ts +5 -0
- package/dist/partner/redaction-placeholders.d.ts.map +1 -0
- package/dist/partner/redaction-placeholders.js +9 -0
- package/dist/partner/redaction-placeholders.js.map +1 -0
- package/dist/partner/redaction.cjs +267 -0
- package/dist/partner/redaction.cjs.map +1 -0
- package/dist/partner/redaction.d.cts +124 -0
- package/dist/partner/redaction.d.cts.map +1 -0
- package/dist/partner/redaction.d.ts +124 -0
- package/dist/partner/redaction.d.ts.map +1 -0
- package/dist/partner/redaction.js +257 -0
- package/dist/partner/redaction.js.map +1 -0
- package/dist/raw/encoding.cjs +74 -35
- package/dist/raw/encoding.cjs.map +1 -1
- package/dist/raw/encoding.js +74 -38
- package/dist/raw/encoding.js.map +1 -1
- package/dist/raw/index.cjs +740 -587
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +126 -19
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +126 -19
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +736 -589
- package/dist/raw/index.js.map +1 -1
- package/dist/raw/url.cjs +111 -0
- package/dist/raw/url.cjs.map +1 -0
- package/dist/raw/url.d.cts +41 -0
- package/dist/raw/url.d.cts.map +1 -0
- package/dist/raw/url.d.ts +41 -0
- package/dist/raw/url.d.ts.map +1 -0
- package/dist/raw/url.js +110 -0
- package/dist/raw/url.js.map +1 -0
- package/dist/s3/index.cjs +355 -18
- package/dist/s3/index.cjs.map +1 -1
- package/dist/s3/index.d.cts +233 -5
- package/dist/s3/index.d.cts.map +1 -1
- package/dist/s3/index.d.ts +233 -5
- package/dist/s3/index.d.ts.map +1 -1
- package/dist/s3/index.js +351 -22
- package/dist/s3/index.js.map +1 -1
- package/dist/s3/sigv4.cjs +154 -0
- package/dist/s3/sigv4.cjs.map +1 -0
- package/dist/s3/sigv4.d.cts +43 -0
- package/dist/s3/sigv4.d.cts.map +1 -0
- package/dist/s3/sigv4.d.ts +43 -0
- package/dist/s3/sigv4.d.ts.map +1 -0
- package/dist/s3/sigv4.js +153 -0
- package/dist/s3/sigv4.js.map +1 -0
- package/dist/s3/validation.cjs +69 -0
- package/dist/s3/validation.cjs.map +1 -0
- package/dist/s3/validation.d.cts +43 -0
- package/dist/s3/validation.d.cts.map +1 -0
- package/dist/s3/validation.d.ts +43 -0
- package/dist/s3/validation.d.ts.map +1 -0
- package/dist/s3/validation.js +66 -0
- package/dist/s3/validation.js.map +1 -0
- package/dist/simulator/capabilities.cjs +63 -48
- package/dist/simulator/capabilities.cjs.map +1 -1
- package/dist/simulator/capabilities.js +63 -49
- package/dist/simulator/capabilities.js.map +1 -1
- package/dist/simulator/index.cjs +3114 -1547
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +186 -20
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +186 -20
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +3098 -1545
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/partner.cjs +719 -0
- package/dist/simulator/partner.cjs.map +1 -0
- package/dist/simulator/partner.d.cts +183 -0
- package/dist/simulator/partner.d.cts.map +1 -0
- package/dist/simulator/partner.d.ts +183 -0
- package/dist/simulator/partner.d.ts.map +1 -0
- package/dist/simulator/partner.js +718 -0
- package/dist/simulator/partner.js.map +1 -0
- package/dist/simulator/validation.cjs +772 -157
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +120 -21
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +120 -21
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +755 -167
- package/dist/simulator/validation.js.map +1 -1
- package/dist/streams/collect.cjs +74 -24
- package/dist/streams/collect.cjs.map +1 -1
- package/dist/streams/collect.d.cts +14 -1
- package/dist/streams/collect.d.cts.map +1 -1
- package/dist/streams/collect.d.ts +14 -1
- package/dist/streams/collect.d.ts.map +1 -1
- package/dist/streams/collect.js +74 -25
- package/dist/streams/collect.js.map +1 -1
- package/dist/streams/file-source.cjs +287 -0
- package/dist/streams/file-source.cjs.map +1 -0
- package/dist/streams/file-source.d.cts +96 -0
- package/dist/streams/file-source.d.cts.map +1 -0
- package/dist/streams/file-source.d.ts +96 -0
- package/dist/streams/file-source.d.ts.map +1 -0
- package/dist/streams/file-source.js +286 -0
- package/dist/streams/file-source.js.map +1 -0
- package/dist/streams/hash.cjs +207 -115
- package/dist/streams/hash.cjs.map +1 -1
- package/dist/streams/hash.d.cts +5 -4
- package/dist/streams/hash.d.cts.map +1 -1
- package/dist/streams/hash.d.ts +5 -4
- package/dist/streams/hash.d.ts.map +1 -1
- package/dist/streams/hash.js +208 -95
- package/dist/streams/hash.js.map +1 -1
- package/dist/streams/index.cjs +12 -12
- package/dist/streams/index.d.cts +3 -3
- package/dist/streams/index.d.cts.map +1 -1
- package/dist/streams/index.d.ts +3 -3
- package/dist/streams/index.d.ts.map +1 -1
- package/dist/streams/index.js +3 -11
- package/dist/streams/progress.cjs +60 -46
- package/dist/streams/progress.cjs.map +1 -1
- package/dist/streams/progress.js +60 -46
- package/dist/streams/progress.js.map +1 -1
- package/dist/streams/source.cjs +317 -146
- package/dist/streams/source.cjs.map +1 -1
- package/dist/streams/source.d.cts +56 -18
- package/dist/streams/source.d.cts.map +1 -1
- package/dist/streams/source.d.ts +56 -18
- package/dist/streams/source.d.ts.map +1 -1
- package/dist/streams/source.js +313 -149
- package/dist/streams/source.js.map +1 -1
- package/dist/sync/actions/index.cjs +236 -184
- package/dist/sync/actions/index.cjs.map +1 -1
- package/dist/sync/actions/index.d.cts +29 -21
- package/dist/sync/actions/index.d.cts.map +1 -1
- package/dist/sync/actions/index.d.ts +29 -21
- package/dist/sync/actions/index.d.ts.map +1 -1
- package/dist/sync/actions/index.js +236 -190
- package/dist/sync/actions/index.js.map +1 -1
- package/dist/sync/b2-sha1-reader.cjs +152 -0
- package/dist/sync/b2-sha1-reader.cjs.map +1 -0
- package/dist/sync/b2-sha1-reader.d.cts +58 -0
- package/dist/sync/b2-sha1-reader.d.cts.map +1 -0
- package/dist/sync/b2-sha1-reader.d.ts +58 -0
- package/dist/sync/b2-sha1-reader.d.ts.map +1 -0
- package/dist/sync/b2-sha1-reader.js +149 -0
- package/dist/sync/b2-sha1-reader.js.map +1 -0
- package/dist/sync/download-staging.cjs +266 -0
- package/dist/sync/download-staging.cjs.map +1 -0
- package/dist/sync/download-staging.d.cts +55 -0
- package/dist/sync/download-staging.d.cts.map +1 -0
- package/dist/sync/download-staging.d.ts +55 -0
- package/dist/sync/download-staging.d.ts.map +1 -0
- package/dist/sync/download-staging.js +260 -0
- package/dist/sync/download-staging.js.map +1 -0
- package/dist/sync/filesystem-errors.cjs +32 -0
- package/dist/sync/filesystem-errors.cjs.map +1 -0
- package/dist/sync/filesystem-errors.d.cts +8 -0
- package/dist/sync/filesystem-errors.d.cts.map +1 -0
- package/dist/sync/filesystem-errors.d.ts +8 -0
- package/dist/sync/filesystem-errors.d.ts.map +1 -0
- package/dist/sync/filesystem-errors.js +32 -0
- package/dist/sync/filesystem-errors.js.map +1 -0
- package/dist/sync/filters.cjs +217 -0
- package/dist/sync/filters.cjs.map +1 -0
- package/dist/sync/filters.d.cts +51 -0
- package/dist/sync/filters.d.cts.map +1 -0
- package/dist/sync/filters.d.ts +51 -0
- package/dist/sync/filters.d.ts.map +1 -0
- package/dist/sync/filters.js +213 -0
- package/dist/sync/filters.js.map +1 -0
- package/dist/sync/index.cjs +39 -22
- package/dist/sync/index.d.cts +14 -9
- package/dist/sync/index.d.cts.map +1 -1
- package/dist/sync/index.d.ts +14 -9
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +9 -20
- package/dist/sync/local-file-identity.cjs +61 -0
- package/dist/sync/local-file-identity.cjs.map +1 -0
- package/dist/sync/local-file-identity.d.cts +37 -0
- package/dist/sync/local-file-identity.d.cts.map +1 -0
- package/dist/sync/local-file-identity.d.ts +37 -0
- package/dist/sync/local-file-identity.d.ts.map +1 -0
- package/dist/sync/local-file-identity.js +60 -0
- package/dist/sync/local-file-identity.js.map +1 -0
- package/dist/sync/local-file-io.cjs +369 -0
- package/dist/sync/local-file-io.cjs.map +1 -0
- package/dist/sync/local-file-io.d.cts +76 -0
- package/dist/sync/local-file-io.d.cts.map +1 -0
- package/dist/sync/local-file-io.d.ts +76 -0
- package/dist/sync/local-file-io.d.ts.map +1 -0
- package/dist/sync/local-file-io.js +365 -0
- package/dist/sync/local-file-io.js.map +1 -0
- package/dist/sync/local-filesystem-root.cjs +27 -0
- package/dist/sync/local-filesystem-root.cjs.map +1 -0
- package/dist/sync/local-filesystem-root.d.cts +18 -0
- package/dist/sync/local-filesystem-root.d.cts.map +1 -0
- package/dist/sync/local-filesystem-root.d.ts +18 -0
- package/dist/sync/local-filesystem-root.d.ts.map +1 -0
- package/dist/sync/local-filesystem-root.js +26 -0
- package/dist/sync/local-filesystem-root.js.map +1 -0
- package/dist/sync/local-sha1.cjs +110 -0
- package/dist/sync/local-sha1.cjs.map +1 -0
- package/dist/sync/local-sha1.d.cts +31 -0
- package/dist/sync/local-sha1.d.cts.map +1 -0
- package/dist/sync/local-sha1.d.ts +31 -0
- package/dist/sync/local-sha1.d.ts.map +1 -0
- package/dist/sync/local-sha1.js +109 -0
- package/dist/sync/local-sha1.js.map +1 -0
- package/dist/sync/pairing.cjs +118 -29
- package/dist/sync/pairing.cjs.map +1 -1
- package/dist/sync/pairing.d.cts +7 -2
- package/dist/sync/pairing.d.cts.map +1 -1
- package/dist/sync/pairing.d.ts +7 -2
- package/dist/sync/pairing.d.ts.map +1 -1
- package/dist/sync/pairing.js +120 -31
- package/dist/sync/pairing.js.map +1 -1
- package/dist/sync/path-order.cjs +30 -0
- package/dist/sync/path-order.cjs.map +1 -0
- package/dist/sync/path-order.d.cts +28 -0
- package/dist/sync/path-order.d.cts.map +1 -0
- package/dist/sync/path-order.d.ts +28 -0
- package/dist/sync/path-order.d.ts.map +1 -0
- package/dist/sync/path-order.js +29 -0
- package/dist/sync/path-order.js.map +1 -0
- package/dist/sync/path-safety.cjs +111 -0
- package/dist/sync/path-safety.cjs.map +1 -0
- package/dist/sync/path-safety.d.cts +78 -0
- package/dist/sync/path-safety.d.cts.map +1 -0
- package/dist/sync/path-safety.d.ts +78 -0
- package/dist/sync/path-safety.d.ts.map +1 -0
- package/dist/sync/path-safety.js +105 -0
- package/dist/sync/path-safety.js.map +1 -0
- package/dist/sync/paths.d.cts +19 -0
- package/dist/sync/paths.d.cts.map +1 -0
- package/dist/sync/paths.d.ts +19 -0
- package/dist/sync/paths.d.ts.map +1 -0
- package/dist/sync/policies/compare.cjs +391 -11
- package/dist/sync/policies/compare.cjs.map +1 -1
- package/dist/sync/policies/compare.d.cts +100 -2
- package/dist/sync/policies/compare.d.cts.map +1 -1
- package/dist/sync/policies/compare.d.ts +100 -2
- package/dist/sync/policies/compare.d.ts.map +1 -1
- package/dist/sync/policies/compare.js +389 -13
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +70 -65
- package/dist/sync/policies/index.cjs.map +1 -1
- package/dist/sync/policies/index.d.cts +35 -6
- package/dist/sync/policies/index.d.cts.map +1 -1
- package/dist/sync/policies/index.d.ts +35 -6
- package/dist/sync/policies/index.d.ts.map +1 -1
- package/dist/sync/policies/index.js +70 -65
- package/dist/sync/policies/index.js.map +1 -1
- package/dist/sync/prefix.cjs +96 -0
- package/dist/sync/prefix.cjs.map +1 -0
- package/dist/sync/prefix.d.cts +55 -0
- package/dist/sync/prefix.d.cts.map +1 -0
- package/dist/sync/prefix.d.ts +55 -0
- package/dist/sync/prefix.d.ts.map +1 -0
- package/dist/sync/prefix.js +92 -0
- package/dist/sync/prefix.js.map +1 -0
- package/dist/sync/regexp-safety.cjs +192 -0
- package/dist/sync/regexp-safety.cjs.map +1 -0
- package/dist/sync/regexp-safety.d.cts +29 -0
- package/dist/sync/regexp-safety.d.cts.map +1 -0
- package/dist/sync/regexp-safety.d.ts +29 -0
- package/dist/sync/regexp-safety.d.ts.map +1 -0
- package/dist/sync/regexp-safety.js +190 -0
- package/dist/sync/regexp-safety.js.map +1 -0
- package/dist/sync/scan-events.cjs +33 -0
- package/dist/sync/scan-events.cjs.map +1 -0
- package/dist/sync/scan-events.d.cts +17 -0
- package/dist/sync/scan-events.d.cts.map +1 -0
- package/dist/sync/scan-events.d.ts +17 -0
- package/dist/sync/scan-events.d.ts.map +1 -0
- package/dist/sync/scan-events.js +32 -0
- package/dist/sync/scan-events.js.map +1 -0
- package/dist/sync/scan-limit.cjs +33 -0
- package/dist/sync/scan-limit.cjs.map +1 -0
- package/dist/sync/scan-limit.d.cts +21 -0
- package/dist/sync/scan-limit.d.cts.map +1 -0
- package/dist/sync/scan-limit.d.ts +21 -0
- package/dist/sync/scan-limit.d.ts.map +1 -0
- package/dist/sync/scan-limit.js +31 -0
- package/dist/sync/scan-limit.js.map +1 -0
- package/dist/sync/scanners/b2.cjs +239 -55
- package/dist/sync/scanners/b2.cjs.map +1 -1
- package/dist/sync/scanners/b2.d.cts +26 -7
- package/dist/sync/scanners/b2.d.cts.map +1 -1
- package/dist/sync/scanners/b2.d.ts +26 -7
- package/dist/sync/scanners/b2.d.ts.map +1 -1
- package/dist/sync/scanners/b2.js +239 -55
- package/dist/sync/scanners/b2.js.map +1 -1
- package/dist/sync/scanners/local.cjs +215 -56
- package/dist/sync/scanners/local.cjs.map +1 -1
- package/dist/sync/scanners/local.d.cts +22 -7
- package/dist/sync/scanners/local.d.cts.map +1 -1
- package/dist/sync/scanners/local.d.ts +22 -7
- package/dist/sync/scanners/local.d.ts.map +1 -1
- package/dist/sync/scanners/local.js +216 -57
- package/dist/sync/scanners/local.js.map +1 -1
- package/dist/sync/sha1-metadata.cjs +94 -0
- package/dist/sync/sha1-metadata.cjs.map +1 -0
- package/dist/sync/sha1-metadata.d.cts +82 -0
- package/dist/sync/sha1-metadata.d.cts.map +1 -0
- package/dist/sync/sha1-metadata.d.ts +82 -0
- package/dist/sync/sha1-metadata.d.ts.map +1 -0
- package/dist/sync/sha1-metadata.js +89 -0
- package/dist/sync/sha1-metadata.js.map +1 -0
- package/dist/sync/sha1-options.cjs +23 -0
- package/dist/sync/sha1-options.cjs.map +1 -0
- package/dist/sync/sha1-options.d.cts +14 -0
- package/dist/sync/sha1-options.d.cts.map +1 -0
- package/dist/sync/sha1-options.d.ts +14 -0
- package/dist/sync/sha1-options.d.ts.map +1 -0
- package/dist/sync/sha1-options.js +21 -0
- package/dist/sync/sha1-options.js.map +1 -0
- package/dist/sync/synchronizer.cjs +783 -197
- package/dist/sync/synchronizer.cjs.map +1 -1
- package/dist/sync/synchronizer.d.cts +47 -1
- package/dist/sync/synchronizer.d.cts.map +1 -1
- package/dist/sync/synchronizer.d.ts +47 -1
- package/dist/sync/synchronizer.d.ts.map +1 -1
- package/dist/sync/synchronizer.js +780 -173
- package/dist/sync/synchronizer.js.map +1 -1
- package/dist/sync/types.d.cts +208 -16
- package/dist/sync/types.d.cts.map +1 -1
- package/dist/sync/types.d.ts +208 -16
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/types/auth.cjs +80 -56
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +71 -9
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +71 -9
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +81 -57
- package/dist/types/auth.js.map +1 -1
- package/dist/types/backup.d.cts +80 -0
- package/dist/types/backup.d.cts.map +1 -0
- package/dist/types/backup.d.ts +80 -0
- package/dist/types/backup.d.ts.map +1 -0
- package/dist/types/bucket.cjs +74 -38
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.d.cts +4 -2
- package/dist/types/bucket.d.cts.map +1 -1
- package/dist/types/bucket.d.ts +4 -2
- package/dist/types/bucket.d.ts.map +1 -1
- package/dist/types/bucket.js +75 -41
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/download.cjs +62 -0
- package/dist/types/download.cjs.map +1 -0
- package/dist/types/download.d.cts +98 -0
- package/dist/types/download.d.cts.map +1 -1
- package/dist/types/download.d.ts +98 -0
- package/dist/types/download.d.ts.map +1 -1
- package/dist/types/download.js +61 -0
- package/dist/types/download.js.map +1 -0
- package/dist/types/encryption.cjs +194 -328
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +48 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +48 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +192 -311
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +56 -0
- package/dist/types/errors.cjs.map +1 -0
- package/dist/types/errors.d.cts +13 -4
- package/dist/types/errors.d.cts.map +1 -1
- package/dist/types/errors.d.ts +13 -4
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +56 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/file.cjs +36 -19
- package/dist/types/file.cjs.map +1 -1
- package/dist/types/file.d.cts +17 -4
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +17 -4
- package/dist/types/file.d.ts.map +1 -1
- package/dist/types/file.js +37 -21
- package/dist/types/file.js.map +1 -1
- package/dist/types/ids.cjs +83 -9
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.d.cts +32 -0
- package/dist/types/ids.d.cts.map +1 -1
- package/dist/types/ids.d.ts +32 -0
- package/dist/types/ids.d.ts.map +1 -1
- package/dist/types/ids.js +82 -16
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +18 -13
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +18 -13
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/key.d.cts +44 -8
- package/dist/types/key.d.cts.map +1 -1
- package/dist/types/key.d.ts +44 -8
- package/dist/types/key.d.ts.map +1 -1
- package/dist/types/lock.cjs +33 -13
- package/dist/types/lock.cjs.map +1 -1
- package/dist/types/lock.d.cts +14 -0
- package/dist/types/lock.d.cts.map +1 -1
- package/dist/types/lock.d.ts +14 -0
- package/dist/types/lock.d.ts.map +1 -1
- package/dist/types/lock.js +34 -15
- package/dist/types/lock.js.map +1 -1
- package/dist/types/notifications.cjs +44 -22
- package/dist/types/notifications.cjs.map +1 -1
- package/dist/types/notifications.d.cts +5 -3
- package/dist/types/notifications.d.cts.map +1 -1
- package/dist/types/notifications.d.ts +5 -3
- package/dist/types/notifications.d.ts.map +1 -1
- package/dist/types/notifications.js +45 -23
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/partner.cjs +32 -0
- package/dist/types/partner.cjs.map +1 -0
- package/dist/types/partner.d.cts +394 -0
- package/dist/types/partner.d.cts.map +1 -0
- package/dist/types/partner.d.ts +394 -0
- package/dist/types/partner.d.ts.map +1 -0
- package/dist/types/partner.js +29 -0
- package/dist/types/partner.js.map +1 -0
- package/dist/types/upload.d.cts +53 -6
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +53 -6
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +46 -0
- package/dist/upload/abort-scope.cjs.map +1 -0
- package/dist/upload/abort-scope.d.cts +26 -0
- package/dist/upload/abort-scope.d.cts.map +1 -0
- package/dist/upload/abort-scope.d.ts +26 -0
- package/dist/upload/abort-scope.d.ts.map +1 -0
- package/dist/upload/abort-scope.js +45 -0
- package/dist/upload/abort-scope.js.map +1 -0
- package/dist/upload/cancel.cjs +183 -8
- package/dist/upload/cancel.cjs.map +1 -1
- package/dist/upload/cancel.d.cts +110 -2
- package/dist/upload/cancel.d.cts.map +1 -1
- package/dist/upload/cancel.d.ts +110 -2
- package/dist/upload/cancel.d.ts.map +1 -1
- package/dist/upload/cancel.js +178 -9
- package/dist/upload/cancel.js.map +1 -1
- package/dist/upload/concurrency.cjs +79 -52
- package/dist/upload/concurrency.cjs.map +1 -1
- package/dist/upload/concurrency.js +79 -53
- package/dist/upload/concurrency.js.map +1 -1
- package/dist/upload/finish.cjs +54 -0
- package/dist/upload/finish.cjs.map +1 -0
- package/dist/upload/finish.d.cts +26 -0
- package/dist/upload/finish.d.cts.map +1 -0
- package/dist/upload/finish.d.ts +26 -0
- package/dist/upload/finish.d.ts.map +1 -0
- package/dist/upload/finish.js +54 -0
- package/dist/upload/finish.js.map +1 -0
- package/dist/upload/large.cjs +305 -218
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +90 -9
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +90 -9
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +305 -218
- package/dist/upload/large.js.map +1 -1
- package/dist/upload/options.cjs +28 -0
- package/dist/upload/options.cjs.map +1 -0
- package/dist/upload/options.d.cts +116 -0
- package/dist/upload/options.d.cts.map +1 -0
- package/dist/upload/options.d.ts +116 -0
- package/dist/upload/options.d.ts.map +1 -0
- package/dist/upload/options.js +27 -0
- package/dist/upload/options.js.map +1 -0
- package/dist/upload/resume.cjs +334 -33
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +84 -12
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +84 -12
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +331 -33
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +191 -0
- package/dist/upload/retry.cjs.map +1 -0
- package/dist/upload/retry.d.cts +127 -0
- package/dist/upload/retry.d.cts.map +1 -0
- package/dist/upload/retry.d.ts +127 -0
- package/dist/upload/retry.d.ts.map +1 -0
- package/dist/upload/retry.js +187 -0
- package/dist/upload/retry.js.map +1 -0
- package/dist/upload/single.cjs +69 -44
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +8 -1
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +8 -1
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +69 -44
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +319 -193
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +9 -1
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +9 -1
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +318 -192
- package/dist/upload/stream.js.map +1 -1
- package/dist/util/abort.cjs +114 -0
- package/dist/util/abort.cjs.map +1 -0
- package/dist/util/abort.d.cts +65 -0
- package/dist/util/abort.d.cts.map +1 -0
- package/dist/util/abort.d.ts +65 -0
- package/dist/util/abort.d.ts.map +1 -0
- package/dist/util/abort.js +109 -0
- package/dist/util/abort.js.map +1 -0
- package/dist/util/best-effort.cjs +42 -8
- package/dist/util/best-effort.cjs.map +1 -1
- package/dist/util/best-effort.d.cts +2 -1
- package/dist/util/best-effort.d.cts.map +1 -1
- package/dist/util/best-effort.d.ts +2 -1
- package/dist/util/best-effort.d.ts.map +1 -1
- package/dist/util/best-effort.js +43 -9
- package/dist/util/best-effort.js.map +1 -1
- package/dist/util/bytes.cjs +23 -0
- package/dist/util/bytes.cjs.map +1 -0
- package/dist/util/bytes.d.cts +15 -0
- package/dist/util/bytes.d.cts.map +1 -0
- package/dist/util/bytes.d.ts +15 -0
- package/dist/util/bytes.d.ts.map +1 -0
- package/dist/util/bytes.js +23 -0
- package/dist/util/bytes.js.map +1 -0
- package/dist/util/crypto.cjs +68 -0
- package/dist/util/crypto.cjs.map +1 -0
- package/dist/util/crypto.d.cts +26 -0
- package/dist/util/crypto.d.cts.map +1 -0
- package/dist/util/crypto.d.ts +26 -0
- package/dist/util/crypto.d.ts.map +1 -0
- package/dist/util/crypto.js +66 -0
- package/dist/util/crypto.js.map +1 -0
- package/dist/util/defaults.cjs +28 -9
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.d.cts +2 -0
- package/dist/util/defaults.d.cts.map +1 -1
- package/dist/util/defaults.d.ts +2 -0
- package/dist/util/defaults.d.ts.map +1 -1
- package/dist/util/defaults.js +28 -11
- package/dist/util/defaults.js.map +1 -1
- package/dist/util/error-reason.cjs +41 -0
- package/dist/util/error-reason.cjs.map +1 -0
- package/dist/util/error-reason.d.cts +9 -0
- package/dist/util/error-reason.d.cts.map +1 -0
- package/dist/util/error-reason.d.ts +9 -0
- package/dist/util/error-reason.d.ts.map +1 -0
- package/dist/util/error-reason.js +41 -0
- package/dist/util/error-reason.js.map +1 -0
- package/dist/util/http.cjs +23 -0
- package/dist/util/http.cjs.map +1 -0
- package/dist/util/http.d.cts +13 -0
- package/dist/util/http.d.cts.map +1 -0
- package/dist/util/http.d.ts +13 -0
- package/dist/util/http.d.ts.map +1 -0
- package/dist/util/http.js +23 -0
- package/dist/util/http.js.map +1 -0
- package/dist/util/md5.cjs +211 -0
- package/dist/util/md5.cjs.map +1 -0
- package/dist/util/md5.d.cts +43 -0
- package/dist/util/md5.d.cts.map +1 -0
- package/dist/util/md5.d.ts +43 -0
- package/dist/util/md5.d.ts.map +1 -0
- package/dist/util/md5.js +209 -0
- package/dist/util/md5.js.map +1 -0
- package/dist/util/normalize.cjs +66 -7
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.d.cts +7 -7
- package/dist/util/normalize.d.cts.map +1 -1
- package/dist/util/normalize.d.ts +7 -7
- package/dist/util/normalize.d.ts.map +1 -1
- package/dist/util/normalize.js +67 -10
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +69 -14
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.d.cts +3 -1
- package/dist/util/paginator.d.cts.map +1 -1
- package/dist/util/paginator.d.ts +3 -1
- package/dist/util/paginator.d.ts.map +1 -1
- package/dist/util/paginator.js +70 -16
- package/dist/util/paginator.js.map +1 -1
- package/dist/util/plan-ranges.cjs +47 -22
- package/dist/util/plan-ranges.cjs.map +1 -1
- package/dist/util/plan-ranges.js +48 -24
- package/dist/util/plan-ranges.js.map +1 -1
- package/dist/util/sha1.cjs +27 -0
- package/dist/util/sha1.cjs.map +1 -0
- package/dist/util/sha1.d.cts +17 -0
- package/dist/util/sha1.d.cts.map +1 -0
- package/dist/util/sha1.d.ts +17 -0
- package/dist/util/sha1.d.ts.map +1 -0
- package/dist/util/sha1.js +26 -0
- package/dist/util/sha1.js.map +1 -0
- package/dist/util/text-codec.cjs +29 -5
- package/dist/util/text-codec.cjs.map +1 -1
- package/dist/util/text-codec.js +30 -7
- package/dist/util/text-codec.js.map +1 -1
- package/dist/util/to-error.cjs +18 -4
- package/dist/util/to-error.cjs.map +1 -1
- package/dist/util/to-error.js +19 -5
- package/dist/util/to-error.js.map +1 -1
- package/dist/version.cjs +17 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -3
- package/dist/version.d.ts +3 -3
- package/dist/version.js +19 -6
- package/dist/version.js.map +1 -1
- package/package.json +45 -20
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/notifications/index.cjs.map +0 -1
- package/dist/notifications/index.js.map +0 -1
- package/dist/package.json.cjs +0 -9
- package/dist/package.json.cjs.map +0 -1
- package/dist/package.json.js +0 -9
- package/dist/package.json.js.map +0 -1
- package/dist/streams/index.cjs.map +0 -1
- package/dist/streams/index.js.map +0 -1
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.js.map +0 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { B2PartnerAuthorizationError } from "../errors/index.js";
|
|
2
|
+
import { APPLICATION_KEY_REDACTED, PARTNER_TOKEN_REDACTED } from "./redaction-placeholders.js";
|
|
3
|
+
//#region src/partner/redaction.ts
|
|
4
|
+
var inspectSymbol = Symbol.for("nodejs.util.inspect.custom");
|
|
5
|
+
function installPortableJsonHook(target, toJson) {
|
|
6
|
+
const originalPrototype = Object.getPrototypeOf(target);
|
|
7
|
+
const redactionPrototype = Object.create(originalPrototype);
|
|
8
|
+
Object.defineProperty(redactionPrototype, "toJSON", {
|
|
9
|
+
value: toJson,
|
|
10
|
+
enumerable: false,
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
13
|
+
Object.setPrototypeOf(target, redactionPrototype);
|
|
14
|
+
Object.defineProperty(target, "toJSON", {
|
|
15
|
+
value: toJson,
|
|
16
|
+
enumerable: false,
|
|
17
|
+
configurable: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a redacted copy for log serializers that intentionally hide tokens.
|
|
22
|
+
*
|
|
23
|
+
* @param auth - Partner authorization response to render safely.
|
|
24
|
+
*
|
|
25
|
+
* @returns A plain object with the Partner token replaced by a placeholder.
|
|
26
|
+
*/
|
|
27
|
+
function partnerAuthorizeResponseToRedactedJson(auth) {
|
|
28
|
+
return {
|
|
29
|
+
...auth,
|
|
30
|
+
authorizationToken: PARTNER_TOKEN_REDACTED
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns a redacted copy for log serializers that intentionally hide group-member keys.
|
|
35
|
+
*
|
|
36
|
+
* @param result - Create group member result to render safely.
|
|
37
|
+
*
|
|
38
|
+
* @returns A plain object with the application key secret replaced by a placeholder.
|
|
39
|
+
*/
|
|
40
|
+
function createGroupMemberResultToRedactedJson(result) {
|
|
41
|
+
return {
|
|
42
|
+
...result,
|
|
43
|
+
applicationKey: APPLICATION_KEY_REDACTED
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns a redacted copy for log serializers that intentionally hide group-member keys.
|
|
48
|
+
*
|
|
49
|
+
* @param response - Create group member response to render safely.
|
|
50
|
+
*
|
|
51
|
+
* @returns A plain array with every application key secret replaced by a placeholder.
|
|
52
|
+
*/
|
|
53
|
+
function createGroupMemberResponseToRedactedJson(response) {
|
|
54
|
+
return response.map((result) => createGroupMemberResultToRedactedJson(result));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Returns a redacted copy for log serializers that intentionally hide trial account keys.
|
|
58
|
+
*
|
|
59
|
+
* @param result - Reserve trial account result to render safely.
|
|
60
|
+
*
|
|
61
|
+
* @returns A plain object with the application key secret replaced by a placeholder.
|
|
62
|
+
*/
|
|
63
|
+
function reserveTrialCreateAccountResultToRedactedJson(result) {
|
|
64
|
+
return {
|
|
65
|
+
...result,
|
|
66
|
+
applicationKey: APPLICATION_KEY_REDACTED
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns a redacted copy for log serializers that intentionally hide trial account keys.
|
|
71
|
+
*
|
|
72
|
+
* @param response - Reserve trial account response to render safely.
|
|
73
|
+
*
|
|
74
|
+
* @returns A plain array with every application key secret replaced by a placeholder.
|
|
75
|
+
*/
|
|
76
|
+
function reserveTrialCreateAccountResponseToRedactedJson(response) {
|
|
77
|
+
return response.map((result) => reserveTrialCreateAccountResultToRedactedJson(result));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Adds non-enumerable serialization and inspection hooks that redact the
|
|
81
|
+
* Partner token through `JSON.stringify`, `toString`, and Node `util.inspect`
|
|
82
|
+
* while preserving direct property access.
|
|
83
|
+
*
|
|
84
|
+
* `JSON.stringify` no longer round-trips `authorizationToken` from protected
|
|
85
|
+
* authorize responses. Persist trusted auth caches with
|
|
86
|
+
* `partnerAuthorizeResponseForPersistence(auth)` only into encrypted or
|
|
87
|
+
* otherwise credential-grade storage, or read `authorizationToken` directly
|
|
88
|
+
* into secure storage before serializing.
|
|
89
|
+
*
|
|
90
|
+
* This does not make the object universally log-safe: object spread,
|
|
91
|
+
* `Object.assign`, `Object.entries`, `structuredClone`, and serializers that
|
|
92
|
+
* walk enumerable properties can still expose the raw token.
|
|
93
|
+
*
|
|
94
|
+
* @param auth - Partner authorization response to protect from accidental inspection.
|
|
95
|
+
*
|
|
96
|
+
* @returns The same auth object with inspection hooks installed when possible.
|
|
97
|
+
*/
|
|
98
|
+
function redactPartnerAuthorizeResponse(auth) {
|
|
99
|
+
const target = Object.isExtensible(auth) ? auth : { ...auth };
|
|
100
|
+
const toRedactedJson = () => partnerAuthorizeResponseToRedactedJson(target);
|
|
101
|
+
const toRedactedString = () => `[PartnerAuthorizeResponse ${PARTNER_TOKEN_REDACTED}]`;
|
|
102
|
+
installPortableJsonHook(target, toRedactedJson);
|
|
103
|
+
Object.defineProperties(target, {
|
|
104
|
+
toString: {
|
|
105
|
+
value: toRedactedString,
|
|
106
|
+
enumerable: false,
|
|
107
|
+
configurable: true
|
|
108
|
+
},
|
|
109
|
+
[inspectSymbol]: {
|
|
110
|
+
value: toRedactedJson,
|
|
111
|
+
enumerable: false,
|
|
112
|
+
configurable: true
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return target;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Adds non-enumerable serialization and inspection hooks that redact the
|
|
119
|
+
* application key secret while preserving direct property access.
|
|
120
|
+
*
|
|
121
|
+
* @param result - Create group member result to protect from accidental logging.
|
|
122
|
+
*
|
|
123
|
+
* @returns The same result object with redaction hooks installed when possible.
|
|
124
|
+
*/
|
|
125
|
+
function redactCreateGroupMemberResult(result) {
|
|
126
|
+
const target = Object.isExtensible(result) ? result : { ...result };
|
|
127
|
+
const toRedactedJson = () => createGroupMemberResultToRedactedJson(target);
|
|
128
|
+
const toRedactedString = () => `[CreateGroupMemberResult ${APPLICATION_KEY_REDACTED}]`;
|
|
129
|
+
installPortableJsonHook(target, toRedactedJson);
|
|
130
|
+
Object.defineProperties(target, {
|
|
131
|
+
toString: {
|
|
132
|
+
value: toRedactedString,
|
|
133
|
+
enumerable: false,
|
|
134
|
+
configurable: true
|
|
135
|
+
},
|
|
136
|
+
[inspectSymbol]: {
|
|
137
|
+
value: toRedactedJson,
|
|
138
|
+
enumerable: false,
|
|
139
|
+
configurable: true
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return target;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Adds non-enumerable serialization and inspection hooks that redact all
|
|
146
|
+
* create-group-member application key secrets while preserving direct access.
|
|
147
|
+
*
|
|
148
|
+
* @param response - Create group member response to protect from accidental logging.
|
|
149
|
+
*
|
|
150
|
+
* @returns The same response array with redaction hooks installed when possible.
|
|
151
|
+
*
|
|
152
|
+
* @throws B2PartnerAuthorizationError if the response is not an array.
|
|
153
|
+
*/
|
|
154
|
+
function redactCreateGroupMemberResponse(response) {
|
|
155
|
+
if (!Array.isArray(response)) throw new B2PartnerAuthorizationError("b2_create_group_member response was not a JSON array");
|
|
156
|
+
const target = Object.isExtensible(response) ? response : [...response];
|
|
157
|
+
const writableTarget = target;
|
|
158
|
+
for (let i = 0; i < writableTarget.length; i++) {
|
|
159
|
+
const result = writableTarget[i];
|
|
160
|
+
if (result !== void 0) writableTarget[i] = redactCreateGroupMemberResult(result);
|
|
161
|
+
}
|
|
162
|
+
const toRedactedJson = () => createGroupMemberResponseToRedactedJson(target);
|
|
163
|
+
const toRedactedString = () => `[CreateGroupMemberResponse ${APPLICATION_KEY_REDACTED}]`;
|
|
164
|
+
Object.defineProperties(target, {
|
|
165
|
+
toJSON: {
|
|
166
|
+
value: toRedactedJson,
|
|
167
|
+
enumerable: false,
|
|
168
|
+
configurable: true
|
|
169
|
+
},
|
|
170
|
+
toString: {
|
|
171
|
+
value: toRedactedString,
|
|
172
|
+
enumerable: false,
|
|
173
|
+
configurable: true
|
|
174
|
+
},
|
|
175
|
+
[inspectSymbol]: {
|
|
176
|
+
value: toRedactedJson,
|
|
177
|
+
enumerable: false,
|
|
178
|
+
configurable: true
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return target;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Adds non-enumerable serialization and inspection hooks that redact the
|
|
185
|
+
* application key secret while preserving direct property access.
|
|
186
|
+
*
|
|
187
|
+
* `JSON.stringify` redacts because the response contains newly minted
|
|
188
|
+
* application key secrets that are commonly logged as batch results. Callers
|
|
189
|
+
* that need to persist the key should read `applicationKey` directly into
|
|
190
|
+
* secure storage before serializing the object.
|
|
191
|
+
*
|
|
192
|
+
* @param result - Reserve trial account result to protect from accidental logging.
|
|
193
|
+
*
|
|
194
|
+
* @returns The same result object with redaction hooks installed when possible.
|
|
195
|
+
*/
|
|
196
|
+
function redactReserveTrialCreateAccountResult(result) {
|
|
197
|
+
const target = Object.isExtensible(result) ? result : { ...result };
|
|
198
|
+
const toRedactedJson = () => reserveTrialCreateAccountResultToRedactedJson(target);
|
|
199
|
+
const toRedactedString = () => `[ReserveTrialCreateAccountResult ${APPLICATION_KEY_REDACTED}]`;
|
|
200
|
+
installPortableJsonHook(target, toRedactedJson);
|
|
201
|
+
Object.defineProperties(target, {
|
|
202
|
+
toString: {
|
|
203
|
+
value: toRedactedString,
|
|
204
|
+
enumerable: false,
|
|
205
|
+
configurable: true
|
|
206
|
+
},
|
|
207
|
+
[inspectSymbol]: {
|
|
208
|
+
value: toRedactedJson,
|
|
209
|
+
enumerable: false,
|
|
210
|
+
configurable: true
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return target;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Adds non-enumerable serialization and inspection hooks that redact all
|
|
217
|
+
* reserve-trial application key secrets while preserving direct property access.
|
|
218
|
+
*
|
|
219
|
+
* @param response - Reserve trial account response to protect from accidental logging.
|
|
220
|
+
*
|
|
221
|
+
* @returns The same response array with redaction hooks installed when possible.
|
|
222
|
+
*
|
|
223
|
+
* @throws B2PartnerAuthorizationError if the response is not an array.
|
|
224
|
+
*/
|
|
225
|
+
function redactReserveTrialCreateAccountResponse(response) {
|
|
226
|
+
if (!Array.isArray(response)) throw new B2PartnerAuthorizationError("b2_reserve_trial_create_account response was not a JSON array");
|
|
227
|
+
const target = Object.isExtensible(response) ? response : [...response];
|
|
228
|
+
const writableTarget = target;
|
|
229
|
+
for (let i = 0; i < writableTarget.length; i++) {
|
|
230
|
+
const result = writableTarget[i];
|
|
231
|
+
if (result !== void 0) writableTarget[i] = redactReserveTrialCreateAccountResult(result);
|
|
232
|
+
}
|
|
233
|
+
const toRedactedJson = () => reserveTrialCreateAccountResponseToRedactedJson(target);
|
|
234
|
+
const toRedactedString = () => `[ReserveTrialCreateAccountResponse ${APPLICATION_KEY_REDACTED}]`;
|
|
235
|
+
Object.defineProperties(target, {
|
|
236
|
+
toJSON: {
|
|
237
|
+
value: toRedactedJson,
|
|
238
|
+
enumerable: false,
|
|
239
|
+
configurable: true
|
|
240
|
+
},
|
|
241
|
+
toString: {
|
|
242
|
+
value: toRedactedString,
|
|
243
|
+
enumerable: false,
|
|
244
|
+
configurable: true
|
|
245
|
+
},
|
|
246
|
+
[inspectSymbol]: {
|
|
247
|
+
value: toRedactedJson,
|
|
248
|
+
enumerable: false,
|
|
249
|
+
configurable: true
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
return target;
|
|
253
|
+
}
|
|
254
|
+
//#endregion
|
|
255
|
+
export { PARTNER_TOKEN_REDACTED, createGroupMemberResponseToRedactedJson, createGroupMemberResultToRedactedJson, partnerAuthorizeResponseToRedactedJson, redactCreateGroupMemberResponse, redactCreateGroupMemberResult, redactPartnerAuthorizeResponse, redactReserveTrialCreateAccountResponse, redactReserveTrialCreateAccountResult, reserveTrialCreateAccountResponseToRedactedJson, reserveTrialCreateAccountResultToRedactedJson };
|
|
256
|
+
|
|
257
|
+
//# sourceMappingURL=redaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redaction.js","names":[],"sources":["../../src/partner/redaction.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type {\n CreateGroupMemberResponse,\n CreateGroupMemberResult,\n PartnerAuthorizeResponse,\n ReserveTrialCreateAccountResponse,\n ReserveTrialCreateAccountResult,\n} from '../types/partner.ts'\nimport { APPLICATION_KEY_REDACTED, PARTNER_TOKEN_REDACTED } from './redaction-placeholders.ts'\n\nexport {\n APPLICATION_KEY_REDACTED,\n PARTNER_TOKEN_REDACTED,\n} from './redaction-placeholders.ts'\n\n/**\n * JSON-safe Partner authorize response with the Partner token replaced by a\n * placeholder string.\n */\nexport interface RedactedPartnerAuthorizeResponseJson\n extends Omit<PartnerAuthorizeResponse, 'authorizationToken'> {\n /** Redacted Partner authorization token placeholder. */\n readonly authorizationToken: string\n}\n\nexport type RedactedCreateGroupMemberResultJson = Omit<\n CreateGroupMemberResult,\n 'applicationKey'\n> & {\n readonly applicationKey: string\n}\n\nexport type RedactedCreateGroupMemberResponseJson = readonly RedactedCreateGroupMemberResultJson[]\n\nexport type RedactedReserveTrialCreateAccountResultJson = Omit<\n ReserveTrialCreateAccountResult,\n 'applicationKey'\n> & {\n readonly applicationKey: string\n}\n\nexport type RedactedReserveTrialCreateAccountResponseJson =\n readonly RedactedReserveTrialCreateAccountResultJson[]\n\nconst inspectSymbol = Symbol.for('nodejs.util.inspect.custom')\n\n// Bun/WebKit only honor object toJSON hooks when they are inherited, while Node\n// honors own hooks. Install both shapes so SDK safe serialization is portable.\nfunction installPortableJsonHook<T extends object>(target: T, toJson: () => unknown): void {\n const originalPrototype = Object.getPrototypeOf(target)\n const redactionPrototype = Object.create(originalPrototype) as object\n Object.defineProperty(redactionPrototype, 'toJSON', {\n value: toJson,\n enumerable: false,\n configurable: true,\n })\n Object.setPrototypeOf(target, redactionPrototype)\n Object.defineProperty(target, 'toJSON', {\n value: toJson,\n enumerable: false,\n configurable: true,\n })\n}\n\n/**\n * Returns a redacted copy for log serializers that intentionally hide tokens.\n *\n * @param auth - Partner authorization response to render safely.\n *\n * @returns A plain object with the Partner token replaced by a placeholder.\n */\nexport function partnerAuthorizeResponseToRedactedJson(\n auth: PartnerAuthorizeResponse,\n): RedactedPartnerAuthorizeResponseJson {\n return {\n ...auth,\n authorizationToken: PARTNER_TOKEN_REDACTED,\n }\n}\n\n/**\n * Returns a redacted copy for log serializers that intentionally hide group-member keys.\n *\n * @param result - Create group member result to render safely.\n *\n * @returns A plain object with the application key secret replaced by a placeholder.\n */\nexport function createGroupMemberResultToRedactedJson(\n result: CreateGroupMemberResult,\n): RedactedCreateGroupMemberResultJson {\n return {\n ...result,\n applicationKey: APPLICATION_KEY_REDACTED,\n }\n}\n\n/**\n * Returns a redacted copy for log serializers that intentionally hide group-member keys.\n *\n * @param response - Create group member response to render safely.\n *\n * @returns A plain array with every application key secret replaced by a placeholder.\n */\nexport function createGroupMemberResponseToRedactedJson(\n response: CreateGroupMemberResponse,\n): RedactedCreateGroupMemberResponseJson {\n return response.map((result) => createGroupMemberResultToRedactedJson(result))\n}\n\n/**\n * Returns a redacted copy for log serializers that intentionally hide trial account keys.\n *\n * @param result - Reserve trial account result to render safely.\n *\n * @returns A plain object with the application key secret replaced by a placeholder.\n */\nexport function reserveTrialCreateAccountResultToRedactedJson(\n result: ReserveTrialCreateAccountResult,\n): RedactedReserveTrialCreateAccountResultJson {\n return {\n ...result,\n applicationKey: APPLICATION_KEY_REDACTED,\n }\n}\n\n/**\n * Returns a redacted copy for log serializers that intentionally hide trial account keys.\n *\n * @param response - Reserve trial account response to render safely.\n *\n * @returns A plain array with every application key secret replaced by a placeholder.\n */\nexport function reserveTrialCreateAccountResponseToRedactedJson(\n response: ReserveTrialCreateAccountResponse,\n): RedactedReserveTrialCreateAccountResponseJson {\n return response.map((result) => reserveTrialCreateAccountResultToRedactedJson(result))\n}\n\n/**\n * Adds non-enumerable serialization and inspection hooks that redact the\n * Partner token through `JSON.stringify`, `toString`, and Node `util.inspect`\n * while preserving direct property access.\n *\n * `JSON.stringify` no longer round-trips `authorizationToken` from protected\n * authorize responses. Persist trusted auth caches with\n * `partnerAuthorizeResponseForPersistence(auth)` only into encrypted or\n * otherwise credential-grade storage, or read `authorizationToken` directly\n * into secure storage before serializing.\n *\n * This does not make the object universally log-safe: object spread,\n * `Object.assign`, `Object.entries`, `structuredClone`, and serializers that\n * walk enumerable properties can still expose the raw token.\n *\n * @param auth - Partner authorization response to protect from accidental inspection.\n *\n * @returns The same auth object with inspection hooks installed when possible.\n */\nexport function redactPartnerAuthorizeResponse(\n auth: PartnerAuthorizeResponse,\n): PartnerAuthorizeResponse {\n const target = Object.isExtensible(auth) ? auth : { ...auth }\n const toRedactedJson = (): RedactedPartnerAuthorizeResponseJson =>\n partnerAuthorizeResponseToRedactedJson(target)\n const toRedactedString = (): string => `[PartnerAuthorizeResponse ${PARTNER_TOKEN_REDACTED}]`\n\n installPortableJsonHook(target, toRedactedJson)\n Object.defineProperties(target, {\n toString: {\n value: toRedactedString,\n enumerable: false,\n configurable: true,\n },\n [inspectSymbol]: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n })\n\n return target\n}\n\n/**\n * Adds non-enumerable serialization and inspection hooks that redact the\n * application key secret while preserving direct property access.\n *\n * @param result - Create group member result to protect from accidental logging.\n *\n * @returns The same result object with redaction hooks installed when possible.\n */\nexport function redactCreateGroupMemberResult(\n result: CreateGroupMemberResult,\n): CreateGroupMemberResult {\n const target = Object.isExtensible(result) ? result : { ...result }\n const toRedactedJson = (): RedactedCreateGroupMemberResultJson =>\n createGroupMemberResultToRedactedJson(target)\n const toRedactedString = (): string => `[CreateGroupMemberResult ${APPLICATION_KEY_REDACTED}]`\n\n installPortableJsonHook(target, toRedactedJson)\n Object.defineProperties(target, {\n toString: {\n value: toRedactedString,\n enumerable: false,\n configurable: true,\n },\n [inspectSymbol]: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n })\n\n return target\n}\n\n/**\n * Adds non-enumerable serialization and inspection hooks that redact all\n * create-group-member application key secrets while preserving direct access.\n *\n * @param response - Create group member response to protect from accidental logging.\n *\n * @returns The same response array with redaction hooks installed when possible.\n *\n * @throws B2PartnerAuthorizationError if the response is not an array.\n */\nexport function redactCreateGroupMemberResponse(\n response: CreateGroupMemberResponse,\n): CreateGroupMemberResponse {\n if (!Array.isArray(response)) {\n throw new B2PartnerAuthorizationError('b2_create_group_member response was not a JSON array')\n }\n\n const target = Object.isExtensible(response) ? response : [...response]\n const writableTarget = target as CreateGroupMemberResult[]\n for (let i = 0; i < writableTarget.length; i++) {\n const result = writableTarget[i]\n if (result !== undefined) writableTarget[i] = redactCreateGroupMemberResult(result)\n }\n\n const toRedactedJson = (): RedactedCreateGroupMemberResponseJson =>\n createGroupMemberResponseToRedactedJson(target)\n const toRedactedString = (): string => `[CreateGroupMemberResponse ${APPLICATION_KEY_REDACTED}]`\n\n Object.defineProperties(target, {\n toJSON: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n toString: {\n value: toRedactedString,\n enumerable: false,\n configurable: true,\n },\n [inspectSymbol]: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n })\n\n return target\n}\n\n/**\n * Adds non-enumerable serialization and inspection hooks that redact the\n * application key secret while preserving direct property access.\n *\n * `JSON.stringify` redacts because the response contains newly minted\n * application key secrets that are commonly logged as batch results. Callers\n * that need to persist the key should read `applicationKey` directly into\n * secure storage before serializing the object.\n *\n * @param result - Reserve trial account result to protect from accidental logging.\n *\n * @returns The same result object with redaction hooks installed when possible.\n */\nexport function redactReserveTrialCreateAccountResult(\n result: ReserveTrialCreateAccountResult,\n): ReserveTrialCreateAccountResult {\n const target = Object.isExtensible(result) ? result : { ...result }\n const toRedactedJson = (): RedactedReserveTrialCreateAccountResultJson =>\n reserveTrialCreateAccountResultToRedactedJson(target)\n const toRedactedString = (): string =>\n `[ReserveTrialCreateAccountResult ${APPLICATION_KEY_REDACTED}]`\n\n installPortableJsonHook(target, toRedactedJson)\n Object.defineProperties(target, {\n toString: {\n value: toRedactedString,\n enumerable: false,\n configurable: true,\n },\n [inspectSymbol]: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n })\n\n return target\n}\n\n/**\n * Adds non-enumerable serialization and inspection hooks that redact all\n * reserve-trial application key secrets while preserving direct property access.\n *\n * @param response - Reserve trial account response to protect from accidental logging.\n *\n * @returns The same response array with redaction hooks installed when possible.\n *\n * @throws B2PartnerAuthorizationError if the response is not an array.\n */\nexport function redactReserveTrialCreateAccountResponse(\n response: ReserveTrialCreateAccountResponse,\n): ReserveTrialCreateAccountResponse {\n if (!Array.isArray(response)) {\n throw new B2PartnerAuthorizationError(\n 'b2_reserve_trial_create_account response was not a JSON array',\n )\n }\n\n const target = Object.isExtensible(response) ? response : [...response]\n const writableTarget = target as ReserveTrialCreateAccountResult[]\n for (let i = 0; i < writableTarget.length; i++) {\n const result = writableTarget[i]\n if (result !== undefined) writableTarget[i] = redactReserveTrialCreateAccountResult(result)\n }\n\n const toRedactedJson = (): RedactedReserveTrialCreateAccountResponseJson =>\n reserveTrialCreateAccountResponseToRedactedJson(target)\n const toRedactedString = (): string =>\n `[ReserveTrialCreateAccountResponse ${APPLICATION_KEY_REDACTED}]`\n\n Object.defineProperties(target, {\n toJSON: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n toString: {\n value: toRedactedString,\n enumerable: false,\n configurable: true,\n },\n [inspectSymbol]: {\n value: toRedactedJson,\n enumerable: false,\n configurable: true,\n },\n })\n\n return target\n}\n"],"mappings":";;;AA4CA,IAAM,gBAAgB,OAAO,IAAI,4BAA4B;AAI7D,SAAS,wBAA0C,QAAW,QAA6B;CACzF,MAAM,oBAAoB,OAAO,eAAe,MAAM;CACtD,MAAM,qBAAqB,OAAO,OAAO,iBAAiB;CAC1D,OAAO,eAAe,oBAAoB,UAAU;EAClD,OAAO;EACP,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO,eAAe,QAAQ,kBAAkB;CAChD,OAAO,eAAe,QAAQ,UAAU;EACtC,OAAO;EACP,YAAY;EACZ,cAAc;CAChB,CAAC;AACH;;;;;;;;AASA,SAAgB,uCACd,MACsC;CACtC,OAAO;EACL,GAAG;EACH,oBAAoB;CACtB;AACF;;;;;;;;AASA,SAAgB,sCACd,QACqC;CACrC,OAAO;EACL,GAAG;EACH,gBAAgB;CAClB;AACF;;;;;;;;AASA,SAAgB,wCACd,UACuC;CACvC,OAAO,SAAS,KAAK,WAAW,sCAAsC,MAAM,CAAC;AAC/E;;;;;;;;AASA,SAAgB,8CACd,QAC6C;CAC7C,OAAO;EACL,GAAG;EACH,gBAAgB;CAClB;AACF;;;;;;;;AASA,SAAgB,gDACd,UAC+C;CAC/C,OAAO,SAAS,KAAK,WAAW,8CAA8C,MAAM,CAAC;AACvF;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,+BACd,MAC0B;CAC1B,MAAM,SAAS,OAAO,aAAa,IAAI,IAAI,OAAO,EAAE,GAAG,KAAK;CAC5D,MAAM,uBACJ,uCAAuC,MAAM;CAC/C,MAAM,yBAAiC,6BAA6B,uBAAuB;CAE3F,wBAAwB,QAAQ,cAAc;CAC9C,OAAO,iBAAiB,QAAQ;EAC9B,UAAU;GACR,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;GACC,gBAAgB;GACf,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;CAED,OAAO;AACT;;;;;;;;;AAUA,SAAgB,8BACd,QACyB;CACzB,MAAM,SAAS,OAAO,aAAa,MAAM,IAAI,SAAS,EAAE,GAAG,OAAO;CAClE,MAAM,uBACJ,sCAAsC,MAAM;CAC9C,MAAM,yBAAiC,4BAA4B,yBAAyB;CAE5F,wBAAwB,QAAQ,cAAc;CAC9C,OAAO,iBAAiB,QAAQ;EAC9B,UAAU;GACR,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;GACC,gBAAgB;GACf,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;CAED,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,gCACd,UAC2B;CAC3B,IAAI,CAAC,MAAM,QAAQ,QAAQ,GACzB,MAAM,IAAI,4BAA4B,sDAAsD;CAG9F,MAAM,SAAS,OAAO,aAAa,QAAQ,IAAI,WAAW,CAAC,GAAG,QAAQ;CACtE,MAAM,iBAAiB;CACvB,KAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,SAAS,eAAe;EAC9B,IAAI,WAAW,KAAA,GAAW,eAAe,KAAK,8BAA8B,MAAM;CACpF;CAEA,MAAM,uBACJ,wCAAwC,MAAM;CAChD,MAAM,yBAAiC,8BAA8B,yBAAyB;CAE9F,OAAO,iBAAiB,QAAQ;EAC9B,QAAQ;GACN,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;EACA,UAAU;GACR,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;GACC,gBAAgB;GACf,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;CAED,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,sCACd,QACiC;CACjC,MAAM,SAAS,OAAO,aAAa,MAAM,IAAI,SAAS,EAAE,GAAG,OAAO;CAClE,MAAM,uBACJ,8CAA8C,MAAM;CACtD,MAAM,yBACJ,oCAAoC,yBAAyB;CAE/D,wBAAwB,QAAQ,cAAc;CAC9C,OAAO,iBAAiB,QAAQ;EAC9B,UAAU;GACR,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;GACC,gBAAgB;GACf,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;CAED,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,wCACd,UACmC;CACnC,IAAI,CAAC,MAAM,QAAQ,QAAQ,GACzB,MAAM,IAAI,4BACR,+DACF;CAGF,MAAM,SAAS,OAAO,aAAa,QAAQ,IAAI,WAAW,CAAC,GAAG,QAAQ;CACtE,MAAM,iBAAiB;CACvB,KAAK,IAAI,IAAI,GAAG,IAAI,eAAe,QAAQ,KAAK;EAC9C,MAAM,SAAS,eAAe;EAC9B,IAAI,WAAW,KAAA,GAAW,eAAe,KAAK,sCAAsC,MAAM;CAC5F;CAEA,MAAM,uBACJ,gDAAgD,MAAM;CACxD,MAAM,yBACJ,sCAAsC,yBAAyB;CAEjE,OAAO,iBAAiB,QAAQ;EAC9B,QAAQ;GACN,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;EACA,UAAU;GACR,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;GACC,gBAAgB;GACf,OAAO;GACP,YAAY;GACZ,cAAc;EAChB;CACF,CAAC;CAED,OAAO;AACT"}
|
package/dist/raw/encoding.cjs
CHANGED
|
@@ -1,47 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
);
|
|
1
|
+
const require_text_codec = require("../util/text-codec.cjs");
|
|
2
|
+
//#region src/raw/encoding.ts
|
|
3
|
+
/**
|
|
4
|
+
* Characters that B2 treats as safe (not percent-encoded) in file names.
|
|
5
|
+
*
|
|
6
|
+
* Per the B2 docs, everything except `a-z A-Z 0-9 - . _ ~ / ! $ & ' ( ) * + , ; = : @`
|
|
7
|
+
* must be percent-encoded using UTF-8 byte values.
|
|
8
|
+
*/
|
|
9
|
+
var SAFE_CHARS = new Set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/".split(""));
|
|
10
|
+
/**
|
|
11
|
+
* Percent-encodes a file name using the B2-specific encoding rules.
|
|
12
|
+
*
|
|
13
|
+
* Unlike standard `encodeURIComponent`, B2 keeps `/` and several other
|
|
14
|
+
* characters unencoded while encoding all other non-ASCII and special
|
|
15
|
+
* characters as uppercase percent-encoded UTF-8 bytes.
|
|
16
|
+
*
|
|
17
|
+
* @param name - The raw (unencoded) file name.
|
|
18
|
+
*
|
|
19
|
+
* @returns The percent-encoded file name suitable for `X-Bz-File-Name` headers.
|
|
20
|
+
*/
|
|
7
21
|
function encodeFileName(name) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, "0")}`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return encoded.join("");
|
|
22
|
+
const encoded = [];
|
|
23
|
+
for (const char of name) if (SAFE_CHARS.has(char)) encoded.push(char);
|
|
24
|
+
else {
|
|
25
|
+
const bytes = require_text_codec.utf8Encoder.encode(char);
|
|
26
|
+
for (const byte of bytes) encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, "0")}`);
|
|
27
|
+
}
|
|
28
|
+
return encoded.join("");
|
|
20
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Decodes a B2 percent-encoded file name back to a plain string.
|
|
32
|
+
*
|
|
33
|
+
* B2 percent-encoding is compatible with standard `decodeURIComponent`,
|
|
34
|
+
* so this is a thin wrapper.
|
|
35
|
+
*
|
|
36
|
+
* @param encoded - The percent-encoded file name from B2.
|
|
37
|
+
*
|
|
38
|
+
* @returns The decoded file name.
|
|
39
|
+
*/
|
|
21
40
|
function decodeFileName(encoded) {
|
|
22
|
-
|
|
41
|
+
return decodeURIComponent(encoded);
|
|
23
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts a file-info map into `X-Bz-Info-*` HTTP headers.
|
|
45
|
+
*
|
|
46
|
+
* Both keys and values are percent-encoded with {@link encodeFileName}
|
|
47
|
+
* to satisfy B2 header requirements.
|
|
48
|
+
*
|
|
49
|
+
* @param fileInfo - Key/value pairs to attach as custom file info, or `undefined`.
|
|
50
|
+
*
|
|
51
|
+
* @returns A record of header name/value pairs (empty if `fileInfo` is `undefined`).
|
|
52
|
+
*/
|
|
24
53
|
function buildFileInfoHeaders(fileInfo) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
return headers;
|
|
54
|
+
if (!fileInfo) return {};
|
|
55
|
+
const headers = {};
|
|
56
|
+
for (const [key, value] of Object.entries(fileInfo)) headers[`X-Bz-Info-${encodeFileName(key)}`] = encodeFileName(value);
|
|
57
|
+
return headers;
|
|
31
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Extracts custom file-info key/value pairs from B2 response headers.
|
|
61
|
+
*
|
|
62
|
+
* Scans for headers prefixed with `x-bz-info-` and decodes both the
|
|
63
|
+
* key suffix and value using {@link decodeFileName}.
|
|
64
|
+
*
|
|
65
|
+
* @param headers - The HTTP response headers from a B2 download or file-info call.
|
|
66
|
+
*
|
|
67
|
+
* @returns A record of decoded file-info key/value pairs.
|
|
68
|
+
*/
|
|
32
69
|
function parseFileInfoHeaders(headers) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
70
|
+
const info = {};
|
|
71
|
+
headers.forEach((value, key) => {
|
|
72
|
+
const lower = key.toLowerCase();
|
|
73
|
+
if (lower.startsWith("x-bz-info-")) {
|
|
74
|
+
const infoKey = decodeFileName(lower.slice(10));
|
|
75
|
+
info[infoKey] = decodeFileName(value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return info;
|
|
42
79
|
}
|
|
80
|
+
//#endregion
|
|
43
81
|
exports.buildFileInfoHeaders = buildFileInfoHeaders;
|
|
44
82
|
exports.decodeFileName = decodeFileName;
|
|
45
83
|
exports.encodeFileName = encodeFileName;
|
|
46
84
|
exports.parseFileInfoHeaders = parseFileInfoHeaders;
|
|
47
|
-
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=encoding.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.cjs","sources":["../../src/raw/encoding.ts"],"sourcesContent":["import { utf8Encoder } from '../util/text-codec.ts'\n\n/**\n * Characters that B2 treats as safe (not percent-encoded) in file names.\n *\n * Per the B2 docs, everything except `a-z A-Z 0-9 - . _ ~ / ! $ & ' ( ) * + , ; = : @`\n * must be percent-encoded using UTF-8 byte values.\n */\nconst SAFE_CHARS = new Set(\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/\".split(''),\n)\n\n/**\n * Percent-encodes a file name using the B2-specific encoding rules.\n *\n * Unlike standard `encodeURIComponent`, B2 keeps `/` and several other\n * characters unencoded while encoding all other non-ASCII and special\n * characters as uppercase percent-encoded UTF-8 bytes.\n *\n * @param name - The raw (unencoded) file name.\n *\n * @returns The percent-encoded file name suitable for `X-Bz-File-Name` headers.\n */\nexport function encodeFileName(name: string): string {\n const encoded: string[] = []\n for (const char of name) {\n if (SAFE_CHARS.has(char)) {\n encoded.push(char)\n } else {\n const bytes = utf8Encoder.encode(char)\n for (const byte of bytes) {\n encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, '0')}`)\n }\n }\n }\n return encoded.join('')\n}\n\n/**\n * Decodes a B2 percent-encoded file name back to a plain string.\n *\n * B2 percent-encoding is compatible with standard `decodeURIComponent`,\n * so this is a thin wrapper.\n *\n * @param encoded - The percent-encoded file name from B2.\n *\n * @returns The decoded file name.\n */\nexport function decodeFileName(encoded: string): string {\n return decodeURIComponent(encoded)\n}\n\n/**\n * Converts a file-info map into `X-Bz-Info-*` HTTP headers.\n *\n * Both keys and values are percent-encoded with {@link encodeFileName}\n * to satisfy B2 header requirements.\n *\n * @param fileInfo - Key/value pairs to attach as custom file info, or `undefined`.\n *\n * @returns A record of header name/value pairs (empty if `fileInfo` is `undefined`).\n */\nexport function buildFileInfoHeaders(\n fileInfo: Record<string, string> | undefined,\n): Record<string, string> {\n if (!fileInfo) return {}\n const headers: Record<string, string> = {}\n for (const [key, value] of Object.entries(fileInfo)) {\n headers[`X-Bz-Info-${encodeFileName(key)}`] = encodeFileName(value)\n }\n return headers\n}\n\n/**\n * Extracts custom file-info key/value pairs from B2 response headers.\n *\n * Scans for headers prefixed with `x-bz-info-` and decodes both the\n * key suffix and value using {@link decodeFileName}.\n *\n * @param headers - The HTTP response headers from a B2 download or file-info call.\n *\n * @returns A record of decoded file-info key/value pairs.\n */\nexport function parseFileInfoHeaders(headers: Headers): Record<string, string> {\n const info: Record<string, string> = {}\n headers.forEach((value, key) => {\n const lower = key.toLowerCase()\n if (lower.startsWith('x-bz-info-')) {\n const infoKey = decodeFileName(lower.slice('x-bz-info-'.length))\n info[infoKey] = decodeFileName(value)\n }\n })\n return info\n}\n"],"
|
|
1
|
+
{"version":3,"file":"encoding.cjs","names":[],"sources":["../../src/raw/encoding.ts"],"sourcesContent":["import { utf8Encoder } from '../util/text-codec.ts'\n\n/**\n * Characters that B2 treats as safe (not percent-encoded) in file names.\n *\n * Per the B2 docs, everything except `a-z A-Z 0-9 - . _ ~ / ! $ & ' ( ) * + , ; = : @`\n * must be percent-encoded using UTF-8 byte values.\n */\nconst SAFE_CHARS = new Set(\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/\".split(''),\n)\n\n/**\n * Percent-encodes a file name using the B2-specific encoding rules.\n *\n * Unlike standard `encodeURIComponent`, B2 keeps `/` and several other\n * characters unencoded while encoding all other non-ASCII and special\n * characters as uppercase percent-encoded UTF-8 bytes.\n *\n * @param name - The raw (unencoded) file name.\n *\n * @returns The percent-encoded file name suitable for `X-Bz-File-Name` headers.\n */\nexport function encodeFileName(name: string): string {\n const encoded: string[] = []\n for (const char of name) {\n if (SAFE_CHARS.has(char)) {\n encoded.push(char)\n } else {\n const bytes = utf8Encoder.encode(char)\n for (const byte of bytes) {\n encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, '0')}`)\n }\n }\n }\n return encoded.join('')\n}\n\n/**\n * Decodes a B2 percent-encoded file name back to a plain string.\n *\n * B2 percent-encoding is compatible with standard `decodeURIComponent`,\n * so this is a thin wrapper.\n *\n * @param encoded - The percent-encoded file name from B2.\n *\n * @returns The decoded file name.\n */\nexport function decodeFileName(encoded: string): string {\n return decodeURIComponent(encoded)\n}\n\n/**\n * Converts a file-info map into `X-Bz-Info-*` HTTP headers.\n *\n * Both keys and values are percent-encoded with {@link encodeFileName}\n * to satisfy B2 header requirements.\n *\n * @param fileInfo - Key/value pairs to attach as custom file info, or `undefined`.\n *\n * @returns A record of header name/value pairs (empty if `fileInfo` is `undefined`).\n */\nexport function buildFileInfoHeaders(\n fileInfo: Record<string, string> | undefined,\n): Record<string, string> {\n if (!fileInfo) return {}\n const headers: Record<string, string> = {}\n for (const [key, value] of Object.entries(fileInfo)) {\n headers[`X-Bz-Info-${encodeFileName(key)}`] = encodeFileName(value)\n }\n return headers\n}\n\n/**\n * Extracts custom file-info key/value pairs from B2 response headers.\n *\n * Scans for headers prefixed with `x-bz-info-` and decodes both the\n * key suffix and value using {@link decodeFileName}.\n *\n * @param headers - The HTTP response headers from a B2 download or file-info call.\n *\n * @returns A record of decoded file-info key/value pairs.\n */\nexport function parseFileInfoHeaders(headers: Headers): Record<string, string> {\n const info: Record<string, string> = {}\n headers.forEach((value, key) => {\n const lower = key.toLowerCase()\n if (lower.startsWith('x-bz-info-')) {\n const infoKey = decodeFileName(lower.slice('x-bz-info-'.length))\n info[infoKey] = decodeFileName(value)\n }\n })\n return info\n}\n"],"mappings":";;;;;;;;AAQA,IAAM,aAAa,IAAI,IACrB,mFAAmF,MAAM,EAAE,CAC7F;;;;;;;;;;;;AAaA,SAAgB,eAAe,MAAsB;CACnD,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,MACjB,IAAI,WAAW,IAAI,IAAI,GACrB,QAAQ,KAAK,IAAI;MACZ;EACL,MAAM,QAAQ,mBAAA,YAAY,OAAO,IAAI;EACrC,KAAK,MAAM,QAAQ,OACjB,QAAQ,KAAK,IAAI,KAAK,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;CAEvE;CAEF,OAAO,QAAQ,KAAK,EAAE;AACxB;;;;;;;;;;;AAYA,SAAgB,eAAe,SAAyB;CACtD,OAAO,mBAAmB,OAAO;AACnC;;;;;;;;;;;AAYA,SAAgB,qBACd,UACwB;CACxB,IAAI,CAAC,UAAU,OAAO,CAAC;CACvB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,GAChD,QAAQ,aAAa,eAAe,GAAG,OAAO,eAAe,KAAK;CAEpE,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,qBAAqB,SAA0C;CAC7E,MAAM,OAA+B,CAAC;CACtC,QAAQ,SAAS,OAAO,QAAQ;EAC9B,MAAM,QAAQ,IAAI,YAAY;EAC9B,IAAI,MAAM,WAAW,YAAY,GAAG;GAClC,MAAM,UAAU,eAAe,MAAM,MAAM,EAAmB,CAAC;GAC/D,KAAK,WAAW,eAAe,KAAK;EACtC;CACF,CAAC;CACD,OAAO;AACT"}
|
package/dist/raw/encoding.js
CHANGED
|
@@ -1,47 +1,83 @@
|
|
|
1
1
|
import { utf8Encoder } from "../util/text-codec.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
)
|
|
2
|
+
//#region src/raw/encoding.ts
|
|
3
|
+
/**
|
|
4
|
+
* Characters that B2 treats as safe (not percent-encoded) in file names.
|
|
5
|
+
*
|
|
6
|
+
* Per the B2 docs, everything except `a-z A-Z 0-9 - . _ ~ / ! $ & ' ( ) * + , ; = : @`
|
|
7
|
+
* must be percent-encoded using UTF-8 byte values.
|
|
8
|
+
*/
|
|
9
|
+
var SAFE_CHARS = new Set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/".split(""));
|
|
10
|
+
/**
|
|
11
|
+
* Percent-encodes a file name using the B2-specific encoding rules.
|
|
12
|
+
*
|
|
13
|
+
* Unlike standard `encodeURIComponent`, B2 keeps `/` and several other
|
|
14
|
+
* characters unencoded while encoding all other non-ASCII and special
|
|
15
|
+
* characters as uppercase percent-encoded UTF-8 bytes.
|
|
16
|
+
*
|
|
17
|
+
* @param name - The raw (unencoded) file name.
|
|
18
|
+
*
|
|
19
|
+
* @returns The percent-encoded file name suitable for `X-Bz-File-Name` headers.
|
|
20
|
+
*/
|
|
5
21
|
function encodeFileName(name) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, "0")}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return encoded.join("");
|
|
22
|
+
const encoded = [];
|
|
23
|
+
for (const char of name) if (SAFE_CHARS.has(char)) encoded.push(char);
|
|
24
|
+
else {
|
|
25
|
+
const bytes = utf8Encoder.encode(char);
|
|
26
|
+
for (const byte of bytes) encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, "0")}`);
|
|
27
|
+
}
|
|
28
|
+
return encoded.join("");
|
|
18
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Decodes a B2 percent-encoded file name back to a plain string.
|
|
32
|
+
*
|
|
33
|
+
* B2 percent-encoding is compatible with standard `decodeURIComponent`,
|
|
34
|
+
* so this is a thin wrapper.
|
|
35
|
+
*
|
|
36
|
+
* @param encoded - The percent-encoded file name from B2.
|
|
37
|
+
*
|
|
38
|
+
* @returns The decoded file name.
|
|
39
|
+
*/
|
|
19
40
|
function decodeFileName(encoded) {
|
|
20
|
-
|
|
41
|
+
return decodeURIComponent(encoded);
|
|
21
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts a file-info map into `X-Bz-Info-*` HTTP headers.
|
|
45
|
+
*
|
|
46
|
+
* Both keys and values are percent-encoded with {@link encodeFileName}
|
|
47
|
+
* to satisfy B2 header requirements.
|
|
48
|
+
*
|
|
49
|
+
* @param fileInfo - Key/value pairs to attach as custom file info, or `undefined`.
|
|
50
|
+
*
|
|
51
|
+
* @returns A record of header name/value pairs (empty if `fileInfo` is `undefined`).
|
|
52
|
+
*/
|
|
22
53
|
function buildFileInfoHeaders(fileInfo) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return headers;
|
|
54
|
+
if (!fileInfo) return {};
|
|
55
|
+
const headers = {};
|
|
56
|
+
for (const [key, value] of Object.entries(fileInfo)) headers[`X-Bz-Info-${encodeFileName(key)}`] = encodeFileName(value);
|
|
57
|
+
return headers;
|
|
29
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Extracts custom file-info key/value pairs from B2 response headers.
|
|
61
|
+
*
|
|
62
|
+
* Scans for headers prefixed with `x-bz-info-` and decodes both the
|
|
63
|
+
* key suffix and value using {@link decodeFileName}.
|
|
64
|
+
*
|
|
65
|
+
* @param headers - The HTTP response headers from a B2 download or file-info call.
|
|
66
|
+
*
|
|
67
|
+
* @returns A record of decoded file-info key/value pairs.
|
|
68
|
+
*/
|
|
30
69
|
function parseFileInfoHeaders(headers) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
70
|
+
const info = {};
|
|
71
|
+
headers.forEach((value, key) => {
|
|
72
|
+
const lower = key.toLowerCase();
|
|
73
|
+
if (lower.startsWith("x-bz-info-")) {
|
|
74
|
+
const infoKey = decodeFileName(lower.slice(10));
|
|
75
|
+
info[infoKey] = decodeFileName(value);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return info;
|
|
40
79
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
parseFileInfoHeaders
|
|
46
|
-
};
|
|
47
|
-
//# sourceMappingURL=encoding.js.map
|
|
80
|
+
//#endregion
|
|
81
|
+
export { buildFileInfoHeaders, decodeFileName, encodeFileName, parseFileInfoHeaders };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=encoding.js.map
|
package/dist/raw/encoding.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding.js","sources":["../../src/raw/encoding.ts"],"sourcesContent":["import { utf8Encoder } from '../util/text-codec.ts'\n\n/**\n * Characters that B2 treats as safe (not percent-encoded) in file names.\n *\n * Per the B2 docs, everything except `a-z A-Z 0-9 - . _ ~ / ! $ & ' ( ) * + , ; = : @`\n * must be percent-encoded using UTF-8 byte values.\n */\nconst SAFE_CHARS = new Set(\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/\".split(''),\n)\n\n/**\n * Percent-encodes a file name using the B2-specific encoding rules.\n *\n * Unlike standard `encodeURIComponent`, B2 keeps `/` and several other\n * characters unencoded while encoding all other non-ASCII and special\n * characters as uppercase percent-encoded UTF-8 bytes.\n *\n * @param name - The raw (unencoded) file name.\n *\n * @returns The percent-encoded file name suitable for `X-Bz-File-Name` headers.\n */\nexport function encodeFileName(name: string): string {\n const encoded: string[] = []\n for (const char of name) {\n if (SAFE_CHARS.has(char)) {\n encoded.push(char)\n } else {\n const bytes = utf8Encoder.encode(char)\n for (const byte of bytes) {\n encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, '0')}`)\n }\n }\n }\n return encoded.join('')\n}\n\n/**\n * Decodes a B2 percent-encoded file name back to a plain string.\n *\n * B2 percent-encoding is compatible with standard `decodeURIComponent`,\n * so this is a thin wrapper.\n *\n * @param encoded - The percent-encoded file name from B2.\n *\n * @returns The decoded file name.\n */\nexport function decodeFileName(encoded: string): string {\n return decodeURIComponent(encoded)\n}\n\n/**\n * Converts a file-info map into `X-Bz-Info-*` HTTP headers.\n *\n * Both keys and values are percent-encoded with {@link encodeFileName}\n * to satisfy B2 header requirements.\n *\n * @param fileInfo - Key/value pairs to attach as custom file info, or `undefined`.\n *\n * @returns A record of header name/value pairs (empty if `fileInfo` is `undefined`).\n */\nexport function buildFileInfoHeaders(\n fileInfo: Record<string, string> | undefined,\n): Record<string, string> {\n if (!fileInfo) return {}\n const headers: Record<string, string> = {}\n for (const [key, value] of Object.entries(fileInfo)) {\n headers[`X-Bz-Info-${encodeFileName(key)}`] = encodeFileName(value)\n }\n return headers\n}\n\n/**\n * Extracts custom file-info key/value pairs from B2 response headers.\n *\n * Scans for headers prefixed with `x-bz-info-` and decodes both the\n * key suffix and value using {@link decodeFileName}.\n *\n * @param headers - The HTTP response headers from a B2 download or file-info call.\n *\n * @returns A record of decoded file-info key/value pairs.\n */\nexport function parseFileInfoHeaders(headers: Headers): Record<string, string> {\n const info: Record<string, string> = {}\n headers.forEach((value, key) => {\n const lower = key.toLowerCase()\n if (lower.startsWith('x-bz-info-')) {\n const infoKey = decodeFileName(lower.slice('x-bz-info-'.length))\n info[infoKey] = decodeFileName(value)\n }\n })\n return info\n}\n"],"
|
|
1
|
+
{"version":3,"file":"encoding.js","names":[],"sources":["../../src/raw/encoding.ts"],"sourcesContent":["import { utf8Encoder } from '../util/text-codec.ts'\n\n/**\n * Characters that B2 treats as safe (not percent-encoded) in file names.\n *\n * Per the B2 docs, everything except `a-z A-Z 0-9 - . _ ~ / ! $ & ' ( ) * + , ; = : @`\n * must be percent-encoded using UTF-8 byte values.\n */\nconst SAFE_CHARS = new Set(\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~!$&'()*+,;=:@/\".split(''),\n)\n\n/**\n * Percent-encodes a file name using the B2-specific encoding rules.\n *\n * Unlike standard `encodeURIComponent`, B2 keeps `/` and several other\n * characters unencoded while encoding all other non-ASCII and special\n * characters as uppercase percent-encoded UTF-8 bytes.\n *\n * @param name - The raw (unencoded) file name.\n *\n * @returns The percent-encoded file name suitable for `X-Bz-File-Name` headers.\n */\nexport function encodeFileName(name: string): string {\n const encoded: string[] = []\n for (const char of name) {\n if (SAFE_CHARS.has(char)) {\n encoded.push(char)\n } else {\n const bytes = utf8Encoder.encode(char)\n for (const byte of bytes) {\n encoded.push(`%${byte.toString(16).toUpperCase().padStart(2, '0')}`)\n }\n }\n }\n return encoded.join('')\n}\n\n/**\n * Decodes a B2 percent-encoded file name back to a plain string.\n *\n * B2 percent-encoding is compatible with standard `decodeURIComponent`,\n * so this is a thin wrapper.\n *\n * @param encoded - The percent-encoded file name from B2.\n *\n * @returns The decoded file name.\n */\nexport function decodeFileName(encoded: string): string {\n return decodeURIComponent(encoded)\n}\n\n/**\n * Converts a file-info map into `X-Bz-Info-*` HTTP headers.\n *\n * Both keys and values are percent-encoded with {@link encodeFileName}\n * to satisfy B2 header requirements.\n *\n * @param fileInfo - Key/value pairs to attach as custom file info, or `undefined`.\n *\n * @returns A record of header name/value pairs (empty if `fileInfo` is `undefined`).\n */\nexport function buildFileInfoHeaders(\n fileInfo: Record<string, string> | undefined,\n): Record<string, string> {\n if (!fileInfo) return {}\n const headers: Record<string, string> = {}\n for (const [key, value] of Object.entries(fileInfo)) {\n headers[`X-Bz-Info-${encodeFileName(key)}`] = encodeFileName(value)\n }\n return headers\n}\n\n/**\n * Extracts custom file-info key/value pairs from B2 response headers.\n *\n * Scans for headers prefixed with `x-bz-info-` and decodes both the\n * key suffix and value using {@link decodeFileName}.\n *\n * @param headers - The HTTP response headers from a B2 download or file-info call.\n *\n * @returns A record of decoded file-info key/value pairs.\n */\nexport function parseFileInfoHeaders(headers: Headers): Record<string, string> {\n const info: Record<string, string> = {}\n headers.forEach((value, key) => {\n const lower = key.toLowerCase()\n if (lower.startsWith('x-bz-info-')) {\n const infoKey = decodeFileName(lower.slice('x-bz-info-'.length))\n info[infoKey] = decodeFileName(value)\n }\n })\n return info\n}\n"],"mappings":";;;;;;;;AAQA,IAAM,aAAa,IAAI,IACrB,mFAAmF,MAAM,EAAE,CAC7F;;;;;;;;;;;;AAaA,SAAgB,eAAe,MAAsB;CACnD,MAAM,UAAoB,CAAC;CAC3B,KAAK,MAAM,QAAQ,MACjB,IAAI,WAAW,IAAI,IAAI,GACrB,QAAQ,KAAK,IAAI;MACZ;EACL,MAAM,QAAQ,YAAY,OAAO,IAAI;EACrC,KAAK,MAAM,QAAQ,OACjB,QAAQ,KAAK,IAAI,KAAK,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,GAAG,GAAG,GAAG;CAEvE;CAEF,OAAO,QAAQ,KAAK,EAAE;AACxB;;;;;;;;;;;AAYA,SAAgB,eAAe,SAAyB;CACtD,OAAO,mBAAmB,OAAO;AACnC;;;;;;;;;;;AAYA,SAAgB,qBACd,UACwB;CACxB,IAAI,CAAC,UAAU,OAAO,CAAC;CACvB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,QAAQ,GAChD,QAAQ,aAAa,eAAe,GAAG,OAAO,eAAe,KAAK;CAEpE,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,qBAAqB,SAA0C;CAC7E,MAAM,OAA+B,CAAC;CACtC,QAAQ,SAAS,OAAO,QAAQ;EAC9B,MAAM,QAAQ,IAAI,YAAY;EAC9B,IAAI,MAAM,WAAW,YAAY,GAAG;GAClC,MAAM,UAAU,eAAe,MAAM,MAAM,EAAmB,CAAC;GAC/D,KAAK,WAAW,eAAe,KAAK;EACtC;CACF,CAAC;CACD,OAAO;AACT"}
|