Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@corbado/node-sdk

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corbado/node-sdk

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

  • 3.0.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
298
increased by53.61%
Maintainers
0
Weekly downloads
 
Created
Source
GitHub Repo Cover

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: Installation | :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:

  • sessions for managing sessions (examples)
  • identifiers for managing identifiers (examples)
  • users for managing users (examples)

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

corbado.sessions().getAndValidateCurrentUser(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 vincent.delitz@corbado.com.

Vulnerability reporting

Please report suspected security vulnerabilities in private to security@corbado.com. Please do NOT create publicly viewable issues for suspected security vulnerabilities.

Keywords

FAQs

Package last updated on 12 Sep 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc