mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 09:54:00 +00:00
29 lines
794 B
TypeScript
29 lines
794 B
TypeScript
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
|
|
|
|
import {
|
|
SessionServiceClient,
|
|
SessionServiceDefinition,
|
|
} from "../../proto/server/zitadel/session/v2alpha/session_service";
|
|
|
|
import { ZitadelServer, createClient, getServers } from "../../server";
|
|
|
|
export const getSession = (server?: string | ZitadelServer) => {
|
|
let config;
|
|
if (server && typeof server === "string") {
|
|
const apps = getServers();
|
|
config = apps.find((a) => a.name === server)?.config;
|
|
} else if (server && typeof server === "object") {
|
|
config = server.config;
|
|
}
|
|
|
|
if (!config) {
|
|
throw Error("No ZITADEL server found");
|
|
}
|
|
|
|
return createClient<SessionServiceClient>(
|
|
SessionServiceDefinition as CompatServiceDefinition,
|
|
config.apiUrl,
|
|
config.token
|
|
);
|
|
};
|