@datawallet/pls
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

PLS

The most polite library you'll ever find.

Stands for Permissioned Local Storage and is your companion to interact with Datawallet 3.0 and get access to your users' data ethically.

🛠 Installation

npm install @datawallet/pls --save

or

yarn add @datawallet/pls

🏖 How does it work?

This library currently exposes 3 methods: authorize, query and a utilitary function isAvailable. It is written in Typescript and has typings available for further documentation.

Authorize

authorize takes a single string argument in the form of a GraphQL query and returns a Promise<ISignedQuery>. The full documentation of the schemas is available here: https://docs.datawallet.com.

⚠️ It is important to note that authorize will throw if the user denies consent or something else fails. ⚠️

Query

query takes a single ISignedQuery argument which is an opaque signed query object and returns a Promise<any> the same shape of your GraphQL query.

Is available

isAvailable returns a boolean indicating if Datawallet 3.0 is installed or not.

👌 Basic Usage

import pls from '@datawallet/pls';

if (!pls.isAvailable()) {
    // show some call to action to your user to install Datawallet 3.0
    // and give feedback.
    return;
}

const signedQuery = await pls.authorize(`
    datawallet {
        userId
    }
`);
// authorize ~= {query: "datawallet { userId }}", signature: "..."}

const data = await pls.query(signedQuery);
// data ~= {datawallet: {userId: "..."}}

// or
const {datawallet: {userId}} = await pls.query(signedQuery);
// userId ~= "...";

Readme

Keywords

none

Package Sidebar

Install

npm i @datawallet/pls

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

12.2 kB

Total Files

14

Last publish

Collaborators

  • datawallet-patricio
  • melgaafary
  • datawallet-alex
  • nicolasbrugneaux