1.1.9 • Published 11 months ago

@corbado/nodejs v1.1.9

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

Corbado Node.js library

The Corbado Node.js library provides convenient access to the Corbado API from applications running on Node.js.

Documentation

See the Corbado API Reference and Corbado API-only integration guide to understand the usage of Corbado API.

Requirements

Node 8 or higher.

Installation

npm install @corbado/nodejs --save

Usage

The package needs to be configured with your Corbado account's project ID and API secret. All the parameters can be obtained from Corbado developer panel.

project ID and API secret should be provided when initializing the Corbado module:

const Corbado = require('@corbado/nodejs');

const config = new Corbado.Configuration()
config.projectID = process.env.PROJECT_ID
config.apiSecret = process.env.API_SECRET

const corbado = new Corbado.SDK(config)

Services

Corbado provides several services, e.g. PasskeyService, SessionService, EmailLinkService or bashortSessionService. To access specific methods in, e.g. SessionService, you can call:

corbado.session.verify(sessionToken, clientInfo);

ShortSession

Short session service provides you an easy way of accessing our session v2 variant. It provides a validate method that returns a user object with all information about the current users state. This state contains the current authentication state as well as users id, name, email and phone number.

const Corbado = require('@corbado/nodejs');

const config = new Corbado.Configuration()
config.projectID = process.env.PROJECT_ID
config.apiSecret = process.env.API_SECRET
config.authenticationURL = "https://" + config.projectID + '.auth.corbado.com'

const corbado = new Corbado.SDK(config)

const user = await corbado.shortSession.validate(req)
if (user.authenticated === true) {
    // Do anything with authenticated user
} else {
    // Perform login ceremony
}

Utilities

Corbado package also provides several useful utility functions that can ease the development process, e.g.:

Corbado.getClientInfo(req);

helps to obtain relevant client information (UserAgent, RemoteAddress, etc.) object from an HttpRequest.

1.1.9

11 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago