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

@mybambu/account-service-sdk

v1.0.0

Published

TypeScript SDK for MyBambu Account Service

Downloads

5

Readme

MyBambu Account Service SDK

TypeScript SDK for interacting with the MyBambu Account Service API.

Table of Contents

Installation

npm install @mybambu/account-service-sdk

Quick Start

import { AccountServiceClient } from '@mybambu/account-service-sdk';

// Initialize the client
const client = new AccountServiceClient({
  baseURL: 'http://localhost:3000',
  apiPrefix: 'api/v1', // optional, defaults to 'api/v1'
  timeout: 30000, // optional, defaults to 30000ms
});

// Register a new user
const { access_token, user } = await client.register({
  email: '[email protected]',
  password: 'SecurePassword123!',
  firstName: 'John',
  lastName: 'Doe',
});

// The token is automatically set after registration/login
console.log('Logged in as:', user.email);

// Make authenticated requests
const profile = await client.getUserProfile();

Configuration

AccountServiceConfig

| Property | Type | Required | Default | Description | |----------|------|----------|---------|-------------| | baseURL | string | Yes | - | Base URL of the Account Service | | apiPrefix | string | No | 'api/v1' | API prefix path | | timeout | number | No | 30000 | Request timeout in milliseconds | | headers | Record<string, string> | No | {} | Additional headers to include |

Authentication

The SDK automatically handles JWT token management. After successful login or registration, the token is stored and included in all subsequent requests.

Manual Token Management

// Set token manually
client.setToken('your-jwt-token');

// Get current token
const token = client.getToken();

// Clear token
client.clearToken();

Token Auto-Clear on 401

The SDK automatically clears the stored token when a 401 Unauthorized response is received.

API Reference

Authentication

register(data: RegisterDto): Promise

Register a new user account.

const response = await client.register({
  email: '[email protected]',
  password: 'SecurePassword123!',
  firstName: 'John',
  lastName: 'Doe',
  phoneNumber: '+1234567890', // optional
  dateOfBirth: '1990-01-01', // optional
});

login(data: LoginDto): Promise

Login with email and password.

const response = await client.login({
  email: '[email protected]',
  password: 'SecurePassword123!',
});

getCurrentUser(): Promise

Get the current authenticated user's profile.

const user = await client.getCurrentUser();

logout(): Promise<{ message: string }>

Logout the current user.

await client.logout();

User Management

getUserProfile(): Promise

Get detailed user profile.

const profile = await client.getUserProfile();

updateProfile(data: UpdateProfileDto): Promise

Update user profile information.

const updatedProfile = await client.updateProfile({
  firstName: 'Jane',
  lastName: 'Smith',
  phoneNumber: '+1987654321',
});

updatePassword(data: UpdatePasswordDto): Promise<{ message: string }>

Change user password.

await client.updatePassword({
  currentPassword: 'OldPassword123!',
  newPassword: 'NewPassword123!',
});

getUserPreferences(): Promise

Get user preferences.

const preferences = await client.getUserPreferences();

updatePreferences(data: any): Promise

Update user preferences.

const updated = await client.updatePreferences({
  theme: 'dark',
  notifications: true,
});

deactivateAccount(): Promise<{ message: string }>

Deactivate user account.

await client.deactivateAccount();

PIN Management

// Set PIN
await client.setPin('1234');

// Verify PIN
const { valid } = await client.verifyPin('1234');

// Update PIN
await client.updatePin('1234', '5678');

Address Management

getAddress(): Promise

Get user's address.

const address = await client.getAddress();

createAddress(data: CreateAddressDto): Promise

Create a new address.

const address = await client.createAddress({
  street: '123 Main St',
  city: 'New York',
  state: 'NY',
  postalCode: '10001',
  country: 'USA',
});

updateAddress(data: UpdateAddressDto): Promise

Update existing address.

const updated = await client.updateAddress({
  street: '456 Oak Ave',
});

deleteAddress(): Promise

Delete user's address.

await client.deleteAddress();

Address Validation

// Get pending address
const pending = await client.getPendingAddress();

// Submit for validation
await client.submitAddressForValidation({
  street: '123 Main St',
  city: 'New York',
  state: 'NY',
  postalCode: '10001',
  country: 'USA',
});

// Approve pending address
const approved = await client.approvePendingAddress();

Device Management

registerDevice(data: RegisterDeviceDto): Promise

Register a new device.

const device = await client.registerDevice({
  deviceId: 'unique-device-id',
  deviceType: 'ios',
  deviceModel: 'iPhone 14',
  osVersion: '16.0',
  appVersion: '1.0.0',
  pushToken: 'fcm-token',
});

getUserDevices(): Promise<DeviceResponse[]>

Get all user devices.

const devices = await client.getUserDevices();

getDevice(deviceId: string): Promise

