UNPKG

@primerouting/zitadel-node

Version:

Library for API access to ZITADEL. Provides compiled gRPC service clients and helpers for applications and service accounts. Support http2 self-hosted instances

104 lines (103 loc) 5.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAdminClient = createAdminClient; exports.createAuthClient = createAuthClient; exports.createManagementClient = createManagementClient; exports.createUserClientV2 = createUserClientV2; exports.createOrganizationClientV2 = createOrganizationClientV2; const nice_grpc_1 = require("nice-grpc"); const admin_1 = require("./generated/zitadel/admin"); const auth_1 = require("./generated/zitadel/auth"); const management_1 = require("./generated/zitadel/management"); const user_service_1 = require("./generated/zitadel/user/v2/user_service"); const org_service_1 = require("./generated/zitadel/org/v2/org_service"); /** * Create a new gRPC service client for the [Admin API](https://docs.zitadel.com/docs/apis/proto/admin) of ZITADEL. * The client can be configured with multiple client interceptors. For authentication interceptors, * see the interceptors in this package. * * @param apiEndpoint The API endpoint of your ZITADEL instance. * @param interceptors A list of interceptors that should be used for the client. * * @returns A new gRPC service client for the [Admin API](https://docs.zitadel.com/docs/apis/proto/admin) of ZITADEL. */ function createAdminClient(apiEndpoint, ...interceptors) { const channel = (0, nice_grpc_1.createChannel)(apiEndpoint); let factory = (0, nice_grpc_1.createClientFactory)(); for (const interceptor of interceptors) { factory = factory.use(interceptor); } return factory.create(admin_1.AdminServiceDefinition, channel); } /** * Create a new gRPC service client for the [Auth API](https://docs.zitadel.com/docs/apis/proto/auth) of ZITADEL. * The client can be configured with multiple client interceptors. For authentication interceptors, * see the interceptors in this package. * * @param apiEndpoint The API endpoint of your ZITADEL instance. * @param interceptors A list of interceptors that should be used for the client. * * @returns A new gRPC service client for the [Auth API](https://docs.zitadel.com/docs/apis/proto/auth) of ZITADEL. */ function createAuthClient(apiEndpoint, ...interceptors) { const channel = (0, nice_grpc_1.createChannel)(apiEndpoint); let factory = (0, nice_grpc_1.createClientFactory)(); for (const interceptor of interceptors) { factory = factory.use(interceptor); } return factory.create(auth_1.AuthServiceDefinition, channel); } /** * Create a new gRPC service client for the [Management API](https://docs.zitadel.com/docs/apis/proto/management) of ZITADEL. * The client can be configured with multiple client interceptors. For authentication interceptors, * see the interceptors in this package. * * @param apiEndpoint The API endpoint of your ZITADEL instance. * @param interceptors A list of interceptors that should be used for the client. * * @returns A new gRPC service client for the [Management API](https://docs.zitadel.com/docs/apis/proto/management) of ZITADEL. */ function createManagementClient(apiEndpoint, ...interceptors) { const channel = (0, nice_grpc_1.createChannel)(apiEndpoint); let factory = (0, nice_grpc_1.createClientFactory)(); for (const interceptor of interceptors) { factory = factory.use(interceptor); } return factory.create(management_1.ManagementServiceDefinition, channel); } /** * Create a new gRPC service client for the [UserService V2 API](https://zitadel.com/docs/apis/resources/user_service_v2/user-service) of ZITADEL. * The client can be configured with multiple client interceptors. For authentication interceptors, * see the interceptors in this package. * * @param apiEndpoint The API endpoint of your ZITADEL instance. * @param interceptors A list of interceptors that should be used for the client. * * @returns A new gRPC service client for the [UserService V2 API](https://zitadel.com/docs/apis/resources/user_service_v2/user-service) of ZITADEL. */ function createUserClientV2(apiEndpoint, ...interceptors) { const channel = (0, nice_grpc_1.createChannel)(apiEndpoint); let factory = (0, nice_grpc_1.createClientFactory)(); for (const interceptor of interceptors) { factory = factory.use(interceptor); } return factory.create(user_service_1.UserServiceDefinition, channel); } /** * Create a new gRPC service client for the [OrganizationService V2 API](https://zitadel.com/docs/apis/resources/organization_service_v2/organization-service) of ZITADEL. * The client can be configured with multiple client interceptors. For authentication interceptors, * see the interceptors in this package. * * @param apiEndpoint The API endpoint of your ZITADEL instance. * @param interceptors A list of interceptors that should be used for the client. * * @returns A new gRPC service client for the [OrganizationService V2 API](https://zitadel.com/docs/apis/resources/organization_service_v2/organization-service) of ZITADEL. */ function createOrganizationClientV2(apiEndpoint, ...interceptors) { const channel = (0, nice_grpc_1.createChannel)(apiEndpoint); let factory = (0, nice_grpc_1.createClientFactory)(); for (const interceptor of interceptors) { factory = factory.use(interceptor); } return factory.create(org_service_1.OrganizationServiceDefinition, channel); }