Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Vonage/vonage-node-sdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @vonage/server-sdk@3.4.0
Choose a base ref
...
head repository: Vonage/vonage-node-sdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @vonage/server-sdk@3.5.0
Choose a head ref
  • 8 commits
  • 18 files changed
  • 2 contributors

Commits on May 16, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ffbf97b View commit details
  2. Copy the full SHA
    fff69dd View commit details

Commits on May 17, 2023

  1. Copy the full SHA
    15bfc32 View commit details

Commits on May 19, 2023

  1. Copy the full SHA
    3e04e19 View commit details

Commits on May 22, 2023

  1. Copy the full SHA
    365d4b8 View commit details

Commits on May 23, 2023

  1. Copy the full SHA
    c93bc3d View commit details
  2. Copy the full SHA
    4097b53 View commit details
  3. Publish

     - @vonage/messages@1.5.0
     - @Vonage/server-sdk@3.5.0
     - @vonage/verify2@1.3.0
    manchuck committed May 23, 2023
    Copy the full SHA
    a9a36c9 View commit details
28 changes: 22 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -6,24 +6,40 @@ on:
pull_request:
jobs:
test:
continue-on-error: ${{ matrix.experimental }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node: [14.x, 16.x, 18.x]
runs-on: ${{ matrix.os }}
node: [16.x, 18.x, 20.x]
experimental: [false]
include:
- os: ubuntu-latest
node: 14
experimental: true
npm_version: "@8.3.1"
- os: windows-latest
node: 14
experimental: true
npm_version: "@8.3.1"
- os: macos-latest
node: 14
experimental: true
npm_version: "@8.3.1"
steps:
- uses: actions/checkout@v3

- name: Set up Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: npm install -g typescript npm@8.3.1 && npm install
- name: Install typescript
run: npm install -g typescript npm${{ matrix.npm_version }} && npm install

- name: Lint, Compile, Test
run: npm run compile && npm run test -- --coverage
run: npm run compile && npm run test -- --coverage --verbose --maxWorkers=2

- name: Run codecov
uses: codecov/codecov-action@v3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ The following is a list of Vonage APIs and whether the Node Server SDK provides
| Reports API | Beta ||
| SMS API | General Availability ||
| Verify API | General Availability ||
| Verify v2 API | Beta ||
| Verify v2 API | General Availability ||
| Voice API | General Availability ||

[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk
14 changes: 9 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 9 additions & 21 deletions packages/messages/lib/messages.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { Client } from '@vonage/server-client';
import { Client, AuthenticationType } from '@vonage/server-client';
import { VetchOptions } from '@vonage/vetch';
import { MessageSuccess } from './interfaces';
import { SendMessageParams, MessageSuccessResponse } from './types';
import debug from 'debug';

const log = debug('vonage:messages');

type VonageRequest = {
data: { [key: string]: unknown }
headers: { Authorization: string }
}

export class Messages extends Client {
/**
* Handle various ways the Messages API handles auth
@@ -19,30 +15,22 @@ export class Messages extends Client {
* @param {any} request - Object containing request data
*/
public async addAuthenticationToRequest(
request: VonageRequest,
): Promise<VonageRequest & unknown> {
request: VetchOptions,
): Promise<VetchOptions & unknown> {
log('Auth config', this.auth);
this.authType = AuthenticationType.KEY_SECRET;

if (this.auth.applicationId && this.auth.privateKey) {
log('Adding JWT token to request');
request.headers.Authorization = await this.auth.createBearerHeader();
return request;
this.authType = AuthenticationType.JWT;
}

if (this.auth.signature) {
log('Signing the request');
request.data = {
...request.data,
...(await this.auth.createSignatureHash(request.data)),
};
return request;
this.authType = AuthenticationType.SIGNATURE;
}

log('Adding query parameters to request');
request.data = {
...request.data,
...(await this.auth.getQueryParams(request?.data)),
};
return request;
return super.addAuthenticationToRequest(request);
}

public async send(message: SendMessageParams): Promise<MessageSuccess> {
3 changes: 2 additions & 1 deletion packages/messages/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/messages",
"version": "1.4.0",
"version": "1.5.0",
"description": "Multi-channel messaging that integrates WhatsApp, Facebook, Viber, SMS, and MMS",
"keywords": [
"whatsapp",
@@ -38,6 +38,7 @@
"dependencies": {
"@vonage/auth": "^1.3.0",
"@vonage/server-client": "^1.4.0",
"@vonage/vetch": "^1.3.0",
"debug": "^4.3.4"
},
"devDependencies": {
3 changes: 2 additions & 1 deletion packages/server-sdk/README.md
Original file line number Diff line number Diff line change
@@ -87,6 +87,7 @@ You can find more information for each product below:
* [Server SDK](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/server-sdk/README.md)
* [SMS](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/sms/README.md)
* [Verify](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/verify/README.md)
* [Verify V2](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/verify2/README.md)
* [Vetch](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/vetch/README.md)
* [Video](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/video/README.md)
* [Voice](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/voice/README.md)
@@ -114,7 +115,7 @@ The following is a list of Vonage APIs and whether the Node Server SDK provides
| Reports API | Beta ||
| SMS API | General Availability ||
| Verify API | General Availability ||
| Verify v2 API | Beta ||
| Verify v2 API | General Availability ||
| Voice API | General Availability ||

[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk
3 changes: 3 additions & 0 deletions packages/server-sdk/lib/vonage.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import { Pricing } from '@vonage/pricing';
import { Redact } from '@vonage/redact';
import { SMS } from '@vonage/sms';
import { Verify } from '@vonage/verify';
import { Verify2 } from '@vonage/verify2';
import { Voice } from '@vonage/voice';
import { ConfigParams } from '@vonage/server-client';

@@ -25,6 +26,7 @@ export class Vonage {
public secrets: Secrets;
public sms: SMS;
public verify: Verify;
public verify2: Verify2;
public voice: Voice;

constructor(credentials: AuthInterface, options?: ConfigParams) {
@@ -45,6 +47,7 @@ export class Vonage {
this.secrets = new Secrets(this.credentials, this.options);
this.sms = new SMS(this.credentials, this.options);
this.verify = new Verify(this.credentials, this.options);
this.verify2 = new Verify2(this.credentials, this.options);
this.voice = new Voice(this.credentials, this.options);
}
}
5 changes: 3 additions & 2 deletions packages/server-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/server-sdk",
"version": "3.4.0",
"version": "3.5.0",
"description": "Node.js Client for the Vonage API Platform",
"homepage": "https://developer.vonage.com",
"bugs": {
@@ -30,14 +30,15 @@
"@vonage/accounts": "^1.4.0",
"@vonage/applications": "^1.4.0",
"@vonage/auth": "^1.3.0",
"@vonage/messages": "^1.4.0",
"@vonage/messages": "^1.5.0",
"@vonage/number-insights": "^1.4.0",
"@vonage/numbers": "^1.4.0",
"@vonage/pricing": "^1.4.0",
"@vonage/redact": "^1.3.0",
"@vonage/server-client": "^1.4.0",
"@vonage/sms": "^1.4.0",
"@vonage/verify": "^1.4.0",
"@vonage/verify2": "^1.3.0",
"@vonage/voice": "^1.4.0"
},
"publishConfig": {
28 changes: 28 additions & 0 deletions packages/verify2/__tests__/__dataSets__/cancel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default [
{
label: 'cancel request',
request: ['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', 'DELETE'],
response: [204],
method: 'post',
clientMethod: 'cancel',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1'],
expected: true,
},
{
label: 'error when request not found',
request: ['/v2/verify/091e717f-8715-41a0-a3f0-cc04912deaa1', 'DELETE'],
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: 'delete',
clientMethod: 'cancel',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1'],
expected: false,
},
];
12 changes: 9 additions & 3 deletions packages/verify2/__tests__/__dataSets__/check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheckCodeRequest } from '../../lib/types';
import { CheckCodeRequest, CheckRequestResponse } from '../../lib/types';

export default [
{
@@ -10,11 +10,17 @@ export default [
code: '123456',
} as CheckCodeRequest,
],
response: [200],
response: [
200,
{
request_id: '091e717f-8715-41a0-a3f0-cc04912deaa1',
status: 'complete',
} as CheckRequestResponse,
],
method: 'post',
clientMethod: 'checkCode',
parameters: ['091e717f-8715-41a0-a3f0-cc04912deaa1', '123456'],
expected: true,
expected: 'complete',
},
{
label: 'error when request not found',
5 changes: 5 additions & 0 deletions packages/verify2/__tests__/__dataSets__/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import requestTests from './verify';
import checkTests from './check';
import cancelTests from './cancel';

export default [
{
@@ -10,4 +11,8 @@ export default [
label: 'Check tests',
tests: checkTests,
},
{
label: 'Cancel tests',
tests: cancelTests,
},
];
Loading