2.15.0 • Published 5 days ago

rupt v2.15.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 days ago

Rupt JavaScript SDK

This Quick start guide will walk you through the steps to integrate Rupt into your app or website using JavaScript. By the end of this guide, you will have a fully working account-sharing detection mechanism integrated into your website.

Installation

yarn add rupt

or if using npm

npm install --save rupt

Import

import Rupt from "rupt";

Note the common js version can be found in rupt/common.cjs

Usage

The two main things you need to do are:

  1. Attach devices to accounts. Ideally, you should do this on every page once.
  2. Detach devices from accounts. You should do this when the user logs out.

Doing these two things will allow Rupt to associate devices with accounts and detect behaviors that indicate account sharing. For more on this, see How account sharing prevention works?

Attach a device

First import the script (only if you installed using a package manager)

import Rupt from "rupt";

Call the attach function to link the device to the account. You must pass the client_id and a account.

const { device_id } = await Rupt.attach({
  client_id: `client_id`,
  account: `account_id`,
  redirect_urls: {
    logout_url: "https://your-logout-url.com",
    new_account_url: "https://your-create-new-account-url.com",
  },
});

Ideally, you should call the attach function on every page as soon as you have the account id available. For more on this refer to the advanced section: When and where to call the attach function?

Detach a device

By default, devices are automatically detached if they are not used for 1 week. You can change this behavior in the dashboard settings.

But you should also call the detach function when the user logs out. This will ensure that Rupt has the most up-to-date information about the devices associated with the account. To do this, call the detach function like so:

await Rupt.detach({
  client_id: `client_id`,
  account: `account_id`,
  device: `device_id`,
});

The device field takes the device ID returned in the attach function response as device_id. Finally, when a detach function is called, it triggers the logout flow so the user will be redirected to the callbacks.logout_url in the target device. Ensure you have set the logout_url in the redirect_urls object when calling the attach function. For more, see Signing the user out

That's it. To learn more, visit the documentation

2.15.0

5 days ago

2.14.0

5 months ago

2.13.0

7 months ago

2.11.2

8 months ago

2.11.3

8 months ago

2.11.0

8 months ago

2.12.0

7 months ago

2.11.1

8 months ago

2.9.2

11 months ago

2.9.4

11 months ago

2.9.3

11 months ago

2.9.6

11 months ago

2.9.5

11 months ago

2.10.1

10 months ago

2.10.0

11 months ago

2.8.3

1 year ago

2.8.2

1 year ago

2.8.1

1 year ago

2.8.0

1 year ago

2.7.0

1 year ago