@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,719 @@
|
|
|
1
|
+
const require_ids = require("../types/ids.cjs");
|
|
2
|
+
const require_auth = require("../types/auth.cjs");
|
|
3
|
+
const require_partner = require("../types/partner.cjs");
|
|
4
|
+
//#region src/simulator/partner.ts
|
|
5
|
+
var DAY_MS = 864e5;
|
|
6
|
+
var PARTNER_REGIONS = new Set(Object.values(require_partner.Region));
|
|
7
|
+
var PARTNER_API_ENDPOINTS = /* @__PURE__ */ new Set([
|
|
8
|
+
"b2_create_group_member",
|
|
9
|
+
"b2_eject_group_member",
|
|
10
|
+
"b2_list_groups",
|
|
11
|
+
"b2_list_group_members",
|
|
12
|
+
"b2_reserve_trial_create_account",
|
|
13
|
+
"bz_list_computers",
|
|
14
|
+
"bz_delete_computer"
|
|
15
|
+
]);
|
|
16
|
+
var DEFAULT_GROUP_COUNT = 3;
|
|
17
|
+
var MAX_GROUPS_PER_ADMIN = 500;
|
|
18
|
+
var DEFAULT_MAX_GROUP_COUNT = 100;
|
|
19
|
+
var MAX_GROUP_COUNT = 100;
|
|
20
|
+
var MAX_AUTO_PROVISIONED_ADMINS = 100;
|
|
21
|
+
var MAX_GROUP_MEMBERS = 5e3;
|
|
22
|
+
var DEFAULT_MAX_MEMBER_COUNT = 100;
|
|
23
|
+
var MAX_MEMBER_COUNT = 1e3;
|
|
24
|
+
var DEFAULT_MAX_COMPUTER_COUNT = 100;
|
|
25
|
+
var MIN_COMPUTER_COUNT = 1;
|
|
26
|
+
var MAX_COMPUTER_COUNT = 500;
|
|
27
|
+
var DEFAULT_COMPUTER_COUNT = 3;
|
|
28
|
+
var MAX_AUTO_PROVISIONED_BACKUP_ACCOUNTS = 100;
|
|
29
|
+
var PARTNER_CREATED_STORAGE_KEY_CAPABILITIES = Object.freeze([
|
|
30
|
+
require_auth.Capability.ListBuckets,
|
|
31
|
+
require_auth.Capability.ReadBuckets,
|
|
32
|
+
require_auth.Capability.WriteBuckets,
|
|
33
|
+
require_auth.Capability.ListFiles,
|
|
34
|
+
require_auth.Capability.ReadFiles,
|
|
35
|
+
require_auth.Capability.WriteFiles,
|
|
36
|
+
require_auth.Capability.DeleteFiles
|
|
37
|
+
]);
|
|
38
|
+
function isPartnerApiEndpoint(endpoint) {
|
|
39
|
+
return PARTNER_API_ENDPOINTS.has(endpoint);
|
|
40
|
+
}
|
|
41
|
+
var PARTNER_QUERY_ENDPOINTS = /* @__PURE__ */ new Set([
|
|
42
|
+
"b2_list_groups",
|
|
43
|
+
"b2_list_group_members",
|
|
44
|
+
"bz_list_computers"
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether a JSON API endpoint can safely receive GET query parameters.
|
|
48
|
+
*
|
|
49
|
+
* @param endpoint - Endpoint name parsed from the request path.
|
|
50
|
+
*
|
|
51
|
+
* @returns `true` for Partner/Backup list endpoints that document GET query requests.
|
|
52
|
+
*/
|
|
53
|
+
function isPartnerQueryEndpoint(endpoint) {
|
|
54
|
+
return PARTNER_QUERY_ENDPOINTS.has(endpoint);
|
|
55
|
+
}
|
|
56
|
+
function utcDateString(ms) {
|
|
57
|
+
return new Date(ms).toISOString().slice(0, 10);
|
|
58
|
+
}
|
|
59
|
+
function utcDayStartMs(ms) {
|
|
60
|
+
const date = new Date(ms);
|
|
61
|
+
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
62
|
+
}
|
|
63
|
+
function requestObject(body) {
|
|
64
|
+
return typeof body === "object" && body !== null ? body : {};
|
|
65
|
+
}
|
|
66
|
+
function normalizeEmail(email) {
|
|
67
|
+
return email.trim().toLowerCase();
|
|
68
|
+
}
|
|
69
|
+
function isValidEmailAddress(email) {
|
|
70
|
+
const trimmed = email.trim();
|
|
71
|
+
if (trimmed !== email || trimmed.length < 3 || trimmed.length > 254) return false;
|
|
72
|
+
const at = trimmed.indexOf("@");
|
|
73
|
+
if (at <= 0 || at !== trimmed.lastIndexOf("@") || at === trimmed.length - 1) return false;
|
|
74
|
+
const domain = trimmed.slice(at + 1);
|
|
75
|
+
if (!domain.includes(".") || domain.startsWith(".") || domain.endsWith(".")) return false;
|
|
76
|
+
return !/\s/.test(trimmed);
|
|
77
|
+
}
|
|
78
|
+
function compareStrings(left, right) {
|
|
79
|
+
if (left < right) return -1;
|
|
80
|
+
if (left > right) return 1;
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Handles Partner and Computer Backup simulator state and endpoint logic.
|
|
85
|
+
*
|
|
86
|
+
* B2Simulator owns dispatch and shared storage primitives. This collaborator
|
|
87
|
+
* intentionally keeps both Partner and Backup surfaces together because one
|
|
88
|
+
* Partner token authorizes both products. Product-specific state remains split
|
|
89
|
+
* by map: groups/trials/members for Partner, computers for Backup.
|
|
90
|
+
*
|
|
91
|
+
* Auth has two modes:
|
|
92
|
+
*
|
|
93
|
+
* - default `new B2Simulator()` endpoint tests are permissive and accept any
|
|
94
|
+
* non-empty Partner token without binding request account IDs;
|
|
95
|
+
* - `partnerAuthorize: true` or `strictAuth: true` turns on issued-token
|
|
96
|
+
* validation so client auth-error tests can still exercise 401 responses.
|
|
97
|
+
*/
|
|
98
|
+
var PartnerSimulator = class {
|
|
99
|
+
host;
|
|
100
|
+
issuedTokens = /* @__PURE__ */ new Map();
|
|
101
|
+
knownEmails = /* @__PURE__ */ new Set();
|
|
102
|
+
groups = /* @__PURE__ */ new Map();
|
|
103
|
+
groupsByAdmin = /* @__PURE__ */ new Map();
|
|
104
|
+
groupMembers = /* @__PURE__ */ new Map();
|
|
105
|
+
groupMembersByAccountId = /* @__PURE__ */ new Map();
|
|
106
|
+
computersByAccount = /* @__PURE__ */ new Map();
|
|
107
|
+
authorizeEnabled;
|
|
108
|
+
validateIssuedTokens;
|
|
109
|
+
apiEnabled;
|
|
110
|
+
accountHasValidPhone;
|
|
111
|
+
accountInGoodStanding;
|
|
112
|
+
/**
|
|
113
|
+
* Creates the Partner/Backup simulator facade.
|
|
114
|
+
*
|
|
115
|
+
* @param host - Narrow callbacks into the parent B2 simulator.
|
|
116
|
+
* @param options - Parent simulator options relevant to Partner behavior.
|
|
117
|
+
*/
|
|
118
|
+
constructor(host, options) {
|
|
119
|
+
this.host = host;
|
|
120
|
+
this.authorizeEnabled = options.partnerAuthorize ?? false;
|
|
121
|
+
this.validateIssuedTokens = this.authorizeEnabled || (options.strictAuth ?? false);
|
|
122
|
+
this.apiEnabled = options.partnerApiEnabled ?? true;
|
|
123
|
+
this.accountHasValidPhone = options.partnerAccountHasValidPhone ?? true;
|
|
124
|
+
this.accountInGoodStanding = options.partnerAccountInGoodStanding ?? true;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Reports whether v3 authorize should return Partner/Backup suites.
|
|
128
|
+
*
|
|
129
|
+
* @returns `true` when Partner authorization is enabled.
|
|
130
|
+
*/
|
|
131
|
+
isAuthorizeEnabled() {
|
|
132
|
+
return this.authorizeEnabled;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Checks whether an endpoint name belongs to Partner or Backup APIs.
|
|
136
|
+
*
|
|
137
|
+
* @param endpoint - Endpoint name parsed from the request path.
|
|
138
|
+
*
|
|
139
|
+
* @returns `true` when this simulator should handle the endpoint.
|
|
140
|
+
*/
|
|
141
|
+
isEndpoint(endpoint) {
|
|
142
|
+
return isPartnerApiEndpoint(endpoint);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Authorizes a Partner administrator and mints a Partner token.
|
|
146
|
+
*
|
|
147
|
+
* @param authzHeader - Basic authorization header from b2_authorize_account.
|
|
148
|
+
* @param origin - Request origin used to build simulator endpoint URLs.
|
|
149
|
+
*
|
|
150
|
+
* @returns JSON response with Partner, Backup, and storage API information.
|
|
151
|
+
*/
|
|
152
|
+
authorize(authzHeader, origin = "http://localhost:0") {
|
|
153
|
+
if (!this.host.canAuthorize(authzHeader)) return this.host.error(401, "bad_auth_token", "missing or invalid Partner authorize credentials");
|
|
154
|
+
const tokenStr = this.host.genId("sim_partner_auth_token");
|
|
155
|
+
this.issuedTokens.set(tokenStr, {
|
|
156
|
+
accountId: this.host.accountId,
|
|
157
|
+
expiresAt: this.host.now() + this.host.authTokenTtlMs
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
status: 200,
|
|
161
|
+
body: {
|
|
162
|
+
accountId: require_ids.accountId(this.host.accountId),
|
|
163
|
+
authorizationToken: tokenStr,
|
|
164
|
+
apiInfo: {
|
|
165
|
+
storageApi: {
|
|
166
|
+
absoluteMinimumPartSize: this.host.minimumPartSize,
|
|
167
|
+
apiUrl: origin,
|
|
168
|
+
bucketId: null,
|
|
169
|
+
bucketName: null,
|
|
170
|
+
capabilities: [
|
|
171
|
+
require_auth.Capability.ListBuckets,
|
|
172
|
+
require_auth.Capability.ReadBuckets,
|
|
173
|
+
require_auth.Capability.WriteBuckets,
|
|
174
|
+
require_auth.Capability.DeleteBuckets,
|
|
175
|
+
require_auth.Capability.ListFiles,
|
|
176
|
+
require_auth.Capability.ReadFiles,
|
|
177
|
+
require_auth.Capability.WriteFiles,
|
|
178
|
+
require_auth.Capability.DeleteFiles
|
|
179
|
+
],
|
|
180
|
+
downloadUrl: origin,
|
|
181
|
+
infoType: "storageApi",
|
|
182
|
+
namePrefix: null,
|
|
183
|
+
recommendedPartSize: this.host.recommendedPartSize,
|
|
184
|
+
s3ApiUrl: origin
|
|
185
|
+
},
|
|
186
|
+
groupsApi: {
|
|
187
|
+
capabilities: [require_partner.PartnerCapability.All],
|
|
188
|
+
groupsApiUrl: `${origin}/partner`,
|
|
189
|
+
infoType: "groupsApi"
|
|
190
|
+
},
|
|
191
|
+
backupApi: {
|
|
192
|
+
backupApiUrl: `${origin}/backup`,
|
|
193
|
+
capabilities: [require_partner.PartnerCapability.All],
|
|
194
|
+
infoType: "backupApi"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
applicationKeyExpirationTimestamp: null
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Handles b2_reserve_trial_create_account.
|
|
203
|
+
*
|
|
204
|
+
* @param body - Parsed JSON array request body.
|
|
205
|
+
* @param authToken - Partner authorization token.
|
|
206
|
+
*
|
|
207
|
+
* @returns Simulator JSON response.
|
|
208
|
+
*/
|
|
209
|
+
reserveTrialCreateAccount(body, authToken) {
|
|
210
|
+
const auth = this.authorizeRequest(authToken);
|
|
211
|
+
if ("status" in auth) return auth;
|
|
212
|
+
if (!Array.isArray(body)) return this.host.error(400, "bad_request", "request body must be an array");
|
|
213
|
+
if (body.length === 0) return this.host.error(400, "bad_request", "request body must include at least one account");
|
|
214
|
+
const entries = [];
|
|
215
|
+
const requestEmails = /* @__PURE__ */ new Set();
|
|
216
|
+
for (const item of body) {
|
|
217
|
+
const parsed = this.parseReserveTrialCreateAccountEntry(item, requestEmails);
|
|
218
|
+
if (parsed.error !== null) return parsed.error;
|
|
219
|
+
entries.push(parsed);
|
|
220
|
+
}
|
|
221
|
+
const startDayMs = utcDayStartMs(this.host.now());
|
|
222
|
+
return {
|
|
223
|
+
status: 200,
|
|
224
|
+
body: entries.map(({ entry, normalizedEmail }) => this.createReserveTrialAccount(entry, normalizedEmail, startDayMs))
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Handles b2_create_group_member.
|
|
229
|
+
*
|
|
230
|
+
* @param body - Parsed JSON request body.
|
|
231
|
+
* @param authToken - Partner authorization token.
|
|
232
|
+
*
|
|
233
|
+
* @returns Simulator JSON response.
|
|
234
|
+
*/
|
|
235
|
+
createGroupMember(body, authToken) {
|
|
236
|
+
const auth = this.authorizeRequest(authToken, { checkPhone: false });
|
|
237
|
+
if ("status" in auth) return auth;
|
|
238
|
+
const record = requestObject(body);
|
|
239
|
+
const request = this.parseCreateGroupMemberRequest(record);
|
|
240
|
+
if ("error" in request) return request.error;
|
|
241
|
+
const accountError = this.authorizeAccount(auth, request.adminAccountId);
|
|
242
|
+
if (accountError !== null) return accountError;
|
|
243
|
+
const group = this.activeGroup(request.groupId, request.adminAccountId);
|
|
244
|
+
if (group === null) return this.host.error(401, "invalid_group_id", "group ID is invalid or deleted");
|
|
245
|
+
if (!this.accountHasValidPhone) return this.host.error(401, "invalid_sms_phone", "account is missing a valid SMS phone");
|
|
246
|
+
const normalizedEmail = normalizeEmail(request.memberEmail);
|
|
247
|
+
if (!isValidEmailAddress(request.memberEmail) || this.knownEmails.has(normalizedEmail)) return this.host.error(401, "invalid_email", "email address is invalid or already exists");
|
|
248
|
+
const members = this.membersForGroup(group.groupId);
|
|
249
|
+
if (this.activeMembersForGroup(group.groupId).length >= MAX_GROUP_MEMBERS) return this.host.error(401, "too_many_members", "group member count limit exceeded");
|
|
250
|
+
const accountId$1 = require_ids.accountId(this.host.genId("sim_group_member_account"));
|
|
251
|
+
const applicationKeyId$1 = require_ids.applicationKeyId(this.host.genId("sim_key"));
|
|
252
|
+
const applicationKey = this.host.genId("sim_secret");
|
|
253
|
+
const region = request.region ?? require_partner.Region.UsWest;
|
|
254
|
+
const stored = {
|
|
255
|
+
accountId: accountId$1,
|
|
256
|
+
email: request.memberEmail,
|
|
257
|
+
normalizedEmail,
|
|
258
|
+
groupId: group.groupId,
|
|
259
|
+
groupName: group.groupName,
|
|
260
|
+
region,
|
|
261
|
+
s3Endpoint: `s3.${region}-001.backblazeb2.com`,
|
|
262
|
+
applicationKeyId: applicationKeyId$1,
|
|
263
|
+
applicationKey,
|
|
264
|
+
createdTimestamp: this.host.monotonicTimestamp(),
|
|
265
|
+
ejected: false
|
|
266
|
+
};
|
|
267
|
+
members.set(normalizedEmail, stored);
|
|
268
|
+
this.groupMembersByAccountId.set(accountId$1, stored);
|
|
269
|
+
this.knownEmails.add(normalizedEmail);
|
|
270
|
+
this.host.storeKey({
|
|
271
|
+
applicationKeyId: applicationKeyId$1,
|
|
272
|
+
keyName: `group-member-${accountId$1}`,
|
|
273
|
+
capabilities: PARTNER_CREATED_STORAGE_KEY_CAPABILITIES,
|
|
274
|
+
accountId: accountId$1,
|
|
275
|
+
applicationKey,
|
|
276
|
+
bucketIds: null,
|
|
277
|
+
namePrefix: null,
|
|
278
|
+
expirationTimestamp: null
|
|
279
|
+
});
|
|
280
|
+
return {
|
|
281
|
+
status: 200,
|
|
282
|
+
body: [{
|
|
283
|
+
applicationKeyId: applicationKeyId$1,
|
|
284
|
+
applicationKey,
|
|
285
|
+
groupMember: this.publicGroupMember(stored)
|
|
286
|
+
}]
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Handles b2_eject_group_member.
|
|
291
|
+
*
|
|
292
|
+
* @param body - Parsed JSON request body.
|
|
293
|
+
* @param authToken - Partner authorization token.
|
|
294
|
+
*
|
|
295
|
+
* @returns Simulator JSON response.
|
|
296
|
+
*/
|
|
297
|
+
ejectGroupMember(body, authToken) {
|
|
298
|
+
const auth = this.authorizeRequest(authToken);
|
|
299
|
+
if ("status" in auth) return auth;
|
|
300
|
+
const record = requestObject(body);
|
|
301
|
+
const request = this.parseEjectGroupMemberRequest(record);
|
|
302
|
+
if ("error" in request) return request.error;
|
|
303
|
+
const accountError = this.authorizeAccount(auth, request.adminAccountId);
|
|
304
|
+
if (accountError !== null) return accountError;
|
|
305
|
+
const group = this.activeGroup(request.groupId, request.adminAccountId);
|
|
306
|
+
if (group === null) return this.host.error(401, "invalid_group_id", "group ID is invalid or deleted");
|
|
307
|
+
const member = this.groupMembersByAccountId.get(request.memberAccountId);
|
|
308
|
+
if (member === void 0 || member.ejected || member.groupId !== group.groupId) return this.host.error(401, "invalid_member_account_id", "group member account ID is invalid");
|
|
309
|
+
const previousNormalizedEmail = member.normalizedEmail;
|
|
310
|
+
if (request.email !== void 0 && request.email !== null) {
|
|
311
|
+
const normalizedEmail = normalizeEmail(request.email);
|
|
312
|
+
const keepsSameEmail = normalizedEmail === previousNormalizedEmail;
|
|
313
|
+
if (!isValidEmailAddress(request.email) || !keepsSameEmail && this.knownEmails.has(normalizedEmail)) return this.host.error(401, "invalid_email", "email address is invalid or already exists");
|
|
314
|
+
if (!keepsSameEmail) {
|
|
315
|
+
this.knownEmails.delete(previousNormalizedEmail);
|
|
316
|
+
this.knownEmails.add(normalizedEmail);
|
|
317
|
+
}
|
|
318
|
+
member.email = request.email;
|
|
319
|
+
member.normalizedEmail = normalizedEmail;
|
|
320
|
+
}
|
|
321
|
+
member.ejected = true;
|
|
322
|
+
this.groupMembers.get(group.groupId)?.delete(previousNormalizedEmail);
|
|
323
|
+
return {
|
|
324
|
+
status: 200,
|
|
325
|
+
body: this.publicGroupMember(member)
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Handles b2_list_groups.
|
|
330
|
+
*
|
|
331
|
+
* @param body - Parsed GET query parameters or JSON body.
|
|
332
|
+
* @param authToken - Partner authorization token.
|
|
333
|
+
*
|
|
334
|
+
* @returns Simulator JSON response.
|
|
335
|
+
*/
|
|
336
|
+
listGroups(body, authToken) {
|
|
337
|
+
const auth = this.authorizeRequest(authToken, { checkPhone: false });
|
|
338
|
+
if ("status" in auth) return auth;
|
|
339
|
+
const record = requestObject(body);
|
|
340
|
+
const adminAccountId = this.requiredString(record, "adminAccountId", 400, "bad_request");
|
|
341
|
+
if ("error" in adminAccountId) return adminAccountId.error;
|
|
342
|
+
const accountError = this.authorizeAccount(auth, adminAccountId.value);
|
|
343
|
+
if (accountError !== null) return accountError;
|
|
344
|
+
const maxGroupCount = this.optionalInteger(record, "maxGroupCount", DEFAULT_MAX_GROUP_COUNT, 1, MAX_GROUP_COUNT, 401, "out_of_range");
|
|
345
|
+
if ("error" in maxGroupCount) return maxGroupCount.error;
|
|
346
|
+
const groupSeedError = this.ensureGroupsForAdmin(adminAccountId.value);
|
|
347
|
+
if (groupSeedError !== null) return groupSeedError;
|
|
348
|
+
const groupNameValue = record["groupName"];
|
|
349
|
+
const groupName = typeof groupNameValue === "string" ? groupNameValue : void 0;
|
|
350
|
+
const startGroupIdValue = record["startGroupId"];
|
|
351
|
+
const startGroupId = typeof startGroupIdValue === "string" ? startGroupIdValue : void 0;
|
|
352
|
+
if (startGroupId !== void 0 && this.activeGroup(startGroupId, adminAccountId.value) === null) return this.host.error(401, "invalid_group_id", "group ID is invalid or deleted");
|
|
353
|
+
const allGroups = this.activeGroupsForAdmin(adminAccountId.value).filter((group) => groupName === void 0 || group.groupName === groupName).sort((left, right) => compareStrings(left.groupId, right.groupId));
|
|
354
|
+
const startIndex = startGroupId === void 0 ? 0 : allGroups.findIndex((group) => group.groupId >= startGroupId);
|
|
355
|
+
const normalizedStartIndex = startIndex === -1 ? allGroups.length : startIndex;
|
|
356
|
+
const page = allGroups.slice(normalizedStartIndex, normalizedStartIndex + maxGroupCount.value);
|
|
357
|
+
const next = allGroups[normalizedStartIndex + maxGroupCount.value];
|
|
358
|
+
return {
|
|
359
|
+
status: 200,
|
|
360
|
+
body: {
|
|
361
|
+
accountId: require_ids.accountId(adminAccountId.value),
|
|
362
|
+
groups: page.map((group) => this.publicGroup(group)),
|
|
363
|
+
nextGroupId: next === void 0 ? null : require_ids.groupId(next.groupId)
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Handles b2_list_group_members.
|
|
369
|
+
*
|
|
370
|
+
* @param body - Parsed GET query parameters or JSON body.
|
|
371
|
+
* @param authToken - Partner authorization token.
|
|
372
|
+
*
|
|
373
|
+
* @returns Simulator JSON response.
|
|
374
|
+
*/
|
|
375
|
+
listGroupMembers(body, authToken) {
|
|
376
|
+
const auth = this.authorizeRequest(authToken, { checkPhone: false });
|
|
377
|
+
if ("status" in auth) return auth;
|
|
378
|
+
const record = requestObject(body);
|
|
379
|
+
const request = this.parseListGroupMembersRequest(record);
|
|
380
|
+
if ("error" in request) return request.error;
|
|
381
|
+
const accountError = this.authorizeAccount(auth, request.adminAccountId);
|
|
382
|
+
if (accountError !== null) return accountError;
|
|
383
|
+
const group = this.activeGroup(request.groupId, request.adminAccountId);
|
|
384
|
+
if (group === null) return this.host.error(401, "invalid_group_id", "group ID is invalid or deleted");
|
|
385
|
+
const members = this.activeMembersForGroup(group.groupId).sort((left, right) => compareStrings(left.normalizedEmail, right.normalizedEmail));
|
|
386
|
+
const startEmail = request.startEmail === void 0 ? void 0 : normalizeEmail(request.startEmail);
|
|
387
|
+
const startIndex = startEmail === void 0 ? 0 : members.findIndex((member) => member.normalizedEmail >= startEmail);
|
|
388
|
+
const normalizedStartIndex = startIndex === -1 ? members.length : startIndex;
|
|
389
|
+
const page = members.slice(normalizedStartIndex, normalizedStartIndex + request.maxMemberCount);
|
|
390
|
+
const next = members[normalizedStartIndex + request.maxMemberCount];
|
|
391
|
+
return {
|
|
392
|
+
status: 200,
|
|
393
|
+
body: [{
|
|
394
|
+
groupId: require_ids.groupId(group.groupId),
|
|
395
|
+
groupName: group.groupName,
|
|
396
|
+
groupMembers: page.map((member) => this.publicListedGroupMember(member)),
|
|
397
|
+
nextEmail: next === void 0 ? null : next.email
|
|
398
|
+
}]
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Handles bz_list_computers.
|
|
403
|
+
*
|
|
404
|
+
* @param body - Parsed GET query parameters or JSON body.
|
|
405
|
+
* @param authToken - Partner authorization token.
|
|
406
|
+
*
|
|
407
|
+
* @returns Simulator JSON response.
|
|
408
|
+
*/
|
|
409
|
+
listComputers(body, authToken) {
|
|
410
|
+
const auth = this.authorizeRequest(authToken, { checkPhone: false });
|
|
411
|
+
if ("status" in auth) return auth;
|
|
412
|
+
const record = requestObject(body);
|
|
413
|
+
const accountId = this.requiredString(record, "accountId", 400, "invalid_account_id");
|
|
414
|
+
if ("error" in accountId) return accountId.error;
|
|
415
|
+
const accountError = this.authorizeAccount(auth, accountId.value);
|
|
416
|
+
if (accountError !== null) return accountError;
|
|
417
|
+
const maxComputerCount = this.optionalInteger(record, "maxComputerCount", DEFAULT_MAX_COMPUTER_COUNT, MIN_COMPUTER_COUNT, MAX_COMPUTER_COUNT, 400, "out_of_range");
|
|
418
|
+
if ("error" in maxComputerCount) return maxComputerCount.error;
|
|
419
|
+
const computers = this.ensureComputersForAccount(accountId.value);
|
|
420
|
+
if ("status" in computers) return computers;
|
|
421
|
+
const startComputerIdValue = record["startComputerId"];
|
|
422
|
+
const startComputerId = typeof startComputerIdValue === "string" ? startComputerIdValue : void 0;
|
|
423
|
+
if (startComputerId !== void 0) {
|
|
424
|
+
const start = computers.get(startComputerId);
|
|
425
|
+
if (start === void 0 || start.deleted) return this.host.error(400, "invalid_computer_id", "computer ID is invalid or deleted");
|
|
426
|
+
}
|
|
427
|
+
const activeComputers = [...computers.values()].filter((computer) => !computer.deleted).sort((left, right) => compareStrings(left.computerId, right.computerId));
|
|
428
|
+
const startIndex = startComputerId === void 0 ? 0 : activeComputers.findIndex((computer) => computer.computerId >= startComputerId);
|
|
429
|
+
const normalizedStartIndex = startIndex === -1 ? activeComputers.length : startIndex;
|
|
430
|
+
const page = activeComputers.slice(normalizedStartIndex, normalizedStartIndex + maxComputerCount.value);
|
|
431
|
+
const next = activeComputers[normalizedStartIndex + maxComputerCount.value];
|
|
432
|
+
return {
|
|
433
|
+
status: 200,
|
|
434
|
+
body: {
|
|
435
|
+
nextComputerId: next === void 0 ? null : next.computerId,
|
|
436
|
+
computers: page.map((computer) => this.publicComputer(computer))
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Handles bz_delete_computer.
|
|
442
|
+
*
|
|
443
|
+
* @param body - Parsed JSON request body.
|
|
444
|
+
* @param authToken - Partner authorization token.
|
|
445
|
+
*
|
|
446
|
+
* @returns Simulator JSON response.
|
|
447
|
+
*/
|
|
448
|
+
deleteComputer(body, authToken) {
|
|
449
|
+
const auth = this.authorizeRequest(authToken, { checkPhone: false });
|
|
450
|
+
if ("status" in auth) return auth;
|
|
451
|
+
const record = requestObject(body);
|
|
452
|
+
const accountId = this.requiredString(record, "accountId", 400, "invalid_account_id");
|
|
453
|
+
if ("error" in accountId) return accountId.error;
|
|
454
|
+
const computerId = this.requiredString(record, "computerId", 400, "invalid_computer_id");
|
|
455
|
+
if ("error" in computerId) return computerId.error;
|
|
456
|
+
const accountError = this.authorizeAccount(auth, accountId.value);
|
|
457
|
+
if (accountError !== null) return accountError;
|
|
458
|
+
const computer = this.computersByAccount.get(accountId.value)?.get(computerId.value);
|
|
459
|
+
if (computer === void 0 || computer.deleted) return this.host.error(400, "invalid_computer_id", "computer ID is invalid or deleted");
|
|
460
|
+
computer.deleted = true;
|
|
461
|
+
return {
|
|
462
|
+
status: 200,
|
|
463
|
+
body: [this.publicComputer(computer)]
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
authorizeRequest(authToken, options = {}) {
|
|
467
|
+
if (authToken === void 0 || authToken.trim() === "" || /\s/.test(authToken)) return this.host.error(403, "access_denied", "missing or malformed Partner API Authorization header");
|
|
468
|
+
if (!this.validateIssuedTokens) {
|
|
469
|
+
if (!this.apiEnabled) return this.host.error(403, "access_denied", "account is not enabled for Partner API");
|
|
470
|
+
if (options.checkPhone !== false && !this.accountHasValidPhone) return this.host.error(403, "access_denied", "account does not have a valid phone number");
|
|
471
|
+
if (!this.accountInGoodStanding) return this.host.error(403, "access_denied", "account is not in good standing");
|
|
472
|
+
return { accountId: null };
|
|
473
|
+
}
|
|
474
|
+
const token = this.issuedTokens.get(authToken);
|
|
475
|
+
if (token === void 0 || this.host.now() > token.expiresAt) return this.host.error(401, "unauthorized", "invalid Partner API authorization token");
|
|
476
|
+
if (!this.apiEnabled) return this.host.error(403, "access_denied", "account is not enabled for Partner API");
|
|
477
|
+
if (options.checkPhone !== false && !this.accountHasValidPhone) return this.host.error(403, "access_denied", "account does not have a valid phone number");
|
|
478
|
+
if (!this.accountInGoodStanding) return this.host.error(403, "access_denied", "account is not in good standing");
|
|
479
|
+
return { accountId: token.accountId };
|
|
480
|
+
}
|
|
481
|
+
authorizeAccount(auth, requestedAccountId) {
|
|
482
|
+
if (auth.accountId === null) return null;
|
|
483
|
+
if (auth.accountId === requestedAccountId) return null;
|
|
484
|
+
return this.host.error(403, "unauthorized", "Partner token is not authorized for requested account");
|
|
485
|
+
}
|
|
486
|
+
parseReserveTrialCreateAccountEntry(value, requestEmails) {
|
|
487
|
+
if (typeof value !== "object" || value === null) return { error: this.host.error(400, "bad_request", "trial account request must be an object") };
|
|
488
|
+
const record = value;
|
|
489
|
+
const email = record["email"];
|
|
490
|
+
if (typeof email !== "string") return { error: this.host.error(400, "bad_request", "email is required") };
|
|
491
|
+
if (!isValidEmailAddress(email)) return { error: this.host.error(400, "bad_request", "email address is invalid") };
|
|
492
|
+
const normalizedEmail = normalizeEmail(email);
|
|
493
|
+
if (this.knownEmails.has(normalizedEmail) || requestEmails.has(normalizedEmail)) return { error: this.host.error(400, "bad_request", "email must not already exist as a Backblaze account") };
|
|
494
|
+
const term = record["term"];
|
|
495
|
+
if (typeof term !== "number" || !Number.isInteger(term) || term < 7 || term > 30) return { error: this.host.error(400, "bad_request", "term must be between 7 and 30 days") };
|
|
496
|
+
const storage = record["storage"];
|
|
497
|
+
if (typeof storage !== "number" || !Number.isInteger(storage) || storage < 1 || storage > 50) return { error: this.host.error(400, "bad_request", "storage must be between 1 and 50 TB") };
|
|
498
|
+
const region = record["region"];
|
|
499
|
+
if (region !== void 0 && region !== null && (typeof region !== "string" || !PARTNER_REGIONS.has(region))) return { error: this.host.error(400, "bad_request", "region is not supported") };
|
|
500
|
+
requestEmails.add(normalizedEmail);
|
|
501
|
+
return {
|
|
502
|
+
entry: {
|
|
503
|
+
email,
|
|
504
|
+
term,
|
|
505
|
+
storage,
|
|
506
|
+
...region !== void 0 ? { region } : {}
|
|
507
|
+
},
|
|
508
|
+
normalizedEmail,
|
|
509
|
+
error: null
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
createReserveTrialAccount(request, normalizedEmail, startDayMs) {
|
|
513
|
+
const accountId$2 = require_ids.accountId(this.host.genId("sim_trial_account"));
|
|
514
|
+
const bucketName = `trial-${this.host.genId("bucket").slice(-8)}`;
|
|
515
|
+
const bucketResponse = this.host.createBucket({
|
|
516
|
+
accountId: accountId$2,
|
|
517
|
+
bucketName,
|
|
518
|
+
bucketType: "allPrivate"
|
|
519
|
+
});
|
|
520
|
+
if (bucketResponse.status !== 200) throw new Error("failed to create simulator reserve trial bucket");
|
|
521
|
+
const bucket = bucketResponse.body;
|
|
522
|
+
const keyId = require_ids.applicationKeyId(this.host.genId("sim_key"));
|
|
523
|
+
const applicationKey = this.host.genId("sim_secret");
|
|
524
|
+
this.host.storeKey({
|
|
525
|
+
applicationKeyId: keyId,
|
|
526
|
+
keyName: `reserve-trial-${bucketName}`,
|
|
527
|
+
capabilities: PARTNER_CREATED_STORAGE_KEY_CAPABILITIES,
|
|
528
|
+
accountId: accountId$2,
|
|
529
|
+
applicationKey,
|
|
530
|
+
bucketIds: [bucket.bucketId],
|
|
531
|
+
namePrefix: null,
|
|
532
|
+
expirationTimestamp: null
|
|
533
|
+
});
|
|
534
|
+
this.knownEmails.add(normalizedEmail);
|
|
535
|
+
return {
|
|
536
|
+
accountId: accountId$2,
|
|
537
|
+
applicationKey,
|
|
538
|
+
applicationKeyId: keyId,
|
|
539
|
+
s3Endpoint: `s3.${request.region ?? require_partner.Region.UsWest}-001.backblazeb2.com`,
|
|
540
|
+
startDate: utcDateString(startDayMs),
|
|
541
|
+
endDate: utcDateString(startDayMs + request.term * DAY_MS),
|
|
542
|
+
email: request.email,
|
|
543
|
+
bucketName: bucket.bucketName,
|
|
544
|
+
bucketId: bucket.bucketId
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
parseCreateGroupMemberRequest(record) {
|
|
548
|
+
const adminAccountId = this.requiredString(record, "adminAccountId", 400, "bad_request");
|
|
549
|
+
if ("error" in adminAccountId) return adminAccountId;
|
|
550
|
+
const groupId$1 = this.requiredString(record, "groupId", 401, "invalid_group_id");
|
|
551
|
+
if ("error" in groupId$1) return groupId$1;
|
|
552
|
+
const memberEmail = this.requiredString(record, "memberEmail", 401, "invalid_email");
|
|
553
|
+
if ("error" in memberEmail) return memberEmail;
|
|
554
|
+
const regionValue = record["region"];
|
|
555
|
+
if (regionValue !== void 0 && regionValue !== null && (typeof regionValue !== "string" || !PARTNER_REGIONS.has(regionValue))) return { error: this.host.error(401, "invalid_region", "region is invalid") };
|
|
556
|
+
return {
|
|
557
|
+
adminAccountId: require_ids.accountId(adminAccountId.value),
|
|
558
|
+
groupId: require_ids.groupId(groupId$1.value),
|
|
559
|
+
memberEmail: memberEmail.value,
|
|
560
|
+
...regionValue !== void 0 ? { region: regionValue } : {}
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
parseEjectGroupMemberRequest(record) {
|
|
564
|
+
const adminAccountId = this.requiredString(record, "adminAccountId", 400, "bad_request");
|
|
565
|
+
if ("error" in adminAccountId) return adminAccountId;
|
|
566
|
+
const groupId$2 = this.requiredString(record, "groupId", 401, "invalid_group_id");
|
|
567
|
+
if ("error" in groupId$2) return groupId$2;
|
|
568
|
+
const memberAccountId = this.requiredString(record, "memberAccountId", 401, "invalid_member_account_id");
|
|
569
|
+
if ("error" in memberAccountId) return memberAccountId;
|
|
570
|
+
const email = record["email"];
|
|
571
|
+
if (email !== void 0 && email !== null && typeof email !== "string") return { error: this.host.error(401, "invalid_email", "email address is invalid") };
|
|
572
|
+
return {
|
|
573
|
+
adminAccountId: require_ids.accountId(adminAccountId.value),
|
|
574
|
+
groupId: require_ids.groupId(groupId$2.value),
|
|
575
|
+
memberAccountId: require_ids.accountId(memberAccountId.value),
|
|
576
|
+
...email !== void 0 ? { email } : {}
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
parseListGroupMembersRequest(record) {
|
|
580
|
+
const adminAccountId = this.requiredString(record, "adminAccountId", 400, "bad_request");
|
|
581
|
+
if ("error" in adminAccountId) return adminAccountId;
|
|
582
|
+
const groupId$3 = this.requiredString(record, "groupId", 401, "invalid_group_id");
|
|
583
|
+
if ("error" in groupId$3) return groupId$3;
|
|
584
|
+
const maxMemberCount = this.optionalInteger(record, "maxMemberCount", DEFAULT_MAX_MEMBER_COUNT, 1, MAX_MEMBER_COUNT, 401, "out_of_range", { zeroUsesDefault: true });
|
|
585
|
+
if ("error" in maxMemberCount) return maxMemberCount;
|
|
586
|
+
const startEmail = record["startEmail"];
|
|
587
|
+
if (startEmail !== void 0 && typeof startEmail !== "string") return { error: this.host.error(400, "bad_request", "startEmail must be a string") };
|
|
588
|
+
return {
|
|
589
|
+
adminAccountId: require_ids.accountId(adminAccountId.value),
|
|
590
|
+
groupId: require_ids.groupId(groupId$3.value),
|
|
591
|
+
...startEmail !== void 0 ? { startEmail } : {},
|
|
592
|
+
maxMemberCount: maxMemberCount.value
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
requiredString(record, field, status, code) {
|
|
596
|
+
const value = record[field];
|
|
597
|
+
if (typeof value !== "string" || value === "") return { error: this.host.error(status, code, `${field} is required`) };
|
|
598
|
+
return { value };
|
|
599
|
+
}
|
|
600
|
+
optionalInteger(record, field, defaultValue, min, max, status, code, options = {}) {
|
|
601
|
+
const raw = record[field];
|
|
602
|
+
if (raw === void 0) return { value: defaultValue };
|
|
603
|
+
const value = typeof raw === "number" ? raw : typeof raw === "string" && raw !== "" ? Number(raw) : NaN;
|
|
604
|
+
if (options.zeroUsesDefault === true && value === 0) return { value: defaultValue };
|
|
605
|
+
if (!Number.isInteger(value) || value < min || value > max) return { error: this.host.error(status, code, `${field} must be between ${min} and ${max}`) };
|
|
606
|
+
return { value };
|
|
607
|
+
}
|
|
608
|
+
ensureGroupsForAdmin(adminAccountId) {
|
|
609
|
+
if (this.groupsByAdmin.has(adminAccountId)) return null;
|
|
610
|
+
if (this.groupsByAdmin.size >= MAX_AUTO_PROVISIONED_ADMINS) return this.host.error(400, "too_many_accounts", "simulator Partner account auto-provisioning cap exceeded");
|
|
611
|
+
this.groupsByAdmin.set(adminAccountId, []);
|
|
612
|
+
for (let index = 1; index <= DEFAULT_GROUP_COUNT; index += 1) this.createGroup(adminAccountId, `Simulator Group ${index}`);
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
createGroup(adminAccountId, groupName) {
|
|
616
|
+
const existingGroupIds = this.groupsByAdmin.get(adminAccountId) ?? [];
|
|
617
|
+
if (existingGroupIds.length >= MAX_GROUPS_PER_ADMIN) throw new Error("simulator Partner group cap exceeded");
|
|
618
|
+
const group = {
|
|
619
|
+
adminAccountId,
|
|
620
|
+
groupId: this.host.genId("sim_group"),
|
|
621
|
+
groupName,
|
|
622
|
+
groupProducts: ["STORAGE", "BACKUP"],
|
|
623
|
+
createdTimestamp: this.host.monotonicTimestamp(),
|
|
624
|
+
deleted: false
|
|
625
|
+
};
|
|
626
|
+
this.groups.set(group.groupId, group);
|
|
627
|
+
existingGroupIds.push(group.groupId);
|
|
628
|
+
this.groupsByAdmin.set(adminAccountId, existingGroupIds);
|
|
629
|
+
this.groupMembers.set(group.groupId, /* @__PURE__ */ new Map());
|
|
630
|
+
return group;
|
|
631
|
+
}
|
|
632
|
+
activeGroup(groupId, adminAccountId) {
|
|
633
|
+
const group = this.groups.get(groupId);
|
|
634
|
+
if (group === void 0 || group.deleted || group.adminAccountId !== adminAccountId) return null;
|
|
635
|
+
return group;
|
|
636
|
+
}
|
|
637
|
+
activeGroupsForAdmin(adminAccountId) {
|
|
638
|
+
return (this.groupsByAdmin.get(adminAccountId) ?? []).map((groupId) => this.groups.get(groupId)).filter((group) => group !== void 0 && !group.deleted);
|
|
639
|
+
}
|
|
640
|
+
membersForGroup(groupId) {
|
|
641
|
+
const existing = this.groupMembers.get(groupId);
|
|
642
|
+
if (existing !== void 0) return existing;
|
|
643
|
+
const created = /* @__PURE__ */ new Map();
|
|
644
|
+
this.groupMembers.set(groupId, created);
|
|
645
|
+
return created;
|
|
646
|
+
}
|
|
647
|
+
activeMembersForGroup(groupId) {
|
|
648
|
+
return [...this.groupMembers.get(groupId)?.values() ?? []].filter((member) => !member.ejected);
|
|
649
|
+
}
|
|
650
|
+
ensureComputersForAccount(accountId) {
|
|
651
|
+
const existing = this.computersByAccount.get(accountId);
|
|
652
|
+
if (existing !== void 0) return existing;
|
|
653
|
+
if (this.computersByAccount.size >= MAX_AUTO_PROVISIONED_BACKUP_ACCOUNTS) return this.host.error(400, "too_many_accounts", "simulator Backup account auto-provisioning cap exceeded");
|
|
654
|
+
const computers = /* @__PURE__ */ new Map();
|
|
655
|
+
for (let index = 1; index <= DEFAULT_COMPUTER_COUNT; index += 1) {
|
|
656
|
+
const computer = {
|
|
657
|
+
accountId,
|
|
658
|
+
computerId: this.host.genId("sim_computer"),
|
|
659
|
+
computerName: `sim-computer-${index}`,
|
|
660
|
+
lastFileUploadedTimestamp: this.host.monotonicTimestamp(),
|
|
661
|
+
deleted: false
|
|
662
|
+
};
|
|
663
|
+
computers.set(computer.computerId, computer);
|
|
664
|
+
}
|
|
665
|
+
this.computersByAccount.set(accountId, computers);
|
|
666
|
+
return computers;
|
|
667
|
+
}
|
|
668
|
+
publicGroup(group) {
|
|
669
|
+
const timestamp = new Date(group.createdTimestamp).toISOString();
|
|
670
|
+
return {
|
|
671
|
+
accountStandingDetails: { state: "good_standing" },
|
|
672
|
+
b2Stats: this.emptyB2Stats(group.createdTimestamp),
|
|
673
|
+
groupId: require_ids.groupId(group.groupId),
|
|
674
|
+
groupName: group.groupName,
|
|
675
|
+
groupProducts: group.groupProducts,
|
|
676
|
+
groupStats: {
|
|
677
|
+
createdTimestamp: timestamp,
|
|
678
|
+
groupStatsAsOfTimestamp: timestamp,
|
|
679
|
+
memberCount: this.activeMembersForGroup(group.groupId).length
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
publicGroupMember(member) {
|
|
684
|
+
return {
|
|
685
|
+
accountId: require_ids.accountId(member.accountId),
|
|
686
|
+
email: member.email,
|
|
687
|
+
groupId: require_ids.groupId(member.groupId),
|
|
688
|
+
groupName: member.groupName,
|
|
689
|
+
region: member.region,
|
|
690
|
+
s3Endpoint: member.s3Endpoint
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
publicListedGroupMember(member) {
|
|
694
|
+
return {
|
|
695
|
+
...this.publicGroupMember(member),
|
|
696
|
+
b2Stats: this.emptyB2Stats(member.createdTimestamp)
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
publicComputer(computer) {
|
|
700
|
+
return {
|
|
701
|
+
computerId: require_ids.computerId(computer.computerId),
|
|
702
|
+
computerName: computer.computerName,
|
|
703
|
+
lastFileUploadedTimestamp: computer.lastFileUploadedTimestamp
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
emptyB2Stats(timestamp) {
|
|
707
|
+
return {
|
|
708
|
+
b2BytesStoredCount: "0",
|
|
709
|
+
b2FilesStoredCount: "0",
|
|
710
|
+
b2StatsAsOfTimestamp: new Date(timestamp).toISOString(),
|
|
711
|
+
bucketCount: "0"
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
//#endregion
|
|
716
|
+
exports.PartnerSimulator = PartnerSimulator;
|
|
717
|
+
exports.isPartnerQueryEndpoint = isPartnerQueryEndpoint;
|
|
718
|
+
|
|
719
|
+
//# sourceMappingURL=partner.cjs.map
|