@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,108 @@
|
|
|
1
|
+
const require_errors_index = require("../errors/index.cjs");
|
|
2
|
+
const require_url_guard = require("../http/url-guard.cjs");
|
|
3
|
+
const require_transport = require("../http/transport.cjs");
|
|
4
|
+
//#region src/partner/endpoint-url.ts
|
|
5
|
+
function isLoopbackHost(hostname) {
|
|
6
|
+
const host = hostname.toLowerCase();
|
|
7
|
+
if (host === "[::1]" || host === "::1") return true;
|
|
8
|
+
const parts = host.split(".");
|
|
9
|
+
return parts.length === 4 && parts[0] === "127" && parts.every((part) => /^\d+$/.test(part) && Number(part) <= 255);
|
|
10
|
+
}
|
|
11
|
+
function hostAllowedBySuffixes(hostname, allowedSuffixes) {
|
|
12
|
+
return allowedSuffixes.some((suffix) => require_url_guard.hostMatchesAllowedSuffix(hostname, suffix));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.
|
|
16
|
+
*
|
|
17
|
+
* @param transport - Transport whose URL guard may already be locked.
|
|
18
|
+
* @param authorizedSuffixes - Suffixes derived from validated Partner authorization.
|
|
19
|
+
* @param messages - Surface-specific failure messages.
|
|
20
|
+
*
|
|
21
|
+
* @returns The suffixes safe for credential-bearing endpoint requests.
|
|
22
|
+
*
|
|
23
|
+
* @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
function endpointAllowedSuffixes(transport, authorizedSuffixes, messages) {
|
|
28
|
+
if (authorizedSuffixes.length > 0) return authorizedSuffixes;
|
|
29
|
+
const guard = require_transport.getTransportUrlGuard(transport);
|
|
30
|
+
if (guard === void 0) throw new require_errors_index.B2PartnerAuthorizationError(messages.missingGuard);
|
|
31
|
+
const suffixes = guard.getAllowedSuffixes();
|
|
32
|
+
if (suffixes.length === 0) throw new require_errors_index.B2PartnerAuthorizationError(messages.unlockedGuard);
|
|
33
|
+
return suffixes;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates a Partner-derived endpoint URL before a Partner token is sent to it.
|
|
37
|
+
*
|
|
38
|
+
* @param rawUrl - Endpoint URL from Partner authorization or cache.
|
|
39
|
+
* @param fieldName - Authorize-response field being validated.
|
|
40
|
+
* @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.
|
|
41
|
+
*
|
|
42
|
+
* @returns The original URL when it is safe to use.
|
|
43
|
+
*
|
|
44
|
+
* @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
function validatePartnerEndpointUrl(rawUrl, fieldName, allowedSuffixes) {
|
|
49
|
+
let url;
|
|
50
|
+
try {
|
|
51
|
+
url = new URL(rawUrl);
|
|
52
|
+
} catch {
|
|
53
|
+
throw new require_errors_index.B2PartnerAuthorizationError(`Partner authorize response included malformed ${fieldName}`);
|
|
54
|
+
}
|
|
55
|
+
const host = url.hostname.toLowerCase();
|
|
56
|
+
const isAllowedLoopbackHttp = url.protocol === "http:" && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes);
|
|
57
|
+
if (url.protocol !== "https:" && !isAllowedLoopbackHttp) throw new require_errors_index.B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`);
|
|
58
|
+
if (url.username !== "" || url.password !== "") throw new require_errors_index.B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must not include userinfo`);
|
|
59
|
+
if (url.search !== "" || url.hash !== "") throw new require_errors_index.B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must not include query or fragment`);
|
|
60
|
+
if (isAllowedLoopbackHttp) return rawUrl;
|
|
61
|
+
const guard = new require_url_guard.UrlGuard();
|
|
62
|
+
guard.setAllowedSuffixes(allowedSuffixes);
|
|
63
|
+
try {
|
|
64
|
+
guard.check(rawUrl);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
throw new require_errors_index.B2PartnerAuthorizationError(err instanceof Error ? `Partner authorize response included unsafe ${fieldName}: ${err.message}` : `Partner authorize response included unsafe ${fieldName}`);
|
|
67
|
+
}
|
|
68
|
+
return rawUrl;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Appends query parameters using the SDK's B2 URL encoding semantics.
|
|
72
|
+
*
|
|
73
|
+
* @param url - Base URL without query string.
|
|
74
|
+
* @param query - Query keys and string/number values to append.
|
|
75
|
+
*
|
|
76
|
+
* @returns URL with encoded query parameters, or the original URL for an empty query.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
function withQueryString(url, query) {
|
|
81
|
+
const queryString = Object.entries(query).map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`).join("&");
|
|
82
|
+
return queryString.length === 0 ? url : `${url}?${queryString}`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Forces non-idempotent mutation calls to opt out of automatic request replay.
|
|
86
|
+
*
|
|
87
|
+
* @param options - Caller-provided request options.
|
|
88
|
+
*
|
|
89
|
+
* @returns Request options with `retry.maxRetries` set to zero.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
function nonRetryingMutationRequestOptions(options) {
|
|
94
|
+
return {
|
|
95
|
+
...options?.signal !== void 0 ? { signal: options.signal } : {},
|
|
96
|
+
retry: {
|
|
97
|
+
...options?.retry ?? {},
|
|
98
|
+
maxRetries: 0
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
exports.endpointAllowedSuffixes = endpointAllowedSuffixes;
|
|
104
|
+
exports.nonRetryingMutationRequestOptions = nonRetryingMutationRequestOptions;
|
|
105
|
+
exports.validatePartnerEndpointUrl = validatePartnerEndpointUrl;
|
|
106
|
+
exports.withQueryString = withQueryString;
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=endpoint-url.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-url.cjs","names":[],"sources":["../../src/partner/endpoint-url.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport { getTransportUrlGuard, type HttpTransport } from '../http/transport.ts'\nimport { hostMatchesAllowedSuffix, UrlGuard } from '../http/url-guard.ts'\n\n/** Partner authorize endpoint URL field names that are validated before token use. */\nexport type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl'\n\n/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */\nexport interface EndpointAllowedSuffixMessages {\n /** Error message when no validated suffixes and no URL guard are available. */\n readonly missingGuard: string\n /** Error message when a URL guard exists but has not been locked to suffixes. */\n readonly unlockedGuard: string\n}\n\n/** Query-string scalar value supported by Partner and Backup endpoint helpers. */\nexport type QueryValue = string | number\n/** Query-string parameter map supported by Partner and Backup endpoint helpers. */\nexport type QueryParams = Readonly<Record<string, QueryValue>>\n\n/** Shared request options shape for non-idempotent Partner and Backup mutations. */\nexport interface MutationRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const host = hostname.toLowerCase()\n if (host === '[::1]' || host === '::1') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction hostAllowedBySuffixes(hostname: string, allowedSuffixes: readonly string[]): boolean {\n return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix))\n}\n\n/**\n * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.\n *\n * @param transport - Transport whose URL guard may already be locked.\n * @param authorizedSuffixes - Suffixes derived from validated Partner authorization.\n * @param messages - Surface-specific failure messages.\n *\n * @returns The suffixes safe for credential-bearing endpoint requests.\n *\n * @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.\n *\n * @internal\n */\nexport function endpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n messages: EndpointAllowedSuffixMessages,\n): readonly string[] {\n if (authorizedSuffixes.length > 0) return authorizedSuffixes\n\n const guard = getTransportUrlGuard(transport)\n if (guard === undefined) {\n throw new B2PartnerAuthorizationError(messages.missingGuard)\n }\n\n const suffixes = guard.getAllowedSuffixes()\n if (suffixes.length === 0) {\n throw new B2PartnerAuthorizationError(messages.unlockedGuard)\n }\n\n return suffixes\n}\n\n/**\n * Validates a Partner-derived endpoint URL before a Partner token is sent to it.\n *\n * @param rawUrl - Endpoint URL from Partner authorization or cache.\n * @param fieldName - Authorize-response field being validated.\n * @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.\n *\n * @returns The original URL when it is safe to use.\n *\n * @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.\n *\n * @internal\n */\nexport function validatePartnerEndpointUrl(\n rawUrl: string,\n fieldName: PartnerEndpointUrlField,\n allowedSuffixes: readonly string[],\n): string {\n let url: URL\n try {\n url = new URL(rawUrl)\n } catch {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response included malformed ${fieldName}`,\n )\n }\n\n const host = url.hostname.toLowerCase()\n const isAllowedLoopbackHttp =\n url.protocol === 'http:' && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes)\n\n if (url.protocol !== 'https:' && !isAllowedLoopbackHttp) {\n throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`)\n }\n if (url.username !== '' || url.password !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include userinfo`,\n )\n }\n if (url.search !== '' || url.hash !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include query or fragment`,\n )\n }\n\n if (isAllowedLoopbackHttp) return rawUrl\n\n const guard = new UrlGuard()\n guard.setAllowedSuffixes(allowedSuffixes)\n try {\n guard.check(rawUrl)\n } catch (err) {\n throw new B2PartnerAuthorizationError(\n err instanceof Error\n ? `Partner authorize response included unsafe ${fieldName}: ${err.message}`\n : `Partner authorize response included unsafe ${fieldName}`,\n )\n }\n\n return rawUrl\n}\n\n/**\n * Appends query parameters using the SDK's B2 URL encoding semantics.\n *\n * @param url - Base URL without query string.\n * @param query - Query keys and string/number values to append.\n *\n * @returns URL with encoded query parameters, or the original URL for an empty query.\n *\n * @internal\n */\nexport function withQueryString(url: string, query: QueryParams): string {\n // Match the storage raw client's encodeURIComponent query semantics: spaces\n // are `%20`, not form-style `+`.\n const queryString = Object.entries(query)\n .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)\n .join('&')\n return queryString.length === 0 ? url : `${url}?${queryString}`\n}\n\n/**\n * Forces non-idempotent mutation calls to opt out of automatic request replay.\n *\n * @param options - Caller-provided request options.\n *\n * @returns Request options with `retry.maxRetries` set to zero.\n *\n * @internal\n */\nexport function nonRetryingMutationRequestOptions(\n options: MutationRequestOptions | undefined,\n): MutationRequestOptions {\n return {\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n retry: { ...(options?.retry ?? {}), maxRetries: 0 },\n }\n}\n"],"mappings":";;;;AA6BA,SAAS,eAAe,UAA2B;CACjD,MAAM,OAAO,SAAS,YAAY;CAClC,IAAI,SAAS,WAAW,SAAS,OAAO,OAAO;CAE/C,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,OACE,MAAM,WAAW,KACjB,MAAM,OAAO,SACb,MAAM,OAAO,SAAS,QAAQ,KAAK,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG;AAEnE;AAEA,SAAS,sBAAsB,UAAkB,iBAA6C;CAC5F,OAAO,gBAAgB,MAAM,WAAW,kBAAA,yBAAyB,UAAU,MAAM,CAAC;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,WACA,oBACA,UACmB;CACnB,IAAI,mBAAmB,SAAS,GAAG,OAAO;CAE1C,MAAM,QAAQ,kBAAA,qBAAqB,SAAS;CAC5C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,qBAAA,4BAA4B,SAAS,YAAY;CAG7D,MAAM,WAAW,MAAM,mBAAmB;CAC1C,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,qBAAA,4BAA4B,SAAS,aAAa;CAG9D,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,2BACd,QACA,WACA,iBACQ;CACR,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,MAAM;CACtB,QAAQ;EACN,MAAM,IAAI,qBAAA,4BACR,iDAAiD,WACnD;CACF;CAEA,MAAM,OAAO,IAAI,SAAS,YAAY;CACtC,MAAM,wBACJ,IAAI,aAAa,WAAW,eAAe,IAAI,KAAK,sBAAsB,MAAM,eAAe;CAEjG,IAAI,IAAI,aAAa,YAAY,CAAC,uBAChC,MAAM,IAAI,qBAAA,4BAA4B,8BAA8B,UAAU,gBAAgB;CAEhG,IAAI,IAAI,aAAa,MAAM,IAAI,aAAa,IAC1C,MAAM,IAAI,qBAAA,4BACR,8BAA8B,UAAU,2BAC1C;CAEF,IAAI,IAAI,WAAW,MAAM,IAAI,SAAS,IACpC,MAAM,IAAI,qBAAA,4BACR,8BAA8B,UAAU,oCAC1C;CAGF,IAAI,uBAAuB,OAAO;CAElC,MAAM,QAAQ,IAAI,kBAAA,SAAS;CAC3B,MAAM,mBAAmB,eAAe;CACxC,IAAI;EACF,MAAM,MAAM,MAAM;CACpB,SAAS,KAAK;EACZ,MAAM,IAAI,qBAAA,4BACR,eAAe,QACX,8CAA8C,UAAU,IAAI,IAAI,YAChE,8CAA8C,WACpD;CACF;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,gBAAgB,KAAa,OAA4B;CAGvE,MAAM,cAAc,OAAO,QAAQ,KAAK,CAAC,CACtC,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,GAAG,mBAAmB,OAAO,KAAK,CAAC,GAAG,CAAC,CACpE,KAAK,GAAG;CACX,OAAO,YAAY,WAAW,IAAI,MAAM,GAAG,IAAI,GAAG;AACpD;;;;;;;;;;AAWA,SAAgB,kCACd,SACwB;CACxB,OAAO;EACL,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAClE,OAAO;GAAE,GAAI,SAAS,SAAS,CAAC;GAAI,YAAY;EAAE;CACpD;AACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { RetryOptions } from '../http/retry.js';
|
|
2
|
+
import { HttpTransport } from '../http/transport.js';
|
|
3
|
+
/** Partner authorize endpoint URL field names that are validated before token use. */
|
|
4
|
+
export type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl';
|
|
5
|
+
/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */
|
|
6
|
+
export interface EndpointAllowedSuffixMessages {
|
|
7
|
+
/** Error message when no validated suffixes and no URL guard are available. */
|
|
8
|
+
readonly missingGuard: string;
|
|
9
|
+
/** Error message when a URL guard exists but has not been locked to suffixes. */
|
|
10
|
+
readonly unlockedGuard: string;
|
|
11
|
+
}
|
|
12
|
+
/** Query-string scalar value supported by Partner and Backup endpoint helpers. */
|
|
13
|
+
export type QueryValue = string | number;
|
|
14
|
+
/** Query-string parameter map supported by Partner and Backup endpoint helpers. */
|
|
15
|
+
export type QueryParams = Readonly<Record<string, QueryValue>>;
|
|
16
|
+
/** Shared request options shape for non-idempotent Partner and Backup mutations. */
|
|
17
|
+
export interface MutationRequestOptions {
|
|
18
|
+
/** Abort signal for cancelling the request. */
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
/** Per-request retry override. */
|
|
21
|
+
readonly retry?: Partial<RetryOptions>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.
|
|
25
|
+
*
|
|
26
|
+
* @param transport - Transport whose URL guard may already be locked.
|
|
27
|
+
* @param authorizedSuffixes - Suffixes derived from validated Partner authorization.
|
|
28
|
+
* @param messages - Surface-specific failure messages.
|
|
29
|
+
*
|
|
30
|
+
* @returns The suffixes safe for credential-bearing endpoint requests.
|
|
31
|
+
*
|
|
32
|
+
* @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function endpointAllowedSuffixes(transport: HttpTransport, authorizedSuffixes: readonly string[], messages: EndpointAllowedSuffixMessages): readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Validates a Partner-derived endpoint URL before a Partner token is sent to it.
|
|
39
|
+
*
|
|
40
|
+
* @param rawUrl - Endpoint URL from Partner authorization or cache.
|
|
41
|
+
* @param fieldName - Authorize-response field being validated.
|
|
42
|
+
* @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.
|
|
43
|
+
*
|
|
44
|
+
* @returns The original URL when it is safe to use.
|
|
45
|
+
*
|
|
46
|
+
* @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function validatePartnerEndpointUrl(rawUrl: string, fieldName: PartnerEndpointUrlField, allowedSuffixes: readonly string[]): string;
|
|
51
|
+
/**
|
|
52
|
+
* Appends query parameters using the SDK's B2 URL encoding semantics.
|
|
53
|
+
*
|
|
54
|
+
* @param url - Base URL without query string.
|
|
55
|
+
* @param query - Query keys and string/number values to append.
|
|
56
|
+
*
|
|
57
|
+
* @returns URL with encoded query parameters, or the original URL for an empty query.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare function withQueryString(url: string, query: QueryParams): string;
|
|
62
|
+
/**
|
|
63
|
+
* Forces non-idempotent mutation calls to opt out of automatic request replay.
|
|
64
|
+
*
|
|
65
|
+
* @param options - Caller-provided request options.
|
|
66
|
+
*
|
|
67
|
+
* @returns Request options with `retry.maxRetries` set to zero.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export declare function nonRetryingMutationRequestOptions(options: MutationRequestOptions | undefined): MutationRequestOptions;
|
|
72
|
+
//# sourceMappingURL=endpoint-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-url.d.ts","sourceRoot":"","sources":["../../src/partner/endpoint-url.js"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG/E,sFAAsF;AACtF,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,cAAc,CAAA;AAErE,4FAA4F;AAC5F,MAAM,WAAW,6BAA6B;IAC5C,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AACxC,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;AAE9D,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CACvC;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,SAAS,MAAM,EAAE,EACrC,QAAQ,EAAE,6BAA6B,GACtC,SAAS,MAAM,EAAE,CAcnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,uBAAuB,EAClC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,CA2CR;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,sBAAsB,GAAG,SAAS,GAC1C,sBAAsB,CAKxB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { RetryOptions } from '../http/retry.js';
|
|
2
|
+
import { HttpTransport } from '../http/transport.js';
|
|
3
|
+
/** Partner authorize endpoint URL field names that are validated before token use. */
|
|
4
|
+
export type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl';
|
|
5
|
+
/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */
|
|
6
|
+
export interface EndpointAllowedSuffixMessages {
|
|
7
|
+
/** Error message when no validated suffixes and no URL guard are available. */
|
|
8
|
+
readonly missingGuard: string;
|
|
9
|
+
/** Error message when a URL guard exists but has not been locked to suffixes. */
|
|
10
|
+
readonly unlockedGuard: string;
|
|
11
|
+
}
|
|
12
|
+
/** Query-string scalar value supported by Partner and Backup endpoint helpers. */
|
|
13
|
+
export type QueryValue = string | number;
|
|
14
|
+
/** Query-string parameter map supported by Partner and Backup endpoint helpers. */
|
|
15
|
+
export type QueryParams = Readonly<Record<string, QueryValue>>;
|
|
16
|
+
/** Shared request options shape for non-idempotent Partner and Backup mutations. */
|
|
17
|
+
export interface MutationRequestOptions {
|
|
18
|
+
/** Abort signal for cancelling the request. */
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
/** Per-request retry override. */
|
|
21
|
+
readonly retry?: Partial<RetryOptions>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.
|
|
25
|
+
*
|
|
26
|
+
* @param transport - Transport whose URL guard may already be locked.
|
|
27
|
+
* @param authorizedSuffixes - Suffixes derived from validated Partner authorization.
|
|
28
|
+
* @param messages - Surface-specific failure messages.
|
|
29
|
+
*
|
|
30
|
+
* @returns The suffixes safe for credential-bearing endpoint requests.
|
|
31
|
+
*
|
|
32
|
+
* @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function endpointAllowedSuffixes(transport: HttpTransport, authorizedSuffixes: readonly string[], messages: EndpointAllowedSuffixMessages): readonly string[];
|
|
37
|
+
/**
|
|
38
|
+
* Validates a Partner-derived endpoint URL before a Partner token is sent to it.
|
|
39
|
+
*
|
|
40
|
+
* @param rawUrl - Endpoint URL from Partner authorization or cache.
|
|
41
|
+
* @param fieldName - Authorize-response field being validated.
|
|
42
|
+
* @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.
|
|
43
|
+
*
|
|
44
|
+
* @returns The original URL when it is safe to use.
|
|
45
|
+
*
|
|
46
|
+
* @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.
|
|
47
|
+
*
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function validatePartnerEndpointUrl(rawUrl: string, fieldName: PartnerEndpointUrlField, allowedSuffixes: readonly string[]): string;
|
|
51
|
+
/**
|
|
52
|
+
* Appends query parameters using the SDK's B2 URL encoding semantics.
|
|
53
|
+
*
|
|
54
|
+
* @param url - Base URL without query string.
|
|
55
|
+
* @param query - Query keys and string/number values to append.
|
|
56
|
+
*
|
|
57
|
+
* @returns URL with encoded query parameters, or the original URL for an empty query.
|
|
58
|
+
*
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare function withQueryString(url: string, query: QueryParams): string;
|
|
62
|
+
/**
|
|
63
|
+
* Forces non-idempotent mutation calls to opt out of automatic request replay.
|
|
64
|
+
*
|
|
65
|
+
* @param options - Caller-provided request options.
|
|
66
|
+
*
|
|
67
|
+
* @returns Request options with `retry.maxRetries` set to zero.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export declare function nonRetryingMutationRequestOptions(options: MutationRequestOptions | undefined): MutationRequestOptions;
|
|
72
|
+
//# sourceMappingURL=endpoint-url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-url.d.ts","sourceRoot":"","sources":["../../src/partner/endpoint-url.js"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAG/E,sFAAsF;AACtF,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,cAAc,CAAA;AAErE,4FAA4F;AAC5F,MAAM,WAAW,6BAA6B;IAC5C,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,iFAAiF;IACjF,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAC/B;AAED,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;AACxC,mFAAmF;AACnF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;AAE9D,oFAAoF;AACpF,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CACvC;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,SAAS,MAAM,EAAE,EACrC,QAAQ,EAAE,6BAA6B,GACtC,SAAS,MAAM,EAAE,CAcnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,uBAAuB,EAClC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC,MAAM,CA2CR;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,CAOvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,sBAAsB,GAAG,SAAS,GAC1C,sBAAsB,CAKxB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { B2PartnerAuthorizationError } from "../errors/index.js";
|
|
2
|
+
import { UrlGuard, hostMatchesAllowedSuffix } from "../http/url-guard.js";
|
|
3
|
+
import { getTransportUrlGuard } from "../http/transport.js";
|
|
4
|
+
//#region src/partner/endpoint-url.ts
|
|
5
|
+
function isLoopbackHost(hostname) {
|
|
6
|
+
const host = hostname.toLowerCase();
|
|
7
|
+
if (host === "[::1]" || host === "::1") return true;
|
|
8
|
+
const parts = host.split(".");
|
|
9
|
+
return parts.length === 4 && parts[0] === "127" && parts.every((part) => /^\d+$/.test(part) && Number(part) <= 255);
|
|
10
|
+
}
|
|
11
|
+
function hostAllowedBySuffixes(hostname, allowedSuffixes) {
|
|
12
|
+
return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.
|
|
16
|
+
*
|
|
17
|
+
* @param transport - Transport whose URL guard may already be locked.
|
|
18
|
+
* @param authorizedSuffixes - Suffixes derived from validated Partner authorization.
|
|
19
|
+
* @param messages - Surface-specific failure messages.
|
|
20
|
+
*
|
|
21
|
+
* @returns The suffixes safe for credential-bearing endpoint requests.
|
|
22
|
+
*
|
|
23
|
+
* @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
function endpointAllowedSuffixes(transport, authorizedSuffixes, messages) {
|
|
28
|
+
if (authorizedSuffixes.length > 0) return authorizedSuffixes;
|
|
29
|
+
const guard = getTransportUrlGuard(transport);
|
|
30
|
+
if (guard === void 0) throw new B2PartnerAuthorizationError(messages.missingGuard);
|
|
31
|
+
const suffixes = guard.getAllowedSuffixes();
|
|
32
|
+
if (suffixes.length === 0) throw new B2PartnerAuthorizationError(messages.unlockedGuard);
|
|
33
|
+
return suffixes;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates a Partner-derived endpoint URL before a Partner token is sent to it.
|
|
37
|
+
*
|
|
38
|
+
* @param rawUrl - Endpoint URL from Partner authorization or cache.
|
|
39
|
+
* @param fieldName - Authorize-response field being validated.
|
|
40
|
+
* @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.
|
|
41
|
+
*
|
|
42
|
+
* @returns The original URL when it is safe to use.
|
|
43
|
+
*
|
|
44
|
+
* @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.
|
|
45
|
+
*
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
function validatePartnerEndpointUrl(rawUrl, fieldName, allowedSuffixes) {
|
|
49
|
+
let url;
|
|
50
|
+
try {
|
|
51
|
+
url = new URL(rawUrl);
|
|
52
|
+
} catch {
|
|
53
|
+
throw new B2PartnerAuthorizationError(`Partner authorize response included malformed ${fieldName}`);
|
|
54
|
+
}
|
|
55
|
+
const host = url.hostname.toLowerCase();
|
|
56
|
+
const isAllowedLoopbackHttp = url.protocol === "http:" && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes);
|
|
57
|
+
if (url.protocol !== "https:" && !isAllowedLoopbackHttp) throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`);
|
|
58
|
+
if (url.username !== "" || url.password !== "") throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must not include userinfo`);
|
|
59
|
+
if (url.search !== "" || url.hash !== "") throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must not include query or fragment`);
|
|
60
|
+
if (isAllowedLoopbackHttp) return rawUrl;
|
|
61
|
+
const guard = new UrlGuard();
|
|
62
|
+
guard.setAllowedSuffixes(allowedSuffixes);
|
|
63
|
+
try {
|
|
64
|
+
guard.check(rawUrl);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
throw new B2PartnerAuthorizationError(err instanceof Error ? `Partner authorize response included unsafe ${fieldName}: ${err.message}` : `Partner authorize response included unsafe ${fieldName}`);
|
|
67
|
+
}
|
|
68
|
+
return rawUrl;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Appends query parameters using the SDK's B2 URL encoding semantics.
|
|
72
|
+
*
|
|
73
|
+
* @param url - Base URL without query string.
|
|
74
|
+
* @param query - Query keys and string/number values to append.
|
|
75
|
+
*
|
|
76
|
+
* @returns URL with encoded query parameters, or the original URL for an empty query.
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
function withQueryString(url, query) {
|
|
81
|
+
const queryString = Object.entries(query).map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`).join("&");
|
|
82
|
+
return queryString.length === 0 ? url : `${url}?${queryString}`;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Forces non-idempotent mutation calls to opt out of automatic request replay.
|
|
86
|
+
*
|
|
87
|
+
* @param options - Caller-provided request options.
|
|
88
|
+
*
|
|
89
|
+
* @returns Request options with `retry.maxRetries` set to zero.
|
|
90
|
+
*
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
function nonRetryingMutationRequestOptions(options) {
|
|
94
|
+
return {
|
|
95
|
+
...options?.signal !== void 0 ? { signal: options.signal } : {},
|
|
96
|
+
retry: {
|
|
97
|
+
...options?.retry ?? {},
|
|
98
|
+
maxRetries: 0
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { endpointAllowedSuffixes, nonRetryingMutationRequestOptions, validatePartnerEndpointUrl, withQueryString };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=endpoint-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint-url.js","names":[],"sources":["../../src/partner/endpoint-url.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { RetryOptions } from '../http/retry.ts'\nimport { getTransportUrlGuard, type HttpTransport } from '../http/transport.ts'\nimport { hostMatchesAllowedSuffix, UrlGuard } from '../http/url-guard.ts'\n\n/** Partner authorize endpoint URL field names that are validated before token use. */\nexport type PartnerEndpointUrlField = 'groupsApiUrl' | 'backupApiUrl'\n\n/** Message copy for resolving endpoint suffixes from an authorized or guarded transport. */\nexport interface EndpointAllowedSuffixMessages {\n /** Error message when no validated suffixes and no URL guard are available. */\n readonly missingGuard: string\n /** Error message when a URL guard exists but has not been locked to suffixes. */\n readonly unlockedGuard: string\n}\n\n/** Query-string scalar value supported by Partner and Backup endpoint helpers. */\nexport type QueryValue = string | number\n/** Query-string parameter map supported by Partner and Backup endpoint helpers. */\nexport type QueryParams = Readonly<Record<string, QueryValue>>\n\n/** Shared request options shape for non-idempotent Partner and Backup mutations. */\nexport interface MutationRequestOptions {\n /** Abort signal for cancelling the request. */\n readonly signal?: AbortSignal\n /** Per-request retry override. */\n readonly retry?: Partial<RetryOptions>\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const host = hostname.toLowerCase()\n if (host === '[::1]' || host === '::1') return true\n\n const parts = host.split('.')\n return (\n parts.length === 4 &&\n parts[0] === '127' &&\n parts.every((part) => /^\\d+$/.test(part) && Number(part) <= 255)\n )\n}\n\nfunction hostAllowedBySuffixes(hostname: string, allowedSuffixes: readonly string[]): boolean {\n return allowedSuffixes.some((suffix) => hostMatchesAllowedSuffix(hostname, suffix))\n}\n\n/**\n * Resolves endpoint host suffixes from fresh/cached Partner authorization or a locked transport guard.\n *\n * @param transport - Transport whose URL guard may already be locked.\n * @param authorizedSuffixes - Suffixes derived from validated Partner authorization.\n * @param messages - Surface-specific failure messages.\n *\n * @returns The suffixes safe for credential-bearing endpoint requests.\n *\n * @throws B2PartnerAuthorizationError if no locked guard or authorized suffixes exist.\n *\n * @internal\n */\nexport function endpointAllowedSuffixes(\n transport: HttpTransport,\n authorizedSuffixes: readonly string[],\n messages: EndpointAllowedSuffixMessages,\n): readonly string[] {\n if (authorizedSuffixes.length > 0) return authorizedSuffixes\n\n const guard = getTransportUrlGuard(transport)\n if (guard === undefined) {\n throw new B2PartnerAuthorizationError(messages.missingGuard)\n }\n\n const suffixes = guard.getAllowedSuffixes()\n if (suffixes.length === 0) {\n throw new B2PartnerAuthorizationError(messages.unlockedGuard)\n }\n\n return suffixes\n}\n\n/**\n * Validates a Partner-derived endpoint URL before a Partner token is sent to it.\n *\n * @param rawUrl - Endpoint URL from Partner authorization or cache.\n * @param fieldName - Authorize-response field being validated.\n * @param allowedSuffixes - Host suffix allow-list derived from the trusted realm.\n *\n * @returns The original URL when it is safe to use.\n *\n * @throws B2PartnerAuthorizationError if the URL is malformed or unsafe.\n *\n * @internal\n */\nexport function validatePartnerEndpointUrl(\n rawUrl: string,\n fieldName: PartnerEndpointUrlField,\n allowedSuffixes: readonly string[],\n): string {\n let url: URL\n try {\n url = new URL(rawUrl)\n } catch {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response included malformed ${fieldName}`,\n )\n }\n\n const host = url.hostname.toLowerCase()\n const isAllowedLoopbackHttp =\n url.protocol === 'http:' && isLoopbackHost(host) && hostAllowedBySuffixes(host, allowedSuffixes)\n\n if (url.protocol !== 'https:' && !isAllowedLoopbackHttp) {\n throw new B2PartnerAuthorizationError(`Partner authorize response ${fieldName} must use HTTPS`)\n }\n if (url.username !== '' || url.password !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include userinfo`,\n )\n }\n if (url.search !== '' || url.hash !== '') {\n throw new B2PartnerAuthorizationError(\n `Partner authorize response ${fieldName} must not include query or fragment`,\n )\n }\n\n if (isAllowedLoopbackHttp) return rawUrl\n\n const guard = new UrlGuard()\n guard.setAllowedSuffixes(allowedSuffixes)\n try {\n guard.check(rawUrl)\n } catch (err) {\n throw new B2PartnerAuthorizationError(\n err instanceof Error\n ? `Partner authorize response included unsafe ${fieldName}: ${err.message}`\n : `Partner authorize response included unsafe ${fieldName}`,\n )\n }\n\n return rawUrl\n}\n\n/**\n * Appends query parameters using the SDK's B2 URL encoding semantics.\n *\n * @param url - Base URL without query string.\n * @param query - Query keys and string/number values to append.\n *\n * @returns URL with encoded query parameters, or the original URL for an empty query.\n *\n * @internal\n */\nexport function withQueryString(url: string, query: QueryParams): string {\n // Match the storage raw client's encodeURIComponent query semantics: spaces\n // are `%20`, not form-style `+`.\n const queryString = Object.entries(query)\n .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)\n .join('&')\n return queryString.length === 0 ? url : `${url}?${queryString}`\n}\n\n/**\n * Forces non-idempotent mutation calls to opt out of automatic request replay.\n *\n * @param options - Caller-provided request options.\n *\n * @returns Request options with `retry.maxRetries` set to zero.\n *\n * @internal\n */\nexport function nonRetryingMutationRequestOptions(\n options: MutationRequestOptions | undefined,\n): MutationRequestOptions {\n return {\n ...(options?.signal !== undefined ? { signal: options.signal } : {}),\n retry: { ...(options?.retry ?? {}), maxRetries: 0 },\n }\n}\n"],"mappings":";;;;AA6BA,SAAS,eAAe,UAA2B;CACjD,MAAM,OAAO,SAAS,YAAY;CAClC,IAAI,SAAS,WAAW,SAAS,OAAO,OAAO;CAE/C,MAAM,QAAQ,KAAK,MAAM,GAAG;CAC5B,OACE,MAAM,WAAW,KACjB,MAAM,OAAO,SACb,MAAM,OAAO,SAAS,QAAQ,KAAK,IAAI,KAAK,OAAO,IAAI,KAAK,GAAG;AAEnE;AAEA,SAAS,sBAAsB,UAAkB,iBAA6C;CAC5F,OAAO,gBAAgB,MAAM,WAAW,yBAAyB,UAAU,MAAM,CAAC;AACpF;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,WACA,oBACA,UACmB;CACnB,IAAI,mBAAmB,SAAS,GAAG,OAAO;CAE1C,MAAM,QAAQ,qBAAqB,SAAS;CAC5C,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,4BAA4B,SAAS,YAAY;CAG7D,MAAM,WAAW,MAAM,mBAAmB;CAC1C,IAAI,SAAS,WAAW,GACtB,MAAM,IAAI,4BAA4B,SAAS,aAAa;CAG9D,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,2BACd,QACA,WACA,iBACQ;CACR,IAAI;CACJ,IAAI;EACF,MAAM,IAAI,IAAI,MAAM;CACtB,QAAQ;EACN,MAAM,IAAI,4BACR,iDAAiD,WACnD;CACF;CAEA,MAAM,OAAO,IAAI,SAAS,YAAY;CACtC,MAAM,wBACJ,IAAI,aAAa,WAAW,eAAe,IAAI,KAAK,sBAAsB,MAAM,eAAe;CAEjG,IAAI,IAAI,aAAa,YAAY,CAAC,uBAChC,MAAM,IAAI,4BAA4B,8BAA8B,UAAU,gBAAgB;CAEhG,IAAI,IAAI,aAAa,MAAM,IAAI,aAAa,IAC1C,MAAM,IAAI,4BACR,8BAA8B,UAAU,2BAC1C;CAEF,IAAI,IAAI,WAAW,MAAM,IAAI,SAAS,IACpC,MAAM,IAAI,4BACR,8BAA8B,UAAU,oCAC1C;CAGF,IAAI,uBAAuB,OAAO;CAElC,MAAM,QAAQ,IAAI,SAAS;CAC3B,MAAM,mBAAmB,eAAe;CACxC,IAAI;EACF,MAAM,MAAM,MAAM;CACpB,SAAS,KAAK;EACZ,MAAM,IAAI,4BACR,eAAe,QACX,8CAA8C,UAAU,IAAI,IAAI,YAChE,8CAA8C,WACpD;CACF;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,gBAAgB,KAAa,OAA4B;CAGvE,MAAM,cAAc,OAAO,QAAQ,KAAK,CAAC,CACtC,KAAK,CAAC,KAAK,WAAW,GAAG,IAAI,GAAG,mBAAmB,OAAO,KAAK,CAAC,GAAG,CAAC,CACpE,KAAK,GAAG;CACX,OAAO,YAAY,WAAW,IAAI,MAAM,GAAG,IAAI,GAAG;AACpD;;;;;;;;;;AAWA,SAAgB,kCACd,SACwB;CACxB,OAAO;EACL,GAAI,SAAS,WAAW,KAAA,IAAY,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;EAClE,OAAO;GAAE,GAAI,SAAS,SAAS,CAAC;GAAI,YAAY;EAAE;CACpD;AACF"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const require_errors_index = require("../errors/index.cjs");
|
|
2
|
+
const require_redaction_placeholders = require("./redaction-placeholders.cjs");
|
|
3
|
+
const require_auth_clone = require("./auth-clone.cjs");
|
|
4
|
+
const require_redaction = require("./redaction.cjs");
|
|
5
|
+
//#region src/partner/in-memory.ts
|
|
6
|
+
function clonePartnerAuth(auth) {
|
|
7
|
+
return require_redaction.redactPartnerAuthorizeResponse(require_auth_clone.clonePartnerAuthorizeResponse(auth));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* In-memory implementation of {@link PartnerAccountInfo}.
|
|
11
|
+
* Suitable for short-lived processes or tests; state is lost when the process exits.
|
|
12
|
+
*/
|
|
13
|
+
var InMemoryPartnerAccountInfo = class {
|
|
14
|
+
/** Cached Partner authorization response, or null before authorizePartner() is called. */
|
|
15
|
+
#auth = null;
|
|
16
|
+
/**
|
|
17
|
+
* Store a fresh Partner authorization response, replacing any previous state.
|
|
18
|
+
*
|
|
19
|
+
* @param auth - The Partner authorize response to store.
|
|
20
|
+
*/
|
|
21
|
+
setAuth(auth) {
|
|
22
|
+
this.#auth = clonePartnerAuth(auth);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Return the current Partner authorization response, or null if not authorized.
|
|
26
|
+
*
|
|
27
|
+
* @returns The cached Partner authorization response, or null if not yet authorized.
|
|
28
|
+
*/
|
|
29
|
+
getAuth() {
|
|
30
|
+
return this.#auth;
|
|
31
|
+
}
|
|
32
|
+
/** Discard all cached Partner authorization state. */
|
|
33
|
+
clear() {
|
|
34
|
+
this.#auth = null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Current Partner/Backup authorization token.
|
|
38
|
+
*
|
|
39
|
+
* @returns The current Partner token.
|
|
40
|
+
*
|
|
41
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
42
|
+
*/
|
|
43
|
+
getPartnerToken() {
|
|
44
|
+
return this.requireAuth().authorizationToken;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Base URL for Partner API calls.
|
|
48
|
+
*
|
|
49
|
+
* @returns The base URL for Partner API calls.
|
|
50
|
+
*
|
|
51
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
52
|
+
*/
|
|
53
|
+
getGroupsApiUrl() {
|
|
54
|
+
return this.requireAuth().apiInfo.groupsApi?.groupsApiUrl ?? null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Base URL for Computer Backup API calls, or null when the suite is unavailable.
|
|
58
|
+
*
|
|
59
|
+
* @returns The Computer Backup API URL, or null.
|
|
60
|
+
*
|
|
61
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
62
|
+
*/
|
|
63
|
+
getBackupApiUrl() {
|
|
64
|
+
return this.requireAuth().backupApiUrl ?? null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The authorized partner administrator account ID.
|
|
68
|
+
*
|
|
69
|
+
* @returns The authorized account identifier.
|
|
70
|
+
*
|
|
71
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
72
|
+
*/
|
|
73
|
+
getAccountId() {
|
|
74
|
+
return this.requireAuth().accountId;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Capabilities granted for Partner API calls.
|
|
78
|
+
*
|
|
79
|
+
* @returns The Partner API capabilities.
|
|
80
|
+
*
|
|
81
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
82
|
+
*/
|
|
83
|
+
getGroupsCapabilities() {
|
|
84
|
+
return this.requireAuth().apiInfo.groupsApi?.capabilities ?? null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.
|
|
88
|
+
*
|
|
89
|
+
* @returns The Computer Backup API capabilities, or null.
|
|
90
|
+
*
|
|
91
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
92
|
+
*/
|
|
93
|
+
getBackupCapabilities() {
|
|
94
|
+
return this.requireAuth().backupCapabilities ?? null;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Hides the Partner token from `JSON.stringify(accountInfo)`.
|
|
98
|
+
*
|
|
99
|
+
* @returns Redacted Partner auth state, or null when not authorized.
|
|
100
|
+
*/
|
|
101
|
+
toJSON() {
|
|
102
|
+
return { auth: this.#auth === null ? null : require_redaction.partnerAuthorizeResponseToRedactedJson(this.#auth) };
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Hides the Partner token from default stringification.
|
|
106
|
+
*
|
|
107
|
+
* @returns A short opaque label for this account info store.
|
|
108
|
+
*/
|
|
109
|
+
toString() {
|
|
110
|
+
return this.#auth === null ? "[InMemoryPartnerAccountInfo unauthorized]" : `[InMemoryPartnerAccountInfo ${require_redaction_placeholders.PARTNER_TOKEN_REDACTED}]`;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Hides the Partner token from Node's `util.inspect`.
|
|
114
|
+
*
|
|
115
|
+
* @returns A short opaque label for this account info store.
|
|
116
|
+
*/
|
|
117
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
118
|
+
return this.toString();
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Retrieve the cached auth response or throw if not yet authorized.
|
|
122
|
+
*
|
|
123
|
+
* @returns The cached authorization response.
|
|
124
|
+
*
|
|
125
|
+
* @throws B2PartnerAuthorizationError if authorizePartner() has not been called.
|
|
126
|
+
*/
|
|
127
|
+
requireAuth() {
|
|
128
|
+
if (!this.#auth) throw new require_errors_index.B2PartnerAuthorizationError("Not authorized. Call authorizePartner() first.");
|
|
129
|
+
return this.#auth;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
//#endregion
|
|
133
|
+
exports.InMemoryPartnerAccountInfo = InMemoryPartnerAccountInfo;
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=in-memory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.cjs","names":["#auth"],"sources":["../../src/partner/in-memory.ts"],"sourcesContent":["import { B2PartnerAuthorizationError } from '../errors/index.ts'\nimport type { AccountId, PartnerToken } from '../types/ids.ts'\nimport type { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.ts'\nimport type { PartnerAccountInfo } from './account-info.ts'\nimport { clonePartnerAuthorizeResponse } from './auth-clone.ts'\nimport {\n PARTNER_TOKEN_REDACTED,\n partnerAuthorizeResponseToRedactedJson,\n type RedactedPartnerAuthorizeResponseJson,\n redactPartnerAuthorizeResponse,\n} from './redaction.ts'\n\n/** Redacted JSON diagnostic shape emitted by {@link InMemoryPartnerAccountInfo.toJSON}. */\nexport interface InMemoryPartnerAccountInfoJson {\n /** Redacted cached authorization state, or null before authorization. */\n readonly auth: RedactedPartnerAuthorizeResponseJson | null\n}\n\nfunction clonePartnerAuth(auth: PartnerAuthorizeResponse): PartnerAuthorizeResponse {\n return redactPartnerAuthorizeResponse(clonePartnerAuthorizeResponse(auth))\n}\n\n/**\n * In-memory implementation of {@link PartnerAccountInfo}.\n * Suitable for short-lived processes or tests; state is lost when the process exits.\n */\nexport class InMemoryPartnerAccountInfo implements PartnerAccountInfo {\n /** Cached Partner authorization response, or null before authorizePartner() is called. */\n #auth: PartnerAuthorizeResponse | null = null\n\n /**\n * Store a fresh Partner authorization response, replacing any previous state.\n *\n * @param auth - The Partner authorize response to store.\n */\n setAuth(auth: PartnerAuthorizeResponse): void {\n this.#auth = clonePartnerAuth(auth)\n }\n\n /**\n * Return the current Partner authorization response, or null if not authorized.\n *\n * @returns The cached Partner authorization response, or null if not yet authorized.\n */\n getAuth(): PartnerAuthorizeResponse | null {\n return this.#auth\n }\n\n /** Discard all cached Partner authorization state. */\n clear(): void {\n this.#auth = null\n }\n\n /**\n * Current Partner/Backup authorization token.\n *\n * @returns The current Partner token.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getPartnerToken(): PartnerToken {\n return this.requireAuth().authorizationToken\n }\n\n /**\n * Base URL for Partner API calls.\n *\n * @returns The base URL for Partner API calls.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsApiUrl(): string | null {\n return this.requireAuth().apiInfo.groupsApi?.groupsApiUrl ?? null\n }\n\n /**\n * Base URL for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API URL, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupApiUrl(): string | null {\n return this.requireAuth().backupApiUrl ?? null\n }\n\n /**\n * The authorized partner administrator account ID.\n *\n * @returns The authorized account identifier.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getAccountId(): AccountId {\n return this.requireAuth().accountId\n }\n\n /**\n * Capabilities granted for Partner API calls.\n *\n * @returns The Partner API capabilities.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getGroupsCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().apiInfo.groupsApi?.capabilities ?? null\n }\n\n /**\n * Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.\n *\n * @returns The Computer Backup API capabilities, or null.\n *\n * @throws B2PartnerAuthorizationError if not yet authorized.\n */\n getBackupCapabilities(): readonly PartnerCapability[] | null {\n return this.requireAuth().backupCapabilities ?? null\n }\n\n /**\n * Hides the Partner token from `JSON.stringify(accountInfo)`.\n *\n * @returns Redacted Partner auth state, or null when not authorized.\n */\n toJSON(): InMemoryPartnerAccountInfoJson {\n return {\n auth: this.#auth === null ? null : partnerAuthorizeResponseToRedactedJson(this.#auth),\n }\n }\n\n /**\n * Hides the Partner token from default stringification.\n *\n * @returns A short opaque label for this account info store.\n */\n toString(): string {\n return this.#auth === null\n ? '[InMemoryPartnerAccountInfo unauthorized]'\n : `[InMemoryPartnerAccountInfo ${PARTNER_TOKEN_REDACTED}]`\n }\n\n /**\n * Hides the Partner token from Node's `util.inspect`.\n *\n * @returns A short opaque label for this account info store.\n */\n [Symbol.for('nodejs.util.inspect.custom')](): string {\n return this.toString()\n }\n\n /**\n * Retrieve the cached auth response or throw if not yet authorized.\n *\n * @returns The cached authorization response.\n *\n * @throws B2PartnerAuthorizationError if authorizePartner() has not been called.\n */\n private requireAuth(): PartnerAuthorizeResponse {\n if (!this.#auth) {\n throw new B2PartnerAuthorizationError('Not authorized. Call authorizePartner() first.')\n }\n return this.#auth\n }\n}\n"],"mappings":";;;;;AAkBA,SAAS,iBAAiB,MAA0D;CAClF,OAAO,kBAAA,+BAA+B,mBAAA,8BAA8B,IAAI,CAAC;AAC3E;;;;;AAMA,IAAa,6BAAb,MAAsE;;CAEpE,QAAyC;;;;;;CAOzC,QAAQ,MAAsC;EAC5C,KAAKA,QAAQ,iBAAiB,IAAI;CACpC;;;;;;CAOA,UAA2C;EACzC,OAAO,KAAKA;CACd;;CAGA,QAAc;EACZ,KAAKA,QAAQ;CACf;;;;;;;;CASA,kBAAgC;EAC9B,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,kBAAiC;EAC/B,OAAO,KAAK,YAAY,CAAC,CAAC,gBAAgB;CAC5C;;;;;;;;CASA,eAA0B;EACxB,OAAO,KAAK,YAAY,CAAC,CAAC;CAC5B;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,QAAQ,WAAW,gBAAgB;CAC/D;;;;;;;;CASA,wBAA6D;EAC3D,OAAO,KAAK,YAAY,CAAC,CAAC,sBAAsB;CAClD;;;;;;CAOA,SAAyC;EACvC,OAAO,EACL,MAAM,KAAKA,UAAU,OAAO,OAAO,kBAAA,uCAAuC,KAAKA,KAAK,EACtF;CACF;;;;;;CAOA,WAAmB;EACjB,OAAO,KAAKA,UAAU,OAClB,8CACA,+BAA+B,+BAAA,uBAAuB;CAC5D;;;;;;CAOA,CAAC,OAAO,IAAI,4BAA4B,KAAa;EACnD,OAAO,KAAK,SAAS;CACvB;;;;;;;;CASA,cAAgD;EAC9C,IAAI,CAAC,KAAKA,OACR,MAAM,IAAI,qBAAA,4BAA4B,gDAAgD;EAExF,OAAO,KAAKA;CACd;AACF"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AccountId, PartnerToken } from '../types/ids.js';
|
|
2
|
+
import { PartnerAuthorizeResponse, PartnerCapability } from '../types/partner.js';
|
|
3
|
+
import { PartnerAccountInfo } from './account-info.js';
|
|
4
|
+
import { RedactedPartnerAuthorizeResponseJson } from './redaction.js';
|
|
5
|
+
/** Redacted JSON diagnostic shape emitted by {@link InMemoryPartnerAccountInfo.toJSON}. */
|
|
6
|
+
export interface InMemoryPartnerAccountInfoJson {
|
|
7
|
+
/** Redacted cached authorization state, or null before authorization. */
|
|
8
|
+
readonly auth: RedactedPartnerAuthorizeResponseJson | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* In-memory implementation of {@link PartnerAccountInfo}.
|
|
12
|
+
* Suitable for short-lived processes or tests; state is lost when the process exits.
|
|
13
|
+
*/
|
|
14
|
+
export declare class InMemoryPartnerAccountInfo implements PartnerAccountInfo {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* Store a fresh Partner authorization response, replacing any previous state.
|
|
18
|
+
*
|
|
19
|
+
* @param auth - The Partner authorize response to store.
|
|
20
|
+
*/
|
|
21
|
+
setAuth(auth: PartnerAuthorizeResponse): void;
|
|
22
|
+
/**
|
|
23
|
+
* Return the current Partner authorization response, or null if not authorized.
|
|
24
|
+
*
|
|
25
|
+
* @returns The cached Partner authorization response, or null if not yet authorized.
|
|
26
|
+
*/
|
|
27
|
+
getAuth(): PartnerAuthorizeResponse | null;
|
|
28
|
+
/** Discard all cached Partner authorization state. */
|
|
29
|
+
clear(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Current Partner/Backup authorization token.
|
|
32
|
+
*
|
|
33
|
+
* @returns The current Partner token.
|
|
34
|
+
*
|
|
35
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
36
|
+
*/
|
|
37
|
+
getPartnerToken(): PartnerToken;
|
|
38
|
+
/**
|
|
39
|
+
* Base URL for Partner API calls.
|
|
40
|
+
*
|
|
41
|
+
* @returns The base URL for Partner API calls.
|
|
42
|
+
*
|
|
43
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
44
|
+
*/
|
|
45
|
+
getGroupsApiUrl(): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Base URL for Computer Backup API calls, or null when the suite is unavailable.
|
|
48
|
+
*
|
|
49
|
+
* @returns The Computer Backup API URL, or null.
|
|
50
|
+
*
|
|
51
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
52
|
+
*/
|
|
53
|
+
getBackupApiUrl(): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* The authorized partner administrator account ID.
|
|
56
|
+
*
|
|
57
|
+
* @returns The authorized account identifier.
|
|
58
|
+
*
|
|
59
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
60
|
+
*/
|
|
61
|
+
getAccountId(): AccountId;
|
|
62
|
+
/**
|
|
63
|
+
* Capabilities granted for Partner API calls.
|
|
64
|
+
*
|
|
65
|
+
* @returns The Partner API capabilities.
|
|
66
|
+
*
|
|
67
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
68
|
+
*/
|
|
69
|
+
getGroupsCapabilities(): readonly PartnerCapability[] | null;
|
|
70
|
+
/**
|
|
71
|
+
* Capabilities granted for Computer Backup API calls, or null when the suite is unavailable.
|
|
72
|
+
*
|
|
73
|
+
* @returns The Computer Backup API capabilities, or null.
|
|
74
|
+
*
|
|
75
|
+
* @throws B2PartnerAuthorizationError if not yet authorized.
|
|
76
|
+
*/
|
|
77
|
+
getBackupCapabilities(): readonly PartnerCapability[] | null;
|
|
78
|
+
/**
|
|
79
|
+
* Hides the Partner token from `JSON.stringify(accountInfo)`.
|
|
80
|
+
*
|
|
81
|
+
* @returns Redacted Partner auth state, or null when not authorized.
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): InMemoryPartnerAccountInfoJson;
|
|
84
|
+
/**
|
|
85
|
+
* Hides the Partner token from default stringification.
|
|
86
|
+
*
|
|
87
|
+
* @returns A short opaque label for this account info store.
|
|
88
|
+
*/
|
|
89
|
+
toString(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve the cached auth response or throw if not yet authorized.
|
|
92
|
+
*
|
|
93
|
+
* @returns The cached authorization response.
|
|
94
|
+
*
|
|
95
|
+
* @throws B2PartnerAuthorizationError if authorizePartner() has not been called.
|
|
96
|
+
*/
|
|
97
|
+
private requireAuth;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=in-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/partner/in-memory.js"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAGL,KAAK,oCAAoC,EAE1C,MAAM,gBAAgB,CAAA;AAEvB,2FAA2F;AAC3F,MAAM,WAAW,8BAA8B;IAC7C,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,oCAAoC,GAAG,IAAI,CAAA;CAC3D;AAMD;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,kBAAkB;;IAInE;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI;IAI7C;;;;OAIG;IACH,OAAO,IAAI,wBAAwB,GAAG,IAAI;IAI1C,sDAAsD;IACtD,KAAK,IAAI,IAAI;IAIb;;;;;;OAMG;IACH,eAAe,IAAI,YAAY;IAI/B;;;;;;OAMG;IACH,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC;;;;;;OAMG;IACH,eAAe,IAAI,MAAM,GAAG,IAAI;IAIhC;;;;;;OAMG;IACH,YAAY,IAAI,SAAS;IAIzB;;;;;;OAMG;IACH,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI;IAI5D;;;;;;OAMG;IACH,qBAAqB,IAAI,SAAS,iBAAiB,EAAE,GAAG,IAAI;IAI5D;;;;OAIG;IACH,MAAM,IAAI,8BAA8B;IAMxC;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAelB;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;CAMpB"}
|