@twin.org/api-processors 0.0.1-next.10
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/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +338 -0
- package/dist/esm/index.mjs +333 -0
- package/dist/types/data/routeProcessor.d.ts +31 -0
- package/dist/types/identity/nodeIdentityProcessor.d.ts +28 -0
- package/dist/types/identity/staticUserIdentityProcessor.d.ts +31 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/logging/loggingProcessor.d.ts +44 -0
- package/dist/types/models/IRequestLoggingProcessorConfig.d.ts +17 -0
- package/dist/types/models/IResponseLoggingProcessorConfig.d.ts +9 -0
- package/dist/types/models/IRouteProcessorConfig.d.ts +9 -0
- package/dist/types/models/IStaticUserIdentityProcessorConfig.d.ts +9 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/LoggingProcessor.md +123 -0
- package/docs/reference/classes/NodeIdentityProcessor.md +95 -0
- package/docs/reference/classes/RouteProcessor.md +81 -0
- package/docs/reference/classes/StaticUserIdentityProcessor.md +81 -0
- package/docs/reference/index.md +15 -0
- package/docs/reference/interfaces/IRequestLoggingProcessorConfig.md +27 -0
- package/docs/reference/interfaces/IResponseLoggingProcessorConfig.md +11 -0
- package/docs/reference/interfaces/IRouteProcessorConfig.md +11 -0
- package/docs/reference/interfaces/IStaticUserIdentityProcessorConfig.md +11 -0
- package/locales/en.json +12 -0
- package/package.json +42 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Class: NodeIdentityProcessor
|
|
2
|
+
|
|
3
|
+
Adds a node identity to the request identity.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IHttpRestRouteProcessor`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new NodeIdentityProcessor()
|
|
12
|
+
|
|
13
|
+
> **new NodeIdentityProcessor**(): [`NodeIdentityProcessor`](NodeIdentityProcessor.md)
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
[`NodeIdentityProcessor`](NodeIdentityProcessor.md)
|
|
18
|
+
|
|
19
|
+
## Properties
|
|
20
|
+
|
|
21
|
+
### CLASS\_NAME
|
|
22
|
+
|
|
23
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
24
|
+
|
|
25
|
+
Runtime name for the class.
|
|
26
|
+
|
|
27
|
+
#### Implementation of
|
|
28
|
+
|
|
29
|
+
`IHttpRestRouteProcessor.CLASS_NAME`
|
|
30
|
+
|
|
31
|
+
## Methods
|
|
32
|
+
|
|
33
|
+
### start()
|
|
34
|
+
|
|
35
|
+
> **start**(`nodeIdentity`, `nodeLoggingConnectorType`?): `Promise`\<`void`\>
|
|
36
|
+
|
|
37
|
+
The service needs to be started when the application is initialized.
|
|
38
|
+
|
|
39
|
+
#### Parameters
|
|
40
|
+
|
|
41
|
+
• **nodeIdentity**: `string`
|
|
42
|
+
|
|
43
|
+
The identity of the node.
|
|
44
|
+
|
|
45
|
+
• **nodeLoggingConnectorType?**: `string`
|
|
46
|
+
|
|
47
|
+
The node logging connector type, defaults to "node-logging".
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
`Promise`\<`void`\>
|
|
52
|
+
|
|
53
|
+
Nothing.
|
|
54
|
+
|
|
55
|
+
#### Implementation of
|
|
56
|
+
|
|
57
|
+
`IHttpRestRouteProcessor.start`
|
|
58
|
+
|
|
59
|
+
***
|
|
60
|
+
|
|
61
|
+
### pre()
|
|
62
|
+
|
|
63
|
+
> **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
64
|
+
|
|
65
|
+
Pre process the REST request for the specified route.
|
|
66
|
+
|
|
67
|
+
#### Parameters
|
|
68
|
+
|
|
69
|
+
• **request**: `IHttpServerRequest`\<`any`\>
|
|
70
|
+
|
|
71
|
+
The incoming request.
|
|
72
|
+
|
|
73
|
+
• **response**: `IHttpResponse`\<`any`\>
|
|
74
|
+
|
|
75
|
+
The outgoing response.
|
|
76
|
+
|
|
77
|
+
• **route**: `undefined` \| `IRestRoute`\<`any`, `any`\>
|
|
78
|
+
|
|
79
|
+
The route to process.
|
|
80
|
+
|
|
81
|
+
• **requestIdentity**: `IHttpRequestIdentity`
|
|
82
|
+
|
|
83
|
+
The identity context for the request.
|
|
84
|
+
|
|
85
|
+
• **processorState**
|
|
86
|
+
|
|
87
|
+
The state handed through the processors.
|
|
88
|
+
|
|
89
|
+
#### Returns
|
|
90
|
+
|
|
91
|
+
`Promise`\<`void`\>
|
|
92
|
+
|
|
93
|
+
#### Implementation of
|
|
94
|
+
|
|
95
|
+
`IHttpRestRouteProcessor.pre`
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Class: RouteProcessor
|
|
2
|
+
|
|
3
|
+
Process the REST request and hands it on to the route handler.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IHttpRestRouteProcessor`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new RouteProcessor()
|
|
12
|
+
|
|
13
|
+
> **new RouteProcessor**(`options`?): [`RouteProcessor`](RouteProcessor.md)
|
|
14
|
+
|
|
15
|
+
Create a new instance of RouteProcessor.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **options?**
|
|
20
|
+
|
|
21
|
+
Options for the processor.
|
|
22
|
+
|
|
23
|
+
• **options.config?**: [`IRouteProcessorConfig`](../interfaces/IRouteProcessorConfig.md)
|
|
24
|
+
|
|
25
|
+
The configuration for the processor.
|
|
26
|
+
|
|
27
|
+
#### Returns
|
|
28
|
+
|
|
29
|
+
[`RouteProcessor`](RouteProcessor.md)
|
|
30
|
+
|
|
31
|
+
Promise that resolves when the processor is initialized.
|
|
32
|
+
|
|
33
|
+
## Properties
|
|
34
|
+
|
|
35
|
+
### CLASS\_NAME
|
|
36
|
+
|
|
37
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
38
|
+
|
|
39
|
+
Runtime name for the class.
|
|
40
|
+
|
|
41
|
+
#### Implementation of
|
|
42
|
+
|
|
43
|
+
`IHttpRestRouteProcessor.CLASS_NAME`
|
|
44
|
+
|
|
45
|
+
## Methods
|
|
46
|
+
|
|
47
|
+
### process()
|
|
48
|
+
|
|
49
|
+
> **process**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
50
|
+
|
|
51
|
+
Process the REST request for the specified route.
|
|
52
|
+
|
|
53
|
+
#### Parameters
|
|
54
|
+
|
|
55
|
+
• **request**: `IHttpServerRequest`\<`any`\>
|
|
56
|
+
|
|
57
|
+
The incoming request.
|
|
58
|
+
|
|
59
|
+
• **response**: `IHttpResponse`\<`any`\>
|
|
60
|
+
|
|
61
|
+
The outgoing response.
|
|
62
|
+
|
|
63
|
+
• **route**: `undefined` \| `IRestRoute`\<`any`, `any`\>
|
|
64
|
+
|
|
65
|
+
The route to process.
|
|
66
|
+
|
|
67
|
+
• **requestIdentity**: `IHttpRequestIdentity`
|
|
68
|
+
|
|
69
|
+
The identity context for the request.
|
|
70
|
+
|
|
71
|
+
• **processorState**
|
|
72
|
+
|
|
73
|
+
The state handed through the processors.
|
|
74
|
+
|
|
75
|
+
#### Returns
|
|
76
|
+
|
|
77
|
+
`Promise`\<`void`\>
|
|
78
|
+
|
|
79
|
+
#### Implementation of
|
|
80
|
+
|
|
81
|
+
`IHttpRestRouteProcessor.process`
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Class: StaticUserIdentityProcessor
|
|
2
|
+
|
|
3
|
+
Adds a static user identity to the request context.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IHttpRestRouteProcessor`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### new StaticUserIdentityProcessor()
|
|
12
|
+
|
|
13
|
+
> **new StaticUserIdentityProcessor**(`options`): [`StaticUserIdentityProcessor`](StaticUserIdentityProcessor.md)
|
|
14
|
+
|
|
15
|
+
Create a new instance of StaticIdentityProcessor.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **options**
|
|
20
|
+
|
|
21
|
+
Options for the processor.
|
|
22
|
+
|
|
23
|
+
• **options.config**: [`IStaticUserIdentityProcessorConfig`](../interfaces/IStaticUserIdentityProcessorConfig.md)
|
|
24
|
+
|
|
25
|
+
The configuration for the processor.
|
|
26
|
+
|
|
27
|
+
#### Returns
|
|
28
|
+
|
|
29
|
+
[`StaticUserIdentityProcessor`](StaticUserIdentityProcessor.md)
|
|
30
|
+
|
|
31
|
+
Promise that resolves when the processor is initialized.
|
|
32
|
+
|
|
33
|
+
## Properties
|
|
34
|
+
|
|
35
|
+
### CLASS\_NAME
|
|
36
|
+
|
|
37
|
+
> `readonly` **CLASS\_NAME**: `string`
|
|
38
|
+
|
|
39
|
+
Runtime name for the class.
|
|
40
|
+
|
|
41
|
+
#### Implementation of
|
|
42
|
+
|
|
43
|
+
`IHttpRestRouteProcessor.CLASS_NAME`
|
|
44
|
+
|
|
45
|
+
## Methods
|
|
46
|
+
|
|
47
|
+
### pre()
|
|
48
|
+
|
|
49
|
+
> **pre**(`request`, `response`, `route`, `requestIdentity`, `processorState`): `Promise`\<`void`\>
|
|
50
|
+
|
|
51
|
+
Pre process the REST request for the specified route.
|
|
52
|
+
|
|
53
|
+
#### Parameters
|
|
54
|
+
|
|
55
|
+
• **request**: `IHttpServerRequest`\<`any`\>
|
|
56
|
+
|
|
57
|
+
The incoming request.
|
|
58
|
+
|
|
59
|
+
• **response**: `IHttpResponse`\<`any`\>
|
|
60
|
+
|
|
61
|
+
The outgoing response.
|
|
62
|
+
|
|
63
|
+
• **route**: `undefined` \| `IRestRoute`\<`any`, `any`\>
|
|
64
|
+
|
|
65
|
+
The route to process.
|
|
66
|
+
|
|
67
|
+
• **requestIdentity**: `IHttpRequestIdentity`
|
|
68
|
+
|
|
69
|
+
The identity context for the request.
|
|
70
|
+
|
|
71
|
+
• **processorState**
|
|
72
|
+
|
|
73
|
+
The state handed through the processors.
|
|
74
|
+
|
|
75
|
+
#### Returns
|
|
76
|
+
|
|
77
|
+
`Promise`\<`void`\>
|
|
78
|
+
|
|
79
|
+
#### Implementation of
|
|
80
|
+
|
|
81
|
+
`IHttpRestRouteProcessor.pre`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @twin.org/api-processors
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [RouteProcessor](classes/RouteProcessor.md)
|
|
6
|
+
- [NodeIdentityProcessor](classes/NodeIdentityProcessor.md)
|
|
7
|
+
- [StaticUserIdentityProcessor](classes/StaticUserIdentityProcessor.md)
|
|
8
|
+
- [LoggingProcessor](classes/LoggingProcessor.md)
|
|
9
|
+
|
|
10
|
+
## Interfaces
|
|
11
|
+
|
|
12
|
+
- [IRequestLoggingProcessorConfig](interfaces/IRequestLoggingProcessorConfig.md)
|
|
13
|
+
- [IResponseLoggingProcessorConfig](interfaces/IResponseLoggingProcessorConfig.md)
|
|
14
|
+
- [IRouteProcessorConfig](interfaces/IRouteProcessorConfig.md)
|
|
15
|
+
- [IStaticUserIdentityProcessorConfig](interfaces/IStaticUserIdentityProcessorConfig.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IRequestLoggingProcessorConfig
|
|
2
|
+
|
|
3
|
+
Configuration for the request logging processor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### includeBody?
|
|
8
|
+
|
|
9
|
+
> `optional` **includeBody**: `boolean`
|
|
10
|
+
|
|
11
|
+
Include the body objects when logging the information.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### fullBase64?
|
|
16
|
+
|
|
17
|
+
> `optional` **fullBase64**: `boolean`
|
|
18
|
+
|
|
19
|
+
Show the full base64 content for data, default to abbreviate.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### obfuscateProperties?
|
|
24
|
+
|
|
25
|
+
> `optional` **obfuscateProperties**: `string`[]
|
|
26
|
+
|
|
27
|
+
List of property names to obfuscate, can be regex, defaults to "password".
|
package/locales/en.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"error": {
|
|
3
|
+
"routeProcessor": {
|
|
4
|
+
"routeNotFound": "The web server could not find the route \"{notFoundId}\""
|
|
5
|
+
},
|
|
6
|
+
"jwtIdentityProcessor": {
|
|
7
|
+
"jwtMissing": "The JSON Web token could not be found in the authorization header or a cookie",
|
|
8
|
+
"jwtSignatureInvalid": "The JSON Web token signature could not be validated",
|
|
9
|
+
"jwtExpired": "The JSON Web token has expired"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twin.org/api-processors",
|
|
3
|
+
"version": "0.0.1-next.10",
|
|
4
|
+
"description": "Route processors for use with API servers",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/twinfoundation/api.git",
|
|
8
|
+
"directory": "packages/api-processors"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@twin.org/api-models": "0.0.1-next.10",
|
|
18
|
+
"@twin.org/core": "next",
|
|
19
|
+
"@twin.org/entity": "next",
|
|
20
|
+
"@twin.org/entity-storage-models": "next",
|
|
21
|
+
"@twin.org/logging-models": "next",
|
|
22
|
+
"@twin.org/nameof": "next",
|
|
23
|
+
"@twin.org/web": "next"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/cjs/index.cjs",
|
|
26
|
+
"module": "./dist/esm/index.mjs",
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"require": "./dist/cjs/index.cjs",
|
|
31
|
+
"import": "./dist/esm/index.mjs",
|
|
32
|
+
"types": "./dist/types/index.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/cjs",
|
|
37
|
+
"dist/esm",
|
|
38
|
+
"dist/types",
|
|
39
|
+
"locales",
|
|
40
|
+
"docs"
|
|
41
|
+
]
|
|
42
|
+
}
|