Socket
Socket
Sign inDemoInstall

@vonage/server-client

Package Overview
Dependencies
Maintainers
43
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vonage/server-client - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

29

dist/lib/client.d.ts

@@ -36,2 +36,3 @@ import { Response } from 'node-fetch';

constructor(credentials: AuthInterface | AuthParams, options?: ConfigParams);
getConfig(): ConfigParams;
/**

@@ -45,2 +46,30 @@ * Adds the appropriate authentication headers or parameters to the request based on the authentication type.

/**
* Adds API key and secret to the request body.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
protected addQueryKeySecretToRequestBody(request: VetchOptions): Promise<VetchOptions>;
/**
* Adds API key and secret to the request.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
protected addQueryKeySecretToRequest(request: VetchOptions): Promise<VetchOptions>;
/**
* Adds a JWT to the request.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
protected addJWTToRequest(request: VetchOptions): Promise<VetchOptions>;
/**
* Adds basic authentication headers to the request.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
protected addBasicAuthToRequest(request: VetchOptions): Promise<VetchOptions>;
/**
* Sends a DELETE request to the specified URL.

@@ -47,0 +76,0 @@ *

75

dist/lib/client.js

@@ -57,2 +57,5 @@ "use strict";

}
getConfig() {
return this.config;
}
/**

@@ -69,22 +72,23 @@ * Adds the appropriate authentication headers or parameters to the request based on the authentication type.

}
if ([enums_1.AuthenticationType.OAUTH2, enums_1.AuthenticationType.CIBA].includes(this.authType)) {
throw new Error('OAuth2 and CIBA authentication is not supported for this Client');
}
switch (this.authType) {
case enums_1.AuthenticationType.BASIC:
request.headers = Object.assign({}, request.headers, {
Authorization: await this.auth.createBasicHeader(),
});
return request;
return this.addBasicAuthToRequest(request);
case enums_1.AuthenticationType.JWT:
request.headers = Object.assign({}, request.headers, {
Authorization: await this.auth.createBearerHeader(),
});
return request;
return this.addJWTToRequest(request);
case enums_1.AuthenticationType.QUERY_KEY_SECRET:
return this.addQueryKeySecretToRequest(request);
default:
return this.addQueryKeySecretToRequestBody(request);
}
if (this.authType === enums_1.AuthenticationType.QUERY_KEY_SECRET) {
log('adding parameters to query string');
request.params = {
...(request.params ? request.params : {}),
...(await this.auth.getQueryParams({})),
};
return request;
}
}
/**
* Adds API key and secret to the request body.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
async addQueryKeySecretToRequestBody(request) {
if (typeof request.data === 'string') {

@@ -104,2 +108,40 @@ throw new Error('Cannot append auth parameters to body');

/**
* Adds API key and secret to the request.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
async addQueryKeySecretToRequest(request) {
log('adding parameters to query string');
request.params = {
...(request.params ? request.params : {}),
...(await this.auth.getQueryParams({})),
};
return request;
}
/**
* Adds a JWT to the request.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
async addJWTToRequest(request) {
request.headers = Object.assign({}, request.headers, {
Authorization: await this.auth.createBearerHeader(),
});
return request;
}
/**
* Adds basic authentication headers to the request.
*
* @param {VetchOptions} request - The request options to which authentication needs to be added.
* @return {VetchOptions} - The request options with the added authentication.
*/
async addBasicAuthToRequest(request) {
request.headers = Object.assign({}, request.headers, {
Authorization: await this.auth.createBasicHeader(),
});
return request;
}
/**
* Sends a DELETE request to the specified URL.

@@ -255,2 +297,3 @@ *

request = await this.addAuthenticationToRequest(request);
log('Request prepared', request);
const url = new URL(request.url);

@@ -257,0 +300,0 @@ const params = new URLSearchParams(request.params);

@@ -7,11 +7,11 @@ /**

/**
* @description Basic authentication using a base64-encoded string.
* Basic authentication using a base64-encoded string.
*/
BASIC = "basic",
/**
* @description JSON Web Token (JWT) authentication.
* JSON Web Token (JWT) authentication.
*/
JWT = "jwt",
/**
* @description Authentication using both API key and secret in the request body.
* Authentication using both API key and secret in the request body.
* @deprecated This method is deprecated.

@@ -21,10 +21,18 @@ */

/**
* @description Authentication using API key and secret in the query parameters.
* Authentication using API key and secret in the query parameters.
*/
QUERY_KEY_SECRET = "query_key_secret",
/**
* @description HMAC signature-based authentication.
* HMAC signature-based authentication.
*/
SIGNATURE = "signature"
SIGNATURE = "signature",
/**
* CIBA authentication
*/
CIBA = "ciba",
/**
* OAuth2 authentication.
*/
OAUTH2 = "oauth2"
}
//# sourceMappingURL=AuthenticationType.d.ts.map

@@ -11,11 +11,11 @@ "use strict";

/**
* @description Basic authentication using a base64-encoded string.
* Basic authentication using a base64-encoded string.
*/
AuthenticationType["BASIC"] = "basic";
/**
* @description JSON Web Token (JWT) authentication.
* JSON Web Token (JWT) authentication.
*/
AuthenticationType["JWT"] = "jwt";
/**
* @description Authentication using both API key and secret in the request body.
* Authentication using both API key and secret in the request body.
* @deprecated This method is deprecated.

@@ -25,10 +25,18 @@ */

/**
* @description Authentication using API key and secret in the query parameters.
* Authentication using API key and secret in the query parameters.
*/
AuthenticationType["QUERY_KEY_SECRET"] = "query_key_secret";
/**
* @description HMAC signature-based authentication.
* HMAC signature-based authentication.
*/
AuthenticationType["SIGNATURE"] = "signature";
/**
* CIBA authentication
*/
AuthenticationType["CIBA"] = "ciba";
/**
* OAuth2 authentication.
*/
AuthenticationType["OAUTH2"] = "oauth2";
})(AuthenticationType || (exports.AuthenticationType = AuthenticationType = {}));
//# sourceMappingURL=AuthenticationType.js.map
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@vonage/server-client",
"version": "1.13.0",
"version": "1.14.0",
"description": "The Vonage Server Client provides core functionalities for interacting with Vonage APIs, ensuring a standardized response regardless of the underlying HTTP adapter.",

@@ -40,3 +40,3 @@ "homepage": "https://developer.vonage.com",

"dependencies": {
"@vonage/auth": "^1.11.0",
"@vonage/auth": "^1.12.0",
"@vonage/vetch": "^1.8.0",

@@ -43,0 +43,0 @@ "debug": "^4.3.4",

@@ -1,2 +0,2 @@

# Vonage Auth SDK for Node.js
# Vonage Server Client SDK for Node.js

@@ -3,0 +3,0 @@ ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/vonage/vonage-node-sdk/ci.yml?branch=3.x) [![Codecov](https://img.shields.io/codecov/c/github/vonage/vonage-node-sdk?label=Codecov&logo=codecov&style=flat-square)](https://codecov.io/gh/Vonage/vonage-server-sdk) ![Latest Release](https://img.shields.io/npm/v/@vonage/server-client?label=%40vonage%2Fserver-client&style=flat-square) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg?style=flat-square)](../../CODE_OF_CONDUCT.md) [![License](https://img.shields.io/npm/l/@vonage/accounts?label=License&style=flat-square)][license]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc