Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Importing FireBlocks SDK adds a global Axios interceptor via @notabene/pii-sdk #307

Open
florian-besser opened this issue Nov 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@florian-besser
Copy link

florian-besser commented Nov 7, 2024

Describe the bug
If you import the FireBlocks SDK it in turn imports:

import PIIsdk from "@notabene/pii-sdk";

(See pii-client.d.ts)

This in turn runs the following code:

const $cc4675d9e8e3b77e$var$errorInterceptor = (error)=>{
    return Promise.reject({
        req: {
            url: "" + error?.response?.config?.baseURL + error?.response?.config?.url,
            method: error?.request?.method
        },
        status: error?.response?.status,
        statusText: error?.response?.statusText,
        err: JSON.stringify(error?.response?.data?.err || error?.response?.data || error)
    });
};
(0, ($parcel$interopDefault($iyY9t$axios))).interceptors.request.use((res)=>res, (error)=>$cc4675d9e8e3b77e$var$errorInterceptor(error));
(0, ($parcel$interopDefault($iyY9t$axios))).interceptors.response.use((res)=>res, (error)=>$cc4675d9e8e3b77e$var$errorInterceptor(error));

This sets a default Axios interceptor, from now on any Axios errors will use errorInterceptor which transforms the usual Axios error that has fields like error.request.method into this new (custom?) format that has fields like error.req.method

This is confusing and unexpected; I would expect FireBlocks to decorate their own Axios instance as they desire, but leave all other Axios instances alone.

To Reproduce

import { FireblocksSDK } from 'fireblocks-sdk';
import * as axios from 'axios';

new FireblocksSDK("Some secret", "API key");

// Expect: 0
// Actual: 1
console.log(axios.default.interceptors.response.handlers.length);

Expected behavior
No default interceptors should be registered; these interceptors should only be registered on the FireBlocks-SDK-internal axios instance

Version:

  • fireblocks-sdk version: 5.33.0
  • npm version: 10.8.2
  • node version: v20.18.0
@florian-besser florian-besser added the bug Something isn't working label Nov 7, 2024
@florian-besser
Copy link
Author

Consider moving to something other than @notabene/pii-sdk or fixing @notabene/pii-sdk to allow adding interceptors only to certain specific Axios instances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant