add grpc-web transport, fix release pnpm version

This commit is contained in:
Max Peintner
2025-01-08 14:20:16 +01:00
parent 6ce3b62dc2
commit ef1c8013eb
4 changed files with 21 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@zitadel/client": patch
---
add missing client transport utility

View File

@@ -22,7 +22,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
version: 10.0.0
- name: Install dependencies
run: pnpm install

View File

@@ -1,5 +1,5 @@
{
"packageManager": "pnpm@9.1.2+sha256.19c17528f9ca20bd442e4ca42f00f1b9808a9cb419383cd04ba32ef19322aba7",
"packageManager": "pnpm@10.0.0",
"private": true,
"name": "typescript-monorepo",
"scripts": {

View File

@@ -1,9 +1,10 @@
import { createGrpcTransport, GrpcTransportOptions } from "@connectrpc/connect-node";
import { createGrpcWebTransport } from "@connectrpc/connect-web";
import { importPKCS8, SignJWT } from "jose";
import { NewAuthorizationBearerInterceptor } from "./interceptors";
/**
* Create a server transport with the given token and configuration options.
* Create a server transport using grpc with the given token and configuration options.
* @param token
* @param opts
*/
@@ -14,6 +15,18 @@ export function createServerTransport(token: string, opts: GrpcTransportOptions)
});
}
/**
* Create a client transport using grpc web with the given token and configuration options.
* @param token
* @param opts
*/
export function createClientTransport(token: string, opts: GrpcTransportOptions) {
return createGrpcWebTransport({
...opts,
interceptors: [...(opts.interceptors || []), NewAuthorizationBearerInterceptor(token)],
});
}
export async function newSystemToken() {
return await new SignJWT({})
.setProtectedHeader({ alg: "RS256" })