All Projects → greymass → anchor-link

greymass / anchor-link

Licence: other
Persistent, fast and secure signature provider for EOSIO chains built on top of EOSIO Signing Requests (EEP-7)

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to anchor-link

alcor-ui
Alcor Exchange | First self-listing onchain DEX for eosio tokens;
Stars: ✭ 103 (+255.17%)
Mutual labels:  eos, eosio
EOS-Proxy-Token
Proxy token to allow mitigating EOSIO Ram exploit
Stars: ✭ 22 (-24.14%)
Mutual labels:  eos, eosio
ping-eos
Implementing ping between EOS / React.js
Stars: ✭ 86 (+196.55%)
Mutual labels:  eos, eosio
twitbot
🦉Just a simple twitter bot for tipping in EOS
Stars: ✭ 18 (-37.93%)
Mutual labels:  eos, eosio
every-eos
Decentralized exchange based on eos.io
Stars: ✭ 20 (-31.03%)
Mutual labels:  eos, eosio
eosdart ecc
Elliptic curve cryptography functions in Dart. Private Key, Public Key, Signature, AES, Encryption, Decryption
Stars: ✭ 25 (-13.79%)
Mutual labels:  eos, eosio
eosdart
EOS API Client in Dart Language
Stars: ✭ 33 (+13.79%)
Mutual labels:  eos, eosio
namevault
Account creator & name generator for users on EOS and EOSIO compatible blockchains.
Stars: ✭ 17 (-41.38%)
Mutual labels:  eos, eosio
eosreach-android
An EOS wallet developed in Kotlin using the eos-jvm SDK and the model view intent (MVI) design pattern. This wallet serves as a blueprint for how other developers might want to utilise eos-jvm to develop native Android apps that consume the EOS blockchain.
Stars: ✭ 37 (+27.59%)
Mutual labels:  eos, eosio
eosportal-api
🗳EOSPortal Community Voting
Stars: ✭ 16 (-44.83%)
Mutual labels:  eos, eosio
django-scatter-auth
Django Scatter Auth for EOS blockchain
Stars: ✭ 16 (-44.83%)
Mutual labels:  eos, eosio
EOSWallet
🔐EOS Wallet: Manage your EOS accounts with steroids :)
Stars: ✭ 36 (+24.14%)
Mutual labels:  eos, eosio
eosgo-client
A simple Go wrapper of EOS (eosio) RPC API, and more!
Stars: ✭ 29 (+0%)
Mutual labels:  eos, eosio
EOSBank
EOS Bank (CPU rent contract)
Stars: ✭ 45 (+55.17%)
Mutual labels:  eos, eosio
luckydog
luckydog(锦鲤) 一个幸运小游戏
Stars: ✭ 14 (-51.72%)
Mutual labels:  eos, eosio
geos
golang implementation of the EOS protocol
Stars: ✭ 67 (+131.03%)
Mutual labels:  eos, eosio
Monstereos
A Tamagotchi and Battle Game for EOS Blockchain :)
Stars: ✭ 174 (+500%)
Mutual labels:  eos, eosio
Awesome Eos
A curated list of awesome EOS frameworks, libraries, software and resources.
Stars: ✭ 181 (+524.14%)
Mutual labels:  eos, eosio
eos-jvm
EOS libraries for the JVM, designed primarily for Android development.
Stars: ✭ 38 (+31.03%)
Mutual labels:  eos, eosio
Scatter-Demos
A set of integration demos using eosjs and Scatter
Stars: ✭ 80 (+175.86%)
Mutual labels:  eos, eosio

Anchor Link Package Version License

Persistent, fast and secure signature provider for EOSIO chains built on top of EOSIO Signing Requests (EEP-7)

Key features:

  • Persistent account sessions
  • End-to-end encryption (E2EE)
  • Account-based identity proofs
  • Cross-device signing
  • Network resource management
  • Open standard

Resources:

Guides:

Examples:

Installation

The anchor-link package is distributed both as a module on npm and a standalone bundle on unpkg.

Browser using a bundler (recommended)

Install Anchor Link and a transport:

yarn add anchor-link anchor-link-browser-transport
# or
npm install --save anchor-link anchor-link-browser-transport

Import them into your project:

import AnchorLink from 'anchor-link'
import AnchorLinkBrowserTransport from 'anchor-link-browser-transport'

