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

crx

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crx - npm Package Compare versions

Comparing version 0.2.9 to 0.4.0

6

bin/crx.js

@@ -47,4 +47,4 @@ #!/usr/bin/env node

path.exists(key, function(exists) {
if (exists) return cb && cb()
fs.exists(key, function(exists) {
if (exists) return cb && typeof(cb) == "function" && cb()

@@ -59,3 +59,3 @@ var pubPath = key + ".pub"

fs.unlink(pubPath)
cb && cb()
cb && typeof(cb) == "function" && cb()
})

@@ -62,0 +62,0 @@ })

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

"description": "Build Google Chrome extensions with node.js",
"version": "0.2.9",
"version": "0.4.0",
"homepage": "https://github.com/jed/crx",

@@ -17,3 +17,3 @@ "bin": {

"engines": {
"node": "~0.6.0"
"node": ">=0.7.12"
},

@@ -24,5 +24,8 @@ "scripts": {

"dependencies": {
"commander": ""
"commander": "",
"archiver": "0.4.x",
"wrench": "1.5.x",
"bufferstream": "0.5.x"
},
"devDependencies": {}
}

@@ -6,10 +6,9 @@ crx

crx is a [node.js](http://nodejs.org/) command line app for packing Google Chrome extensions.
crx is a [node.js](http://nodejs.org/) command line app for packing Google Chrome extensions. If you'd like to integrate it into your [grunt](http://gruntjs.com/) workflow, give [oncletom](https://github.com/oncletom)'s [grunt-crx](https://github.com/oncletom/grunt-crx) a spin.
## Requirements
* [node.js](http://nodejs.org/), tested with 0.4.12
* [node.js](http://nodejs.org/), tested with >= 0.7.12
* openssl
* ssh-keygen
* zip

@@ -48,6 +47,7 @@ ## Install

, ChromeExtension = require("crx")
, join = require("path").join
, crx = new ChromeExtension(
codebase: "http://localhost:8000/myFirstExtension.crx",
privateKey: fs.readFileSync(__dirname + "/key.pem"),
rootDirectory: __dirname + "/myFirstExtension"
privateKey: fs.readFileSync(join(__dirname, "key.pem")),
rootDirectory: join(__dirname, "myFirstExtension")
})

@@ -63,4 +63,4 @@

fs.writeFile(__dirname + "/update.xml", updateXML)
fs.writeFile(__dirname + "/myFirstExtension.crx", data)
fs.writeFile(join(__dirname, "update.xml"), updateXML)
fs.writeFile(join(__dirname, "myFirstExtension.crx"), data)

@@ -67,0 +67,0 @@ this.destroy()

var fs = require("fs")
, join = require("path").join
, sep = require("path").sep
, crypto = require("crypto")
, child = require("child_process")
, wrench = require("wrench")
, archiver = require("archiver")
, BufferStream = require("bufferstream")
, spawn = child.spawn

@@ -13,3 +17,3 @@ , exec = child.exec

this.path = join("/tmp", "crx-" + (Math.random() * 1e17).toString(36))
this.path = join("tmp", "crx-" + (Math.random() * 1e17).toString(36))
}

@@ -23,3 +27,3 @@

this.destroy = function() {
spawn("rm", ["-rf", this.path])
wrench.rmdirSyncRecursive(this.path)
}

@@ -53,6 +57,8 @@

this.load = function(cb) {
var child = spawn("cp", ["-R", this.rootDirectory, this.path])
child.on("exit", function() {
this.manifest = require(join(this.path, "manifest.json"))
if (!fs.existsSync("tmp")) {
fs.mkdirSync("tmp")
}
wrench.copyDirRecursive(this.rootDirectory, this.path, function(err) {
if (err) { throw err }
this.manifest = require(join(process.cwd(), this.path, "manifest.json"))
this.loaded = true

@@ -107,10 +113,25 @@

this.loadContents = function(cb) {
var command = "zip -qr -9 -X - . -x key.pem"
, options = {cwd: this.path, encoding: "binary", maxBuffer: this.maxBuffer}
var archive = archiver("zip")
this.contents = ""
exec(command, options, function(err, data) {
if (err) return cb.call(this, err)
archive.on("error", function(err) {
throw err
})
this.contents = new Buffer(data, "binary")
zipStream = new BufferStream({ size: "flexible" })
archive.pipe(zipStream)
files = wrench.readdirSyncRecursive(this.path)
for (var i = 0; i < files.length; i++) {
current = files[i]
stat = fs.statSync(join(this.path, current))
if (stat.isFile() && current !== "key.pem") {
archive.append(fs.createReadStream(join(this.path, current)), { name: current })
}
}
archive.finalize(function(err, written) {
if (err) return cb.call(this, err)
this.contents = zipStream.getBuffer()
cb.call(this)

@@ -117,0 +138,0 @@ }.bind(this))

var fs = require("fs")
, assert = require("assert")
, ChromeExtension = require("../")
, join = require("path").join
, crx = new ChromeExtension({
privateKey: fs.readFileSync(__dirname + "/key.pem"),
privateKey: fs.readFileSync(join(__dirname, "key.pem")),
codebase: "http://localhost:8000/myFirstExtension.crx",
rootDirectory: __dirname + "/myFirstExtension"
rootDirectory: join(__dirname, "myFirstExtension")
})

@@ -15,6 +16,6 @@

fs.writeFile(__dirname + "/update.xml", updateXML)
fs.writeFile(__dirname + "/myFirstExtension.crx", data)
fs.writeFile(join(__dirname, "update.xml"), updateXML)
fs.writeFile(join(__dirname, "myFirstExtension.crx"), data)
this.destroy()
})
{
"name": "My First Extension",
"manifest_version": 2,
"version": "1.0",

@@ -4,0 +5,0 @@ "description": "The first extension that I made.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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