New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@evervault/sdk

Package Overview
Dependencies
Maintainers
0
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evervault/sdk - npm Package Compare versions

Comparing version 6.2.1 to 6.2.2

108

lib/core/http.js
const { errors, Datatypes } = require('../utils');
const phin = require('phin');
const axios = require('axios');

@@ -32,3 +32,3 @@ /**

return phin({
return axios({
url:

@@ -41,3 +41,3 @@ path.startsWith('https://') || path.startsWith('http://')

data,
parse,
validateStatus: (status) => true,
});

@@ -65,4 +65,4 @@ };

const response = await makeGetRequestWithRetry(getCagesKeyCallback);
if (response.statusCode >= 200 && response.statusCode < 300) {
return response.body;
if (response.status >= 200 && response.status < 300) {
return response.data;
}

@@ -83,4 +83,4 @@ throw errors.mapResponseCodeToError(response);

const response = await makeGetRequestWithRetry(getAppKeyCallback);
if (response.statusCode >= 200 && response.statusCode < 300) {
return response.body;
if (response.status >= 200 && response.status < 300) {
return response.data;
}

@@ -90,21 +90,10 @@ };

const getCert = async () => {
const response = await phin({
url: config.certHostname,
method: 'GET',
parse: 'cer',
})
.catch(() => {
// Blindly retry
return phin({
url: config.certHostname,
method: 'GET',
parse: 'cer',
});
})
.catch((err) => {
throw new errors.EvervaultError(
`Unable to download cert from ${config.certHostname} (${err.message})`
);
});
return response.body;
const response = await makeGetRequestWithRetry(async () =>
axios(config.certHostname)
).catch((err) => {
throw new errors.EvervaultError(
`Unable to download cert from ${config.certHostname} (${err.message})`
);
});
return response.data;
};

@@ -116,21 +105,10 @@

}/.well-known/attestation`;
const response = await phin({
url,
method: 'GET',
parse: 'json',
})
.catch(() => {
// Blindly retry
return phin({
url,
method: 'GET',
parse: 'json',
});
})
.catch((err) => {
throw new errors.EvervaultError(
`Unable to download attestation doc from ${url} (${err.message})`
);
});
return response.body;
const response = await makeGetRequestWithRetry(async () =>
axios(url)
).catch((err) => {
throw new errors.EvervaultError(
`Unable to download attestation doc from ${url} (${err.message})`
);
});
return response.data;
};

@@ -144,3 +122,3 @@

});
if (response.statusCode >= 200 && response.statusCode < 300) {
if (response.status >= 200 && response.status < 300) {
const pollIntervalHeaderValue = response.headers['x-poll-interval'];

@@ -151,3 +129,3 @@ return {

: parseFloat(pollIntervalHeaderValue),
data: response.body,
data: response.data,
};

@@ -170,4 +148,4 @@ }

if (response.statusCode >= 200 && response.statusCode < 300) {
const responseBody = response.body;
if (response.status >= 200 && response.status < 300) {
const responseBody = response.data;
if (responseBody.status === 'success') {

@@ -179,3 +157,3 @@ return response;

const responseBody = response.body;
const responseBody = response.data;
throw errors.mapApiResponseToError(responseBody);

@@ -206,3 +184,9 @@ };

try {
return await requestCallback();
return await requestCallback().then((response) => {
if (response.status < 200 || response.status >= 300) {
throw new errors.EvervaultError('Unknown error occured');
} else {
return response;
}
});
} catch (e) {

@@ -240,12 +224,12 @@ retryCount++;

);
if (response.statusCode >= 200 && response.statusCode < 300) {
if (response.status >= 200 && response.status < 300) {
if (contentType === 'application/json') {
const { data } = JSON.parse(response.body);
const { data } = response.data;
return data;
}
return response.body;
return response.data;
}
const resBody = Buffer.isBuffer(response.body)
? JSON.parse(response.body.toString())
: response.body;
const resBody = Buffer.isBuffer(response.data)
? JSON.parse(response.data.toString())
: response.data;
throw errors.mapApiResponseToError(resBody);

@@ -288,10 +272,10 @@ };

);
if (response.statusCode >= 200 && response.statusCode < 300) {
if (response.status >= 200 && response.status < 300) {
return {
...response.body,
createdAt: new Date(response.body.createdAt),
expiry: new Date(response.body.expiry),
...response.data,
createdAt: new Date(response.data.createdAt),
expiry: new Date(response.data.expiry),
};
}
throw errors.mapApiResponseToError(response.body);
throw errors.mapApiResponseToError(response.data);
};

@@ -298,0 +282,0 @@

@@ -386,6 +386,6 @@ const crypto = require('crypto');

);
return response.body;
return response.data;
} else {
const response = await this.http.runFunction(functionName, payload);
return response.body;
return response.data;
}

@@ -405,3 +405,3 @@ }

const response = await this.http.createRunToken(functionName, payload);
return response.body;
return response.data;
}

@@ -408,0 +408,0 @@

@@ -63,14 +63,14 @@ class EvervaultError extends Error {

const mapResponseCodeToError = ({ statusCode, body, headers }) => {
if (statusCode === 401)
const mapResponseCodeToError = ({ status, data, headers }) => {
if (status === 401)
return new EvervaultError('Invalid authorization provided.');
if (
statusCode === 403 &&
status === 403 &&
headers['x-evervault-error-code'] === 'forbidden-ip-error'
) {
return new EvervaultError(
body.message || "IP is not present on the invoked Enclave's whitelist."
data.message || "IP is not present on the invoked Enclave's whitelist."
);
}
if (statusCode === 403) {
if (status === 403) {
return new EvervaultError(

@@ -80,9 +80,9 @@ 'The API key provided does not have the required permissions.'

}
if (statusCode === 422) {
return new EvervaultError(body.message || 'Unable to decrypt data.');
if (status === 422) {
return new EvervaultError(data.message || 'Unable to decrypt data.');
}
if (body.message) {
return new EvervaultError(body.message);
if (data.message) {
return new EvervaultError(data.message);
}
return new EvervaultError(`Request returned with status [${statusCode}]`);
return new EvervaultError(`Request returned with status [${status}]`);
};

@@ -89,0 +89,0 @@

{
"name": "@evervault/sdk",
"version": "6.2.1",
"version": "6.2.2",
"description": "Node.js SDK for Evervault",

@@ -43,3 +43,2 @@ "main": "lib/index.js",

"crc-32": "^1.2.2",
"phin": "^3.5.0",
"uuid": "^8.1.0"

@@ -46,0 +45,0 @@ },

declare function _exports(appUuid: string, apiKey: string, config: import('../types').HttpConfig): {
getCageKey: () => Promise<any>;
getAppKey: () => Promise<any>;
runFunction: (functionName: any, payload: any) => Promise<phin.IJSONResponse<any>>;
runFunction: (functionName: any, payload: any) => Promise<any>;
getCert: () => Promise<any>;
createRunToken: (functionName: any, payload: any) => Promise<phin.IJSONResponse<any>>;
createRunToken: (functionName: any, payload: any) => any;
getRelayOutboundConfig: () => Promise<{

@@ -16,2 +16,1 @@ pollInterval: number;

export = _exports;
import phin = require("phin");

@@ -14,5 +14,5 @@ export let Crypto: (config: import("../types").CurveConfig) => {

getAppKey: () => Promise<any>;
runFunction: (functionName: any, payload: any) => Promise<import("phin").IJSONResponse<any>>;
runFunction: (functionName: any, payload: any) => Promise<any>;
getCert: () => Promise<any>;
createRunToken: (functionName: any, payload: any) => Promise<import("phin").IJSONResponse<any>>;
createRunToken: (functionName: any, payload: any) => any;
getRelayOutboundConfig: () => Promise<{

@@ -19,0 +19,0 @@ pollInterval: number;

@@ -9,5 +9,5 @@ export class EvervaultError extends Error {

}): never;
export function mapResponseCodeToError({ statusCode, body, headers }: {
statusCode: any;
body: any;
export function mapResponseCodeToError({ status, data, headers }: {
status: any;
data: any;
headers: any;

@@ -14,0 +14,0 @@ }): EvervaultError;

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