Skip to content
The most polite way to access your users' data.
TypeScript JavaScript Makefile Shell
Branch: master
Clone or download

README.md

PLS

The most polite way to access your users' data.

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 ~= "...";

🚀 Complete walkthrough and demo

If this wasn't sufficient, you can check this document to read a complete walkthrough as well as some examples

You can’t perform that action at this time.