Coder Social home page Coder Social logo

ual-anchor's Introduction

UAL for Anchor Authenticator

This authenticator is meant to be used with Anchor and Universal Authenticator Library. When used in combination with them, it gives developers the ability to request transaction signatures through Anchor using the common UAL API.

Supported Environments

  • The Anchor Authenticator only supports both Desktop and Mobile environments

Getting Started

yarn add ual-anchor

Dependencies

You must use one of the UAL renderers below.

React - ual-reactjs-renderer PlainJS - ual-plainjs-renderer

Basic usage and configuration with React

import { Anchor } from 'ual-anchor'
import { UALProvider, withUAL } from 'ual-reactjs-renderer'

const eos = {
  chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
  rpcEndpoints: [{
    protocol: 'https',
    host: 'eos.greymass.com',
    port: '443',
  }]
}

const App = (props) => <div>{JSON.stringify(props.ual)}</div>
const AppWithUAL = withUAL(App)

const anchor = new Anchor([eos], {
  // Required: The app name, required by anchor-link. Short string identifying the app
  appName: 'my-example-dapp',
  // Optional: a @greymass/eosio APIClient from eosjs for both your use and to use internally in UAL
  // client = new APIClient({ provider }),
  // Optional: a JsonRpc instance from eosjs for your use
  // rpc: new JsonRpc(),
  // Optional: The callback service URL to use, defaults to https://cb.anchor.link
  // service: 'https://cb.anchor.link',
  // Optional: A flag to disable the Greymass Fuel integration, defaults to false (enabled)
  // disableGreymassFuel: false,
  // Optional: An account name on a Fuel enabled network to specify as the referrer for transactions
  // fuelReferrer: 'teamgreymass',
  // Optional: A flag to enable the Anchor Link UI request status, defaults to true (enabled)
  // requestStatus: true,  
  // Optional: Whether or not to verify the signatures during user login, defaults to false (disabled)
  // verifyProofs: false,
})

<UALProvider chains={[exampleNet]} authenticators={[anchor]}>
  <AppWithUAL />
</UALProvider>

License

MIT

ual-anchor's People

Contributors

aaroncox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ual-anchor's Issues

Unable to pass fetch provider to eosio core as option

 ERROR  Cannot start nuxt:  Missing fetch                             22:33:43

  at new FetchProvider (node_modules/@greymass/eosio/lib/eosio-core.js:3510:23)
  at new Anchor (node_modules/ual-anchor/dist/Anchor.js:72:30)
  at node_modules/nuxt3-ual/module.mjs:13:19
  at Array.map (<anonymous>)
  at setup (node_modules/nuxt3-ual/module.mjs:12:28)
  at Object.wrappedModule (node_modules/@nuxt/kit/dist/index.mjs:1249:22)
  at installModule (node_modules/@nuxt/kit/dist/index.mjs:1298:17)
  at async initNuxt (node_modules/nuxt3/dist/index.mjs:917:5)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6713:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6752:5)

I'm currently running into an issue that the underlaying package eosio-core.js doesn't work because the fetch provider is missing. It's an option in eosio to provide fetch in the options, but ual-anchor doesn't let us set those options.

It would be nice to have a clean way to pass through those options.

Currently I got it working by setting global.fetch but this pollutes the global scope.

Problem with socket.io connection

Hello,

I have a problem with socket.io. After successfully signing a transaction via the button Sign manually and then clicking on the Launch Anchor button my socket connection just closes and I can't send any events. After several attempts to send events in my connection it just creates new socket connections. It can be replicated only if I'm clicking on the Sign manually button and then on the Launch Anchor button. Everything is okay when the Anchor Wallet app opens itself. I'm using the Chrome 96.0.4664.110 version and the latest package version.
Could you help me please resolve the issue?
Thank you!

Need authenticate func

ual-scatter has the following authenticate implementation:
https://github.com/EOSIO/ual-scatter/blob/master/src/ScatterUser.ts#L111

This is useful when receiving user signup from a centralized server, separate from client-wallet communication.
This is because sending a signature, data, nonce, and publicKey to the server enables data validation with the ecc.recoverHash command.
Can you provide a function to verify the possession of a private key through a signature like this?

Problem with socketio

Hey guys, I'm having a problem with socketio, all my bussiness rule is on a websocket server, that waits from ual-anchor(Anchor transport link) to get the user account, and when I click on Launch Anchor, just close connection(Transport not open) to my websocket, are there some workaround to prevent this?

I'm on Brave(Chromium)

Inherit the appName from the generic UAL configuration instead of requiring it during ual-anchor instantiation

Currently ual-anchor throws an error if you don't include a name during its instantiation.

For example:

import AnchorLinkProvider from 'eos-transit-anchorlink-provider';

const context = initAccessContext({
  appName: 'dapp_name',
  walletProviders: [AnchorLinkProvider()]
});

This will throw an error unless you also pass the name to the AnchorLinkProvider constructor, like so:

import AnchorLinkProvider from 'eos-transit-anchorlink-provider';

const context = initAccessContext({
  appName: 'dapp_name',
  walletProviders: [AnchorLinkProvider('dapp_name')]
});

Ideally the AnchorLinkProvider should just inherit the name from the appName variable within the parent configuration.

Module not found: Error: Can't resolve 'crypto' in 'node_modules/asmcrypto.js'

When pulling ual-anchor via webpack +v5, the following error is shown:

ERROR in ./node_modules/asmcrypto.js/asmcrypto.all.es8.js 4107:27-44
Module not found: Error: Can't resolve 'crypto' in '[...]node_modules/asmcrypto.js'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

The anchor libraries use AES_CBC from asmcrypto.js which imports nodejs "crypto", but its not necessary. The AES_CBC code doesnt actually use any of that crypto

signArbitrary doesn't work

Signing an arbitrary string message is still not available with Anchor. I don't want to recomment my users another wallet instead, so I would be glad if this feature will be integrated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.