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

Error when import JwtPayload from jsonwebtoken #213

Open
francozini2 opened this issue Nov 20, 2023 · 3 comments
Open

Error when import JwtPayload from jsonwebtoken #213

francozini2 opened this issue Nov 20, 2023 · 3 comments

Comments

@francozini2
Copy link

Hi! I installed the 3.0.1 version but I had this error:

node_modules/verify-apple-id-token/dist/lib/types.d.ts:1:15 - error TS2305: Module '"jsonwebtoken"' has no exported member 'JwtPayload'.

1 import type { JwtPayload } from "jsonwebtoken";
                ~~~~~~~~~~


Found 1 error in node_modules/verify-apple-id-token/dist/lib/types.d.ts:1

I have [email protected] and @types/[email protected]

@stefanprokopdev
Copy link
Owner

Hello @francozini2 👋

Thanks for creating the issue! Can you please share with me part of your code? I would like to reproduce it 🙏 I think we can start with package json and usage of the library. Thank you.

Btw you can also install the newest version 3.1.0.

@francozini2
Copy link
Author

Hi! @stefanprokopdev

The part of my code is this:

import verifyAppleToken from "verify-apple-id-token";

export const AppleService = {
    async verifyToken(token: string, nonce: string): Promise<Boolean> {
        try {
            const jwtClaims = await verifyAppleToken({
                idToken: token,
                clientId: "APPLE_API_CLIENT",
            })
            if (jwtClaims) {
                return true
            }
            return false
        } catch (error) {
            return false
        }
    },
}

and the package.json:

  "name": "",
  "version": "0.0.0",
  "author": "",
  "license": "UNLICENSED",
  "repository": {
    "type": "git",
    "url": ""
  },
  "main": "dist/index.js",
  "scripts": {
    "build": "tsc",
    "start": "node -r ts-node/register -r tsconfig-paths/register dist/src/server.js",
    "dev": "nodemon",
    "fix-lint": "prettier --config --write '**/**'",
    "check-lint": "prettier --config --check '**/**'",
    "ts-node-server": "ts-node src/server.ts",
    "prepare": "husky install"
  },
  "lint-staged": {
    "**/**": [
      "npx prettier --config --write '**/**'"
    ]
  },
  "jest": {
    "globals": {
      "__DEV__": true
    },
    "testEnvironment": "node",
    "testPathIgnorePatterns": [
      "/node_modules/"
    ]
  },
  "dependencies": {
    "@babel/generator": "7.7.4",
    "axios": "^0.27.2",
    "core-js": "3.4.7",
    "dotenv": "^8.2.0",
    "es6-promise": "4.2.8",
    "express": "^4.17.1",
    "http-status-codes": "1.4.0",
    "i18n": "^0.13.3",
    "jsonwebtoken": "^9.0.1",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.34",
    "tsconfig-paths": "^3.11.0",
    "validator": "^13.7.0",
    "winston": "^3.7.2",
    "verify-apple-id-token": "^3.1.0"
  },
  "devDependencies": {
    "@babel/cli": "7.7.4",
    "@babel/core": "^7.6.0",
    "@babel/helpers": "7.7.4",
    "@babel/node": "^7.15.8",
    "@babel/preset-env": "^7.7.4",
    "@babel/preset-react": "7.7.4",
    "@babel/preset-typescript": "7.7.4",
    "@babel/runtime": "7.12 .5",
    "@babel/runtime-corejs3": "7.7.5",
    "@types/jsonwebtoken": "^9.0.2",
    "axios-logger": "^2.6.2",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "10.0.3",
    "babel-jest": "24.9.0",
    "babel-loader": "8.0.6",
    "cross-env": "^6.0.3",
    "husky": "^7.0.0",
    "lint-staged": "^11.2.3",
    "nodemon": "^2.0.2",
    "prettier": "^2.4.1",
    "ts-node": "^10.0.0",
    "tslint-config-prettier": "^1.18.0",
    "typescript": "^4.4.3",
    "typescript-transform-paths": "^3.3.1"
  },
  "peerDependencies": {
    "@types/node": "^16.10.1"
  }
}

I want to tell you something before, I did some tests and it worked. I tried to change the way to import the verifyAppleToken

I changed import verifyAppleToken from "verify-apple-id-token"; to const verifyAppleToken = require("verify-apple-id-token").default; and works.

@stefanprokopdev
Copy link
Owner

Hey @francozini2 👋 sorry for a very long delay 😞 I published a new version of the package v3.1.1. I made a package @types/jsonwebtoken a part of the production dependencies. So there shouldnt be a problem anymore because now its part of the package. Can you please let me know if its ok now and resolve the issue?

Thank you so much and sorry again. Btw wish you a happy new year 🎉

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