Stands for Permissioned Local Storage and is your companion to interact with Datawallet 3.0 and get access to your users' data ethically.
npm install @datawallet/pls --save
or
yarn add @datawallet/pls
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 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.
authorize will throw if the user denies consent or something else fails.
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.
isAvailable returns a boolean indicating if Datawallet 3.0 is installed or not.
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 ~= "...";If this wasn't sufficient, you can check this document to read a complete walkthrough as well as some examples