@rapidrest/core 1.3.0 → 1.3.2
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/dist/lib/ClassLoader.js +3 -2
- package/dist/lib/ClassLoader.js.map +1 -1
- package/dist/lib/JWTUtils.js +1 -0
- package/dist/lib/JWTUtils.js.map +1 -1
- package/dist/lib/StringUtils.js +3 -3
- package/dist/types/JWTUtils.d.ts +1 -0
- package/dist/types/StringUtils.d.ts +3 -3
- package/package.json +2 -7
- package/docs/Makefile +0 -20
- package/docs/conf.py +0 -58
- package/docs/index.rst +0 -17
- package/docs/make.bat +0 -35
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/README.md +0 -21
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Config.md +0 -33
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Destroy.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Init.md +0 -33
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Inject.md +0 -33
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Logger.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Nullable.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/functions/Validator.md +0 -25
- package/docs/reference/@rapidrest/namespaces/ObjectDecorators/type-aliases/ValidatorFunction.md +0 -31
- package/docs/reference/README.md +0 -35
- package/docs/reference/classes/AlertUtils.md +0 -158
- package/docs/reference/classes/ApiError.md +0 -251
- package/docs/reference/classes/ClassLoader.md +0 -224
- package/docs/reference/classes/Event.md +0 -109
- package/docs/reference/classes/EventUtils.md +0 -123
- package/docs/reference/classes/FileUtils.md +0 -193
- package/docs/reference/classes/JWTUtils.md +0 -139
- package/docs/reference/classes/MessagingUtils.md +0 -167
- package/docs/reference/classes/OASUtils.md +0 -227
- package/docs/reference/classes/ObjectFactory.md +0 -276
- package/docs/reference/classes/ObjectUtils.md +0 -60
- package/docs/reference/classes/StringUtils.md +0 -169
- package/docs/reference/classes/ThreadPool.md +0 -249
- package/docs/reference/classes/ThreadWorker.md +0 -91
- package/docs/reference/classes/UserUtils.md +0 -185
- package/docs/reference/classes/ValidationUtils.md +0 -294
- package/docs/reference/enumerations/AlertPriority.md +0 -61
- package/docs/reference/enumerations/JWTUtilsCompressionMethods.md +0 -21
- package/docs/reference/enumerations/WorkerMessageType.md +0 -43
- package/docs/reference/functions/sleep.md +0 -25
- package/docs/reference/globals.md +0 -73
- package/docs/reference/interfaces/Alert.md +0 -101
- package/docs/reference/interfaces/AlertAttachment.md +0 -51
- package/docs/reference/interfaces/AlertClose.md +0 -31
- package/docs/reference/interfaces/AlertUtilsAttachmentOptions.md +0 -42
- package/docs/reference/interfaces/AlertUtilsOptions.md +0 -41
- package/docs/reference/interfaces/InstanceOptions.md +0 -41
- package/docs/reference/interfaces/JWTPayload.md +0 -143
- package/docs/reference/interfaces/JWTUser.md +0 -55
- package/docs/reference/interfaces/JWTUtilsConfig.md +0 -45
- package/docs/reference/interfaces/JWTUtilsPayloadKeyOptions.md +0 -68
- package/docs/reference/interfaces/JWTUtilsPayloadOptions.md +0 -40
- package/docs/reference/interfaces/JWTUtilsPayloadPasswordOptions.md +0 -78
- package/docs/reference/interfaces/NewEvent.md +0 -25
- package/docs/reference/interfaces/OriginSettings.md +0 -25
- package/docs/reference/interfaces/SlackConfig.md +0 -33
- package/docs/reference/interfaces/SmtpAuth.md +0 -25
- package/docs/reference/interfaces/SmtpConfig.md +0 -41
- package/docs/reference/interfaces/Template.md +0 -105
- package/docs/reference/interfaces/TemplateMapBase.md +0 -13
- package/docs/reference/interfaces/TwilioConfig.md +0 -33
- package/docs/reference/interfaces/WorkerMessage.md +0 -31
- package/docs/reference/interfaces/WorkerOptions.md +0 -61
- package/docs/reference/type-aliases/BooleanFunc.md +0 -23
- package/docs/reference/type-aliases/TemplateMap.md +0 -17
- package/docs/reference/type-aliases/WorkerCallback.md +0 -31
- package/docs/reference/variables/Logger.md +0 -25
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / Event
|
|
6
|
-
|
|
7
|
-
# Class: Event
|
|
8
|
-
|
|
9
|
-
Defined in: [src/TelemetryUtils.ts:23](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L23)
|
|
10
|
-
|
|
11
|
-
Describes a single telemetry event. A telemetry event is when something occurs in the system.
|
|
12
|
-
|
|
13
|
-
## Author
|
|
14
|
-
|
|
15
|
-
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
16
|
-
|
|
17
|
-
## Implements
|
|
18
|
-
|
|
19
|
-
- [`NewEvent`](../interfaces/NewEvent.md)
|
|
20
|
-
|
|
21
|
-
## Constructors
|
|
22
|
-
|
|
23
|
-
### Constructor
|
|
24
|
-
|
|
25
|
-
> **new Event**(`config`, `userId`, `data`): `Event`
|
|
26
|
-
|
|
27
|
-
Defined in: [src/TelemetryUtils.ts:54](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L54)
|
|
28
|
-
|
|
29
|
-
#### Parameters
|
|
30
|
-
|
|
31
|
-
##### config
|
|
32
|
-
|
|
33
|
-
`any`
|
|
34
|
-
|
|
35
|
-
##### userId
|
|
36
|
-
|
|
37
|
-
`string`
|
|
38
|
-
|
|
39
|
-
##### data
|
|
40
|
-
|
|
41
|
-
[`NewEvent`](../interfaces/NewEvent.md)
|
|
42
|
-
|
|
43
|
-
#### Returns
|
|
44
|
-
|
|
45
|
-
`Event`
|
|
46
|
-
|
|
47
|
-
## Properties
|
|
48
|
-
|
|
49
|
-
### environment
|
|
50
|
-
|
|
51
|
-
> `readonly` **environment**: `string`
|
|
52
|
-
|
|
53
|
-
Defined in: [src/TelemetryUtils.ts:32](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L32)
|
|
54
|
-
|
|
55
|
-
The name of the environment that the event originated from. This is typically `dev` or `prod`.
|
|
56
|
-
|
|
57
|
-
***
|
|
58
|
-
|
|
59
|
-
### origin
|
|
60
|
-
|
|
61
|
-
> `readonly` **origin**: `string`
|
|
62
|
-
|
|
63
|
-
Defined in: [src/TelemetryUtils.ts:37](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L37)
|
|
64
|
-
|
|
65
|
-
The unique name of the service or client that the event originated from.
|
|
66
|
-
|
|
67
|
-
***
|
|
68
|
-
|
|
69
|
-
### timestamp
|
|
70
|
-
|
|
71
|
-
> `readonly` **timestamp**: `Date`
|
|
72
|
-
|
|
73
|
-
Defined in: [src/TelemetryUtils.ts:42](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L42)
|
|
74
|
-
|
|
75
|
-
The date and time that the event occured.
|
|
76
|
-
|
|
77
|
-
***
|
|
78
|
-
|
|
79
|
-
### type
|
|
80
|
-
|
|
81
|
-
> `readonly` **type**: `string`
|
|
82
|
-
|
|
83
|
-
Defined in: [src/TelemetryUtils.ts:47](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L47)
|
|
84
|
-
|
|
85
|
-
The type of event being recorded.
|
|
86
|
-
|
|
87
|
-
#### Implementation of
|
|
88
|
-
|
|
89
|
-
[`NewEvent`](../interfaces/NewEvent.md).[`type`](../interfaces/NewEvent.md#type)
|
|
90
|
-
|
|
91
|
-
***
|
|
92
|
-
|
|
93
|
-
### uid
|
|
94
|
-
|
|
95
|
-
> `readonly` **uid**: `string`
|
|
96
|
-
|
|
97
|
-
Defined in: [src/TelemetryUtils.ts:27](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L27)
|
|
98
|
-
|
|
99
|
-
The universally unique identifier of the event.
|
|
100
|
-
|
|
101
|
-
***
|
|
102
|
-
|
|
103
|
-
### userId
|
|
104
|
-
|
|
105
|
-
> `readonly` **userId**: `string`
|
|
106
|
-
|
|
107
|
-
Defined in: [src/TelemetryUtils.ts:52](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L52)
|
|
108
|
-
|
|
109
|
-
The universally unique identifer of the user that sent the event.
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / EventUtils
|
|
6
|
-
|
|
7
|
-
# Class: EventUtils
|
|
8
|
-
|
|
9
|
-
Defined in: [src/TelemetryUtils.ts:84](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L84)
|
|
10
|
-
|
|
11
|
-
Provides a common set of static functions for recording and working with telemetry `Event` instances.
|
|
12
|
-
|
|
13
|
-
The `init` function must be called before any other function can be called.
|
|
14
|
-
|
|
15
|
-
The `record` function is used to send an event to a configured `telemetry_services` service for permanent storage.
|
|
16
|
-
|
|
17
|
-
The `on` function allows code within the same application or service to listen for outgoing events that have been
|
|
18
|
-
sent via the `record` function.
|
|
19
|
-
|
|
20
|
-
## Author
|
|
21
|
-
|
|
22
|
-
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
23
|
-
|
|
24
|
-
## Constructors
|
|
25
|
-
|
|
26
|
-
### Constructor
|
|
27
|
-
|
|
28
|
-
> **new EventUtils**(): `EventUtils`
|
|
29
|
-
|
|
30
|
-
#### Returns
|
|
31
|
-
|
|
32
|
-
`EventUtils`
|
|
33
|
-
|
|
34
|
-
## Methods
|
|
35
|
-
|
|
36
|
-
### init()
|
|
37
|
-
|
|
38
|
-
> `static` **init**(`config`, `logger`, `jwtToken`): `Promise`\<`void`\>
|
|
39
|
-
|
|
40
|
-
Defined in: [src/TelemetryUtils.ts:99](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L99)
|
|
41
|
-
|
|
42
|
-
Initializes `EventUtils` with the provided defaults.
|
|
43
|
-
|
|
44
|
-
#### Parameters
|
|
45
|
-
|
|
46
|
-
##### config
|
|
47
|
-
|
|
48
|
-
`any`
|
|
49
|
-
|
|
50
|
-
The application configuration to use.
|
|
51
|
-
|
|
52
|
-
##### logger
|
|
53
|
-
|
|
54
|
-
`any`
|
|
55
|
-
|
|
56
|
-
The logging utility to use.
|
|
57
|
-
|
|
58
|
-
##### jwtToken
|
|
59
|
-
|
|
60
|
-
`string`
|
|
61
|
-
|
|
62
|
-
The user's JWT token to send telemetry events on behalf of.
|
|
63
|
-
|
|
64
|
-
#### Returns
|
|
65
|
-
|
|
66
|
-
`Promise`\<`void`\>
|
|
67
|
-
|
|
68
|
-
***
|
|
69
|
-
|
|
70
|
-
### on()
|
|
71
|
-
|
|
72
|
-
> `static` **on**(`type`, `callback`): `void`
|
|
73
|
-
|
|
74
|
-
Defined in: [src/TelemetryUtils.ts:173](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L173)
|
|
75
|
-
|
|
76
|
-
Registers a `callback` function to receive notifications of recorded events of the given `type`. Note that only
|
|
77
|
-
events originating from the same application or service will be notified.
|
|
78
|
-
|
|
79
|
-
#### Parameters
|
|
80
|
-
|
|
81
|
-
##### type
|
|
82
|
-
|
|
83
|
-
`string`
|
|
84
|
-
|
|
85
|
-
The type of event to be notified of.
|
|
86
|
-
|
|
87
|
-
##### callback
|
|
88
|
-
|
|
89
|
-
`Function`
|
|
90
|
-
|
|
91
|
-
The function to call when an event is recorded.
|
|
92
|
-
|
|
93
|
-
#### Returns
|
|
94
|
-
|
|
95
|
-
`void`
|
|
96
|
-
|
|
97
|
-
***
|
|
98
|
-
|
|
99
|
-
### record()
|
|
100
|
-
|
|
101
|
-
> `static` **record**(`evt`, `type?`): `Promise`\<`void`\>
|
|
102
|
-
|
|
103
|
-
Defined in: [src/TelemetryUtils.ts:118](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/TelemetryUtils.ts#L118)
|
|
104
|
-
|
|
105
|
-
Sends the given event to the telemetry service for permanent recording.
|
|
106
|
-
|
|
107
|
-
#### Parameters
|
|
108
|
-
|
|
109
|
-
##### evt
|
|
110
|
-
|
|
111
|
-
`any`
|
|
112
|
-
|
|
113
|
-
The event to send and record.
|
|
114
|
-
|
|
115
|
-
##### type?
|
|
116
|
-
|
|
117
|
-
`string`
|
|
118
|
-
|
|
119
|
-
The type of event to record. Overrides any `type` value set in `evt`.
|
|
120
|
-
|
|
121
|
-
#### Returns
|
|
122
|
-
|
|
123
|
-
`Promise`\<`void`\>
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / FileUtils
|
|
6
|
-
|
|
7
|
-
# Class: FileUtils
|
|
8
|
-
|
|
9
|
-
Defined in: [src/FileUtils.ts:17](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/FileUtils.ts#L17)
|
|
10
|
-
|
|
11
|
-
Utility functions for working with files.
|
|
12
|
-
|
|
13
|
-
## Author
|
|
14
|
-
|
|
15
|
-
Jean-Philippe Steinmetz
|
|
16
|
-
|
|
17
|
-
## Constructors
|
|
18
|
-
|
|
19
|
-
### Constructor
|
|
20
|
-
|
|
21
|
-
> **new FileUtils**(): `FileUtils`
|
|
22
|
-
|
|
23
|
-
#### Returns
|
|
24
|
-
|
|
25
|
-
`FileUtils`
|
|
26
|
-
|
|
27
|
-
## Methods
|
|
28
|
-
|
|
29
|
-
### copyBinaryFile()
|
|
30
|
-
|
|
31
|
-
> `static` **copyBinaryFile**(`srcPath`, `outPath`, `variables?`): `Promise`\<`void`\>
|
|
32
|
-
|
|
33
|
-
Defined in: [src/FileUtils.ts:159](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/FileUtils.ts#L159)
|
|
34
|
-
|
|
35
|
-
Generates a copy of the source file at the desired output destination using binary copy mode.
|
|
36
|
-
|
|
37
|
-
#### Parameters
|
|
38
|
-
|
|
39
|
-
##### srcPath
|
|
40
|
-
|
|
41
|
-
`string`
|
|
42
|
-
|
|
43
|
-
The source file to copy.
|
|
44
|
-
|
|
45
|
-
##### outPath
|
|
46
|
-
|
|
47
|
-
`string`
|
|
48
|
-
|
|
49
|
-
The destination file to generate.
|
|
50
|
-
|
|
51
|
-
##### variables?
|
|
52
|
-
|
|
53
|
-
`any` = `{}`
|
|
54
|
-
|
|
55
|
-
The map of variable names to values to swap. Applies to outPath only.
|
|
56
|
-
|
|
57
|
-
#### Returns
|
|
58
|
-
|
|
59
|
-
`Promise`\<`void`\>
|
|
60
|
-
|
|
61
|
-
***
|
|
62
|
-
|
|
63
|
-
### copyDirectory()
|
|
64
|
-
|
|
65
|
-
> `static` **copyDirectory**(`srcPath`, `outPath`, `vars?`, `excludeFilters?`, `binaryFilters?`, `force?`): `Promise`\<`void`\>
|
|
66
|
-
|
|
67
|
-
Defined in: [src/FileUtils.ts:187](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/FileUtils.ts#L187)
|
|
68
|
-
|
|
69
|
-
Performs a deep copy of a directory tree at the given srcPath to the specified output directory. Performs
|
|
70
|
-
template replacement for all variables given and skips any files in the specified filter.
|
|
71
|
-
|
|
72
|
-
#### Parameters
|
|
73
|
-
|
|
74
|
-
##### srcPath
|
|
75
|
-
|
|
76
|
-
`string`
|
|
77
|
-
|
|
78
|
-
The path to the source directory to copy files from.
|
|
79
|
-
|
|
80
|
-
##### outPath
|
|
81
|
-
|
|
82
|
-
`string`
|
|
83
|
-
|
|
84
|
-
The path to the destination directory to copy files to.
|
|
85
|
-
|
|
86
|
-
##### vars?
|
|
87
|
-
|
|
88
|
-
`any` = `{}`
|
|
89
|
-
|
|
90
|
-
The map of template variables to perform replacement on.
|
|
91
|
-
|
|
92
|
-
##### excludeFilters?
|
|
93
|
-
|
|
94
|
-
`string`[] = `[]`
|
|
95
|
-
|
|
96
|
-
The list of file extension filters to exclude during the copy process.
|
|
97
|
-
|
|
98
|
-
##### binaryFilters?
|
|
99
|
-
|
|
100
|
-
`string`[] = `[]`
|
|
101
|
-
|
|
102
|
-
The list of file extension filters to copy as binary only.
|
|
103
|
-
|
|
104
|
-
##### force?
|
|
105
|
-
|
|
106
|
-
`boolean` = `false`
|
|
107
|
-
|
|
108
|
-
Set to `true` to force writing over any existing files.
|
|
109
|
-
|
|
110
|
-
#### Returns
|
|
111
|
-
|
|
112
|
-
`Promise`\<`void`\>
|
|
113
|
-
|
|
114
|
-
***
|
|
115
|
-
|
|
116
|
-
### copyFile()
|
|
117
|
-
|
|
118
|
-
> `static` **copyFile**(`srcPath`, `outPath`, `variables?`, `overwrite?`): `Promise`\<`void`\>
|
|
119
|
-
|
|
120
|
-
Defined in: [src/FileUtils.ts:123](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/FileUtils.ts#L123)
|
|
121
|
-
|
|
122
|
-
Generates a copy of the source file at the desired output destination and performs a swap of all values of the
|
|
123
|
-
variables specified.
|
|
124
|
-
|
|
125
|
-
#### Parameters
|
|
126
|
-
|
|
127
|
-
##### srcPath
|
|
128
|
-
|
|
129
|
-
`string`
|
|
130
|
-
|
|
131
|
-
The source file to copy.
|
|
132
|
-
|
|
133
|
-
##### outPath
|
|
134
|
-
|
|
135
|
-
`string`
|
|
136
|
-
|
|
137
|
-
The destination file to generate.
|
|
138
|
-
|
|
139
|
-
##### variables?
|
|
140
|
-
|
|
141
|
-
`any` = `{}`
|
|
142
|
-
|
|
143
|
-
The map of variable names to values to swap.
|
|
144
|
-
|
|
145
|
-
##### overwrite?
|
|
146
|
-
|
|
147
|
-
`boolean` = `false`
|
|
148
|
-
|
|
149
|
-
#### Returns
|
|
150
|
-
|
|
151
|
-
`Promise`\<`void`\>
|
|
152
|
-
|
|
153
|
-
***
|
|
154
|
-
|
|
155
|
-
### writeFile()
|
|
156
|
-
|
|
157
|
-
> `static` **writeFile**(`srcPath`, `outPath`, `contents`, `overwrite?`): `Promise`\<`void`\>
|
|
158
|
-
|
|
159
|
-
Defined in: [src/FileUtils.ts:28](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/FileUtils.ts#L28)
|
|
160
|
-
|
|
161
|
-
Attempts to write the provided contents to the file path given. If a file already exists the user is prompted to
|
|
162
|
-
allow the file to be overwritten or merged. In the case of a merge, srcPath is used as a baseline in order to
|
|
163
|
-
perform a 3-way merge.
|
|
164
|
-
|
|
165
|
-
#### Parameters
|
|
166
|
-
|
|
167
|
-
##### srcPath
|
|
168
|
-
|
|
169
|
-
`string`
|
|
170
|
-
|
|
171
|
-
The baseline template file to use during a merge.
|
|
172
|
-
|
|
173
|
-
##### outPath
|
|
174
|
-
|
|
175
|
-
`string`
|
|
176
|
-
|
|
177
|
-
The destination file path to be written.
|
|
178
|
-
|
|
179
|
-
##### contents
|
|
180
|
-
|
|
181
|
-
`any`
|
|
182
|
-
|
|
183
|
-
The contents of the file to write.
|
|
184
|
-
|
|
185
|
-
##### overwrite?
|
|
186
|
-
|
|
187
|
-
`boolean` = `false`
|
|
188
|
-
|
|
189
|
-
Set to `true` to overwite the file and not perform a merge.
|
|
190
|
-
|
|
191
|
-
#### Returns
|
|
192
|
-
|
|
193
|
-
`Promise`\<`void`\>
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
[**@rapidrest/core**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@rapidrest/core](../globals.md) / JWTUtils
|
|
6
|
-
|
|
7
|
-
# Class: JWTUtils
|
|
8
|
-
|
|
9
|
-
Defined in: [src/JWTUtils.ts:145](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/JWTUtils.ts#L145)
|
|
10
|
-
|
|
11
|
-
Utility class for working with Json Web Token (JWT) authentication tokens.
|
|
12
|
-
|
|
13
|
-
## Author
|
|
14
|
-
|
|
15
|
-
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
16
|
-
|
|
17
|
-
## Constructors
|
|
18
|
-
|
|
19
|
-
### Constructor
|
|
20
|
-
|
|
21
|
-
> **new JWTUtils**(): `JWTUtils`
|
|
22
|
-
|
|
23
|
-
#### Returns
|
|
24
|
-
|
|
25
|
-
`JWTUtils`
|
|
26
|
-
|
|
27
|
-
## Methods
|
|
28
|
-
|
|
29
|
-
### createToken()
|
|
30
|
-
|
|
31
|
-
> `static` **createToken**(`config`, `user`, `data?`): `Promise`\<`string`\>
|
|
32
|
-
|
|
33
|
-
Defined in: [src/JWTUtils.ts:170](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/JWTUtils.ts#L170)
|
|
34
|
-
|
|
35
|
-
#### Parameters
|
|
36
|
-
|
|
37
|
-
##### config
|
|
38
|
-
|
|
39
|
-
[`JWTUtilsConfig`](../interfaces/JWTUtilsConfig.md)
|
|
40
|
-
|
|
41
|
-
##### user
|
|
42
|
-
|
|
43
|
-
[`JWTUser`](../interfaces/JWTUser.md)
|
|
44
|
-
|
|
45
|
-
##### data?
|
|
46
|
-
|
|
47
|
-
`any`
|
|
48
|
-
|
|
49
|
-
#### Returns
|
|
50
|
-
|
|
51
|
-
`Promise`\<`string`\>
|
|
52
|
-
|
|
53
|
-
***
|
|
54
|
-
|
|
55
|
-
### createTokenSync()
|
|
56
|
-
|
|
57
|
-
> `static` **createTokenSync**(`config`, `user`, `data?`): `string`
|
|
58
|
-
|
|
59
|
-
Defined in: [src/JWTUtils.ts:216](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/JWTUtils.ts#L216)
|
|
60
|
-
|
|
61
|
-
#### Parameters
|
|
62
|
-
|
|
63
|
-
##### config
|
|
64
|
-
|
|
65
|
-
[`JWTUtilsConfig`](../interfaces/JWTUtilsConfig.md)
|
|
66
|
-
|
|
67
|
-
##### user
|
|
68
|
-
|
|
69
|
-
[`JWTUser`](../interfaces/JWTUser.md)
|
|
70
|
-
|
|
71
|
-
##### data?
|
|
72
|
-
|
|
73
|
-
`any`
|
|
74
|
-
|
|
75
|
-
#### Returns
|
|
76
|
-
|
|
77
|
-
`string`
|
|
78
|
-
|
|
79
|
-
***
|
|
80
|
-
|
|
81
|
-
### decodeToken()
|
|
82
|
-
|
|
83
|
-
> `static` **decodeToken**(`config`, `token`): `Promise`\<[`JWTPayload`](../interfaces/JWTPayload.md)\>
|
|
84
|
-
|
|
85
|
-
Defined in: [src/JWTUtils.ts:270](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/JWTUtils.ts#L270)
|
|
86
|
-
|
|
87
|
-
Decodes the given JWT authentication token using the provided configuration. If the token is not valid an
|
|
88
|
-
error is thrown with the reason. Returns the encoded user object payload upon success.
|
|
89
|
-
|
|
90
|
-
#### Parameters
|
|
91
|
-
|
|
92
|
-
##### config
|
|
93
|
-
|
|
94
|
-
[`JWTUtilsConfig`](../interfaces/JWTUtilsConfig.md)
|
|
95
|
-
|
|
96
|
-
The JWT configuration to use when validating the token.
|
|
97
|
-
|
|
98
|
-
##### token
|
|
99
|
-
|
|
100
|
-
`string`
|
|
101
|
-
|
|
102
|
-
The JWT token to validate.
|
|
103
|
-
|
|
104
|
-
#### Returns
|
|
105
|
-
|
|
106
|
-
`Promise`\<[`JWTPayload`](../interfaces/JWTPayload.md)\>
|
|
107
|
-
|
|
108
|
-
The data encoded in the token's payload.
|
|
109
|
-
|
|
110
|
-
***
|
|
111
|
-
|
|
112
|
-
### decodeTokenSync()
|
|
113
|
-
|
|
114
|
-
> `static` **decodeTokenSync**(`config`, `token`): [`JWTPayload`](../interfaces/JWTPayload.md)
|
|
115
|
-
|
|
116
|
-
Defined in: [src/JWTUtils.ts:320](https://github.com/rapidrest/core/blob/df82e91f4c858ef61526c7f35789a4199b84d999/src/JWTUtils.ts#L320)
|
|
117
|
-
|
|
118
|
-
Decodes the given JWT authentication token using the provided configuration. If the token is not valid an
|
|
119
|
-
error is thrown with the reason. Returns the encoded user object payload upon success.
|
|
120
|
-
|
|
121
|
-
#### Parameters
|
|
122
|
-
|
|
123
|
-
##### config
|
|
124
|
-
|
|
125
|
-
[`JWTUtilsConfig`](../interfaces/JWTUtilsConfig.md)
|
|
126
|
-
|
|
127
|
-
The JWT configuration to use when validating the token.
|
|
128
|
-
|
|
129
|
-
##### token
|
|
130
|
-
|
|
131
|
-
`string`
|
|
132
|
-
|
|
133
|
-
The JWT token to validate.
|
|
134
|
-
|
|
135
|
-
#### Returns
|
|
136
|
-
|
|
137
|
-
[`JWTPayload`](../interfaces/JWTPayload.md)
|
|
138
|
-
|
|
139
|
-
The data encoded in the token's payload.
|