Giter VIP home page Giter VIP logo

Comments (7)

nikosdouvlis avatar nikosdouvlis commented on June 27, 2024 5

Hello there - many thanks for the feedback!

Every Clerk package depends on the public @clerk/types package - if you're using @clerk/nextjs this will also be installed. Could you try importing UserResource from @clerk/types instead? Eg:

import { UserResource } from "@clerk/types";

Your comments about withAuth/requireAuth are valid. Improving type support for the nextjs package was on our roadmap, but let me see if we can publish a first batch of improvements with the next beta release :)

from javascript.

mikestopcontinues avatar mikestopcontinues commented on June 27, 2024

Let me tack on here that the types for withAuth and requireAuth are a little messy, both from /nextjs/api, but also up in /node-sdk.

At minimum, it would make a big difference if handler: Function was replaced with the res, req, next defs from just a few lines down.

Even better would be the generics used over in /nextjs/ssr so that (1) it could be extended by the nextjs package, and (2) so that session can be added.

from javascript.

mikestopcontinues avatar mikestopcontinues commented on June 27, 2024

Hi @nikosdouvlis,

Thanks! I can get UserResource out of types. That said, I do still think it should be exported by the package that uses it.

Similar topic: where's the user and session objects that get passed in when using withServerSideAuth (e.g. User)? It's not the same as UserResource. Maybe a better question: Should they be the same shape?

Thanks again!

from javascript.

clerk-cookie avatar clerk-cookie commented on June 27, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

from javascript.

clerk-cookie avatar clerk-cookie commented on June 27, 2024

This issue was closed because it has been stalled for 10 days with no activity.

from javascript.

dimkl avatar dimkl commented on June 27, 2024

@mikestopcontinues The objects passed in withServerSideAuth come from the @clerk/backend package types. The are 2 different types of resources for user for example, User and UserResource.
The User type is related to the shape generated from an API call from your application server to Clerk server to retrieve an object with information about a user which contains private metadata and other private data that are meant to be used by the server of the application.
The UserResource is related to the shape generated from the API call from the end-user Browser to the Clerk server to retrieve information based on the end-user session which will not contain private metadata for example.
Based on the above we explicitly use different shapes in the withServerSideAuth and in the hooks exposed by our packages to mistakenly expose or expect the wrong data.

Example for user object

from javascript.

mikestopcontinues avatar mikestopcontinues commented on June 27, 2024

Thanks, @dimkl. I appreciate the context, and I should've probably closed this issue a while back.

from javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.