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

@@ -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" })