@vonage/server-client
Advanced tools
Comparing version 1.11.1 to 1.12.0-1
@@ -31,2 +31,3 @@ import { Response } from 'node-fetch'; | ||
constructor(credentials: AuthInterface | AuthParams, options?: ConfigParams); | ||
getConfig(): ConfigParams; | ||
/** | ||
@@ -40,2 +41,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. | ||
@@ -42,0 +71,0 @@ * |
@@ -63,2 +63,5 @@ "use strict"; | ||
} | ||
getConfig() { | ||
return this.config; | ||
} | ||
/** | ||
@@ -75,22 +78,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 supportedfor 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') { | ||
@@ -110,2 +114,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. | ||
@@ -112,0 +154,0 @@ * |
@@ -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,9 +21,17 @@ */ | ||
/** | ||
* @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" | ||
} |
@@ -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,9 +25,17 @@ */ | ||
/** | ||
* @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 = {})); |
{ | ||
"$schema": "https://json.schemastore.org/package.json", | ||
"name": "@vonage/server-client", | ||
"version": "1.11.1", | ||
"version": "1.12.0-1", | ||
"description": "The Vonage Server Client provides core functionalities for interacting with Vonage APIs, ensuring a standardized response regardless of the underlying HTTP adapter.", | ||
@@ -40,4 +40,3 @@ "homepage": "https://developer.vonage.com", | ||
"dependencies": { | ||
"@vonage/auth": "^1.9.1", | ||
"@vonage/conversations": "1.1.1", | ||
"@vonage/auth": "^1.10.0", | ||
"@vonage/vetch": "^1.7.1", | ||
@@ -44,0 +43,0 @@ "debug": "^4.3.4", |
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
58725
9
1266
1
- Removed@vonage/conversations@1.1.1
- Removed@types/debug@4.1.12(transitive)
- Removed@types/ms@0.7.34(transitive)
- Removed@vonage/conversations@1.1.1(transitive)
- Removed@vonage/messages@1.16.0(transitive)
- Removed@vonage/server-client@1.14.0(transitive)
- Removed@vonage/users@1.8.0(transitive)
- Removed@vonage/voice@1.14.0(transitive)
- Removedts-xor@1.3.0(transitive)
Updated@vonage/auth@^1.10.0