New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

larvituser

Package Overview
Dependencies
Maintainers
6
Versions
268
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

larvituser - npm Package Compare versions

Comparing version 0.19.1 to 0.20.1

dist/dataWriter.d.ts

39

package.json
{
"name": "larvituser",
"version": "0.19.1",
"version": "0.20.1",
"author": {

@@ -11,18 +11,30 @@ "name": "Mikael 'Lilleman' Göransson",

"dependencies": {
"async": "^2.6.1",
"bcryptjs": "^2.4.3",
"larvitamintercom": "^0.3.0",
"larvitamsync": "^0.7.0",
"larvitdbmigration": "^4.0.1",
"larvitutils": "^2.0.0",
"uuid": "^3.3.2"
"bcryptjs": "2.4.3",
"larvitdbmigration": "6.0.0",
"larvitutils": "5.0.0",
"uuid": "8.3.2"
},
"description": "User module for node.js",
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@types/bcryptjs": "2.4.2",
"@types/mocha": "9.0.0",
"@types/node": "17.0.8",
"@types/uuid": "8.3.4",
"@typescript-eslint/eslint-plugin": "5.9.1",
"@typescript-eslint/parser": "5.9.1",
"eslint": "8.6.0",
"freeport": "1.0.5",
"mocha": "6.2.2",
"mocha-eslint": "5.0.0"
"larvitdb": "3.2.0",
"mocha": "9.1.3",
"mocha-eslint": "7.0.0",
"nyc": "15.1.0",
"ts-node": "10.4.0",
"typescript": "4.5.4"
},
"scripts": {
"test": "mocha --exit"
"build": "rm -rf dist/* && tsc",
"lint": "eslint src/*.ts test/*.ts",
"test": "npm run lint && npm run test:unit",
"test:unit": "nyc mocha --exit --bail -r ts-node/register 'test/**/*.ts'"
},

@@ -33,3 +45,6 @@ "keywords": [

],
"main": "index.js",
"main": "dist/index.js",
"files": [
"/dist"
],
"repository": {

@@ -36,0 +51,0 @@ "url": "https://github.com/larvit/larvituser",

@@ -12,13 +12,11 @@ [![Build Status](https://travis-ci.org/larvit/larvituser.svg?branch=master)](https://travis-ci.org/larvit/larvituser) [![Dependencies](https://david-dm.org/larvit/larvituser.svg)](https://david-dm.org/larvit/larvituser.svg)

```javascript
const UserLib = require('larvituser'),
Intercom = require('larvitamintercom'),
winston = require('winston'),
log = winston.createLogger({'transports': [new winston.transports.Console()]}),
const UserLib = require('larvituser'),
Intercom = require('larvitamintercom'),
winston = require('winston'),
log = winston.createLogger({'transports': [new winston.transports.Console()]}),
userLib = new UserLib({
'db': require('larvitdb'),
'db': require('larvitdb'),
// Optional parameters
'mode': 'noSync', // Other options are "master" or "slave"
'intercom': new Intercom({'conStr': 'loopback interface', 'log': log}),
'log': log
'log': log
});

@@ -33,4 +31,4 @@

const userData = {
'firstname': 'Nisse',
'lastname': 'Nilsson',
'firstname': 'Nisse',
'lastname': 'Nilsson',
'role': [

@@ -42,5 +40,4 @@ 'user',

userLib.create('myUsername', 'myPassword', userData, function (err, user) {
console.log('New user UUID: ' + user.uuid);
});
const user = await userLib.create('myUsername', 'myPassword', userData);
console.log('New user UUID: ' + user.uuid);
```

@@ -52,7 +49,7 @@

const uuidLib = require('uuid');
const uuidLib = require('uuid');
const uuid = uuidLib.v1();
const userData = {
'firstname': 'Nisse',
'lastname': 'Nilsson',
'firstname': 'Nisse',
'lastname': 'Nilsson',
'role': [

@@ -63,6 +60,4 @@ 'user',

}
userLib.create('myUsername', 'myPassword', userData, uuid, function (err, user) {
console.log('New user UUID: ' + user.uuid);
});
const user = await userLib.create('myUsername', 'myPassword', userData, uuid);
console.log('New user UUID: ' + user.uuid);
```

@@ -73,13 +68,8 @@

```javascript
userLib.fromUserAndPass('myUsername', 'myPassword', function (err, user) {
if (err) {
throw err;
}
if ( ! user) {
// No match found, or other more serious error
} else {
console.log('Fetched user ID: ' + user.id);
}
});
const user = await userLib.fromUserAndPass('myUsername', 'myPassword');
if ( ! user) {
// No match found, or other more serious error
} else {
console.log('Fetched user ID: ' + user.id);
}
```

@@ -90,9 +80,6 @@

```javascript
const users = new UserLib.Users({'db': db, 'log': log});
const users = new UserLib.Users({'db': db, 'log': log});
users.get(function (err, userList) {
if (err) throw err;
console.log(userList); // An array of objects
});
const result = await users.get();
console.log(result.users); // An array of objects
```

@@ -103,9 +90,6 @@

```javascript
const users = new UserLib.Users({'db': db, 'log': log});
const users = new UserLib.Users({'db': db, 'log': log});
users.getFieldData('fieldName', function (err, result) {
if (err) throw err;
console.log(userList); // An array of strings
});
const result = await users.getFieldData('fieldName');
console.log(result); // An array of strings
```

@@ -116,3 +100,3 @@

```javascript
const users = new UserLib.Users({'db': db, 'log': log});
const users = new UserLib.Users({'db': db, 'log': log});

@@ -124,7 +108,4 @@ users.order = {

users.get(function (err, userList) {
if (err) throw err;
console.log(userList); // An array of objects
});
const result = await users.get();
console.log(result.users); // An array of objects
```

@@ -137,5 +118,3 @@

```javascript
userLib.addUserDataField(userUuid, fieldName, fieldValue, function (err) {
// Field have been added
});
await userLib.addUserDataField(userUuid, fieldName, fieldValue);
```

@@ -146,5 +125,3 @@

```javascript
userLib.checkPassword('passwordToTest', 'theHashToTestAgainst', function (err, result) {
// Result being either true or false
});
const isValid = await userLib.checkPassword('passwordToTest', 'theHashToTestAgainst');
```

@@ -155,5 +132,3 @@

```javascript
userLib.create('username', 'password', {'firstname': 'John', 'lastname': 'Smith'}, function (err, user) {
console.log(user.uuid); // 91f15599-c1fa-4051-9e0e-906cab9819fe (or rather, a random Uuid)
});
const user = await userLib.create('username', 'password', {'firstname': 'John', 'lastname': 'Smith'});console.log(user.uuid); // 91f15599-c1fa-4051-9e0e-906cab9819fe (or rather, a random Uuid)
```

@@ -164,5 +139,4 @@

```javascript
userLib.create('username', 'password', {'firstname': 'John', 'lastname': 'Smith'}, 'f9684592-b245-42fa-88c6-9f16b9236ac3', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
const user = await userLib.create('username', 'password', {'firstname': 'John', 'lastname': 'Smith'}, 'f9684592-b245-42fa-88c6-9f16b9236ac3');
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
```

@@ -175,5 +149,4 @@

```javascript
userLib.fromField('firstname', 'John', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
const user = await userLib.fromField('firstname', 'John');
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
```

@@ -186,5 +159,4 @@

```javascript
userLib.fromFields({'firstname': 'John', 'lastname': 'Smith'}, function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
const user = await userLib.fromFields({'firstname': 'John', 'lastname': 'Smith'});
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
```

@@ -195,5 +167,4 @@

```javascript
userLib.fromUsername('username', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3 or user will be false if no user is found
});
const user = await userLib.fromUsername('username');
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3 or user will be false if no user is found
```

@@ -204,5 +175,4 @@

```javascript
userLib.fromUuid('f9684592-b245-42fa-88c6-9f16b9236ac3', function (err, user) {
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
});
const user = await userLib.fromUuid('f9684592-b245-42fa-88c6-9f16b9236ac3');
console.log(user.uuid); // f9684592-b245-42fa-88c6-9f16b9236ac3
```

@@ -213,5 +183,4 @@

```javascript
userLib.getFieldData('f9684592-b245-42fa-88c6-9f16b9236ac3', 'firstname', function (err, data) {
console.log(data); // ['John'] - Observe this will always be an array with values, since a field can hold several values
});
const data = await userLib.getFieldData('f9684592-b245-42fa-88c6-9f16b9236ac3', 'firstname');
console.log(data); // ['John'] - Observe this will always be an array with values, since a field can hold several values
```

@@ -224,10 +193,8 @@

```javascript
userLib.replaceUserFields('f9684592-b245-42fa-88c6-9f16b9236ac3', {'lastname': ['Smith', 'Johnsson']}, function (err) {
// The field "lastname" will now be replaced with the two values "Smith" and "Johnsson"
// And all other fields will be removed
await userLib.replaceUserFields('f9684592-b245-42fa-88c6-9f16b9236ac3', {'lastname': ['Smith', 'Johnsson']});
// The field "lastname" will now be replaced with the two values "Smith" and "Johnsson"
// And all other fields will be removed
userLib.getFieldData('f9684592-b245-42fa-88c6-9f16b9236ac3', 'lastname', function (err, data) {
console.log(data); // ['Smith', 'Johnsson']
});
});
const data = await userLib.getFieldData('f9684592-b245-42fa-88c6-9f16b9236ac3', 'lastname');
console.log(data); // ['Smith', 'Johnsson']
```

@@ -238,7 +205,5 @@

```javascript
userLib.rmUserField('f9684592-b245-42fa-88c6-9f16b9236ac3', 'lastname', function (err) {
userLib.fromUuid('f9684592-b245-42fa-88c6-9f16b9236ac3', function (err, user) {
console.log(user.fields); // {'firstname': ['John']}
});
});
await userLib.rmUserField('f9684592-b245-42fa-88c6-9f16b9236ac3', 'lastname');
const user = await userLib.fromUuid('f9684592-b245-42fa-88c6-9f16b9236ac3');
console.log(user.fields); // {'firstname': ['John']}
```

@@ -249,5 +214,3 @@

```javascript
userLib.setPassword('f9684592-b245-42fa-88c6-9f16b9236ac3', 'newSuperSecretPwd', function (err) {
// Now the users password is updated to "newSuperSecretPwd"
});
await userLib.setPassword('f9684592-b245-42fa-88c6-9f16b9236ac3', 'newSuperSecretPwd');
```

@@ -258,5 +221,3 @@

```javascript
userLib.setPassword('f9684592-b245-42fa-88c6-9f16b9236ac3', false, function (err) {
// This user can no longer login
});
await userLib.setPassword('f9684592-b245-42fa-88c6-9f16b9236ac3', false);
```

@@ -267,10 +228,24 @@

```javascript
userLib.setUsername('f9684592-b245-42fa-88c6-9f16b9236ac3', 'theNewUsername', function (err) {
// Now the users username is updated to "theNewUsername"
});
await userLib.setUsername('f9684592-b245-42fa-88c6-9f16b9236ac3', 'theNewUsername');
```
### Errors
All functions in the API will throw an exception upon error.
For instance:
```javascript
const user1 = await userLib.create('nisse', false);
const user2 = await userLib.create('olle', false);
try {
await user2.setUsername('nisse'); // Will throw since username "nisse" is already taken
} catch (err) {
console.error(err);
}
```
## Tests
Run tests with mocha, make sure to have an empty database configured for tests to pass correctly!
Run tests with ```npm test```, make sure to have an empty database configured for tests to pass correctly!

@@ -282,3 +257,3 @@ The default config file will be _application path_/config/db_test.json

```bash
mocha test/test.js /path/to/config/db_another.json
DBCONFFILE=/path/to/config/db_another.json mocha test/test.js
```
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