@api-client/core 0.5.19 → 0.5.20
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/build/browser.d.ts +2 -2
- package/build/browser.js +2 -0
- package/build/browser.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -0
- package/build/index.js.map +1 -1
- package/build/src/events/BaseEvents.d.ts +1 -1
- package/build/src/events/BaseEvents.js.map +1 -1
- package/build/src/events/EventTypes.d.ts +0 -28
- package/build/src/events/Events.d.ts +0 -1
- package/build/src/events/models/ClientCertificateEvents.d.ts +6 -8
- package/build/src/events/models/ClientCertificateEvents.js +4 -6
- package/build/src/events/models/ClientCertificateEvents.js.map +1 -1
- package/build/src/events/models/ModelEventTypes.d.ts +0 -34
- package/build/src/events/models/ModelEventTypes.js +0 -34
- package/build/src/events/models/ModelEventTypes.js.map +1 -1
- package/build/src/events/models/ModelEvents.d.ts +0 -2
- package/build/src/events/models/ModelEvents.js +0 -2
- package/build/src/events/models/ModelEvents.js.map +1 -1
- package/build/src/lib/Buffer.d.ts +21 -0
- package/build/src/lib/Buffer.js +43 -0
- package/build/src/lib/Buffer.js.map +1 -0
- package/build/src/models/ClientCertificate.d.ts +130 -25
- package/build/src/models/ClientCertificate.js +150 -1
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/Request.d.ts +3 -3
- package/build/src/models/Request.js +3 -2
- package/build/src/models/Request.js.map +1 -1
- package/build/src/runtime/http-engine/CoreEngine.js +4 -1
- package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.d.ts +4 -4
- package/build/src/runtime/http-engine/HttpEngine.js +38 -29
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/build/src/runtime/modules/ModulesRegistry.d.ts +2 -2
- package/build/src/runtime/node/ProjectRequestRunner.js +1 -1
- package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
- package/build/src/runtime/node/RequestFactory.d.ts +2 -2
- package/build/src/runtime/node/RequestFactory.js.map +1 -1
- package/package.json +1 -1
- package/src/events/BaseEvents.ts +1 -1
- package/src/events/models/ClientCertificateEvents.ts +11 -13
- package/src/events/models/ModelEventTypes.ts +0 -34
- package/src/events/models/ModelEvents.ts +0 -2
- package/src/lib/Buffer.ts +48 -0
- package/src/models/ClientCertificate.ts +224 -25
- package/src/models/Request.ts +5 -5
- package/src/runtime/http-engine/CoreEngine.ts +4 -1
- package/src/runtime/http-engine/HttpEngine.ts +39 -33
- package/src/runtime/modules/ModulesRegistry.ts +2 -2
- package/src/runtime/node/ProjectRequestRunner.ts +1 -1
- package/src/runtime/node/RequestFactory.ts +2 -2
- package/build/src/events/models/ProjectEvents.d.ts +0 -221
- package/build/src/events/models/ProjectEvents.js +0 -253
- package/build/src/events/models/ProjectEvents.js.map +0 -1
- package/src/events/models/ProjectEvents.ts +0 -331
|
@@ -1,54 +1,124 @@
|
|
|
1
|
+
import { base64ToBuffer, bufferToBase64 } from '../lib/Buffer.js';
|
|
2
|
+
import v4 from '../lib/uuid.js';
|
|
3
|
+
|
|
1
4
|
export type CertificateType = 'p12' | 'pem';
|
|
2
5
|
|
|
6
|
+
export const Kind = 'Core#Certificate';
|
|
7
|
+
|
|
8
|
+
export type CertificateDataFormat = string | ArrayBuffer | Buffer | Uint8Array;
|
|
9
|
+
|
|
3
10
|
/**
|
|
4
11
|
* Represents a single certificate object (cert/key)
|
|
5
12
|
*/
|
|
6
|
-
export interface
|
|
13
|
+
export interface ICertificateData {
|
|
7
14
|
/**
|
|
8
15
|
* The certificate to use.
|
|
9
16
|
* The `p12` type certificate must be a Buffer.
|
|
10
17
|
*/
|
|
11
|
-
data:
|
|
18
|
+
data: CertificateDataFormat;
|
|
12
19
|
/**
|
|
13
20
|
* A passphrase to use to unlock the certificate.
|
|
14
21
|
*/
|
|
15
22
|
passphrase?: string;
|
|
16
23
|
/**
|
|
17
|
-
* The original data type of the certificate. This is used by the data store
|
|
24
|
+
* The original data type of the certificate. This is only used internally by the data store
|
|
18
25
|
* to move between buffers and string values stored in the store.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
26
|
+
* Outside the internal procedure of the data store this
|
|
27
|
+
* is always `undefined` and the `data` contains the original data format.
|
|
21
28
|
*/
|
|
22
|
-
type?:
|
|
29
|
+
type?: 'buffer';
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
export interface ICertificate {
|
|
33
|
+
kind: typeof Kind;
|
|
34
|
+
/**
|
|
35
|
+
* The data store key to refer.
|
|
36
|
+
*/
|
|
37
|
+
key: string;
|
|
38
|
+
/**
|
|
39
|
+
* Custom name of the certificate.
|
|
40
|
+
*/
|
|
41
|
+
name: string;
|
|
42
|
+
/**
|
|
43
|
+
* Timestamp when the certificate was inserted into the data store.
|
|
44
|
+
* Required when returning a result. Auto-generated when inserting, if missing.
|
|
45
|
+
*/
|
|
46
|
+
created?: number;
|
|
47
|
+
/**
|
|
31
48
|
* Certificate type. Either `p12` or `pem`.
|
|
32
49
|
*/
|
|
33
50
|
type: CertificateType;
|
|
34
51
|
/**
|
|
35
52
|
* Certificate or list of certificates to use.
|
|
36
53
|
*/
|
|
37
|
-
cert:
|
|
54
|
+
cert: ICertificateData;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface IP12Certificate extends ICertificate {
|
|
58
|
+
type: 'p12';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Represents a complete certificate configuration required to make
|
|
63
|
+
* an HTTP request.
|
|
64
|
+
*/
|
|
65
|
+
export interface IPemCertificate extends ICertificate {
|
|
66
|
+
type: 'pem';
|
|
38
67
|
/**
|
|
39
|
-
*
|
|
68
|
+
* The key for the `pem` type certificate.
|
|
40
69
|
*/
|
|
41
|
-
|
|
70
|
+
certKey: ICertificateData;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export type HttpCertificate = IP12Certificate | IPemCertificate;
|
|
74
|
+
|
|
75
|
+
export interface IPemCreateOptions {
|
|
76
|
+
type: 'p12';
|
|
77
|
+
/**
|
|
78
|
+
* The certificate contents.
|
|
79
|
+
*/
|
|
80
|
+
cert: CertificateDataFormat;
|
|
81
|
+
/**
|
|
82
|
+
* The key contents.
|
|
83
|
+
*/
|
|
84
|
+
key: CertificateDataFormat;
|
|
85
|
+
/**
|
|
86
|
+
* Optional name for the certificate.
|
|
87
|
+
*/
|
|
88
|
+
name?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional passphrase for the key.
|
|
91
|
+
*/
|
|
92
|
+
passphrase?: string;
|
|
42
93
|
}
|
|
43
94
|
|
|
95
|
+
export interface IP12CreateOptions {
|
|
96
|
+
type: 'pem';
|
|
97
|
+
/**
|
|
98
|
+
* The certificate contents.
|
|
99
|
+
*/
|
|
100
|
+
cert: CertificateDataFormat;
|
|
101
|
+
/**
|
|
102
|
+
* Optional name for the certificate.
|
|
103
|
+
*/
|
|
104
|
+
name?: string;
|
|
105
|
+
/**
|
|
106
|
+
* Optional passphrase for the certificate.
|
|
107
|
+
*/
|
|
108
|
+
passphrase?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type ICertificateCreateOptions = IPemCreateOptions | IP12CreateOptions;
|
|
112
|
+
|
|
44
113
|
/**
|
|
45
|
-
*
|
|
114
|
+
* A class that represents a certificate in the system
|
|
46
115
|
*/
|
|
47
|
-
export
|
|
116
|
+
export class Certificate {
|
|
117
|
+
kind = Kind;
|
|
48
118
|
/**
|
|
49
|
-
*
|
|
119
|
+
* The data store key to refer.
|
|
50
120
|
*/
|
|
51
|
-
|
|
121
|
+
key: string;
|
|
52
122
|
/**
|
|
53
123
|
* Custom name of the certificate.
|
|
54
124
|
*/
|
|
@@ -58,11 +128,140 @@ export interface ICertificateIndex {
|
|
|
58
128
|
* Required when returning a result. Auto-generated when inserting, if missing.
|
|
59
129
|
*/
|
|
60
130
|
created?: number;
|
|
61
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Certificate type. Either `p12` or `pem`.
|
|
133
|
+
*/
|
|
134
|
+
type: CertificateType;
|
|
135
|
+
/**
|
|
136
|
+
* Certificate or list of certificates to use.
|
|
137
|
+
*/
|
|
138
|
+
cert: ICertificateData;
|
|
139
|
+
/**
|
|
140
|
+
* The key for the `pem` type certificate.
|
|
141
|
+
*/
|
|
142
|
+
certKey?: ICertificateData;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Creates a new certificate instance for a PEM key
|
|
146
|
+
*
|
|
147
|
+
* @param pem The certificate contents
|
|
148
|
+
* @param key The key contents
|
|
149
|
+
* @param name The certificate name
|
|
150
|
+
* @param keyPassphrase The key passphrase
|
|
151
|
+
*/
|
|
152
|
+
static fromPem(pem: CertificateDataFormat, key: CertificateDataFormat, name = 'New PEM certificate', keyPassphrase?: string): Certificate {
|
|
153
|
+
const init: IPemCertificate = {
|
|
154
|
+
kind: Kind,
|
|
155
|
+
cert: {
|
|
156
|
+
data: pem,
|
|
157
|
+
},
|
|
158
|
+
certKey: {
|
|
159
|
+
data: key,
|
|
160
|
+
},
|
|
161
|
+
key: v4(),
|
|
162
|
+
name,
|
|
163
|
+
type: 'pem',
|
|
164
|
+
};
|
|
165
|
+
if (keyPassphrase) {
|
|
166
|
+
init.certKey.passphrase = keyPassphrase;
|
|
167
|
+
}
|
|
168
|
+
return new Certificate(init);
|
|
169
|
+
}
|
|
62
170
|
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
171
|
+
/**
|
|
172
|
+
* Creates a new certificate instance for a P12 key
|
|
173
|
+
*
|
|
174
|
+
* @param cert The certificate contents
|
|
175
|
+
* @param name The certificate name
|
|
176
|
+
* @param passphrase The key passphrase
|
|
177
|
+
*/
|
|
178
|
+
static fromP12(cert: CertificateDataFormat, name = 'New P12 certificate', passphrase?: string): Certificate {
|
|
179
|
+
const init: IP12Certificate = {
|
|
180
|
+
kind: Kind,
|
|
181
|
+
cert: {
|
|
182
|
+
data: cert,
|
|
183
|
+
},
|
|
184
|
+
key: v4(),
|
|
185
|
+
name,
|
|
186
|
+
type: 'p12',
|
|
187
|
+
};
|
|
188
|
+
if (passphrase) {
|
|
189
|
+
init.cert.passphrase = passphrase;
|
|
190
|
+
}
|
|
191
|
+
return new Certificate(init);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
constructor(certificate: HttpCertificate) {
|
|
195
|
+
const { type, cert, key=v4(), name='', created } = certificate;
|
|
196
|
+
this.key = key;
|
|
197
|
+
this.name = name;
|
|
198
|
+
this.type = type;
|
|
199
|
+
this.cert = this.fromStore(cert);
|
|
200
|
+
if (typeof created === 'number') {
|
|
201
|
+
this.created = created;
|
|
202
|
+
}
|
|
203
|
+
if (type === 'pem') {
|
|
204
|
+
this.certKey = this.fromStore(certificate.certKey);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* When needed it reads the certificate's original format.
|
|
210
|
+
* @param data The certificate data.
|
|
211
|
+
* @returns The restored certificate.
|
|
212
|
+
*/
|
|
213
|
+
fromStore(data: ICertificateData): ICertificateData {
|
|
214
|
+
if (data.type) {
|
|
215
|
+
delete data.type;
|
|
216
|
+
const content = data.data as string;
|
|
217
|
+
data.data = base64ToBuffer(content);
|
|
218
|
+
}
|
|
219
|
+
return data;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Prepares certificate object to be stored in the data store.
|
|
224
|
+
* If the `data` property is not string then it assumes buffer (either
|
|
225
|
+
* Node's or ArrayBuffer). In this case it converts buffer to base64 string.
|
|
226
|
+
* It also adds `type` property set to `buffer` for the `fromStore()`
|
|
227
|
+
* function to recognize what to do with the data.
|
|
228
|
+
*
|
|
229
|
+
* Note, for optimization, PEM keys should be strings as the content of the
|
|
230
|
+
* certificate is already a base62 string. To spare double base64 conversion
|
|
231
|
+
* use string data.
|
|
232
|
+
*
|
|
233
|
+
* @param data The certificate data object.
|
|
234
|
+
* @throws When data is not set
|
|
235
|
+
*/
|
|
236
|
+
toStore(data: ICertificateData): ICertificateData {
|
|
237
|
+
if (!data) {
|
|
238
|
+
throw new Error('Certificate data is missing.');
|
|
239
|
+
}
|
|
240
|
+
if (!data.data) {
|
|
241
|
+
throw new Error('Certificate content not set.');
|
|
242
|
+
}
|
|
243
|
+
if (typeof data.data !== 'string') {
|
|
244
|
+
data.type = 'buffer';
|
|
245
|
+
const buff = data.data as Buffer;
|
|
246
|
+
data.data = bufferToBase64(buff);
|
|
247
|
+
}
|
|
248
|
+
return data;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
toJSON(): HttpCertificate {
|
|
252
|
+
const result: IP12Certificate = {
|
|
253
|
+
kind: Kind,
|
|
254
|
+
key: this.key,
|
|
255
|
+
cert: this.toStore(this.cert),
|
|
256
|
+
name: this.name,
|
|
257
|
+
type: 'p12',
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
if (this.type === 'pem') {
|
|
261
|
+
const typed = (result as unknown) as IPemCertificate;
|
|
262
|
+
typed.certKey = this.toStore(this.certKey!);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
68
267
|
}
|
package/src/models/Request.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IRequestConfig, RequestConfig } from './RequestConfig.js';
|
|
2
2
|
import { Thing, IThing, Kind as ThingKind } from './Thing.js';
|
|
3
3
|
import { IRequestActions, RequestActions } from './RequestActions.js';
|
|
4
|
-
import {
|
|
4
|
+
import { HttpCertificate, Certificate } from './ClientCertificate.js';
|
|
5
5
|
import { IRequestAuthorization, RequestAuthorization } from './RequestAuthorization.js';
|
|
6
6
|
import { IRequestLog, RequestLog, Kind as LogKind } from './RequestLog.js';
|
|
7
7
|
import { SentRequest } from './SentRequest.js';
|
|
@@ -64,7 +64,7 @@ export interface IRequest {
|
|
|
64
64
|
/**
|
|
65
65
|
* The list of certificates to use with the request.
|
|
66
66
|
*/
|
|
67
|
-
clientCertificate?:
|
|
67
|
+
clientCertificate?: HttpCertificate;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export class Request {
|
|
@@ -99,7 +99,7 @@ export class Request {
|
|
|
99
99
|
/**
|
|
100
100
|
* The list of certificates to use with the request.
|
|
101
101
|
*/
|
|
102
|
-
clientCertificate?:
|
|
102
|
+
clientCertificate?: Certificate;
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Creates a request from an URL.
|
|
@@ -373,7 +373,7 @@ export class Request {
|
|
|
373
373
|
this.actions = undefined;
|
|
374
374
|
}
|
|
375
375
|
if (clientCertificate) {
|
|
376
|
-
this.clientCertificate = clientCertificate;
|
|
376
|
+
this.clientCertificate = new Certificate(clientCertificate);
|
|
377
377
|
} else {
|
|
378
378
|
this.clientCertificate = undefined;
|
|
379
379
|
}
|
|
@@ -401,7 +401,7 @@ export class Request {
|
|
|
401
401
|
result.actions = this.actions.toJSON();
|
|
402
402
|
}
|
|
403
403
|
if (this.clientCertificate) {
|
|
404
|
-
result.clientCertificate =
|
|
404
|
+
result.clientCertificate = this.clientCertificate.toJSON();
|
|
405
405
|
}
|
|
406
406
|
return result;
|
|
407
407
|
}
|
|
@@ -728,12 +728,15 @@ export class CoreEngine extends HttpEngine {
|
|
|
728
728
|
return;
|
|
729
729
|
}
|
|
730
730
|
if (data.length === 0) {
|
|
731
|
+
if (this.currentResponse?.status === 204) {
|
|
732
|
+
this._reportResponse();
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
731
735
|
if (this.currentHeaders.has('Content-Length')) {
|
|
732
736
|
// If the server do not close the connection and clearly indicate that
|
|
733
737
|
// there are no further data to receive the app can close the connection
|
|
734
738
|
// and prepare the response.
|
|
735
739
|
const length = Number(this.currentHeaders.get('Content-Length'));
|
|
736
|
-
// NaN never equals NaN. This is faster.
|
|
737
740
|
if (!Number.isNaN(length) && length === 0) {
|
|
738
741
|
this._reportResponse();
|
|
739
742
|
return;
|
|
@@ -10,7 +10,7 @@ import { IHttpRequest, HttpRequest } from '../../models/HttpRequest.js';
|
|
|
10
10
|
import { IRequestBaseConfig } from '../../models/RequestConfig.js';
|
|
11
11
|
import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
12
12
|
import { HostRule } from '../../models/HostRule.js';
|
|
13
|
-
import {
|
|
13
|
+
import { HttpCertificate } from '../../models/ClientCertificate.js';
|
|
14
14
|
import { SentRequest } from '../../models/SentRequest.js';
|
|
15
15
|
import { Response } from '../../models/Response.js';
|
|
16
16
|
import { ErrorResponse } from '../../models/ErrorResponse.js';
|
|
@@ -40,7 +40,7 @@ export interface HttpEngineOptions extends IRequestBaseConfig {
|
|
|
40
40
|
/**
|
|
41
41
|
* A certificate to use with the request.
|
|
42
42
|
*/
|
|
43
|
-
certificates?:
|
|
43
|
+
certificates?: HttpCertificate[];
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface RequestStats {
|
|
@@ -385,7 +385,7 @@ export abstract class HttpEngine extends EventEmitter {
|
|
|
385
385
|
|
|
386
386
|
/**
|
|
387
387
|
* Reports response when redirected.
|
|
388
|
-
* @param
|
|
388
|
+
* @param status Received status code
|
|
389
389
|
* @return True if the request has been redirected.
|
|
390
390
|
*/
|
|
391
391
|
_reportRedirect(status: number): boolean {
|
|
@@ -734,51 +734,57 @@ Check your request parameters.`);
|
|
|
734
734
|
* @param certificate List of certificate configurations.
|
|
735
735
|
* @param options Request options. Cert agent options are added to this object.
|
|
736
736
|
*/
|
|
737
|
-
_addClientCertificate(certificate:
|
|
737
|
+
_addClientCertificate(certificate: HttpCertificate, options: tls.ConnectionOptions): void {
|
|
738
738
|
if (!certificate) {
|
|
739
739
|
return;
|
|
740
740
|
}
|
|
741
741
|
const cert = { ...certificate };
|
|
742
|
-
if (!Array.isArray(cert.cert)) {
|
|
743
|
-
cert.cert = [cert.cert];
|
|
744
|
-
}
|
|
745
742
|
if (cert.type === 'p12') {
|
|
746
743
|
if (!options.pfx) {
|
|
747
744
|
options.pfx = [];
|
|
748
745
|
}
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
746
|
+
const struct: tls.PxfObject = {
|
|
747
|
+
buf: Buffer.from(cert.cert.data as string),
|
|
748
|
+
};
|
|
749
|
+
if (cert.cert.passphrase) {
|
|
750
|
+
struct.passphrase = cert.cert.passphrase;
|
|
751
|
+
}
|
|
752
|
+
if (!Array.isArray(options.pfx)) {
|
|
753
|
+
if (options.pfx) {
|
|
754
|
+
options.pfx = [options.pfx];
|
|
755
|
+
} else {
|
|
756
|
+
options.pfx = [];
|
|
755
757
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
options.pfx = (options.pfx as tls.PxfObject[]).concat(added);
|
|
758
|
+
}
|
|
759
|
+
options.pfx.push(struct);
|
|
759
760
|
} else if (cert.type === 'pem') {
|
|
760
761
|
if (!options.cert) {
|
|
761
762
|
options.cert = [];
|
|
762
763
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
cert
|
|
768
|
-
}
|
|
769
|
-
if (!options.key) {
|
|
770
|
-
options.key = [];
|
|
764
|
+
if (!Array.isArray(options.cert)) {
|
|
765
|
+
if (options.cert) {
|
|
766
|
+
options.cert = [options.cert];
|
|
767
|
+
} else {
|
|
768
|
+
options.cert = [];
|
|
771
769
|
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
770
|
+
}
|
|
771
|
+
const added = Buffer.from(cert.cert.data as string);
|
|
772
|
+
options.cert.push(added);
|
|
773
|
+
if (cert.certKey) {
|
|
774
|
+
if (!Array.isArray(options.key)) {
|
|
775
|
+
if (options.key) {
|
|
776
|
+
options.key = [options.key];
|
|
777
|
+
} else {
|
|
778
|
+
options.key = [];
|
|
778
779
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
780
|
+
}
|
|
781
|
+
const struct: tls.KeyObject = {
|
|
782
|
+
pem: Buffer.from(cert.certKey.data as string),
|
|
783
|
+
};
|
|
784
|
+
if (cert.certKey.passphrase) {
|
|
785
|
+
struct.passphrase = cert.certKey.passphrase;
|
|
786
|
+
}
|
|
787
|
+
options.key.push(struct);
|
|
782
788
|
}
|
|
783
789
|
}
|
|
784
790
|
}
|
|
@@ -8,7 +8,7 @@ import { ClientCertificateEvents } from '../../events/models/ClientCertificateEv
|
|
|
8
8
|
import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
9
9
|
import { IRequestConfig } from '../../models/RequestConfig.js';
|
|
10
10
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
11
|
-
import {
|
|
11
|
+
import { HttpCertificate } from '../../models/ClientCertificate.js';
|
|
12
12
|
|
|
13
13
|
export interface RegisteredRequestModule {
|
|
14
14
|
fn: (request: IHttpRequest, context: ExecutionContext) => Promise<number>;
|
|
@@ -49,7 +49,7 @@ export interface ExecutionContext {
|
|
|
49
49
|
/**
|
|
50
50
|
* Can be altered by the actions.
|
|
51
51
|
*/
|
|
52
|
-
certificates?:
|
|
52
|
+
certificates?: HttpCertificate[];
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export interface ExecutionEvents {
|
|
@@ -136,7 +136,7 @@ export class ProjectRequestRunner extends EventEmitter {
|
|
|
136
136
|
factory.actions = request.actions.toJSON();
|
|
137
137
|
}
|
|
138
138
|
if (request.clientCertificate) {
|
|
139
|
-
factory.certificates = [request.clientCertificate];
|
|
139
|
+
factory.certificates = [request.clientCertificate.toJSON()];
|
|
140
140
|
}
|
|
141
141
|
if (config.enabled !== false) {
|
|
142
142
|
factory.config = config.toJSON();
|
|
@@ -3,7 +3,7 @@ import { IHttpRequest } from '../../models/HttpRequest.js';
|
|
|
3
3
|
import { IRequestConfig, IRequestBaseConfig } from '../../models/RequestConfig.js';
|
|
4
4
|
import { IRequestAuthorization } from '../../models/RequestAuthorization.js';
|
|
5
5
|
import { IRequestActions } from '../../models/RequestActions.js';
|
|
6
|
-
import {
|
|
6
|
+
import { HttpCertificate } from '../../models/ClientCertificate.js';
|
|
7
7
|
import { IRequestLog } from '../../models/RequestLog.js';
|
|
8
8
|
import { VariablesProcessor } from '../variables/VariablesProcessor.js';
|
|
9
9
|
import { IRunnableAction } from '../../models/actions/RunnableAction.js';
|
|
@@ -57,7 +57,7 @@ export class RequestFactory {
|
|
|
57
57
|
/**
|
|
58
58
|
* The list of certificates to use with the request.
|
|
59
59
|
*/
|
|
60
|
-
certificates?:
|
|
60
|
+
certificates?: HttpCertificate[];
|
|
61
61
|
/**
|
|
62
62
|
* The cumulative list of all variables to be applied to the request and other properties.
|
|
63
63
|
* The variables must be already processed for variables in values (evaluated).
|