@ledgerhq/live-network
Advanced tools
Comparing version 1.1.0 to 1.1.1-next.0
module.exports = { | ||
parser: "@typescript-eslint/parser", | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
jest: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
overrides: [ | ||
{ | ||
files: ["src/**/*.test.{ts,tsx}"], | ||
env: { | ||
"jest/globals": true, | ||
}, | ||
plugins: ["jest"], | ||
}, | ||
], | ||
globals: { | ||
Atomics: "readonly", | ||
SharedArrayBuffer: "readonly", | ||
}, | ||
plugins: ["@typescript-eslint", "prettier"], | ||
rules: { | ||
"no-console": ["error", { allow: ["warn", "error"] }], | ||
"linebreak-style": ["error", "unix"], | ||
semi: ["error", "always"], | ||
"no-unused-vars": "off", | ||
"import/prefer-default-export": 0, | ||
"no-plusplus": 0, | ||
"no-underscore-dangle": 0, | ||
"prefer-template": 0, | ||
"no-await-in-loop": 0, | ||
"no-restricted-syntax": 0, | ||
"consistent-return": 0, | ||
"no-lonely-if": 0, | ||
"no-use-before-define": 0, | ||
"no-nested-ternary": 0, | ||
"import/no-cycle": 0, | ||
"no-multi-assign": 0, | ||
"guard-for-in": 0, | ||
"no-continue": 0, | ||
"lines-between-class-members": 0, | ||
"prefer-destructuring": 0, | ||
"prettier/prettier": "error", | ||
"@typescript-eslint/no-use-before-define": "off", | ||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-namespace": ["error", { allowDeclarations: true }], | ||
"@typescript-eslint/no-explicit-any": 0, | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
extendDefaults: true, | ||
types: { | ||
"{}": false, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
# @ledgerhq/live-network | ||
## 1.1.1-next.0 | ||
### Patch Changes | ||
- Updated dependencies [[`9adc1862dd`](https://github.com/LedgerHQ/ledger-live/commit/9adc1862dda605a722d19f3b6895bd324834c914)]: | ||
- @ledgerhq/errors@6.12.7-next.0 | ||
## 1.1.0 | ||
@@ -4,0 +11,0 @@ |
@@ -31,3 +31,3 @@ import LRU from "lru-cache"; | ||
return promise; | ||
promise = f(...args).catch((e) => { | ||
promise = f(...args).catch(e => { | ||
cache.delete(key); | ||
@@ -41,3 +41,3 @@ throw e; | ||
const key = keyExtractor(...args); | ||
const promise = f(...args).catch((e) => { | ||
const promise = f(...args).catch(e => { | ||
cache.delete(key); | ||
@@ -44,0 +44,0 @@ throw e; |
@@ -144,3 +144,3 @@ import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from "@ledgerhq/errors"; | ||
setAxiosLedgerClientVersionHeader(getEnv("LEDGER_CLIENT_VERSION")); | ||
changes.subscribe((e) => { | ||
changes.subscribe(e => { | ||
if (e.name === "LEDGER_CLIENT_VERSION") { | ||
@@ -147,0 +147,0 @@ setAxiosLedgerClientVersionHeader(e.value); |
@@ -37,3 +37,3 @@ "use strict"; | ||
return promise; | ||
promise = f(...args).catch((e) => { | ||
promise = f(...args).catch(e => { | ||
cache.delete(key); | ||
@@ -47,3 +47,3 @@ throw e; | ||
const key = keyExtractor(...args); | ||
const promise = f(...args).catch((e) => { | ||
const promise = f(...args).catch(e => { | ||
cache.delete(key); | ||
@@ -50,0 +50,0 @@ throw e; |
@@ -153,3 +153,3 @@ "use strict"; | ||
setAxiosLedgerClientVersionHeader((0, live_env_1.getEnv)("LEDGER_CLIENT_VERSION")); | ||
live_env_1.changes.subscribe((e) => { | ||
live_env_1.changes.subscribe(e => { | ||
if (e.name === "LEDGER_CLIENT_VERSION") { | ||
@@ -156,0 +156,0 @@ setAxiosLedgerClientVersionHeader(e.value); |
{ | ||
"name": "@ledgerhq/live-network", | ||
"version": "1.1.0", | ||
"version": "1.1.1-next.0", | ||
"description": "Ledger Live network and cache utilities", | ||
@@ -56,3 +56,3 @@ "keywords": [ | ||
"lru-cache": "^7.14.1", | ||
"@ledgerhq/errors": "^6.12.6", | ||
"@ledgerhq/errors": "^6.12.7-next.0", | ||
"@ledgerhq/live-env": "^0.3.0", | ||
@@ -65,12 +65,3 @@ "@ledgerhq/live-promise": "^0.0.1", | ||
"@types/jest": "^29.2.4", | ||
"@typescript-eslint/eslint-plugin": "^5.46.1", | ||
"@typescript-eslint/parser": "^5.46.1", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-typescript": "^3.0.0", | ||
"eslint-formatter-pretty": "^3.0.1", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-typescript": "^0.14.0", | ||
"jest": "^28.1.1", | ||
"prettier": "^2.8.1", | ||
"ts-jest": "^28.0.5" | ||
@@ -77,0 +68,0 @@ }, |
@@ -28,3 +28,3 @@ import LRU from "lru-cache"; | ||
ttl: 5 * 60 * 1000, | ||
} | ||
}, | ||
): CacheRes<A, T> => { | ||
@@ -48,3 +48,3 @@ // LRU-Cache is written in JS and do not enforce in its code the type checking. | ||
if (promise) return promise; | ||
promise = f(...args).catch((e) => { | ||
promise = f(...args).catch(e => { | ||
cache.delete(key); | ||
@@ -59,3 +59,3 @@ throw e; | ||
const key = keyExtractor(...args); | ||
const promise = f(...args).catch((e) => { | ||
const promise = f(...args).catch(e => { | ||
cache.delete(key); | ||
@@ -62,0 +62,0 @@ throw e; |
@@ -12,5 +12,3 @@ import { LedgerAPI4xx, LedgerAPI5xx, NetworkDown } from "@ledgerhq/errors"; | ||
export const requestInterceptor = ( | ||
request: AxiosRequestConfig | ||
): ExtendedXHRConfig => { | ||
export const requestInterceptor = (request: AxiosRequestConfig): ExtendedXHRConfig => { | ||
if (!getEnv("ENABLE_NETWORK_LOGS")) { | ||
@@ -36,5 +34,3 @@ return request; | ||
export const responseInterceptor = ( | ||
response: InterceptedResponse | ||
): InterceptedResponse => { | ||
export const responseInterceptor = (response: InterceptedResponse): InterceptedResponse => { | ||
if (!getEnv("ENABLE_NETWORK_LOGS")) { | ||
@@ -49,6 +45,6 @@ return response; | ||
"network-success", | ||
`${response.status} ${method} ${baseURL || ""}${url} (${( | ||
Date.now() - startTime | ||
).toFixed(0)}ms)`, | ||
{ data: response.data } | ||
`${response.status} ${method} ${baseURL || ""}${url} (${(Date.now() - startTime).toFixed( | ||
0, | ||
)}ms)`, | ||
{ data: response.data }, | ||
); | ||
@@ -95,6 +91,4 @@ | ||
"network-error", | ||
`${status} ${method} ${baseURL || ""}${url} (${duration}): ${ | ||
errorToThrow.message | ||
}`, | ||
getEnv("DEBUG_HTTP_RESPONSE") ? { data: data } : {} | ||
`${status} ${method} ${baseURL || ""}${url} (${duration}): ${errorToThrow.message}`, | ||
getEnv("DEBUG_HTTP_RESPONSE") ? { data: data } : {}, | ||
); | ||
@@ -113,5 +107,3 @@ throw errorToThrow; | ||
// not react native | ||
if ( | ||
!(typeof navigator !== "undefined" && navigator.product === "ReactNative") | ||
) { | ||
if (!(typeof navigator !== "undefined" && navigator.product === "ReactNative")) { | ||
// the keepAlive is necessary when we make a lot of request in in parallel, especially for bitcoin sync. Otherwise, it may raise "connect ETIMEDOUT" error | ||
@@ -124,8 +116,3 @@ // refer to https://stackoverflow.com/questions/63064393/getting-axios-error-connect-etimedout-when-making-high-volume-of-calls | ||
const makeError = ( | ||
msg: string, | ||
status: number, | ||
url: string | undefined, | ||
method: Method | "" | ||
) => { | ||
const makeError = (msg: string, status: number, url: string | undefined, method: Method | "") => { | ||
const obj = { | ||
@@ -141,5 +128,3 @@ status, | ||
const getErrorMessage = ( | ||
data: Record<string, any> | ||
): string | null | undefined => { | ||
const getErrorMessage = (data: Record<string, any>): string | null | undefined => { | ||
if (!data) return ""; | ||
@@ -205,3 +190,3 @@ if (typeof data === "string") return data; | ||
setAxiosLedgerClientVersionHeader(getEnv("LEDGER_CLIENT_VERSION")); | ||
changes.subscribe((e) => { | ||
changes.subscribe(e => { | ||
if (e.name === "LEDGER_CLIENT_VERSION") { | ||
@@ -208,0 +193,0 @@ setAxiosLedgerClientVersionHeader(e.value); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
4
66138
1084
2