question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jwk.jwk2pem is not a function

See original GitHub issue

Describe the bug error raised at https://github.com/Cvmcosta/ltijs/blob/master/dist/Utils/Auth.js#L142

const Jwk = require('rasha');
.....
const key = Jwk.jwk2pem(authConfig.key);

in rasha v 1.2.5 i can’t find jwk2pem indeed

Expected behavior no error

Provider logs Starting in Dev Mode, state validation and session cookies will not be required. THIS SHOULD NOT BE USED IN A PRO DUCTION ENVIRONMENT!

Ready on localhost:3000 provider:main Receiving request at path: /lti/ +15s provider:main Path does not match reserved endpoints +1ms provider:main Cookies received: +2ms provider:main [Object: null prototype] {} +2ms provider:main Received idtoken for validation +2ms provider:auth Response state: 675062db373b0c6c713e0f797b55122d325546d8cebd2b2abb +0ms provider:auth Attempting to validate iss claim +0ms provider:auth Request Iss claim: undefined +0ms provider:auth Response Iss claim: https://canvas.instructure.com +3ms provider:auth Dev Mode enabled: Missing state validation cookies will be ignored +2ms provider:auth Attempting to retrieve registered platform +2ms Executing (default): SELECT “id”, “platformName”, “platformUrl”, “clientId”, “authEndpoint”, "accesstokenEndpoint ", “kid”, “authConfig”, “createdAt”, “updatedAt” FROM “platforms” AS “platform” WHERE “platform”.“platformUrl” = ‘https://canvas.instructure.com’ AND “platform”.“clientId” = ‘25710000000000107’; Executing (default): SELECT “id”, “active”, “createdAt”, “updatedAt” FROM “platformStatuses” AS “platformStatus” WHERE “platformStatus”.“id” = ‘ef741341c735ae957ff0474abff014c1’; provider:auth Retrieving key from jwk_key +405ms provider:main Deleting state cookie and Database entry +419ms Executing (default): SELECT “state”, “query”, “createdAt”, “updatedAt” FROM “states” AS “state” WHERE “state”.“st ate” = ‘675062db373b0c6c713e0f797b55122d325546d8cebd2b2abb’; provider:auth TypeError: Jwk.jwk2pem is not a function provider:auth at Function.validateToken (D:\credo\rivendell\node_modules\ltijs\dist\Utils\Auth.js:142:27) provider:auth at processTicksAndRejections (internal/process/task_queues.js:97:5) provider:auth at sessionValidator (D:\credo\rivendell\node_modules\ltijs\dist\Provider\Provider.js:400:27) +623ms provider:main Passing request to invalid token handler +217ms

Ltijs version

  • 5.7.4

NodeJS version

  • 12.22.1

Platform used

  • Canvas

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lenacomcommented, May 13, 2021

Now the error is fixed. Thank you for quick feedback.

0reactions
Cvmcostacommented, May 13, 2021

Okay, sorry about that, i tested it feeding the method directly a JWK object, the database in this instance will return a String. Fixed it on 5.7.7, simply added a JSON.parse call, seems to be working well. Sorry for the inconvenience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jwk-to-pem
Convert a JSON Web Key to a PEM. Latest version: 2.0.5, last published: 2 years ago. Start using jwk-to-pem in your project by...
Read more >
How to use the jwk-to-pem function in ...
To help you get started, we've selected a few jwk-to-pem examples, based on popular ... jwkToPem(key))) { throw Error("Token signature did not validate");...
Read more >
JWK to PEM Convertor online
Generate a JSON Web Key (JWK). A JSON object that represents a cryptographic key. The members of the object represent properties of the...
Read more >
JavaScript pem-jwk pem2jwk Examples
These are the top rated real world JavaScript examples of pem-jwk.pem2jwk extracted ... it('should enfore not before (nbf) claim', function() { var claims ......
Read more >
error using express-jwt: jwt is not a function - node.js
I'm using express-jwt in my project but I'm getting this error, I couldn't find the solution import jwt from "express-jwt"; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found