New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

anchor-link

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anchor-link

Library for authenticating and signing transactions using the Anchor Link protocol

  • 3.0.0-beta5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
857
decreased by-18.46%
Maintainers
2
Weekly downloads
 
Created
Source

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

Key features:

  • Persistent sessions
  • Cross device signing
  • End to end encryption
  • Open standard

Resources:

Installation

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

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"></script>
<script src="https://unpkg.com/anchor-link-browser-transport"></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')

Basic usage

First you need to instantiate your transport and the link.

const transport = new AnchorLinkBrowserTransport()
const link = new AnchorLink({transport})

Now you're ready to create signing requests for EOS main-net (see options for how to use it on other networks).

const action = {
    account: 'eosio',
    name: 'voteproducer',
    authorization: [{
        actor: '............1', // ............1 will be resolved to the signing accounts permission
        permission: '............2' // ............2 will be resolved to the signing accounts authority
    }],
    data: {
        voter: '............1', // same here
        proxy: 'greymassvote',
        producers: [],
    }
}
link.transact({action}).then((result) => {
    console.log(`Transaction broadcast! Transaction id: ${ result.processed.id }`)
})

See the Link.transact API docs for all options and return values.

To create a persistent login session use Link.login, example:

link.login('mydapp').then(({session}) => {
    session.transact({action}).then((result) => {
        console.log(`Transaction broadcast! Transaction id: ${ result.processed.id }`)
    })
})

You can find more examples in the examples directory in the root of this repository.

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:

PackageDescription
anchor-link-browser-transportBrowser overlay that generates QR codes or triggers local URI handler if available
anchor-link-console-transportTransport 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 and buoy golang).

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.

License

MIT


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

FAQs

Package last updated on 28 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc