0.1.3 • Published 3 years ago

dauth-client-sdk v0.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

dauth-client-sdk-js

dAuth client-side SDK for JavaScript

:warning: dauth-client-sdk-js works fine only on browsers

Installation

$ npm i dauth-client-sdk

Example

To execute the sample codes below, you need to create an application with dAuth in advance.

Initialization

import { DAuth } from "dauth-client-sdk";

const dAuth = await DAuth.init({
  clientID: "CLIENT_ID_OF_YOUR_APPLICATION",
});

Requesting a user's ID token in accordance with OpenID Connect (response_type: id_token)

dAuth.authorize({
  redirectURL: "http://your.app.com/callback",
  nonce: "pdITKAtep0pfPOrUXdzjqW6gKvXezurJ", // arbitrary string to prevent replay attacks
});

Requesting a signature for a message

const sig = await dAuth.sign({
  message: "ARBITRARY_MESSAGE",
});

Requesting a signature for a token transfer transaction

const metaTx = await dAuth.signTokenTransfer({
  id: 1, // token ID
  to: "0x0000000000000000000000000000000000000000", // destination address
  amount: 1, // token amount
});

To execute the transaction, call POST /metaTransactions of dAuth API.

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago