0.0.29 • Published 3 years ago

@nodeauth/authentication v0.0.29

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Authentication

Install with

npm install @nodeauth/authentication

Setup

Need to create a plugin, a good resource to look at is (auth-pg)https://github.com/jackstine/auth-pg .

const { auth, createAuthentication } = require("@nodeauth/authentication");
let config = {
  plugin: {
    TemporaryPasswordRepo: TemporaryPasswordRepo(options),
    TokenRepo: TokenRepo(options),
    UserRepo: UserRepo(options),
    UserVerificationRepo: UserVerificationRepo(options),
    PasswordRepo: PasswordRepo(options),
  },
};
await createAuthentication(config);

Options

NameTypeDescription
googleClientIdStringthe Google Client ID so that you can authenticate Google Tokens
tempPasswordOptions.tempPasswordLifetimeNumber
keyStore.keyCountNumberThe key count, the number of keys that are used to verify a token, making the key expire in (keyCount * timeLimit) time
keyStore.timeLimitNumberThe time limit each key lasts

Plugin

Create a plugin using these methods and objects that comprise the plugin. Each signature of these methods have to be retained. All methods are Async and thus can return Promises. Each require the indicated parameters, and each requires a certian return value.

TemporaryPasswordRepo

  • insertNewUserIdAndPassword {email, newRandomPassword} - return {expiresIn, email, password}
  • selectTemporaryPasswordById {email} - return {created, password}
  • deleteAllOldTempPasswords {timesUpLimit} - returns null
  • deleteTempPassword {email} - returns null

TokenRepo

  • returnAllKeysFromRepo {()} - returns {key, created},...
  • deleteTheOldestKey {()} - returns null
  • insertNewKey {(key, created)} - returns {key, token}

UserRepo

  • getUserIsVerified {(email)} - returns {string, string}{email, verified}
  • verifyUser {(email)} - returns {verified, email}
  • createUser {(user)} - returns {Object} user
  • getUser {(user)} - returns {Object} user
  • updateUser {(user), token} - reutrns {Object} updatedUserInfo

UserVerificationRepo

  • getVerificationCode {(verification_code)} -- {verification_code, created}
  • createVerificationCode {(email, verification_code)} -- returns {email, verification_code}
  • deleteVerificationCode {(verification_code)} -- returns nothing

PasswordRepo

  • insertPassword {({email, password, key})} -- returns encryptedPassword
  • deletePasswordById {(email)} -- nothing returned
  • updatePasswordOnlyShouldBeUsedOnce {(email, password, key)} -- does not return anything
  • getPasswordForId {(email)} -- return {encryptedpassword, key}
0.0.28

3 years ago

0.0.29

3 years ago

0.0.27

3 years ago

0.0.26

3 years ago

0.0.24

3 years ago

0.0.25

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.20

3 years ago

0.0.21

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.9

3 years ago

0.0.16

3 years ago

0.0.8

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.1

3 years ago

1.0.0

3 years ago