mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 23:27:31 +00:00
fix: grpc web transport export
This commit is contained in:
5
.changeset/shiny-islands-sparkle.md
Normal file
5
.changeset/shiny-islands-sparkle.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@zitadel/client": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix export for grpcweb transport
|
@@ -31,6 +31,11 @@
|
|||||||
"types": "./dist/node.d.ts",
|
"types": "./dist/node.d.ts",
|
||||||
"import": "./dist/node.js",
|
"import": "./dist/node.js",
|
||||||
"require": "./dist/node.cjs"
|
"require": "./dist/node.cjs"
|
||||||
|
},
|
||||||
|
"./web": {
|
||||||
|
"types": "./dist/web.d.ts",
|
||||||
|
"import": "./dist/web.js",
|
||||||
|
"require": "./dist/web.cjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { createGrpcTransport, GrpcTransportOptions } from "@connectrpc/connect-node";
|
import { createGrpcTransport, GrpcTransportOptions } from "@connectrpc/connect-node";
|
||||||
import { createGrpcWebTransport } from "@connectrpc/connect-web";
|
|
||||||
import { importPKCS8, SignJWT } from "jose";
|
import { importPKCS8, SignJWT } from "jose";
|
||||||
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||||
|
|
||||||
@@ -15,18 +14,6 @@ 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({
|
export async function newSystemToken({
|
||||||
audience,
|
audience,
|
||||||
subject,
|
subject,
|
||||||
|
15
packages/zitadel-client/src/web.ts
Normal file
15
packages/zitadel-client/src/web.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { GrpcTransportOptions } from "@connectrpc/connect-node";
|
||||||
|
import { createGrpcWebTransport } from "@connectrpc/connect-web";
|
||||||
|
import { NewAuthorizationBearerInterceptor } from "./interceptors";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)],
|
||||||
|
});
|
||||||
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
import { defineConfig, Options } from "tsup";
|
import { defineConfig, Options } from "tsup";
|
||||||
|
|
||||||
export default defineConfig((options: Options) => ({
|
export default defineConfig((options: Options) => ({
|
||||||
entry: ["src/index.ts", "src/v1.ts", "src/v2.ts", "src/v3alpha.ts", "src/node.ts"],
|
entry: ["src/index.ts", "src/v1.ts", "src/v2.ts", "src/v3alpha.ts", "src/node.ts", "src/web.ts"],
|
||||||
format: ["esm", "cjs"],
|
format: ["esm", "cjs"],
|
||||||
treeshake: false,
|
treeshake: false,
|
||||||
splitting: true,
|
splitting: true,
|
||||||
|
Reference in New Issue
Block a user