Skip to content

Introduce modern Asgardeo Nuxt.js SDK - #477

Merged
brionmario merged 44 commits into
asgardeo:mainfrom
kavindadimuthu:nuxt-sdk-start-without-playground
Apr 28, 2026
Merged

brionmario merged 44 commits into
asgardeo:mainfrom
kavindadimuthu:nuxt-sdk-start-without-playground

Conversation

@kavindadimuthu

@kavindadimuthu kavindadimuthu commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

This pull request introduces modern Nuxt.Js SDK with nuxt 3 for asgardeo integrations as @asgardeo/nuxt package, focusing on better configuration handling, expanded Nuxt integration, and enhanced developer ergonomics. The most important changes include a major refactor of the Nuxt module setup for more robust config layering and security, auto-registration of a full suite of Nuxt components and composables, and several utility and bugfix improvements in the JavaScript SDK.

Nuxt module implementations:

  • Refactored the Nuxt module (src/module.ts) to support layered configuration (environment variables, user config, and hard defaults), enforce secrets never leak to public config, and register all server API routes, plugins, middleware, and a comprehensive set of Nuxt-specific components and composables automatically. This enables a plug-and-play developer experience and ensures secure, flexible configuration.
  • Updated package.json for @asgardeo/nuxt to expose new exports for server, errors, and utils, added new dependencies and peer dependencies, and bumped the version to 0.1.0-alpha.0. [1] [2] [3] [4]
  • Enhanced the Nuxt entrypoint (src/index.ts) to re-export all major types, composables, and errors, and to provide Nuxt-specific wrappers for navigation and SSR support.

JavaScript SDK improvements and bugfixes:

  • Fixed a bug in updateMeProfile so that user profile updates now strip the userstore prefix from userName, ensuring UI consistency after optimistic updates. [1] [2]
  • Improved generateFlattenedUserProfile utility to correctly handle SCIM2 multi-valued complex attributes by falling back to array filtering when the flattened schema key is not found.

These changes collectively make the Nuxt integration more robust, secure, and user-friendly, while also addressing important edge cases in the core SDK utilities.

Related Issues

Related PRs

  • N/A

Checklist

  • Followed the CONTRIBUTING guidelines.
  • Manual test round performed and verified.
  • Documentation provided. (Add links if there are any)
  • Unit tests provided. (Add links if there are any)

Security checks

Summary by CodeRabbit

  • New Features
    • Full Nuxt 3 module with SSR session handling, embedded and redirect auth (sign-in/sign-up/sign-out), AsgardeoRoot, Nuxt-aware composable, auth middleware, many UI components (sign-in/out/up, user/profile, org controls, loading/signed-in/out), and server API endpoints for auth, session, profile, organizations, and branding.
  • Bug Fixes
    • Normalize returned usernames and improve flattened profile extraction for dotted/multi-valued schema fields.
  • Documentation
    • Expanded Nuxt README with setup, configuration, and usage guidance.
  • Chores
    • Removed Vue SDK playground; added Nuxt sample app.

kavindadimuthu and others added 30 commits April 27, 2026 15:39
- Updated pnpm workspace configuration to include nuxt-sdk-playground.
- Created .gitignore for nuxt-sdk-playground to exclude unnecessary files.
- Added README.md for setup instructions and environment variables.
- Implemented main application layout in app.vue with authentication controls.
- Added global styles in main.css for consistent UI.
- Configured nuxt.config.ts for Nuxt 3 with Asgardeo module integration.
- Created package.json with necessary dependencies and scripts for the playground.
- Developed index.vue as the main landing page with authentication status display.
- Created protected.vue to demonstrate access control based on authentication.
- Added TypeScript configuration for the playground.
…ment

- Add route middleware for authentication to protect pages.
- Implement returnTo functionality for redirecting users after sign-in.
- Introduce server utilities for session management: useServerSession and requireServerSession.
- Create a route matcher utility for advanced middleware handling.
- Update API routes to support session retrieval and token management.
- Enhance the SDK playground with new API demo page and improved user experience.
…ession manager, and URL validation

