mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-11 21:42:11 +00:00
tailwind package
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
|
||||
|
||||
import { createChannel, createClientFactory } from "nice-grpc";
|
||||
import {
|
||||
AuthServiceClient,
|
||||
AuthServiceDefinition,
|
||||
} from "./proto/server/zitadel/auth";
|
||||
import {
|
||||
AdminServiceClient,
|
||||
AdminServiceDefinition,
|
||||
} from "./proto/server/zitadel/admin";
|
||||
import { authMiddleware } from "./middleware";
|
||||
|
||||
const createClient = <Client>(
|
||||
definition: CompatServiceDefinition,
|
||||
accessToken: string
|
||||
) => {
|
||||
const channel = createChannel(process.env.ZITADEL_API_URL ?? "");
|
||||
return createClientFactory()
|
||||
.use(authMiddleware(accessToken))
|
||||
.create(definition, channel) as Client;
|
||||
};
|
||||
|
||||
export const getAdmin = () =>
|
||||
createClient<AdminServiceClient>(
|
||||
AdminServiceDefinition as CompatServiceDefinition,
|
||||
process.env.ZITADEL_ADMIN_TOKEN ?? ""
|
||||
);
|
||||
@@ -1,25 +1,19 @@
|
||||
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
|
||||
import { createChannel, createClientFactory } from "nice-grpc";
|
||||
import {
|
||||
AuthServiceClient,
|
||||
AuthServiceDefinition,
|
||||
} from "./proto/server/zitadel/auth";
|
||||
import { ZitadelApp } from "./app";
|
||||
import { authMiddleware } from "./middleware";
|
||||
|
||||
const createClient = <Client>(
|
||||
definition: CompatServiceDefinition,
|
||||
accessToken: string
|
||||
) => {
|
||||
const channel = createChannel(process.env.ZITADEL_API_URL ?? "");
|
||||
return createClientFactory()
|
||||
.use(authMiddleware(accessToken))
|
||||
.create(definition, channel) as Client;
|
||||
};
|
||||
// const createClient = <Client>(
|
||||
// definition: CompatServiceDefinition,
|
||||
// accessToken: string
|
||||
// ) => {
|
||||
// const channel = createChannel(process.env.ZITADEL_API_URL ?? "");
|
||||
// return createClientFactory()
|
||||
// .use(authMiddleware(accessToken))
|
||||
// .create(definition, channel) as Client;
|
||||
// };
|
||||
|
||||
export async function getAuth(app?: ZitadelApp): Promise<AuthServiceClient> {
|
||||
return createClient<AuthServiceClient>(
|
||||
AuthServiceDefinition as CompatServiceDefinition,
|
||||
""
|
||||
);
|
||||
export async function getAuth(app?: ZitadelApp) {
|
||||
// return createClient<AuthServiceClient>(
|
||||
// AuthServiceDefinition as CompatServiceDefinition,
|
||||
// ""
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
export { initializeApp, getApps } from "./app";
|
||||
|
||||
export { getAuth } from "./auth";
|
||||
export { getManagement } from "./management";
|
||||
export { getAdmin } from "./admin";
|
||||
export { getSystem } from "./system";
|
||||
|
||||
export type { ZitadelOptions } from "./app";
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
|
||||
|
||||
import { createChannel, createClientFactory } from "nice-grpc";
|
||||
import {
|
||||
ManagementServiceClient,
|
||||
ManagementServiceDefinition,
|
||||
} from "./proto/server/zitadel/management";
|
||||
|
||||
import { authMiddleware } from "./middleware";
|
||||
import { ZitadelApp, getApps } from "./app";
|
||||
|
||||
const createClient = <Client>(
|
||||
definition: CompatServiceDefinition,
|
||||
apiUrl: string,
|
||||
token: string
|
||||
) => {
|
||||
if (!apiUrl) {
|
||||
throw Error("ZITADEL_API_URL not set");
|
||||
}
|
||||
|
||||
const channel = createChannel(process.env.ZITADEL_API_URL ?? "");
|
||||
return createClientFactory()
|
||||
.use(authMiddleware(token))
|
||||
.create(definition, channel) as Client;
|
||||
};
|
||||
|
||||
export const getManagement = (app?: string | ZitadelApp) => {
|
||||
let config;
|
||||
if (app && typeof app === "string") {
|
||||
const apps = getApps();
|
||||
config = apps.find((a) => a.name === app)?.config;
|
||||
} else if (app && typeof app === "object") {
|
||||
config = app.config;
|
||||
}
|
||||
|
||||
if (!config) {
|
||||
throw Error("No ZITADEL app found");
|
||||
}
|
||||
|
||||
return createClient<ManagementServiceClient>(
|
||||
ManagementServiceDefinition as CompatServiceDefinition,
|
||||
config.apiUrl,
|
||||
config.token
|
||||
);
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CallOptions, ClientMiddlewareCall, Metadata } from "nice-grpc";
|
||||
import { CallOptions, ClientMiddlewareCall, Metadata } from "nice-grpc-web";
|
||||
|
||||
export const authMiddleware = (token: string) =>
|
||||
async function* <Request, Response>(
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { CompatServiceDefinition } from "nice-grpc/lib/service-definitions";
|
||||
import { importPKCS8, SignJWT } from "jose";
|
||||
|
||||
import { createChannel, createClientFactory } from "nice-grpc";
|
||||
import {
|
||||
SystemServiceClient,
|
||||
SystemServiceDefinition,
|
||||
} from "./proto/server/zitadel/system";
|
||||
import { authMiddleware } from "./middleware";
|
||||
|
||||
const createSystemClient = <Client>(
|
||||
definition: CompatServiceDefinition,
|
||||
accessToken: string
|
||||
) => {
|
||||
const channel = createChannel(process.env.ZITADEL_SYSTEM_API_URL ?? "");
|
||||
return createClientFactory()
|
||||
.use(authMiddleware(accessToken))
|
||||
.create(definition, channel) as Client;
|
||||
};
|
||||
|
||||
export const getSystem = async () => {
|
||||
const token = await new SignJWT({})
|
||||
.setProtectedHeader({ alg: "RS256" })
|
||||
.setIssuedAt()
|
||||
.setExpirationTime("1h")
|
||||
.setIssuer(process.env.ZITADEL_SYSTEM_API_USERID ?? "")
|
||||
.setSubject(process.env.ZITADEL_SYSTEM_API_USERID ?? "")
|
||||
.setAudience(process.env.ZITADEL_ISSUER ?? "")
|
||||
.sign(await importPKCS8(process.env.ZITADEL_SYSTEM_API_KEY ?? "", "RS256"));
|
||||
|
||||
return createSystemClient<SystemServiceClient>(
|
||||
SystemServiceDefinition as CompatServiceDefinition,
|
||||
token
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user