0.1.102 • Published 2 months ago

mchplus-auth-js v0.1.102

Weekly downloads
89
License
ISC
Repository
github
Last release
2 months ago

Authentication API for MCH Plus

This API connects to the authentication of MCH Plus, the blockchain game publishing service of doublejump.tokyo.

Please read the documentation below for how to use the API and which endpoints are exposed.

Installation

Npm

npm install mchplus-auth-js

Yarn

yarn add mchplus-auth-js

IMPORTANT: Breaking changes from version 0.1.1

Since version 0.1.1, mchplus-auth-js needs a provider instead of a web3 instance. This allows projects to freely choose between web3.js or ethers.js.

Note: mchplus-auth-js uses ethers.js under the hood.

Usage(> 0.1.1)

import MchplusAuth from 'mchplus-auth-js'

const clientId = 'xxx'
const provider = // your user's provider
const env = 'sand' || 'prod' // env can be either sand or prod
const lang = 'en' // set your user's language here

const auth = new MchplusAuth(clientId, provider, env, lang)

// call methods here

Usage(< 0.1.1)

import MchplusAuth from 'mchplus-auth-js'

const clientId = 'xxx'
const web3 = // your user's web3 instance
const env = 'sand' || 'prod' // env can be either sand or prod
const lang = 'en' // set your user's language here

const auth = new MchplusAuth(clientId, web3, env, lang)

// call methods here

Authentication API

Authenticate a user with their Ethereum address

Users sign up and log into the game with their Ethereum address. The signAuth logs in the user (or creates a new account if first login) and signs a Ethereum transaction with the public key.

await auth.signAuth();

Verify Phone Number API

Connect a user's phone number to their account

MCH Plus offers a phone number verification to protect our games from multiple accounts. The account verification has 2 steps:

  1. Type in a user's phone number to receive a text message or call with the Authentication Pin.
const number = "+8108092624621";
const isCall = false; // if true, user will get called instead of text message

await auth.submitNumber(number, isCall);
  1. Type in the Authentication Pin and sign a transaction with the public key.
const code = "xxxxxx"; // the frontend should have an input field

await auth.confirmNumber(code);

Helper Functions

The API also provides some helper functions to make the frontend development easier:

Return a list of available regions and their country codes:

await auth.getNumberRegions();

QR code generation API for login

Generates a QR code for the user to log into the game.

await auth.getQRCode(callbackUrl, state);

Get Client Info API

You can get the values of the terms of use and privacy policy associated with the client_id.

await auth.getClientInfo();
0.1.102

2 months ago

0.1.101

3 months ago

0.1.100

9 months ago

0.1.98

1 year ago

0.1.96

1 year ago

0.1.97

1 year ago

0.1.93

1 year ago

0.1.94

1 year ago

0.1.95

1 year ago

0.1.92

2 years ago

0.1.91

3 years ago

0.1.9

3 years ago

0.1.61

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.0.48

3 years ago

0.0.47

3 years ago

0.0.45

3 years ago

0.0.46

3 years ago

0.0.44

3 years ago

0.0.43

3 years ago

0.0.42

3 years ago

0.0.41

4 years ago

0.0.40

4 years ago

0.0.39

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.34

4 years ago

0.0.30

4 years ago

0.0.31

4 years ago

0.0.32

4 years ago

0.0.33

4 years ago

0.0.28

4 years ago

0.0.29

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.23

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.19

4 years ago

0.0.18

4 years ago

0.0.15

4 years ago

0.0.16

4 years ago

0.0.17

4 years ago

0.0.13

4 years ago

0.0.14

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago