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 🙏

© 2024 – Pkg Stats / Ryan Hefner

karma-auth.npm

v1.1.0

Published

Karma Auth is a auth library, an alternative to firebase auth. Karma Auth is a opensource project under the "Karma Project".

Downloads

76

Readme

Karma Auth Library

KarmaAuth

This class provides methods to manage organization users, roles, and user roles.

Constructor

Syntax:

constructor(orgAuthId: string, orgAuthToken: string)

Parameters:

  • orgAuthId: A string representing the organization's authentication ID.
  • orgAuthToken: A string representing the organization's authentication token.

Example:

const karmaAuth = new KarmaAuth('your_org_auth_id', 'your_org_auth_token');

Properties

  • Users: Instance of OrgUsers to manage organization users.
  • Roles: Instance of OrgRoles to manage organization roles.
  • UserRoles: Instance of OrgUserRoles to manage organization user roles.

Methods

The methods are part of the instantiated classes OrgUsers, OrgRoles, and OrgUserRoles.


KarmaUser

This class provides methods to manage user-specific operations.

Constructor

Syntax:

constructor(token: string)

Parameters:

  • token: A string representing the user's token.

Example:

const karmaUser = new KarmaUser('your_user_token');

Properties

  • Users: Instance of Users to manage user-specific operations.

OrgUsers

This class provides methods to manage organization users.

Constructor

Syntax:

constructor(config: Config)

Parameters:

  • config: An instance of the Config class.

Methods

createUser

Creates a new user.

Syntax:

createUser(userData: any): Promise<any>

Parameters:

  • userData: An object containing user data.

Example:

karmaAuth.Users.createUser({ name: "John Doe", email: "[email protected]" });

getUser

Fetches a user by UID.

Syntax:

getUser(uid: string): Promise<any>

Parameters:

  • uid: A string representing the user's ID.

Example:

karmaAuth.Users.getUser('user_id');

authenticateUserByEmail

Authenticates a user by email and password.

Syntax:

authenticateUserByEmail(email: string, password: string): Promise<any>

Parameters:

  • email: A string representing the user's email.
  • password: A string representing the user's password.

Example:

karmaAuth.Users.authenticateUserByEmail('[email protected]', 'password123');

authenticateUserByPhone

Authenticates a user by phone and password.

Syntax:

authenticateUserByPhone(phone: string, password: string): Promise<any>

Parameters:

  • phone: A string representing the user's phone number.
  • password: A string representing the user's password.

Example:

karmaAuth.Users.authenticateUserByPhone('1234567890', 'password123');

updateUser

Updates user information by UID.

Syntax:

updateUser(uid: string, updateData: any): Promise<any>

Parameters:

  • uid: A string representing the user's ID.
  • updateData: An object containing the updated user data.

Example:

karmaAuth.Users.updateUser('user_id', { name: "Jane Doe", email: "[email protected]" });

deleteUser

Deletes a user by UID.

Syntax:

deleteUser(uid: string): Promise<any>

Parameters:

  • uid: A string representing the user's ID.

Example:

karmaAuth.Users.deleteUser('user_id');

OrgUserRoles

This class provides methods to manage user roles within the organization.

Constructor

Syntax:

constructor(baseURL: string, config: Config)

Parameters:

  • baseURL: A string representing the base URL for the API.
  • config: An instance of the Config class.

Methods

createUserRole

Creates a user role.

Syntax:

createUserRole(roleID: string, userID: string): Promise<any>

Parameters:

  • roleID: A string representing the role's ID.
  • userID: A string representing the user's ID.

Example:

karmaAuth.UserRoles.createUserRole('role_id', 'user_id');

OrgRoles

This class provides methods to manage roles within the organization.

Constructor

Syntax:

constructor(baseURL: string, config: Config)

Parameters:

  • baseURL: A string representing the base URL for the API.
  • config: An instance of the Config class.

Methods

createRole

Creates a new role.

Syntax:

createRole(name: string, permissions: Permissions): Promise<any>

Parameters:

  • name: A string representing the name of the role.
  • permissions: An object representing the permissions assigned to the role.

Example:

karmaAuth.Roles.createRole('Admin', { read: true, write: true, delete: false });

getRole

Fetches a role by RID.

Syntax:

getRole(rid: string): Promise<any>

Parameters:

  • rid: A string representing the role's ID.

Example:

karmaAuth.Roles.getRole('role_id');

getAllRoles

Fetches all roles.

Syntax:

getAllRoles(): Promise<any>

Example:

karmaAuth.Roles.getAllRoles();

getRoleByName

Fetches a role by name.

Syntax:

getRoleByName(name: string): Promise<any>

Parameters:

  • name: A string representing the role's name.

Example:

karmaAuth.Roles.getRoleByName('Admin');

updateRole

Updates a role by RID.

Syntax:

updateRole(rid: string, updateData: {name: string, permissions: Permissions}): Promise<any>

Parameters:

  • rid: A string representing the role's ID.
  • updateData: An object containing the updated role data.

Example:

karmaAuth.Roles.updateRole('role_id', { name: "Moderator", permissions: { read: true, write: true, delete: true } });

deleteRole

Deletes a role by RID.

Syntax:

deleteRole(rid: string): Promise<any>

Parameters:

  • rid: A string representing the role's ID.

Example:

karmaAuth.Roles.deleteRole('role_id');

Users

This class provides methods to manage user-specific operations outside of an organization context.

Constructor

Syntax:

constructor(token: string)

Parameters:

  • token: A string representing the user's token.

Methods

getUser

Fetches the current user's information.

Syntax:

getUser(userData: any): Promise<any>

Parameters:

  • userData: An object representing the user data.

Example:

karmaUser.Users.getUser({ token: 'your_token' });

getUserRoles

Fetches roles for the user, optionally by RID.

Syntax:

getUserRoles(rid?: string): Promise<any>

Parameters:

  • rid: An optional string representing the role's ID.

Example:

karmaUser.Users.getUserRoles('role_id');

deleteUserRole

Deletes a user role by RID.

Syntax:

deleteUserRole(rid: string): Promise<any>

Parameters:

  • rid: A string representing the role's ID.

Example:

karmaUser.Users.deleteUserRole('role_id');