*Add api for getSupportedTlds

This commit is contained in:
Derrick Hammer 2022-08-19 11:20:33 -04:00
parent 9818d17a06
commit 2b747e72fa
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@ let resolver: ResolverModule;
export function setup(rm: ResolverModule) { export function setup(rm: ResolverModule) {
addHandler("resolve", handleResolve); addHandler("resolve", handleResolve);
addHandler("register", handleRegister); addHandler("register", handleRegister);
addHandler("getSupportedTlds", handleGetSupportedTlds);
onmessage = handleMessage; onmessage = handleMessage;
resolver = rm; resolver = rm;
} }
@ -42,4 +43,8 @@ async function handleResolve(aq: ActiveQuery) {
aq.respond(ret); aq.respond(ret);
} }
function handleGetSupportedTlds(aq: ActiveQuery) {
aq.respond(resolver.getSupportedTlds());
}
export * from "./resolverRegistry.js"; export * from "./resolverRegistry.js";

View File

@ -71,6 +71,14 @@ export class ResolverModule {
return resolverError(err); return resolverError(err);
} }
return ret;
}
async getSupportedTlds(): Promise<string[]> {
const [ret, err] = await callModule(this.domain, "getSupportedTlds");
if (err) {
throw new Error(err);
}
return ret; return ret;
} }
} }