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

fix decode example of UnsecuredJWT #330

Merged
merged 2 commits into from
Nov 20, 2021
Merged

fix decode example of UnsecuredJWT #330

merged 2 commits into from
Nov 20, 2021

Conversation

maxarndt
Copy link
Contributor

@maxarndt maxarndt commented Nov 20, 2021

.decode() is a static function of the UnsecuredJWT class. Instantiating a new object and calling the function afterwards doesn't make sense and leads to an exception:

const payload = new jose.UnsecuredJWT.decode(unsecuredJwt, {
                ^

TypeError: jose.UnsecuredJWT.decode is not a constructor
    at file:https:///Users/maxarndt/Downloads/some-repo/utilities/jwt/unsecuredJWT.js:12:17
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

Because of this the new operator should be removed from the examples.

@maxarndt maxarndt marked this pull request as ready for review November 20, 2021 10:51
@panva
Copy link
Owner

panva commented Nov 20, 2021

Thank you @maxarndt

@panva panva merged commit 4375cde into panva:main Nov 20, 2021
@maxarndt maxarndt deleted the patch-1 branch November 20, 2021 11:57
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants