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

node-mpw

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-mpw - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

yarn.lock

4

.vscode/settings.json

@@ -5,2 +5,6 @@ {

"editor.renderWhitespace": "boundary",
"editor.rulers": [
80,
140
],
"files.encoding": "utf8",

@@ -7,0 +11,0 @@ "files.trimTrailingWhitespace": true,

10

dist/index.js

@@ -17,3 +17,3 @@ "use strict";

*/
exports.generateKey = function (name, password, version, namespace) {
function generateKey(name, password, version, namespace) {
if (version === void 0) { version = constants.MP_ALGORITHM_VERSION; }

@@ -36,3 +36,4 @@ if (namespace === void 0) { namespace = constants.NAMESPACE; }

return scrypt.hashSync(password, constants.SCRYPT_PARAMS, 64, buf);
};
}
exports.generateKey = generateKey;
/**

@@ -50,3 +51,3 @@ * Encode a site password using the site's type template.

*/
exports.generatePassword = function (site, key, counter, template, version, namespace) {
function generatePassword(site, key, counter, template, version, namespace) {
if (counter === void 0) { counter = 1; }

@@ -66,2 +67,3 @@ if (template === void 0) { template = 'long'; }

return helpers_1.computeTemplate(templates_1.templates, templates_1.templateChars, template, seed);
};
}
exports.generatePassword = generatePassword;

@@ -11,8 +11,8 @@ "use strict";

* @param {Buffer} key An `scrypt`-hashed key generated from the `generateKey()` function.
* @param {number} [counter] An integer that can be incremented when the user needs a new password for the site.
* @param {number} [version] The algorithm version being used for this process.
* @param {string} [namespace] The namespace used as a salt to calculate the seed.
* @param {number} [counter=1] An integer that can be incremented when the user needs a new password for the site.
* @param {number} [version=constants.MP_ALGORITHM_VERSION] The algorithm version being used for this process.
* @param {string} [namespace=constants.NAMESPACE] The namespace used as a salt to calculate the seed.
* @returns {Buffer} the template seed.
*/
exports.generateSeed = function (site, key, counter, version, namespace) {
function generateSeed(site, key, counter, version, namespace) {
if (counter === void 0) { counter = 1; }

@@ -38,3 +38,4 @@ if (version === void 0) { version = constants.MP_ALGORITHM_VERSION; }

return crypto.createHmac('sha256', key).update(buf).digest();
};
}
exports.generateSeed = generateSeed;
/**

@@ -47,3 +48,3 @@ * Converts a Buffer into network byte order.

*/
exports.toNetworkByte = function (buffer) {
function toNetworkByte(buffer) {
var uint = new Uint16Array(buffer.length);

@@ -57,3 +58,4 @@ // Convert seed to network byte order.

return uint;
};
}
exports.toNetworkByte = toNetworkByte;
/**

@@ -63,4 +65,4 @@ * Determines the template to use based on the template seed, and computes the final password.

* @export
* @param {Object} templates An Object containing a list of the available templates.
* @param {Object} templateChars An Object containing a list of password characters.
* @param {{ [key: string]: any }} templates An Object containing a list of the available templates.
* @param {{ [key: string]: any }} templateChars An Object containing a list of password characters.
* @param {string} template The desired template.

@@ -70,3 +72,3 @@ * @param {(Buffer | Uint16Array)} seed The template seed generated from the `generateSeed()` function.

*/
exports.computeTemplate = function (templates, templateChars, template, seed) {
function computeTemplate(templates, templateChars, template, seed) {
// Find the selected template array and select a specific template based

@@ -81,2 +83,3 @@ // on `seed[0]`

}).join('');
};
}
exports.computeTemplate = computeTemplate;

@@ -5,4 +5,2 @@ // Type definitions for node-mpw

