Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@endpass/connect

0.5.1-alpha • Public • Published

Endpass Connect

Table of contents

Library

Install library via npm of yarn.

npm i --save @endpass/connect
yarn add @endpass/connect

You don't need any dependencies like web3, Endpass Connect includes it out of the box.

Usage

Create instance of class and use it in your application. You can know about options and methods in the API section.

import EndpassConnect from '@endpass/connect';
 
const connect = new EndpassConnect({
  appUrl: 'http://connect.url',
});

Next, you can try to authentificate user.

try {
  const res = await connect.auth();
 
  // Now, you have active account address and network id
} catch (err) {
  // Something goes wrong! User is not authorized
}

API

Instance options

Property Type Default Description
appUrl string undefined Url of Endpass Connect application. Required params.

Instance methods

Method Params Returns Description
auth Promise<{ status: boolean, message?: string }> Open Endpass Connect application for user authorization, return promise, which returns object with auth status. See Errors handling for more details.
logout Promise<{ status: boolean, message?: string }> Open Endpass Connect application for user logout, return promise, which returns object with auth status. See Errors handling for more details.
getAccountData Promise<{ activeAccount: string, activeNet: number }> Returns authorized user active account.
injectWeb3 target: Window Injects web3 with provider to the target for intercepting requests. Use it if your application works with web3 and Etherium network. Also, highly recommended use it with subscribe option.
sendSettings selectedAddress: string, networkVersion: string Set user settings to the injected web3 provider.

Errors handling

The most of Endpass Connect methods throws errors by default, but there are some exceptions. For example auth method, which returns result of authentification with status property and message. If status if falsy, you can use message proprty to determine reason and handle error with some interface solutions.

Development

Command Description
build Builds application and library.
dev:app Starts application dev server.
build:app Builds application.
dev:lib Starts library development environment.
build:lib Builds library.
test:unit Runs unit tests.
format Formats code of packages with eslint and prettier.

Keywords

none

Install

npm i @endpass/[email protected]

Version

0.5.1-alpha

License

MIT

Unpacked Size

755 kB

Total Files

117

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar