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

sensei-uaepass

v1.0.3

Published

πŸ₯‹ Master of UAE Pass integration! Angular OAuth 2.0 (PKCE) client with sensei-level signals-based state management, multi-language support, and elegant UI components.

Readme

πŸ₯‹ Sensei UAE Pass

Master of UAE Pass integration! Angular OAuth 2.0 (PKCE) client with sensei-level signals-based state management and standalone components.

Based on official UAE Pass documentation: https://docs.uaepass.ae/feature-guides/authentication/web-application

Features

  • πŸ” OAuth 2.0 Integration - Complete UAE Pass OAuth 2.0 flow support with PKCE
  • πŸš€ Angular 19+ Support - Built for modern Angular with signals-based state management
  • πŸ”§ Easy Configuration - Simple setup with dependency injection
  • 🌐 Proxy Support - Built-in proxy configuration for secure token exchange
  • πŸ“ Comprehensive Types - Full TypeScript interfaces for UAE Pass API
  • πŸ›‘οΈ Security First - Proper PKCE validation and CSRF protection
  • πŸ“Š Signals-Based - Reactive state management with Angular signals
  • πŸ›οΈ Official Compliance - Based on official UAE Pass documentation
  • 🎌 Standalone Components - Modern Angular architecture

Install

npm install sensei-uaepass

Peer deps: @angular/core, @angular/common, rxjs. Ensure HttpClient is provided in your app.

Provide configuration

Add the provider to your application (e.g. app.config.ts).

import { provideHttpClient, withFetch } from "@angular/common/http";
import { provideUaePass, UaePassLanguageCode, UaePassStorageMode } from "sensei-uaepass";

export const appConfig = {
  providers: [
    provideHttpClient(withFetch()),
    provideUaePass({
      clientId: "<CLIENT_ID>",
      redirectUri: "https://your.app/uae-pass/callback",
      isProduction: false,
      language: UaePassLanguageCode.En,
      scope: "urn:uae:digitalid:profile:general",
      tokenProxyUrl: "/api/uae-pass/token", // recommended
      userInfoProxyUrl: "/api/uae-pass/userinfo",
      storage: UaePassStorageMode.Session,
    }),
  ],
};

Add routes

import { Routes } from "@angular/router";
import { UaePassCallbackComponent } from "sensei-uaepass";

export const routes: Routes = [
  // ...
  { path: "uae-pass/callback", component: UaePassCallbackComponent },
];

Use the login button

<uae-pass-login-button [label]="'Sign in with UAE PASS'" [busyLabel]="'Signing in…'" [logoSrc]="'/assets/uae-pass.svg'" (pressed)="onPressed()"></uae-pass-login-button>

The button calls redirectToAuthorization() for you. Alternatively, inject UaePassAuthService and call it directly.

Handle callback result (optional)

UaePassCallbackComponent emits outputs you can use to react:

<uae-pass-callback (success)="onLogin()" (failed)="onLoginError($event)"></uae-pass-callback>

You can also handle programmatically:

constructor(private auth: UaePassAuthService) {}
ngOnInit() { this.auth.handleRedirectCallback(); }

Service API

Signals (Reactive State)

  • status(): Signal<UaePassAuthStatus> - Current authentication status
  • tokens(): Signal<UaePassTokens|null> - Access and refresh tokens
  • profile(): Signal<UaePassUserProfile|null> - User profile information
  • error(): Signal<string|null> - Last error message
  • isAuthenticated(): Signal<boolean> - Computed authentication state

Methods

  • redirectToAuthorization(): Promise<void> - Redirect to UAE Pass login
  • handleRedirectCallback(url?: string): Promise<void> - Handle callback from UAE Pass
  • logout(): void - Logout and clear session
  • resetError(): void - Clear error state

Proxy Server Setup

Why Use a Proxy Server?

The proxy server is highly recommended for security reasons:

  1. Client Secret Protection - Keeps your client secret secure on the server-side
  2. CORS Handling - Avoids cross-origin issues with UAE Pass APIs
  3. Token Security - Prevents exposure of sensitive tokens in browser
  4. Request Validation - Adds an extra layer of validation

Backend Alternatives

You can replace the proxy server with any backend technology:

Node.js/Express Example

app.post("/api/uae-pass/token", async (req, res) => {
  const { code, redirect_uri, code_verifier } = req.body;

  const params = new URLSearchParams({
    grant_type: "authorization_code",
    client_id: "your-client-id",
    client_secret: "your-client-secret",
    code,
    redirect_uri,
    code_verifier,
  });

  const response = await fetch("https://stg-id.uaepass.ae/idshub/token", {
    method: "POST",
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    body: params.toString(),
  });

  const data = await response.json();
  res.json(data);
});

ASP.NET Core Example

[HttpPost("api/uae-pass/token")]
public async Task<IActionResult> ExchangeToken([FromBody] TokenRequest request)
{
    var parameters = new Dictionary<string, string>
    {
        ["grant_type"] = "authorization_code",
        ["client_id"] = "your-client-id",
        ["client_secret"] = "your-client-secret",
        ["code"] = request.Code,
        ["redirect_uri"] = request.RedirectUri,
        ["code_verifier"] = request.CodeVerifier
    };

    var content = new FormUrlEncodedContent(parameters);
    var response = await client.PostAsync("https://stg-id.uaepass.ae/idshub/token", content);
    var result = await response.Content.ReadAsStringAsync();

    return Ok(JsonSerializer.Deserialize<object>(result));
}

Notes

  • For security, prefer a backend proxy for the token exchange (tokenProxyUrl), to avoid exposing client secrets and to handle CORS.
  • storage: UaePassStorageMode.Session | Local | None controls persistence of tokens/profile across reloads.
  • acr_values defaults to web flow in browsers.

Demo

A demo application is included in this workspace to showcase the library:

# Build the library first
npm run build:lib

# Start the demo app
npm run start:demo

# Start the proxy server (in another terminal)
node proxy-server.js

The demo shows:

  • UAE Pass login button with enum-based configuration
  • Real-time authentication status display
  • User profile and token information
  • Proper routing with callback handling

Demo Configuration

The demo uses staging environment with these settings:

  • clientId: 'sandbox_stage'
  • redirectUri: 'http://localhost:4200/uae-pass/callback'
  • language: UaePassLanguageCode.En
  • storage: UaePassStorageMode.Session

Enums

All commonly used string unions are exposed as enums for type safety:

  • UaePassAuthStatus β€” Idle, Authorizing, ExchangingToken, Authenticated, Error, LoggedOut
  • UaePassStorageMode β€” None, Session, Local
  • UaePassAcr β€” Web, MobileOnDevice
  • UaePassLanguageCode β€” En, Ar
  • OAuthResponseType β€” Code
  • CodeChallengeMethod β€” S256
  • OAuthGrantType β€” AuthorizationCode

Resources