npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@salesforce/ui-bundle-template-feature-angular-authentication

v12.11.0

Published

Angular authentication feature (login, registration, session timeout) for UI Bundles

Readme

feature-angular-authentication

Complete user authentication for Angular UI Bundles: login, registration, password management, session timeout, and route protection.

This feature ships:

  • authGuard — a functional route guard that protects authenticated-only routes.
  • AuthService — an injectable service that resolves the current user and manages auth state.
  • AuthAppLayoutComponent — a route layout for the authenticated shell.
  • Authentication pages — Login, Register, Profile, Forgot Password, Reset Password, Change Password.
  • Apex classes — the server-side handlers (UIBundleLogin, UIBundleRegistration, UIBundleForgotPassword, UIBundleChangePassword, UIBundleAuthUtils).

Built with Angular standalone components, signals, and Reactive Forms.

Features

  • Checks authentication status via UI API GraphQL (uiapi.currentUser).
  • Protects routes with authGuard, redirecting unauthenticated users to login.
  • Supports a return URL (retUrl) query parameter for post-login navigation.
  • Session timeout with a configurable duration.
  • Password strength validation via hand-written reactive-form validators.
  • Forgot password and reset password flows.
  • User profile display and change-password functionality.

Install

npx @salesforce/ui-bundle-features-experimental install angular-authentication --ui-bundle-dir <your-ui-bundle>

This copies the authentication library, the auth pages, the profile GraphQL service, and the Apex handler classes into your project. It also copies the feature's route file to src/app/features/authentication/__example__authentication-routes.ts as an integration example — the CLI lists it as an __example__ file to review, merge, and delete.

Usage

Protecting routes

Add the auth routes from the example file into your app's route file (src/app/app.routes.ts). The top-level layout node swaps to AuthAppLayoutComponent, and protected routes use canActivate: [authGuard]:

import { Routes } from "@angular/router";
import { AuthAppLayoutComponent } from "./features/authentication/...";
import { authGuard } from "./features/authentication/auth/auth.guard";
import { ProfilePageComponent } from "./pages/profile/profile-page";

export const routes: Routes = [
  {
    path: "",
    component: AuthAppLayoutComponent,
    children: [
      { path: "login", loadComponent: () => import("./pages/login/login-page") },
      { path: "register", loadComponent: () => import("./pages/register/register-page") },
      {
        path: "profile",
        canActivate: [authGuard],
        component: ProfilePageComponent,
      },
      // ...forgot-password, reset-password, change-password
    ],
  },
];

The feature's route file (copied on install to __example__authentication-routes.ts) shows the full route set — merge it into your own route file rather than replacing it, so your existing routes are preserved, then delete the example file.

Reading auth state

Inject AuthService in any component to read the current user and auth state:

import { Component, inject } from "@angular/core";
import { AuthService } from "./features/authentication/auth/auth.service";

@Component({/* ... */})
export class MyComponent {
  private readonly auth = inject(AuthService);

  readonly user = this.auth.user; // signal
  readonly isAuthenticated = this.auth.isAuthenticated; // signal
}

Local preview limitations

Some authentication surfaces only work on the deployed Experience site, not in local preview (npm run dev on http://localhost). This is expected: the local dev server proxies requests to the org outside the Experience site's guest/community context, so the site session does not exist.

| Surface | Local preview (localhost) | Deployed site | | -------------------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------- | | Login / registration / password flows | The site session cannot be established, so these fail with a generic message. | Work — the platform completes the flow. | | MFA challenge | The site session cannot be established, so login fails with a generic message. | Works — the platform renders and completes the challenge. | | Current-user check (uiapi.currentUser) | Works — the local dev proxy forwards GraphQL calls with the CLI-authenticated user. | Works |

How to test these: open the published site login page, e.g. https://<your-domain>.site.com/<site-path>/login. The login failure above is expected locally and is not a misconfiguration.

Notes

  • Routes integrate by merging the feature's app.routes.ts into your app's route file — the top-level layout node swaps to AuthAppLayoutComponent, and the auth routes are appended alongside your existing routes.
  • The Apex classes deploy to your project's classes/ directory and are required for the login/registration/password flows to work server-side.
  • This feature is dependency-free at the package level — Angular, the router, and forms are provided by the base app.

Development

# Build the feature (applies patches from template to dist)
npm run build

# Type-check
npm run typecheck