1.8.2 • Published 3 years ago

@daocasino/platform-back-js-lib v1.8.2

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

Platform JS sdk

This is the frontend library for DaoPlatform

Architecture

This library is used to work as handy client for platform backend. It is written with TypeScrypt, compiled into JavaScript. It also exports types similar to ones used in backend.

The project is structured as node.js project, containing package.json, so it can be imported as npm module in frontend frameworks like react.js.

Usage

This library has a simple api. It exports the next methods:

  • Connect - creates connection to backend. Takes address of the platform Backend and object with optional params:

    • secure - if true, will use https and wss, else http and ws.

    • autoRefresh - if true, after websocket authorization it will automatically check timeout of authorization tokens and refresh them, firing event emits.

    • onClose - function that is called when socket is closed

  • WalletAuth - the constructor that creates WalletAuth object. This can be used to implement authorization via DaoWallet. It takes walletUrl and redirectUrl as params. When constructor is invoked, it checks if token is present in browser url. If so, it stores it inside the created WalletAuth object. Then user can invoke the next methods:

    • clearLocation - removes token from the browser url (if present)

    • getWalletToken - returns stored token (if present, null otherwise)

    • hasToken - returns true if token is stored inside

    • reset - creates new WalletAuth object based on this one

    • auth - redirects browser to DaoWallet to proceed authorization. It takes caisnoName as argument.

Method connect returns api object that can be used to communicate with platform backend. Methods of the api object are described below.

Api methods

This section describes methods of the api object. This methods work just as rpc calls to methods described in documentation.

  • getToken - used to get access and refresh tokens to authorize in websocket based on DaoWallet token.

    • Takes walletAuth as argument - to get DaoWallet token.

    • Returns access and refresh tokens (as one object).

  • auth - authorizes webSocket connection.

    • Takes access and refresh tokens (as one object)

    • Returns information about authorized account, including name and email.

  • accountInfo

    • Do not take any arguments.

    • Returns information about authorized account, including name and email.

  • fetchCasinos

    • Do not take any arguments.

    • Returns information about casinos in this system.

  • fetchGames

    • Do not take any arguments.

    • Returns information about games in this system.

  • fetchSessions

    • Do not take any arguments.

    • Returns information about game sessions of authorized account.

  • fetchGamesInCasino

    • Takes casinoId as argument.

    • Returns information about games presented in this casino.

  • fetchSessionUpdates

    • Takes sessionId as argument.

    • Returns information about updates of this session.

  • gameAction - used to do any action in the current game session.

    • Takes sessionId, actionType, params as arguments.

    • Returns nothing.

  • newGame - used to create new game sessions.

    • Takes deposit, casinoId, gameId, actionType, actionParams as arguments.

    • Returns information about created GameSession

Example

You can find example in the example folder of a project. It is a react spa that uses this library.

1.8.2

3 years ago

1.8.1

3 years ago

1.8.0

3 years ago

1.7.12

3 years ago

1.7.11

3 years ago

1.7.10

3 years ago

1.7.9

3 years ago

1.7.8

3 years ago

1.7.7

3 years ago

1.7.6

3 years ago

1.7.5

3 years ago

1.7.4

3 years ago

1.7.3

3 years ago

1.7.2

3 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.12

4 years ago

1.6.11

4 years ago

1.6.10

4 years ago

1.6.9

4 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.10

4 years ago

1.5.12

4 years ago

1.5.11

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago