@@ -4,28 +4,30 @@ import * as https from "node:https";
4
4
import { Agent } from "undici" ;
5
5
import createClient from "../../src/index.js" ;
6
6
import * as forge from "node-forge" ;
7
- import * as crypto from "crypto" ;
8
- import httpServer from "express/lib/application.js" ;
7
+ import * as crypto from "node:crypto" ;
9
8
10
9
const pki = forge . pki ;
11
10
12
- const genCACert = async ( options = { } ) => {
13
- options = {
11
+ const genCACert = async ( opts = { } ) => {
12
+ const options = {
14
13
...{
15
14
commonName : "Testing CA - DO NOT TRUST" ,
16
15
bits : 2048 ,
17
16
} ,
18
- ...options ,
17
+ ...opts ,
19
18
} ;
20
19
21
- let keyPair = await new Promise ( ( res , rej ) => {
20
+ const keyPair = await new Promise ( ( res , rej ) => {
22
21
pki . rsa . generateKeyPair ( { bits : options . bits } , ( error , pair ) => {
23
- if ( error ) rej ( error ) ;
24
- else res ( pair ) ;
22
+ if ( error ) {
23
+ rej ( error ) ;
24
+ } else {
25
+ res ( pair ) ;
26
+ }
25
27
} ) ;
26
28
} ) ;
27
29
28
- let cert = pki . createCertificate ( ) ;
30
+ const cert = pki . createCertificate ( ) ;
29
31
cert . publicKey = keyPair . publicKey ;
30
32
cert . serialNumber = crypto . randomUUID ( ) . replace ( / - / g, "" ) ;
31
33
@@ -70,9 +72,9 @@ app.get("/v1/foo", (req, res) => {
70
72
} ) ;
71
73
72
74
test ( "requestInitExt" , async ( ) => {
73
- let cert = await genCACert ( ) ;
74
- let buffers = caToBuffer ( cert . ca ) ;
75
- let options = { } ;
75
+ const cert = await genCACert ( ) ;
76
+ const buffers = caToBuffer ( cert . ca ) ;
77
+ const options = { } ;
76
78
options . key = buffers . key ;
77
79
options . cert = buffers . cert ;
78
80
const httpsServer = https . createServer ( options , app ) ;
0 commit comments