@backblaze-labs/b2-sdk 0.1.0 → 0.2.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 +110 -5
- package/README.md +144 -33
- 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/bucket.cjs +785 -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 +780 -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 +114 -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 +112 -69
- package/dist/copy/large.js.map +1 -1
- package/dist/download/checksum.cjs +89 -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 +87 -0
- package/dist/download/checksum.js.map +1 -0
- package/dist/download/parallel.cjs +214 -118
- package/dist/download/parallel.cjs.map +1 -1
- package/dist/download/parallel.d.cts +5 -1
- package/dist/download/parallel.d.cts.map +1 -1
- package/dist/download/parallel.d.ts +5 -1
- package/dist/download/parallel.d.ts.map +1 -1
- package/dist/download/parallel.js +212 -116
- package/dist/download/parallel.js.map +1 -1
- package/dist/download/single.cjs +188 -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 +186 -98
- package/dist/download/single.js.map +1 -1
- package/dist/errors/index.cjs +699 -243
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.d.cts +285 -82
- package/dist/errors/index.d.cts.map +1 -1
- package/dist/errors/index.d.ts +285 -82
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +678 -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 +438 -140
- package/dist/http/transport.cjs.map +1 -1
- package/dist/http/transport.d.cts +21 -2
- package/dist/http/transport.d.cts.map +1 -1
- package/dist/http/transport.d.ts +21 -2
- package/dist/http/transport.d.ts.map +1 -1
- package/dist/http/transport.js +437 -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 +101 -77
- package/dist/index.d.cts +27 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +27 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -71
- 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 +9 -55
- package/dist/object.d.cts.map +1 -1
- package/dist/object.d.ts +9 -55
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +249 -206
- package/dist/object.js.map +1 -1
- 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 +678 -587
- package/dist/raw/index.cjs.map +1 -1
- package/dist/raw/index.d.cts +121 -18
- package/dist/raw/index.d.cts.map +1 -1
- package/dist/raw/index.d.ts +121 -18
- package/dist/raw/index.d.ts.map +1 -1
- package/dist/raw/index.js +674 -589
- package/dist/raw/index.js.map +1 -1
- 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 +149 -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 +148 -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 +2124 -1548
- package/dist/simulator/index.cjs.map +1 -1
- package/dist/simulator/index.d.cts +79 -11
- package/dist/simulator/index.d.cts.map +1 -1
- package/dist/simulator/index.d.ts +79 -11
- package/dist/simulator/index.d.ts.map +1 -1
- package/dist/simulator/index.js +2112 -1546
- package/dist/simulator/index.js.map +1 -1
- package/dist/simulator/validation.cjs +191 -153
- package/dist/simulator/validation.cjs.map +1 -1
- package/dist/simulator/validation.d.cts +3 -21
- package/dist/simulator/validation.d.cts.map +1 -1
- package/dist/simulator/validation.d.ts +3 -21
- package/dist/simulator/validation.d.ts.map +1 -1
- package/dist/simulator/validation.js +188 -162
- 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 +2 -10
- 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 +316 -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 +312 -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 +148 -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 +145 -0
- package/dist/sync/b2-sha1-reader.js.map +1 -0
- package/dist/sync/download-staging.cjs +265 -0
- package/dist/sync/download-staging.cjs.map +1 -0
- package/dist/sync/download-staging.d.cts +54 -0
- package/dist/sync/download-staging.d.cts.map +1 -0
- package/dist/sync/download-staging.d.ts +54 -0
- package/dist/sync/download-staging.d.ts.map +1 -0
- package/dist/sync/download-staging.js +259 -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 +364 -0
- package/dist/sync/local-file-io.cjs.map +1 -0
- package/dist/sync/local-file-io.d.cts +75 -0
- package/dist/sync/local-file-io.d.cts.map +1 -0
- package/dist/sync/local-file-io.d.ts +75 -0
- package/dist/sync/local-file-io.d.ts.map +1 -0
- package/dist/sync/local-file-io.js +360 -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 +119 -0
- package/dist/sync/local-sha1.cjs.map +1 -0
- package/dist/sync/local-sha1.d.cts +39 -0
- package/dist/sync/local-sha1.d.cts.map +1 -0
- package/dist/sync/local-sha1.d.ts +39 -0
- package/dist/sync/local-sha1.d.ts.map +1 -0
- package/dist/sync/local-sha1.js +117 -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 +389 -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 +387 -13
- package/dist/sync/policies/compare.js.map +1 -1
- package/dist/sync/policies/index.cjs +76 -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 +76 -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 +782 -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 +779 -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 +76 -56
- package/dist/types/auth.cjs.map +1 -1
- package/dist/types/auth.d.cts +67 -9
- package/dist/types/auth.d.cts.map +1 -1
- package/dist/types/auth.d.ts +67 -9
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/auth.js +77 -57
- package/dist/types/auth.js.map +1 -1
- package/dist/types/bucket.cjs +74 -38
- package/dist/types/bucket.cjs.map +1 -1
- package/dist/types/bucket.js +75 -41
- package/dist/types/bucket.js.map +1 -1
- package/dist/types/encryption.cjs +364 -327
- package/dist/types/encryption.cjs.map +1 -1
- package/dist/types/encryption.d.cts +16 -0
- package/dist/types/encryption.d.cts.map +1 -1
- package/dist/types/encryption.d.ts +16 -0
- package/dist/types/encryption.d.ts.map +1 -1
- package/dist/types/encryption.js +364 -310
- package/dist/types/encryption.js.map +1 -1
- package/dist/types/errors.cjs +47 -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 +47 -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 +2 -2
- package/dist/types/file.d.cts.map +1 -1
- package/dist/types/file.d.ts +2 -2
- 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 +53 -9
- package/dist/types/ids.cjs.map +1 -1
- package/dist/types/ids.js +54 -15
- package/dist/types/ids.js.map +1 -1
- package/dist/types/index.d.cts +12 -11
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +12 -11
- 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.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.js +45 -23
- package/dist/types/notifications.js.map +1 -1
- package/dist/types/upload.d.cts +39 -5
- package/dist/types/upload.d.cts.map +1 -1
- package/dist/types/upload.d.ts +39 -5
- package/dist/types/upload.d.ts.map +1 -1
- package/dist/upload/abort-scope.cjs +91 -0
- package/dist/upload/abort-scope.cjs.map +1 -0
- package/dist/upload/abort-scope.d.cts +48 -0
- package/dist/upload/abort-scope.d.cts.map +1 -0
- package/dist/upload/abort-scope.d.ts +48 -0
- package/dist/upload/abort-scope.d.ts.map +1 -0
- package/dist/upload/abort-scope.js +88 -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 +59 -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 +59 -0
- package/dist/upload/finish.js.map +1 -0
- package/dist/upload/large.cjs +301 -218
- package/dist/upload/large.cjs.map +1 -1
- package/dist/upload/large.d.cts +76 -9
- package/dist/upload/large.d.cts.map +1 -1
- package/dist/upload/large.d.ts +76 -9
- package/dist/upload/large.d.ts.map +1 -1
- package/dist/upload/large.js +301 -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 +104 -0
- package/dist/upload/options.d.cts.map +1 -0
- package/dist/upload/options.d.ts +104 -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 +333 -33
- package/dist/upload/resume.cjs.map +1 -1
- package/dist/upload/resume.d.cts +82 -12
- package/dist/upload/resume.d.cts.map +1 -1
- package/dist/upload/resume.d.ts +82 -12
- package/dist/upload/resume.d.ts.map +1 -1
- package/dist/upload/resume.js +330 -33
- package/dist/upload/resume.js.map +1 -1
- package/dist/upload/retry.cjs +186 -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 +182 -0
- package/dist/upload/retry.js.map +1 -0
- package/dist/upload/single.cjs +68 -44
- package/dist/upload/single.cjs.map +1 -1
- package/dist/upload/single.d.cts +2 -1
- package/dist/upload/single.d.cts.map +1 -1
- package/dist/upload/single.d.ts +2 -1
- package/dist/upload/single.d.ts.map +1 -1
- package/dist/upload/single.js +68 -44
- package/dist/upload/single.js.map +1 -1
- package/dist/upload/stream.cjs +317 -193
- package/dist/upload/stream.cjs.map +1 -1
- package/dist/upload/stream.d.cts +3 -1
- package/dist/upload/stream.d.cts.map +1 -1
- package/dist/upload/stream.d.ts +3 -1
- package/dist/upload/stream.d.ts.map +1 -1
- package/dist/upload/stream.js +316 -192
- package/dist/upload/stream.js.map +1 -1
- 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 +25 -9
- package/dist/util/defaults.cjs.map +1 -1
- package/dist/util/defaults.js +26 -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/normalize.cjs +66 -7
- package/dist/util/normalize.cjs.map +1 -1
- package/dist/util/normalize.js +67 -10
- package/dist/util/normalize.js.map +1 -1
- package/dist/util/paginator.cjs +63 -14
- package/dist/util/paginator.cjs.map +1 -1
- package/dist/util/paginator.js +64 -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 +19 -16
- 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,96 @@
|
|
|
1
|
+
const require_download_staging = require("./download-staging.cjs");
|
|
2
|
+
//#region src/sync/prefix.ts
|
|
3
|
+
/**
|
|
4
|
+
* Treats the supplied string as a raw B2 key prefix without adding a folder boundary.
|
|
5
|
+
*
|
|
6
|
+
* B2 keys are byte-oriented names, not local filesystem paths. A backslash in a prefix is a real
|
|
7
|
+
* key character and must not be rewritten to `/`; callers that want slash-delimited prefixes should
|
|
8
|
+
* pass `/` explicitly.
|
|
9
|
+
*
|
|
10
|
+
* @param prefix - User-supplied raw B2 key prefix.
|
|
11
|
+
*
|
|
12
|
+
* @returns Raw B2 key prefix.
|
|
13
|
+
*/
|
|
14
|
+
function asRawB2KeyPrefix(prefix) {
|
|
15
|
+
return prefix;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes a B2 object name into a safe folder-relative sync path.
|
|
19
|
+
*
|
|
20
|
+
* Object names are converted to forward-slash sync paths for local compatibility. Callers that scan
|
|
21
|
+
* B2 must detect normalized-path collisions between distinct raw B2 keys before yielding entries.
|
|
22
|
+
*
|
|
23
|
+
* @param path - B2 object name or prefix-stripped suffix returned by a listing.
|
|
24
|
+
* @param options - Optional normalization behavior for legacy slashless raw prefixes.
|
|
25
|
+
*
|
|
26
|
+
* @returns Folder-relative sync path.
|
|
27
|
+
*
|
|
28
|
+
* @throws When the object name cannot be represented as a safe relative path.
|
|
29
|
+
*/
|
|
30
|
+
function normalizeB2RelativePath(path, options = {}) {
|
|
31
|
+
const slashPath = path.split("\\").join("/");
|
|
32
|
+
const relativePath = options.stripLeadingSlashes === true ? stripSingleLeadingSlash(slashPath) : slashPath;
|
|
33
|
+
const segments = relativePath.split("/");
|
|
34
|
+
if (/^[A-Za-z]:/.test(relativePath) || segments.some((segment) => segmentIsUnsafe(segment))) throw new Error("Unsafe B2 file name cannot be used as a sync relative path");
|
|
35
|
+
return relativePath;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts a B2 object key under a configured raw prefix into a sync relative path.
|
|
39
|
+
*
|
|
40
|
+
* @param prefix - Raw B2 key prefix used for the scan or mutation guard.
|
|
41
|
+
* @param fileName - Full B2 object key.
|
|
42
|
+
*
|
|
43
|
+
* @returns The normalized sync relative path for the key suffix.
|
|
44
|
+
*/
|
|
45
|
+
function b2KeyToRelativePathUnderPrefix(prefix, fileName) {
|
|
46
|
+
const rawPrefix = asRawB2KeyPrefix(prefix);
|
|
47
|
+
return normalizeB2RelativePath(rawPrefix === "" ? fileName : fileName.slice(rawPrefix.length), { stripLeadingSlashes: rawPrefix !== "" && !rawPrefix.endsWith("/") });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether a sync path is unsafe to materialize on Windows-compatible local filesystems.
|
|
51
|
+
* B2-to-B2 syncs can preserve these object names, but B2-to-local syncs skip them before writing.
|
|
52
|
+
*
|
|
53
|
+
* @param relativePath - Folder-relative sync path.
|
|
54
|
+
*
|
|
55
|
+
* @returns True when any segment is Windows-dangerous or ambiguous.
|
|
56
|
+
*/
|
|
57
|
+
function localFilesystemSyncPathIsUnsafe(relativePath) {
|
|
58
|
+
const segments = relativePath.split("/");
|
|
59
|
+
return require_download_staging.isDownloadStagingDirectorySegment(segments[0]) || segments.some((segment) => segmentIsLocalFilesystemUnsafe(segment));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Produces an approximate Windows/macOS-style canonical key for local collision detection.
|
|
63
|
+
*
|
|
64
|
+
* @param relativePath - Folder-relative sync path.
|
|
65
|
+
*
|
|
66
|
+
* @returns A canonicalized path key for detecting case/Unicode collisions before local writes.
|
|
67
|
+
*/
|
|
68
|
+
function localFilesystemCanonicalSyncPath(relativePath) {
|
|
69
|
+
return relativePath.split("/").map((segment) => segment.normalize("NFC").toLocaleLowerCase("en-US")).join("/");
|
|
70
|
+
}
|
|
71
|
+
function segmentIsUnsafe(segment) {
|
|
72
|
+
return segment === "" || segment === "." || segment === ".." || containsControlCharacter(segment);
|
|
73
|
+
}
|
|
74
|
+
function segmentIsLocalFilesystemUnsafe(segment) {
|
|
75
|
+
if (segment.includes(":") || segment.endsWith(".") || segment.endsWith(" ")) return true;
|
|
76
|
+
const basename = segment.split(".")[0]?.toUpperCase();
|
|
77
|
+
return basename !== void 0 && /^(CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[0-9¹²³]|LPT[0-9¹²³])$/u.test(basename);
|
|
78
|
+
}
|
|
79
|
+
function containsControlCharacter(segment) {
|
|
80
|
+
for (let index = 0; index < segment.length; index++) {
|
|
81
|
+
const code = segment.charCodeAt(index);
|
|
82
|
+
if (code >= 0 && code <= 31) return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function stripSingleLeadingSlash(path) {
|
|
87
|
+
return path.startsWith("/") ? path.slice(1) : path;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
exports.asRawB2KeyPrefix = asRawB2KeyPrefix;
|
|
91
|
+
exports.b2KeyToRelativePathUnderPrefix = b2KeyToRelativePathUnderPrefix;
|
|
92
|
+
exports.localFilesystemCanonicalSyncPath = localFilesystemCanonicalSyncPath;
|
|
93
|
+
exports.localFilesystemSyncPathIsUnsafe = localFilesystemSyncPathIsUnsafe;
|
|
94
|
+
exports.normalizeB2RelativePath = normalizeB2RelativePath;
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=prefix.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.cjs","names":[],"sources":["../../src/sync/prefix.ts"],"sourcesContent":["import { isDownloadStagingDirectorySegment } from './download-staging.ts'\n\n/**\n * Treats the supplied string as a raw B2 key prefix without adding a folder boundary.\n *\n * B2 keys are byte-oriented names, not local filesystem paths. A backslash in a prefix is a real\n * key character and must not be rewritten to `/`; callers that want slash-delimited prefixes should\n * pass `/` explicitly.\n *\n * @param prefix - User-supplied raw B2 key prefix.\n *\n * @returns Raw B2 key prefix.\n */\nexport function asRawB2KeyPrefix(prefix: string): string {\n return prefix\n}\n\n/**\n * Normalizes a B2 object name into a safe folder-relative sync path.\n *\n * Object names are converted to forward-slash sync paths for local compatibility. Callers that scan\n * B2 must detect normalized-path collisions between distinct raw B2 keys before yielding entries.\n *\n * @param path - B2 object name or prefix-stripped suffix returned by a listing.\n * @param options - Optional normalization behavior for legacy slashless raw prefixes.\n *\n * @returns Folder-relative sync path.\n *\n * @throws When the object name cannot be represented as a safe relative path.\n */\nexport function normalizeB2RelativePath(\n path: string,\n options: { readonly stripLeadingSlashes?: boolean } = {},\n): string {\n const slashPath = path.split('\\\\').join('/')\n const relativePath =\n options.stripLeadingSlashes === true ? stripSingleLeadingSlash(slashPath) : slashPath\n const segments = relativePath.split('/')\n if (/^[A-Za-z]:/.test(relativePath) || segments.some((segment) => segmentIsUnsafe(segment))) {\n throw new Error('Unsafe B2 file name cannot be used as a sync relative path')\n }\n return relativePath\n}\n\n/**\n * Converts a B2 object key under a configured raw prefix into a sync relative path.\n *\n * @param prefix - Raw B2 key prefix used for the scan or mutation guard.\n * @param fileName - Full B2 object key.\n *\n * @returns The normalized sync relative path for the key suffix.\n */\nexport function b2KeyToRelativePathUnderPrefix(prefix: string, fileName: string): string {\n const rawPrefix = asRawB2KeyPrefix(prefix)\n const suffix = rawPrefix === '' ? fileName : fileName.slice(rawPrefix.length)\n return normalizeB2RelativePath(suffix, {\n stripLeadingSlashes: rawPrefix !== '' && !rawPrefix.endsWith('/'),\n })\n}\n\n/**\n * Returns whether a sync path is unsafe to materialize on Windows-compatible local filesystems.\n * B2-to-B2 syncs can preserve these object names, but B2-to-local syncs skip them before writing.\n *\n * @param relativePath - Folder-relative sync path.\n *\n * @returns True when any segment is Windows-dangerous or ambiguous.\n */\nexport function localFilesystemSyncPathIsUnsafe(relativePath: string): boolean {\n const segments = relativePath.split('/')\n return (\n isDownloadStagingDirectorySegment(segments[0]) ||\n segments.some((segment) => segmentIsLocalFilesystemUnsafe(segment))\n )\n}\n\n/**\n * Produces an approximate Windows/macOS-style canonical key for local collision detection.\n *\n * @param relativePath - Folder-relative sync path.\n *\n * @returns A canonicalized path key for detecting case/Unicode collisions before local writes.\n */\nexport function localFilesystemCanonicalSyncPath(relativePath: string): string {\n return relativePath\n .split('/')\n .map((segment) => segment.normalize('NFC').toLocaleLowerCase('en-US'))\n .join('/')\n}\n\nfunction segmentIsUnsafe(segment: string): boolean {\n return segment === '' || segment === '.' || segment === '..' || containsControlCharacter(segment)\n}\n\nfunction segmentIsLocalFilesystemUnsafe(segment: string): boolean {\n if (segment.includes(':') || segment.endsWith('.') || segment.endsWith(' ')) return true\n const basename = segment.split('.')[0]?.toUpperCase()\n return (\n basename !== undefined &&\n /^(CON|PRN|AUX|NUL|CONIN\\$|CONOUT\\$|COM[0-9¹²³]|LPT[0-9¹²³])$/u.test(basename)\n )\n}\n\nfunction containsControlCharacter(segment: string): boolean {\n for (let index = 0; index < segment.length; index++) {\n const code = segment.charCodeAt(index)\n if (code >= 0 && code <= 31) return true\n }\n return false\n}\n\nfunction stripSingleLeadingSlash(path: string): string {\n return path.startsWith('/') ? path.slice(1) : path\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,iBAAiB,QAAwB;CACvD,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,MACA,UAAsD,CAAC,GAC/C;CACR,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;CAC3C,MAAM,eACJ,QAAQ,wBAAwB,OAAO,wBAAwB,SAAS,IAAI;CAC9E,MAAM,WAAW,aAAa,MAAM,GAAG;CACvC,IAAI,aAAa,KAAK,YAAY,KAAK,SAAS,MAAM,YAAY,gBAAgB,OAAO,CAAC,GACxF,MAAM,IAAI,MAAM,4DAA4D;CAE9E,OAAO;AACT;;;;;;;;;AAUA,SAAgB,+BAA+B,QAAgB,UAA0B;CACvF,MAAM,YAAY,iBAAiB,MAAM;CAEzC,OAAO,wBADQ,cAAc,KAAK,WAAW,SAAS,MAAM,UAAU,MAAM,GACrC,EACrC,qBAAqB,cAAc,MAAM,CAAC,UAAU,SAAS,GAAG,EAClE,CAAC;AACH;;;;;;;;;AAUA,SAAgB,gCAAgC,cAA+B;CAC7E,MAAM,WAAW,aAAa,MAAM,GAAG;CACvC,OACE,yBAAA,kCAAkC,SAAS,EAAE,KAC7C,SAAS,MAAM,YAAY,+BAA+B,OAAO,CAAC;AAEtE;;;;;;;;AASA,SAAgB,iCAAiC,cAA8B;CAC7E,OAAO,aACJ,MAAM,GAAG,CAAC,CACV,KAAK,YAAY,QAAQ,UAAU,KAAK,CAAC,CAAC,kBAAkB,OAAO,CAAC,CAAC,CACrE,KAAK,GAAG;AACb;AAEA,SAAS,gBAAgB,SAA0B;CACjD,OAAO,YAAY,MAAM,YAAY,OAAO,YAAY,QAAQ,yBAAyB,OAAO;AAClG;AAEA,SAAS,+BAA+B,SAA0B;CAChE,IAAI,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,GAAG,GAAG,OAAO;CACpF,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,YAAY;CACpD,OACE,aAAa,KAAA,KACb,gEAAgE,KAAK,QAAQ;AAEjF;AAEA,SAAS,yBAAyB,SAA0B;CAC1D,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS;EACnD,MAAM,OAAO,QAAQ,WAAW,KAAK;EACrC,IAAI,QAAQ,KAAK,QAAQ,IAAI,OAAO;CACtC;CACA,OAAO;AACT;AAEA,SAAS,wBAAwB,MAAsB;CACrD,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,CAAC,IAAI;AAChD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Treats the supplied string as a raw B2 key prefix without adding a folder boundary.
|
|
3
|
+
*
|
|
4
|
+
* B2 keys are byte-oriented names, not local filesystem paths. A backslash in a prefix is a real
|
|
5
|
+
* key character and must not be rewritten to `/`; callers that want slash-delimited prefixes should
|
|
6
|
+
* pass `/` explicitly.
|
|
7
|
+
*
|
|
8
|
+
* @param prefix - User-supplied raw B2 key prefix.
|
|
9
|
+
*
|
|
10
|
+
* @returns Raw B2 key prefix.
|
|
11
|
+
*/
|
|
12
|
+
export declare function asRawB2KeyPrefix(prefix: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes a B2 object name into a safe folder-relative sync path.
|
|
15
|
+
*
|
|
16
|
+
* Object names are converted to forward-slash sync paths for local compatibility. Callers that scan
|
|
17
|
+
* B2 must detect normalized-path collisions between distinct raw B2 keys before yielding entries.
|
|
18
|
+
*
|
|
19
|
+
* @param path - B2 object name or prefix-stripped suffix returned by a listing.
|
|
20
|
+
* @param options - Optional normalization behavior for legacy slashless raw prefixes.
|
|
21
|
+
*
|
|
22
|
+
* @returns Folder-relative sync path.
|
|
23
|
+
*
|
|
24
|
+
* @throws When the object name cannot be represented as a safe relative path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizeB2RelativePath(path: string, options?: {
|
|
27
|
+
readonly stripLeadingSlashes?: boolean;
|
|
28
|
+
}): string;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a B2 object key under a configured raw prefix into a sync relative path.
|
|
31
|
+
*
|
|
32
|
+
* @param prefix - Raw B2 key prefix used for the scan or mutation guard.
|
|
33
|
+
* @param fileName - Full B2 object key.
|
|
34
|
+
*
|
|
35
|
+
* @returns The normalized sync relative path for the key suffix.
|
|
36
|
+
*/
|
|
37
|
+
export declare function b2KeyToRelativePathUnderPrefix(prefix: string, fileName: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Returns whether a sync path is unsafe to materialize on Windows-compatible local filesystems.
|
|
40
|
+
* B2-to-B2 syncs can preserve these object names, but B2-to-local syncs skip them before writing.
|
|
41
|
+
*
|
|
42
|
+
* @param relativePath - Folder-relative sync path.
|
|
43
|
+
*
|
|
44
|
+
* @returns True when any segment is Windows-dangerous or ambiguous.
|
|
45
|
+
*/
|
|
46
|
+
export declare function localFilesystemSyncPathIsUnsafe(relativePath: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Produces an approximate Windows/macOS-style canonical key for local collision detection.
|
|
49
|
+
*
|
|
50
|
+
* @param relativePath - Folder-relative sync path.
|
|
51
|
+
*
|
|
52
|
+
* @returns A canonicalized path key for detecting case/Unicode collisions before local writes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function localFilesystemCanonicalSyncPath(relativePath: string): string;
|
|
55
|
+
//# sourceMappingURL=prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../../src/sync/prefix.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAO,GACvD,MAAM,CASR;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMvF;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAM7E;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAK7E"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Treats the supplied string as a raw B2 key prefix without adding a folder boundary.
|
|
3
|
+
*
|
|
4
|
+
* B2 keys are byte-oriented names, not local filesystem paths. A backslash in a prefix is a real
|
|
5
|
+
* key character and must not be rewritten to `/`; callers that want slash-delimited prefixes should
|
|
6
|
+
* pass `/` explicitly.
|
|
7
|
+
*
|
|
8
|
+
* @param prefix - User-supplied raw B2 key prefix.
|
|
9
|
+
*
|
|
10
|
+
* @returns Raw B2 key prefix.
|
|
11
|
+
*/
|
|
12
|
+
export declare function asRawB2KeyPrefix(prefix: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes a B2 object name into a safe folder-relative sync path.
|
|
15
|
+
*
|
|
16
|
+
* Object names are converted to forward-slash sync paths for local compatibility. Callers that scan
|
|
17
|
+
* B2 must detect normalized-path collisions between distinct raw B2 keys before yielding entries.
|
|
18
|
+
*
|
|
19
|
+
* @param path - B2 object name or prefix-stripped suffix returned by a listing.
|
|
20
|
+
* @param options - Optional normalization behavior for legacy slashless raw prefixes.
|
|
21
|
+
*
|
|
22
|
+
* @returns Folder-relative sync path.
|
|
23
|
+
*
|
|
24
|
+
* @throws When the object name cannot be represented as a safe relative path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function normalizeB2RelativePath(path: string, options?: {
|
|
27
|
+
readonly stripLeadingSlashes?: boolean;
|
|
28
|
+
}): string;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a B2 object key under a configured raw prefix into a sync relative path.
|
|
31
|
+
*
|
|
32
|
+
* @param prefix - Raw B2 key prefix used for the scan or mutation guard.
|
|
33
|
+
* @param fileName - Full B2 object key.
|
|
34
|
+
*
|
|
35
|
+
* @returns The normalized sync relative path for the key suffix.
|
|
36
|
+
*/
|
|
37
|
+
export declare function b2KeyToRelativePathUnderPrefix(prefix: string, fileName: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Returns whether a sync path is unsafe to materialize on Windows-compatible local filesystems.
|
|
40
|
+
* B2-to-B2 syncs can preserve these object names, but B2-to-local syncs skip them before writing.
|
|
41
|
+
*
|
|
42
|
+
* @param relativePath - Folder-relative sync path.
|
|
43
|
+
*
|
|
44
|
+
* @returns True when any segment is Windows-dangerous or ambiguous.
|
|
45
|
+
*/
|
|
46
|
+
export declare function localFilesystemSyncPathIsUnsafe(relativePath: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Produces an approximate Windows/macOS-style canonical key for local collision detection.
|
|
49
|
+
*
|
|
50
|
+
* @param relativePath - Folder-relative sync path.
|
|
51
|
+
*
|
|
52
|
+
* @returns A canonicalized path key for detecting case/Unicode collisions before local writes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function localFilesystemCanonicalSyncPath(relativePath: string): string;
|
|
55
|
+
//# sourceMappingURL=prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../../src/sync/prefix.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAO,GACvD,MAAM,CASR;AAED;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMvF;AAED;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAM7E;AAED;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAK7E"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { isDownloadStagingDirectorySegment } from "./download-staging.js";
|
|
2
|
+
//#region src/sync/prefix.ts
|
|
3
|
+
/**
|
|
4
|
+
* Treats the supplied string as a raw B2 key prefix without adding a folder boundary.
|
|
5
|
+
*
|
|
6
|
+
* B2 keys are byte-oriented names, not local filesystem paths. A backslash in a prefix is a real
|
|
7
|
+
* key character and must not be rewritten to `/`; callers that want slash-delimited prefixes should
|
|
8
|
+
* pass `/` explicitly.
|
|
9
|
+
*
|
|
10
|
+
* @param prefix - User-supplied raw B2 key prefix.
|
|
11
|
+
*
|
|
12
|
+
* @returns Raw B2 key prefix.
|
|
13
|
+
*/
|
|
14
|
+
function asRawB2KeyPrefix(prefix) {
|
|
15
|
+
return prefix;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes a B2 object name into a safe folder-relative sync path.
|
|
19
|
+
*
|
|
20
|
+
* Object names are converted to forward-slash sync paths for local compatibility. Callers that scan
|
|
21
|
+
* B2 must detect normalized-path collisions between distinct raw B2 keys before yielding entries.
|
|
22
|
+
*
|
|
23
|
+
* @param path - B2 object name or prefix-stripped suffix returned by a listing.
|
|
24
|
+
* @param options - Optional normalization behavior for legacy slashless raw prefixes.
|
|
25
|
+
*
|
|
26
|
+
* @returns Folder-relative sync path.
|
|
27
|
+
*
|
|
28
|
+
* @throws When the object name cannot be represented as a safe relative path.
|
|
29
|
+
*/
|
|
30
|
+
function normalizeB2RelativePath(path, options = {}) {
|
|
31
|
+
const slashPath = path.split("\\").join("/");
|
|
32
|
+
const relativePath = options.stripLeadingSlashes === true ? stripSingleLeadingSlash(slashPath) : slashPath;
|
|
33
|
+
const segments = relativePath.split("/");
|
|
34
|
+
if (/^[A-Za-z]:/.test(relativePath) || segments.some((segment) => segmentIsUnsafe(segment))) throw new Error("Unsafe B2 file name cannot be used as a sync relative path");
|
|
35
|
+
return relativePath;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Converts a B2 object key under a configured raw prefix into a sync relative path.
|
|
39
|
+
*
|
|
40
|
+
* @param prefix - Raw B2 key prefix used for the scan or mutation guard.
|
|
41
|
+
* @param fileName - Full B2 object key.
|
|
42
|
+
*
|
|
43
|
+
* @returns The normalized sync relative path for the key suffix.
|
|
44
|
+
*/
|
|
45
|
+
function b2KeyToRelativePathUnderPrefix(prefix, fileName) {
|
|
46
|
+
const rawPrefix = asRawB2KeyPrefix(prefix);
|
|
47
|
+
return normalizeB2RelativePath(rawPrefix === "" ? fileName : fileName.slice(rawPrefix.length), { stripLeadingSlashes: rawPrefix !== "" && !rawPrefix.endsWith("/") });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns whether a sync path is unsafe to materialize on Windows-compatible local filesystems.
|
|
51
|
+
* B2-to-B2 syncs can preserve these object names, but B2-to-local syncs skip them before writing.
|
|
52
|
+
*
|
|
53
|
+
* @param relativePath - Folder-relative sync path.
|
|
54
|
+
*
|
|
55
|
+
* @returns True when any segment is Windows-dangerous or ambiguous.
|
|
56
|
+
*/
|
|
57
|
+
function localFilesystemSyncPathIsUnsafe(relativePath) {
|
|
58
|
+
const segments = relativePath.split("/");
|
|
59
|
+
return isDownloadStagingDirectorySegment(segments[0]) || segments.some((segment) => segmentIsLocalFilesystemUnsafe(segment));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Produces an approximate Windows/macOS-style canonical key for local collision detection.
|
|
63
|
+
*
|
|
64
|
+
* @param relativePath - Folder-relative sync path.
|
|
65
|
+
*
|
|
66
|
+
* @returns A canonicalized path key for detecting case/Unicode collisions before local writes.
|
|
67
|
+
*/
|
|
68
|
+
function localFilesystemCanonicalSyncPath(relativePath) {
|
|
69
|
+
return relativePath.split("/").map((segment) => segment.normalize("NFC").toLocaleLowerCase("en-US")).join("/");
|
|
70
|
+
}
|
|
71
|
+
function segmentIsUnsafe(segment) {
|
|
72
|
+
return segment === "" || segment === "." || segment === ".." || containsControlCharacter(segment);
|
|
73
|
+
}
|
|
74
|
+
function segmentIsLocalFilesystemUnsafe(segment) {
|
|
75
|
+
if (segment.includes(":") || segment.endsWith(".") || segment.endsWith(" ")) return true;
|
|
76
|
+
const basename = segment.split(".")[0]?.toUpperCase();
|
|
77
|
+
return basename !== void 0 && /^(CON|PRN|AUX|NUL|CONIN\$|CONOUT\$|COM[0-9¹²³]|LPT[0-9¹²³])$/u.test(basename);
|
|
78
|
+
}
|
|
79
|
+
function containsControlCharacter(segment) {
|
|
80
|
+
for (let index = 0; index < segment.length; index++) {
|
|
81
|
+
const code = segment.charCodeAt(index);
|
|
82
|
+
if (code >= 0 && code <= 31) return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
function stripSingleLeadingSlash(path) {
|
|
87
|
+
return path.startsWith("/") ? path.slice(1) : path;
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { asRawB2KeyPrefix, b2KeyToRelativePathUnderPrefix, localFilesystemCanonicalSyncPath, localFilesystemSyncPathIsUnsafe, normalizeB2RelativePath };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix.js","names":[],"sources":["../../src/sync/prefix.ts"],"sourcesContent":["import { isDownloadStagingDirectorySegment } from './download-staging.ts'\n\n/**\n * Treats the supplied string as a raw B2 key prefix without adding a folder boundary.\n *\n * B2 keys are byte-oriented names, not local filesystem paths. A backslash in a prefix is a real\n * key character and must not be rewritten to `/`; callers that want slash-delimited prefixes should\n * pass `/` explicitly.\n *\n * @param prefix - User-supplied raw B2 key prefix.\n *\n * @returns Raw B2 key prefix.\n */\nexport function asRawB2KeyPrefix(prefix: string): string {\n return prefix\n}\n\n/**\n * Normalizes a B2 object name into a safe folder-relative sync path.\n *\n * Object names are converted to forward-slash sync paths for local compatibility. Callers that scan\n * B2 must detect normalized-path collisions between distinct raw B2 keys before yielding entries.\n *\n * @param path - B2 object name or prefix-stripped suffix returned by a listing.\n * @param options - Optional normalization behavior for legacy slashless raw prefixes.\n *\n * @returns Folder-relative sync path.\n *\n * @throws When the object name cannot be represented as a safe relative path.\n */\nexport function normalizeB2RelativePath(\n path: string,\n options: { readonly stripLeadingSlashes?: boolean } = {},\n): string {\n const slashPath = path.split('\\\\').join('/')\n const relativePath =\n options.stripLeadingSlashes === true ? stripSingleLeadingSlash(slashPath) : slashPath\n const segments = relativePath.split('/')\n if (/^[A-Za-z]:/.test(relativePath) || segments.some((segment) => segmentIsUnsafe(segment))) {\n throw new Error('Unsafe B2 file name cannot be used as a sync relative path')\n }\n return relativePath\n}\n\n/**\n * Converts a B2 object key under a configured raw prefix into a sync relative path.\n *\n * @param prefix - Raw B2 key prefix used for the scan or mutation guard.\n * @param fileName - Full B2 object key.\n *\n * @returns The normalized sync relative path for the key suffix.\n */\nexport function b2KeyToRelativePathUnderPrefix(prefix: string, fileName: string): string {\n const rawPrefix = asRawB2KeyPrefix(prefix)\n const suffix = rawPrefix === '' ? fileName : fileName.slice(rawPrefix.length)\n return normalizeB2RelativePath(suffix, {\n stripLeadingSlashes: rawPrefix !== '' && !rawPrefix.endsWith('/'),\n })\n}\n\n/**\n * Returns whether a sync path is unsafe to materialize on Windows-compatible local filesystems.\n * B2-to-B2 syncs can preserve these object names, but B2-to-local syncs skip them before writing.\n *\n * @param relativePath - Folder-relative sync path.\n *\n * @returns True when any segment is Windows-dangerous or ambiguous.\n */\nexport function localFilesystemSyncPathIsUnsafe(relativePath: string): boolean {\n const segments = relativePath.split('/')\n return (\n isDownloadStagingDirectorySegment(segments[0]) ||\n segments.some((segment) => segmentIsLocalFilesystemUnsafe(segment))\n )\n}\n\n/**\n * Produces an approximate Windows/macOS-style canonical key for local collision detection.\n *\n * @param relativePath - Folder-relative sync path.\n *\n * @returns A canonicalized path key for detecting case/Unicode collisions before local writes.\n */\nexport function localFilesystemCanonicalSyncPath(relativePath: string): string {\n return relativePath\n .split('/')\n .map((segment) => segment.normalize('NFC').toLocaleLowerCase('en-US'))\n .join('/')\n}\n\nfunction segmentIsUnsafe(segment: string): boolean {\n return segment === '' || segment === '.' || segment === '..' || containsControlCharacter(segment)\n}\n\nfunction segmentIsLocalFilesystemUnsafe(segment: string): boolean {\n if (segment.includes(':') || segment.endsWith('.') || segment.endsWith(' ')) return true\n const basename = segment.split('.')[0]?.toUpperCase()\n return (\n basename !== undefined &&\n /^(CON|PRN|AUX|NUL|CONIN\\$|CONOUT\\$|COM[0-9¹²³]|LPT[0-9¹²³])$/u.test(basename)\n )\n}\n\nfunction containsControlCharacter(segment: string): boolean {\n for (let index = 0; index < segment.length; index++) {\n const code = segment.charCodeAt(index)\n if (code >= 0 && code <= 31) return true\n }\n return false\n}\n\nfunction stripSingleLeadingSlash(path: string): string {\n return path.startsWith('/') ? path.slice(1) : path\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,iBAAiB,QAAwB;CACvD,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,wBACd,MACA,UAAsD,CAAC,GAC/C;CACR,MAAM,YAAY,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;CAC3C,MAAM,eACJ,QAAQ,wBAAwB,OAAO,wBAAwB,SAAS,IAAI;CAC9E,MAAM,WAAW,aAAa,MAAM,GAAG;CACvC,IAAI,aAAa,KAAK,YAAY,KAAK,SAAS,MAAM,YAAY,gBAAgB,OAAO,CAAC,GACxF,MAAM,IAAI,MAAM,4DAA4D;CAE9E,OAAO;AACT;;;;;;;;;AAUA,SAAgB,+BAA+B,QAAgB,UAA0B;CACvF,MAAM,YAAY,iBAAiB,MAAM;CAEzC,OAAO,wBADQ,cAAc,KAAK,WAAW,SAAS,MAAM,UAAU,MAAM,GACrC,EACrC,qBAAqB,cAAc,MAAM,CAAC,UAAU,SAAS,GAAG,EAClE,CAAC;AACH;;;;;;;;;AAUA,SAAgB,gCAAgC,cAA+B;CAC7E,MAAM,WAAW,aAAa,MAAM,GAAG;CACvC,OACE,kCAAkC,SAAS,EAAE,KAC7C,SAAS,MAAM,YAAY,+BAA+B,OAAO,CAAC;AAEtE;;;;;;;;AASA,SAAgB,iCAAiC,cAA8B;CAC7E,OAAO,aACJ,MAAM,GAAG,CAAC,CACV,KAAK,YAAY,QAAQ,UAAU,KAAK,CAAC,CAAC,kBAAkB,OAAO,CAAC,CAAC,CACrE,KAAK,GAAG;AACb;AAEA,SAAS,gBAAgB,SAA0B;CACjD,OAAO,YAAY,MAAM,YAAY,OAAO,YAAY,QAAQ,yBAAyB,OAAO;AAClG;AAEA,SAAS,+BAA+B,SAA0B;CAChE,IAAI,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,GAAG,GAAG,OAAO;CACpF,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,YAAY;CACpD,OACE,aAAa,KAAA,KACb,gEAAgE,KAAK,QAAQ;AAEjF;AAEA,SAAS,yBAAyB,SAA0B;CAC1D,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS;EACnD,MAAM,OAAO,QAAQ,WAAW,KAAK;EACrC,IAAI,QAAQ,KAAK,QAAQ,IAAI,OAAO;CACtC;CACA,OAAO;AACT;AAEA,SAAS,wBAAwB,MAAsB;CACrD,OAAO,KAAK,WAAW,GAAG,IAAI,KAAK,MAAM,CAAC,IAAI;AAChD"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
//#region src/sync/regexp-safety.ts
|
|
2
|
+
var MAX_REGEXP_SOURCE_LENGTH = 512;
|
|
3
|
+
var MAX_REGEXP_INPUT_LENGTH = 1024;
|
|
4
|
+
var MAX_REGEXP_UNBOUNDED_QUANTIFIERS = 1;
|
|
5
|
+
var MAX_REGEXP_BOUNDED_QUANTIFIER = 200;
|
|
6
|
+
var MAX_REGEXP_BOUNDED_QUANTIFIERS = 16;
|
|
7
|
+
var MAX_REGEXP_BOUNDED_QUANTIFIER_PRODUCT = 1e4;
|
|
8
|
+
var safeRegExpCache = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
var validatedFilterCache = /* @__PURE__ */ new WeakSet();
|
|
10
|
+
/**
|
|
11
|
+
* Validates every RegExp filter in an include/exclude filter set.
|
|
12
|
+
*
|
|
13
|
+
* @param filters - Optional include and exclude filters to validate.
|
|
14
|
+
*
|
|
15
|
+
* @throws When a RegExp filter is too large or structurally unsafe.
|
|
16
|
+
*/
|
|
17
|
+
function validateSyncFilters(filters) {
|
|
18
|
+
if (filters === void 0) return;
|
|
19
|
+
if (validatedFilterCache.has(filters)) return;
|
|
20
|
+
validateSyncFilterList("include", filters.include);
|
|
21
|
+
validateSyncFilterList("exclude", filters.exclude);
|
|
22
|
+
validatedFilterCache.add(filters);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Tests a path with a caller-provided RegExp without retaining `lastIndex` state.
|
|
26
|
+
*
|
|
27
|
+
* @param relativePath - Folder-relative path to test.
|
|
28
|
+
* @param pattern - Caller-provided RegExp filter.
|
|
29
|
+
*
|
|
30
|
+
* @returns True when the RegExp matches the relative path.
|
|
31
|
+
*
|
|
32
|
+
* @throws When the RegExp filter is too large or structurally unsafe.
|
|
33
|
+
*/
|
|
34
|
+
function regexpMatchesSyncPath(relativePath, pattern) {
|
|
35
|
+
if (pathExceedsSafeRegExpInput(relativePath)) return false;
|
|
36
|
+
return regexpWithoutState(pattern).test(relativePath);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Tests whether a relative path is too long to feed to caller-provided RegExp filters.
|
|
40
|
+
*
|
|
41
|
+
* @param relativePath - Folder-relative path to test.
|
|
42
|
+
*
|
|
43
|
+
* @returns True when RegExp filters should not be evaluated for the path.
|
|
44
|
+
*/
|
|
45
|
+
function pathExceedsSafeRegExpInput(relativePath) {
|
|
46
|
+
return relativePath.length > MAX_REGEXP_INPUT_LENGTH;
|
|
47
|
+
}
|
|
48
|
+
function validateSyncFilterList(kind, patterns) {
|
|
49
|
+
for (const pattern of patterns ?? []) if (typeof pattern !== "string") regexpWithoutState(pattern, kind);
|
|
50
|
+
}
|
|
51
|
+
function regexpWithoutState(pattern, kind = "pattern") {
|
|
52
|
+
const cached = safeRegExpCache.get(pattern);
|
|
53
|
+
if (cached !== void 0) return cached;
|
|
54
|
+
assertSafeRegExp(pattern, kind);
|
|
55
|
+
const compiled = new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ""));
|
|
56
|
+
safeRegExpCache.set(pattern, compiled);
|
|
57
|
+
return compiled;
|
|
58
|
+
}
|
|
59
|
+
function assertSafeRegExp(pattern, kind) {
|
|
60
|
+
const source = pattern.source;
|
|
61
|
+
if (source.length > MAX_REGEXP_SOURCE_LENGTH) throw new Error(`Sync filter RegExp is too long (${kind}: /${source}/)`);
|
|
62
|
+
if (!regexpSourceLooksSafe(source)) throw new Error(`Sync filter RegExp is too complex (${kind}: /${source}/)`);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Best-effort linear RegExp guard for filters matched synchronously on attacker-controlled paths.
|
|
66
|
+
*
|
|
67
|
+
* The accepted subset intentionally rejects constructs that are hard to bound in the JavaScript
|
|
68
|
+
* RegExp engine: backreferences, unterminated escapes/classes/groups, repeated unbounded
|
|
69
|
+
* quantifiers, bounded quantifiers above {@link MAX_REGEXP_BOUNDED_QUANTIFIER}, too many bounded
|
|
70
|
+
* quantifiers or too large a bounded-quantifier product, and any quantified group whose subtree
|
|
71
|
+
* already contains a quantifier or alternation. Group state is propagated upward so nested groups
|
|
72
|
+
* cannot hide a quantified or alternated subtree before an outer bounded or unbounded quantifier.
|
|
73
|
+
*
|
|
74
|
+
* @param source - RegExp source text to inspect.
|
|
75
|
+
*
|
|
76
|
+
* @returns True when the source passes the SDK's structural safety heuristic.
|
|
77
|
+
*/
|
|
78
|
+
function regexpSourceLooksSafe(source) {
|
|
79
|
+
let escaped = false;
|
|
80
|
+
let inClass = false;
|
|
81
|
+
let unboundedQuantifiers = 0;
|
|
82
|
+
let boundedQuantifiers = 0;
|
|
83
|
+
let boundedQuantifierProduct = 1;
|
|
84
|
+
const groups = [];
|
|
85
|
+
let lastToken = null;
|
|
86
|
+
for (let i = 0; i < source.length; i++) {
|
|
87
|
+
const char = source[i] ?? "";
|
|
88
|
+
if (escaped) {
|
|
89
|
+
if (!inClass && char === "k" && source[i + 1] === "<") return false;
|
|
90
|
+
if (!inClass && /[1-9]/.test(char)) return false;
|
|
91
|
+
escaped = false;
|
|
92
|
+
lastToken = { type: "atom" };
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (char === "\\") {
|
|
96
|
+
escaped = true;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (inClass) {
|
|
100
|
+
if (char === "]") inClass = false;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (char === "[") {
|
|
104
|
+
inClass = true;
|
|
105
|
+
lastToken = { type: "atom" };
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (char === "(") {
|
|
109
|
+
groups.push({
|
|
110
|
+
hasQuantifier: false,
|
|
111
|
+
hasAlternation: false
|
|
112
|
+
});
|
|
113
|
+
lastToken = null;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (char === ")") {
|
|
117
|
+
const group = groups.pop();
|
|
118
|
+
if (!group) return false;
|
|
119
|
+
const parent = groups.at(-1);
|
|
120
|
+
if (parent) mergeGroupState(parent, group);
|
|
121
|
+
lastToken = {
|
|
122
|
+
type: "group",
|
|
123
|
+
...group
|
|
124
|
+
};
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (char === "|") {
|
|
128
|
+
const group = groups.at(-1);
|
|
129
|
+
if (group) group.hasAlternation = true;
|
|
130
|
+
lastToken = null;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const quantifier = lastToken !== null ? parseQuantifier(source, i) : null;
|
|
134
|
+
if (lastToken !== null && quantifier !== null) {
|
|
135
|
+
if (lastToken?.type === "group" && (lastToken.hasQuantifier || lastToken.hasAlternation)) return false;
|
|
136
|
+
if (quantifier.unbounded) {
|
|
137
|
+
unboundedQuantifiers++;
|
|
138
|
+
if (unboundedQuantifiers > MAX_REGEXP_UNBOUNDED_QUANTIFIERS) return false;
|
|
139
|
+
} else {
|
|
140
|
+
boundedQuantifiers++;
|
|
141
|
+
if (boundedQuantifiers > MAX_REGEXP_BOUNDED_QUANTIFIERS) return false;
|
|
142
|
+
if (quantifier.maxRepetitions > MAX_REGEXP_BOUNDED_QUANTIFIER) return false;
|
|
143
|
+
boundedQuantifierProduct *= Math.max(quantifier.maxRepetitions, 1);
|
|
144
|
+
if (boundedQuantifierProduct > MAX_REGEXP_BOUNDED_QUANTIFIER_PRODUCT) return false;
|
|
145
|
+
}
|
|
146
|
+
const group = groups.at(-1);
|
|
147
|
+
if (group) group.hasQuantifier = true;
|
|
148
|
+
i = quantifier.endIndex;
|
|
149
|
+
lastToken = null;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
lastToken = { type: "atom" };
|
|
153
|
+
}
|
|
154
|
+
return !escaped && !inClass && groups.length === 0;
|
|
155
|
+
}
|
|
156
|
+
function mergeGroupState(target, source) {
|
|
157
|
+
target.hasQuantifier = target.hasQuantifier || source.hasQuantifier;
|
|
158
|
+
target.hasAlternation = target.hasAlternation || source.hasAlternation;
|
|
159
|
+
}
|
|
160
|
+
function parseQuantifier(source, index) {
|
|
161
|
+
const char = source[index];
|
|
162
|
+
if (char === "*" || char === "+") return {
|
|
163
|
+
endIndex: index,
|
|
164
|
+
maxRepetitions: Number.POSITIVE_INFINITY,
|
|
165
|
+
unbounded: true
|
|
166
|
+
};
|
|
167
|
+
if (char === "?") return {
|
|
168
|
+
endIndex: index,
|
|
169
|
+
maxRepetitions: 1,
|
|
170
|
+
unbounded: false
|
|
171
|
+
};
|
|
172
|
+
if (char !== "{") return null;
|
|
173
|
+
const end = source.indexOf("}", index + 1);
|
|
174
|
+
if (end === -1) return null;
|
|
175
|
+
const body = source.slice(index + 1, end);
|
|
176
|
+
const match = /^(\d+)(?:,(\d*))?$/.exec(body);
|
|
177
|
+
if (!match) return null;
|
|
178
|
+
const min = Number(match[1]);
|
|
179
|
+
const maxText = match[2];
|
|
180
|
+
const unbounded = body.includes(",") && maxText === "";
|
|
181
|
+
return {
|
|
182
|
+
endIndex: end,
|
|
183
|
+
maxRepetitions: unbounded ? Number.POSITIVE_INFINITY : Number(maxText ?? min),
|
|
184
|
+
unbounded
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
exports.pathExceedsSafeRegExpInput = pathExceedsSafeRegExpInput;
|
|
189
|
+
exports.regexpMatchesSyncPath = regexpMatchesSyncPath;
|
|
190
|
+
exports.validateSyncFilters = validateSyncFilters;
|
|
191
|
+
|
|
192
|
+
//# sourceMappingURL=regexp-safety.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexp-safety.cjs","names":[],"sources":["../../src/sync/regexp-safety.ts"],"sourcesContent":["import type { SyncFilterOptions, SyncFilterPattern } from './types.ts'\n\nconst MAX_REGEXP_SOURCE_LENGTH = 512\nconst MAX_REGEXP_INPUT_LENGTH = 1024\nconst MAX_REGEXP_UNBOUNDED_QUANTIFIERS = 1\nconst MAX_REGEXP_BOUNDED_QUANTIFIER = 200\nconst MAX_REGEXP_BOUNDED_QUANTIFIERS = 16\nconst MAX_REGEXP_BOUNDED_QUANTIFIER_PRODUCT = 10_000\nconst safeRegExpCache = new WeakMap<RegExp, RegExp>()\n// Validation is memoized by object identity. Treat filter objects and their\n// include/exclude arrays as immutable after first use, otherwise new patterns\n// added later would not be revalidated through this cache.\nconst validatedFilterCache = new WeakSet<SyncFilterOptions>()\n\ninterface RegExpGroupState {\n hasQuantifier: boolean\n hasAlternation: boolean\n}\n\ntype RegExpTokenState = { type: 'atom' } | ({ type: 'group' } & RegExpGroupState)\n\ninterface RegExpQuantifier {\n endIndex: number\n maxRepetitions: number\n unbounded: boolean\n}\n\n/**\n * Validates every RegExp filter in an include/exclude filter set.\n *\n * @param filters - Optional include and exclude filters to validate.\n *\n * @throws When a RegExp filter is too large or structurally unsafe.\n */\nexport function validateSyncFilters(filters: SyncFilterOptions | undefined): void {\n if (filters === undefined) return\n if (validatedFilterCache.has(filters)) return\n\n validateSyncFilterList('include', filters.include)\n validateSyncFilterList('exclude', filters.exclude)\n validatedFilterCache.add(filters)\n}\n\n/**\n * Tests a path with a caller-provided RegExp without retaining `lastIndex` state.\n *\n * @param relativePath - Folder-relative path to test.\n * @param pattern - Caller-provided RegExp filter.\n *\n * @returns True when the RegExp matches the relative path.\n *\n * @throws When the RegExp filter is too large or structurally unsafe.\n */\nexport function regexpMatchesSyncPath(relativePath: string, pattern: RegExp): boolean {\n if (pathExceedsSafeRegExpInput(relativePath)) return false\n return regexpWithoutState(pattern).test(relativePath)\n}\n\n/**\n * Tests whether a relative path is too long to feed to caller-provided RegExp filters.\n *\n * @param relativePath - Folder-relative path to test.\n *\n * @returns True when RegExp filters should not be evaluated for the path.\n */\nexport function pathExceedsSafeRegExpInput(relativePath: string): boolean {\n return relativePath.length > MAX_REGEXP_INPUT_LENGTH\n}\n\nfunction validateSyncFilterList(\n kind: 'include' | 'exclude',\n patterns: readonly SyncFilterPattern[] | undefined,\n): void {\n for (const pattern of patterns ?? []) {\n if (typeof pattern !== 'string') {\n regexpWithoutState(pattern, kind)\n }\n }\n}\n\nfunction regexpWithoutState(pattern: RegExp, kind = 'pattern'): RegExp {\n const cached = safeRegExpCache.get(pattern)\n if (cached !== undefined) return cached\n\n assertSafeRegExp(pattern, kind)\n const compiled = new RegExp(pattern.source, pattern.flags.replace(/[gy]/g, ''))\n safeRegExpCache.set(pattern, compiled)\n return compiled\n}\n\nfunction assertSafeRegExp(pattern: RegExp, kind: string): void {\n const source = pattern.source\n if (source.length > MAX_REGEXP_SOURCE_LENGTH) {\n throw new Error(`Sync filter RegExp is too long (${kind}: /${source}/)`)\n }\n\n if (!regexpSourceLooksSafe(source)) {\n throw new Error(`Sync filter RegExp is too complex (${kind}: /${source}/)`)\n }\n}\n\n/**\n * Best-effort linear RegExp guard for filters matched synchronously on attacker-controlled paths.\n *\n * The accepted subset intentionally rejects constructs that are hard to bound in the JavaScript\n * RegExp engine: backreferences, unterminated escapes/classes/groups, repeated unbounded\n * quantifiers, bounded quantifiers above {@link MAX_REGEXP_BOUNDED_QUANTIFIER}, too many bounded\n * quantifiers or too large a bounded-quantifier product, and any quantified group whose subtree\n * already contains a quantifier or alternation. Group state is propagated upward so nested groups\n * cannot hide a quantified or alternated subtree before an outer bounded or unbounded quantifier.\n *\n * @param source - RegExp source text to inspect.\n *\n * @returns True when the source passes the SDK's structural safety heuristic.\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: keep the regex safety scan linear.\nfunction regexpSourceLooksSafe(source: string): boolean {\n let escaped = false\n let inClass = false\n let unboundedQuantifiers = 0\n let boundedQuantifiers = 0\n let boundedQuantifierProduct = 1\n const groups: RegExpGroupState[] = []\n let lastToken: RegExpTokenState | null = null\n\n for (let i = 0; i < source.length; i++) {\n const char = source[i] ?? ''\n\n if (escaped) {\n if (!inClass && char === 'k' && source[i + 1] === '<') return false\n if (!inClass && /[1-9]/.test(char)) return false\n escaped = false\n lastToken = { type: 'atom' }\n continue\n }\n\n if (char === '\\\\') {\n escaped = true\n continue\n }\n\n if (inClass) {\n if (char === ']') inClass = false\n continue\n }\n\n if (char === '[') {\n inClass = true\n lastToken = { type: 'atom' }\n continue\n }\n\n if (char === '(') {\n groups.push({ hasQuantifier: false, hasAlternation: false })\n lastToken = null\n continue\n }\n\n if (char === ')') {\n const group = groups.pop()\n if (!group) return false\n const parent = groups.at(-1)\n if (parent) mergeGroupState(parent, group)\n lastToken = { type: 'group', ...group }\n continue\n }\n\n if (char === '|') {\n const group = groups.at(-1)\n if (group) group.hasAlternation = true\n lastToken = null\n continue\n }\n\n const quantifier = lastToken !== null ? parseQuantifier(source, i) : null\n if (lastToken !== null && quantifier !== null) {\n if (lastToken?.type === 'group' && (lastToken.hasQuantifier || lastToken.hasAlternation)) {\n return false\n }\n\n if (quantifier.unbounded) {\n unboundedQuantifiers++\n if (unboundedQuantifiers > MAX_REGEXP_UNBOUNDED_QUANTIFIERS) return false\n } else {\n boundedQuantifiers++\n if (boundedQuantifiers > MAX_REGEXP_BOUNDED_QUANTIFIERS) return false\n if (quantifier.maxRepetitions > MAX_REGEXP_BOUNDED_QUANTIFIER) return false\n boundedQuantifierProduct *= Math.max(quantifier.maxRepetitions, 1)\n if (boundedQuantifierProduct > MAX_REGEXP_BOUNDED_QUANTIFIER_PRODUCT) return false\n }\n\n const group = groups.at(-1)\n if (group) group.hasQuantifier = true\n\n i = quantifier.endIndex\n lastToken = null\n continue\n }\n\n lastToken = { type: 'atom' }\n }\n\n return !escaped && !inClass && groups.length === 0\n}\n\nfunction mergeGroupState(target: RegExpGroupState, source: RegExpGroupState): void {\n target.hasQuantifier = target.hasQuantifier || source.hasQuantifier\n target.hasAlternation = target.hasAlternation || source.hasAlternation\n}\n\nfunction parseQuantifier(source: string, index: number): RegExpQuantifier | null {\n const char = source[index]\n if (char === '*' || char === '+') {\n return { endIndex: index, maxRepetitions: Number.POSITIVE_INFINITY, unbounded: true }\n }\n if (char === '?') {\n return { endIndex: index, maxRepetitions: 1, unbounded: false }\n }\n if (char !== '{') return null\n\n const end = source.indexOf('}', index + 1)\n if (end === -1) return null\n\n const body = source.slice(index + 1, end)\n const match = /^(\\d+)(?:,(\\d*))?$/.exec(body)\n if (!match) return null\n\n const min = Number(match[1])\n const maxText = match[2]\n const unbounded = body.includes(',') && maxText === ''\n return {\n endIndex: end,\n maxRepetitions: unbounded ? Number.POSITIVE_INFINITY : Number(maxText ?? min),\n unbounded,\n }\n}\n"],"mappings":";AAEA,IAAM,2BAA2B;AACjC,IAAM,0BAA0B;AAChC,IAAM,mCAAmC;AACzC,IAAM,gCAAgC;AACtC,IAAM,iCAAiC;AACvC,IAAM,wCAAwC;AAC9C,IAAM,kCAAkB,IAAI,QAAwB;AAIpD,IAAM,uCAAuB,IAAI,QAA2B;;;;;;;;AAsB5D,SAAgB,oBAAoB,SAA8C;CAChF,IAAI,YAAY,KAAA,GAAW;CAC3B,IAAI,qBAAqB,IAAI,OAAO,GAAG;CAEvC,uBAAuB,WAAW,QAAQ,OAAO;CACjD,uBAAuB,WAAW,QAAQ,OAAO;CACjD,qBAAqB,IAAI,OAAO;AAClC;;;;;;;;;;;AAYA,SAAgB,sBAAsB,cAAsB,SAA0B;CACpF,IAAI,2BAA2B,YAAY,GAAG,OAAO;CACrD,OAAO,mBAAmB,OAAO,CAAC,CAAC,KAAK,YAAY;AACtD;;;;;;;;AASA,SAAgB,2BAA2B,cAA+B;CACxE,OAAO,aAAa,SAAS;AAC/B;AAEA,SAAS,uBACP,MACA,UACM;CACN,KAAK,MAAM,WAAW,YAAY,CAAC,GACjC,IAAI,OAAO,YAAY,UACrB,mBAAmB,SAAS,IAAI;AAGtC;AAEA,SAAS,mBAAmB,SAAiB,OAAO,WAAmB;CACrE,MAAM,SAAS,gBAAgB,IAAI,OAAO;CAC1C,IAAI,WAAW,KAAA,GAAW,OAAO;CAEjC,iBAAiB,SAAS,IAAI;CAC9B,MAAM,WAAW,IAAI,OAAO,QAAQ,QAAQ,QAAQ,MAAM,QAAQ,SAAS,EAAE,CAAC;CAC9E,gBAAgB,IAAI,SAAS,QAAQ;CACrC,OAAO;AACT;AAEA,SAAS,iBAAiB,SAAiB,MAAoB;CAC7D,MAAM,SAAS,QAAQ;CACvB,IAAI,OAAO,SAAS,0BAClB,MAAM,IAAI,MAAM,mCAAmC,KAAK,KAAK,OAAO,GAAG;CAGzE,IAAI,CAAC,sBAAsB,MAAM,GAC/B,MAAM,IAAI,MAAM,sCAAsC,KAAK,KAAK,OAAO,GAAG;AAE9E;;;;;;;;;;;;;;;AAiBA,SAAS,sBAAsB,QAAyB;CACtD,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,uBAAuB;CAC3B,IAAI,qBAAqB;CACzB,IAAI,2BAA2B;CAC/B,MAAM,SAA6B,CAAC;CACpC,IAAI,YAAqC;CAEzC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACtC,MAAM,OAAO,OAAO,MAAM;EAE1B,IAAI,SAAS;GACX,IAAI,CAAC,WAAW,SAAS,OAAO,OAAO,IAAI,OAAO,KAAK,OAAO;GAC9D,IAAI,CAAC,WAAW,QAAQ,KAAK,IAAI,GAAG,OAAO;GAC3C,UAAU;GACV,YAAY,EAAE,MAAM,OAAO;GAC3B;EACF;EAEA,IAAI,SAAS,MAAM;GACjB,UAAU;GACV;EACF;EAEA,IAAI,SAAS;GACX,IAAI,SAAS,KAAK,UAAU;GAC5B;EACF;EAEA,IAAI,SAAS,KAAK;GAChB,UAAU;GACV,YAAY,EAAE,MAAM,OAAO;GAC3B;EACF;EAEA,IAAI,SAAS,KAAK;GAChB,OAAO,KAAK;IAAE,eAAe;IAAO,gBAAgB;GAAM,CAAC;GAC3D,YAAY;GACZ;EACF;EAEA,IAAI,SAAS,KAAK;GAChB,MAAM,QAAQ,OAAO,IAAI;GACzB,IAAI,CAAC,OAAO,OAAO;GACnB,MAAM,SAAS,OAAO,GAAG,EAAE;GAC3B,IAAI,QAAQ,gBAAgB,QAAQ,KAAK;GACzC,YAAY;IAAE,MAAM;IAAS,GAAG;GAAM;GACtC;EACF;EAEA,IAAI,SAAS,KAAK;GAChB,MAAM,QAAQ,OAAO,GAAG,EAAE;GAC1B,IAAI,OAAO,MAAM,iBAAiB;GAClC,YAAY;GACZ;EACF;EAEA,MAAM,aAAa,cAAc,OAAO,gBAAgB,QAAQ,CAAC,IAAI;EACrE,IAAI,cAAc,QAAQ,eAAe,MAAM;GAC7C,IAAI,WAAW,SAAS,YAAY,UAAU,iBAAiB,UAAU,iBACvE,OAAO;GAGT,IAAI,WAAW,WAAW;IACxB;IACA,IAAI,uBAAuB,kCAAkC,OAAO;GACtE,OAAO;IACL;IACA,IAAI,qBAAqB,gCAAgC,OAAO;IAChE,IAAI,WAAW,iBAAiB,+BAA+B,OAAO;IACtE,4BAA4B,KAAK,IAAI,WAAW,gBAAgB,CAAC;IACjE,IAAI,2BAA2B,uCAAuC,OAAO;GAC/E;GAEA,MAAM,QAAQ,OAAO,GAAG,EAAE;GAC1B,IAAI,OAAO,MAAM,gBAAgB;GAEjC,IAAI,WAAW;GACf,YAAY;GACZ;EACF;EAEA,YAAY,EAAE,MAAM,OAAO;CAC7B;CAEA,OAAO,CAAC,WAAW,CAAC,WAAW,OAAO,WAAW;AACnD;AAEA,SAAS,gBAAgB,QAA0B,QAAgC;CACjF,OAAO,gBAAgB,OAAO,iBAAiB,OAAO;CACtD,OAAO,iBAAiB,OAAO,kBAAkB,OAAO;AAC1D;AAEA,SAAS,gBAAgB,QAAgB,OAAwC;CAC/E,MAAM,OAAO,OAAO;CACpB,IAAI,SAAS,OAAO,SAAS,KAC3B,OAAO;EAAE,UAAU;EAAO,gBAAgB,OAAO;EAAmB,WAAW;CAAK;CAEtF,IAAI,SAAS,KACX,OAAO;EAAE,UAAU;EAAO,gBAAgB;EAAG,WAAW;CAAM;CAEhE,IAAI,SAAS,KAAK,OAAO;CAEzB,MAAM,MAAM,OAAO,QAAQ,KAAK,QAAQ,CAAC;CACzC,IAAI,QAAQ,IAAI,OAAO;CAEvB,MAAM,OAAO,OAAO,MAAM,QAAQ,GAAG,GAAG;CACxC,MAAM,QAAQ,qBAAqB,KAAK,IAAI;CAC5C,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,MAAM,OAAO,MAAM,EAAE;CAC3B,MAAM,UAAU,MAAM;CACtB,MAAM,YAAY,KAAK,SAAS,GAAG,KAAK,YAAY;CACpD,OAAO;EACL,UAAU;EACV,gBAAgB,YAAY,OAAO,oBAAoB,OAAO,WAAW,GAAG;EAC5E;CACF;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SyncFilterOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates every RegExp filter in an include/exclude filter set.
|
|
4
|
+
*
|
|
5
|
+
* @param filters - Optional include and exclude filters to validate.
|
|
6
|
+
*
|
|
7
|
+
* @throws When a RegExp filter is too large or structurally unsafe.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateSyncFilters(filters: SyncFilterOptions | undefined): void;
|
|
10
|
+
/**
|
|
11
|
+
* Tests a path with a caller-provided RegExp without retaining `lastIndex` state.
|
|
12
|
+
*
|
|
13
|
+
* @param relativePath - Folder-relative path to test.
|
|
14
|
+
* @param pattern - Caller-provided RegExp filter.
|
|
15
|
+
*
|
|
16
|
+
* @returns True when the RegExp matches the relative path.
|
|
17
|
+
*
|
|
18
|
+
* @throws When the RegExp filter is too large or structurally unsafe.
|
|
19
|
+
*/
|
|
20
|
+
export declare function regexpMatchesSyncPath(relativePath: string, pattern: RegExp): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Tests whether a relative path is too long to feed to caller-provided RegExp filters.
|
|
23
|
+
*
|
|
24
|
+
* @param relativePath - Folder-relative path to test.
|
|
25
|
+
*
|
|
26
|
+
* @returns True when RegExp filters should not be evaluated for the path.
|
|
27
|
+
*/
|
|
28
|
+
export declare function pathExceedsSafeRegExpInput(relativePath: string): boolean;
|
|
29
|
+
//# sourceMappingURL=regexp-safety.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexp-safety.d.ts","sourceRoot":"","sources":["../../src/sync/regexp-safety.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,YAAY,CAAA;AA2BtE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAOhF;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAExE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SyncFilterOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Validates every RegExp filter in an include/exclude filter set.
|
|
4
|
+
*
|
|
5
|
+
* @param filters - Optional include and exclude filters to validate.
|
|
6
|
+
*
|
|
7
|
+
* @throws When a RegExp filter is too large or structurally unsafe.
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateSyncFilters(filters: SyncFilterOptions | undefined): void;
|
|
10
|
+
/**
|
|
11
|
+
* Tests a path with a caller-provided RegExp without retaining `lastIndex` state.
|
|
12
|
+
*
|
|
13
|
+
* @param relativePath - Folder-relative path to test.
|
|
14
|
+
* @param pattern - Caller-provided RegExp filter.
|
|
15
|
+
*
|
|
16
|
+
* @returns True when the RegExp matches the relative path.
|
|
17
|
+
*
|
|
18
|
+
* @throws When the RegExp filter is too large or structurally unsafe.
|
|
19
|
+
*/
|
|
20
|
+
export declare function regexpMatchesSyncPath(relativePath: string, pattern: RegExp): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Tests whether a relative path is too long to feed to caller-provided RegExp filters.
|
|
23
|
+
*
|
|
24
|
+
* @param relativePath - Folder-relative path to test.
|
|
25
|
+
*
|
|
26
|
+
* @returns True when RegExp filters should not be evaluated for the path.
|
|
27
|
+
*/
|
|
28
|
+
export declare function pathExceedsSafeRegExpInput(relativePath: string): boolean;
|
|
29
|
+
//# sourceMappingURL=regexp-safety.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regexp-safety.d.ts","sourceRoot":"","sources":["../../src/sync/regexp-safety.js"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAqB,MAAM,YAAY,CAAA;AA2BtE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAOhF;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGpF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAExE"}
|