Package detail

@vonage/auth

Vonage306.4kApache-2.01.13.1

Vonage Auth Package adds the correct authentication headers to requests to Vonage API's

readme

Vonage Auth SDK for Node.js

GitHub Workflow Status Codecov Latest Release Contributor Covenant License

Vonage

This is the Vonage Auth SDK for Node.js for creating authentication headers and signature for use with Vonage APIs. To use it you will need a Vonage account. Sign up for free at vonage.com.

We recommend using this package as part of the overall @vonage/server-sdk package.

For full API documentation refer to developer.vonage.com.

Installation

We recommend using this SDK as part of the overall @vonage/server-sdk package. Please see the main package for installation.

You can also use this SDK standalone if you only need access to just the Auth SDK.

With NPM

npm install @vonage/auth

With Yarn

yarn add @vonage/auth

Usage

As part of the Vonage Server SDK

If you are using this SDK as part of the Vonage Server SDK, you can access it as the auth property off of the client that you instantiate.

The SDK can be used standalone from the main Vonage Server SDK for Node.js if you only need to use the Auth API. All you need to do is require('@vonage/auth'), and use the returned object to create your own client.

const { Auth } = require('@vonage/server-sdk');
// Or if standalone
const { Auth } = require('@vonage/auth');

const vonageAuth = new Auth({
  apiKey: API_KEY,
  apiSecret: API_SECRET,
  applicationId: APP_ID,
  privateKey: PRIVATE_KEY_PATH,
});

(async () => {
  const basicHeader = vonageAuth.createBasicHeader();
  console.log(basicHeader);
})()

Options

Options is an object with the following properties:

  • apiKey - API Key from Vonage API. If applicationId and privateKey are present, apiKey is optional.
  • apiSecret - API Secret from Vonage API. If applicationId and privateKey are present, apiSecret is optional.
  • applicationId - (optional) The Vonage API Application ID to be used when creating JWTs.
  • privateKey - (optional) The Private Key to be used when creating JWTs. You can specify the key as any of the following:
    • A Buffer containing the file contents.
    • A String containing the path to the key file on disk.
    • A String containing the key itself.

Testing

Run:

npm run test

changelog

(2025-01-10)

