blockchain-lab-um / masca

Snap for managing VCs and DIDs in MetaMask
https://masca.io
Apache License 2.0
51 stars 16 forks source link

[bug](snap): queryCredentials function calling failing #624

Open aditya9729 opened 3 months ago

aditya9729 commented 3 months ago

Describe the bug

We are using masca connector version 1.1.0 in our dapp. In Chrome, we see that when we enableMasca and try to query a particular credentialSubject Type or even query all credentials, queryCredentials promise doesn't resolve and gives us an error : {success:False, error:'Object[object]'}, its not very clear what's the error. Note we are behind corporate VPN and have seen that disabling usage of ceramic credential store doesn't help.

Code below: ` const enableResult = await enableMasca(address, { snapId: 'npm:@blockchain-lab-um/masca', version: '1.1.0', supportedMethods: ['did:key'] } );

    if (isError(enableResult)) {
      throw new Error(enableResult.message);
    }

    const mascaApi = await enableResult.data.getMascaApi();
    const getMethod = await mascaApi.getSelectedMethod();

    if (getMethod !== "did:key") {
      await mascaApi.switchDIDMethod('did:key');

    }
    const query = `$[?(@.data.credentialSubject.type == "credentialX")]`;
    const vcs = await mascaApi.queryCredentials({
        filter: {
            type: 'JSONPath',
            filter: query,
        },
        options: {
            returnStore: true,
        },
    });

`

To Reproduce

  1. Connect to a VPN server
  2. Use masca-connector version 1.1.0
  3. Build a basic dapp a provide access masca snap
  4. You should be able to give access to your ethereum address.
  5. Ethereum address is fed to enableMasca function call to a specific version with supported did methods being only 'did:key'
  6. Now when you queryCredentials, you should see the promise doesn't resolve and you get an error that doesn't tell you anything.

Expected behavior

Maybe its because of packet filtering, when we are behind the VPN, what version of masca connector should we use? What addresses should we whitelist such that we don't see metamask RPC timeout errors or even promise resolution errors?

pseudobun commented 3 months ago

Hi @aditya9729!

It looks to me like the issue could be related to https://github.com/MetaMask/snaps/issues/2324. Are you testing Masca on localhost? One of the solutions to this specific problem is using ngrok temporarily until the MM team has fixed this.

Additionally as of today the latest connector shouldn't have been causing any more problems so you can update the masca-connector to v1.3.2.