Socket
Book a DemoInstallSign in
Socket

@arv-bedrock/auth-sso

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arv-bedrock/auth-sso

`@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

0.4.2
latest
npmnpm
Version published
Weekly downloads
362
10.03%
Maintainers
3
Weekly downloads
 
Created
Source

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.");

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("user@example.com", 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(["example@gmail.com", "email@gmail.com"]);
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;
}

FAQs

Package last updated on 15 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.