Skip to content

Node SDK: verifyToken function has wrong signature #2280

Closed

Description

@mboudreau

Preliminary Checks

Reproduction / Replay Link

https://github.com/clerk/javascript/blob/main/packages/sdk-node/src/clerkClient.ts#L11

Publishable key

yeah, nah

Description

Steps to reproduce:

  1. install @clerk/clerk-sdk-node@4.12.23
  2. Add code that calls clerkClient.verifyToken(token)
  3. Watch as typescript throws a fit because it's expecting 2 arguments. Weird.
  4. Add options object as second parameter. Watch typescript throw a tantrum asking for the issuer to be specified even though it shouldn't be required.

Expected behavior:

The signature should be able to accept a single argument as per your code, but because the (ExtendedClerk type references @clerk/backend for the verifyToken type)[https://github.com/clerk/javascript/blob/main/packages/sdk-node/src/clerkClient.ts#L11] and since that signature is a broken, it breaks the child.

I personally find it weird that the backend code requires the second argument with empty object fallback as all the properties inside this options object should be optional except for some reason, the issuer hasn't been made optional in the option signature, even though it is optional in the code for verifyToken.

Furthermore, code like this type signature makes it extremely hard to read and gives very little value to your developers other than not having to copy some types over, but the issue now lies that the base type has immense power over your SDK signature which can break things as clearly shown here. Having 2 picks and your own extension to the type shows that your types are not well thought out and should be reassessed for better abstraction, or maybe it might be easier to just have an explicit type for each function to prevent these kinds spaghetti type issues in the future.

Actual behavior:

verifyToken signature won't allow single token argument without breaking.

Environment

Doesn't matter

Activity

  1. added
    needs-triageA ticket that needs to be triaged by a team member
    on Dec 7, 2023
  2. self-assigned this
    on Dec 7, 2023
  3. added
    prioritizedThis issue has been triaged and the team is working on it
    and removed
    needs-triageA ticket that needs to be triaged by a team member
    on Dec 7, 2023
  4. dimkl commented on Dec 7, 2023

    @dimkl
    Contributor

    Hello @mboudreau
    thank you for reporting this. A fix has been released as part of @clerk/clerk-sdk-node@4.13.0

  5. clerk-cookie commented on Dec 7, 2024

    @clerk-cookie
    Collaborator

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  6. locked as resolved and limited conversation to collaborators on Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prioritizedThis issue has been triaged and the team is working on it

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions