feat: update deno-github-mode.ts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
getFetchAutoProxyInit,
|
||||
} from "https://hatter.ink/script/fetch/library/deno-fetch-auto-proxy-mod.ts?202501191421";
|
||||
fetchWithTimoutAndAutoProxy,
|
||||
} from "https://hatter.ink/script/fetch/library/deno-fetch-auto-proxy-mod.ts?202501191815";
|
||||
|
||||
export class SshKey {
|
||||
algorithm: string;
|
||||
@@ -35,15 +35,7 @@ export async function fetchKeys(
|
||||
timeout?: number,
|
||||
): Promise<Array<SshKey>> {
|
||||
const url = `https://github.com/${username}.keys`;
|
||||
const fetchTimeout = timeout || 10000;
|
||||
const abortController = new AbortController();
|
||||
const timoutHandler = setTimeout(() => {
|
||||
abortController.abort(`Timout ${fetchTimeout} ms`);
|
||||
}, fetchTimeout);
|
||||
const init = getFetchAutoProxyInit() || {};
|
||||
init.signal = abortController.signal;
|
||||
const response = await fetch(url, init);
|
||||
const responseText = await response.text();
|
||||
clearTimeout(timoutHandler);
|
||||
const response = await fetchWithTimoutAndAutoProxy(url, timeout);
|
||||
const responseText: string = await response.text();
|
||||
return responseText.trim().split("\n").map((k) => SshKey.parseSshKey(k));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user