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

zipster

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zipster - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

3

lib/enums/Formats.d.ts

@@ -5,6 +5,7 @@ /**

declare enum Formats {
TAR = "tar",
ZIP = "zip",
ZIP_ENCRYPTABLE = "zip-encryptable"
ZIP_ENCRYPTED = "zip-encryptable"
}
export { Formats };
//# sourceMappingURL=Formats.d.ts.map

@@ -8,6 +8,7 @@ "use strict";

(function (Formats) {
Formats["TAR"] = "tar";
Formats["ZIP"] = "zip";
Formats["ZIP_ENCRYPTABLE"] = "zip-encryptable";
Formats["ZIP_ENCRYPTED"] = "zip-encryptable";
})(Formats || (Formats = {}));
exports.Formats = Formats;
//# sourceMappingURL=Formats.js.map
/**
* Zipper Error is the generic error for the Zipper library
* Zipster Error is the generic error for the Zipster library
*/

@@ -4,0 +4,0 @@ declare class ZipsterError extends Error {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Zipper Error is the generic error for the Zipper library
* Zipster Error is the generic error for the Zipster library
*/

@@ -6,0 +6,0 @@ class ZipsterError extends Error {

@@ -30,6 +30,6 @@ "use strict";

} }, rest);
if (options.format === Formats_1.Formats.ZIP) {
if (options.format === Formats_1.Formats.ZIP || options.format === Formats_1.Formats.TAR) {
return archiver_1.create(options.format, archiverOptions);
}
if (options.format === Formats_1.Formats.ZIP_ENCRYPTABLE) {
if (options.format === Formats_1.Formats.ZIP_ENCRYPTED) {
this.registerZipEncryptable();

@@ -41,4 +41,4 @@ return archiver_1.create(options.format, archiverOptions);

static registerZipEncryptable() {
if (!archiver_1.isRegisteredFormat(Formats_1.Formats.ZIP_ENCRYPTABLE)) {
archiver_1.registerFormat(Formats_1.Formats.ZIP_ENCRYPTABLE, archiverZipEncryptable);
if (!archiver_1.isRegisteredFormat(Formats_1.Formats.ZIP_ENCRYPTED)) {
archiver_1.registerFormat(Formats_1.Formats.ZIP_ENCRYPTED, archiverZipEncryptable);
}

@@ -45,0 +45,0 @@ }

import { Options } from './types/Options';
/**
* Zipper facilitates the zipping and protecting of data
* Zipster facilitates the zipping and protecting of data
*/

@@ -5,0 +5,0 @@ declare class Zipster {

@@ -6,2 +6,3 @@ "use strict";

const uuid = require("uuid");
const Formats_1 = require("./enums/Formats");
const FileParts_1 = require("./libs/FileParts");

@@ -11,3 +12,3 @@ const ZipsterError_1 = require("./errors/ZipsterError");

/**
* Zipper facilitates the zipping and protecting of data
* Zipster facilitates the zipping and protecting of data
*/

@@ -122,5 +123,11 @@ class Zipster {

var _a, _b, _c, _d;
const extensionMap = {
[Formats_1.Formats.TAR]: 'tar',
[Formats_1.Formats.ZIP]: 'zip',
[Formats_1.Formats.ZIP_ENCRYPTED]: 'zip'
};
const extension = extensionMap[options.format];
const outputName = (_b = (_a = options.output) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : uuid.v4();
const outputDirectory = (_d = (_c = options.output) === null || _c === void 0 ? void 0 : _c.path) !== null && _d !== void 0 ? _d : os.tmpdir();
return `${outputDirectory}/${outputName}.zip`;
return `${outputDirectory}/${outputName}.${extension}`;
}

@@ -127,0 +134,0 @@ }

{
"name": "zipster",
"version": "2.0.0",
"version": "2.1.0",
"description": "TypeScript library built for Node backends to create ZIP files with password protection",

@@ -23,3 +23,6 @@ "main": "lib/index.js",

"compress",
"bulk"
"bulk",
"pattern",
"directory",
"promises"
],

@@ -61,3 +64,3 @@ "files": [

"mocha": "9.1.3",
"nyc": "^15.1.0",
"nyc": "15.1.0",
"sinon": "12.0.1",

@@ -64,0 +67,0 @@ "sinon-chai": "3.7.0",

@@ -9,7 +9,8 @@ # Zipster

Zipster aims to enable developers to easily create password-protected ZIP files. This library relies on a combination of
other libraries to function correctly as well as built-in Node functionality.
Zipster aims to enable developers to rapidly and easily create password-protected ZIP files. With various handy
functions available to satisfy different use-cases, this promise-based library is built using TypeScript and uses native
Node functionality and leverages two primary libraries.
Although the core behind Zipster is password-protected ZIP files, you can also create passwordless ZIP files and pass in
a number of different options to configure how your ZIP files are created.
Although the fundamental principle behind Zipster is password-protected ZIP files, you can also create unprotected ZIP
files and pass in a number of different options to configure how your ZIP files are created.

@@ -27,4 +28,6 @@ **This project is still in development. Please report any bugs or feature requests as an

- [Create a ZIP from a directory](#fromdirectorypath-string-options-options)
- [Create a ZIP with a pattern](#frompatternpath-string-pattern-string-options-options)
- [Options](#options)
- [Password Example](#password-example)
- [Supported Formats](#supported-formats)
- [Tests](#running-tests)

@@ -37,3 +40,3 @@ - [Issues](#issues)

This is how to get a copy of this working locally. The only requirement is that Node is installed on the base machine.
You can get started with cloning the Zipster repository by using the following command:

@@ -48,3 +51,3 @@ ```bash

Use the following command to install the Zipster:
Use the following command to install the Zipster package:

@@ -57,8 +60,10 @@ ```

You can create a ZIP file containing a single file or multiple files, set a password or not and configure how you want
the ZIP to be created.
There are various ways in which you can create your ZIP file and even more options on how you want it configured. You
can set a password or not, compress or not, specify patterns to match for zipping files, etc.
Here are some examples of how to use the functionality provided by this package:
#### .fromPath(path: string, options: Options)
Create ZIP file containing a single file
Create an unprotected ZIP file containing a single specified file

@@ -78,3 +83,3 @@ ```typescript

Create ZIP file containing multiple files
Create an unprotected ZIP file containing multiple specified files

@@ -97,3 +102,3 @@ ```typescript

Creates a ZIP file containing all the sub-directories at a given path, retaining the folder structure of the
Create an unprotected ZIP file containing all the sub-directories at a given path, retaining the folder structure of the
sub-directories

@@ -114,3 +119,3 @@

Creates a ZIP file containing all the files matching the given pattern at the given path
Create an unprotected ZIP file containing all the files matching the given pattern at the given path

@@ -140,3 +145,3 @@ ```typescript

Create a password-protected ZIP file
Create a password-protected ZIP file containing the specified file

@@ -155,2 +160,7 @@ ```typescript

#### Supported Formats
There are currently only two formats that are supported, the `.zip` and `.tar` formats. The `zip` format is the only
format which supports password protection. The password format is specifically available through the `Formats` enum.
## Tests

@@ -157,0 +167,0 @@

@@ -43,3 +43,3 @@ import * as archiver from 'archiver'

{
descriptor: 'returns archiver without password',
descriptor: 'returns ZIP archiver without password',
options: {

@@ -55,5 +55,16 @@ format: Formats.ZIP

{
descriptor: 'returns archiver with a password',
descriptor: 'returns TAR archiver without password',
options: {
format: Formats.ZIP_ENCRYPTABLE,
format: Formats.TAR
} as Options,
assertions: () => {
create.should.have.been.calledOnceWithExactly(Formats.TAR, defaultArchiverOptions)
registerFormat.should.have.callCount(0)
isRegisteredFormat.should.have.callCount(0)
}
},
{
descriptor: 'returns ZIP archiver with a password configured and registers the formatter',
options: {
format: Formats.ZIP_ENCRYPTED,
password: 'Foo'

@@ -66,14 +77,14 @@ } as Options,

assertions: () => {
create.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTABLE, {
create.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTED, {
...defaultArchiverOptions,
password: 'Foo'
})
registerFormat.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTABLE, archiverZipEncryptable)
isRegisteredFormat.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTABLE)
registerFormat.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTED, archiverZipEncryptable)
isRegisteredFormat.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTED)
}
},
{
descriptor: 'returns archiver with a password and does not re-register formatter',
descriptor: 'returns archiver with a password configured and does not re-register formatter',
options: {
format: Formats.ZIP_ENCRYPTABLE,
format: Formats.ZIP_ENCRYPTED,
password: 'Foo'

@@ -86,3 +97,3 @@ } as Options,

assertions: () => {
create.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTABLE, {
create.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTED, {
...defaultArchiverOptions,

@@ -92,3 +103,3 @@ password: 'Foo'

registerFormat.should.have.callCount(0)
isRegisteredFormat.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTABLE)
isRegisteredFormat.should.have.been.calledOnceWithExactly(Formats.ZIP_ENCRYPTED)
}

@@ -95,0 +106,0 @@ }

@@ -257,3 +257,3 @@ import * as fs from 'fs'

const options: Options = {
format: Formats.ZIP_ENCRYPTABLE,
format: Formats.ZIP_ENCRYPTED,
password: 'testing',

@@ -260,0 +260,0 @@ output: {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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