credify-crypto
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -342,48 +342,38 @@ import { Crypto } from '@peculiar/webcrypto'; | ||
if (password === void 0) { password = undefined; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var decomposed; | ||
return __generator(this, function (_a) { | ||
if (!this._privateKey) { | ||
throw new Error("private key is not instantiated."); | ||
} | ||
decomposed = { | ||
format: 'pkcs8-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
seed: this._privateKey.slice(0, 32), | ||
}, | ||
}; | ||
if (password) { | ||
// @ts-ignore | ||
decomposed["encryptionAlgorithm"] = { | ||
keyDerivationFunc: { | ||
id: 'pbkdf2', | ||
iterationCount: 10000, | ||
keyLength: 32, | ||
prf: 'hmac-with-sha256' // The pseudo-random function | ||
}, | ||
encryptionScheme: 'aes256-cbc', | ||
}; | ||
} | ||
return [2 /*return*/, composePrivateKey(decomposed, { password: password }).replace(/\n$/, "")]; | ||
}); | ||
}); | ||
if (!this._privateKey) { | ||
throw new Error("private key is not instantiated."); | ||
} | ||
var decomposed = { | ||
format: 'pkcs8-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
seed: this._privateKey.slice(0, 32), | ||
}, | ||
}; | ||
if (password) { | ||
// @ts-ignore | ||
decomposed["encryptionAlgorithm"] = { | ||
keyDerivationFunc: { | ||
id: 'pbkdf2', | ||
iterationCount: 10000, | ||
keyLength: 32, | ||
prf: 'hmac-with-sha256' // The pseudo-random function | ||
}, | ||
encryptionScheme: 'aes256-cbc', | ||
}; | ||
} | ||
return composePrivateKey(decomposed, { password: password }).replace(/\n$/, ""); | ||
}; | ||
Signing.prototype.exportPublicKey = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var decomposed; | ||
return __generator(this, function (_a) { | ||
if (!this._publicKey) { | ||
throw new Error("public key is not instantiated."); | ||
} | ||
decomposed = { | ||
format: 'spki-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
bytes: this._publicKey, | ||
}, | ||
}; | ||
return [2 /*return*/, composePublicKey(decomposed).replace(/\n$/, "")]; | ||
}); | ||
}); | ||
if (!this._publicKey) { | ||
throw new Error("public key is not instantiated."); | ||
} | ||
var decomposed = { | ||
format: 'spki-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
bytes: this._publicKey, | ||
}, | ||
}; | ||
return composePublicKey(decomposed).replace(/\n$/, ""); | ||
}; | ||
@@ -390,0 +380,0 @@ return Signing; |
@@ -346,48 +346,38 @@ 'use strict'; | ||
if (password === void 0) { password = undefined; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var decomposed; | ||
return __generator(this, function (_a) { | ||
if (!this._privateKey) { | ||
throw new Error("private key is not instantiated."); | ||
} | ||
decomposed = { | ||
format: 'pkcs8-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
seed: this._privateKey.slice(0, 32), | ||
}, | ||
}; | ||
if (password) { | ||
// @ts-ignore | ||
decomposed["encryptionAlgorithm"] = { | ||
keyDerivationFunc: { | ||
id: 'pbkdf2', | ||
iterationCount: 10000, | ||
keyLength: 32, | ||
prf: 'hmac-with-sha256' // The pseudo-random function | ||
}, | ||
encryptionScheme: 'aes256-cbc', | ||
}; | ||
} | ||
return [2 /*return*/, cryptoKeyComposer.composePrivateKey(decomposed, { password: password }).replace(/\n$/, "")]; | ||
}); | ||
}); | ||
if (!this._privateKey) { | ||
throw new Error("private key is not instantiated."); | ||
} | ||
var decomposed = { | ||
format: 'pkcs8-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
seed: this._privateKey.slice(0, 32), | ||
}, | ||
}; | ||
if (password) { | ||
// @ts-ignore | ||
decomposed["encryptionAlgorithm"] = { | ||
keyDerivationFunc: { | ||
id: 'pbkdf2', | ||
iterationCount: 10000, | ||
keyLength: 32, | ||
prf: 'hmac-with-sha256' // The pseudo-random function | ||
}, | ||
encryptionScheme: 'aes256-cbc', | ||
}; | ||
} | ||
return cryptoKeyComposer.composePrivateKey(decomposed, { password: password }).replace(/\n$/, ""); | ||
}; | ||
Signing.prototype.exportPublicKey = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var decomposed; | ||
return __generator(this, function (_a) { | ||
if (!this._publicKey) { | ||
throw new Error("public key is not instantiated."); | ||
} | ||
decomposed = { | ||
format: 'spki-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
bytes: this._publicKey, | ||
}, | ||
}; | ||
return [2 /*return*/, cryptoKeyComposer.composePublicKey(decomposed).replace(/\n$/, "")]; | ||
}); | ||
}); | ||
if (!this._publicKey) { | ||
throw new Error("public key is not instantiated."); | ||
} | ||
var decomposed = { | ||
format: 'spki-pem', | ||
keyAlgorithm: { id: 'ed25519' }, | ||
keyData: { | ||
bytes: this._publicKey, | ||
}, | ||
}; | ||
return cryptoKeyComposer.composePublicKey(decomposed).replace(/\n$/, ""); | ||
}; | ||
@@ -394,0 +384,0 @@ return Signing; |
@@ -12,5 +12,5 @@ /// <reference types="node" /> | ||
verifyString(message: string, signature: string): boolean; | ||
exportPrivateKey(password?: string | undefined): Promise<string>; | ||
exportPublicKey(): Promise<string>; | ||
exportPrivateKey(password?: string | undefined): string; | ||
exportPublicKey(): string; | ||
} | ||
export default Signing; |
{ | ||
"name": "credify-crypto", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Credify cryptographic related helpers in JavaScript", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
14
41063