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

@ridi/comic-parser

Package Overview
Dependencies
Maintainers
12
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ridi/comic-parser - npm Package Compare versions

Comparing version 0.3.0-alpha.3 to 0.3.0-alpha.4

30

lib/ComicParser.js

@@ -244,16 +244,13 @@ 'use strict';

(0, _parserCore.validateOptions)(options, ComicParser.parseOptionTypes);
if (this.cryptoProvider) {
this.cryptoProvider.status = _parserCore.CryptoProvider.Status.PARSE;
}
context = new _Context2.default();
context.options = (0, _parserCore.mergeObjects)(ComicParser.parseDefaultOptions, options);
_context2.next = 6;
_context2.next = 5;
return (0, _parserCore.readEntries)(this.input, this.cryptoProvider);
case 6:
case 5:
context.entries = _context2.sent;
return _context2.abrupt('return', context);
case 8:
case 7:
case 'end':

@@ -365,19 +362,16 @@ return _context2.stop();

if (!(!(0, _parserCore.isString)(entries.source) && (0, _parserCore.isExists)(unzipPath))) {
_context5.next = 7;
_context5.next = 6;
break;
}
if (this.cryptoProvider) {
this.cryptoProvider.status = _parserCore.CryptoProvider.Status.UNZIP;
}
_context5.next = 6;
_context5.next = 5;
return entries.source.extractAll(unzipPath, overwrite);
case 6:
case 5:
privateProps.set(this, (0, _extends3.default)({}, privateProps.get(this), { input: unzipPath }));
case 7:
case 6:
return _context5.abrupt('return', context);
case 8:
case 7:
case 'end':

@@ -549,6 +543,2 @@ return _context5.stop();

entries = _context8.sent;
if (this.cryptoProvider) {
this.cryptoProvider.status = _parserCore.CryptoProvider.Status.READ;
}
return _context8.abrupt('return', {

@@ -560,3 +550,3 @@ items: items,

case 8:
case 7:
case 'end':

@@ -621,3 +611,3 @@ return _context8.stop();

if (options.base64) {
results.push(file.toString('base64'));
results.push('data:' + item.mimeType + ';base64,' + file.toString('base64'));
} else {

@@ -624,0 +614,0 @@ results.push(file);

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -7,13 +7,38 @@ Object.defineProperty(exports, "__esModule", {

var _freeze = require("babel-runtime/core-js/object/freeze");
var _freeze = require('babel-runtime/core-js/object/freeze');
var _freeze2 = _interopRequireDefault(_freeze);
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _path = require('path');
var _path2 = _interopRequireDefault(_path);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Item = function () {
(0, _createClass3.default)(Item, [{
key: 'mimeType',
get: function get() {
var ext = _path2.default.extname(this.path).toLocaleLowerCase().replace('.', '');
switch (ext) {
case 'jpg':
case 'jpeg':
case 'png':
case 'bmp':
case 'gif':
return 'image/' + ext;
default:
return '';
}
}
}]);
function Item() {

@@ -20,0 +45,0 @@ var rawObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

{
"name": "@ridi/comic-parser",
"version": "0.3.0-alpha.3",
"version": "0.3.0-alpha.4",
"description": "Common comic data parser for Ridibooks services",

@@ -21,3 +21,3 @@ "author": {

"dependencies": {
"@ridi/parser-core": "^0.3.0-alpha.3",
"@ridi/parser-core": "^0.3.0-alpha.4",
"fs-extra": "^7.0.1",

@@ -24,0 +24,0 @@ "natural-orderby": "^1.0.2"

@@ -53,3 +53,3 @@ # @ridi/comic-parser

const { Status } = CryptoProvider;
const { Purpose } = CryptoProvider;
const { Modes, Padding } = Cryptor;

@@ -60,26 +60,37 @@

super();
this.cryptor = new Cryptor(Modes.ECB, { key, padding: Padding.PKCS7 });
this.cryptor = new Cryptor(Modes.ECB, { key });
}
// Encrypt all content when unzipping and decrypt it when read.
run(data, filePath) {
if (this.status === Status.UNZIP) {
return this.encrypt(data);
} else if (this.status === Status.READ) {
return Buffer.from(this.decrypt(data));
getCryptor(filePath, purpose) {
return this.cryptor;
}
// If use as follows:
// const provider = new ContentCryptoProvider(...);
// const parser = new ComicParser('encrypted.zip', provider);
// const book = await parser.parse({ unzipPath: ... });
// const firstImage = await parser.readItem(book.items[0]);
//
// It will be called as follows:
// 1. run(data, 'encrypted.zip', Purpose.READ_IN_DIR)
// 2. run(data, '0001.jpg', Purpose.READ_IN_ZIP)
// ...
// 4. run(data, '0001.jpg', Purpose.WRITE)
// ...
// 5. run(data, '0001.jpg', Purpose.READ_IN_DIR)
//
run(data, filePath, purpose) {
const cryptor = this.getCryptor(filePath, purpose);
const padding = Padding.AUTO;
if (purpose === Purpose.READ_IN_DIR) {
return cryptor.decrypt(data, padding);
} else if (purpose === Purpose.WRITE) {
return cryptor.encrypt(data, padding);
}
return data;
}
encrypt(data, filePath) {
return this.cryptor.encrypt(data);
}
decrypt(data, filePath) {
return this.cryptor.decrypt(data);
}
}
const cryptoProvider = new ContentCryptoProvider(key);
const parser = new ComicParser('./foo/bar.zip' or './unzippedPath', cryptoProvider);
const parser = new ComicParser('./encrypted.zip' or './unzippedPath', cryptoProvider);
```

@@ -86,0 +97,0 @@

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