Comparing version 0.0.7 to 1.0.0-beta-1
{ | ||
"name": "nexmo", | ||
"description": "A node.js library for accessing the Nexmo REST API", | ||
"keywords": ["nexmo", "sms"], | ||
"author": "Paul O'Fallon <paul@ofallonfamily.com>", | ||
"homepage": "https://github.com/pofallon/node-nexmo", | ||
"dependencies": { | ||
"request": "2.2.x", | ||
"connect": "1.8.x" | ||
"author": "nexmo", | ||
"version": "1.0.0-beta-1", | ||
"main": "lib/nexmo", | ||
"keywords": [ | ||
"sms", | ||
"voice", | ||
"nexmo" | ||
], | ||
"homepage": "https://github.com/nexmo/nexmo-node", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nexmo/nexmo-node.git" | ||
}, | ||
"description": "A nodejs wrapper for nexmo API to send SMS", | ||
"contributors": [ | ||
"nexmo", | ||
"pvela", | ||
"leggetter", | ||
"akuzi", | ||
"bpilot", | ||
"justinfreitag", | ||
"ecwyne", | ||
"https://github.com/backhand" | ||
], | ||
"scripts": { | ||
"compile": "./node_modules/.bin/babel -d lib src/ -s inline", | ||
"prepublish": "npm run compile", | ||
"test": "npm run compile && mocha --compilers ./node_modules/.bin/_mocha --compilers js:babel-register ./test/*-test.js" | ||
}, | ||
"devDependencies": { | ||
"nodeunit": "0.6.x" | ||
}, | ||
"engine": "node >= 0.4.1", | ||
"version": "0.0.7", | ||
"files": [ | ||
"index.js", | ||
"lib", | ||
"package.json", | ||
"README.md", | ||
"test" | ||
], | ||
"main": "index" | ||
"babel-cli": "^6.7.7", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-register": "^6.7.2", | ||
"dotenv": "^2.0.0", | ||
"expect.js": "^0.3.1", | ||
"mocha": "^2.4.5" | ||
} | ||
} |
347
README.md
@@ -1,49 +0,334 @@ | ||
# node-nexmo | ||
A node.js library for accessing the Nexmo REST API. | ||
# Nexmo Client Library for Node.js [![build status](https://secure.travis-ci.org/Nexmo/nexmo-node.png)](http://travis-ci.org/Nexmo/nexmo-node) | ||
A Node.JS REST API Wrapper library for Nexmo (http://nexmo.com/) | ||
For full API documentation refer to https://docs.nexmo.com/ | ||
[![NPM](https://nodei.co/npm/easynexmo.png)](https://nodei.co/npm/easynexmo/) | ||
## Installation Instructions | ||
```bash | ||
npm install easynexmo | ||
``` | ||
## Usage | ||
```javascript | ||
var nexmo = require('nexmo')({key: 'key', secret: 'secret'}); | ||
```js | ||
var Nexmo = require('easynexmo'); | ||
// Send an SMS message | ||
var nexmo = new Nexmo({key: KEY, secret: SECRET}, {debug: DEBUG}); | ||
``` | ||
var message = nexmo.sms({to: 'to', from: 'from', text: 'Welcome to Nexmo from Node!'}); | ||
* `KEY` - API Key from Nexmo | ||
* `SECRET` - API SECRET from Nexmo | ||
* `DEBUG` - set this to true to debug library calls | ||
message.send(function(err, results) { | ||
if (!err) { | ||
console.log('Your message was delivered in ' + results['message-count'] + ' part(s)!'); | ||
} | ||
}); | ||
## List of API's supported by the library | ||
// Check your account balance | ||
### Send a text message | ||
nexmo.account.balance(function(err, balance) { | ||
if (!err) { | ||
console.log('Your account balance is: ' + balance); | ||
} | ||
}); | ||
```js | ||
nexmo.sms.sendTextMessage(sender, recipient, message, opts, callback); | ||
``` | ||
// ... or spin up an http server and emit message receipts | ||
* `opts` - parameter is optional | ||
nexmo.receipts.on('failed', function(msg) { | ||
console.log('Message to ' + msg.to + ' failed!'); | ||
nexmo.receipts.stop(); | ||
### Send a Binary Message | ||
```js | ||
nexmo.sms.sendBinaryMessage(fromnumber, tonumber,body, udh, callback); | ||
``` | ||
* `body` - Hex encoded binary data | ||
* `udh` - Hex encoded udh | ||
### Send a WAP Push Message | ||
```js | ||
nexmo.sms.sendWapPushMessage(fromnumber, tonumber, title, url, validity, callback); | ||
``` | ||
* `validity` - is optional (if given should be in milliseconds) | ||
### Send a Short Code alert | ||
```js | ||
nexmo.sms.shortcodeAlert(recipient, messageParams, opts, callback); | ||
``` | ||
### Check Account Balance | ||
```js | ||
nexmo.account.checkBalance(callback); | ||
``` | ||
### Get Pricing for sending message to a country. | ||
```js | ||
nexmo.number.getPricing(countryCode, callback); | ||
``` | ||
* `countryCode` - 2 letter ISO Country Code | ||
### Get Pricing for sending message or making a call to a number. | ||
```js | ||
nexmo.number.getPhonePricing(product, countryCode, callback); | ||
``` | ||
* `product` - either `voice` or `sms` | ||
* `countryCode` - 2 letter ISO Country Code | ||
### Get all numbers associated to the account. | ||
```js | ||
nexmo.number.get(options, callback); | ||
``` | ||
* `options` parameter is an optional Dictionary Object containing any of the following parameters | ||
* `pattern` | ||
* `search_pattern` | ||
* `index` | ||
* `size` | ||
For more details on what the above options mean refer to the Nexmo API [documentation](https://docs.nexmo.com/tools/developer-api/account-numbers) | ||
Example: | ||
```js | ||
nexmo.number.get({pattern:714,index:1,size:50,search_pattern:2},consolelog); | ||
``` | ||
### Search for MSISDN's available to purchase. | ||
```js | ||
nexmo.number.search(countryCode,options,callback); | ||
``` | ||
`options` parameter is optional. They can be one of the following : | ||
1. number pattern to match the search (eg. 1408) | ||
2. Dictionary Object optionally containing the following parameters : | ||
* `pattern` | ||
* `search_pattern` | ||
* `features` | ||
* `index` | ||
* `size` | ||
For more details on what the above options mean refer to the Nexmo API [documentation](https://docs.nexmo.com/tools/developer-api/number-search) | ||
Example: | ||
```js nexmo.number.search('US',{pattern:3049,index:1,size:50,features:'VOICE',search_pattern:2},consolelog); | ||
``` | ||
### Purchase number | ||
```js | ||
nexmo.number.buy(countryCode, msisdn, callback); | ||
``` | ||
### Cancel Number | ||
```js | ||
nexmo.number.cancel(countryCode, msisdn, callback); | ||
``` | ||
### Update Number | ||
```js | ||
nexmo.number.update(countryCode, msisdn, params, callback); | ||
``` | ||
params is a dictionary of parameters per [documentation](https://docs.nexmo.com/index.php/developer-api/number-update) | ||
### Update Password (API Secret) | ||
```js | ||
nexmo.account.updatePassword(<NEW_PASSWORD>,callback); | ||
``` | ||
### Update Callback URL associated to the account | ||
```js | ||
nexmo.updateSMSCallback(<NEW_CALLBACK_URL>,callback); | ||
``` | ||
### Change Delivery Receipt URL associated to the account | ||
```js | ||
nexmo.account.updateDeliveryReceiptCallback(<NEW_DR_CALLBACK_URL>,callback); | ||
``` | ||
### Send TTS Message | ||
```js | ||
nexmo.voice.sendTTSMessage = function(<TO_NUMBER>,message,options,callback); | ||
``` | ||
### Send TTS Prompt With Capture | ||
```js | ||
nexmo.sendTTSPromptWithCapture(<TO_NUMBER>,message,<MAX_DIGITS>, <BYE_TEXT>,options,callback); | ||
``` | ||
### Send TTS Prompt With Confirm | ||
```js | ||
nexmo.voice.sendTTSPromptWithConfirm(<TO_NUMBER>, message ,<MAX_DIGITS>,'<PIN_CODE>',<BYE_TEXT>,<FAILED_TEXT>,options,callback); | ||
``` | ||
### Make a voice call | ||
```js | ||
nexmo.voice.call(<TO_NUMBER>,<ANSWER_URL>,options,callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/voice/call | ||
### Submit a Verification Request | ||
```js | ||
nexmo.verify.request({number:<NUMBER_TO_BE_VERIFIED>,brand:<NAME_OF_THE_APP>},callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#vrequest | ||
### Validate the response of a Verification Request | ||
```js | ||
nexmo.verify.check({request_id:<UNIQUE_ID_FROM_VERIFICATION_REQUEST>,code:<CODE_TO_CHECK>},callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#check | ||
### Search one or more Verification Request | ||
```js | ||
nexmo.verify.search(<ONE_REQUEST_ID or ARRAY_OF_REQUEST_ID>,callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#search | ||
### Verification Control API | ||
```js | ||
nexmo.verify.control({request_id:<UNIQUE_ID_FROM_VERIFICATION_REQUEST>,cmd:<CODE_TO_CHECK>},callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/verify/api-reference/api-reference#control | ||
### Number Insight - Basic | ||
```js | ||
nexmo.numberInsight.get({level: 'basic', number: NUMBER}, callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/number-insight/basic | ||
Example: | ||
```js | ||
nexmo.numberInsight.get({level: 'basic', number: '1-234-567-8900'}, consolelog); | ||
``` | ||
### Number Insight - Standard | ||
```js | ||
nexmo.numberInsight.get({level: 'standard', number: NUMBER}, callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/number-insight/standard | ||
Example: | ||
```js | ||
nexmo.numberInsight.get({level: 'standard', number: '1-234-567-8900'}, consolelog); | ||
``` | ||
### Number Insight - Advanced | ||
```js | ||
nexmo.numberInsight.get({level: 'advanced', number: NUMBER}, callback); | ||
``` | ||
For more information check the documentation at https://docs.nexmo.com/number-insight/advanced | ||
## Callbacks | ||
Callback from all API calls returns 2 parameters - error and a json object. | ||
An example callback function: | ||
```js | ||
function consolelog (err,messageResponse) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
console.dir(messageResponse); | ||
} | ||
} | ||
nexmo.receipts.start(); | ||
``` | ||
Refer here https://docs.nexmo.com/ to get the schema for the returned message response object. | ||
## Testing | ||
Run the | ||
```bash | ||
npm test | ||
``` | ||
## Install | ||
For testing purposes you can also use setHost function to make the library send requests to another place like localhost instead of real Nexmo. Feel free to catch and process those requests the way you need. A usage example: | ||
<pre> | ||
npm install nexmo | ||
</pre> | ||
```js | ||
nexmo.setHost('localhost'); | ||
``` | ||
## Dependencies | ||
Note that default port is 443 and easynexmo does https calls in such a case. You can use setPort function to make it proper for your testing environment. When port is not 443 it will make requests via http protocol. Have a look at an example: | ||
This library depends on: | ||
```js | ||
nexmo.setPort('8080'); | ||
``` | ||
* [mikeal/request](https://github.com/mikeal/request) | ||
* [senchalabs/connect](https://github.com/senchalabs/connect) | ||
* [caolan/nodeunit](https://github.com/caolan/nodeunit) (for unit tests) | ||
## Examples | ||
There are some basic examples which will test the functionality. They uses environment variables for settings for the tests. The environment variables are: | ||
* KEY = The API key provided by Nexmo for your account | ||
* SECRET = The secret provided by NExmo for your account | ||
* FROM_NUMBER = The phone number to send messages and make calls from. | ||
* TO_NUMBER = The phone number to send messages and make calls to. | ||
* MAX_DIGITS = The maximum number of digits for the pin code. | ||
* ANSWER_URL = The URL which has the VoiceXML file to control the call functionality | ||
* PIN_CODE = The digits you must enter to confirm the message | ||
The simplest way to run the examples is to create a `.env` file in the `examples` directory with the following: | ||
``` | ||
KEY={value} | ||
SECRET={value} | ||
FROM_NUMBER={value} | ||
TO_NUMBER={value} | ||
MAX_DIGITS={value} | ||
ANSWER_URL={value} | ||
PIN_CODE={value} | ||
``` | ||
Then run: | ||
```bash | ||
node examples/pre-v1.js | ||
``` | ||
And | ||
```bash | ||
node examples/v1-beta.js | ||
``` | ||
## License | ||
MIT - see [LICENSE](LICENSE.txt) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
162637
0
28
0
1489
335
7
11
4
- Removedconnect@1.8.x
- Removedrequest@2.2.x
- Removedcall-bind@1.0.7(transitive)
- Removedconnect@1.8.7(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedformidable@1.0.17(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhasown@2.0.2(transitive)
- Removedmime@4.0.4(transitive)
- Removedobject-inspect@1.13.2(transitive)
- Removedqs@6.13.0(transitive)
- Removedrequest@2.2.9(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedside-channel@1.0.6(transitive)