Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(accounts): added doc blocks #878

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
version: '3.1.1'
release: '2 Mar 2023'
id: vonage-node-sdk
title: 'vonage-node-sdk'
icon: 'node-color'
pkgName: 'Node SDK'
---

# Changelog

All notable changes to this project will be documented in this file.


## 3.1.1

### Features

* Ported Audit and Redact packages from Node Server SDK v2.
* Introduced async auth handlers.
* Added simple search for Numbers.
* Added Verify v2.
* Added Video experience composer, captions, audio connector, ACL for JWT generator, SIP and DTMF playing.

### Bug Fixes

- Reverts back to ES6 and CommonJS for better Node compatibility.
- Improved response types for Verify v1.
- Fixed wrong case for Messages API parameters.
- Corrected our return types when sending SMS.
- Allowed no filter when getting owned numbers, added required filter when searching available numbers.
- Allowed features to be searched in available numbers.

Full Changelog: [https://github.com/Vonage/vonage-node-sdk/compare/@vonage/[email protected]...@vonage/[email protected]](https://github.com/Vonage/vonage-node-sdk/compare/@vonage/[email protected]...@vonage/[email protected])


## 3.0.11

### Features

- Added auth docs.
- Fixed readme for all products available.

Full Changelog: [https://github.com/Vonage/vonage-node-sdk/compare/@vonage/[email protected]...@vonage/[email protected]](https://github.com/Vonage/vonage-node-sdk/compare/@vonage/[email protected]...@vonage/[email protected])


## 3.0.1

### Features

- Added verify and voice.

### Bug Fixes

- Fixed a few typos in Number Insights.

[https://github.com/Vonage/vonage-node-sdk/compare/@vonage/[email protected]...@vonage/[email protected]](https://github.com/Vonage/vonage-node-sdk/compare/@vonage/[email protected]...@vonage/[email protected])


## 3.0.0

>This version is a complete rewrite of version 2. Written in Typescript and broken out into smaller packages to reduce package size. Callbacks have been removed, and most functions will take in param objects instead of using positional params. SMS and Messages have been broken out to mirror the API.

You can find migration guides for each package here:

- [Accounts](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/accounts/v2_TO_v3_MIGRATION_GUIDE.md)
- [Applications](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/applications/v2_TO_v3_MIGRATION_GUIDE.md)
- [Messages](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/messages/v2_TO_v3_MIGRATION_GUIDE.md)
- [Number Insights](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/number-insights/v2_TO_v3_MIGRATION_GUIDE.md)
- [Numbers](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/numbers/v2_TO_v3_MIGRATION_GUIDE.md)
- [Pricing](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/pricing/v2_TO_v3_MIGRATION_GUIDE.md)
- [SMS](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/sms/v2_TO_v3_MIGRATION_GUIDE.md)
- [Verify](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/verify/v2_TO_v3_MIGRATION_GUIDE.md)
- [Voice](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/voice/v2_TO_v3_MIGRATION_GUIDE.md)


## 2.11.2

- Corrected the issue where downloading a voice recording transcript would throw an exception.


## 2.11.0

- Added support for the Messages API v1.0


## 2.10.1

### Updated

* Corrected license information.


## 2.10.0

>This version serves as the change from the Nexmo namespace to the Vonage namespace. The module now resides on NPM as `@vonage/server-sdk`. Prior versions under the Nexmo namespace will remain in maintenance mode for the next 12 months and receive bug and security fixes. All new functionality will only be added to the @vonage namespace.

### Updated

- Migrated SDK module from `nexmo` to `@vonage/server-sdk`.


## 2.9.1

* Fixed: TypeError: Nexmo is not a constructor.


## 2.9.0

* FIXED: #295 - Nexmo constructor changes of the given options object
* ADDED: Optional `target_api_key` parameter for the `number.buy()` and `number.cancel()` methods.
* ADDED: Typings for Messages API
* UPDATED: Private Key strings now replace `\n` with newlines for easier usage in environment variables.

## 2.8.0

* ADDED: Support for Verify PSD2 requests via `nexmo.verify.psd2()`.

## 2.7.0

* ADDED: Made `apiKey` and `apiSecret` optional when `applicationId` and `privateKey` are present in the Nexmo constructor.

## 2.6.0

* ADDED: Change host via the config object, using `apiHost` & `restHost`

## 2.5.3

* FIXED: URI Encode Signed SMS Message

## 2.5.2

* ADDED: Pricing API support

## 2.5.1

* ADDED: typings for Verify API
* ADDED: Applications API V2 support

## 2.4.2

* Added message signing for sending SMS
* Added `Nexmo.generateSignature` to verify signed messages

## 2.0.1

* FIXED: #116 - default setting of `retry-after` for 429 HTTP status code responses

## 2.0.0

* FIXED: #110 - check the `statusCode` on the response
* FIXED: #114 - handle 429 HTTP status codes
* UPDATED: To allow errors to be programmatically useful the `error` callback objects has been updated to `{statusCode: STATUS_CODE, body: JSON_BODY, headers: HEADERS}`

## 1.2.0

* ADDED: Add File API to the library. `nexmo.files.get` and `nexmo.files.save`.

## 1.1.2

* Fixed: Bug #104 - Fix JSON parsing error

## 1.1.1

* UPDATED: Changed User Agent format to match other libraries
* FIXED: Bug #88 - Undefined method when missing `method` declaration

## 1.1.0

* ADDED: `nexmo.generateJwt` to generate JWT based on instance credentials
* ADDED: `Nexmo.generateJwt` static function to generate JWT

## [1.0.0]

* ADDED: `applicationId` and `privateKey` properties to the first constructor parameter to support JWT generation.
* ADDED: `options.logger` to constructor 2nd parameter to allow adding customer logger.
* ADDED: `options.appendToUserAgent` to constructor 2nd parameter to append a custom string to `User-Agent` header sent to Nexmo.
* ADDED: nexmo.calls adding support to `create`, `get`, `update` and `delete` calls.
* ADDED: nexmo.applications adding support to `create`, `get`, `update` and `delete` calls.
* ADDED: Functionality is now namespaced:
* `nexmo.message`
* `nexmo.calls`
* `nexmo.number`
* `nexmo.verify`
* `nexmo.numberInsight`
* `nexmo.account`
* `nexmo.voice` - legacy voice functionality
* CHANGED: `var Nexmo = require('nexmo');` returns a class definition which should be created using the `new` operator e.g. `var nexmo = new Nexmo(args...);`.
* REMOVED: `var nexmo = require('nexmo');` no longer exposes singleton functions offered by "easynexmo".

## Pre 1.0.0

Earlier versions of this library were published as "easynexmo". The "easynexmo" package is now deprecated.

[1.0.0]: https://github.com/Nexmo/nexmo-node/tree/v1.0.0
33 changes: 22 additions & 11 deletions packages/accounts/__tests__/accounts.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import nock from 'nock';
import { Accounts } from '../lib/index'
import { Accounts } from '../lib/index';
import { Auth } from '@vonage/auth';

describe('accounts', () => {
let client;

beforeEach(() => {
client = new Accounts(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
client = new Accounts(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
});

afterEach(() => {
client = null;
client = null;
});

test("get balance", async () => {
const expectedResponse = {
"value": 10.28,
"autoReload": false
"autoReload": false,
};

nock("https://rest.nexmo.com")
Expand All @@ -33,7 +33,7 @@ describe('accounts', () => {
test("top up balance", async () => {
const expectedResponse = {
"error-code": "200",
"error-code-label": "success"
"error-code-label": "success",
};

nock("https://rest.nexmo.com")
Expand All @@ -42,9 +42,13 @@ describe('accounts', () => {
.query({ api_key: 'abcd', api_secret: '1234' })
.reply(200, expectedResponse);

const lookup = await client.topUpBalance('8ef2447e69604f642ae59363aa5f781b');
const lookup = await client.topUpBalance(
'8ef2447e69604f642ae59363aa5f781b',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this hardcoded value in here? I'm not a big fan of hardcoding items - can we use a random generator to create a random account_id and use it?

);
expect(lookup['error-code']).toEqual(expectedResponse['error-code']);
expect(lookup['error-code-label']).toEqual(expectedResponse['error-code-label']);
expect(
lookup['error-code-label'],
).toEqual(expectedResponse['error-code-label']);
});

test("update callbacks", async () => {
Expand All @@ -53,10 +57,13 @@ describe('accounts', () => {
"dr-callback-url": "https://example.com/webhooks/delivery-receipt",
"max-outbound-request": 30,
"max-inbound-request": 30,
"max-calls-per-second": 30
"max-calls-per-second": 30,
};

const callbacks = {moCallBackUrl: "https://example.com/webhooks/inbound-sms", drCallBackUrl: "https://example.com/webhooks/delivery-receipt"};
const callbacks = {
moCallBackUrl: "https://example.com/webhooks/inbound-sms",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment re: hardcoded values

drCallBackUrl: "https://example.com/webhooks/delivery-receipt",
};
const queryString = new URLSearchParams(callbacks);
const re = new RegExp(queryString.toString(), "g");

Expand All @@ -67,7 +74,11 @@ describe('accounts', () => {
.reply(200, expectedResponse);

const lookup = await client.updateAccountCallbacks(callbacks);
expect(lookup['mo-callback-url']).toEqual(expectedResponse['mo-callback-url']);
expect(lookup['dr-callback-url']).toEqual(expectedResponse['dr-callback-url']);
expect(
lookup['mo-callback-url'],
).toEqual(expectedResponse['mo-callback-url']);
expect(
lookup['dr-callback-url'],
).toEqual(expectedResponse['dr-callback-url']);
});
});
52 changes: 28 additions & 24 deletions packages/accounts/__tests__/secrets.test.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import nock from 'nock';
import { Secrets } from '../lib/index'
import { Secrets } from '../lib/index';
import { Auth } from '@vonage/auth';

describe('secrets', () => {
let client;

beforeEach(() => {
client = new Secrets(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
client = new Secrets(new Auth({ apiKey: 'abcd', apiSecret: '1234' }));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment re: hardcoded values

});

afterEach(() => {
client = null;
client = null;
});

test("list secrets", async () => {
const expectedResponse = {
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"_embedded": {
"secrets": [
{
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"id": "ad6dc56f-07b5-46e1-a527-85530e625800",
"created_at": "2017-03-02T16:34:49Z"
}
]
}
"created_at": "2017-03-02T16:34:49Z",
},
],
},
};

nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "Basic YWJjZDoxMjM0" is used as
authorization header
.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we used a randomly generated value to avoid the code scanning issues?

.persist()
.get('/accounts/abcd/secrets')
.reply(200, expectedResponse);
Expand All @@ -49,16 +49,16 @@
const expectedResponse = {
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"id": "ad6dc56f-07b5-46e1-a527-85530e625800",
"created_at": "2017-03-02T16:34:49Z"
"created_at": "2017-03-02T16:34:49Z",
};

nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
Dismissed Show dismissed Hide dismissed
.persist()
.post('/accounts/abcd/secrets', {secret: 'te5ts3cret!'})
.post('/accounts/abcd/secrets', { secret: 'te5ts3cret!' })
.reply(200, expectedResponse);

const lookup = await client.createSecret('abcd', 'te5ts3cret!');
Expand All @@ -71,30 +71,34 @@
const expectedResponse = {
"_links": {
"self": {
"href": "abc123"
}
"href": "abc123",
},
},
"id": "ad6dc56f-07b5-46e1-a527-85530e625800",
"created_at": "2017-03-02T16:34:49Z"
"created_at": "2017-03-02T16:34:49Z",
};

nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
Dismissed Show dismissed Hide dismissed
.persist()
.get('/accounts/abcd/secrets/ad6dc56f-07b5-46e1-a527-85530e625800')
.reply(200, expectedResponse);

const lookup = await client.getSecret('abcd', 'ad6dc56f-07b5-46e1-a527-85530e625800');
const lookup = await client.getSecret(
'abcd',
'ad6dc56f-07b5-46e1-a527-85530e625800',
);
expect(lookup._links).toEqual(expectedResponse._links);
expect(lookup.id).toEqual(expectedResponse.id);
expect(lookup.created_at).toEqual(expectedResponse.created_at);
});

test("get a secret", async () => {
nock("https://api.nexmo.com", {reqheaders: {'Authorization': 'Basic YWJjZDoxMjM0'} })
test("delete a secret", async () => {
nock("https://api.nexmo.com", { reqheaders: { 'Authorization': 'Basic YWJjZDoxMjM0' } })
Dismissed Show dismissed Hide dismissed
.persist()
.delete('/accounts/abcd/secrets/ad6dc56f-07b5-46e1-a527-85530e625800')
.reply(204);

await client.deleteSecret('abcd', 'ad6dc56f-07b5-46e1-a527-85530e625800');
expect(nock.isDone()).toBeTruthy();
});
});
Loading
Loading