rupt
v2.31.2
Published
Library for monitoring and preventing account sharing in web apps.
Maintainers
Readme
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 ruptor if using npm
npm install --save ruptImport
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:
- Attach devices to accounts. Ideally, you should do this on every page once.
- 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?
Get signals
When using the Rupt API, you need to pass signals to the API to identify the device. To get the signals, call the getSignals function like so:
await Rupt.getSignals();Fingerprint a device
To fingerprint a device, call the fingerprint function like so:
await Rupt.fingerprint({
client_id: `client_id`,
});This will return a fingerprint ID. For more on this, see Fingerprint a device.
Get fingerprint hash
To get the fingerprint hash, call the getHash function like so:
const [hash, last_hash] = await Rupt.getHash();This will return an array with the first element being the current fingerprint hash and the second element being the last fingerprint hash.
That's it. To learn more, visit the documentation
