Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/transitive-bullshit/parse-otp-message
Parses OTP messages for a verification code and service provider.
https://github.com/transitive-bullshit/parse-otp-message
2-factor activation authentication code otp pin sms verification
Last synced: 14 days ago
JSON representation
Parses OTP messages for a verification code and service provider.
- Host: GitHub
- URL: https://github.com/transitive-bullshit/parse-otp-message
- Owner: transitive-bullshit
- Created: 2018-05-06T20:05:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-30T07:49:46.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T00:53:48.479Z (6 months ago)
- Topics: 2-factor, activation, authentication, code, otp, pin, sms, verification
- Language: JavaScript
- Homepage:
- Size: 812 KB
- Stars: 23
- Watchers: 5
- Forks: 7
- Open Issues: 10
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# parse-otp-message
> Parses OTP messages for a verification code and service provider.
[![NPM](https://img.shields.io/npm/v/parse-otp-message.svg)](https://www.npmjs.com/package/parse-otp-message) [![Build Status](https://travis-ci.com/transitive-bullshit/parse-otp-message.svg?branch=master)](https://travis-ci.com/transitive-bullshit/parse-otp-message) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
- handles hundreds of known services (wechat, google, facebook, whatsapp, uber, twitter, etc...)
- thorough test suite
- meant for parsing automated sms messages## Install
```bash
npm install --save parse-otp-message
```## Usage
```js
const parse = require('parse-otp-message')const result = parse('Use 5677 as Microsoft account security code')
// result.code = '5677
// result.service = 'microsoft'
```See the [test suite](https://github.com/transitive-bullshit/parse-otp-message/tree/master/test/index.js) for more examples of the types of messages this module can parse.
## API
### parse(message)
Returns: `Object`
Parses the given message and returns an object containing two fields, `code` and `service`. The auth `code` will be all digits except in some special cases, and the returned `service` will always be lowercase.
If no code or service is found, `undefined` is returned.
#### message
Type: `String`
**Required**SMS or email message possibly containing an auth code and/or service provider details.
## License
MIT © [Travis Fischer](https://github.com/transitive-bullshit)
Support my OSS work by following me on twitter