Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chrome-app-api-proxy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chrome-app-api-proxy - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

3

chrome-app/background.js

@@ -15,5 +15,4 @@ 'use strict';

minHeight: APP_HEIGHT
},
alwaysOnTop: true
}
});
});
'use strict';
chrome.runtime.onConnectExternal.addListener(function(port) {
(function() {
var state = document.querySelector('#state');
state.innerHTML = 'Connected';
var port;
chrome.runtime.onConnectExternal.addListener(function(_port) {
port = _port;
state.innerHTML = 'Connected';
port.onMessage.addListener(function(message) {
var callId = message.callId;
var params = message.params;
if (!params) {
params = [];
}
params.push(function(data) {
port.postMessage({ callId: callId, data: data });
});
// Convert Array to ArrayBuffer.
if (message.call === 'chrome.serial.send') {
params[1] = new Uint8Array(params[1]).buffer;
}
var call = window;
var objects = message.call.split('.');
objects.forEach(function(object) {
call = call[object];
});
call instanceof Function && call.apply(null, params);
});
port.onDisconnect.addListener(function() {
state.innerHTML = 'Disconnected';
});
});
// Send serialport data to the Webpage.
// The listener only can be registered once,
// or it will be triggered multiple times.
chrome.serial.onReceive.addListener(function(info) {
info.data = toHexString(info.data);
port.postMessage({ type: 'serial', info: info });
});
port.onMessage.addListener(function(message) {
var callId = message.callId;
var params = message.params;
if (!params) {
params = [];
function toHexString(arrayBuffer) {
var string = '';
var uint8Array = new Uint8Array(arrayBuffer);
for (var i = 0; i < uint8Array.length; i++) {
var hex = uint8Array[i].toString(16);
if (hex.length == 1) {
string += '0';
}
string += hex;
}
return string;
}
params.push(function(data) {
port.postMessage({ callId: callId, data: data });
});
// Convert Array to ArrayBuffer.
if (message.call === 'chrome.serial.send') {
params[1] = new Uint8Array(params[1]).buffer;
}
var call = window;
var objects = message.call.split('.');
objects.forEach(function(object) {
call = call[object];
});
call instanceof Function && call.apply(null, params);
});
function toHexString(arrayBuffer) {
var string = '';
var uint8Array = new Uint8Array(arrayBuffer);
for (var i = 0; i < uint8Array.length; i++) {
var hex = uint8Array[i].toString(16);
if (hex.length == 1) {
string += '0';
}
string += hex;
}
return string;
}
});
}());

@@ -5,3 +5,3 @@ {

"description": "Call Chrome App APIs from a Webpage.",
"version": "0.0.1",
"version": "0.0.3",
"app": {

@@ -8,0 +8,0 @@ "background": {

/* global ChromeApiProxy */
'use strict';
var extensionId = 'mncdajaedfblonbkmodofckdialkolgk';
var extensionId = 'dacgaojeadgpmpmbfoibmncggacokdjd';
var proxy = new ChromeApiProxy(extensionId);

@@ -6,0 +6,0 @@

{
"name": "chrome-app-api-proxy",
"version": "0.0.2",
"version": "0.0.3",
"homepage": "https://github.com/evanxd/chrome-api-proxy",

@@ -5,0 +5,0 @@ "authors": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc