# virgil-passwordless

> Passwordless auth utils using Virgil public keys service

Latest version **1.0.1** (published 2015-11-18) · BSD license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install virgil-passwordless
pnpm add virgil-passwordless
yarn add virgil-passwordless
bun add virgil-passwordless
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-11-18 |
| First published | 2015-11-18 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Virgil Security Inc. |
| Maintainers | virgilsecurity |
| Keywords | express, security, virgil, passwordless, crypto, encryption |

## Links

- npm: https://www.npmjs.com/package/virgil-passwordless
- Repository: https://github.com/VirgilSecurity/node-virgil-passwordless
- Homepage: https://github.com/VirgilSecurity/node-virgil-passwordless#readme
- Issues: https://github.com/VirgilSecurity/node-virgil-passwordless/issues
- npm.io page: https://npm.io/package/virgil-passwordless

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [virgil-crypto](https://npm.io/package/virgil-crypto.md) ^0.2.6
- [virgil-public-keys](https://npm.io/package/virgil-public-keys.md) ^0.2.6

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-11-18
- 1.0.0 — 2015-11-18

## README

## Passwordless auth for node applications

This module provides simple passwordless auth service using Virgil Public Keys infrastructure.

## Installation

```
npm install virgil-passwordless
```

## Usage

### Initialize service

```javascript
var VirgilPasswordless = require('virgil-passwordless');
var appToken = '1b79865e30978ec2ec9a83a44916b0a5';
var passwordless = new VirgilPasswordless(appToken);
```

### Generate encrypted auth handshake token for email

```javascript
var userEmail = 'user@example.com';
passwordless.generateToken(userEmail, function afterTokenGenerated (err, payload) {
	// payload = {
	//     encrypted_token: '91v2j39182jd39182jd1323c8j23c49...',
	//     public_key_id: 'vj32r-23e3ev-cece3-23gvc-423v'
	// }
});
```

#### What's inside

1. Using given email retrive public key from Virgil public keys service
2. Generate random token token and encrypt it using retrived public key
3. Store token in local storage (memory or custom storage passed to constructor)
4. Schedule token expiration (default timeout is 120 seconds)

#### Possible errors

Error                   | Code
------------------------|-------
Public key lookup error | 1
Storage set error       | 2

### Verify decrypted token retrieved from the client

```javascript
passwordless.verifyToken(userEmail, decryptedToken, function afterVerification (err) {
	// if err is null then verification was successfully passed
});
```

#### What's inside

1. Pick original token from storage
2. Compare origin token and `decryptedToken` passed to function
3. Remove token from storage (even in case if compare failure)

#### Possible errors

Error                 | Code
----------------------|-------
Storage get error     | 3
Token not found       | 4
Tokens not match      | 5
Storage unset error   | 6

## Custom store for tokens

You can use custom store for tokens

```javascript
new VirgilPasswordless(appToken, {
	store: customStore
});
```

Store should implement node-style callbacks based interface, example of implementation:

```javascript
var store = {
	cache: {},
	get: function get (key, cb) {
		cb(null, cache[key]);
	},
	set: function set (key, value, cb) {
		this.cache[key] = value;
		cb(null);
	},
	unset: function unset (key, cb) {
		delete this.cache[key];
		cb(null);
	}
};
```

## Token expire time

You can specify token expire time in ms

```javascript
new VirgilPasswordless(appToken, {
	expireTimeout: 60000 // ms
});
```

## License

BSD 3-Clause. See LICENSE for details.

## Contacts

Email: support@virgilsecurity.com

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