thom4parisot / crx

A node.js command line app for packing Google Chrome extensions.
https://npmjs.com/crx
MIT License
516 stars 71 forks source link

Cannot .pack() extension because of 'Error: It is not public key' #48

Closed se-panfilov closed 9 years ago

se-panfilov commented 9 years ago

Hi, thanks for crx.

I'm trying to make simple gulp-crx extension. But i'm run into an issue with "rsa publick key" and cannot figure out what I'm doing wrong:

        var crx = new ChromeExtension();

        crx.load(file.path).then(function () {
            return crx.loadContents();
        }, showError).then(function (archiveBuffer) {
            fs.writeFile(path.join(file.path, 'extension.zip'), archiveBuffer);
            return crx.pack(archiveBuffer);
        }, showError).then(function (crxBuffer) {
            fs.writeFile(path.join(file.path, 'extension.crx'), crxBuffer);
        }, showError)

Whatever I'm trying, after crx.pack(archiveBuffer); i've got an error:

{ [Error: Error: It is not public key]
  name: 'Error',
  message: 'Error: It is not public key',
  stack: 'Error: Error: It is not public key\n    at /work/gulp-crx-pkg/node_modules/crx/src/crx.js:83:13\n    at lib$es6$promise$$internal$$tryCatch (/work/gulp-crx-pkg/node_modules/crx/node_modules/es6-promise/dist/es6-promise.js:331:16)\n    at lib$es6$promise$$internal$$invokeCallback (/work/gulp-crx-pkg/node_modules/crx/node_modules/es6-promise/dist/es6-promise.js:343:17)\n    at /work/gulp-crx-pkg/node_modules/crx/node_modules/es6-promise/dist/es6-promise.js:891:13\n    at Object.lib$es6$promise$asap$$flush [as _onImmediate] (/work/gulp-crx-pkg/node_modules/crx/node_modules/es6-promise/dist/es6-promise.js:125:9)\n    at processImmediate [as _immediateCallback] (timers.js:363:15)',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-crx-pkg' }

Btw: ubuntu 14.04 x64, node v0.10.40, crx v3.0.3. And chrome browser can build up a test extension

PavelVanecek commented 9 years ago

You are supposed to either: a) include a key.pem private key file in the root extension directory, or b) pass the private key text as a parameter

See the usage section in docs: https://github.com/oncletom/crx#module-example

See the code that handles it: https://github.com/oncletom/crx/blob/e946117d8994655a294757ae07b07ef58fe6f8a4/bin/crx.js#L93

Side note: feel free to use an already finished https://github.com/PavelVanecek/gulp-crx :)

se-panfilov commented 9 years ago

Oh, thanks a lot. )

P.S. I think it's be a good idea to includ ref to gulp-crx in to the docs. Thanks anyway