- Implemented a minimal stub for Nuxt's `#app` virtual module to facilitate unit testing.
- Created tests for `defineAsgardeoMiddleware` to validate authentication flows for signed-in and unauthenticated users.
- Added tests for error codes and the `AsgardeoError` class to ensure consistent error handling.
- Developed tests for the `createRouteMatcher` utility to verify path matching behavior.
- Implemented tests for session token creation and verification, including handling of tampered tokens.
- Added URL validation tests to prevent open redirect vulnerabilities.
- Configured Vitest for testing environment and module resolution.
- Updated AsgardeoPlugin to support delegated mode for SSR environments.
- Create .env.example for environment variables configuration.
- Update .gitignore to exclude sensitive files and logs.
- Revise README.md to provide clearer setup instructions and environment variable descriptions.
- Refactor app.vue to utilize Asgardeo components for sign-in/out functionality.
- Remove unused main.css file and styles.
- Update nuxt.config.ts for improved configuration and environment variable handling.
- Simplify package.json scripts and dependencies.
- Delete api-demo.vue and protected.vue pages; add dashboard.vue for protected content.
- Revise index.vue to enhance user experience with loading states and authentication checks.
- Remove deprecated server API route for user session access.
- Introduced `AsgardeoNuxtClient` for improved client handling.
- Replaced `useAsgardeoServerClient` with direct client instance usage.
- Added proactive access token refresh logic in `getValidAccessToken`.
- Enhanced session token creation to include access token expiry, refresh token, and ID token.
- Updated auth state resolution to initialize the client on the first request.
- Removed legacy client utility functions and streamlined imports.
- Updated tests to cover new session management features and token refresh logic.
- Modified playground sample to utilize new client structure.

Co-authored-by: Copilot <[email protected]>
…ion management

- Introduced a new Nitro plugin for SSR that initializes the Asgardeo client and manages user session verification.
- Added routes for fetching user organizations, all organizations, user profiles, and updating user profiles.
- Implemented organization switching functionality with session management.
- Enhanced state management for user profiles and organizations in the Nuxt plugin.
- Added comprehensive error handling for API routes and improved logging.
- Updated types to support new features and ensure type safety across the integration.

Co-authored-by: Copilot <[email protected]>
- Introduced OrganizationProfile, OrganizationSwitcher, SignIn, SignInButton, SignOutButton, SignUp, SignUpButton, SignedIn, SignedOut, User, UserDropdown, and UserProfile components to enhance user authentication and organization management.
- Implemented SSR-safe navigation using Nuxt's navigateTo for sign-in, sign-out, and sign-up flows.
- Updated types to include theme mode preferences in AsgardeoNuxtConfig.
- Modified playground sample configuration to reflect new environment variables and preferences for theme and user fetching.
…rences to asgardeo-ssr for clarity in context augmentation
…ment and user session handling

- Added new API routes for managing organizations, including creating, fetching, and switching organizations.
- Implemented session management routes for signing in, signing out, and retrieving user session information.
- Enhanced the AsgardeoNuxtClient with methods for organization creation and retrieval.
- Updated the sign-out process to fetch the redirect URL from the server.
- Introduced branding preference retrieval based on the current organization context.
- Added user profile management routes for fetching and updating user information.

Co-authored-by: Copilot <[email protected]>
…yground

- Implemented new pages for user profile retrieval and update, including GET /api/auth/user/profile and PATCH /api/auth/user/profile.
- Added organization management routes: GET /api/auth/organizations/me and POST /api/auth/organizations/switch.
- Created session management routes: GET /api/auth/session, GET /api/auth/token, and sign-in/sign-out functionalities.
- Introduced utility functions in sdkRoutes.ts for easier API calls.
- Enhanced user experience with loading states and error handling in the UI components.
- Created `profile-patch.vue` for updating user profiles via SCIM2 PatchOp.
- Implemented `user.vue` for fetching basic user information from the current session.
- Added utility overview page at `utilities/index.vue` to showcase server utilities.
- Introduced `session.vue` for managing session data and fetching session information.
- Developed `token.vue` to handle access token management and fetching token metadata.
- Created `userinfo.vue` for fetching SCIM2 user profiles using AsgardeoNuxtClient.
- Established a manifest file `sdk-manifest.ts` to serve as a single source of truth for SDK exports and utilities.

