Skip to content

Commit 0888bc6

Browse files
committed
feat: allowing async function for verifyCallback
[ci skip]
1 parent ee39469 commit 0888bc6

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/QUICConnection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,9 @@ class QUICConnection extends EventTarget {
823823
);
824824
try {
825825
// Running verify callback if available
826-
if (this.verifyCallback != null) this.verifyCallback(peerCertsPem);
826+
if (this.verifyCallback != null) {
827+
await this.verifyCallback(peerCertsPem);
828+
}
827829
this.logger.debug('TLS verification succeeded');
828830
// Generate ack frame to satisfy the short + 1 condition of secure establishment
829831
this.conn.sendAckEliciting();

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ type QUICConfig = {
307307
enableEarlyData: boolean;
308308
};
309309

310-
type VerifyCallback = (certs: Array<string>) => void;
310+
type VerifyCallback = (certs: Array<string>) => Promise<void> | void;
311311

312312
export type {
313313
Opaque,

tests/QUICClient.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ describe(QUICClient.name, () => {
13271327
},
13281328
);
13291329
await connectionEventProm.p;
1330-
// Connection would timeout after 100ms if keep alive didn't work
1330+
// Connection would time out after 100ms if keep alive didn't work
13311331
await Promise.race([
13321332
sleep(300),
13331333
clientTimeoutProm.p.then(() => {
@@ -1517,7 +1517,7 @@ describe(QUICClient.name, () => {
15171517
verifyPeer: true,
15181518
verifyAllowFail: true,
15191519
},
1520-
verifyCallback: (certs) => {
1520+
verifyCallback: async (certs) => {
15211521
verifyProm.resolveP(certs);
15221522
},
15231523
});
@@ -1600,7 +1600,7 @@ describe(QUICClient.name, () => {
16001600
verifyPeer: true,
16011601
verifyAllowFail: true,
16021602
},
1603-
verifyCallback: (certs) => {
1603+
verifyCallback: async (certs) => {
16041604
verifyProm.resolveP(certs);
16051605
},
16061606
});
@@ -1722,7 +1722,7 @@ describe(QUICClient.name, () => {
17221722
port: 55555 as Port,
17231723
});
17241724
// If the server is slow to respond then this will time out.
1725-
// Then main cause of this was the server not processing the inititial packet
1725+
// Then main cause of this was the server not processing the initial packet
17261726
// that creates the `QUICConnection`, as a result, the whole creation waited
17271727
// an extra 1 second for the client to retry the initial packet.
17281728
const client = await QUICClient.createQUICClient(

0 commit comments

Comments
 (0)