@api-client/core 0.5.18 → 0.5.21

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.
Files changed (112) hide show
  1. package/build/browser.d.ts +10 -2
  2. package/build/browser.js +13 -0
  3. package/build/browser.js.map +1 -1
  4. package/build/index.d.ts +7 -2
  5. package/build/index.js +10 -0
  6. package/build/index.js.map +1 -1
  7. package/build/src/authorization/AuthorizationError.d.ts +23 -0
  8. package/build/src/authorization/AuthorizationError.js +33 -0
  9. package/build/src/authorization/AuthorizationError.js.map +1 -0
  10. package/build/src/authorization/CustomParameters.d.ts +24 -0
  11. package/build/src/authorization/CustomParameters.js +59 -0
  12. package/build/src/authorization/CustomParameters.js.map +1 -0
  13. package/build/src/authorization/OAuth2Authorization.d.ts +332 -0
  14. package/build/src/authorization/OAuth2Authorization.js +965 -0
  15. package/build/src/authorization/OAuth2Authorization.js.map +1 -0
  16. package/build/src/authorization/OidcAuthorization.d.ts +34 -0
  17. package/build/src/authorization/OidcAuthorization.js +139 -0
  18. package/build/src/authorization/OidcAuthorization.js.map +1 -0
  19. package/build/src/authorization/Utils.d.ts +51 -0
  20. package/build/src/authorization/Utils.js +122 -0
  21. package/build/src/authorization/Utils.js.map +1 -0
  22. package/build/src/authorization/lib/IframeAuthorization.d.ts +53 -0
  23. package/build/src/authorization/lib/IframeAuthorization.js +116 -0
  24. package/build/src/authorization/lib/IframeAuthorization.js.map +1 -0
  25. package/build/src/authorization/lib/KnownGrants.d.ts +6 -0
  26. package/build/src/authorization/lib/KnownGrants.js +7 -0
  27. package/build/src/authorization/lib/KnownGrants.js.map +1 -0
  28. package/build/src/authorization/lib/PopupAuthorization.d.ts +41 -0
  29. package/build/src/authorization/lib/PopupAuthorization.js +73 -0
  30. package/build/src/authorization/lib/PopupAuthorization.js.map +1 -0
  31. package/build/src/authorization/lib/Tokens.d.ts +55 -0
  32. package/build/src/authorization/lib/Tokens.js +117 -0
  33. package/build/src/authorization/lib/Tokens.js.map +1 -0
  34. package/build/src/authorization/types.d.ts +174 -0
  35. package/build/src/authorization/types.js +2 -0
  36. package/build/src/authorization/types.js.map +1 -0
  37. package/build/src/events/BaseEvents.d.ts +1 -1
  38. package/build/src/events/BaseEvents.js.map +1 -1
  39. package/build/src/events/EventTypes.d.ts +0 -28
  40. package/build/src/events/Events.d.ts +0 -1
  41. package/build/src/events/models/ClientCertificateEvents.d.ts +6 -8
  42. package/build/src/events/models/ClientCertificateEvents.js +4 -6
  43. package/build/src/events/models/ClientCertificateEvents.js.map +1 -1
  44. package/build/src/events/models/ModelEventTypes.d.ts +0 -34
  45. package/build/src/events/models/ModelEventTypes.js +0 -34
  46. package/build/src/events/models/ModelEventTypes.js.map +1 -1
  47. package/build/src/events/models/ModelEvents.d.ts +0 -2
  48. package/build/src/events/models/ModelEvents.js +0 -2
  49. package/build/src/events/models/ModelEvents.js.map +1 -1
  50. package/build/src/lib/Buffer.d.ts +21 -0
  51. package/build/src/lib/Buffer.js +43 -0
  52. package/build/src/lib/Buffer.js.map +1 -0
  53. package/build/src/lib/definitions/HttpDefinitions.d.ts +33 -0
  54. package/build/src/lib/definitions/HttpDefinitions.js +58 -0
  55. package/build/src/lib/definitions/HttpDefinitions.js.map +1 -0
  56. package/build/src/lib/headers/Headers.d.ts +8 -1
  57. package/build/src/lib/headers/Headers.js +48 -34
  58. package/build/src/lib/headers/Headers.js.map +1 -1
  59. package/build/src/lib/headers/HeadersData.d.ts +35 -0
  60. package/build/src/lib/headers/HeadersData.js +678 -0
  61. package/build/src/lib/headers/HeadersData.js.map +1 -0
  62. package/build/src/lib/parsers/UrlProcessor.d.ts +2 -2
  63. package/build/src/lib/parsers/UrlProcessor.js +2 -2
  64. package/build/src/lib/parsers/UrlProcessor.js.map +1 -1
  65. package/build/src/models/ClientCertificate.d.ts +130 -25
  66. package/build/src/models/ClientCertificate.js +150 -1
  67. package/build/src/models/ClientCertificate.js.map +1 -1
  68. package/build/src/models/Request.d.ts +3 -3
  69. package/build/src/models/Request.js +3 -2
  70. package/build/src/models/Request.js.map +1 -1
  71. package/build/src/runtime/http-engine/CoreEngine.js +4 -1
  72. package/build/src/runtime/http-engine/CoreEngine.js.map +1 -1
  73. package/build/src/runtime/http-engine/HttpEngine.d.ts +4 -4
  74. package/build/src/runtime/http-engine/HttpEngine.js +38 -29
  75. package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
  76. package/build/src/runtime/modules/ModulesRegistry.d.ts +2 -2
  77. package/build/src/runtime/node/ProjectRequestRunner.js +1 -1
  78. package/build/src/runtime/node/ProjectRequestRunner.js.map +1 -1
  79. package/build/src/runtime/node/RequestFactory.d.ts +2 -2
  80. package/build/src/runtime/node/RequestFactory.js.map +1 -1
  81. package/oauth-popup.html +29 -0
  82. package/package.json +3 -1
  83. package/src/authorization/AuthorizationError.ts +25 -0
  84. package/src/authorization/CustomParameters.ts +61 -0
  85. package/src/authorization/OAuth2Authorization.ts +1027 -0
  86. package/src/authorization/OidcAuthorization.ts +143 -0
  87. package/src/authorization/Utils.ts +126 -0
  88. package/src/authorization/lib/IframeAuthorization.ts +128 -0
  89. package/src/authorization/lib/KnownGrants.ts +6 -0
  90. package/src/authorization/lib/PopupAuthorization.ts +80 -0
  91. package/src/authorization/lib/Tokens.ts +124 -0
  92. package/src/authorization/types.ts +176 -0
  93. package/src/events/BaseEvents.ts +1 -1
  94. package/src/events/models/ClientCertificateEvents.ts +11 -13
  95. package/src/events/models/ModelEventTypes.ts +0 -34
  96. package/src/events/models/ModelEvents.ts +0 -2
  97. package/src/lib/Buffer.ts +48 -0
  98. package/src/lib/definitions/HttpDefinitions.ts +63 -0
  99. package/src/lib/headers/Headers.ts +50 -34
  100. package/src/lib/headers/HeadersData.ts +788 -0
  101. package/src/lib/parsers/UrlProcessor.ts +3 -3
  102. package/src/models/ClientCertificate.ts +224 -25
  103. package/src/models/Request.ts +5 -5
  104. package/src/runtime/http-engine/CoreEngine.ts +4 -1
  105. package/src/runtime/http-engine/HttpEngine.ts +39 -33
  106. package/src/runtime/modules/ModulesRegistry.ts +2 -2
  107. package/src/runtime/node/ProjectRequestRunner.ts +1 -1
  108. package/src/runtime/node/RequestFactory.ts +2 -2
  109. package/build/src/events/models/ProjectEvents.d.ts +0 -221
  110. package/build/src/events/models/ProjectEvents.js +0 -253
  111. package/build/src/events/models/ProjectEvents.js.map +0 -1
  112. package/src/events/models/ProjectEvents.ts +0 -331