Co-authored-by: Copilot <[email protected]>
…sdk capabilities

- Introduced a new context utility in `context.vue` to fetch Asgardeo context via the demo API.
- Updated `index.vue` to clarify the need for explicit imports for server utilities.
- Enhanced `session.vue` to reflect explicit import requirements for session handling.
- Modified `token.vue` to require explicit imports for token management functions.
- Removed `userinfo.vue` as it was redundant and not aligned with the current API structure.
- Updated `preferences.vue` to streamline preference handling and removed SSR state checks.
- Improved `state.vue` to warn against using internal SDK state keys directly.
- Created a new demo API route for context retrieval in `context.get.ts`.
- Refined session and token API routes to reflect explicit import changes.
- Added manifest alignment tests to ensure all exports are correctly referenced.
- Updated SDK manifest to reflect changes in server utilities and middleware.
- Adjusted SDK routes to rename organization switch parameter for clarity.
- Added Vitest configuration for testing the playground.
- Introduced SignUpOptionFactory for V1 sign-up flow rendering.
- Created BaseSignUp and SignUp components for V2 sign-up flow handling.
- Implemented callback page for embedded authentication flows in Nuxt.js.
- Enhanced error handling and form validation for sign-up processes.
- Added support for passkey registration and social login redirection.
…in nuxtjs sdk playground

- Deleted `preferences.vue` and `state.vue` pages to streamline the SDK playground.
- Introduced `token-debugger.vue` for inspecting and decoding tokens in the current auth flow.
- Added `playground-overrides.client.ts` to manage theme mode persistence in localStorage.
- Created server API endpoint `tokens.get.ts` to expose auth tokens for debugging in development.
- Implemented JWT decoding utility functions in `decodeJwt.ts`.
- Added localStorage helpers in `playground-overrides.ts` for managing runtime overrides.
- Introduced time formatting utilities in `timeFormat.ts` for better token expiration display.

Co-authored-by: Copilot <[email protected]>
…ersisted preferences to eliminate flash-of-wrong-theme during hydration
…cution

- Updated `theme.vue` and `user.vue` to utilize a new composable specification structure for improved state inspection and function execution.
- Introduced `composables-manifest.ts` to define and manage composable specifications, including state and function details.
- Refactored state display in `theme.vue` and `user.vue` to use `StateInspectionTable` for better organization and clarity.
- Added function execution handling in `user.vue` for `updateProfile` and `revalidateProfile` with loading and error states.
- Updated SDK manifest to include `useFlowMeta` composable for flow metadata management.

Co-authored-by: Copilot <[email protected]>
…outing and example environment configuration
- Introduced `ComponentCard.vue` for displaying component details and previews.
- Added `ComponentTabNav.vue` for navigation between different components.
- Created `PreviewCanvas.vue` to provide a canvas for component previews.
- Implemented `PreviewSignInGate.vue` to handle sign-in requirements for previews.
- Developed `SlotInspection.vue` for inspecting slot variants and payloads.
- Added `PropsCustomizer.vue` for customizing component props dynamically.
- Created `SlotVariantPicker.vue` for selecting slot variants.
- Implemented various control components: `BooleanControl.vue`, `ChipMultiSelectControl.vue`, `JsonControl.vue`, `SelectControl.vue`, and `StringControl.vue` for prop customization.
- Added `_sandbox.vue` page for testing components in a sandbox environment.
- Established `components-manifest.ts` to define component specifications and properties.
- Updated user.vue to enhance component structure and improve user data handling.
- Removed auto-import badges from various composable and middleware pages for a cleaner UI.
- Streamlined code snippets and descriptions for better clarity and usability.
@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •