Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lifeomic/axios-fetch

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lifeomic/axios-fetch - npm Package Compare versions

Comparing version 2.0.3-pr-79-983716217-1624990782.0 to 2.0.3-pr-88-1317337924-1633629756.0

.eslintrc.json

16

package.json
{
"name": "@lifeomic/axios-fetch",
"version": "2.0.3-pr-79-983716217-1624990782.0",
"version": "2.0.3-pr-88-1317337924-1633629756.0",
"description": "A WebAPI Fetch implementation backed by an Axios client",

@@ -32,15 +32,15 @@ "main": "src/index.js",

"devDependencies": {
"@lifeomic/eslint-plugin-node": "^2.0.1",
"@lifeomic/eslint-config-standards": "^1.2.1",
"@types/lodash": "^4.14.175",
"@types/sinon": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"ava": "^3.15.0",
"axios": "0.21.1",
"axios": "0.22.0",
"coveralls": "^3.1.0",
"eslint": "^6.0.0",
"eslint": "^7.32.0",
"lodash": "^4.17.21",
"nock": "^11.3.3",
"nyc": "^15.0.0",
"sinon": "^10.0.1",
"ts-node": "^9.1.1",
"typescript": "^4.2.4"
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
},

@@ -47,0 +47,0 @@ "dependencies": {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildAxiosFetch = void 0;
const node_fetch_1 = require("node-fetch");
const form_data_1 = __importDefault(require("form-data"));
const typeUtils_1 = require("./typeUtils");
/**
* A Fetch WebAPI implementation based on the Axios client
*/
async function axiosFetch(axios,
// Convert the `fetch` style arguments into a Axios style config
transformer, input, init = {}) {
const rawHeaders = init.headers || {};
const axiosFetch = (axios, transformer = (config) => config) => async (input, init = {}) => {
const rawHeaders = (0, typeUtils_1.createAxiosHeaders)(init.headers);
const lowerCasedHeaders = Object.keys(rawHeaders)

@@ -25,5 +20,5 @@ .reduce((acc, key) => {

const rawConfig = {
url: input,
url: (0, typeUtils_1.getUrl)(input),
method: init.method || 'GET',
data: typeof init.body === 'undefined' || init.body instanceof form_data_1.default ? init.body : String(init.body),
data: init.body,
headers: lowerCasedHeaders,

@@ -34,5 +29,5 @@ // Force the response to an arraybuffer type. Without this, the Response

// NOTE: Don't use 'stream' because it's not supported in the browser
responseType: 'arraybuffer'
responseType: 'arraybuffer',
};
const config = transformer ? transformer(rawConfig, input, init) : rawConfig;
const config = transformer(rawConfig, input, init);
let result;

@@ -50,13 +45,12 @@ try {

}
const fetchHeaders = new node_fetch_1.Headers(result.headers);
return new node_fetch_1.Response(result.data, {
status: result.status,
statusText: result.statusText,
headers: fetchHeaders
headers: (0, typeUtils_1.createFetchHeaders)(result.headers),
});
}
};
function buildAxiosFetch(axios, transformer) {
return axiosFetch.bind(undefined, axios, transformer);
return axiosFetch(axios, transformer);
}
exports.buildAxiosFetch = buildAxiosFetch;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQSwyQ0FBK0Q7QUFDL0QsMERBQWlDO0FBY2pDOztHQUVHO0FBQ0gsS0FBSyxVQUFVLFVBQVUsQ0FDdkIsS0FBb0I7QUFDcEIsZ0VBQWdFO0FBQ2hFLFdBQThCLEVBQzlCLEtBQWMsRUFDZCxPQUFrQixFQUFFO0lBRXBCLE1BQU0sVUFBVSxHQUEyQixJQUFJLENBQUMsT0FBTyxJQUFJLEVBQUUsQ0FBQztJQUM5RCxNQUFNLGlCQUFpQixHQUFHLE1BQU0sQ0FBQyxJQUFJLENBQUMsVUFBVSxDQUFDO1NBQzlDLE1BQU0sQ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gPSBlcnIucmVzcG9uc2U7XG4gICAgfSBlbHNlIHtcbiAgICAgIHRocm93IGVycjtcbiAgICB9XG4gIH1cblxuICByZXR1cm4gbmV3IFJlc3BvbnNlKHJlc3VsdC5kYXRhLCB7XG4gICAgc3RhdHVzOiByZXN1bHQuc3RhdHVzLFxuICAgIHN0YXR1c1RleHQ6IHJlc3VsdC5zdGF0dXNUZXh0LFxuICAgIGhlYWRlcnM6IGNyZWF0ZUZldGNoSGVhZGVycyhyZXN1bHQuaGVhZGVycyksXG4gIH0pO1xufTtcblxuZXhwb3J0IGZ1bmN0aW9uIGJ1aWxkQXhpb3NGZXRjaCAoYXhpb3M6IEF4aW9zSW5zdGFuY2UsIHRyYW5zZm9ybWVyPzogQXhpb3NUcmFuc2Zvcm1lcik6IEF4aW9zRmV0Y2gge1xuICByZXR1cm4gYXhpb3NGZXRjaChheGlvcywgdHJhbnNmb3JtZXIpO1xufVxuIl19

@@ -1,15 +0,18 @@

import { Response, Headers as FetchHeaders } from 'node-fetch';
import FormData from 'form-data';
import { Response, RequestInit, RequestInfo } from 'node-fetch';
import { AxiosInstance, AxiosRequestConfig } from './types';
import { createFetchHeaders, createAxiosHeaders, getUrl } from './typeUtils';
export interface FetchInit extends Record<string, any> {
headers?: Record<string, string>;
method?: AxiosRequestConfig['method'];
body?: FormData | any;
export interface FetchInit extends Omit<RequestInit, 'body'> {
method?: string | AxiosRequestConfig['method'];
body?: RequestInit['body'] | Record<string, any>;
extra?: any;
}
export type AxiosTransformer = (config: AxiosRequestConfig, input: string | undefined, init: FetchInit) => AxiosRequestConfig;
export type AxiosTransformer = (
config: AxiosRequestConfig,
input?: RequestInfo,
init?: FetchInit,
) => AxiosRequestConfig;
export type AxiosFetch = (input?: string, init?: FetchInit) => Promise<Response>;
export type AxiosFetch = (input?: RequestInfo, init?: FetchInit) => Promise<Response>;

@@ -19,10 +22,10 @@ /**

*/
async function axiosFetch (
axios: AxiosInstance,
// Convert the `fetch` style arguments into a Axios style config
transformer?: AxiosTransformer,
input?: string,
init: FetchInit = {}
) {
const rawHeaders: Record<string, string> = init.headers || {};
const axiosFetch: (axios: AxiosInstance, transformer?: AxiosTransformer) => AxiosFetch = (
axios,
transformer = (config) => config,
) => async (
input,
init= {},
) => {
const rawHeaders: Record<string, string> = createAxiosHeaders(init.headers);
const lowerCasedHeaders = Object.keys(rawHeaders)

@@ -34,3 +37,3 @@ .reduce<Record<string, string>>(

},
{}
{},
);

@@ -43,5 +46,5 @@

const rawConfig: AxiosRequestConfig = {
url: input,
method: init.method || 'GET',
data: typeof init.body === 'undefined' || init.body instanceof FormData ? init.body : String(init.body),
url: getUrl(input),
method: (init.method as AxiosRequestConfig['method']) || 'GET',
data: init.body,
headers: lowerCasedHeaders,

@@ -52,6 +55,6 @@ // Force the response to an arraybuffer type. Without this, the Response

// NOTE: Don't use 'stream' because it's not supported in the browser
responseType: 'arraybuffer'
responseType: 'arraybuffer',
};
const config = transformer ? transformer(rawConfig, input, init) : rawConfig;
const config = transformer(rawConfig, input, init);

@@ -61,3 +64,3 @@ let result;

result = await axios.request(config);
} catch (err) {
} catch (err: any) {
if (err.response) {

@@ -70,13 +73,11 @@ result = err.response;

const fetchHeaders = new FetchHeaders(result.headers);
return new Response(result.data, {
status: result.status,
statusText: result.statusText,
headers: fetchHeaders
headers: createFetchHeaders(result.headers),
});
}
};
export function buildAxiosFetch (axios: AxiosInstance, transformer?: AxiosTransformer): AxiosFetch {
return axiosFetch.bind(undefined, axios, transformer);
return axiosFetch(axios, transformer);
}
"use strict";
// Copied and edited from axios@0.21.1 because types aren't available in version 0.17
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ0eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEscUZBQXFGIiwic291cmNlc0NvbnRlbnQiOlsiLy8gQ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Xhpb3NSZXF1ZXN0Q29uZmlnIHtcbiAgdXJsPzogc3RyaW5nO1xuICBtZXRob2Q/OiBNZXRob2Q7XG4gIGhlYWRlcnM/OiBhbnk7XG4gIGRhdGE/OiBhbnk7XG4gIHJlc3BvbnNlVHlwZT86IFJlc3BvbnNlVHlwZTtcbiAgW2tleTogc3RyaW5nXTogYW55O1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIEF4aW9zUmVzcG9uc2U8VCA9IGFueT4ge1xuICBkYXRhOiBUO1xuICBzdGF0dXM6IG51bWJlcjtcbiAgc3RhdHVzVGV4dDogc3RyaW5nO1xuICBoZWFkZXJzOiBhbnk7XG4gIGNvbmZpZzogQXhpb3NSZXF1ZXN0Q29uZmlnO1xuICByZXF1ZXN0PzogYW55O1xufVxuXG5leHBvcnQgaW50ZXJmYWNlIEF4aW9zRXJyb3I8VCA9IG5ldmVyPiBleHRlbmRzIEVycm9yIHtcbiAgY29uZmlnOiBBeGlvc1JlcXVlc3RDb25maWc7XG4gIGNvZGU/OiBzdHJpbmc7XG4gIHJlcXVlc3Q/OiBhbnk7XG4gIHJlc3BvbnNlPzogQXhpb3NSZXNwb25zZTxUPjtcbiAgaXNBeGlvc0Vycm9yOiBib29sZWFuO1xuICB0b0pTT046ICgpID0+IG9iamVjdDtcbn1cblxuZXhwb3J0IHR5cGUgQXhpb3NQcm9taXNlPFQgPSBhbnk+ID0gUHJvbWlzZTxBeGlvc1Jlc3BvbnNlPFQ+PiAmIGFueVxuXG5leHBvcnQgaW50ZXJmYWNlIEF4aW9zSW5zdGFuY2Uge1xuICByZXF1ZXN0PFQgPSBhbnk+KGNvbmZpZzogQXhpb3NSZXF1ZXN0Q29uZmlnKTogQXhpb3NQcm9taXNlPFQ+O1xufVxuIl19

@@ -41,2 +41,11 @@ // Copied and edited from axios@0.21.1 because types aren't available in version 0.17

export interface AxiosError<T = never> extends Error {
config: AxiosRequestConfig;
code?: string;
request?: any;
response?: AxiosResponse<T>;
isAxiosError: boolean;
toJSON: () => object;
}
export type AxiosPromise<T = any> = Promise<AxiosResponse<T>> & any

@@ -43,0 +52,0 @@

@@ -25,3 +25,4 @@ {

"src/**/*",
"bin/*"
"bin/*",
"test/**/*"
],

@@ -28,0 +29,0 @@ "exclude": [

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