fix: address widget review feedback
This commit is contained in:
1 parent
b1b17ad69f
commit
a38e731209
79 files changed
+2138
-244
No files matched your search
@@ -1,8 +1,9 @@
|
||||
import type { AgentOptions } from "node:https";
|
||||
import { Agent as HttpsAgent } from "node:https";
|
||||
import type { LookupFunction } from "node:net";
|
||||
import { checkServerIdentity } from "node:tls";
|
||||
import axios from "axios";
|
||||
import type { Agent as UndiciAgent, RequestInfo, RequestInit, Response } from "undici";
|
||||
import type { EnvHttpProxyAgent as UndiciEnvHttpProxyAgent, RequestInfo, RequestInit, Response } from "undici";
|
||||
import { fetch } from "undici";
|
||||
|
||||
import {
|
||||
@@ -30,17 +31,25 @@ export const createCustomCheckServerIdentity = (
|
||||
};
|
||||
|
||||
export const createCertificateAgentAsync = async (
|
||||
override?: {
|
||||
override?: Partial<{
|
||||
ca: string | string[];
|
||||
checkServerIdentity: typeof checkServerIdentity;
|
||||
},
|
||||
agentOptions?: Pick<UndiciAgent.Options, "bodyTimeout">,
|
||||
lookup: LookupFunction;
|
||||
}>,
|
||||
agentOptions?: Pick<
|
||||
UndiciEnvHttpProxyAgent.Options,
|
||||
"autoSelectFamily" | "bodyTimeout" | "httpProxy" | "httpsProxy" | "noProxy"
|
||||
>,
|
||||
) => {
|
||||
const ca = override?.ca ?? (await getAllTrustedCertificatesAsync());
|
||||
const identityCheck =
|
||||
override?.checkServerIdentity ?? createCustomCheckServerIdentity(await getTrustedCertificateHostnamesAsync());
|
||||
return new UndiciHttpAgent({
|
||||
...agentOptions,
|
||||
connect: override ?? {
|
||||
ca: await getAllTrustedCertificatesAsync(),
|
||||
checkServerIdentity: createCustomCheckServerIdentity(await getTrustedCertificateHostnamesAsync()),
|
||||
connect: {
|
||||
ca,
|
||||
checkServerIdentity: identityCheck,
|
||||
...(override?.lookup ? { lookup: override.lookup } : {}),
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user