@api-client/core 0.6.28 → 0.6.29
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/src/events/BaseEvents.d.ts +30 -28
- package/build/src/events/BaseEvents.js +15 -15
- package/build/src/events/BaseEvents.js.map +1 -1
- package/build/src/events/models/ClientCertificateEvents.d.ts +4 -4
- package/build/src/events/models/ClientCertificateEvents.js +6 -6
- package/build/src/events/models/ClientCertificateEvents.js.map +1 -1
- package/build/src/events/transport/TransportEvents.js.map +1 -1
- package/build/src/mocking/ProjectMock.d.ts +2 -0
- package/build/src/mocking/ProjectMock.js +3 -0
- package/build/src/mocking/ProjectMock.js.map +1 -1
- package/build/src/mocking/lib/Arc.d.ts +10 -0
- package/build/src/mocking/lib/Arc.js +31 -0
- package/build/src/mocking/lib/Arc.js.map +1 -0
- package/build/src/mocking/lib/Certificates.js +4 -1
- package/build/src/mocking/lib/Certificates.js.map +1 -1
- package/build/src/mocking/lib/Request.js +5 -2
- package/build/src/mocking/lib/Request.js.map +1 -1
- package/build/src/models/ClientCertificate.d.ts +2 -2
- package/build/src/models/ClientCertificate.js +10 -7
- package/build/src/models/ClientCertificate.js.map +1 -1
- package/build/src/models/arc/ArcProject.js +5 -0
- package/build/src/models/arc/ArcProject.js.map +1 -1
- package/build/src/runtime/http-engine/HttpEngine.js +7 -5
- package/build/src/runtime/http-engine/HttpEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/events/BaseEvents.ts +33 -33
- package/src/events/models/ClientCertificateEvents.ts +6 -6
- package/src/events/transport/TransportEvents.ts +2 -0
- package/src/mocking/ProjectMock.ts +3 -0
- package/src/mocking/lib/Arc.ts +34 -0
- package/src/mocking/lib/Certificates.ts +4 -1
- package/src/mocking/lib/Request.ts +6 -3
- package/src/models/ClientCertificate.ts +12 -9
- package/src/models/arc/ArcProject.ts +5 -0
- package/src/runtime/http-engine/HttpEngine.ts +8 -6
|
@@ -71,7 +71,7 @@ export interface IPemCertificate extends ICertificate {
|
|
|
71
71
|
certKey: ICertificateData;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export type HttpCertificate = IP12Certificate | IPemCertificate;
|
|
74
|
+
export type HttpCertificate = IP12Certificate | IPemCertificate | ICertificate;
|
|
75
75
|
|
|
76
76
|
export interface IPemCreateOptions {
|
|
77
77
|
type: 'p12';
|
|
@@ -128,7 +128,7 @@ export class Certificate {
|
|
|
128
128
|
* Timestamp when the certificate was inserted into the data store.
|
|
129
129
|
* Required when returning a result. Auto-generated when inserting, if missing.
|
|
130
130
|
*/
|
|
131
|
-
created
|
|
131
|
+
created = 0;
|
|
132
132
|
/**
|
|
133
133
|
* Certificate type. Either `p12` or `pem`.
|
|
134
134
|
*/
|
|
@@ -162,6 +162,7 @@ export class Certificate {
|
|
|
162
162
|
key: v4(),
|
|
163
163
|
name,
|
|
164
164
|
type: 'pem',
|
|
165
|
+
created: Date.now(),
|
|
165
166
|
};
|
|
166
167
|
if (keyPassphrase) {
|
|
167
168
|
init.certKey.passphrase = keyPassphrase;
|
|
@@ -185,6 +186,7 @@ export class Certificate {
|
|
|
185
186
|
key: v4(),
|
|
186
187
|
name,
|
|
187
188
|
type: 'p12',
|
|
189
|
+
created: Date.now(),
|
|
188
190
|
};
|
|
189
191
|
if (passphrase) {
|
|
190
192
|
init.cert.passphrase = passphrase;
|
|
@@ -224,6 +226,7 @@ export class Certificate {
|
|
|
224
226
|
key: _id,
|
|
225
227
|
name,
|
|
226
228
|
type: 'p12',
|
|
229
|
+
created,
|
|
227
230
|
};
|
|
228
231
|
return new Certificate(init);
|
|
229
232
|
}
|
|
@@ -231,16 +234,15 @@ export class Certificate {
|
|
|
231
234
|
}
|
|
232
235
|
|
|
233
236
|
constructor(certificate: HttpCertificate) {
|
|
234
|
-
const { type, cert, key = v4(), name = '', created } = certificate;
|
|
237
|
+
const { type, cert, key = v4(), name = '', created = Date.now() } = certificate;
|
|
235
238
|
this.key = key;
|
|
236
239
|
this.name = name;
|
|
237
240
|
this.type = type;
|
|
238
241
|
this.cert = Certificate.fromStore(cert);
|
|
239
|
-
|
|
240
|
-
this.created = created;
|
|
241
|
-
}
|
|
242
|
+
this.created = created;
|
|
242
243
|
if (type === 'pem') {
|
|
243
|
-
|
|
244
|
+
const typed = certificate as IPemCertificate;
|
|
245
|
+
this.certKey = Certificate.fromStore(typed.certKey);
|
|
244
246
|
}
|
|
245
247
|
}
|
|
246
248
|
|
|
@@ -288,12 +290,13 @@ export class Certificate {
|
|
|
288
290
|
}
|
|
289
291
|
|
|
290
292
|
toJSON(): HttpCertificate {
|
|
291
|
-
const result:
|
|
293
|
+
const result: HttpCertificate = {
|
|
292
294
|
kind: Kind,
|
|
293
295
|
key: this.key,
|
|
294
296
|
cert: Certificate.toStore(this.cert),
|
|
295
297
|
name: this.name,
|
|
296
|
-
type:
|
|
298
|
+
type: this.type,
|
|
299
|
+
created: this.created,
|
|
297
300
|
};
|
|
298
301
|
|
|
299
302
|
if (this.type === 'pem' && this.certKey) {
|
|
@@ -951,12 +951,15 @@ export class ArcProject extends ArcProjectParent {
|
|
|
951
951
|
init.kind = ArcProjectKind;
|
|
952
952
|
}
|
|
953
953
|
} else {
|
|
954
|
+
const now = Date.now();
|
|
954
955
|
init = {
|
|
955
956
|
kind: ArcProjectKind,
|
|
956
957
|
key: v4(),
|
|
957
958
|
definitions: {},
|
|
958
959
|
items: [],
|
|
959
960
|
info: Thing.fromName('').toJSON(),
|
|
961
|
+
created: now,
|
|
962
|
+
updated: now,
|
|
960
963
|
}
|
|
961
964
|
}
|
|
962
965
|
this.new(init);
|
|
@@ -1001,6 +1004,8 @@ export class ArcProject extends ArcProjectParent {
|
|
|
1001
1004
|
definitions: {},
|
|
1002
1005
|
items: [],
|
|
1003
1006
|
info: this.info.toJSON(),
|
|
1007
|
+
created: this.created,
|
|
1008
|
+
updated: this.updated,
|
|
1004
1009
|
};
|
|
1005
1010
|
if (Array.isArray(this.definitions.requests) && this.definitions.requests.length) {
|
|
1006
1011
|
result.definitions.requests = this.definitions.requests.map(i => i.toJSON());
|
|
@@ -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 { HttpCertificate } from '../../models/ClientCertificate.js';
|
|
13
|
+
import { HttpCertificate, IPemCertificate } 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';
|
|
@@ -645,6 +645,7 @@ Check your request parameters.`);
|
|
|
645
645
|
this.finalizeRequest(result);
|
|
646
646
|
} catch (e) {
|
|
647
647
|
const error = e as Error;
|
|
648
|
+
// eslint-disable-next-line no-console
|
|
648
649
|
console.error(error);
|
|
649
650
|
this._errorRequest({
|
|
650
651
|
message: (error && error.message) || 'Unknown error occurred',
|
|
@@ -797,6 +798,7 @@ Check your request parameters.`);
|
|
|
797
798
|
}
|
|
798
799
|
options.pfx.push(struct);
|
|
799
800
|
} else if (cert.type === 'pem') {
|
|
801
|
+
const typed = cert as IPemCertificate;
|
|
800
802
|
if (!options.cert) {
|
|
801
803
|
options.cert = [];
|
|
802
804
|
}
|
|
@@ -807,9 +809,9 @@ Check your request parameters.`);
|
|
|
807
809
|
options.cert = [];
|
|
808
810
|
}
|
|
809
811
|
}
|
|
810
|
-
const added = Buffer.from(
|
|
812
|
+
const added = Buffer.from(typed.cert.data as string);
|
|
811
813
|
options.cert.push(added);
|
|
812
|
-
if (
|
|
814
|
+
if (typed.certKey) {
|
|
813
815
|
if (!Array.isArray(options.key)) {
|
|
814
816
|
if (options.key) {
|
|
815
817
|
options.key = [options.key];
|
|
@@ -818,10 +820,10 @@ Check your request parameters.`);
|
|
|
818
820
|
}
|
|
819
821
|
}
|
|
820
822
|
const struct: tls.KeyObject = {
|
|
821
|
-
pem: Buffer.from(
|
|
823
|
+
pem: Buffer.from(typed.certKey.data as string),
|
|
822
824
|
};
|
|
823
|
-
if (
|
|
824
|
-
struct.passphrase =
|
|
825
|
+
if (typed.certKey.passphrase) {
|
|
826
|
+
struct.passphrase = typed.certKey.passphrase;
|
|
825
827
|
}
|
|
826
828
|
options.key.push(struct);
|
|
827
829
|
}
|