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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hahnpro/ai-sdk

v0.11.1

Published

```bash npm install @hahnpro/ai-sdk ```

Readme

ADAM AI SDK

Installation

npm install @hahnpro/ai-sdk

Usage

In your Angular application, you can use the provideAiSdk() function to set up all necessary providers:

// main.ts
import { bootstrapApplication } from '@angular/platform-browser';
import { provideAiSdk } from '@hahnpro/ai-sdk';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, {
  providers: [
    provideAiSdk(),
    // other providers...
  ],
}).catch((err) => console.error(err));

The provideAiSdk() function includes the following configurations:

  • Transloco module for internationalization
  • Markdown support (ngx-markdown)
  • Logger configuration (ngx-logger)

For more granular control, you can also use the individual providers:

import { bootstrapApplication } from '@angular/platform-browser';
import { importProvidersFrom } from '@angular/core';
import { AiTranslocoModule, provideAiMarkdown } from '@hahnpro/ai-sdk';
import { LoggerModule, NgxLoggerLevel } from 'ngx-logger';
import { AppComponent } from './app/app.component';

bootstrapApplication(AppComponent, {
  providers: [
    importProvidersFrom(
      AiTranslocoModule,
      LoggerModule.forRoot({
        level: NgxLoggerLevel.DEBUG,
        disableConsoleLogging: false,
      }),
    ),
    provideAiMarkdown(),
    // other providers...
  ],
}).catch((err) => console.error(err));

User Authentication

Overview

The AuthAdapter is an interface that provides a unified API for different authentication libraries. It abstracts the specific authentication implementation and allows using various auth providers.

Interface Definition

export interface AuthAdapter {
  init(): Promise<void>;
  isAuthenticated(): Promise<boolean>;
  getAccessToken(): Promise<string>;
  loginRedirect(options?: { redirectUri?: string }): Promise<void>;
  loginPopup?(): Promise<void>;
  logout?(): Promise<void>;
}

Required Fields

init(): Initializes the auth provider (e.g., checks existing sessions)

isAuthenticated(): Checks if the user is authenticated

getAccessToken(): Returns the current access token

loginRedirect(): Starts the login flow with redirect

Optional Fields

loginPopup(): Starts the login flow in a popup window

logout(): Logs out the user

Implementation with OIDC

Here's an example implementation using angular-auth-oidc-client:


import { AUTH_ADAPTER, AuthAdapter } from '@hahnpro/ai-sdk';
import { OidcSecurityService } from 'angular-auth-oidc-client';
import { lastValueFrom } from 'rxjs';

export const AUTH_PROVIDERS = [
  // OIDC Provider configuration...
  {
    provide: AUTH_ADAPTER,
    deps: [OidcSecurityService],
    useFactory: (oidc: OidcSecurityService): AuthAdapter => ({
      init: async () => {
        // Automatically checks existing authentication
        await lastValueFrom(oidc.checkAuth());
      },
      isAuthenticated: () => {
        return lastValueFrom(oidc.isAuthenticated());
      },
      getAccessToken(): Promise<string> {
        return lastValueFrom(oidc.getAccessToken());
      },
      loginRedirect: async (options) => {
        // Optional: use redirect URL
        oidc.authorize(options?.redirectUri);
      },
      loginPopup: async () => {
        await lastValueFrom(oidc.authorizeWithPopUp());
      },
      logout: async () => {
        await lastValueFrom(oidc.logoff());
      },
    }),
  },
];

Injection in Angular

  1. Register Provider
import { provideAiSdk } from '@hahnpro/ai-sdk';

bootstrapApplication(AppComponent, {
  providers: [
    provideAiSdk(),
    ...AUTH_PROVIDERS, // AuthAdapter is provided here
  ],
});
  1. Initalize Auth Adapter At some point before using the Auth Adapter, you need to initialize it. This can be done by calling the init() method of the Auth Adapter:
export class AppComponent implements OnInit {
  private readonly auth = inject(AUTH_ADAPTER);

  ngOnInit() {
    this.auth.init();
  }
  ...
}