@ledgerhq/live-network
Advanced tools
Comparing version 1.4.1-nightly.4 to 2.0.0-nightly.5
# @ledgerhq/live-network | ||
## 2.0.0-nightly.5 | ||
### Major Changes | ||
- [#7593](https://github.com/LedgerHQ/ledger-live/pull/7593) [`187293c`](https://github.com/LedgerHQ/ledger-live/commit/187293c6cf6093f15f07d5effc1ded0843a9e6ab) Thanks [@lambertkevin](https://github.com/lambertkevin)! - Migrate to axios version 1.7.3 | ||
### Patch Changes | ||
- [#7593](https://github.com/LedgerHQ/ledger-live/pull/7593) [`187293c`](https://github.com/LedgerHQ/ledger-live/commit/187293c6cf6093f15f07d5effc1ded0843a9e6ab) Thanks [@lambertkevin](https://github.com/lambertkevin)! - Update `axios` to fixed version `1.7.3` | ||
## 1.4.1-nightly.4 | ||
@@ -4,0 +14,0 @@ |
@@ -1,16 +0,21 @@ | ||
import { AxiosPromise, AxiosResponse, type AxiosError, type AxiosRequestConfig } from "axios"; | ||
import { type AxiosPromise, type AxiosResponse, type InternalAxiosRequestConfig, type AxiosError, type AxiosRequestConfig } from "axios"; | ||
type Metadata = { | ||
startTime: number; | ||
}; | ||
type ExtendedXHRConfig = AxiosRequestConfig & { | ||
type ExtendedAxiosRequestConfig = InternalAxiosRequestConfig & { | ||
metadata?: Metadata; | ||
}; | ||
export declare const requestInterceptor: (request: AxiosRequestConfig) => ExtendedXHRConfig; | ||
type InterceptedResponse = { | ||
config: ExtendedXHRConfig; | ||
} & AxiosResponse<any>; | ||
export declare const responseInterceptor: (response: InterceptedResponse) => InterceptedResponse; | ||
type InterceptedError = { | ||
export declare const requestInterceptor: (request: ExtendedAxiosRequestConfig) => ExtendedAxiosRequestConfig; | ||
type ExtendedAxiosResponse = AxiosResponse & { | ||
config: { | ||
metadata?: Metadata; | ||
}; | ||
}; | ||
export declare const responseInterceptor: (response: ExtendedAxiosResponse) => ExtendedAxiosResponse; | ||
type InterceptedResponse = AxiosResponse & { | ||
config: ExtendedAxiosRequestConfig; | ||
}; | ||
type InterceptedError = AxiosError & { | ||
response?: InterceptedResponse; | ||
} & AxiosError<any>; | ||
}; | ||
export declare const errorInterceptor: (error: InterceptedError) => InterceptedError; | ||
@@ -17,0 +22,0 @@ export type LiveNetworkRequest<T> = { |
@@ -22,7 +22,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
log("network", `${method} ${baseURL || ""}${url}`, { data }); | ||
const req = request; | ||
req.metadata = { | ||
request.metadata = { | ||
startTime: Date.now(), | ||
}; | ||
return req; | ||
return request; | ||
}; | ||
@@ -33,3 +32,3 @@ export const responseInterceptor = (response) => { | ||
} | ||
const { baseURL, url, method = "", metadata } = response.config; | ||
const { baseURL, url, method, metadata } = response.config; | ||
const { startTime = 0 } = metadata || {}; | ||
@@ -36,0 +35,0 @@ log("network-success", `${response.status} ${method} ${baseURL || ""}${url} (${(Date.now() - startTime).toFixed(0)}ms)`, { data: response.data }); |
@@ -10,3 +10,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import axios from "axios"; | ||
import axios, { AxiosHeaders } from "axios"; | ||
import { getEnv, setEnv } from "@ledgerhq/live-env"; | ||
@@ -33,2 +33,3 @@ import network, { requestInterceptor, responseInterceptor } from "./network"; | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -44,2 +45,3 @@ const req = requestInterceptor(request); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -56,2 +58,3 @@ const req = requestInterceptor(request); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -69,2 +72,3 @@ requestInterceptor(request); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
@@ -74,3 +78,3 @@ data: "data", | ||
statusText: "OK", | ||
headers: {}, | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -87,7 +91,8 @@ const res = responseInterceptor(response); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
headers: new AxiosHeaders(), | ||
data: "data", | ||
status: 200, | ||
statusText: "OK", | ||
headers: {}, | ||
}; | ||
@@ -105,7 +110,8 @@ const res = responseInterceptor(response); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
headers: new AxiosHeaders(), | ||
data: "data", | ||
status: 200, | ||
statusText: "OK", | ||
headers: {}, | ||
}; | ||
@@ -121,2 +127,3 @@ responseInterceptor(response); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
@@ -126,3 +133,3 @@ data: "data", | ||
statusText: "Error", | ||
headers: {}, | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -129,0 +136,0 @@ try { |
@@ -1,16 +0,21 @@ | ||
import { AxiosPromise, AxiosResponse, type AxiosError, type AxiosRequestConfig } from "axios"; | ||
import { type AxiosPromise, type AxiosResponse, type InternalAxiosRequestConfig, type AxiosError, type AxiosRequestConfig } from "axios"; | ||
type Metadata = { | ||
startTime: number; | ||
}; | ||
type ExtendedXHRConfig = AxiosRequestConfig & { | ||
type ExtendedAxiosRequestConfig = InternalAxiosRequestConfig & { | ||
metadata?: Metadata; | ||
}; | ||
export declare const requestInterceptor: (request: AxiosRequestConfig) => ExtendedXHRConfig; | ||
type InterceptedResponse = { | ||
config: ExtendedXHRConfig; | ||
} & AxiosResponse<any>; | ||
export declare const responseInterceptor: (response: InterceptedResponse) => InterceptedResponse; | ||
type InterceptedError = { | ||
export declare const requestInterceptor: (request: ExtendedAxiosRequestConfig) => ExtendedAxiosRequestConfig; | ||
type ExtendedAxiosResponse = AxiosResponse & { | ||
config: { | ||
metadata?: Metadata; | ||
}; | ||
}; | ||
export declare const responseInterceptor: (response: ExtendedAxiosResponse) => ExtendedAxiosResponse; | ||
type InterceptedResponse = AxiosResponse & { | ||
config: ExtendedAxiosRequestConfig; | ||
}; | ||
type InterceptedError = AxiosError & { | ||
response?: InterceptedResponse; | ||
} & AxiosError<any>; | ||
}; | ||
export declare const errorInterceptor: (error: InterceptedError) => InterceptedError; | ||
@@ -17,0 +22,0 @@ export type LiveNetworkRequest<T> = { |
@@ -28,7 +28,6 @@ "use strict"; | ||
(0, logs_1.log)("network", `${method} ${baseURL || ""}${url}`, { data }); | ||
const req = request; | ||
req.metadata = { | ||
request.metadata = { | ||
startTime: Date.now(), | ||
}; | ||
return req; | ||
return request; | ||
}; | ||
@@ -40,3 +39,3 @@ exports.requestInterceptor = requestInterceptor; | ||
} | ||
const { baseURL, url, method = "", metadata } = response.config; | ||
const { baseURL, url, method, metadata } = response.config; | ||
const { startTime = 0 } = metadata || {}; | ||
@@ -43,0 +42,0 @@ (0, logs_1.log)("network-success", `${response.status} ${method} ${baseURL || ""}${url} (${(Date.now() - startTime).toFixed(0)}ms)`, { data: response.data }); |
@@ -34,7 +34,4 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const axios_1 = __importDefault(require("axios")); | ||
const axios_1 = __importStar(require("axios")); | ||
const live_env_1 = require("@ledgerhq/live-env"); | ||
@@ -61,2 +58,3 @@ const network_1 = __importStar(require("./network")); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}; | ||
@@ -72,2 +70,3 @@ const req = (0, network_1.requestInterceptor)(request); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}; | ||
@@ -84,2 +83,3 @@ const req = (0, network_1.requestInterceptor)(request); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}; | ||
@@ -97,2 +97,3 @@ (0, network_1.requestInterceptor)(request); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}, | ||
@@ -102,3 +103,3 @@ data: "data", | ||
statusText: "OK", | ||
headers: {}, | ||
headers: new axios_1.AxiosHeaders(), | ||
}; | ||
@@ -115,7 +116,8 @@ const res = (0, network_1.responseInterceptor)(response); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}, | ||
headers: new axios_1.AxiosHeaders(), | ||
data: "data", | ||
status: 200, | ||
statusText: "OK", | ||
headers: {}, | ||
}; | ||
@@ -133,7 +135,8 @@ const res = (0, network_1.responseInterceptor)(response); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}, | ||
headers: new axios_1.AxiosHeaders(), | ||
data: "data", | ||
status: 200, | ||
statusText: "OK", | ||
headers: {}, | ||
}; | ||
@@ -149,2 +152,3 @@ (0, network_1.responseInterceptor)(response); | ||
data: "data", | ||
headers: new axios_1.AxiosHeaders(), | ||
}, | ||
@@ -154,3 +158,3 @@ data: "data", | ||
statusText: "Error", | ||
headers: {}, | ||
headers: new axios_1.AxiosHeaders(), | ||
}; | ||
@@ -157,0 +161,0 @@ try { |
{ | ||
"name": "@ledgerhq/live-network", | ||
"version": "1.4.1-nightly.4", | ||
"version": "2.0.0-nightly.5", | ||
"description": "Ledger Live network and cache utilities", | ||
@@ -65,3 +65,3 @@ "keywords": [ | ||
"dependencies": { | ||
"axios": "0.26.1", | ||
"axios": "1.7.3", | ||
"lru-cache": "^7.14.1", | ||
@@ -68,0 +68,0 @@ "@ledgerhq/errors": "^6.19.0-nightly.2", |
@@ -1,2 +0,2 @@ | ||
import axios from "axios"; | ||
import axios, { AxiosHeaders } from "axios"; | ||
import { getEnv, setEnv } from "@ledgerhq/live-env"; | ||
@@ -29,2 +29,3 @@ import network, { requestInterceptor, responseInterceptor } from "./network"; | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -42,2 +43,3 @@ const req = requestInterceptor(request); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -60,2 +62,3 @@ const req = requestInterceptor(request); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -75,2 +78,3 @@ requestInterceptor(request); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
@@ -80,3 +84,3 @@ data: "data", | ||
statusText: "OK", | ||
headers: {}, | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -95,7 +99,8 @@ const res = responseInterceptor(response); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
headers: new AxiosHeaders(), | ||
data: "data", | ||
status: 200, | ||
statusText: "OK", | ||
headers: {}, | ||
}; | ||
@@ -116,7 +121,8 @@ const res = responseInterceptor(response); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
headers: new AxiosHeaders(), | ||
data: "data", | ||
status: 200, | ||
statusText: "OK", | ||
headers: {}, | ||
}; | ||
@@ -134,2 +140,3 @@ responseInterceptor(response); | ||
data: "data", | ||
headers: new AxiosHeaders(), | ||
}, | ||
@@ -139,3 +146,3 @@ data: "data", | ||
statusText: "Error", | ||
headers: {}, | ||
headers: new AxiosHeaders(), | ||
}; | ||
@@ -142,0 +149,0 @@ |
import axios, { | ||
AxiosPromise, | ||
AxiosResponse, | ||
type AxiosPromise, | ||
type AxiosResponse, | ||
type InternalAxiosRequestConfig, | ||
type AxiosError, | ||
type AxiosRequestConfig, | ||
type Method, | ||
} from "axios"; | ||
@@ -14,5 +14,7 @@ import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from "@ledgerhq/errors"; | ||
type Metadata = { startTime: number }; | ||
type ExtendedXHRConfig = AxiosRequestConfig & { metadata?: Metadata }; | ||
type ExtendedAxiosRequestConfig = InternalAxiosRequestConfig & { metadata?: Metadata }; | ||
export const requestInterceptor = (request: AxiosRequestConfig): ExtendedXHRConfig => { | ||
export const requestInterceptor = ( | ||
request: ExtendedAxiosRequestConfig, | ||
): ExtendedAxiosRequestConfig => { | ||
if (!getEnv("ENABLE_NETWORK_LOGS")) { | ||
@@ -25,16 +27,12 @@ return request; | ||
const req: ExtendedXHRConfig = request; | ||
req.metadata = { | ||
request.metadata = { | ||
startTime: Date.now(), | ||
}; | ||
return req; | ||
return request; | ||
}; | ||
type InterceptedResponse = { | ||
config: ExtendedXHRConfig; | ||
} & AxiosResponse<any>; | ||
type ExtendedAxiosResponse = AxiosResponse & { config: { metadata?: Metadata } }; | ||
export const responseInterceptor = (response: InterceptedResponse): InterceptedResponse => { | ||
export const responseInterceptor = (response: ExtendedAxiosResponse): ExtendedAxiosResponse => { | ||
if (!getEnv("ENABLE_NETWORK_LOGS")) { | ||
@@ -44,3 +42,3 @@ return response; | ||
const { baseURL, url, method = "", metadata } = response.config; | ||
const { baseURL, url, method, metadata } = response.config; | ||
const { startTime = 0 } = metadata || {}; | ||
@@ -59,5 +57,8 @@ | ||
type InterceptedError = { | ||
type InterceptedResponse = AxiosResponse & { | ||
config: ExtendedAxiosRequestConfig; | ||
}; | ||
type InterceptedError = AxiosError & { | ||
response?: InterceptedResponse; | ||
} & AxiosError<any>; | ||
}; | ||
@@ -67,3 +68,3 @@ export const errorInterceptor = (error: InterceptedError): InterceptedError => { | ||
if (!config) throw error; | ||
const { baseURL, url, method = "", metadata } = config; | ||
const { baseURL, url, method = "", metadata } = config as ExtendedAxiosRequestConfig; | ||
const { startTime = 0 } = metadata || {}; | ||
@@ -125,3 +126,3 @@ | ||
const makeError = (msg: string, status: number, url: string | undefined, method: Method | "") => { | ||
const makeError = (msg: string, status: number, url: string | undefined, method: string) => { | ||
const obj = { | ||
@@ -128,0 +129,0 @@ status, |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
130707
1822
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@1.7.3(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
- Removedaxios@0.26.1(transitive)
Updatedaxios@1.7.3