@ruptjs/core
TypeScript icon, indicating that this package has built-in type declarations

0.0.14 • Public • Published

Rupt SDK (core)

The Rupt Core SDK is designed to be used on the server. It operates as a convenient wrapper for all Rupt API methods and benefits from type safety and intellisense.

Installation

yarn add @ruptjs/core

or if using npm

npm install @ruptjs/core

Import and instantiation

Replace API_SECRET with your Rupt API secret key. This can be found in your Rupt dashboard. Select the secret key for the api key you want to use.

import RuptCore from '@ruptjs/core';
const Rupt = new RuptCore(API_SECRET);

Usage

List all challenges

Returns a list of your challenges. The challenges are returned sorted by creation date, with the most recently created challenges appearing first.

const { data, total } = await Rupt.getChallenges({
  page: 1,
  limit: 10,
});

Retrieve a challenge

Retrieve the details of an existing challenge. Supply the unique challenge ID from the Rupt SDK onChallenge callback.

const { challenge } = await Rupt.getChallenge(CHALLENGE_ID);

Retrieve challenge devices

Retrieve the list of devices for an existing challenge.

const { data } = await Rupt.getChallengeDevices(CHALLENGE_ID);

Kick a challenge device

Kick an attached device for an existing challenge. Supply the unique challenge ID from the Rupt SDK onChallenge callback. Supply the unique device ID from the list of devices for the challenge.

await Rupt.kickChallengeDevice({
  challenge: "CHALLENGE_ID",
  device: "DEVICE_ID",
});

Send challenge code

Send a two-factor authentication code for an existing challenge.

await Rupt.sendChallengeCode({
  challenge: "CHALLENGE_ID",
  device: "DEVICE_ID",
  language: "en",
  channel: "email"
});

Verify challenge code

Verify a device for an existing challenge.

await Rupt.verifyChallengeCode({
  challenge: "CHALLENGE_ID",
  code: "123456"
});

Complete challenge

Complete an existing challenge.

const { challenge } = await Rupt.completeChallenge(CHALLENGE_ID);

Evaluate an action

Evaluate an action for a user.

const { verdict, reasons, challenge_id } = await Rupt.evaluate({
  action: "login",
  user: "USER_ID",
  fingerprint: ["FINGERPRINT_ID", "LAST_FINGERPRINT_ID"], // Use the rupt client sdk method `getHash` to get the fingerprint hashes from the browser
  ip: "IP_ADDRESS",
});

To learn more, visit the api documentation

Package Sidebar

Install

npm i @ruptjs/core

Weekly Downloads

108

Version

0.0.14

License

MIT

Unpacked Size

12.9 kB

Total Files

6

Last publish

Collaborators

  • marcrupt
  • ahmedsabil