# cf-password-reset-token

> Generate and validate password reset tokens

Latest version **0.0.2** (published 2017-08-08) · 0 weekly downloads

## Install

```sh
npm install cf-password-reset-token
pnpm add cf-password-reset-token
yarn add cf-password-reset-token
bun add cf-password-reset-token
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2017-08-08 |
| First published | 2017-08-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ben Gourley |
| Maintainers | asheboy |

## Links

- npm: https://www.npmjs.com/package/cf-password-reset-token
- Repository: https://github.com/clocklimited/cf-password-reset-token
- Homepage: https://github.com/clocklimited/cf-password-reset-token#readme
- Issues: https://github.com/clocklimited/cf-password-reset-token/issues
- npm.io page: https://npm.io/package/cf-password-reset-token

## Recent versions

- 0.0.2 (latest) — 2017-08-08

## README

# cf-password-reset-token

Generate and validate password reset tokens

## Installation

    npm install --save cf-password-reset-token

## Usage

```js
var passwordResetToken = require('cf-password-reset-token')

// Generate a token for an authable entity (i.e one that can authorize
// themself with the system – e.g. administrator, user, customer)
passwordResetToken.generate(authableEntity)
//-> { token: '...', expiry: '...'}

// Check that a password reset token is valid for a given authable entity
passwordResetToken.validate(authableEntity, token)
//-> true or false
```

## API

### var t = require('cf-password-reset-token')

### t.generate(Object: authableEntity, Object: options)

`authableEntity` must have the following properties: `created` and `password`, along
with an identity property that be configured with `options.identityProperty`. This
defaults to `'emailAddress'`. `options.expiry` can be used to configure how long the
token is valid for. The default is 1 hour.

### t.validate(Object: authableEntity, Object: token)

`authableEntity` is the entity that token should be validated against. This function
will return `true` if **both** of the following conditions are met:

- `token.token` is a valid token
- `token.expiry` is not in the past
- Certain properties of `authableEntity` are the same as when the token was created:
`created`, `password` and its `identityProperty`

## Credits
Built by developers at [Clock](http://clock.co.uk).

## Licence
Licensed under the [New BSD License](http://opensource.org/licenses/bsd-license.php)

---
_Source: https://npm.io/package/cf-password-reset-token · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
