mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 00:27:31 +00:00
instance domain callback
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { importPKCS8, SignJWT } from "jose";
|
||||
import { getInstanceByHost } from "./zitadel";
|
||||
import { getInstanceDomainByHost } from "./zitadel";
|
||||
|
||||
export async function getInstanceUrl(host: string): Promise<string> {
|
||||
const [hostname, port] = host.split(":");
|
||||
@@ -9,26 +9,18 @@ export async function getInstanceUrl(host: string): Promise<string> {
|
||||
return process.env.ZITADEL_API_URL || "";
|
||||
}
|
||||
|
||||
const instance = await getInstanceByHost(host).catch((error) => {
|
||||
const instanceDomain = await getInstanceDomainByHost(host).catch((error) => {
|
||||
console.error(`Could not get instance by host ${host}`, error);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (!instance) {
|
||||
if (!instanceDomain) {
|
||||
throw new Error("No instance found");
|
||||
}
|
||||
|
||||
const generatedDomain = instance.domains.find(
|
||||
(domain) => domain.generated === true,
|
||||
);
|
||||
console.log(`host: ${host}, api: ${instanceDomain}`);
|
||||
|
||||
if (!generatedDomain?.domain) {
|
||||
throw new Error("No generated domain found");
|
||||
}
|
||||
|
||||
console.log(`host: ${host}, api: ${generatedDomain?.domain}`);
|
||||
|
||||
return generatedDomain?.domain;
|
||||
return instanceDomain;
|
||||
}
|
||||
|
||||
export async function systemAPIToken() {
|
||||
|
@@ -66,9 +66,9 @@ const systemService = async () => {
|
||||
return createSystemServiceClient(transport);
|
||||
};
|
||||
|
||||
export async function getInstanceByHost(host: string): Promise<string> {
|
||||
export async function getInstanceDomainByHost(host: string): Promise<string> {
|
||||
// const system = await systemService();
|
||||
// const callback = system
|
||||
// const callbacks = system
|
||||
// .listInstances(
|
||||
// {
|
||||
// queries: [
|
||||
@@ -89,7 +89,15 @@ export async function getInstanceByHost(host: string): Promise<string> {
|
||||
// throw new Error("Could not find instance");
|
||||
// }
|
||||
|
||||
// return resp.result[0];
|
||||
// const generatedDomain = resp.result[0].domains.find(
|
||||
// (domain) => domain.generated === true,
|
||||
// );
|
||||
|
||||
// if (!generatedDomain) {
|
||||
// throw new Error("Could not find generated domain");
|
||||
// }
|
||||
|
||||
// return generatedDomain.domain;
|
||||
// });
|
||||
|
||||
const mockFcn = async (host: string) => {
|
||||
|
Reference in New Issue
Block a user