@@ -200,7 +200,7 @@ export interface IUrlExpandOptions {
200
200
 
201
201
  export type UrlPart = IUrlPart | IUrlParamPart | IUrlExpressionPart;
202
202
 
203
- class SearchParams {
203
+ export class UrlSearchParams {
204
204
  /**
205
205
  * A reference to the URL processor's parts.
206
206
  */
@@ -369,12 +369,12 @@ export class UrlProcessor {
369
369
  /**
370
370
  * A helper class to manipulate query parameters on the parser.
371
371
  */
372
- search: SearchParams;
372
+ search: UrlSearchParams;
373
373
 
374
374
  constructor(expression: string) {
375
375
  this.expression = expression;
376
376
  this.tokens = new Tokenizer(expression);
377
- this.search = new SearchParams(this.parts);
377
+ this.search = new UrlSearchParams(this.parts);
378
378
  this._parse();
379
379
  }
380
380
 
@@ -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 ICertificate {
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: string|ArrayBuffer|Buffer|Uint8Array;
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
- * By any means, outside the internal procedure of the data store this
20
- * filed is always `undefined` and the `data` contains the original data format.
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?: string;
29
+ type?: 'buffer';
23
30
  }
24
31
 
25
- /**
26
- * Represents a complete certificate configuration required to make
27
- * a HTTP request.
28
- */
29
- export interface IRequestCertificate {
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: ICertificate|ICertificate[];
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
- * Key for the `pem` type certificate.
68
+ * The key for the `pem` type certificate.
40
69
  */
41
- key?: ICertificate|ICertificate[];
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
- * Client certificate index definition for listings.
114
+ * A class that represents a certificate in the system
46
115
  */
47
- export interface ICertificateIndex {
116
+ export class Certificate {
117
+ kind = Kind;
48
118
  /**
49
- * Certificate type. Either `p12` or `pem`.
119
+ * The data store key to refer.
50
120
  */
51
- type: CertificateType;
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
- * A base client certificate object used in API Client to create / list objects.
65
- * This is not a data entity but rather something used to outside of a context of a data store.
66
- */
67
- export interface IClientCertificate extends IRequestCertificate, ICertificateIndex {
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
  }
@@ -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 { IRequestCertificate } from './ClientCertificate.js';
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?: IRequestCertificate;
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?: IRequestCertificate;
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 = { ...this.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 { IRequestCertificate } from '../../models/ClientCertificate.js';
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?: IRequestCertificate[];
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 Received status code
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: IRequestCertificate, options: tls.ConnectionOptions): void {
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 added = cert.cert.map((item) => {
750
- const struct: tls.PxfObject = {
751
- buf: Buffer.from(item.data as string),
752
- };
753
- if (item.passphrase) {
754
- struct.passphrase = item.passphrase;
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
- return struct;
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
- const added = cert.cert.map((item) => Buffer.from(item.data as string));
764
- options.cert = (options.cert as Buffer[]).concat(added);
765
- if (cert.key) {
766
- if (!Array.isArray(cert.key)) {
767
- cert.key = [cert.key];
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
- const keys = cert.key.map((item) => {
773
- const struct: tls.KeyObject = {
774
- pem: Buffer.from(item.data as string),
775
- };
776
- if (item.passphrase) {
777
- struct.passphrase = item.passphrase;
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
- return struct;
780
- });
781
- options.key = (options.key as tls.KeyObject[]).concat(keys);
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 { IRequestCertificate } from '../../models/ClientCertificate.js';
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?: IRequestCertificate[];
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 { IRequestCertificate } from '../../models/ClientCertificate.js';
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?: IRequestCertificate[];
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).