@contrast/agent-bundle 5.39.0 → 5.40.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 +10 -10
- package/node_modules/@contrast/agentify/lib/sources.js +1 -0
- package/node_modules/@contrast/agentify/package.json +14 -14
- package/node_modules/@contrast/architecture-components/package.json +5 -5
- package/node_modules/@contrast/assess/lib/crypto-analysis/install/math.js +1 -0
- package/node_modules/@contrast/assess/lib/dataflow/propagation/install/string/replace.js +6 -3
- 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} +1 -1
- package/node_modules/@contrast/assess/package.json +11 -11
- package/node_modules/@contrast/common/lib/constants.d.ts +16 -0
- package/node_modules/@contrast/common/lib/constants.js +22 -1
- package/node_modules/@contrast/common/lib/index.d.ts +1 -0
- package/node_modules/@contrast/common/lib/index.js +12 -2
- package/node_modules/@contrast/common/package.json +1 -1
- package/node_modules/@contrast/config/lib/index.d.ts +1 -0
- package/node_modules/@contrast/config/package.json +3 -3
- package/node_modules/@contrast/core/package.json +5 -5
- 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/package.json +5 -5
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +155 -150
- 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/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/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/package.json +11 -11
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/routes-observed.js +2 -1
- package/node_modules/@contrast/reporter/package.json +6 -6
- package/node_modules/@contrast/rewriter/package.json +5 -5
- package/node_modules/@contrast/route-coverage/lib/index.d.ts +2 -0
- package/node_modules/@contrast/route-coverage/lib/index.js +14 -8
- package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +491 -202
- package/node_modules/@contrast/route-coverage/package.json +9 -9
- package/node_modules/@contrast/scopes/package.json +5 -5
- package/node_modules/@contrast/telemetry/package.json +5 -5
- package/node_modules/@types/node/README.md +1 -1
- 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/package.json +2 -2
- package/node_modules/@types/node/stream/web.d.ts +4 -0
- package/node_modules/@types/node/test.d.ts +1905 -2009
- package/package.json +2 -2
- package/node_modules/@contrast/route-coverage/lib/install/http.js +0 -44
- package/node_modules/path-to-regexp/LICENSE +0 -21
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/agent-bundle",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.40.0",
|
|
4
4
|
"description": "Contrast Security Node.js Agent bundle with all dependencies included",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "bash ../scripts/test.sh"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@contrast/agent": "5.
|
|
29
|
+
"@contrast/agent": "5.40.0"
|
|
30
30
|
},
|
|
31
31
|
"bundleDependencies": [
|
|
32
32
|
"@contrast/agent"
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright: 2025 Contrast Security, Inc
|
|
3
|
-
* Contact: support@contrastsecurity.com
|
|
4
|
-
* License: Commercial
|
|
5
|
-
|
|
6
|
-
* NOTICE: This Software and the patented inventions embodied within may only be
|
|
7
|
-
* used as part of Contrast Security’s commercial offerings. Even though it is
|
|
8
|
-
* made available through public repositories, use of this Software is subject to
|
|
9
|
-
* the applicable End User Licensing Agreement found at
|
|
10
|
-
* https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
|
|
11
|
-
* between Contrast Security and the End User. The Software may not be reverse
|
|
12
|
-
* engineered, modified, repackaged, sold, redistributed or otherwise used in a
|
|
13
|
-
* way not consistent with the End User License Agreement.
|
|
14
|
-
*/
|
|
15
|
-
'use strict';
|
|
16
|
-
|
|
17
|
-
module.exports = function init(core) {
|
|
18
|
-
const { depHooks, patcher, routeCoverage } = core;
|
|
19
|
-
|
|
20
|
-
let handled;
|
|
21
|
-
|
|
22
|
-
return core.routeCoverage.http = {
|
|
23
|
-
install() {
|
|
24
|
-
[['http', '*'], ['https', '*'], ['spdy', '<5']].forEach(([name, version]) => {
|
|
25
|
-
depHooks.resolve({ name, version }, (_export) => {
|
|
26
|
-
if (!_export?.Server?.prototype) return;
|
|
27
|
-
|
|
28
|
-
patcher.patch(_export.Server.prototype, 'listen', {
|
|
29
|
-
name: `${name}.Server.prototype.listen`,
|
|
30
|
-
patchType: 'route-coverage',
|
|
31
|
-
post(data) {
|
|
32
|
-
data.result?.on('listening', () => {
|
|
33
|
-
if (!handled) {
|
|
34
|
-
handled = true;
|
|
35
|
-
routeCoverage.discoveryFinished();
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|
|
@@ -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
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encode a string into another string.
|
|
3
|
-
*/
|
|
4
|
-
export type Encode = (value: string) => string;
|
|
5
|
-
/**
|
|
6
|
-
* Decode a string into another string.
|
|
7
|
-
*/
|
|
8
|
-
export type Decode = (value: string) => string;
|
|
9
|
-
export interface ParseOptions {
|
|
10
|
-
/**
|
|
11
|
-
* A function for encoding input strings.
|
|
12
|
-
*/
|
|
13
|
-
encodePath?: Encode;
|
|
14
|
-
}
|
|
15
|
-
export interface PathToRegexpOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Matches the path completely without trailing characters. (default: `true`)
|
|
18
|
-
*/
|
|
19
|
-
end?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Allows optional trailing delimiter to match. (default: `true`)
|
|
22
|
-
*/
|
|
23
|
-
trailing?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Match will be case sensitive. (default: `false`)
|
|
26
|
-
*/
|
|
27
|
-
sensitive?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* The default delimiter for segments. (default: `'/'`)
|
|
30
|
-
*/
|
|
31
|
-
delimiter?: string;
|
|
32
|
-
}
|
|
33
|
-
export interface MatchOptions extends PathToRegexpOptions {
|
|
34
|
-
/**
|
|
35
|
-
* Function for decoding strings for params, or `false` to disable entirely. (default: `decodeURIComponent`)
|
|
36
|
-
*/
|
|
37
|
-
decode?: Decode | false;
|
|
38
|
-
}
|
|
39
|
-
export interface CompileOptions {
|
|
40
|
-
/**
|
|
41
|
-
* Function for encoding input strings for output into the path, or `false` to disable entirely. (default: `encodeURIComponent`)
|
|
42
|
-
*/
|
|
43
|
-
encode?: Encode | false;
|
|
44
|
-
/**
|
|
45
|
-
* The default delimiter for segments. (default: `'/'`)
|
|
46
|
-
*/
|
|
47
|
-
delimiter?: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Plain text.
|
|
51
|
-
*/
|
|
52
|
-
export interface Text {
|
|
53
|
-
type: "text";
|
|
54
|
-
value: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* A parameter designed to match arbitrary text within a segment.
|
|
58
|
-
*/
|
|
59
|
-
export interface Parameter {
|
|
60
|
-
type: "param";
|
|
61
|
-
name: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A wildcard parameter designed to match multiple segments.
|
|
65
|
-
*/
|
|
66
|
-
export interface Wildcard {
|
|
67
|
-
type: "wildcard";
|
|
68
|
-
name: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* A set of possible tokens to expand when matching.
|
|
72
|
-
*/
|
|
73
|
-
export interface Group {
|
|
74
|
-
type: "group";
|
|
75
|
-
tokens: Token[];
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* A token that corresponds with a regexp capture.
|
|
79
|
-
*/
|
|
80
|
-
export type Key = Parameter | Wildcard;
|
|
81
|
-
/**
|
|
82
|
-
* A sequence of `path-to-regexp` keys that match capturing groups.
|
|
83
|
-
*/
|
|
84
|
-
export type Keys = Array<Key>;
|
|
85
|
-
/**
|
|
86
|
-
* A sequence of path match characters.
|
|
87
|
-
*/
|
|
88
|
-
export type Token = Text | Parameter | Wildcard | Group;
|
|
89
|
-
/**
|
|
90
|
-
* Tokenized path instance.
|
|
91
|
-
*/
|
|
92
|
-
export declare class TokenData {
|
|
93
|
-
readonly tokens: Token[];
|
|
94
|
-
constructor(tokens: Token[]);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Parse a string for the raw tokens.
|
|
98
|
-
*/
|
|
99
|
-
export declare function parse(str: string, options?: ParseOptions): TokenData;
|
|
100
|
-
/**
|
|
101
|
-
* Compile a string to a template function for the path.
|
|
102
|
-
*/
|
|
103
|
-
export declare function compile<P extends ParamData = ParamData>(path: Path, options?: CompileOptions & ParseOptions): (data?: P) => string;
|
|
104
|
-
export type ParamData = Partial<Record<string, string | string[]>>;
|
|
105
|
-
export type PathFunction<P extends ParamData> = (data?: P) => string;
|
|
106
|
-
/**
|
|
107
|
-
* A match result contains data about the path match.
|
|
108
|
-
*/
|
|
109
|
-
export interface MatchResult<P extends ParamData> {
|
|
110
|
-
path: string;
|
|
111
|
-
params: P;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* A match is either `false` (no match) or a match result.
|
|
115
|
-
*/
|
|
116
|
-
export type Match<P extends ParamData> = false | MatchResult<P>;
|
|
117
|
-
/**
|
|
118
|
-
* The match function takes a string and returns whether it matched the path.
|
|
119
|
-
*/
|
|
120
|
-
export type MatchFunction<P extends ParamData> = (path: string) => Match<P>;
|
|
121
|
-
/**
|
|
122
|
-
* Supported path types.
|
|
123
|
-
*/
|
|
124
|
-
export type Path = string | TokenData;
|
|
125
|
-
/**
|
|
126
|
-
* Transform a path into a match function.
|
|
127
|
-
*/
|
|
128
|
-
export declare function match<P extends ParamData>(path: Path | Path[], options?: MatchOptions & ParseOptions): MatchFunction<P>;
|
|
129
|
-
export declare function pathToRegexp(path: Path | Path[], options?: PathToRegexpOptions & ParseOptions): {
|
|
130
|
-
regexp: RegExp;
|
|
131
|
-
keys: Keys;
|
|
132
|
-
};
|
|
133
|
-
/**
|
|
134
|
-
* Stringify token data into a path string.
|
|
135
|
-
*/
|
|
136
|
-
export declare function stringify(data: TokenData): string;
|