diff --git a/docs/plugins/keewebhttp/index.html b/docs/plugins/keewebhttp/index.html index 0ef00a7..d21c62e 100644 --- a/docs/plugins/keewebhttp/index.html +++ b/docs/plugins/keewebhttp/index.html @@ -12,7 +12,13 @@ -

KeeWeb Plugin: KeeWebHttp

- https://plugins.keeweb.info/plugins/keewebhttp +

KeeWeb Plugin: KeeWebHttp

+https://plugins.keeweb.info/plugins/keewebhttp +

This plugin enables integrations with browser extensions, like + chromeIPass + or + PassIFox. +

+

It's the same as KeePassHttp, but for KeeWeb.

diff --git a/docs/plugins/keewebhttp/manifest.json b/docs/plugins/keewebhttp/manifest.json index 01677f4..42d8fd4 100644 --- a/docs/plugins/keewebhttp/manifest.json +++ b/docs/plugins/keewebhttp/manifest.json @@ -11,7 +11,7 @@ "licence": "MIT", "url": "https://plugins.keeweb.info/plugins/keewebhttp", "resources": { - "js": "NB8wqvULI7yTqf8FAkJYx2TbyW/BjDo7zpm15MHHHTcYYVIRhYFAeiKx5f9j9UtXLYr1deVc7STdvVLhNsD//tN4LRsSXmOiMt2NnhjIHLhVHwlKxSZTMeK5NrajxjdS0YtBKMg5oDt9vYa15qOvoX0fhmc9E1gD6j5z9sJAxT450JEDRZidXLnUnEnGIZunVH5OCe75eavvcEQ64sZ3pUouTN9iWU66sjC3hG/pk3o5I4+8W4v1MWy2TR7IKaVOLrRiDrzT/rnZoroRg7QLLUb+L185S/OYMEo8MIa7lMu/ULhmbhk0+JT2pukEofPkOZAlF8BIf1EGXGp6gObo4w==" + "js": "iTzPUSfTwTOP0zjeZHi8xNzmEg357fHuBQ4kHDlFqu4Svn5tZoseSm/XI9rscKnM5EudOAKhsJfck6Z0N3hTw3Ih3LAYlik6ltpI6P1hU0KP0j9L6bcrCndEoH/BZy7iaJiZqIvQHoRy7NHNf26Bbq6W4VO1bBcx8sH3H7GnaQEGHj2zS68KRTDwVR2QIErLTtOQvwuiSZCUwyZYilvDIM1wGcKi6TDzSz38MHNIyx4X/n7uHV63ToZSB6ipcF6HpoAKGkXKBWaXosqy3LoDPAzif5EZzv7JQGB2dAtpOoq2G5grUA5YZrIQ/SSNfREWUDom7Xj1HCNb59RxViOR+Q==" }, "publicKey": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0oZB2Kt7AzRFNqf8FuO3C3kepHPAIQYiDPYdQxHcsiaFCwyKVx6K1cE/3vBhb8/2rj+QIIWNfAAuu1Y+2VK90ZBeq6HciukWzQRO/HWhfdy0c7JwDAslmyGI5olj0ZQkNLhkde1MiMxjDPpRhZtdJaryVO5cFJaJESpv3dV6m0qXsaQCluWYOSNfSjP9C8o2zRVjSi3ZQZnZIV5pnk9K2MtlZIPXrN9iJiM5zZ9DTSnqApI6dC9mX4R3LvGN+GTovm9C8Crl+qb106nGRR3LcweicDnPyMtZLa/E0DBpWYxUVLDp6WeLhxoUBr+6+t3Xp9IDnPoANDQXJXD0f1vQxQIDAQAB", "desktop": true, diff --git a/docs/plugins/keewebhttp/plugin.js b/docs/plugins/keewebhttp/plugin.js index b9628f8..8e10a0b 100644 --- a/docs/plugins/keewebhttp/plugin.js +++ b/docs/plugins/keewebhttp/plugin.js @@ -1,7 +1,5 @@ -let server; -let uninstalled = false; - -setTimeout(run, 500); +let uninstall; +const timeout = setTimeout(run, 500); function run() { const nodeRequire = window.require; @@ -25,8 +23,30 @@ function run() { const keys = {}; const logger = new Logger('keewebhttp'); + let uninstalled; + let server; + + uninstall = function() { + uninstalled = true; + removeEventListeners(); + stopServer(); + }; + + addEventListeners(); startServer(); + function addEventListeners() { + AppModel.instance.files.on('add', fileOpened); + } + + function removeEventListeners() { + AppModel.instance.files.off('add', fileOpened); + } + + function fileOpened(e) { + console.log('file opened', e); + } + function startServer() { if (uninstalled) { return; @@ -78,6 +98,16 @@ function run() { server.conn = {}; } + function stopServer() { + if (server) { + server.close(); + for (const key of Object.keys(server.conn)) { + server.conn[key].destroy(); + } + server = null; + } + } + class RequestContext { constructor(postData) { this.postData = postData; @@ -171,13 +201,17 @@ function run() { } getKeyById() { - // TODO - return keys[this.req.Id]; + let key = keys[this.req.Id]; + if (!key) { + key = ''; // TODO: read key + keys[this.req.Id] = key; + } + return key; } saveKeyWithId() { keys[this.req.Id] = this.req.Key; - // TODO + // TODO: write key } verifyRequest() { @@ -236,8 +270,9 @@ function run() { electron.remote.app.getMainWindow().focus(); return new Promise((resolve, reject) => { Alerts.yesno({ + icon: 'plug', header: 'External Connection', - body: 'Some app is trying to connect to KeeWeb. If you are setting up your plugin, please allow the connection. Otherwise, click No.', + body: 'Some app is trying to manage passwords in KeeWeb. If you are setting up your plugin, please allow the connection. Otherwise, click No.', success: () => { resolve(); }, @@ -247,7 +282,7 @@ function run() { }); }).then(() => { this.req.Id = 'KeeWeb_' + new Date().toISOString() + '_' + crypto.randomBytes(16).toString('hex'); - logger.info('associate: ', this.req.Id); + logger.info(`associate: ${this.req.Id}`); this.saveKeyWithId(); this.createResponse(); return this.resp; @@ -296,9 +331,10 @@ function run() { this.createResponse(); const preset = GeneratorPresets.all.filter(p => p.default)[0] || GeneratorPresets.defaultPreset; const password = Generator.generate(preset); + const bits = Buffer.from(password, 'utf8').byteLength * 8; this.resp.Count = 1; this.resp.Entries = [{ - Login: '', + Login: this.encrypt(bits.toString()), Name: '', Password: this.encrypt(password), StringFields: null, @@ -309,12 +345,9 @@ function run() { } module.exports.uninstall = function() { - if (server) { - server.close(); - for (const key of Object.keys(server.conn)) { - server.conn[key].destroy(); - } - server = null; + if (uninstall) { + uninstall(); + } else { + clearTimeout(timeout); } - uninstalled = true; };