ghost-keychain/packages/extension-inject
Amaury Martiny 452ce41b71
Provider Injection (#253)
* Add PostMessageProvider

* Remove coder

* Add provier in state

* Add msg handling

* Fix lint

* Fix little bugs

* Make send work

* Small tweaks

* Make subscriptions work

* Add readme

* Remove useless file

* Roder alphabet

* Fix lint

* List & start provider

* Add unsubscribe

* List and Use providers

* Update packages/extension/src/background/types.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update packages/extension/src/background/handlers/State.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update packages/extension/src/background/handlers/State.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update packages/extension/src/background/handlers/State.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update packages/extension/src/background/handlers/State.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update packages/extension-dapp/src/index.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update README

* Remove circular dep

* Remove useless function

* Update README

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-02-26 17:18:44 +01:00
..
src Provider Injection (#253) 2020-02-26 17:18:44 +01:00
LICENSE extension-inject (no direct globals for extension/dapp) (#75) 2019-07-12 21:22:06 +02:00
package.json [CI Skip] 0.22.0-beta.6 2020-02-25 11:25:45 +00:00
README.md extension-inject (no direct globals for extension/dapp) (#75) 2019-07-12 21:22:06 +02:00

@polkadot/extension-inject

This is a basic extension injector that manages access to the global objects available. As an extension developer, you don't need to manage access to the windo object manually, by just calling enable here, the global object is setup and managed properly. From here any dapp can access it with the @polkadot/extension-dapp package;

Usage

import { injectExtension } from '@polkadot/extension-inject';

// this a the function that will be exposed to be callable by the dapp. It resolves a promise
// with the injected interface, (see `Injected`) when the dapp at `originName` (url) is allowed
// to access functionality
function enableFn (originName: string): Promise<Injected> {
  ...
}

// injects the extension into the page
injectExtension(enableFn, { name: 'myExtension', version: '1.0.1' });