@aeternity/id-manager-provider

0.0.11 • Public • Published

Æternity ID Manager provider

This basically is a dummy web3 provider which sends its requests to the ID Manager instead of handling them itself. The communication is handled with postMessage calls and callbacks. For security all Dapps using this must run under the following url scheme http(s)://.aepps.(com|dev)

import IdManagerProvider from '@aeternity/id-manager-provider'
// ...
function initWeb3() {
	let web3;
	let idManager = new IdManagerProvider({
		skipSecurity: process.env.NODE_ENV === 'development'
	})
	idManager.checkIdManager().then( (idManagerPresent) => {
		if (idManagerPresent) {
			// optional if you want the provider to poll current blocks
			idManager.startPolling()
			web3 = new Web3(idManager.provider)
		} else if (typeof window.web3 !== 'undefined') { // Metamask
			web3 = new Web3(window.web3.currentProvider);
		} else {
			web3 = null;
		}

		if (web3) {
			// Ready
		} else {
			// Not Ready
		}

	})
}

Readme

Keywords

none

Package Sidebar

Install

npm i @aeternity/id-manager-provider

Weekly Downloads

1

Version

0.0.11

License

ISC

Unpacked Size

6.33 kB

Total Files

4

Last publish

Collaborators

  • hanssv
  • aebot
  • marc0olo
  • thepiwo
  • dincho
  • davidyuk