-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support CRX Package Format #118
Comments
Providing support in the streaming version is easy, please see a quick implementation here: 48428ba You can check it out by installing: The |
Thanks! I was specifically looking to use |
Yes absolutely. You could do something like: // with `buffer` as the buffered data
var signature = buffer.readUInt32LE(0);
if (signature === 0x34327243) {
const baseHeaderLength = 4*4;
var h = binary.parse(buffer)
.word32lu('signature')
.word32lu('version')
.word32lu('pubKeyLength')
.word32lu('signatureLength')
.vars;
buffer = buffer.slice(baseHeaderLength + h.pubKeyLength + h.signatureLength);
}
var directory = await unzipper.Open.buffer(buffer); I added this check to the |
Awesome, can confirm it working: const unzipper = require("unzipper");
const fetch = require("make-fetch-happen");
async function main() {
const id = "hlepfoohegkhhmjieoechaddaejaokhf";
const res = await fetch(`https://clients2.google.com/service/update2/crx?response=redirect&prodversion=74.0&x=id%3D${id}%26installsource%3Dondemand%26uc`);
const buffer = await res.buffer();
const dir = await unzipper.Open.buffer(buffer);
console.log(dir.files.map(file => file.path));
}
main(); In case you're wondering about my use case: I'm pulling CSS files out of released chrome extensions, see here. Once your patch is released, I can drop two dependencies and do it all in-memory. :) |
Chrome extensions in CRX format are zips but with a special header that makes them incompatible with unzipper. Attempting to extract a CRX file like this one results in a
FILE_ENDED
error.Details on the format are here, would be great if support for this format could be added.
There is the unzip-crx module which handles the format, but I'm looking for something that can do in-memory extraction, like unzipper. I guess the function that strips this header could be easily ported to unzipper.
The text was updated successfully, but these errors were encountered: