-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,205 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export enum GenericErrors { | ||
LOW_BALANCE = 'low-balance', | ||
UNAUTHORIZED = 'unauthorized', | ||
FORBIDDEN = 'forbidden', | ||
NOT_FOUND = 'not-found', | ||
UNPROVISIONED = 'unprovisioned', | ||
ACCOUNT_SUSPENDED = 'account-suspended', | ||
JWT_EXPIRED = 'jwt-expired', | ||
JWT_REVOKED = 'jwt-revoked', | ||
INVALID_API_KEY = 'invalid-api-key', | ||
INVALID_SIGNATURE = 'invalid-signature', | ||
INVALID_IP = 'invalid-ip', | ||
MULTIPLE_AUTH_METHODS = 'multiple-auth-methods', | ||
INVALID_ID = 'invalid-id', | ||
INVALID_JSON = 'invalid-json', | ||
WRONG_VERB = 'wrong-verb', | ||
ACCEPT_HEADER = 'accept-header', | ||
CONTENT_TYPE_HEADER = 'content-type-header', | ||
UNAVAILABLE_LEGAL = 'unavailable-legal', | ||
APPLICATION_SUSPENDED = 'application-suspended', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './AuthenticationType'; | ||
export * from './GenericErrorCodes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { Client } from './client'; | ||
export { AuthenticationType } from './enums/AuthenticationType'; | ||
export { APILink, APILinks } from './types'; | ||
export * from './enums/'; | ||
export * from './types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Vonage Verify SDK for Node.js | ||
|
||
![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/Vonage/vonage-node-sdk/ci.yml?branch=3.x) | ||
[![Codecov](https://img.shields.io/codecov/c/github/vonage/vonage-node-sdk?label=Codecov&logo=codecov&style=flat-square)](https://codecov.io/gh/Vonage/vonage-server-sdk) | ||
![Latest Release](https://img.shields.io/npm/v/@vonage/verify2) | ||
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](../../CODE_OF_CONDUCT.md) | ||
[![License](https://img.shields.io/npm/l/@vonage/verify2?label=License&style=flat-square)][license] | ||
|
||
<img src="https://developer.nexmo.com/images/logos/vbc-logo.svg" height="48px" alt="Vonage" /> | ||
|
||
This is the Vonage Verify (for version 2) SDK for Node.js for use with | ||
[Vonage APIs](https://www.vonage.com/). To use it you will need a Vonage | ||
account. Sign up [for free at vonage.com][signup]. | ||
|
||
For full API documentation refer to | ||
[developer.vonage.com](https://developer.vonage.com/). | ||
|
||
- [Installation](#installation) | ||
- [Usage](#using-the-vonage-verify-sdk) | ||
- [Promises](#promises) | ||
- [Testing](#testing) | ||
|
||
## Installation | ||
|
||
### With NPM | ||
|
||
```bash | ||
npm install @vonage/verify2 | ||
``` | ||
|
||
### With Yarn | ||
|
||
```bash | ||
yarn add @vonage/verify2 | ||
``` | ||
|
||
## Using the Vonage Verify v2 SDK | ||
|
||
The SDK can be used standalone from the main | ||
[Vonage Server SDK for Node.js](https://github.com/vonage/vonage-node-sdk) if | ||
you only need to use the Messages API. All you need to do is | ||
`require('@vonage/verify')`, and use the returned object to create your own | ||
client. | ||
|
||
```js | ||
const { Auth } = require('@vonage/auth') | ||
const { Verify2 } = require('@vonage/verify2') | ||
|
||
const credentials = new Auth({ | ||
applicationId: APP_ID, | ||
privateKey: PRIAVTE_KEY, | ||
}) | ||
const options = {} | ||
const verifyClient = new Verify2(credentials, options) | ||
``` | ||
|
||
Where `credentials` is any option from [`@vonage/auth`](https://github.com/Vonage/vonage-node-sdk/tree/3.x/readme/packages/auth#options), | ||
and `options` is any option from [`@vonage/server-client`](https://github.com/Vonage/vonage-node-sdk/tree/3.x/readme/packages/server-client#options) | ||
|
||
## Promises | ||
|
||
Most methods that interact with the Vonage API uses Promises. You can either | ||
resolve these yourself, or use `await` to wait for a response. | ||
|
||
```js | ||
const resp = await verifyClient.checkCode(VERIFY_REQUEST_ID, CODE) | ||
|
||
vonage.verify2 | ||
.checkCode(VERIFY_REQUEST_ID, CODE) | ||
.then((resp) => console.log(resp)) | ||
.catch((err) => console.error(err)) | ||
``` | ||
|
||
## Testing | ||
|
||
Run: | ||
|
||
```bash | ||
npm run test | ||
``` | ||
|
||
[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk | ||
[license]: ../../LICENSE.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { CheckCodeRequest } from '../../lib/types'; | ||
|
||
export default [ | ||
{ | ||
label: 'check code', | ||
request: [ | ||
'/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', | ||
'POST', | ||
{ | ||
code: '123456', | ||
} as CheckCodeRequest, | ||
], | ||
response: [200], | ||
method: 'post', | ||
clientMethod: 'checkCode', | ||
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1', '123456'], | ||
expected: true, | ||
}, | ||
{ | ||
label: 'error when request not found', | ||
request: [ | ||
'/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', | ||
'POST', | ||
{ | ||
code: '123456', | ||
} as CheckCodeRequest, | ||
], | ||
response: [ | ||
404, | ||
{ | ||
title: 'Not Found', | ||
type: 'https://developer.vonage.com/api-errors#not-found', | ||
detail: 'Request <id> was not found or it has been verified already.', | ||
instance: 'bf0ca0bf927b3b52e3cb03217e1a1ddf', | ||
}, | ||
], | ||
method: 'post', | ||
clientMethod: 'checkCode', | ||
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1', '123456'], | ||
expected: true, | ||
error: 'Request failed with status code 404', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import requestTests from './verify'; | ||
import checkTests from './check'; | ||
|
||
export default [ | ||
{ | ||
label: 'Request tests', | ||
tests: requestTests, | ||
}, | ||
{ | ||
label: 'Check tests', | ||
tests: checkTests, | ||
}, | ||
]; |
Oops, something went wrong.