Get specific device.

const device = await client.getDevice('device-id');

updateDevice(deviceId: string, data: UpdateDeviceDto): Promise

Update device information.

const updated = await client.updateDevice('device-id', {
  appVersion: '1.1.0',
  osVersion: '16.1',
});

deleteDevice(deviceId: string): Promise<{ message: string }>

Delete a device.

await client.deleteDevice('device-id');

deactivateDevice(deviceId: string): Promise

Deactivate a device.

await client.deactivateDevice('device-id');

updateDevicePushToken(deviceId: string, pushToken: string): Promise

Update device push notification token.

await client.updateDevicePushToken('device-id', 'new-fcm-token');

Security Questions

getAvailableSecurityQuestions(): Promise<SecurityQuestionResponse[]>

Get list of available security questions.

const questions = await client.getAvailableSecurityQuestions();

getUserSecurityQuestions(): Promise<any[]>

Get user's configured security questions.

const userQuestions = await client.getUserSecurityQuestions();

setSecurityQuestion(data: SetSecurityQuestionDto): Promise

Set a security question.

await client.setSecurityQuestion({
  questionId: 'question-uuid',
  answer: 'My Answer',
});

verifySecurityAnswer(data: VerifySecurityAnswerDto): Promise<{ valid: boolean }>

Verify a security answer.

const { valid } = await client.verifySecurityAnswer({
  questionId: 'question-uuid',
  answer: 'My Answer',
});

deleteSecurityQuestion(questionId: string): Promise<{ message: string }>

Delete a security question.

await client.deleteSecurityQuestion('question-uuid');

Verification

sendVerification(data: SendVerificationDto): Promise

Send verification code via email or phone.

// Send email verification
await client.sendVerification({
  type: 'email',
});

// Send phone verification
await client.sendVerification({
  type: 'phone',
  target: '+1234567890', // optional
});

verifyCode(data: VerifyCodeDto): Promise<{ verified: boolean }>

Verify a code.

const { verified } = await client.verifyCode({
  type: 'email',
  code: '123456',
});

getVerificationStatus(): Promise

Get user's verification status.

const status = await client.getVerificationStatus();
console.log('Email verified:', status.emailVerified);
console.log('Phone verified:', status.phoneVerified);

Password Reset

requestPasswordReset(email: string): Promise<{ sent: boolean; expiresAt: Date }>

Request a password reset.

const response = await client.requestPasswordReset('[email protected]');
console.log('Reset email sent:', response.sent);
console.log('Expires at:', response.expiresAt);

resetPassword(data: ResetPasswordDto): Promise<{ message: string }>

Reset password with token.

await client.resetPassword({
  token: 'reset-token-from-email',
  newPassword: 'NewSecurePassword123!',
});

Disclosures

getCurrentDisclosures(): Promise<DisclosureResponse[]>

Get all current disclosures.

const disclosures = await client.getCurrentDisclosures();

getPendingDisclosures(): Promise<DisclosureResponse[]>

Get disclosures pending user acceptance.

const pending = await client.getPendingDisclosures();

getUserAcceptedDisclosures(): Promise<any[]>

Get user's accepted disclosures.

const accepted = await client.getUserAcceptedDisclosures();

getDisclosureById(id: string): Promise

Get specific disclosure by ID.

const disclosure = await client.getDisclosureById('disclosure-uuid');

acceptDisclosure(data: AcceptDisclosureDto): Promise

Accept a disclosure.

await client.acceptDisclosure({
  disclosureId: 'disclosure-uuid',
  version: '1.0',
});

Error Handling

The SDK uses Axios for HTTP requests. All errors are Axios errors with response data.

try {
  await client.login({
    email: '[email protected]',
    password: 'wrong-password',
  });
} catch (error) {
  if (error.response) {
    // Server responded with error
    console.error('Status:', error.response.status);
    console.error('Message:', error.response.data.message);
  } else if (error.request) {
    // Request made but no response
    console.error('No response received');
  } else {
    // Error setting up request
    console.error('Error:', error.message);
  }
}

Common HTTP Status Codes

  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized (token cleared automatically)
  • 404 - Not Found
  • 409 - Conflict (e.g., user already exists)
  • 500 - Internal Server Error

Examples

See the examples directory for complete working examples:

TypeScript Support

This SDK is written in TypeScript and includes type definitions. You get full IntelliSense and type checking out of the box.

import { AccountServiceClient, UserResponse, LoginResponse } from '@mybambu/account-service-sdk';

const client = new AccountServiceClient({ baseURL: 'http://localhost:3000' });

// TypeScript knows the shape of the response
const loginResponse: LoginResponse = await client.login({
  email: '[email protected]',
  password: 'password',
});

// Type-safe access to properties
console.log(loginResponse.access_token);
console.log(loginResponse.user.email);

License

MIT