@contrast/agent-bundle 5.39.1 → 5.41.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/node_modules/@contrast/agent/lib/start-agent.js +50 -40
- package/node_modules/@contrast/agent/package.json +11 -11
- package/node_modules/@contrast/agent-swc-plugin/index.js +9 -3
- package/node_modules/@contrast/agent-swc-plugin/methods.js +15 -1
- package/node_modules/@contrast/agent-swc-plugin/package.json +5 -8
- package/node_modules/@contrast/agent-swc-plugin/rewriter.wasm +0 -0
- package/node_modules/@contrast/agentify/lib/index.js +2 -2
- package/node_modules/@contrast/agentify/package.json +15 -14
- package/node_modules/@contrast/architecture-components/package.json +5 -5
- package/node_modules/@contrast/assess/lib/dataflow/propagation/install/string/replace.js +6 -3
- package/node_modules/@contrast/assess/lib/dataflow/propagation/install/util-format.js +44 -21
- package/node_modules/@contrast/assess/lib/dataflow/sources/index.js +1 -1
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/{body-parser1.js → body-parser.js} +2 -2
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-bodyparsers.js +3 -1
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/qs6.js +5 -5
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/querystring.js +2 -1
- package/node_modules/@contrast/assess/lib/index.d.ts +0 -1
- package/node_modules/@contrast/assess/lib/make-source-context.js +7 -37
- package/node_modules/@contrast/assess/lib/sampler/common.js +7 -11
- package/node_modules/@contrast/assess/package.json +12 -11
- package/node_modules/@contrast/common/lib/constants.d.ts +6 -0
- package/node_modules/@contrast/common/lib/constants.js +8 -1
- package/node_modules/@contrast/common/lib/types.d.ts +7 -1
- package/node_modules/@contrast/common/package.json +1 -1
- package/node_modules/@contrast/config/lib/common.js +1 -1
- package/node_modules/@contrast/config/lib/config.js +49 -27
- package/node_modules/@contrast/config/lib/index.d.ts +3 -2
- package/node_modules/@contrast/config/lib/options.js +4 -4
- package/node_modules/@contrast/config/package.json +4 -3
- package/node_modules/@contrast/core/lib/sensitive-data-masking/protect-listener.js +15 -15
- package/node_modules/@contrast/core/package.json +6 -6
- package/node_modules/@contrast/deadzones/package.json +5 -5
- package/node_modules/@contrast/dep-hooks/package.json +3 -3
- package/node_modules/@contrast/esm-hooks/package.json +6 -6
- package/node_modules/@contrast/instrumentation/lib/index.js +0 -1
- package/node_modules/@contrast/instrumentation/package.json +5 -5
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +300 -152
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/index.js +9 -2
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/utils.js +54 -43
- package/node_modules/@contrast/library-analysis/package.json +4 -4
- package/node_modules/@contrast/logger/lib/serializers.js +2 -2
- package/node_modules/@contrast/logger/package.json +3 -3
- package/node_modules/@contrast/metrics/package.json +6 -6
- package/node_modules/@contrast/patcher/package.json +2 -2
- package/node_modules/@contrast/protect/lib/get-source-context.js +3 -1
- package/node_modules/@contrast/protect/lib/index.js +6 -1
- package/node_modules/@contrast/protect/lib/input-analysis/handlers.js +7 -9
- package/node_modules/@contrast/protect/lib/input-analysis/index.js +1 -1
- package/node_modules/@contrast/protect/lib/input-analysis/install/{body-parser1.js → body-parser.js} +1 -1
- package/node_modules/@contrast/protect/lib/input-analysis/install/http.js +18 -19
- package/node_modules/@contrast/protect/lib/input-analysis/install/qs6.js +18 -17
- package/node_modules/@contrast/protect/lib/input-analysis/install/universal-cookie4.js +2 -3
- package/node_modules/@contrast/protect/lib/make-source-context.js +22 -66
- package/node_modules/@contrast/protect/lib/semantic-analysis/handlers.js +73 -72
- package/node_modules/@contrast/protect/package.json +11 -11
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/index.js +7 -7
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.d.ts +3 -3
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.js +24 -21
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/routes-observed.js +2 -1
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.js +1 -1
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.d.ts +1 -2
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.js +8 -2
- package/node_modules/@contrast/reporter/lib/reporters/security-logger/index.d.ts +2 -2
- package/node_modules/@contrast/reporter/lib/reporters/security-logger/index.js +22 -20
- package/node_modules/@contrast/reporter/package.json +7 -7
- package/node_modules/@contrast/rewriter/lib/index.js +2 -2
- package/node_modules/@contrast/rewriter/package.json +6 -6
- package/node_modules/@contrast/route-coverage/lib/index.d.ts +2 -0
- package/node_modules/@contrast/route-coverage/lib/index.js +15 -17
- package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +489 -202
- package/node_modules/@contrast/route-coverage/package.json +9 -9
- package/node_modules/@contrast/scopes/package.json +5 -5
- package/node_modules/@contrast/sec-obs/lib/traces/http.js +2 -2
- package/node_modules/@contrast/sec-obs/lib/traces/http.test.js +17 -0
- package/node_modules/@contrast/sec-obs/lib/traces/outbound-service-call.js +2 -2
- package/node_modules/@contrast/sec-obs/lib/traces/outbound-service-call.test.js +17 -0
- package/node_modules/@contrast/sec-obs/package.json +9 -9
- package/node_modules/@contrast/sources/lib/index.js +109 -0
- package/node_modules/@contrast/sources/lib/index.test.js +120 -0
- package/node_modules/@contrast/{route-coverage/lib/normalized-url-mapper.js → sources/lib/normalized-uri-mapper.js} +10 -3
- package/node_modules/@contrast/sources/lib/normalized-uri-mapper.test.js +59 -0
- package/node_modules/@contrast/{sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/constants.js → sources/lib/req-data.js} +0 -6
- package/node_modules/@contrast/sources/lib/source-info.js +183 -0
- package/node_modules/@contrast/sources/lib/source-info.test.js +68 -0
- package/node_modules/@contrast/sources/package.json +16 -0
- package/node_modules/@contrast/telemetry/package.json +6 -6
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js +2858 -103
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +420 -102
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/package.json +3 -3
- package/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/node/buffer.d.ts +5 -0
- package/node_modules/@types/node/dns/promises.d.ts +11 -10
- package/node_modules/@types/node/dns.d.ts +18 -19
- package/node_modules/@types/node/fs.d.ts +13 -1
- package/node_modules/@types/node/http.d.ts +4 -19
- package/node_modules/@types/node/inspector.d.ts +53 -0
- package/node_modules/@types/node/package.json +2 -82
- package/node_modules/@types/node/stream/web.d.ts +4 -0
- package/node_modules/axios/CHANGELOG.md +17 -0
- package/node_modules/axios/README.md +1 -4
- package/node_modules/axios/dist/axios.js +39 -5
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +2 -2
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +46 -9
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +46 -9
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +46 -9
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +13 -2
- package/node_modules/axios/lib/core/Axios.js +2 -2
- package/node_modules/axios/lib/core/mergeConfig.js +1 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/throttle.js +1 -1
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +4 -3
- package/node_modules/axios/lib/utils.js +36 -0
- package/node_modules/axios/package.json +5 -5
- package/node_modules/deepmerge/.editorconfig +7 -0
- package/node_modules/deepmerge/.eslintcache +1 -0
- package/node_modules/deepmerge/changelog.md +167 -0
- package/node_modules/deepmerge/dist/cjs.js +133 -0
- package/node_modules/deepmerge/dist/umd.js +139 -0
- package/node_modules/deepmerge/index.d.ts +20 -0
- package/node_modules/deepmerge/index.js +106 -0
- package/node_modules/{path-to-regexp/LICENSE → deepmerge/license.txt} +1 -1
- package/node_modules/deepmerge/package.json +42 -0
- package/node_modules/deepmerge/readme.md +264 -0
- package/node_modules/deepmerge/rollup.config.js +22 -0
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/form-data/CHANGELOG.md +601 -0
- package/node_modules/form-data/{Readme.md → README.md} +4 -4
- package/node_modules/form-data/lib/form_data.js +2 -6
- package/node_modules/form-data/package.json +22 -6
- package/node_modules/nan/.github/workflows/ci.yml +8 -10
- package/node_modules/nan/.pre-commit-config.yaml +8 -0
- package/node_modules/nan/CHANGELOG.md +5 -1
- package/node_modules/nan/README.md +4 -4
- package/node_modules/nan/nan.h +16 -12
- package/node_modules/nan/nan_callbacks.h +13 -0
- package/node_modules/nan/nan_callbacks_12_inl.h +16 -2
- package/node_modules/nan/nan_callbacks_pre_12_inl.h +6 -2
- package/node_modules/nan/nan_maybe_43_inl.h +1 -1
- package/node_modules/nan/nan_maybe_pre_43_inl.h +1 -1
- package/node_modules/nan/nan_scriptorigin.h +11 -9
- package/node_modules/nan/nan_typedarray_contents.h +1 -1
- package/node_modules/nan/package.json +2 -2
- package/package.json +5 -3
- package/node_modules/@contrast/agentify/lib/sources.js +0 -94
- package/node_modules/@contrast/route-coverage/lib/install/http.js +0 -44
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/constants.d.ts +0 -385
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/constants.js +0 -270
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/index.d.ts +0 -40
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/index.js +0 -228
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/primordials.d.ts +0 -65
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/primordials.js +0 -66
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/types.d.ts +0 -383
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/types.js +0 -30
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/package.json +0 -23
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/README.md +0 -44
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/common.js +0 -131
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/config.js +0 -290
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/index.d.ts +0 -328
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/index.js +0 -29
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/options.js +0 -836
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/validators.js +0 -23
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/package.json +0 -27
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/README.md +0 -98
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/agent-info.js +0 -36
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/app-info.js +0 -233
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/build-id.js +0 -51
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/capture-stacktrace.js +0 -256
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/contrast-methods.js +0 -155
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/index.d.ts +0 -52
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/ioc/core.js +0 -95
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/is-agent-path.js +0 -37
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/messages.js +0 -28
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/index.js +0 -63
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/protect-listener.js +0 -111
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/server-settings-listener.js +0 -44
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/cloud-provider-metadata.js +0 -146
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/index.js +0 -225
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/linux-os-info.js +0 -137
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/utils.js +0 -35
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/package.json +0 -33
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/README.md +0 -94
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-handler-registry.d.ts +0 -121
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-handler-registry.js +0 -206
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.d.ts +0 -72
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.js +0 -88
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/handler-invoker.d.ts +0 -46
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/handler-invoker.js +0 -106
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/helpers.d.ts +0 -28
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/helpers.js +0 -66
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/index.d.ts +0 -115
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/index.js +0 -208
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/package-finder.d.ts +0 -43
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/package-finder.js +0 -79
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/package.json +0 -29
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/README.md +0 -270
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/index.d.ts +0 -16
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/index.js +0 -132
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/serializers.d.ts +0 -33
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/serializers.js +0 -75
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/utils.d.ts +0 -15
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/utils.js +0 -34
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/package.json +0 -28
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/README.md +0 -51
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/lib/index.d.ts +0 -101
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/lib/index.js +0 -544
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/package.json +0 -25
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/README.md +0 -6
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/cache.js +0 -318
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/index.js +0 -216
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/rewrite-is-deadzoned.js +0 -143
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/package.json +0 -30
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/constants.js +0 -26
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/index.d.ts +0 -46
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/index.js +0 -70
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/bluebird.js +0 -128
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/index.js +0 -34
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb-core.js +0 -83
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb3.js +0 -89
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb4.js +0 -80
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb6.js +0 -46
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mysql.js +0 -151
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/redis.js +0 -79
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/utils.js +0 -35
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/package.json +0 -28
- package/node_modules/form-data/README.md.bak +0 -355
- package/node_modules/path-to-regexp/Readme.md +0 -216
- package/node_modules/path-to-regexp/dist/index.d.ts +0 -136
- package/node_modules/path-to-regexp/dist/index.js +0 -403
- package/node_modules/path-to-regexp/dist/index.js.map +0 -1
- package/node_modules/path-to-regexp/package.json +0 -62
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
# Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data)
|
|
2
|
-
|
|
3
|
-
A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications.
|
|
4
|
-
|
|
5
|
-
The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd].
|
|
6
|
-
|
|
7
|
-
[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface
|
|
8
|
-
|
|
9
|
-
[](https://travis-ci.org/form-data/form-data)
|
|
10
|
-
[](https://travis-ci.org/form-data/form-data)
|
|
11
|
-
[](https://travis-ci.org/form-data/form-data)
|
|
12
|
-
|
|
13
|
-
[](https://coveralls.io/github/form-data/form-data?branch=master)
|
|
14
|
-
[](https://david-dm.org/form-data/form-data)
|
|
15
|
-
|
|
16
|
-
## Install
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
npm install --save form-data
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Usage
|
|
23
|
-
|
|
24
|
-
In this example we are constructing a form with 3 fields that contain a string,
|
|
25
|
-
a buffer and a file stream.
|
|
26
|
-
|
|
27
|
-
``` javascript
|
|
28
|
-
var FormData = require('form-data');
|
|
29
|
-
var fs = require('fs');
|
|
30
|
-
|
|
31
|
-
var form = new FormData();
|
|
32
|
-
form.append('my_field', 'my value');
|
|
33
|
-
form.append('my_buffer', new Buffer(10));
|
|
34
|
-
form.append('my_file', fs.createReadStream('/foo/bar.jpg'));
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Also you can use http-response stream:
|
|
38
|
-
|
|
39
|
-
``` javascript
|
|
40
|
-
var FormData = require('form-data');
|
|
41
|
-
var http = require('http');
|
|
42
|
-
|
|
43
|
-
var form = new FormData();
|
|
44
|
-
|
|
45
|
-
http.request('http://nodejs.org/images/logo.png', function (response) {
|
|
46
|
-
form.append('my_field', 'my value');
|
|
47
|
-
form.append('my_buffer', new Buffer(10));
|
|
48
|
-
form.append('my_logo', response);
|
|
49
|
-
});
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Or @mikeal's [request](https://github.com/request/request) stream:
|
|
53
|
-
|
|
54
|
-
``` javascript
|
|
55
|
-
var FormData = require('form-data');
|
|
56
|
-
var request = require('request');
|
|
57
|
-
|
|
58
|
-
var form = new FormData();
|
|
59
|
-
|
|
60
|
-
form.append('my_field', 'my value');
|
|
61
|
-
form.append('my_buffer', new Buffer(10));
|
|
62
|
-
form.append('my_logo', request('http://nodejs.org/images/logo.png'));
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
In order to submit this form to a web application, call ```submit(url, [callback])``` method:
|
|
66
|
-
|
|
67
|
-
``` javascript
|
|
68
|
-
form.submit('http://example.org/', function (err, res) {
|
|
69
|
-
// res – response object (http.IncomingMessage) //
|
|
70
|
-
res.resume();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods.
|
|
76
|
-
|
|
77
|
-
### Custom options
|
|
78
|
-
|
|
79
|
-
You can provide custom options, such as `maxDataSize`:
|
|
80
|
-
|
|
81
|
-
``` javascript
|
|
82
|
-
var FormData = require('form-data');
|
|
83
|
-
|
|
84
|
-
var form = new FormData({ maxDataSize: 20971520 });
|
|
85
|
-
form.append('my_field', 'my value');
|
|
86
|
-
form.append('my_buffer', /* something big */);
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15)
|
|
90
|
-
|
|
91
|
-
### Alternative submission methods
|
|
92
|
-
|
|
93
|
-
You can use node's http client interface:
|
|
94
|
-
|
|
95
|
-
``` javascript
|
|
96
|
-
var http = require('http');
|
|
97
|
-
|
|
98
|
-
var request = http.request({
|
|
99
|
-
method: 'post',
|
|
100
|
-
host: 'example.org',
|
|
101
|
-
path: '/upload',
|
|
102
|
-
headers: form.getHeaders()
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
form.pipe(request);
|
|
106
|
-
|
|
107
|
-
request.on('response', function (res) {
|
|
108
|
-
console.log(res.statusCode);
|
|
109
|
-
});
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Or if you would prefer the `'Content-Length'` header to be set for you:
|
|
113
|
-
|
|
114
|
-
``` javascript
|
|
115
|
-
form.submit('example.org/upload', function (err, res) {
|
|
116
|
-
console.log(res.statusCode);
|
|
117
|
-
});
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
To use custom headers and pre-known length in parts:
|
|
121
|
-
|
|
122
|
-
``` javascript
|
|
123
|
-
var CRLF = '\r\n';
|
|
124
|
-
var form = new FormData();
|
|
125
|
-
|
|
126
|
-
var options = {
|
|
127
|
-
header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF,
|
|
128
|
-
knownLength: 1
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
form.append('my_buffer', buffer, options);
|
|
132
|
-
|
|
133
|
-
form.submit('http://example.com/', function (err, res) {
|
|
134
|
-
if (err) throw err;
|
|
135
|
-
console.log('Done');
|
|
136
|
-
});
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually:
|
|
140
|
-
|
|
141
|
-
``` javascript
|
|
142
|
-
someModule.stream(function (err, stdout, stderr) {
|
|
143
|
-
if (err) throw err;
|
|
144
|
-
|
|
145
|
-
var form = new FormData();
|
|
146
|
-
|
|
147
|
-
form.append('file', stdout, {
|
|
148
|
-
filename: 'unicycle.jpg', // ... or:
|
|
149
|
-
filepath: 'photos/toys/unicycle.jpg',
|
|
150
|
-
contentType: 'image/jpeg',
|
|
151
|
-
knownLength: 19806
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
form.submit('http://example.com/', function (err, res) {
|
|
155
|
-
if (err) throw err;
|
|
156
|
-
console.log('Done');
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory).
|
|
162
|
-
|
|
163
|
-
For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter:
|
|
164
|
-
|
|
165
|
-
``` javascript
|
|
166
|
-
form.submit({
|
|
167
|
-
host: 'example.com',
|
|
168
|
-
path: '/probably.php?extra=params',
|
|
169
|
-
auth: 'username:password'
|
|
170
|
-
}, function (err, res) {
|
|
171
|
-
console.log(res.statusCode);
|
|
172
|
-
});
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`:
|
|
176
|
-
|
|
177
|
-
``` javascript
|
|
178
|
-
form.submit({
|
|
179
|
-
host: 'example.com',
|
|
180
|
-
path: '/surelynot.php',
|
|
181
|
-
headers: { 'x-test-header': 'test-header-value' }
|
|
182
|
-
}, function (err, res) {
|
|
183
|
-
console.log(res.statusCode);
|
|
184
|
-
});
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Methods
|
|
188
|
-
|
|
189
|
-
- [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-).
|
|
190
|
-
- [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-)
|
|
191
|
-
- [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary)
|
|
192
|
-
- [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary)
|
|
193
|
-
- [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer)
|
|
194
|
-
- [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync)
|
|
195
|
-
- [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-)
|
|
196
|
-
- [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength)
|
|
197
|
-
- [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-)
|
|
198
|
-
- [_String_ toString()](https://github.com/form-data/form-data#string-tostring)
|
|
199
|
-
|
|
200
|
-
#### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )
|
|
201
|
-
Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user.
|
|
202
|
-
```javascript
|
|
203
|
-
var form = new FormData();
|
|
204
|
-
form.append('my_string', 'my value');
|
|
205
|
-
form.append('my_integer', 1);
|
|
206
|
-
form.append('my_boolean', true);
|
|
207
|
-
form.append('my_buffer', new Buffer(10));
|
|
208
|
-
form.append('my_array_as_json', JSON.stringify(['bird', 'cute']));
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
You may provide a string for options, or an object.
|
|
212
|
-
```javascript
|
|
213
|
-
// Set filename by providing a string for options
|
|
214
|
-
form.append('my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg');
|
|
215
|
-
|
|
216
|
-
// provide an object.
|
|
217
|
-
form.append('my_file', fs.createReadStream('/foo/bar.jpg'), { filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806 });
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
#### _Headers_ getHeaders( [**Headers** _userHeaders_] )
|
|
221
|
-
This method adds the correct `content-type` header to the provided array of `userHeaders`.
|
|
222
|
-
|
|
223
|
-
#### _String_ getBoundary()
|
|
224
|
-
Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers
|
|
225
|
-
for example:
|
|
226
|
-
```javascript
|
|
227
|
-
--------------------------515890814546601021194782
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### _Void_ setBoundary(String _boundary_)
|
|
231
|
-
Set the boundary string, overriding the default behavior described above.
|
|
232
|
-
|
|
233
|
-
_Note: The boundary must be unique and may not appear in the data._
|
|
234
|
-
|
|
235
|
-
#### _Buffer_ getBuffer()
|
|
236
|
-
Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data.
|
|
237
|
-
```javascript
|
|
238
|
-
var form = new FormData();
|
|
239
|
-
form.append('my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]));
|
|
240
|
-
form.append('my_file', fs.readFileSync('/foo/bar.jpg'));
|
|
241
|
-
|
|
242
|
-
axios.post('https://example.com/path/to/api', form.getBuffer(), form.getHeaders());
|
|
243
|
-
```
|
|
244
|
-
**Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error.
|
|
245
|
-
|
|
246
|
-
#### _Integer_ getLengthSync()
|
|
247
|
-
Same as `getLength` but synchronous.
|
|
248
|
-
|
|
249
|
-
_Note: getLengthSync __doesn't__ calculate streams length._
|
|
250
|
-
|
|
251
|
-
#### _Integer_ getLength(**function** _callback_ )
|
|
252
|
-
Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated
|
|
253
|
-
```javascript
|
|
254
|
-
this.getLength(function (err, length) {
|
|
255
|
-
if (err) {
|
|
256
|
-
this._error(err);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// add content length
|
|
261
|
-
request.setHeader('Content-Length', length);
|
|
262
|
-
|
|
263
|
-
...
|
|
264
|
-
}.bind(this));
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
#### _Boolean_ hasKnownLength()
|
|
268
|
-
Checks if the length of added values is known.
|
|
269
|
-
|
|
270
|
-
#### _Request_ submit(_params_, **function** _callback_ )
|
|
271
|
-
Submit the form to a web application.
|
|
272
|
-
```javascript
|
|
273
|
-
var form = new FormData();
|
|
274
|
-
form.append('my_string', 'Hello World');
|
|
275
|
-
|
|
276
|
-
form.submit('http://example.com/', function (err, res) {
|
|
277
|
-
// res – response object (http.IncomingMessage) //
|
|
278
|
-
res.resume();
|
|
279
|
-
} );
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
#### _String_ toString()
|
|
283
|
-
Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead.
|
|
284
|
-
|
|
285
|
-
### Integration with other libraries
|
|
286
|
-
|
|
287
|
-
#### Request
|
|
288
|
-
|
|
289
|
-
Form submission using [request](https://github.com/request/request):
|
|
290
|
-
|
|
291
|
-
```javascript
|
|
292
|
-
var formData = {
|
|
293
|
-
my_field: 'my_value',
|
|
294
|
-
my_file: fs.createReadStream(__dirname + '/unicycle.jpg'),
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
request.post({url:'http://service.com/upload', formData: formData}, function (err, httpResponse, body) {
|
|
298
|
-
if (err) {
|
|
299
|
-
return console.error('upload failed:', err);
|
|
300
|
-
}
|
|
301
|
-
console.log('Upload successful! Server responded with:', body);
|
|
302
|
-
});
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads).
|
|
306
|
-
|
|
307
|
-
#### node-fetch
|
|
308
|
-
|
|
309
|
-
You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch):
|
|
310
|
-
|
|
311
|
-
```javascript
|
|
312
|
-
var form = new FormData();
|
|
313
|
-
|
|
314
|
-
form.append('a', 1);
|
|
315
|
-
|
|
316
|
-
fetch('http://example.com', { method: 'POST', body: form })
|
|
317
|
-
.then(function (res) {
|
|
318
|
-
return res.json();
|
|
319
|
-
}).then(function (json) {
|
|
320
|
-
console.log(json);
|
|
321
|
-
});
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
#### axios
|
|
325
|
-
|
|
326
|
-
In Node.js you can post a file using [axios](https://github.com/axios/axios):
|
|
327
|
-
```javascript
|
|
328
|
-
const form = new FormData();
|
|
329
|
-
const stream = fs.createReadStream(PATH_TO_FILE);
|
|
330
|
-
|
|
331
|
-
form.append('image', stream);
|
|
332
|
-
|
|
333
|
-
// In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders`
|
|
334
|
-
const formHeaders = form.getHeaders();
|
|
335
|
-
|
|
336
|
-
axios.post('http://example.com', form, {
|
|
337
|
-
headers: {
|
|
338
|
-
...formHeaders,
|
|
339
|
-
},
|
|
340
|
-
})
|
|
341
|
-
.then(response => response)
|
|
342
|
-
.catch(error => error)
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
## Notes
|
|
346
|
-
|
|
347
|
-
- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround.
|
|
348
|
-
- ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```).
|
|
349
|
-
- ```submit``` will not add `content-length` if form length is unknown or not calculable.
|
|
350
|
-
- Starting version `2.x` FormData has dropped support for `node@0.10.x`.
|
|
351
|
-
- Starting version `3.x` FormData has dropped support for `node@4.x`.
|
|
352
|
-
|
|
353
|
-
## License
|
|
354
|
-
|
|
355
|
-
Form-Data is released under the [MIT](License) license.
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# Path-to-RegExp
|
|
2
|
-
|
|
3
|
-
> Turn a path string such as `/user/:name` into a regular expression.
|
|
4
|
-
|
|
5
|
-
[![NPM version][npm-image]][npm-url]
|
|
6
|
-
[![NPM downloads][downloads-image]][downloads-url]
|
|
7
|
-
[![Build status][build-image]][build-url]
|
|
8
|
-
[![Build coverage][coverage-image]][coverage-url]
|
|
9
|
-
[![License][license-image]][license-url]
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
npm install path-to-regexp --save
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
const {
|
|
21
|
-
match,
|
|
22
|
-
pathToRegexp,
|
|
23
|
-
compile,
|
|
24
|
-
parse,
|
|
25
|
-
stringify,
|
|
26
|
-
} = require("path-to-regexp");
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
### Parameters
|
|
30
|
-
|
|
31
|
-
Parameters match arbitrary strings in a path by matching up to the end of the segment, or up to any proceeding tokens. They are defined by prefixing a colon to the parameter name (`:foo`). Parameter names can use any valid JavaScript identifier, or be double quoted to use other characters (`:"param-name"`).
|
|
32
|
-
|
|
33
|
-
```js
|
|
34
|
-
const fn = match("/:foo/:bar");
|
|
35
|
-
|
|
36
|
-
fn("/test/route");
|
|
37
|
-
//=> { path: '/test/route', params: { foo: 'test', bar: 'route' } }
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Wildcard
|
|
41
|
-
|
|
42
|
-
Wildcard parameters match one or more characters across multiple segments. They are defined the same way as regular parameters, but are prefixed with an asterisk (`*foo`).
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
const fn = match("/*splat");
|
|
46
|
-
|
|
47
|
-
fn("/bar/baz");
|
|
48
|
-
//=> { path: '/bar/baz', params: { splat: [ 'bar', 'baz' ] } }
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Optional
|
|
52
|
-
|
|
53
|
-
Braces can be used to define parts of the path that are optional.
|
|
54
|
-
|
|
55
|
-
```js
|
|
56
|
-
const fn = match("/users{/:id}/delete");
|
|
57
|
-
|
|
58
|
-
fn("/users/delete");
|
|
59
|
-
//=> { path: '/users/delete', params: {} }
|
|
60
|
-
|
|
61
|
-
fn("/users/123/delete");
|
|
62
|
-
//=> { path: '/users/123/delete', params: { id: '123' } }
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Match
|
|
66
|
-
|
|
67
|
-
The `match` function returns a function for matching strings against a path:
|
|
68
|
-
|
|
69
|
-
- **path** String or array of strings.
|
|
70
|
-
- **options** _(optional)_ (Extends [pathToRegexp](#pathToRegexp) options)
|
|
71
|
-
- **decode** Function for decoding strings to params, or `false` to disable all processing. (default: `decodeURIComponent`)
|
|
72
|
-
|
|
73
|
-
```js
|
|
74
|
-
const fn = match("/foo/:bar");
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**Please note:** `path-to-regexp` is intended for ordered data (e.g. paths, hosts). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc).
|
|
78
|
-
|
|
79
|
-
## PathToRegexp
|
|
80
|
-
|
|
81
|
-
The `pathToRegexp` function returns a regular expression for matching strings against paths. It
|
|
82
|
-
|
|
83
|
-
- **path** String or array of strings.
|
|
84
|
-
- **options** _(optional)_ (See [parse](#parse) for more options)
|
|
85
|
-
- **sensitive** Regexp will be case sensitive. (default: `false`)
|
|
86
|
-
- **end** Validate the match reaches the end of the string. (default: `true`)
|
|
87
|
-
- **delimiter** The default delimiter for segments, e.g. `[^/]` for `:named` parameters. (default: `'/'`)
|
|
88
|
-
- **trailing** Allows optional trailing delimiter to match. (default: `true`)
|
|
89
|
-
|
|
90
|
-
```js
|
|
91
|
-
const { regexp, keys } = pathToRegexp("/foo/:bar");
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Compile ("Reverse" Path-To-RegExp)
|
|
95
|
-
|
|
96
|
-
The `compile` function will return a function for transforming parameters into a valid path:
|
|
97
|
-
|
|
98
|
-
- **path** A string.
|
|
99
|
-
- **options** (See [parse](#parse) for more options)
|
|
100
|
-
- **delimiter** The default delimiter for segments, e.g. `[^/]` for `:named` parameters. (default: `'/'`)
|
|
101
|
-
- **encode** Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
const toPath = compile("/user/:id");
|
|
105
|
-
|
|
106
|
-
toPath({ id: "name" }); //=> "/user/name"
|
|
107
|
-
toPath({ id: "café" }); //=> "/user/caf%C3%A9"
|
|
108
|
-
|
|
109
|
-
const toPathRepeated = compile("/*segment");
|
|
110
|
-
|
|
111
|
-
toPathRepeated({ segment: ["foo"] }); //=> "/foo"
|
|
112
|
-
toPathRepeated({ segment: ["a", "b", "c"] }); //=> "/a/b/c"
|
|
113
|
-
|
|
114
|
-
// When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.
|
|
115
|
-
const toPathRaw = compile("/user/:id", { encode: false });
|
|
116
|
-
|
|
117
|
-
toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F"
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Stringify
|
|
121
|
-
|
|
122
|
-
Transform `TokenData` (a sequence of tokens) back into a Path-to-RegExp string.
|
|
123
|
-
|
|
124
|
-
- **data** A `TokenData` instance
|
|
125
|
-
|
|
126
|
-
```js
|
|
127
|
-
const data = new TokenData([
|
|
128
|
-
{ type: "text", value: "/" },
|
|
129
|
-
{ type: "param", name: "foo" },
|
|
130
|
-
]);
|
|
131
|
-
|
|
132
|
-
const path = stringify(data); //=> "/:foo"
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Developers
|
|
136
|
-
|
|
137
|
-
- If you are rewriting paths with match and compile, consider using `encode: false` and `decode: false` to keep raw paths passed around.
|
|
138
|
-
- To ensure matches work on paths containing characters usually encoded, such as emoji, consider using [encodeurl](https://github.com/pillarjs/encodeurl) for `encodePath`.
|
|
139
|
-
|
|
140
|
-
### Parse
|
|
141
|
-
|
|
142
|
-
The `parse` function accepts a string and returns `TokenData`, the set of tokens and other metadata parsed from the input string. `TokenData` is can used with `match` and `compile`.
|
|
143
|
-
|
|
144
|
-
- **path** A string.
|
|
145
|
-
- **options** _(optional)_
|
|
146
|
-
- **encodePath** A function for encoding input strings. (default: `x => x`, recommended: [`encodeurl`](https://github.com/pillarjs/encodeurl))
|
|
147
|
-
|
|
148
|
-
### Tokens
|
|
149
|
-
|
|
150
|
-
`TokenData` is a sequence of tokens, currently of types `text`, `parameter`, `wildcard`, or `group`.
|
|
151
|
-
|
|
152
|
-
### Custom path
|
|
153
|
-
|
|
154
|
-
In some applications, you may not be able to use the `path-to-regexp` syntax, but still want to use this library for `match` and `compile`. For example:
|
|
155
|
-
|
|
156
|
-
```js
|
|
157
|
-
import { TokenData, match } from "path-to-regexp";
|
|
158
|
-
|
|
159
|
-
const tokens = [
|
|
160
|
-
{ type: "text", value: "/" },
|
|
161
|
-
{ type: "parameter", name: "foo" },
|
|
162
|
-
];
|
|
163
|
-
const path = new TokenData(tokens);
|
|
164
|
-
const fn = match(path);
|
|
165
|
-
|
|
166
|
-
fn("/test"); //=> { path: '/test', index: 0, params: { foo: 'test' } }
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Errors
|
|
170
|
-
|
|
171
|
-
An effort has been made to ensure ambiguous paths from previous releases throw an error. This means you might be seeing an error when things worked before.
|
|
172
|
-
|
|
173
|
-
### Unexpected `?` or `+`
|
|
174
|
-
|
|
175
|
-
In past releases, `?`, `*`, and `+` were used to denote optional or repeating parameters. As an alternative, try these:
|
|
176
|
-
|
|
177
|
-
- For optional (`?`), use an empty segment in a group such as `/:file{.:ext}`.
|
|
178
|
-
- For repeating (`+`), only wildcard matching is supported, such as `/*path`.
|
|
179
|
-
- For optional repeating (`*`), use a group and a wildcard parameter such as `/files{/*path}`.
|
|
180
|
-
|
|
181
|
-
### Unexpected `(`, `)`, `[`, `]`, etc.
|
|
182
|
-
|
|
183
|
-
Previous versions of Path-to-RegExp used these for RegExp features. This version no longer supports them so they've been reserved to avoid ambiguity. To use these characters literally, escape them with a backslash, e.g. `"\\("`.
|
|
184
|
-
|
|
185
|
-
### Missing parameter name
|
|
186
|
-
|
|
187
|
-
Parameter names must be provided after `:` or `*`, and they must be a valid JavaScript identifier. If you want an parameter name that isn't a JavaScript identifier, such as starting with a number, you can wrap the name in quotes like `:"my-name"`.
|
|
188
|
-
|
|
189
|
-
### Unterminated quote
|
|
190
|
-
|
|
191
|
-
Parameter names can be wrapped in double quote characters, and this error means you forgot to close the quote character.
|
|
192
|
-
|
|
193
|
-
### Express <= 4.x
|
|
194
|
-
|
|
195
|
-
Path-To-RegExp breaks compatibility with Express <= `4.x` in the following ways:
|
|
196
|
-
|
|
197
|
-
- The wildcard `*` must have a name, matching the behavior of parameters `:`.
|
|
198
|
-
- The optional character `?` is no longer supported, use braces instead: `/:file{.:ext}`.
|
|
199
|
-
- Regexp characters are not supported.
|
|
200
|
-
- Some characters have been reserved to avoid confusion during upgrade (`()[]?+!`).
|
|
201
|
-
- Parameter names now support valid JavaScript identifiers, or quoted like `:"this"`.
|
|
202
|
-
|
|
203
|
-
## License
|
|
204
|
-
|
|
205
|
-
MIT
|
|
206
|
-
|
|
207
|
-
[npm-image]: https://img.shields.io/npm/v/path-to-regexp
|
|
208
|
-
[npm-url]: https://npmjs.org/package/path-to-regexp
|
|
209
|
-
[downloads-image]: https://img.shields.io/npm/dm/path-to-regexp
|
|
210
|
-
[downloads-url]: https://npmjs.org/package/path-to-regexp
|
|
211
|
-
[build-image]: https://img.shields.io/github/actions/workflow/status/pillarjs/path-to-regexp/ci.yml?branch=master
|
|
212
|
-
[build-url]: https://github.com/pillarjs/path-to-regexp/actions/workflows/ci.yml?query=branch%3Amaster
|
|
213
|
-
[coverage-image]: https://img.shields.io/codecov/c/gh/pillarjs/path-to-regexp
|
|
214
|
-
[coverage-url]: https://codecov.io/gh/pillarjs/path-to-regexp
|
|
215
|
-
[license-image]: http://img.shields.io/npm/l/path-to-regexp.svg?style=flat
|
|
216
|
-
[license-url]: LICENSE.md
|