0.12.0 • Published 1 year ago

@slashauth/node-client v0.12.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

/Auth Node Client

/auth is the easiest way to provide login and token gating to your web3 enabled app!

This package provides a client to Slashauth to use from your node backend. Authorize any wallet within your app with a single API call.

Learn how to use SlashAuth in your project by reading the docs

Features

  • 🔥 Login and token gating out of the box
  • 🔑 Security for your app and your clients
  • 💨 Fast and lightweight
  • ❤️ Helpful and friendly community

Installation

Install slashauth node client using NPM:

npm i --save @slashauth/node-client

Or Yarn

yarn add @slashauth/node-client

Initial steps

In order to use Slashauth you must first create a Slashauth app. Create one here. Take note of your client ID and client secret because you'll need these in the next step.

Usage

Instantiate the Slashauth Client in your app using your client ID and client secret above:

const slashauthClient = new SlashauthClient(<your client id>, <your client secret>);

Use the client to authorize whether a wallet has a specified role:

const [hasRole, , err] = await slashauthClient.hasRole({
  address: '0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B',
  role: 'admin',
});

if (err) {
  console.log(err);
}

console.log('has role? ', hasRole);

Use the client to validate a user's token. This endpoint will return a 403 for invalid tokens:

slashauthClient
  .validateToken({
    token: 'eyJhbGciOiJSUzI1NiI...R814nN5izqQ-y1OzgNUXSDfF3d1rWjloZ3sw',
  })
  .then((response) => {
    console.log({
      clientID: r.clientID,
      address: r.address,
      expiresAt: r.expiresAt,
    });
  })
  .catch((e) => console.error(e));
0.11.0

1 year ago

0.10.1

1 year ago

0.10.0-beta.2

1 year ago

0.12.0

1 year ago

0.10.0-beta.0

1 year ago

0.10.0-beta.1

1 year ago

0.11.0-beta1

1 year ago

0.10.1-beta.0

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.12.0-beta.0

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.8.3

2 years ago

0.8.2

2 years ago

0.8.1-beta1

2 years ago

0.8.0-beta4

2 years ago

0.8.0-beta3

2 years ago

0.8.0-beta2

2 years ago

0.8.0-beta1

2 years ago

0.8.0-beta5

2 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.7.0-beta.0

2 years ago

0.7.0-beta.1

2 years ago

0.7.0-beta.2

2 years ago

0.7.0-beta.3

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.7

2 years ago

0.7.0-beta.4

2 years ago

0.5.0

2 years ago

0.3.2

2 years ago

0.4.0

2 years ago

0.5.2

2 years ago

0.3.4

2 years ago

0.6.0

2 years ago

0.5.1

2 years ago

0.3.3

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago