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.8.1
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.9.1
Choose a head ref
  • 7 commits
  • 35 files changed
  • 3 contributors

Commits on Aug 21, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    mark-vieira Mark Vieira
    Copy the full SHA
    4b9aab7 View commit details
  2. Copy the full SHA
    7c75951 View commit details
  3. feat: file download (#858)

    manchuck authored Aug 21, 2023
    Copy the full SHA
    67ec0e8 View commit details
  4. Copy the full SHA
    2ac48d3 View commit details
  5. Publish

     - @vonage/accounts@1.8.0
     - @vonage/applications@1.8.0
     - @vonage/audit@1.8.0
     - @vonage/auth@1.6.0
     - @vonage/jwt@1.6.0
     - @vonage/meetings@1.4.0
     - @vonage/messages@1.9.0
     - @vonage/number-insights@1.8.0
     - @vonage/numbers@1.8.0
     - @vonage/pricing@1.8.0
     - @vonage/proactive-connect@1.5.0
     - @vonage/redact@1.7.0
     - @vonage/server-client@1.8.0
     - @Vonage/server-sdk@3.9.0
     - @vonage/sms@1.8.0
     - @vonage/subaccounts@1.4.0
     - @vonage/users@1.2.0
     - @Vonage/verify@1.8.0
     - @vonage/verify2@1.7.0
     - @vonage/video@1.11.0
     - @vonage/voice@1.8.0
    manchuck committed Aug 21, 2023
    Copy the full SHA
    60cb506 View commit details
  6. Copy the full SHA
    08d7ae8 View commit details
  7. Publish

     - @vonage/meetings@1.4.1
     - @vonage/proactive-connect@1.5.1
     - @vonage/redact@1.7.1
     - @Vonage/server-sdk@3.9.1
     - @vonage/subaccounts@1.4.1
     - @vonage/verify2@1.7.1
    manchuck committed Aug 21, 2023
    Copy the full SHA
    e2a2698 View commit details
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ You can find more information for each product below:
* [Number Insights](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/number-insights/README.md)
* [Numbers](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/numbers/README.md)
* [Pricing](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/pricing/README.md)
* [Server Client](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/server-client/README.md)
* [Server Client][server-client]
* [Server SDK](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/server-sdk/README.md)
* [SMS][sms]
* [Sub Accounts](https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/subaccounts/README.md)
@@ -124,28 +124,29 @@ The following is a list of Vonage APIs and whether the Node Server SDK provides

### V2 Migrations

While most of the V2 functions have been ported into their own package, some of the functions have not been ported or were removed. Below is a list of those changes:
While most of the V2 functions have been ported into their own package, some of the functions have not been ported or were removed. Below is a list of those changes:

| V2 Function | Status | Note |
|-----------------------------|:---------------:|:------------------------------------------------------:|
| `vonage.conversion` | _REMOVED_ | |
| `vonage.conversation` | Not Implemented | This was only released as a beta package |
| `vonage.app` | _REMOVED_ | Moved to [Applications][applications] |
| `vonage.files` | Not ported | Has not been ported to V3 at this time |
| `vonage.app` | Moved | Moved to [Applications][applications] |
| `vonage.files` | Moved | Move to [ServerClient][server-client] |
| `vonage.message` | Moved | Moved to [SMS][sms] |
| `vonage.generateJwt` | Moved | Was moved to [JWT][jwt] |
| `vonage.generateJwt` | Moved | Was moved to [JWT][jwt] |
| `vonage.generateSignature` | Not Ported | Has not been ported to V3 at this time |
| `vonage.calls` | Moved | Was moved to [Voice][voice] |
| `vonage.credentials` | Updated | Options can be found in [Server Client][server-client] |
| `vonage.options` | Updated | Options can be found in [Server Client][server-client] |
| `vonage.options.httpClient` | _Removed_ | |
| `vonage.options.userAgent` | Not Ported | Has not been ported to V3 at this time |
| `vonage.options.userAgent` | Moved | Options can be found in [Server Client][server-client] |

For more information, check out each packages migration guide.

[applications]: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/applications/README.md
[auth]: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/auth/README.md
[sms]: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/sms/README.md
[server-client]: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/server-client/README.md
[jwt]: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/jwt/README.md
[voice]: https://github.com/Vonage/vonage-node-sdk/blob/3.x/packages/voice/README.md
[signup]: https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL&utm_medium=github&utm_campaign=node-server-sdk
6 changes: 3 additions & 3 deletions packages/accounts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/accounts",
"version": "1.7.0",
"version": "1.8.0",
"description": "Vonage Account Management API",
"homepage": "https://developer.vonage.com",
"bugs": {
@@ -27,10 +27,10 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/server-client": "^1.7.0"
"@vonage/server-client": "^1.8.0"
},
"devDependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
},
"publishConfig": {
6 changes: 3 additions & 3 deletions packages/applications/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/applications",
"version": "1.7.0",
"version": "1.8.0",
"description": "Vonage Applications API",
"keywords": [
"vonage"
@@ -30,8 +30,8 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/server-client": "^1.7.0",
"@vonage/auth": "^1.6.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0"
},
"devDependencies": {
6 changes: 3 additions & 3 deletions packages/audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/audit",
"version": "1.7.0",
"version": "1.8.0",
"description": "Vonage Audit SDK Package",
"homepage": "https://github.com/vonage/vonage-node-sdk/tree/master/packages/audit#readme",
"bugs": {
@@ -27,8 +27,8 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/server-client": "^1.7.0",
"@vonage/auth": "^1.6.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0"
},
"devDependencies": {
4 changes: 2 additions & 2 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/auth",
"version": "1.5.0",
"version": "1.6.0",
"description": "Vonage Auth Package adds the correct authentication headers to requests to Vonage API's",
"homepage": "https://github.com/vonage/vonage-node-sdk/tree/master/packages/auth#readme",
"bugs": {
@@ -23,7 +23,7 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/jwt": "^1.5.0",
"@vonage/jwt": "^1.6.0",
"debug": "^4.3.4"
},
"devDependencies": {
50 changes: 41 additions & 9 deletions packages/jwt/__tests__/jwt.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { tokenGenerate } from '../lib';
import { verify } from 'jsonwebtoken';
import { tokenGenerate, verifySignature } from '../lib';
import { verify, sign } from 'jsonwebtoken';
import { readFileSync } from 'fs';
import {
MissingApplicationIdError,
@@ -32,29 +32,27 @@ const acl = {
describe('Token Generator', () => {
test('Will throw when missing applicationId', () => {
// eslint-disable-next-line
// @ts-ignore
// @ts-ignore
expect(() => tokenGenerate()).toThrow(new MissingApplicationIdError());
});

test('Will throw when missing privateKey', () => {
// eslint-disable-next-line
// @ts-ignore
expect(() => tokenGenerate('app-id')).toThrow(
new MissingPrivateKeyError(),
);
// @ts-ignore
expect(() => tokenGenerate('app-id')).toThrow(new MissingPrivateKeyError());
});

test('Will throw when applicationId not a string', () => {
// eslint-disable-next-line
// @ts-ignore
// @ts-ignore
expect(() => tokenGenerate(12345, privateKey)).toThrow(
new InvalidApplicationIdError(),
);
});

test('Will throw when privateKey not a string or buffer', () => {
// eslint-disable-next-line
// @ts-ignore
// @ts-ignore
expect(() => tokenGenerate(applicationId, 56789)).toThrow(
new InvalidPrivateKeyError(),
);
@@ -92,4 +90,38 @@ describe('Token Generator', () => {
expect(decoded).not.toHaveProperty('ttl');
expect(decoded.acl).toMatchObject(acl);
});

test('Can Verify signature', () => {
const token = tokenGenerate(applicationId, privateKey, {
ttl,
subject,
acl,
});

// eslint-disable-next-line
expect(verifySignature(token, privateKey)).toEqual(true);
});

test('Will not validate with invalid key', () => {
const token = tokenGenerate(applicationId, privateKey, {
ttl,
subject,
acl,
});

// eslint-disable-next-line
expect(verifySignature(token, 'fizz-buzz')).toEqual(false);
});

test('Will not validate with invalid JWT token', () => {
const token = sign({}, 'fizzBuzz');

// eslint-disable-next-line
expect(verifySignature(token, privateKey)).toEqual(false);
});

test('Will not validate with non JWT token', () => {
// eslint-disable-next-line
expect(verifySignature('fizz-buzz', privateKey)).toEqual(false);
});
});
4 changes: 4 additions & 0 deletions packages/jwt/lib/index.ts
Original file line number Diff line number Diff line change
@@ -15,3 +15,7 @@ export function tokenGenerate(
) {
return instance.tokenGenerate(applicationId, privateKey, opts);
}

export function verifySignature(token: string, privateKey: string | Buffer) {
return instance.verifySignature(token, privateKey);
}
17 changes: 15 additions & 2 deletions packages/jwt/lib/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JWTInterface, GeneratorOptions, Claims } from './common';
import { sign } from 'jsonwebtoken';
import { sign, verify } from 'jsonwebtoken';
import { v4 as uuidv4 } from 'uuid';
import {
MissingApplicationIdError,
@@ -45,6 +45,19 @@ export class JWT implements JWTInterface {
});
}

verifySignature(jwt: string, privateKey: string | Buffer): boolean {
try {
verify(jwt, privateKey, {
algorithms: ['RS256'],
});
return true;
} catch (error) {
log('Error when verifying token', error);
}

return false;
}

private validateOptions(opts?: GeneratorOptions): Claims {
const now = parseInt((Date.now() / 1000).toString(), 10);

@@ -70,7 +83,7 @@ export class JWT implements JWTInterface {

for (const property in opts) {
// eslint-disable-next-line
if (opts.hasOwnProperty(property)) {
if (opts.hasOwnProperty(property)) {
claims[property] = opts[property];
}
}
2 changes: 1 addition & 1 deletion packages/jwt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/jwt",
"version": "1.5.0",
"version": "1.6.0",
"description": "Vonage JWT package. Creates JWT tokens for Vonage API's",
"homepage": "https://github.com/vonage/vonage-node-sdk/tree/master/packages/jwt#readme",
"bugs": {
9 changes: 5 additions & 4 deletions packages/meetings/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/meetings",
"version": "1.3.0",
"version": "1.4.1",
"description": "Vonage Meetings Management API",
"homepage": "httsp://developer.vonage.com",
"bugs": {
@@ -13,28 +13,29 @@
"license": "Apache-2.0",
"author": "Chuck MANCHUCK Reeves <chuck@manchuck.com>",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
"/dist"
],
"scripts": {
"build": "npm run clean && npm run compile",
"clean": "npx shx rm -rf dist tsconfig.tsbuildinfo",
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/server-client": "^1.7.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0",
"fast-xml-parser": "^4.2.5",
"form-data": "^4.0.0",
"lodash.pick": "^4.4.0"
},
"devDependencies": {
"@amvijay/multipart-parser": "^1.0.2",
"@vonage/auth": "^1.5.0",
"@vonage/auth": "^1.6.0",
"nock": "^13.3.1"
}
}
6 changes: 3 additions & 3 deletions packages/messages/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/messages",
"version": "1.8.0",
"version": "1.9.0",
"description": "Multi-channel messaging that integrates WhatsApp, Facebook, Viber, SMS, and MMS",
"keywords": [
"whatsapp",
@@ -36,8 +36,8 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/server-client": "^1.7.0",
"@vonage/auth": "^1.6.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0",
"debug": "^4.3.4"
},
6 changes: 3 additions & 3 deletions packages/number-insights/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/number-insights",
"version": "1.7.0",
"version": "1.8.0",
"description": "Vonage Number Insights API",
"homepage": "https://developer.vonage.com",
"bugs": {
@@ -27,8 +27,8 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/server-client": "^1.7.0",
"@vonage/auth": "^1.6.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0"
},
"devDependencies": {
6 changes: 3 additions & 3 deletions packages/numbers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/numbers",
"version": "1.7.0",
"version": "1.8.0",
"description": "Vonage Numbers SDK Package",
"homepage": "https://github.com/vonage/vonage-node-sdk/tree/master/packages/numbers#readme",
"bugs": {
@@ -27,8 +27,8 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/server-client": "^1.7.0",
"@vonage/auth": "^1.6.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0",
"lodash.omit": "^4.5.0"
},
6 changes: 3 additions & 3 deletions packages/pricing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vonage/pricing",
"version": "1.7.0",
"version": "1.8.0",
"description": "Vonage API for pricing",
"homepage": "https://developer.vonage.com",
"bugs": {
@@ -27,8 +27,8 @@
"compile": "npx tsc --build --verbose"
},
"dependencies": {
"@vonage/auth": "^1.5.0",
"@vonage/server-client": "^1.7.0",
"@vonage/auth": "^1.6.0",
"@vonage/server-client": "^1.8.0",
"@vonage/vetch": "^1.5.0"
},
"devDependencies": {
Loading