Bug Fixes

  • Add missing advanced machine detection mode (#947) (f2cc9c1)
  • create conversation was sending the request incorrectly (#967) (4b81d74)
  • incorrect http method for updating users (#953) (9f52bc5)
  • incorrect http method for updating users (#954) (bacbe72)
  • messages now using basic auth when requested (ac1f603)
  • send form request sending undefined form body (#966) (78b6199)
  • server-client no longer sends undefined query parameters (7d7fc08)
  • subaccounts: correct incorrect type on BalanceTransferParameters (#937) (70f9c25)
  • subaccounts: correct type on SubAccountCreateParameters (#940) (f7e7531)
  • user-to-user header was not being transformed to lisp case (#976) (f83aaf0)
  • video: Corrected video transition guide install instructions (68d3c3b)
  • video: Updated list of supported video APIs in transition guide (f98252f)

Features

4.0.0 (2024-05-24)

Bug Fixes

  • added missing type declration for node fetch (f927b8e)
  • adding rs256 as allowed algrothim (#914) (4e3bd8a)
  • auth: fixed passing in private key path (#920) (0dbb5d2)
  • decoding when charset is in the content type response header (#904) (aec47d6)
  • number-insights-v2: incorrect auth method (#909) (8fd3dcc)
  • outdated/wrong algorithm argument passed to jsonwebtoken (#907) (d5adb68)
  • sms: correct wrong status code for "partner account barred" (#895) (20ed3f2)
  • verify2: sms and silent auth updates (#908) (935a20c)
  • video: Make sure create session returned JSON, and fixed return type (#913) (28ac0df)
  • video: updated endpoints for adding/removing streams from Archive (#922) (9652cac)
  • voice: ncco encoding (#906) (9f2cfc8)

Features

  • add tss languages generate file from voice.json (#926) (a34e4dc)
  • conversations: added conversations package (#905) (e28f6b6)
  • messages: added new webhook, viber, and sms parameters (#921) (691a796)

3.10.1 (2023-11-12)

Bug Fixes

  • explicit_approval typeo in join type (#870) (66ea103)
  • Added dist folder to depcheck ignores (0b3e533)
  • Allow features to be searched in available numbers (#731) (5b4b201)
  • allow no filter when getting owned numbers, require filter when searching available numbers (#747) (ac80247)
  • applications: updating types for application package (#827) (2ff4e5a)
  • build: GHA install typescript and update NPM before running build commands (#737) (504be6a)
  • Correct our return types when sending SMS (#743) (7d9fc80)
  • Exported additional NCCO classes and interfaces that weren't before (#732) (a36ef9c)
  • Fixed issue with WA Template interface from older, incorrect spec (#730) (52de295)
  • jwt: Fix ttl in claims (#846) (54fccdc)
  • kebabecase api parameters (#802) (c71d424)
  • messages: Fixed README example (82570dd)
  • missing depedency for proactive connect (2ac48d3)
  • number paramters casing (#848) (73b4a68)
  • Numbers API was making JSON requests instead of form encoded requests (#734) (9c8e13d)
  • removed importHelpers compiler options (#786) (f07eff9)
  • restored append to user agent (#852) (dcab7ab)
  • Reverts back to ES6 and CommonJS for better Node compatibility (#777) (15503f9)
  • server-client not setting timeout parameter (b9efd8f)
  • server-client: Removing module declaration (d3930fc)
  • server-sdk: Fix links and SMS example (2dec8f9)
  • Set the proper content type when we send put/patch/post (#738) (02c303f)
  • timeout parameter being respected (#850) (52fae4a)
  • type for websocket header (#851) (8dd49dd)
  • types using node:http for import (#741) (e8e5dd6)
  • types: verify response types (#794) (888111d)
  • update packages after audit (#844) (8760b0f)
  • Verify - Added brand to seperate out from Sender ID (#744) (01bfdec)
  • verify2: check code not returning status (#823) (3e04e19)
  • verify2: missing "t" in the silent auth channel enum (#834) (565bcdd)
  • verify2: package json had incorrect main entry (#830) (9b48fb7)
  • verify: Added missing remapping for params (#782) (7fb20f2)
  • verify: import using lib folder (#803) (5530793)
  • video: Added SIP and DTMF playing (#776) (727027e)
  • video: Fix blank values on Dial API (#828) (14ec31f)
  • voice: Fixed response types on file downloads (#864) (0446638)
  • voice: Force NCCO actions to set value for NCCO type to avoid JS problems (#853) (6bce17b)

Features

3.0.0-beta.4 (2022-03-10)

Bug Fixes

  • add top level package-lock (a845782)
  • auth: add signed requests and req updates (887a776)

Features

  • numbers: Add Numbers module code (a78e9f0)
  • numbers: add numbers module) (82805e4)
  • sms: add sms module (4479d03)

3.0.0-beta.3 (2021-08-13)

3.0.0-beta.2 (2021-08-13)

3.0.0-beta.1 (2021-08-11)

3.0.0-beta.0 (2021-08-10)

3.0.1-beta.0 (2021-08-10)

2.10.2 (2020-10-05)

2.10.1 (2020-09-10)

2.9.1 (2020-08-17)

2.8.0 (2020-06-26)

2.4.2 (2019-09-07)

2.4.0 (2018-09-27)

2.2.1 (2018-04-29)

2.2.0 (2018-01-24)

2.1.2 (2018-01-11)

2.1.1 (2017-12-14)

2.0.2 (2017-03-22)

2.0.1 (2017-03-21)

2.0.0 (2017-03-20)