export as namespace mpw
/**

@@ -9,0 +7,0 @@ * Calculate the master key from a user's name and master password.

{
"name": "node-mpw",
"version": "0.1.2",
"version": "0.2.0",
"description": "Implementation of Master Password for nodejs and browser",

@@ -9,2 +9,3 @@ "main": "./dist/index.js",

"build": "rimraf ./dist && tsc",
"commit": "git-cz",
"prepublish": "npm run build",

@@ -32,2 +33,4 @@ "test": "npm run build && mocha",

"chai": "^3.5.0",
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^3.16.1",

@@ -45,3 +48,8 @@ "eslint-config-airbnb-base": "^11.1.0",

"scrypt": "^6.0.3"
},
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
}
}

@@ -77,10 +77,26 @@ # node-mpw

We use a few emojis as an identifier on what the commits are. The following commit naming scheme is loosely based on the [Commitizen](https://commitizen.github.io/cz-cli/) commit naming conventions. Feel free to use this standard as well.
Our commit logs are [Commitizen-friendly](https://commitizen.github.io/cz-cli/). With Commitizen, the header of every commit message has to include a `type`, an optional `scope` and a `subject` with the following format:
- :bulb: (bulb): Working on new features
- :bug: (bug): Bug squashing
- :memo: (memo): Working on documentation
- :dash: (dash): Code style cleanup / linting / dusting / etc.
- :construction: (construction): Large refactors or rewrites
- :wrench: (wrench): Adding missing tests
- :arrow_up: (arrow_up): Version bumps
```
<type>(<scope>): <subject>
```
You can use one of the following methods to use Commitizen.
**Option 1:** Install Commitizen by running `npm install -g commitizen`, and run `git cz` instead of `git commit` when you want to commit. Follow the instructions on the next screen.
**Option 2:** When you run `npm install` the core `commitizen` library is also saved as `devDependencies`. You can simply run `npm run commit` instead of `git commit` to enable Commitizen. Follow the instructions on the next screen.
**Option 3:** Manually typing the commits altogether. We use the following Commitizen tags.
- feat: A new feature
- fix: A bug fix
- docs: Documentation only changes
- style: Changes that do not affect the meaning on the code (white-space, formatting, missing semi-colons, etc)
- refactor: A code change that neither fixes a bug or adds a feature
- perf: A code change that improves performance
- test: Adding missing tests
- build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
- ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
- chore: Changes to the build process or auxiliary tools and libraries such as documentation generation
- revert: Reverts a previous commit

@@ -17,3 +17,3 @@ import * as scrypt from 'scrypt'

*/
export const generateKey = (
export function generateKey (
name: string,

@@ -23,3 +23,3 @@ password: string,

namespace: string = constants.NAMESPACE
): Buffer => {
): Buffer {
// Cache name length for older versions of MPW.

@@ -58,3 +58,3 @@ // https://github.com/tmthrgd/mpw-js/blob/master/mpw.js#L36-L38

*/
export const generatePassword = (
export function generatePassword (
site: string,

@@ -66,3 +66,3 @@ key: Buffer,

namespace: string = constants.NAMESPACE
): string => {
): string {
// Keep a reference of the `seed` variable.

@@ -69,0 +69,0 @@ let seed: Buffer | Uint16Array

@@ -10,8 +10,8 @@ import * as crypto from 'crypto'

* @param {Buffer} key An `scrypt`-hashed key generated from the `generateKey()` function.
* @param {number} [counter] An integer that can be incremented when the user needs a new password for the site.
* @param {number} [version] The algorithm version being used for this process.
* @param {string} [namespace] The namespace used as a salt to calculate the seed.
* @param {number} [counter=1] An integer that can be incremented when the user needs a new password for the site.
* @param {number} [version=constants.MP_ALGORITHM_VERSION] The algorithm version being used for this process.
* @param {string} [namespace=constants.NAMESPACE] The namespace used as a salt to calculate the seed.
* @returns {Buffer} the template seed.
*/
export const generateSeed = (
export function generateSeed (
site: string,

@@ -22,3 +22,3 @@ key: Buffer,

namespace: string = constants.NAMESPACE
): Buffer => {
): Buffer {
// Cache site length for older versions of MPW.

@@ -54,3 +54,3 @@ // https://github.com/tmthrgd/mpw-js/blob/master/mpw.js#L36-L38

*/
export const toNetworkByte = (buffer: Buffer): Uint16Array => {
export function toNetworkByte (buffer: Buffer): Uint16Array {
let uint = new Uint16Array(buffer.length)

@@ -72,4 +72,4 @@

* @export
* @param {Object} templates An Object containing a list of the available templates.
* @param {Object} templateChars An Object containing a list of password characters.
* @param {{ [key: string]: any }} templates An Object containing a list of the available templates.
* @param {{ [key: string]: any }} templateChars An Object containing a list of password characters.
* @param {string} template The desired template.

@@ -79,8 +79,8 @@ * @param {(Buffer | Uint16Array)} seed The template seed generated from the `generateSeed()` function.

*/
export const computeTemplate = (
templates: Object,
templateChars: Object,
export function computeTemplate (
templates: { [key: string]: any },
templateChars: { [key: string]: any },
template: string,
seed: Buffer | Uint16Array
): string => {
): string {
// Find the selected template array and select a specific template based

@@ -91,3 +91,3 @@ // on `seed[0]`

return templateCompute.split('').map((c, i) => {
return templateCompute.split('').map((c: string, i: number) => {
let chars: string = templateChars[c]

@@ -94,0 +94,0 @@

@@ -5,3 +5,3 @@ {

"target": "es5",
"noImplicitAny": false,
"noImplicitAny": true,
"outDir": "dist",

@@ -8,0 +8,0 @@ "sourceMap": false,

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