mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-12 08:32:39 +00:00
remove @zitadel/node, move fcn to /client
This commit is contained in:
@@ -46,6 +46,9 @@
|
||||
"dependencies": {
|
||||
"@bufbuild/protobuf": "^2.2.2",
|
||||
"@connectrpc/connect": "^2.0.0",
|
||||
"@connectrpc/connect-node": "^2.0.0",
|
||||
"@connectrpc/connect-web": "^2.0.0",
|
||||
"jose": "^5.3.0",
|
||||
"@zitadel/proto": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
26
packages/zitadel-client/src/grpc.ts
Normal file
26
packages/zitadel-client/src/grpc.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { createGrpcTransport, GrpcTransportOptions } from "@connectrpc/connect-node";
|
||||
import { importPKCS8, SignJWT } from "jose";
|
||||
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||
|
||||
/**
|
||||
* Create a server transport with the given token and configuration options.
|
||||
* @param token
|
||||
* @param opts
|
||||
*/
|
||||
export function createServerTransport(token: string, opts: GrpcTransportOptions) {
|
||||
return createGrpcTransport({
|
||||
...opts,
|
||||
interceptors: [...(opts.interceptors || []), NewAuthorizationBearerInterceptor(token)],
|
||||
});
|
||||
}
|
||||
|
||||
export async function newSystemToken() {
|
||||
return 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"));
|
||||
}
|
||||
@@ -5,3 +5,5 @@ export { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||
export { create, fromJson, toJson } from "@bufbuild/protobuf";
|
||||
export { TimestampSchema, timestampDate, timestampFromDate, timestampFromMs, timestampMs } from "@bufbuild/protobuf/wkt";
|
||||
export type { Duration, Timestamp } from "@bufbuild/protobuf/wkt";
|
||||
|
||||
export { createServerTransport, newSystemToken } from "./grpc";
|
||||
|
||||
Reference in New Issue
Block a user