Skip to content

Commit

Permalink
Merge pull request #334 from zitadel/fix-missing-client-transport
Browse files Browse the repository at this point in the history
fix: add grpc-web transport, fix release pnpm version
  • Loading branch information
eliobischof authored Jan 8, 2025
2 parents 6ce3b62 + 1c668f2 commit a56afd0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-berries-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zitadel/client": patch
---

add missing client transport utility
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Install dependencies
run: pnpm install
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
node-version: 20.x
cache: 'pnpm'

- uses: actions/cache@v4.0.2
name: Setup Cypress binary cache
- name: Setup Cypress binary cache
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-cypress-binary-${{ hashFiles('**/pnpm-lock.yaml') }}
Expand All @@ -86,8 +86,8 @@ jobs:
- run: echo "PLAYWRIGHT_VERSION=$(npx playwright --version | cut -d ' ' -f 2)" >> $GITHUB_ENV
if: ${{ startsWith(matrix.command, 'test:acceptance') }}

- uses: actions/cache@v4.0.2
name: Setup Playwright binary cache
- name: Setup Playwright binary cache
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
Expand Down
15 changes: 14 additions & 1 deletion packages/zitadel-client/src/node.ts
Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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" })
Expand Down

0 comments on commit a56afd0

Please sign in to comment.