@zitadel/sdk-next 0.1.0-alpha.18 → 0.1.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +22 -19
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -207,15 +207,17 @@ import dynamic from 'next/dynamic';
207
207
 
208
208
  const ZitadelLogin = dynamic(
209
209
  async () => {
210
- await import('@zitadel/components');
210
+ // The /client entry registers the custom elements AND re-exports
211
+ // configureZitadel, so an app that only declares @zitadel/sdk-next
212
+ // resolves everything it needs (strict package managers would not
213
+ // resolve @zitadel/api or @zitadel/components transitively).
214
+ const { configureZitadel } = await import('@zitadel/sdk-next/client');
215
+ configureZitadel({
216
+ projectId: process.env.NEXT_PUBLIC_ZITADEL_PROJECT_ID!,
217
+ proxyPath: '/__nextgen',
218
+ });
211
219
  return function ZitadelLoginElement() {
212
- return (
213
- <zitadel-login
214
- api-base="/__nextgen"
215
- project-id="demo"
216
- post-sign-in-url="/admin"
217
- />
218
- );
220
+ return <zitadel-login post-sign-in-url="/admin" />;
219
221
  };
220
222
  },
221
223
  { ssr: false },
@@ -226,6 +228,10 @@ export function LoginWidget() {
226
228
  }
227
229
  ```
228
230
 
231
+ There is no `api-base` attribute — the element reads the global handle from
232
+ `configureZitadel()` (or you can assign the returned handle to the element's
233
+ `project` property).
234
+
229
235
  ## Middleware options
230
236
 
231
237
  | Option | Type | Default | Description |
@@ -240,18 +246,15 @@ export function LoginWidget() {
240
246
  | `clockSkewMs` | `number` | `5000` | Clock skew tolerance in ms for `exp`, `nbf`, `iat` |
241
247
  | `jwksTimeoutMs` | `number` | `5000` | Timeout in ms for JWKS endpoint requests. Token is rejected if the fetch exceeds this window |
242
248
  | `opaqueTokenTimeoutMs` | `number` | `5000` | Timeout in ms for opaque (non-JWT) session validation via `GET /sessions/me`. Also accepted by `auth()` |
249
+ | `proxyTimeoutMs` | `number` | `5000` | Timeout in ms for upstream proxy requests; requests exceeding it abort with a network error |
250
+ | `jwtKey` | `string` | unset | Reserved for future use — local PEM public key for offline JWT verification |
243
251
  | `audience` | `string \| string[]` | not validated | Expected `aud` claim value(s). When omitted, audience is not checked |
244
252
 
245
253
  ## How JWT verification works
246
254
 
247
- 1. Bearer token from `Authorization` header is checked first; `__nextgen_session` cookie is the fallback
248
- 2. The JWT header is decoded to extract `kid` and `alg`
249
- 3. Tokens with an `alg` not in `allowedAlgorithms` (`RS256`, `ES256` by default) are rejected immediately — no JWKS fetch
250
- 4. Tokens with a `typ` not in `allowedTokenTypes` are rejected immediately
251
- 5. The public key is fetched from `{url}/auth/keys` (JWKS) using the Web Crypto API, with a 5 s timeout, and cached for 5 minutes per `kid`
252
- 6. The signature is verified **before** any claim checks
253
- 7. `iss` must be present and must equal `url` — tokens without an issuer are rejected
254
- 8. `exp` must be present and must be in the future (with `clockSkewMs` tolerance) — tokens without an expiry are rejected
255
- 9. `nbf` and `iat` are validated with `clockSkewMs` tolerance when present
256
- 10. The `x-nextgen-auth-token` header is stripped from all proxied requests to prevent internal state leakage
257
- 11. `auth()` re-applies the same verification to the tunnelled token in the server runtime — the header alone is never treated as proof of a session
255
+ The verification pipeline is shared across SDKs and documented once in
256
+ [`@zitadel/sdk-core`](https://github.com/zitadel/nextgen/tree/main/packages/sdk-core#how-jwt-verification-works).
257
+ On top of that pipeline, the Next.js middleware adds:
258
+
259
+ 1. The `x-nextgen-auth-token` header is stripped from all proxied requests to prevent internal state leakage
260
+ 2. `auth()` re-applies the same verification to the tunnelled token in the server runtime — the header alone is never treated as proof of a session
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zitadel/sdk-next",
3
- "version": "0.1.0-alpha.18",
3
+ "version": "0.1.0-alpha.19",
4
4
  "description": "Next.js helpers and mock auth UI for Zitadel",
5
5
  "homepage": "https://github.com/zitadel/nextgen/tree/main/packages/sdk-next#readme",
6
6
  "bugs": {
@@ -55,9 +55,9 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "server-only": "^0.0.1",
58
- "@zitadel/api": "0.1.0-alpha.18",
59
- "@zitadel/components": "0.1.0-alpha.18",
60
- "@zitadel/sdk-core": "0.1.0-alpha.18"
58
+ "@zitadel/api": "0.1.0-alpha.19",
59
+ "@zitadel/sdk-core": "0.1.0-alpha.19",
60
+ "@zitadel/components": "0.1.0-alpha.19"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "next": ">=15",