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

@live-change/password-authentication-service

Package Overview
Dependencies
Maintainers
1
Versions
217
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@live-change/password-authentication-service - npm Package Compare versions

Comparing version 0.2.7 to 0.2.12

73

index.js

@@ -1,10 +0,14 @@

const autoValidation = require('@live-change/framework/lib/processors/autoValidation')
const nodemailer = require('nodemailer')
const crypto = require('crypto')
const app = require("@live-change/framework").app()
const user = require('@live-change/user-service')
const { AuthenticatedUser } = require("../user-service/model.js")
const definition = app.createServiceDefinition({
name: "passwordAuthentication"
name: "passwordAuthentication",
use: [ user ]
})
const config = definition.config
const User = definition.foreignModel('user', 'User')
const secretProperties = {

@@ -20,2 +24,65 @@ passwordHash: {

const PasswordAuthentication = definition.model({
name: 'PasswordAuthentication',
userProperty: {
userViews: [
{ suffix: 'Exists', fields: ['user'] }
]
},
properties: {
...secretProperties,
}
})
definition.event({
name: 'passwordAuthenticationSet',
async execute({ user, passwordHash }) {
await PasswordAuthentication.create({ id: user, user, passwordHash })
}
})
definition.action({
name: 'setPassword',
waitForEvents: true,
properties: {
...secretProperties
},
access: (params, { client }) => {
return !!client.user
},
async execute({ passwordHash }, { client, service }, emit) {
const user = client.user
const passwordAuthenticationData = await PasswordAuthentication.get(user)
if(passwordAuthenticationData) throw 'exists'
emit({
type: 'passwordAuthenticationSet',
user, passwordHash
})
}
})
definition.action({
name: 'changePassword',
waitForEvents: true,
properties: {
currentPasswordHash: secretProperties.passwordHash,
...secretProperties
},
access: (params, { client }) => {
return !!client.user
},
async execute({ currentPasswordHash, passwordHash }, { client, service }, emit) {
const user = client.user
const passwordAuthenticationData = await PasswordAuthentication.get(user)
if(!passwordAuthenticationData) throw 'notFound'
if(currentPasswordHash != passwordAuthenticationData.passwordHash) throw { properties: {
currentPasswordHash: 'wrongPassword'
} }
emit({
type: 'passwordAuthenticationSet',
user, passwordHash
})
}
})
for(const contactType of config.contactTypes) {

@@ -22,0 +89,0 @@ const contactTypeUpperCaseName = contactType[0].toUpperCase() + contactType.slice(1)

4

package.json
{
"name": "@live-change/password-authentication-service",
"version": "0.2.7",
"version": "0.2.12",
"description": "",

@@ -27,3 +27,3 @@ "main": "index.js",

},
"gitHead": "f864cf2344e08f5678d1c2171f7ce594066b2ed8"
"gitHead": "a0dce761d803684a74e4cf4d50c63a0dc80dd4cf"
}
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