@vonage/server-client
Advanced tools
Comparing version 1.10.2 to 1.10.3-0
@@ -39,2 +39,30 @@ import { Response } from 'node-fetch'; | ||
/** | ||
* 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. | ||
@@ -41,0 +69,0 @@ * |
@@ -76,20 +76,18 @@ "use strict"; | ||
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') { | ||
@@ -109,2 +107,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. | ||
@@ -111,0 +147,0 @@ * |
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "@vonage/server-client", | ||
"version": "1.10.2", | ||
"version": "1.10.3-0", | ||
"description": "The Vonage Server Client provides core functionalities for interacting with Vonage APIs, ensuring a standardized response regardless of the underlying HTTP adapter.", | ||
@@ -6,0 +6,0 @@ "homepage": "https://developer.vonage.com", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57407
1222
1