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

@corbado/node-sdk

v2.0.0

Published

This Node.js SDK eases the integration of Corbado's passkey-first authentication solution.

Downloads

675

Readme

Corbado Node.js SDK

License Latest Stable Version Coverage Status codecov documentation Slack

The Corbado Node SDK provides convenient access to the Corbado Backend API from applications written in Node.js.

:warning: The Corbado Node.js SDK is commonly referred to as a private client, specifically designed for usage within closed backend applications. This particular SDK should exclusively be utilized in such environments, as it is crucial to ensure that the API secret remains strictly confidential and is never shared.

:rocket: Getting started | :hammer_and_wrench: Services | :books: Advanced | :speech_balloon: Support & Feedback

:rocket: Getting started

Requirements

  • Node.js 8 or higher.

Installation

Use the following command to install the Corbado Node.js SDK:

npm install @corbado/node-sdk

Usage

To create a Node.js SDK instance you need to provide your Project ID and API secret which can be found at the Developer Panel.

ES5:

const Corbado = require('@corbado/node-sdk');

const projectID = process.env.CORBADO_PROJECT_ID;
const apiSecret = process.env.CORBADO_API_SECRET;

const config = new Corbado.Config(projectID, apiSecret);
const sdk = new Corbado.SDK(config);

ES6:

import {SDK, Config} from '@corbado/node-sdk';

const projectID = process.env.CORBADO_PROJECT_ID;
const apiSecret = process.env.CORBADO_API_SECRET;

const config = new Config(projectID, apiSecret);
const sdk = new SDK(config);

Examples

A list of examples can be found in the integration tests here.

Services

The Corbado Node.js SDK provides the following services:

  • authTokens for managing authentication tokens needed for own session management (examples)
  • emailMagicLinks for managing email magic links (examples)
  • emailOTPs for managing email OTPs (examples)
  • sessions for managing sessions
  • smsOTPs for managing SMS OTPs (examples)
  • users for managing users (examples)
  • validations for validating email addresses and phone numbers (examples)

To use a specific service, such as sessions, invoke it as shown below:

corbado.sessions().getCurrentUser(req);

:books: Advanced

Error handling

The Corbado Node.js SDK throws exceptions for all errors. The following errors are thrown:

  • BaseError for failed assertions and configuration errors (client side)
  • ServerError for server errors (server side)

If the Backend API returns a HTTP status code other than 200, the Corbado Node.js SDK throws a ServerError. The ServerErrorclass provides convenient methods to access all important data:

try {
    // Try to get non-existing user with ID 'usr-123456789'
    const user = sdk.users().get('usr-123456789');
} catch (error: ServerError) {
    // Show HTTP status code (404 in this case)
    console.log(error.getHttpStatusCode());

    // Show request ID (can be used in developer panel to look up the full request
    // and response, see https://app.corbado.com/app/logs/requests)
    console.log(error.getRequestID());

    // Show full request data
    console.log(error.getRequestData());

    // Show runtime of request in seconds (server side)
    console.log(error.getRuntime());

    // Show validation error messages (server side validation in case of HTTP
    // status code 400 (Bad Request))
    console.log(error.getValidationMessages());

    // Show full error data
    console.log(error.getError());
}

:speech_balloon: Support & Feedback

Report an issue

If you encounter any bugs or have suggestions, please open an issue.

Slack channel

Join our Slack channel to discuss questions or ideas with the Corbado team and other developers.

Slack

Email

You can also reach out to us via email at [email protected].

Vulnerability reporting

Please report suspected security vulnerabilities in private to [email protected]. Please do NOT create publicly viewable issues for suspected security vulnerabilities.