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

@arv-bedrock/auth-sso

v1.5.0

Published

`@arv-bedrock/auth-sso` is a JavaScript/TypeScript library designed to provide an easy-to-use interface for managing user authentication and account-related functionalities. This library integrates seamlessly with the Bedrock authentication system to stre

Downloads

1,897

Readme

Bedrock Auth Library

@arv-bedrock/auth-sso is a JavaScript/TypeScript library designed to provide an easy-to-use interface for managing user authentication and account-related functionalities. This library integrates seamlessly with the Bedrock authentication system to streamline your app's security needs.


Installation

Install the library via npm:

npm install @arv-bedrock/auth-sso

Getting Started

Importing the Library

import * as BedrockAuth from "@arv-bedrock/auth-sso";

Initialization

To initialize the authentication system, provide your credentials and configuration options:

import { initBedrockAuth } from "@arv-bedrock/auth-sso";

initBedrockAuth({
  authUri: "https://auth.example.com",
  clientId: "your-client-id",
  clientSecret: "your-client-secret",
  userType: "officer", // Optional: officer (default) / citizen
  callback: (errorOrData) => {
    if (errorOrData instanceof Error) {
      console.error("Initialization error:", errorOrData);
    } else {
      console.log("Initialization successful:", errorOrData);
    }
  },
});

API Reference

Authentication Methods

doLogin(redirectUrl?: string): void

Redirects the user to the login page.

BedrockAuth.doLogin("https://your-app.com/dashboard");

doLogout(redirectUrl?: string): Promise<void>

Logs the user out and optionally redirects them to the specified URL.

BedrockAuth.doLogout("https://your-app.com");

doRegister(redirectUrl?: string): void

Redirects the user to the registration page.

BedrockAuth.doRegister("https://your-app.com/welcome");

verifyToken(): Promise<ResponseData<[]>>

Verifies the validity of the user's token.

const response = await BedrockAuth.verifyToken();
console.log("Response:", response);

Profile Management

getProfile(): Promise<ResponseData<AuthServiceResponse> | undefined>

Fetches the current user's profile.

const profile = await BedrockAuth.getProfile();
console.log("User profile:", profile);

updateProfile(body: UpdateProfile): Promise<ResponseData<[]>>

Updates the user's profile.

const response = await BedrockAuth.updateProfile({ firstName: "First Name", lastName: "Last Name" title: "Mr.", userId: "User Id" });
console.log("Profile updated.", response);

Account Management

doManageAccount(redirectUrl?: string): void

Redirects the user to the account management page.

BedrockAuth.doManageAccount("https://your-app.com/manage-account");

disabledAccount(body: DisabledAccount): Promise<ResponseData<[]>>

Disables a user account.

await BedrockAuth.disabledAccount({ userId: "12345", isDisabled: true });
console.log("Account disabled.");

Token and Cookie Management

setCookie(code: string): Promise<void>

Sets an authentication cookie.

await BedrockAuth.setCookie("auth-code");

clearCookie(): Promise<void>

Clears the authentication cookie.

await BedrockAuth.clearCookie();

refreshToken(): Promise<ResponseData<RefreshTokenResponse>>

Refreshes the authentication token.

const newToken = await BedrockAuth.refreshToken();
console.log("New token:", newToken);

getCode(): Promise<string>

Retrieves the authentication code.

const code = await BedrockAuth.getCode();
console.log("Auth code:", code);

Invites

requestInviting(email: string, duration?: number): Promise<ResponseData<[]>>

Sends an invitation email.

await BedrockAuth.requestInviting("[email protected]", 7);
console.log("Invitation sent.");

Import/Update/Delete Users

importUsers(usres: ImportUserType[]): Promise<ResponseData<ImportUserResponse>>

Import users for preregistration

const importUser = await BedrockAuth.importUsers([{
  title: "title";
  email: "email";
  firstName: "firstName";
  lastName: "lastName";
  phoneNumber: "phoneNumber";
}]);
console.log("ImportUsers", importUser);

UpdateImportUsers

updateImportUsers(usres: ImportUserType[]): Promise<ResponseData<ImportUserResponse>>

Update the previously existing and unexpired imported records via email

const updateImportUser = await BedrockAuth.updateImportUsers([{
  title: "title";
  email: "email";
  firstName: "firstName";
  lastName: "lastName";
  phoneNumber: "phoneNumber";
}]);
console.log("updateImportUser", updateImportUser);

DeleteImportUsers

deleteImportUsers(usres: ImportUserType[]): Promise<ResponseData<ImportUserResponse>>

Delete the previously existing and unexpired imported records via email

const deleteImportUser = await BedrockAuth.deleteImportUsers(["[email protected]", "[email protected]"]);
console.log("deleteImportUser", deleteImportUser);

Advanced Features

doPortal(): void

Redirects the user to the authentication portal.

BedrockAuth.doPortal();

getRedirectUri(): string

Retrieves the current redirect URI.

const redirectUri = BedrockAuth.getRedirectUri();
console.log("Redirect URI:", redirectUri);

Type Definitions

AuthProps

Defines the properties required to initialize Bedrock Auth.

export type AuthProps = {
  userType?: UserType; // "citizen" | "officer" (default: "officer")
  authUri: string;
  clientId: string;
  clientSecret: string;
  callback: (error?: any) => void;
};

DisabledAccount

Represents the details needed to disable an account.

export type DisabledAccount = {
  userId: string;
  isDisabled: boolean;
};

UpdateProfile

Defines the structure for updating user profile information.

export type UpdateProfile = {
  userId: string;
  title: string;
  firstName: string;
  lastName: string;
  picture?: string | undefined | null;
};

ImportUserType

Represents the input data required to import a single user into the system.

export type ImportUserType {
  title?: string;
  email: string;
  firstName?: string;
  lastName?: string;
  phoneNumber?: string;
}

ImportUserResponse

The response structure returned after processing a batch import of users. Contains a correlation ID for tracking and a list of per-user results.

export type ImportUserResponse {
  correlationId: string;
  results: ImportUserResult[];
}

ImportUserResult

Detailed result of an individual user import operation, including whether it succeeded and any failure reasons.

export type ImportUserResult {
  i: number;
  email: string;
  success: boolean;
  reasons: string[];
  code?: string;
  title?: string;
  firstName?: string;
  lastName?: string;
  phoneNumber?: string;
  expireAt?: string;
}