Browser using a pre-built bundle

Include the scripts in your <head> tag.

<script src="https://unpkg.com/anchor-link@3"></script>
<script src="https://unpkg.com/anchor-link-browser-transport@3"></script>

AnchorLink and AnchorLinkBrowserTransport are now available in the global scope of your document.

Using node.js

Using node.js

yarn add anchor-link anchor-link-console-transport
# or
npm install --save anchor-link anchor-link-console-transport

Import them into your project:

const AnchorLink = require('anchor-link')
const AnchorLinkConsoleTransport = require('anchor-link-console-transport')

Usage

First you need to instantiate your transport and the link.

const transport = new AnchorLinkBrowserTransport()
const link = new AnchorLink({
    transport,
    chains: [
        {
            chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
            nodeUrl: 'https://eos.greymass.com',
        }
    ],
})

Now you have a link instance that can be used in the browser to login and/or transact. See options for a full list of available options. Also refer to the anchor-link-browser-transport README for a list of available options within the transport.

Create a user session

To create a persistent session where you can push multiple transaction to a users wallet you need to call the login method on your link instance and pass your application name.

// Perform the login, which returns the users identity
const identity = await link.login('mydapp')

// Save the session within your application for future use
const {session} = identity
console.log(`Logged in as ${session.auth}`)

Perform a transaction with a user session

Using the session you have persisted within your applications state from the user login, you can now send transactions through the session to the users wallet using the transact method.

const action = {
    account: 'eosio',
    name: 'voteproducer',
    authorization: [session.auth],
    data: {
        voter: session.auth.actor,
        proxy: 'greymassvote',
        producers: [],
    },
}

session.transact({action}).then(({transaction}) => {
    console.log(`Transaction broadcast! Id: ${transaction.id}`)
})

Restoring a session

If a user has previously logged in to your application, you can restore that previous session by calling the restoreSession method on your link instance.

link.restoreSession('mydapp').then(({session}) => {
    console.log(`Session for ${session.auth} restored`)
    const action = {
        account: 'eosio',
        name: 'voteproducer',
        authorization: [session.auth],
        data: {
            voter: session.auth.actor,
            proxy: 'greymassvote',
            producers: [],
        },
    }
    session.transact({action}).then(({transaction}) => {
        console.log(`Transaction broadcast! Id: ${transaction.id}`)
    })
})

Additional Methods

A full list of all methods can be found in the Link class documentation.

One-shot transact

To sign action(s) or a transaction using the link without logging in you can call the transact method on your link instance.

const action = {
    account: 'eosio',
    name: 'voteproducer',
    authorization: [
        {
            actor: '............1', // ............1 will be resolved to the signing accounts name
            permission: '............2', // ............2 will be resolved to the signing accounts authority (e.g. 'active')
        },
    ],
    data: {
        voter: '............1', // same as above, resolved to the signers account name
        proxy: 'greymassvote',
        producers: [],
    },
}
link.transact({action}).then(({signer, transaction}) => {
    console.log(
        `Success! Transaction signed by ${signer} and bradcast with transaction id: ${transaction.id}`
    )
})

You can find more examples in the examples directory at the root of this repository and don't forget to look at the API documentation.

Transports

Transports in Anchor Link are responsible for getting signature requests to the users wallet when establishing a session or when using anchor link without logging in.

Available transports:

Package Description
anchor-link-browser-transport Browser overlay that generates QR codes or triggers local URI handler if available
anchor-link-console-transport Transport that prints ASCII QR codes and esr:// links to the JavaScript console

See the LinkTransport documentation for details on how to implement custom transports.

Protocol

The Anchor Link protocol uses EEP-7 identity requests to establish a channel to compatible wallets using an untrusted HTTP POST to WebSocket forwarder (see buoy node.js).

A session key and unique channel URL is generated by the client which is attached to the identity request and sent to the wallet (see transports). The wallet signs the identity proof and sends it back along with its own channel URL and session key. Subsequent signature requests can now be encrypted to a shared secret derived from the two keys and pushed directly to the wallet channel.

📘 Protocol specification

Developing

You need Make, node.js and yarn installed.

Clone the repository and run make to checkout all dependencies and build the project. See the Makefile for other useful targets. Before submitting a pull request make sure to run make lint.


Made with ☕️ & ❤️ by Greymass, if you find this useful please consider supporting us.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].