@zitadel/sdk-nuxt 0.1.0-alpha.17 → 0.1.0-alpha.18

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.
@@ -96,7 +96,7 @@ async function proxyRequest(event, authUrl, proxyPath, url, proxyTimeoutMs) {
96
96
  const rawBody = hasBody ? await readRawBody(event, false) : void 0;
97
97
  const body = rawBody != null ? new Uint8Array(rawBody) : void 0;
98
98
  const upstreamHeaders = buildUpstreamHeaders(event);
99
- if (!upstreamHeaders.has("authorization")) {
99
+ if (requiresProjectSecret(method, suffix) && !upstreamHeaders.has("authorization")) {
100
100
  const config = useRuntimeConfig();
101
101
  const projectSecret = config.nextgen?.projectSecret;
102
102
  if (projectSecret) {
@@ -130,6 +130,9 @@ async function proxyRequest(event, authUrl, proxyPath, url, proxyTimeoutMs) {
130
130
  }
131
131
  return response.body;
132
132
  }
133
+ function requiresProjectSecret(method, pathname) {
134
+ return method.toUpperCase() === "POST" && pathname === "/sessions/exchange";
135
+ }
133
136
  var DECODER = new TextDecoder();
134
137
  function isJwtShaped(token) {
135
138
  const parts = token.split(".");
@@ -193,13 +196,14 @@ async function handleAuth(event, opts) {
193
196
  };
194
197
  return;
195
198
  }
199
+ let liveAnonymousSession = false;
196
200
  if (!payload && cookieToken && !isJwtShaped(cookieToken)) {
197
201
  const opaqueResult = await validateOpaqueSessionToken(cookieToken, url, opaqueTokenTimeoutMs);
198
- if (opaqueResult) {
202
+ if (opaqueResult?.userId) {
199
203
  event.context.nextgenAuth = {
200
204
  isAuthenticated: true,
201
205
  session: {
202
- userId: opaqueResult.userId ?? "unknown",
206
+ userId: opaqueResult.userId,
203
207
  email: null,
204
208
  name: null,
205
209
  token: cookieToken
@@ -207,11 +211,14 @@ async function handleAuth(event, opts) {
207
211
  };
208
212
  return;
209
213
  }
214
+ liveAnonymousSession = opaqueResult !== null;
210
215
  }
211
216
  event.context.nextgenAuth = { isAuthenticated: false, session: null };
212
- for (const name of Object.keys(parseCookies(event))) {
213
- if (name.startsWith("__nextgen")) {
214
- deleteCookie(event, name);
217
+ if (!liveAnonymousSession) {
218
+ for (const name of Object.keys(parseCookies(event))) {
219
+ if (name.startsWith("__nextgen")) {
220
+ deleteCookie(event, name);
221
+ }
215
222
  }
216
223
  }
217
224
  if (matchesRoutes(pathname, protectedRoutes)) {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- export { ZitadelLogin, ZitadelLogout } from '@zitadel/components';
1
+ export { ZitadelLogin, ZitadelLogout, businessLocales } from '@zitadel/components';
2
2
  export { createNextgenMiddleware, getAuth } from './runtime/server/middleware.js';
3
3
  import { ZitadelProject } from '@zitadel/api/config';
4
- export { ClientAuthResult } from './runtime/types.js';
5
- export { AuthResult, NextgenMiddlewareOptions } from '@zitadel/sdk-core/middleware';
4
+ export { AuthResult, ClientAuthResult, NextgenMiddlewareOptions } from '@zitadel/sdk-core/middleware';
6
5
  import 'h3';
7
6
 
8
7
  /**
package/dist/index.js CHANGED
@@ -2,10 +2,11 @@ import "./chunk-ZNXAFGLP.js";
2
2
  import {
3
3
  createNextgenMiddleware,
4
4
  getAuth
5
- } from "./chunk-AQZKZRKQ.js";
5
+ } from "./chunk-MJ3RLEU6.js";
6
6
 
7
7
  // src/index.ts
8
8
  import { ZitadelLogin, ZitadelLogout } from "@zitadel/components";
9
+ import { businessLocales } from "@zitadel/components";
9
10
 
10
11
  // src/runtime/composables/useZitadelProject.ts
11
12
  import { getZitadelConfig } from "@zitadel/api/config";
@@ -15,6 +16,7 @@ function useZitadelProject() {
15
16
  export {
16
17
  ZitadelLogin,
17
18
  ZitadelLogout,
19
+ businessLocales,
18
20
  createNextgenMiddleware,
19
21
  getAuth,
20
22
  useZitadelProject
package/dist/module.js CHANGED
@@ -48,7 +48,7 @@ var module_default = defineNuxtModule({
48
48
  // Server-only — never exposed to the client. Override at deploy time via
49
49
  // `NUXT_NEXTGEN_PROJECT_SECRET`. Left undefined when the env var (and
50
50
  // `.env.local`) provide no value, so the middleware surfaces a missing
51
- // bearer instead of silently sending an empty one.
51
+ // exchange bearer instead of silently sending an empty one.
52
52
  projectSecret: loadProjectSecret(nuxt.options.rootDir)
53
53
  };
54
54
  nuxt.options.runtimeConfig.public.zitadelProxyPath = options.proxyPath ?? "/__nextgen";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createNextgenMiddleware
3
- } from "../../chunk-AQZKZRKQ.js";
3
+ } from "../../chunk-MJ3RLEU6.js";
4
4
 
5
5
  // src/runtime/server/handler.ts
6
6
  import { useRuntimeConfig } from "#imports";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createNextgenMiddleware,
3
3
  getAuth
4
- } from "../../chunk-AQZKZRKQ.js";
4
+ } from "../../chunk-MJ3RLEU6.js";
5
5
  export {
6
6
  createNextgenMiddleware,
7
7
  getAuth
@@ -1,37 +1 @@
1
- import { UnauthState } from '@zitadel/sdk-core/middleware';
2
- export { AuthResult, AuthState, NextgenMiddlewareOptions, NextgenSession, UnauthState } from '@zitadel/sdk-core/middleware';
3
-
4
- /**
5
- * Re-exports shared SDK types from `@zitadel/sdk-core`.
6
- *
7
- * These types are defined once in sdk-core and shared by both sdk-next
8
- * and sdk-nuxt.
9
- */
10
-
11
- /**
12
- * The client-safe session exposed to Vue components via {@link useAuth}.
13
- * Identical to {@link NextgenSession} but omits `token` — the raw JWT must
14
- * not be serialised into the Nuxt SSR payload where third-party scripts can
15
- * read it.
16
- */
17
- type ClientSession = {
18
- /** The user's unique identifier (`sub` claim). */
19
- userId: string;
20
- /** The user's email address, or `null` if not present in the token. */
21
- email: string | null;
22
- /** The user's display name, or `null` if not present in the token. */
23
- name: string | null;
24
- };
25
- /** Client-safe auth state when the user is signed in. */
26
- type ClientAuthState = {
27
- isAuthenticated: true;
28
- session: ClientSession;
29
- };
30
- /**
31
- * Union of all possible auth states returned by {@link useAuth}.
32
- * Token is intentionally absent — use {@link getAuth} server-side when the
33
- * raw JWT is needed.
34
- */
35
- type ClientAuthResult = ClientAuthState | UnauthState;
36
-
37
- export type { ClientAuthResult, ClientAuthState, ClientSession };
1
+ export { AuthResult, AuthState, ClientAuthResult, ClientAuthState, ClientSession, NextgenMiddlewareOptions, NextgenSession, UnauthState } from '@zitadel/sdk-core/middleware';
package/dist/server.js CHANGED
@@ -2,7 +2,7 @@ import "./chunk-ZNXAFGLP.js";
2
2
  import {
3
3
  createNextgenMiddleware,
4
4
  getAuth
5
- } from "./chunk-AQZKZRKQ.js";
5
+ } from "./chunk-MJ3RLEU6.js";
6
6
  export {
7
7
  createNextgenMiddleware,
8
8
  getAuth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zitadel/sdk-nuxt",
3
- "version": "0.1.0-alpha.17",
3
+ "version": "0.1.0-alpha.18",
4
4
  "description": "Nuxt proxy middleware and helpers for the pre-release Zitadel preview.",
5
5
  "homepage": "https://github.com/zitadel/nextgen/tree/main/packages/sdk-nuxt#readme",
6
6
  "bugs": {
@@ -33,9 +33,9 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@zitadel/api": "0.1.0-alpha.17",
37
- "@zitadel/sdk-core": "0.1.0-alpha.17",
38
- "@zitadel/components": "0.1.0-alpha.17"
36
+ "@zitadel/components": "0.1.0-alpha.18",
37
+ "@zitadel/sdk-core": "0.1.0-alpha.18",
38
+ "@zitadel/api": "0.1.0-alpha.18"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "h3": ">=1",