mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 05:06:55 +00:00
move transport out of package
This commit is contained in:
@@ -1,22 +1,14 @@
|
|||||||
import { createSessionServiceClient } from "@zitadel/client/v2";
|
|
||||||
import { createServerTransport } from "@zitadel/node";
|
|
||||||
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
import { Session } from "@zitadel/proto/zitadel/session/v2/session_pb";
|
||||||
|
import { GetSessionResponse } from "@zitadel/proto/zitadel/session/v2/session_service_pb";
|
||||||
import { getMostRecentCookieWithLoginname } from "./cookies";
|
import { getMostRecentCookieWithLoginname } from "./cookies";
|
||||||
|
|
||||||
const SESSION_LIFETIME_S = 3000;
|
export async function loadMostRecentSession(
|
||||||
|
sessionService: any, // TODO: SessionServiceClient,
|
||||||
const transport = createServerTransport(process.env.ZITADEL_SERVICE_USER_TOKEN!, {
|
loginName?: string,
|
||||||
baseUrl: process.env.ZITADEL_API_URL!,
|
organization?: string,
|
||||||
httpVersion: "2",
|
): Promise<Session | undefined> {
|
||||||
});
|
|
||||||
|
|
||||||
const sessionService = createSessionServiceClient(transport);
|
|
||||||
|
|
||||||
export async function loadMostRecentSession(loginName?: string, organization?: string): Promise<Session | undefined> {
|
|
||||||
const recent = await getMostRecentCookieWithLoginname(loginName, organization);
|
const recent = await getMostRecentCookieWithLoginname(loginName, organization);
|
||||||
return getMostRecentSession(recent.id, recent.token);
|
return sessionService
|
||||||
}
|
.getSession({ sessionId: recent.id, sessionToken: recent.token }, {})
|
||||||
|
.then((resp: GetSessionResponse) => resp.session);
|
||||||
async function getMostRecentSession(sessionId: string, sessionToken: string) {
|
|
||||||
return sessionService.getSession({ sessionId, sessionToken }, {}).then((resp) => resp.session);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user