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

Unable to execute verify function #46

Open
aph5nt opened this issue Oct 18, 2022 · 5 comments
Open

Unable to execute verify function #46

aph5nt opened this issue Oct 18, 2022 · 5 comments

Comments

@aph5nt
Copy link

aph5nt commented Oct 18, 2022

I get the following error during compile time

node_modules/web3-token/dist/web3-token.d.ts:7:31 - error TS2307: Cannot find module './lib/interfaces' or its corresponding type declarations.

7         sign: (signer: import("./lib/interfaces").Signer, opts?: string | import("./lib/interfaces").SignOpts) => Promise<string>;
                                ~~~~~~~~~~~~~~~~~~

node_modules/web3-token/dist/web3-token.d.ts:7:82 - error TS2307: Cannot find module './lib/interfaces' or its corresponding type declarations.

7         sign: (signer: import("./lib/interfaces").Signer, opts?: string | import("./lib/interfaces").SignOpts) => Promise<string>;
                                                                                   ~~~~~~~~~~~~~~~~~~

node_modules/web3-token/dist/web3-token.d.ts:8:47 - error TS2307: Cannot find module './lib/interfaces' or its corresponding type declarations.

8         verify: (token: string, opts?: import("./lib/interfaces").VerifyOpts) => {
                                                ~~~~~~~~~~~~~~~~~~

node_modules/web3-token/dist/web3-token.d.ts:10:26 - error TS2307: Cannot find module './lib/interfaces' or its corresponding type declarations.

10             body: import("./lib/interfaces").DecryptedBody;
                            ~~~~~~~~~~~~~~~~~~


Found 4 errors in the same file, starting at: node_modules/web3-token/dist/web3-token.d.ts:7

source code:


export async function authorize(token) {
    try {

        const { address, body } = await verify(token);

        return {};
    } catch (e) {
        // eslint-disable-next-line no-console
        return null;
    }
}

package.json

  "name": "",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "prestart": "npm run build",
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "@moralisweb3/streams-typings": "^1.0.5",
    "ethers": "^5.7.1",
    "i": "^0.3.7",
    "npm": "^8.19.2",
    "web3-token": "^1.0.2"
  },
  "devDependencies": {
    "@azure/functions": "^3.0.0",
    "typescript": "^4.0.0"
  }
}
@bytesbay
Copy link
Owner

Thanks for the report. Let me check in the morning

@aph5nt
Copy link
Author

aph5nt commented Oct 18, 2022

it works fine in vue3 project, but for azure functions it wont compile. i also tried with brand new fresh az and it still fails

@aph5nt
Copy link
Author

aph5nt commented Oct 18, 2022

plain node js project works fine

const Web3Token = require("web3-token");

async function execute() {
    const token = "XXXX";
    const { address, body } = await Web3Token.verify(token);
      
      console.log(address, body)
}

execute();

returns

0x3.... {    
  uri: 'https://localhost:8081/',
  nonce: '36578978',
  'web3-token-version': '2',
  'chain-id': '1',
  'issued-at': '2022-10-18T20:52:12.266Z',      
  'expiration-time': '2022-10-19T20:52:12.267Z',
  statement: 'Sign message to authenticate'     
}

@aph5nt
Copy link
Author

aph5nt commented Oct 18, 2022

solution: update tsconfig.json to

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "dist",
    "rootDir": ".",
    "sourceMap": true,
    "strict": false,
    "skipLibCheck": true,
  }
}

to be precise: I added "skipLibCheck": true,

@aph5nt aph5nt closed this as completed Oct 18, 2022
@bytesbay
Copy link
Owner

Anyway still cannot get why it happens and what do i need to update in my package build config 👀

@bytesbay bytesbay reopened this Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants