|
1 | | -# Bandwidth Node Multi-Factor Authentication SDK |
2 | | - |
3 | | -Note: As of version 3.0.0, this package has been upgraded to TypeScript |
4 | | - |
5 | | -[](https://github.com/Bandwidth/node-mfa/actions/workflows/test.yml) |
6 | | - |
7 | | -| **OS** | **Node** | |
8 | | -|:---:|:---:| |
9 | | -| Windows 2016 | 12, 14, 16 | |
10 | | -| Windows 2019 | 12, 14, 16 | |
11 | | -| Ubuntu 18.04 | 12, 14, 16 | |
12 | | -| Ubuntu 20.04 | 12, 14, 16 | |
13 | | - |
14 | | -## Getting Started |
15 | | - |
16 | | -### Installation |
17 | | - |
18 | | -``` |
19 | | -npm install @bandwidth/mfa |
20 | | -``` |
21 | | - |
22 | | -### Initialize |
23 | | - |
24 | | -``` |
25 | | -import { Client, MFAController } from '@bandwidth/mfa'; |
26 | | -
|
27 | | -const client = new Client({ |
28 | | - basicAuthUserName: "username", |
29 | | - basicAuthPassword: "password" |
30 | | -}); |
31 | | -
|
32 | | -const controller = new MFAController(client); |
33 | | -const accountId = "12345"; |
34 | | -``` |
35 | | - |
36 | | -### Create A MFA Request |
37 | | - |
38 | | -``` |
39 | | -var from = "+15554443333"; |
40 | | -var to = "+15553334444"; |
41 | | -var applicationId = "3-a-b-c"; |
42 | | -var scope = "scope"; |
43 | | -var digits = 6; |
44 | | -var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; |
45 | | -
|
46 | | -var requestBody = { |
47 | | - from: from, |
48 | | - to: to, |
49 | | - applicationId: applicationId, |
50 | | - scope: scope, |
51 | | - digits: digits, |
52 | | - message: message |
53 | | -}; |
54 | | -
|
55 | | -await controller.voiceTwoFactor(accountId, requestBody); |
56 | | -
|
57 | | -//request verification |
58 | | -const code = '123456'; //this is the user input to validate |
59 | | -const expirationTimeInMinutes = 3 |
60 | | -
|
61 | | -var verifyBody = { |
62 | | - to: to, |
63 | | - applicationId: applicationId, |
64 | | - scope: scope, |
65 | | - code: code, |
66 | | - expirationTimeInMinutes: expirationTimeInMinutes |
67 | | -} |
68 | | -
|
69 | | -var verifyMfaResponse = await controller.verifyTwoFactor(accountId, verifyBody); |
70 | | -
|
71 | | -console.log(verifyMfaResponse.result.valid); |
72 | | -``` |
73 | | - |
74 | | -## Supported Node Versions |
75 | | - |
76 | | -This package can be used with Node >= 10 |
77 | | - |
78 | | -## Documentation |
79 | | - |
80 | | -Documentation for this package can be found at https://dev.bandwidth.com/sdks/node.html |
81 | | - |
82 | | -## Credentials |
83 | | - |
84 | | -Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html |
| 1 | +# Bandwidth Node Multi-Factor Authentication SDK |
| 2 | + |
| 3 | +Note: As of version 3.0.0, this package has been upgraded to TypeScript |
| 4 | + |
| 5 | +[](https://github.com/Bandwidth/node-mfa/actions/workflows/test.yml) |
| 6 | + |
| 7 | +| **OS** | **Node** | |
| 8 | +|:---:|:---:| |
| 9 | +| Windows 2016 | 12, 14, 16 | |
| 10 | +| Windows 2019 | 12, 14, 16 | |
| 11 | +| Ubuntu 20.04 | 12, 14, 16 | |
| 12 | +| Ubuntu 22.04 | 12, 14, 16 | |
| 13 | + |
| 14 | +## Getting Started |
| 15 | + |
| 16 | +### Installation |
| 17 | + |
| 18 | +``` |
| 19 | +npm install @bandwidth/mfa |
| 20 | +``` |
| 21 | + |
| 22 | +### Initialize |
| 23 | + |
| 24 | +``` |
| 25 | +import { Client, MFAController } from '@bandwidth/mfa'; |
| 26 | +
|
| 27 | +const client = new Client({ |
| 28 | + basicAuthUserName: "username", |
| 29 | + basicAuthPassword: "password" |
| 30 | +}); |
| 31 | +
|
| 32 | +const controller = new MFAController(client); |
| 33 | +const accountId = "12345"; |
| 34 | +``` |
| 35 | + |
| 36 | +### Create A MFA Request |
| 37 | + |
| 38 | +``` |
| 39 | +var from = "+15554443333"; |
| 40 | +var to = "+15553334444"; |
| 41 | +var applicationId = "3-a-b-c"; |
| 42 | +var scope = "scope"; |
| 43 | +var digits = 6; |
| 44 | +var message = "Your temporary {NAME} {SCOPE} code is {CODE}"; |
| 45 | +
|
| 46 | +var requestBody = { |
| 47 | + from: from, |
| 48 | + to: to, |
| 49 | + applicationId: applicationId, |
| 50 | + scope: scope, |
| 51 | + digits: digits, |
| 52 | + message: message |
| 53 | +}; |
| 54 | +
|
| 55 | +await controller.voiceTwoFactor(accountId, requestBody); |
| 56 | +
|
| 57 | +//request verification |
| 58 | +const code = '123456'; //this is the user input to validate |
| 59 | +const expirationTimeInMinutes = 3 |
| 60 | +
|
| 61 | +var verifyBody = { |
| 62 | + to: to, |
| 63 | + applicationId: applicationId, |
| 64 | + scope: scope, |
| 65 | + code: code, |
| 66 | + expirationTimeInMinutes: expirationTimeInMinutes |
| 67 | +} |
| 68 | +
|
| 69 | +var verifyMfaResponse = await controller.verifyTwoFactor(accountId, verifyBody); |
| 70 | +
|
| 71 | +console.log(verifyMfaResponse.result.valid); |
| 72 | +``` |
| 73 | + |
| 74 | +## Supported Node Versions |
| 75 | + |
| 76 | +This package can be used with Node >= 10 |
| 77 | + |
| 78 | +## Documentation |
| 79 | + |
| 80 | +Documentation for this package can be found at https://dev.bandwidth.com/sdks/node.html |
| 81 | + |
| 82 | +## Credentials |
| 83 | + |
| 84 | +Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html |
0 commit comments