yaml-crypt
Advanced tools
Comparing version 0.7.3 to 0.7.4
@@ -544,3 +544,3 @@ #!/usr/bin/env node | ||
let arg; | ||
if (key.includes(":")) { | ||
if (key.includes(":") && !key.match(/^[A-Z]:\\/)) { | ||
const idx = key.indexOf(":"); | ||
@@ -769,3 +769,9 @@ prefix = key.substring(0, idx); | ||
const tmpFile = tmp.fileSync({ tmpdir: dir, postfix: ".yaml", keep: true }); | ||
const tmpFile = tmp.fileSync({ | ||
tmpdir: dir, | ||
postfix: ".yaml", | ||
keep: true, | ||
discardDescriptor: true | ||
}); | ||
try { | ||
@@ -779,4 +785,3 @@ const opts = { base64: args.base64, algorithm: algorithm, raw: args.raw }; | ||
fs.writeSync(tmpFile.fd, str); | ||
fs.closeSync(tmpFile.fd); | ||
fs.writeFileSync(tmpFile.name, str); | ||
@@ -792,4 +797,8 @@ childProcess.spawnSync(editor, [tmpFile.name], { stdio: "inherit" }); | ||
} finally { | ||
if (fs.existsSync(tmpFile.name)) { | ||
fs.unlinkSync(tmpFile.name); | ||
try { | ||
tmpFile.removeCallback(); | ||
} finally { | ||
if (fs.existsSync(tmpFile.name)) { | ||
fs.unlinkSync(tmpFile.name); | ||
} | ||
} | ||
@@ -796,0 +805,0 @@ } |
@@ -72,3 +72,10 @@ const { homedir } = require("os"); | ||
const normalizedEncryptionKey = normalizeKey(encryptionKey); | ||
return createYamlcrypt(normalizedKeys, normalizedEncryptionKey); | ||
return createYamlcrypt( | ||
normalizedKeys, | ||
normalizedEncryptionKey == null | ||
? normalizedKeys.length === 1 | ||
? normalizedKeys[0] | ||
: null | ||
: normalizedEncryptionKey | ||
); | ||
} | ||
@@ -241,3 +248,3 @@ | ||
} | ||
return new yaml.Schema(types); | ||
return yaml.DEFAULT_SCHEMA.extend(types); | ||
} | ||
@@ -329,3 +336,3 @@ | ||
const schema = new yaml.Schema(types); | ||
const schema = yaml.DEFAULT_SCHEMA.extend(types); | ||
const decrypted = dumpAll(docs, { schema: schema }); | ||
@@ -332,0 +339,0 @@ |
{ | ||
"name": "yaml-crypt", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "Encrypt and decrypt YAML documents", | ||
@@ -29,3 +29,3 @@ "license": "MIT", | ||
"fernet": "^0.3.1", | ||
"js-yaml": "^4.0.0", | ||
"js-yaml": "^4.1.0", | ||
"pkginfo": "^0.4.1", | ||
@@ -36,6 +36,6 @@ "tmp": "^0.2.1", | ||
"devDependencies": { | ||
"chai": "^4.3.0", | ||
"chai": "^4.3.4", | ||
"coveralls": "^3.1.0", | ||
"eslint": "^7.20.0", | ||
"mocha": "^8.3.0", | ||
"eslint": "^7.25.0", | ||
"mocha": "^8.3.2", | ||
"nyc": "^15.1.0", | ||
@@ -42,0 +42,0 @@ "prettier": "^2.2.1" |
@@ -383,3 +383,6 @@ const fs = require("fs"); | ||
const input = tmp.fileSync({ postfix: ".yaml-crypt" }); | ||
const input = tmp.fileSync({ | ||
postfix: ".yaml-crypt", | ||
discardDescriptor: true | ||
}); | ||
fs.copyFileSync("./test/resources/test-2.yaml-crypt", input.name); | ||
@@ -386,0 +389,0 @@ |
@@ -25,4 +25,4 @@ const mocha = require("mocha"); | ||
walk("./test", true, callback); | ||
expect(files).to.have.lengthOf(15); | ||
expect(files).to.have.lengthOf(16); | ||
}); | ||
}); |
@@ -10,2 +10,3 @@ const fs = require("fs"); | ||
const tmp = require("tmp"); | ||
const { dump } = require("js-yaml"); | ||
@@ -184,2 +185,9 @@ const { loadFile, loadConfig, yamlcrypt } = require("../lib/yaml-crypt"); | ||
it("should correctly parse primitive types", () => { | ||
const yaml = yamlcrypt({ keys: "aehae5Ui0Eechaeghau9Yoh9jufiep7H" }); | ||
const content = fs.readFileSync("./test/resources/test-8.yaml", "utf8"); | ||
const transformed = dump(yaml.decrypt(content)); | ||
expect(transformed).to.equal(content); | ||
}); | ||
it("should throw an error when an invalid key is given", () => { | ||
@@ -186,0 +194,0 @@ expect(() => yamlcrypt({ keys: 0 })).to.throw( |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79129
2219
Updatedjs-yaml@^4.1.0