Skip to content

Commit 4745dd9

Browse files
authored
Merge pull request #59 from Ansimorph/standalone
Remove node-cipher dependency
2 parents 6ea2a68 + ae50c70 commit 4745dd9

16 files changed

+624
-657
lines changed

.github/workflows/nodejs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
node-version: [10.x, 12.x]
12+
node-version: [10.x, 12.x, 14.x]
1313

1414
steps:
1515
- uses: actions/checkout@v1
@@ -20,6 +20,7 @@ jobs:
2020
- name: npm install, build, and test
2121
run: |
2222
npm ci
23-
npm test
23+
npm run build
24+
npm run test
2425
env:
2526
CI: true

.npmignore

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
{
3+
"printWidth": 80
4+
}

cli.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
const {main} = require("./dist/cli");
3+
main();

index.js

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,6 @@
1-
const crypto = require("crypto");
2-
const loaderUtils = require("loader-utils");
3-
const validateOptions = require("schema-utils");
4-
const schema = require("./options-schema.json");
1+
var loader = require('./dist');
52

6-
const defaultOptions = {
7-
algorithm: "cast5-cbc",
8-
salt: "nodecipher",
9-
digest: "sha1",
10-
iterations: 1000,
11-
keylen: 512,
12-
};
13-
14-
module.exports = function decrypt(ciphertext) {
15-
// Result can be cached
16-
if (this.cacheable) this.cacheable();
17-
18-
// Get and validate options
19-
const options = Object.assign(
20-
{},
21-
defaultOptions,
22-
loaderUtils.getOptions(this),
23-
);
24-
25-
validateOptions(schema, options, "Decryption Loader");
26-
27-
// Derive Key from password
28-
const key = crypto.pbkdf2Sync(
29-
options.password,
30-
options.salt,
31-
options.iterations,
32-
options.keylen,
33-
options.digest,
34-
);
35-
36-
// Run Decryption
37-
const decipher = crypto.createDecipher(
38-
options.algorithm,
39-
key.toString("hex"),
40-
);
41-
42-
return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
43-
};
3+
module.exports = loader;
444

455
// This loader works on buffers
46-
module.exports.raw = true;
6+
module.exports.raw = true;

options-schema.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)