@accounts/common
Advanced tools
Comparing version 0.0.18 to 0.0.20
346
lib/index.js
@@ -1,333 +0,13 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(require("lodash"), require("babel-runtime/core-js/json/stringify"), require("babel-runtime/core-js/object/get-prototype-of"), require("babel-runtime/helpers/classCallCheck"), require("babel-runtime/helpers/createClass"), require("babel-runtime/helpers/possibleConstructorReturn"), require("babel-runtime/helpers/inherits")); | ||
else if(typeof define === 'function' && define.amd) | ||
define(["lodash", "babel-runtime/core-js/json/stringify", "babel-runtime/core-js/object/get-prototype-of", "babel-runtime/helpers/classCallCheck", "babel-runtime/helpers/createClass", "babel-runtime/helpers/possibleConstructorReturn", "babel-runtime/helpers/inherits"], factory); | ||
else if(typeof exports === 'object') | ||
exports["@accounts/common"] = factory(require("lodash"), require("babel-runtime/core-js/json/stringify"), require("babel-runtime/core-js/object/get-prototype-of"), require("babel-runtime/helpers/classCallCheck"), require("babel-runtime/helpers/createClass"), require("babel-runtime/helpers/possibleConstructorReturn"), require("babel-runtime/helpers/inherits")); | ||
else | ||
root["@accounts/common"] = factory(root["lodash"], root["babel-runtime/core-js/json/stringify"], root["babel-runtime/core-js/object/get-prototype-of"], root["babel-runtime/helpers/classCallCheck"], root["babel-runtime/helpers/createClass"], root["babel-runtime/helpers/possibleConstructorReturn"], root["babel-runtime/helpers/inherits"]); | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_5__, __WEBPACK_EXTERNAL_MODULE_6__, __WEBPACK_EXTERNAL_MODULE_7__, __WEBPACK_EXTERNAL_MODULE_8__, __WEBPACK_EXTERNAL_MODULE_9__, __WEBPACK_EXTERNAL_MODULE_10__) { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ }; | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.config = exports.toUsernameAndEmail = exports.AccountsError = exports.validators = exports.PasswordSignupFields = undefined; | ||
var _passwordSignupFields = __webpack_require__(1); | ||
var PasswordSignupFields = _interopRequireWildcard(_passwordSignupFields); | ||
var _validators = __webpack_require__(2); | ||
var validators = _interopRequireWildcard(_validators); | ||
var _errors = __webpack_require__(4); | ||
var _toUsernameAndEmail = __webpack_require__(11); | ||
var _toUsernameAndEmail2 = _interopRequireDefault(_toUsernameAndEmail); | ||
var _config = __webpack_require__(12); | ||
var _config2 = _interopRequireDefault(_config); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.PasswordSignupFields = PasswordSignupFields; | ||
exports.validators = validators; | ||
exports.AccountsError = _errors.AccountsError; | ||
exports.toUsernameAndEmail = _toUsernameAndEmail2.default; | ||
exports.config = _config2.default; | ||
/* eslint-disable import/no-named-as-default */ | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/* eslint-disable flowtype/no-types-missing-file-annotation */ | ||
var EMAIL_ONLY = exports.EMAIL_ONLY = 'EMAIL_ONLY'; | ||
var USERNAME_AND_EMAIL = exports.USERNAME_AND_EMAIL = 'USERNAME_AND_EMAIL'; | ||
var USERNAME_AND_OPTIONAL_EMAIL = exports.USERNAME_AND_OPTIONAL_EMAIL = 'USERNAME_AND_OPTIONAL_EMAIL'; | ||
var USERNAME_ONLY = exports.USERNAME_ONLY = 'USERNAME_ONLY'; | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.validateUsername = exports.validatePassword = exports.validateEmail = exports.isEmail = undefined; | ||
var _lodash = __webpack_require__(3); | ||
var isEmail = exports.isEmail = function isEmail(email) { | ||
// eslint-disable-next-line | ||
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | ||
return email && re.test(email); | ||
}; | ||
var validateEmail = exports.validateEmail = function validateEmail(email) { | ||
var isValid = !(0, _lodash.isEmpty)((0, _lodash.trim)(email || '')) && isEmail(email); | ||
return Boolean(isValid); | ||
}; | ||
var validatePassword = exports.validatePassword = function validatePassword(password) { | ||
var isValid = !(0, _lodash.isEmpty)(password); | ||
return isValid; | ||
}; | ||
var validateUsername = exports.validateUsername = function validateUsername(username) { | ||
var usernameRegex = /^[a-zA-Z][a-zA-Z0-9]*$/; | ||
var isValid = username && !(0, _lodash.isEmpty)((0, _lodash.trim)(username)) && usernameRegex.test(username); | ||
return Boolean(isValid); | ||
}; | ||
/***/ }), | ||
/* 3 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("lodash"); | ||
/***/ }), | ||
/* 4 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.AccountsError = undefined; | ||
var _stringify = __webpack_require__(5); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _getPrototypeOf = __webpack_require__(6); | ||
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); | ||
var _classCallCheck2 = __webpack_require__(7); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _createClass2 = __webpack_require__(8); | ||
var _createClass3 = _interopRequireDefault(_createClass2); | ||
var _possibleConstructorReturn2 = __webpack_require__(9); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = __webpack_require__(10); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// eslint-disable-next-line import/prefer-default-export | ||
var AccountsError = exports.AccountsError = function (_Error) { | ||
(0, _inherits3.default)(AccountsError, _Error); | ||
function AccountsError(message, loginInfo, errorCode) { | ||
(0, _classCallCheck3.default)(this, AccountsError); | ||
var _this = (0, _possibleConstructorReturn3.default)(this, (AccountsError.__proto__ || (0, _getPrototypeOf2.default)(AccountsError)).call(this, message)); | ||
_this.epochTime = Date.now(); | ||
if (loginInfo) { | ||
_this.loginInfo = loginInfo; | ||
} | ||
if (errorCode) { | ||
_this.errorCode = errorCode; | ||
} | ||
return _this; | ||
} | ||
(0, _createClass3.default)(AccountsError, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
try { | ||
return (0, _stringify2.default)({ | ||
message: this.message, | ||
loginInfo: this.loginInfo, | ||
errorCode: this.errorCode, | ||
epochTime: this.epochTime | ||
}); | ||
} catch (e) { | ||
return 'Error was thrown but could not be serialized. ' + 'Make sure there is no circular references parameters passed to constructor'; | ||
} | ||
} | ||
}, { | ||
key: 'serialize', | ||
value: function serialize() { | ||
return this.toString(); | ||
} | ||
}]); | ||
return AccountsError; | ||
}(Error); | ||
/***/ }), | ||
/* 5 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("babel-runtime/core-js/json/stringify"); | ||
/***/ }), | ||
/* 6 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("babel-runtime/core-js/object/get-prototype-of"); | ||
/***/ }), | ||
/* 7 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("babel-runtime/helpers/classCallCheck"); | ||
/***/ }), | ||
/* 8 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("babel-runtime/helpers/createClass"); | ||
/***/ }), | ||
/* 9 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("babel-runtime/helpers/possibleConstructorReturn"); | ||
/***/ }), | ||
/* 10 */ | ||
/***/ (function(module, exports) { | ||
module.exports = require("babel-runtime/helpers/inherits"); | ||
/***/ }), | ||
/* 11 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _validators = __webpack_require__(2); | ||
/** | ||
* Given a username, user and/or email figure out the username and/or email. | ||
* | ||
* @param {Object} An object containing at least `username`, `user` and/or `email`. | ||
* @returns {Object} An object containing `username` and `email`. | ||
*/ | ||
var toUsernameAndEmail = function toUsernameAndEmail(_ref) { | ||
var user = _ref.user, | ||
username = _ref.username, | ||
email = _ref.email, | ||
id = _ref.id; | ||
if (user && !username && !email) { | ||
if ((0, _validators.isEmail)(user)) { | ||
email = user; // eslint-disable-line no-param-reassign | ||
username = null; // eslint-disable-line no-param-reassign | ||
} else { | ||
username = user; // eslint-disable-line no-param-reassign | ||
email = null; // eslint-disable-line no-param-reassign | ||
} | ||
} | ||
return { username: username, email: email, id: id }; | ||
}; | ||
exports.default = toUsernameAndEmail; | ||
/***/ }), | ||
/* 12 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _passwordSignupFields = __webpack_require__(1); | ||
exports.default = { | ||
siteUrl: 'http://localhost:3000', | ||
sendVerificationEmail: false, | ||
sendEnrollmentEmail: false, | ||
sendWelcomeEmail: false, | ||
forbidClientAccountCreation: false, | ||
restrictCreationByEmailDomain: null, | ||
passwordResetTokenExpirationInDays: 3, | ||
passwordEnrollTokenExpirationInDays: 30, | ||
passwordSignupFields: _passwordSignupFields.EMAIL_ONLY, | ||
minimumPasswordLength: 7, | ||
path: '/accounts' | ||
}; | ||
/***/ }) | ||
/******/ ]) | ||
}); | ||
; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var validators = require("./validators"); | ||
exports.validators = validators; | ||
var errors_1 = require("./errors"); | ||
exports.AccountsError = errors_1.AccountsError; | ||
var to_username_and_email_1 = require("./to-username-and-email"); | ||
exports.toUsernameAndEmail = to_username_and_email_1.default; | ||
var config_1 = require("./config"); | ||
exports.config = config_1.default; | ||
var password_signup_fields_1 = require("./password-signup-fields"); | ||
exports.PasswordSignupFields = password_signup_fields_1.PasswordSignupFields; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@accounts/common", | ||
"version": "0.0.18", | ||
"version": "0.0.20", | ||
"description": "Fullstack authentication and accounts-management", | ||
"main": "lib/index.js", | ||
"jsnext:main": "lib-es6/index.js", | ||
"typings": "lib/index.d.ts", | ||
"publishConfig": { | ||
@@ -11,9 +11,6 @@ "access": "public" | ||
"scripts": { | ||
"start": "webpack -p --config --progress --watch", | ||
"clean": "rimraf lib lib-es6", | ||
"start": "tsc --watch", | ||
"clean": "rimraf lib", | ||
"precompile": "npm run clean", | ||
"compile": "npm run compile:es6 && npm run compile:umd", | ||
"compile:es6": "babel ./src --out-dir ./lib-es6", | ||
"compile:umd": "webpack", | ||
"postcompile": "npm run flow:prepublish", | ||
"compile": "tsc", | ||
"prepublish": "npm run compile", | ||
@@ -23,16 +20,18 @@ "test": "npm run testonly", | ||
"testonly": "jest", | ||
"flow:check": "flow check", | ||
"flow:gen": "flow gen-flow-files ./src/index.js > ./lib/index.js.flow", | ||
"flow:prepublish": "npm run flow:cplib && npm run flow:cplibes6", | ||
"flow:cplib": "for i in `ls ./src/*.js`; do cp $i `echo $i | sed \"s/src/lib/g\" | sed \"s/js/js\\.flow/g\"`; done", | ||
"flow:cplibes6": "for i in `ls ./src/*.js`; do cp $i `echo $i | sed \"s/src/lib-es6/g\" | sed \"s/js/js\\.flow/g\"`; done", | ||
"coverage": "npm run testonly -- --coverage", | ||
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" | ||
}, | ||
"files": [ | ||
"lib" | ||
], | ||
"jest": { | ||
"testEnvironment": "node", | ||
"testRegex": "(/.*.(test|spec)).(js|jsx)$", | ||
"testPathDirs": [ | ||
"src" | ||
] | ||
"transform": { | ||
".(ts|tsx)": "<rootDir>/../../node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"js" | ||
], | ||
"mapCoverage": true | ||
}, | ||
@@ -56,23 +55,6 @@ "repository": { | ||
"devDependencies": { | ||
"babel-cli": "^6.18.0", | ||
"babel-core": "^6.18.0", | ||
"babel-loader": "^6.2.7", | ||
"babel-plugin-syntax-async-functions": "^6.13.0", | ||
"babel-plugin-transform-async-to-generator": "^6.16.0", | ||
"babel-plugin-transform-builtin-extend": "^1.1.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.21.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.16.0", | ||
"babel-plugin-transform-regenerator": "^6.16.1", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-preset-es2015-node4": "^2.1.0", | ||
"babel-preset-stage-0": "^6.22.0", | ||
"coveralls": "^2.11.14", | ||
"flow-bin": "0.41.0", | ||
"jest": "^18.0.0", | ||
"localstorage-polyfill": "^1.0.1", | ||
"regenerator-runtime": "^0.9.6", | ||
"rimraf": "^2.6.1", | ||
"webpack": "^1.13.3", | ||
"webpack-node-externals": "^1.5.4" | ||
"rimraf": "^2.6.1" | ||
}, | ||
@@ -79,0 +61,0 @@ "dependencies": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
4
13775
22
234
1