OSDN Git Service

refactor: import vue-router
[bytom/Byone.git] / src / inject.js
1 import IdGenerator from '@/utils/IdGenerator'
2 import { EncryptedStream } from 'extension-streams'
3 // import * as PairingTags from './messages/PairingTags'
4 // import * as NetworkMessageTypes from './messages/NetworkMessageTypes'
5
6 /***
7  * This is the javascript which gets injected into
8  * the application and facilitates communication between
9  * bytom chrome extension and the web application.
10  */
11 class Inject {
12   constructor() {
13     // Injecting an encrypted stream into the web application.
14     const stream = new EncryptedStream('inject', IdGenerator.text(64))
15
16     // Waiting for bytomExtension to push itself onto the application
17     stream.listenWith(msg => {
18       console.log(1111, msg)
19       if (msg && msg.hasOwnProperty('type') && msg.type === 'scatter') {
20       }
21       // window.scatter = new Scatterdapp(stream, msg.payload)
22     })
23
24     // Syncing the streams between the extension and the web application
25     stream.sync('bytom', stream.key)
26   }
27 }
28
29 const inject = new Inject()