@gandalf-network/connect
v1.0.5
Published
`connect` is a library that makes it easier to generate valid [Connect](https://docs.gandalf.network/concepts/connect) URLs that lets your users to link their accounts to Gandalf.
Downloads
160
Readme
connect
connect
is a library that makes it easier to generate valid Connect URLs that lets your users to link their accounts to Gandalf.
Features
- Generate valid Connect URLs
- Generate valid Connect QRCodes on web
- Parameter validation
Getting Started
This section provides a quick overview of how to integrate the library into your project.
Prerequisites
NodeJS - version 18.x or higher
Installation
npm install @gandalf-network/connect --save
Usage
Initialization
import Connect from "@gandalf-network/connect";
const connect = new Connect({
publicKey: process.env.PUBLIC_KEY,
redirectURL: "YOUR_REDIRECT_URL",
services: { "NETFLIX": true } // At least one service is required
})
// CommonJS
const Connect = require("@gandalf-network/connect");
const connect = new Connect({
publicKey: process.env.PUBLIC_KEY,
redirectURL: "YOUR_REDIRECT_URL",
services: { "NETFLIX": true } // At least one service is required
})
Generate a Connect URL
const url = await connect.generateURL()
console.log(url)
Generate a Connect QRCode
Note: This function will only work within a browser context and will fail otherwise.
const qrCodeURL = await connect.generateQRCode()
console.log(qrCodeURL)
Extract the dataKey from the redirectURL
const datakey = Connect.getDataKeyFromURL("REDIRECT_URL")
console.log(datakey)
Contributing
Contributions are welcome, whether they're feature requests, bug fixes, or documentation improvements.