ITEnthusiasm
12/06/2022, 6:06 PMIssue
I threw up on GitHub in supertokens-node
. But this question is more specific.
Is there an existing way to replicate the /signin
, /signup
, /session/refresh
route middleware by hand? (And are those the only middlewares created from app.use(middlewares())
?)
(Background in Thread)
ITEnthusiasm
12/06/2022, 6:06 PMremix-supertokens
example that I created works just fine. However, there are limitations: The current implementation relies on calling `http://localhost`/`https://localhost`. If, for some reason, the web server decides to force https
only, then when the Remix server calls itself, it must also use https
.
My application is constrained in this way:
1) I can't make requests to https://localhost
from my own server.
2) I can make requests to https://MY_DOMAIN.com
from my own server.
3) I don't want to make requests to https://MY_DOMAIN.com
from my server because it creates unnecessary round trips and will cost me more money.
(I could go into the details of why I'm in that situation, but I figured that listing out the constraints was simplest.)
Being in this conundrum, I'm now trying to see if there's a way to replicate the SuperTokens functionality on the server directly in my Remix Actions (i.e., "route handlers").ITEnthusiasm
12/06/2022, 6:07 PMrp_st
12/08/2022, 5:51 AMrp_st
12/08/2022, 5:52 AMrp_st
12/08/2022, 5:56 AMITEnthusiasm
12/08/2022, 1:42 PMrp_st
12/08/2022, 1:43 PMrp_st
12/08/2022, 1:43 PMrp_st
12/08/2022, 1:43 PMrp_st
12/08/2022, 1:43 PMrp_st
12/08/2022, 1:44 PMITEnthusiasm
12/08/2022, 1:47 PMrp_st
12/08/2022, 1:48 PMITEnthusiasm
12/08/2022, 1:51 PMhttps://mydomain.com
), then the request would go to Cloudflare (not my origin server), which has valid certificates. But that's an unnecessary round trip that I don't want to take.
For clarity:
- Cloudflare has valid CA certificates. (Node.js trusts these.)
- Origin Server has Cloudflare-signed certificates that Cloudflare trusts, but that Node.js does not. This is typically fine, except for cases where the Node.js server tries to call itself directly through localhost
. (Ironically.)rp_st
12/08/2022, 1:52 PMrp_st
12/08/2022, 1:52 PMITEnthusiasm
12/08/2022, 1:54 PMITEnthusiasm
12/08/2022, 1:57 PM443
is exposed by the server.
Because of this, I cannot call http://localhost
. That would be an HTTP request, which the server rejects.
Now imagine that on the server, I'm using a self-signed certificate in the configuration. Browsers do not trust this certificate. Similarly, no Node.js application will trust this certificate. If someone else tries to call my server using HTTPS (e.g., https://mydomain.com
), Node.js will fail the request because the certificate is not verifiable. In the same way, if I call https://localhost
, Node.js is still unable to verify the self-signed certificate. So even though the server is calling itself, it will fail.ITEnthusiasm
12/08/2022, 1:58 PMrp_st
12/08/2022, 1:59 PMITEnthusiasm
12/08/2022, 2:03 PMserver.js
file in that case. It doesn't bleed into things like certificate authorities and such. And it doesn't require something else like Nginx. (Unrelated: This would also give me a hint to translate all my Remix-SuperTokens code to a new Solid-Start example, I think.)rp_st
12/08/2022, 2:04 PMITEnthusiasm
12/08/2022, 2:05 PMrp_st
12/08/2022, 2:05 PMITEnthusiasm
12/16/2022, 4:24 PMrp_st
12/16/2022, 4:28 PMITEnthusiasm
12/16/2022, 6:03 PMsupertokens.middleware
points. https://github.com/supertokens/supertokens-node/blob/master/lib/ts/framework/express/framework.ts#L159 π€ITEnthusiasm
12/16/2022, 6:04 PMITEnthusiasm
12/16/2022, 7:47 PMsupertokens.middleware
> recipe.handleAPIRequest
, it seemsITEnthusiasm
12/16/2022, 7:59 PMIncomingMessage.headers
, right?ITEnthusiasm
12/16/2022, 8:07 PMany
in many places admittedly makes some aspects of looking around the code and contributing a little difficult. π
ITEnthusiasm
12/16/2022, 8:12 PMITEnthusiasm
12/16/2022, 8:25 PMattachCreateOrRefreshSessionResponseToExpressRes
. Is this the only function used to create the Access+Refresh tokens?
If the answer to Question 2
is yes (I hope it is π¬), is there a way that we can update this (and the related functions) to avoid manipulating the original Response
object and to return the ResponseHeaders
necessary for SuperTokens to properly do its auth stuff only?ITEnthusiasm
12/16/2022, 8:35 PMapp.use(middleware())
, I'm finding that it would actually be a lot better if I could use a framework-agnostic solution... A framework-agnostic solution is the only way to support the neat frameworks like SvelteKit and Solid Start right now. And it will guarantee that all new hot SSR frameworks that appear in the future will immediately be supported. Being able to support next@13
when the app
directory is out of beta would also be a big deal.
Of course, the code would also need to be updated to accept Request information instead of the entire request object. Where needed, SuperTokens could probably accept a `RequestContext`/`RequestData`/etc. object that has any needed information path
, body
, etc. (I'm hoping that SuperTokens doesn't need that much request information -- to keep life simple.)ITEnthusiasm
12/16/2022, 8:44 PMBaseRequest
, BaseResponse
, and all of their child classes. I know this isn't necessary and would be a breaking change, but I think it would thoroughly benefit the SuperTokens team and all contributors. The team wouldn't need to maintain several abstract
classes and sub classes anymore because end-users would simply interact with the Recipe.*
and Session.*
methods directly. And contributors would be able to make contributions more easily. (I personally felt like I was hopping back and forth a lot around the codebase to get only a super basic idea of what the signup
route does just for Express. And not all types were defined. That will probably be a barrier to some people who would otherwise contribute. It was a barrier to me until I found out I really need this feature and SuperTokens can get a 1-Up on Auth0 with this. π
)
It's a short term bother with huge long term benefits. And the docs could just be updated to show how to implement the API routes in each framework. I imagine it wouldn't be that hard.
Just spitballing more thoughts. I can add this to the original issue I opened too if that would be more helpful. But I think the next step would really be to add a feature for framework-agnostic solutions by refactoring those underlying classes I mentioned. Lmk your thoughts. Sorry I know I typed a lot.rp_st
12/17/2022, 1:35 PMres
object, and the middleware
also takes in a req
and res
object (like middleware()(req, res, next)
. Instead of giving it the actual req
, res
objects, you can instead make your own "fake" req, res objects and pass those in. Then later on, you can read from the fake res object the headers / cookies that were set and do whatever you like.
The fake req
, res
objects would have to conform to the BaseRequest and BaseResponse shape and would need to have the boolean of wrapperUsed
as true.
--------------------
So even now, it's technically possible to use SuperTokens with any framework via the above method. You could even use this trick to convert a form post request from the frontend to a JSON request that's understandable by the supertokens API and this would make is so that in the remix backend, you don't have to send a request to the backend itself (which i believe you are doing now).
We will make this more easy / document this in the future.rp_st
12/17/2022, 1:35 PMITEnthusiasm
12/19/2022, 2:38 PMcreateNewSession
will allow me to read those tokens and add them to my own separate response object. I can send my own [req] object in as long as it has the data needed. Sound correct?
Is `ExpressRequest`/`ExpressResponse` internal or is it exposed by the npm package? I'm assuming that reusing those classes would make it easier to do this. If so, maybe I can trying seeing if I can bring that logic to remix-supertokens
-- depending on how it would impact code readers. I'd have to see what the physical code turns out to look like first.
---
Long term though, any thoughts on refactoring some of those internal functions to simply receive data and return a response headers object or something? The workaround you described sounds like it should work. But it will leave the SuperTokens team with maintaining some logic that's more complex; and it will require end users in situations like mine to jump through more hoops. It's more effort for everyone to wrap their brains around things.ITEnthusiasm
12/20/2022, 1:08 PMrp_st
12/23/2022, 2:26 PMrp_st
12/23/2022, 2:29 PMres
object that you give it. So you can provide a custom res object that conforms to the BaseResponse structure, and then can read the tokens from that to set however you like.
> Is ExpressRequest/ExpressResponse internal or is it exposed by the npm package?
It's internal.
> Long term though, any thoughts on refactoring some of those internal functions to simply receive data and return a response headers object or something?
Yes.
> But it will leave the SuperTokens team with maintaining some logic that's more complex;
It won't affect us in terms of additional code maintenance, since you are creating your own res / req object anyway.ITEnthusiasm
12/23/2022, 2:33 PMrp_st
12/23/2022, 2:34 PMITEnthusiasm
12/29/2022, 6:34 PMcreateNewSession
if not.ITEnthusiasm
12/29/2022, 6:40 PMrequest
inputs with simple request data inputs and replace response
inputs with an output of response Headers
.
But it seems like createNewSession
or attachCreateOrRefreshSessionResponseToExpressRes
would be sufficient candidates since that's where the interaction with the response is going on.ITEnthusiasm
12/29/2022, 6:40 PMITEnthusiasm
12/29/2022, 7:40 PMgetCookieValueToSetInHeader
(https://github.com/supertokens/supertokens-node/blob/a8760b966dd1239f0e7b782b72bbfba830fcd859/lib/ts/framework/utils.ts#L300). All of the let
fun is making it hard to follow the logic. π
Does this function basically set a new value for a cookie if it doesn't exist yet and replace the value for a cookie if it already exists?~~
**Edit**: You can ignore this. I'm pretty sure the answer to my question is yes.ITEnthusiasm
12/29/2022, 9:51 PMSet-Cookie
, I believe.ITEnthusiasm
12/29/2022, 9:53 PMITEnthusiasm
12/30/2022, 12:57 AMfront-token
represent? I've never seen it set in my apps. Is it only set when the frontend needs JavaScript?ITEnthusiasm
12/30/2022, 12:58 AMlogin
working now. If this is good to go, I think I'm gonna start targetting signup
and refresh
.ITEnthusiasm
12/30/2022, 3:19 AMITEnthusiasm
12/30/2022, 3:19 AMITEnthusiasm
12/30/2022, 3:19 AMrp_st
12/30/2022, 5:37 AMITEnthusiasm
12/30/2022, 2:21 PMrp_st
12/30/2022, 2:22 PMITEnthusiasm
12/30/2022, 2:51 PMsigin
, signup
, createToken
, and resetPassword
all inside handleRequest
. But I don't see anything for logout
or refreshToken
. Do you know where this logic is defined within supertokens-node
?rp_st
12/30/2022, 2:51 PMITEnthusiasm
12/30/2022, 5:07 PMrevokeSession
returning true
vs false
?ITEnthusiasm
12/30/2022, 7:13 PMITEnthusiasm
12/30/2022, 8:32 PMlogout
because the incoming sAccessToken
that's needed for the initial Session.getSession
call appears to be URI encoded.ITEnthusiasm
12/30/2022, 8:33 PMSuperTokens
/signout
route automatically run decodeURIComponent
on the sAccessToken
? (I didn't see any logic doing this on the supertokens-node
repo ... but decoding the token seems to be required for the code to work.)ITEnthusiasm
12/30/2022, 8:54 PMITEnthusiasm
12/30/2022, 9:17 PMheaders.get("anti-csrf")
was returning null
instead of undefined
. Changing to headers.get("anti-csrf") ?? undefined
makes the code work.
**Question 3**: What's causing that to break? Can SuperTokens not work with both undefined
and null
here?ITEnthusiasm
12/30/2022, 9:36 PMsignUp
tomorrow. But after that, I'd appreciate some review to make sure the things that I've written actually work as expected (if that wouldn't be a bother) -- similar to what we did the first time I created remix-supertokens
. π
Assuming I can get signUp
working, I still don't know if I'd say SuperTokens "supports" things like SolidStart and SvelteKit. π
Once the developer needs knowledge of internals to get things working, it's no longer "supported". But I'm at least glad there's an option to cleverly interact with the internals.ITEnthusiasm
12/30/2022, 9:37 PMsignUp
function as well (when I create it)? Or does EmailPassword.signUp
automatically take care of that for me?rp_st
12/31/2022, 5:24 AMITEnthusiasm
12/31/2022, 2:46 PMITEnthusiasm
12/31/2022, 11:25 PMrp_st
01/01/2023, 6:06 AMITEnthusiasm
01/01/2023, 12:52 PMITEnthusiasm
01/01/2023, 1:06 PMexperiment/custom-supertokens
branch of the remix-supertokens
repo to see the latest code: https://github.com/ITenthusiasm/remix-supertokens/tree/experiment/custom-supertokens.
The most important changes (at least right now) are in this last commit (if you want to look at diffs): https://github.com/ITenthusiasm/remix-supertokens/commit/f50eabc105885ddd024730f1f1652fa741204e23.
If you (and/or any other members) could review the code and test out the app to make sure everything is working correctly, that would be appreciated. Then, if you guys think it's a good idea, I can merge this into main
on the remix-supertokens
repo. (My hesitation is that there's a little more code that devs have to write to get their Remix
apps running. But people using Remix
in certain ways will end up forced to use this approach anyway.)
I'd especially appreciate it if you could let me know if there are any error cases that I'm failing to handle properly -- especially around the /logout
and /auth/session/refresh
routes. π
Thanks again for all your help in this. This thread is several comments long. π If this works out, I'm probably going to do some minor cleanup here or there... Then after I take a break, I'll probably see if I can tackle SvelteKit
with this approach... maybe. π
But I'm only intending for these to be temporary workarounds since these solutions make assumptions about internal logic within supertokens-node
. It's a little dangerous.
In terms of the supertokens-node
refactors that could be done, maybe this code could give ideas about the potential inputs/outputs to require? idk. π€·πΏββοΈ But from this experiment, it seems like the supertokens-node
functions/methods really only need request Headers
as inputs (instead of the whole request object); and it seems like supertokens-node
can return response Headers
instead of accepting and mutating a response object.ITEnthusiasm
01/01/2023, 1:09 PMITEnthusiasm
01/01/2023, 1:11 PMRemix + Express
so I'm not sure what the Cloudflare limitations would be.ITEnthusiasm
01/01/2023, 1:35 PMgetAllCORSHeaders
return? Is there a place where we can see the derivation logic? All the static methods I see on the repo just return empty arrays. π€ITEnthusiasm
01/01/2023, 6:28 PMrp_st
01/02/2023, 4:35 AMrp_st
01/02/2023, 5:37 PMrp_st
01/02/2023, 5:46 PMITEnthusiasm
01/02/2023, 5:46 PMrp_st
01/02/2023, 5:46 PMITEnthusiasm
01/05/2023, 2:09 PMnext@13
is also gradually adopting support for web-standard `Request`/`Response`. If they do this all the way, this approach will also work in Next.js without any additional refactoring. (Refactoring the approach to work with Next.js would be rather easy to do anyway though.)
Really glad Remix came along. It definitely pushed Next.js to make some better changes. π
rp_st
01/06/2023, 4:20 AMITEnthusiasm
01/10/2023, 2:12 PMcookie
package docs (https://github.com/jshttp/cookie#cookieserializename-value-options):
For the encode
option passed to `cookie.serialize`:
> Specifies a function that will be used to encode a cookie's value. Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode a value into a string suited for a cookie's value.
>
> The default function is the global encodeURIComponent
, which will encode a JavaScript string into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
Similarly, for the decode
option passed to `cookie.parse`:
> Specifies a function that will be used to decode a cookie's value. Since the value of a cookie has a limited character set (and must be a simple string), this function can be used to decode a previously-encoded cookie value into a JavaScript string or other object.
>
> The default function is the global decodeURIComponent
, which will decode any URL-encoded sequences into their byte representations.
>
> note if an error is thrown from this function, the original, non-decoded cookie value will be returned as the cookie's value.
So it seems the cookie
package that supertokens-node
uses automatically encodes and decodes. That's why I ran into that hiccup earlier.rp_st
01/10/2023, 2:15 PMrp_st
01/10/2023, 2:15 PMITEnthusiasm
01/10/2023, 2:16 PMITEnthusiasm
01/10/2023, 2:17 PMrp_st
01/10/2023, 2:18 PMrp_st
01/10/2023, 2:18 PMrp_st
01/10/2023, 2:18 PMITEnthusiasm
01/10/2023, 2:31 PMITEnthusiasm
01/12/2023, 9:19 PMrp_st
01/13/2023, 5:49 AMrp_st
01/13/2023, 8:06 AMts
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
requestWrapper = createSuperTokensRequestWrapper(request);
responseWrapper = createNewSuperTokensResponse();
callbackCalled = false;
await middleware()(requestWrapper, responseWrapper, () => {
// this means that the middleware did not handle the request
callbackCalled = true;
})
if (callbackCalled) {
// this means that the middleware didn't handle it, so we let other routes handle it
let markup = renderToString(<RemixServer context={remixContext} url={request.url} />);
responseHeaders.set("Content-Type", "text/html");
return new Response("<!DOCTYPE html>" + markup, {
status: responseStatusCode,
headers: responseHeaders,
});
} else {
// this means that the middleware did handle the request.
// TODO: read from responseWrapper and send relevant response.
}
}
rp_st
01/13/2023, 8:06 AMcreateSuperTokensRequestWrapper
and createNewSuperTokensResponse
would be similar to what you have already made, except that it would also do a mapping of input request paths with what the middleware expects. For example, for the refresh API, the middleware expects it to be a POST request to /auth/session/refresh
. So in the getMethod
function of the request wrapper, you could detect that if the actual request path is /auth/session/refresh
GET, return a POST instead, so that the middleware handles it.
About the // TODO: read from responseWrapper and send relevant response.
part, you would have to create mapping from responses written by the middleware to html / text responses that you want to send to the frontend. If the response contains a 401 status code without clearing the cookies, it means you want to navigate to the refresh route, else to the login page..
So essentially, you would end up reusing all the middleware logic making the overall code easier.
If this kind of makes sense, I can attempt to try this method out by forking your repo. If there is fundamental issue with this (im not too familiar with remix), lmk πITEnthusiasm
01/13/2023, 2:23 PMserver.js
file handles the error cases for getSession
, I think. (You can look at the deriveSession
and setupRemixContext
functions to verify.) The server.js
file is the entry point for the entire Remix app, so any session errors that would have required redirects would already have been caught before I attempt to call my custom logout and refresh functions. Was that the only concern in terms of functionality? Does everything else seem to be working?ITEnthusiasm
01/13/2023, 2:24 PMSuperTokensHelpers.signin
). And in reality, these helper functions are pretty small and simple. Oftentimes, developers will make small, simple functions in order to handle interactions with their databases; this is to be expected for SSR frameworks/apps. With something as important as authentication, it's not surprising (nor is it inconvenient) for developers to also write a small amount of code to make sure auth is working correctly. And it's more flexible for developers to do this in their framework's way than it is to try to push it into their middleware (if their framework even allows that).ITEnthusiasm
01/13/2023, 2:24 PMsupertokens-node
could be refactored such that the request
and the response
are not interacted with (nor required) directly. Instead of interacting with `req`/`res`, the functions/methods would take in cookie data and return response headers + response cookies. If that happened, then in my codebase, the SuperTokensData.Input
and SuperTokensData.Output
classes would go away. And I (as well as all other developers) would only need to work with SuperTokensHelpers
in a single file. (In fact, the helpers could be inlined directly in the server `action`s if desired.) This seems to provide a simple-but-flexible approach for developers -- whether they use an SSR framework or Express
. And from the looks of what I have, the refactors would really only be needed for `Session`'s methods (getSession
, createSession
, etc.).ITEnthusiasm
01/13/2023, 2:25 PMITEnthusiasm
01/13/2023, 2:31 PMhandleRequest
function would get passed to an Express Middleware. This is entry.server.tsx
, which is different.
**Edit**: The snippet doesn't work. π¬
supertokens-node
goes, one of the best solutions I think is an update to Session
. Otherwise, the code would still be a bit confusing, and supertokens-node
would have to create custom wrappers for every single SSR framework -- which is impractical.ITEnthusiasm
01/13/2023, 4:09 PMhandleRequest
in Remix
is only for server rendering; it doesn't interact at all with the `loader`s, `action`s, etc. And it's the `action`s and `loader`s that specifically need to be called during login, logout, refresh, etc. Moreover, handleDataRequest
(separate from handleRequest
) only allows us to interact with the result of a loader
or `action`; it won't override any logic for us. (This, of course, makes sense because if there's any action-related logic, it should simply be placed directly in the action.) So we cannot reuse middleware()
anyway. The other SSR frameworks (Svelte Kit, SolidStart, etc.) will run into a similar issue. I really don't think there's a way around updating `Session`'s methods if there's a desire to support all popular frameworks in a flexible, reliable way.rp_st
01/14/2023, 5:36 AMSuperTokensHelpers.logout
function - how will errors from getSession be caught from this function? Also, if you are already doing session verification in server.js, why also do it in SuperTokensHelpers.logout?
The getSession in server.js in deriveSession
should probably pass in the sessionRequired option as false
. This will prevent it from throwing an unauthorised error and return undefined
instead of the session object. If it returns undefined
, the value of res.locals
would be res.locals = { user: { id: undefined } };
.
Why are we doing getLoadContext: () => ({ ...res.locals }),
in the createRequestHandler
function call if we are not consuming it anywhere? Maybe I just can't find where it is being consumed?
-----------------
About not using the middleware, Im really not sure if thats the best approach from SuperTokens point of view cause whilst for simple use cases, expecting devs to write the API logic themselves using the helper functions works. But when we add multi tenancy, account linking etc to the mix, it suddenly get's really complex.
Let me ask you this - If the APIs exposed via the supertokens middleware were exposed via the supertokens core itself (similar to other auth services), how would those APIs be called from the remix frontend? Cause technically, you could use the supertokens middleware in server.js (as a regular express middleware), and then from remix's point of view, it would just be APIs exposed by some auth service (that happens to have the same domain) which it needs to call.rp_st
01/14/2023, 5:41 AMnpm i -d
npm run dev
Got the following error: https://gist.github.com/rishabhpoddar/bfce3750a10fd373562d5e137c861d24rp_st
01/14/2023, 10:39 AMITEnthusiasm
01/14/2023, 3:23 PMserver.js
file handles the authentication piece, I was hoping that any errors would be caught? But I figured you guys would know for sure.
> Also, if you are already doing session verification in server.js, why also do it in SuperTokensHelpers.logout?
I need something that will allow me to revoke the current session and get response cookies to send back to the browser. That was the only approach I was aware of. Same for the token refresh.
> The getSession in server.js in deriveSession should probably pass in the sessionRequired option as false
For some reason, I still seemed to be getting errors even when I made sessionRequired
false, so I didn't bother. Maybe I can try again?
> Why are we doing getLoadContext: () => ({ ...res.locals }), in the createRequestHandler function call if we are not consuming it anywhere?
getLoadContext
is what sets the context
object that's passed to all of Remix's server functions (i.e., loaders
, actions
, etc.). The server.js
file doesn't do anything with `res.locals`; Remix does.ITEnthusiasm
01/14/2023, 3:25 PMREADME.md
file includes information about how to get the application started, as well as other potentially useful details. In order for the app to work, you first have to compile the SCSS files to CSS using npm run sass
. (You don't have to keep the sass compiler running if you don't want to.)
After that, the configuration variables need to be set properly through the .env
file. (The variable names can also be found in the README.md
file.)ITEnthusiasm
01/14/2023, 3:43 PMmain
branch). But that implementation breaks when using HTTPS, so it is no longer valid. Even if middleware worked here, it would not be guaranteed to work for Svelte Kit
or SolidStart
.
I suppose that theoretically, the Remix application would be able to work if it called SuperTokens core directly. We can't call http://localhost:3000
when the server is HTTPS-only (this is a completely valid use case). And we can't call https://localhost:3000
because it's impossible to make secure, valid certificates for localhost. (Using something like mkcert
in prod would be an unnecessary, dangerous, and hacky solution.) We shouldn't (and sometimes can't) call https://MYDOMAIN.com
because it creates an unnecessary round trip that hurts user experience (waiting time). For highly active applications, this is impractical. (It's also just hacky.) We can call http://localhost:3567
because it is not an HTTPS-only server and does not require round trips. So that's good. However, taking this approach would require developers to learn the core API. And that seems a lot more complicated than just using an updating version of Session
.ITEnthusiasm
01/14/2023, 3:58 PMsupertokens-node
. But to me, the solution to this problem is pretty simple: Improve the APIs to simplify the developer experience.
Just like I'm doing the on the experimental branch of my Remix app, supertokens-node
could expose helper functions for the more complex use cases. And these helper functions can still accept the input headers/cookies as a Map
and return the response headers and cookies as separate `Map`s (as shown on the branch).
And as long as the documentation was kept crystal clear, and the supertokens-node
helper functions simplified and accomplished as much as they could without abstracting too much away (e.g., without requiring req
, res
objects), the developer experience would still be good.ITEnthusiasm
01/14/2023, 4:30 PMsupertokens-node
to be able to push into these frameworks with the advantage of flexibility. But it's going to be harder to do this if supertokens-node
goes against the flow of what these SSR frameworks are trying to do (and what they require, allow, and ban). Long term, I'm not saying that supertokens-node
needs to throw away middleware. But I am saying that the core pieces of SuperTokens (e.g., the Session
class) shouldn't assume that they're in a middleware-like context. If they do, the userbase will be limited, and SuperTokens will run into these incompatibility issues. And if for any reason another competitor arises that is more compatible (or an existing competitor catches on and changes their approach), then SuperTokens will be at a disadvantage.rp_st
01/14/2023, 4:34 PMrp_st
01/14/2023, 4:34 PMrp_st
01/14/2023, 4:35 PMrp_st
01/14/2023, 4:37 PMITEnthusiasm
01/14/2023, 4:43 PMBaseResponse
). That's just a random separate comment though. I'm not saying that's a crazy priority or anything.
But as long as there's a way to push forward without requiring middleware, I think that would be huge so thanks. ππΏrp_st
01/14/2023, 4:44 PMITEnthusiasm
01/14/2023, 4:47 PMts
const remixApp = express();
const superTokens = express();
remixApp.listen(443);
superTokens.listen(3458);
But that still doesn't guarantee anything for Svelte Kit or SolidStart -- or other future frameworks.rp_st
01/14/2023, 4:48 PMITEnthusiasm
01/14/2023, 4:49 PMITEnthusiasm
01/14/2023, 4:51 PMlocalhost
. So when someone attempts fetch(https://localhost:443)
(etc.), the request fails because Node.js doesn't trust the server (even though it's calling itself).rp_st
01/14/2023, 4:51 PMITEnthusiasm
01/14/2023, 4:51 PMhttp
is banned on https-only servers.ITEnthusiasm
01/14/2023, 4:52 PMrp_st
01/14/2023, 4:52 PMITEnthusiasm
01/14/2023, 4:54 PM443
and has some higher security configurations through its integration with Cloudflare.rp_st
01/14/2023, 4:54 PMrp_st
01/14/2023, 4:55 PMITEnthusiasm
01/14/2023, 4:57 PMITEnthusiasm
01/14/2023, 4:58 PMserver.js
file and attached SuperTokens middleware to that, then I could make that an http server. Then the problem goes away -- as far as my own project is concerned.
But that won't be a valid solution for people who aren't using the Node Adapter for Remix. And it's not reliable for other SSR frameworks.rp_st
01/14/2023, 4:59 PMITEnthusiasm
01/14/2023, 5:00 PMrp_st
01/14/2023, 5:00 PMITEnthusiasm
01/14/2023, 5:01 PMrp_st
01/14/2023, 5:02 PMrp_st
01/14/2023, 5:03 PMrp_st
01/14/2023, 5:04 PMITEnthusiasm
01/14/2023, 5:06 PMremix-supertokens
repo. (I'd like to add other kinds of examples to it but I just haven't had the time.)ITEnthusiasm
01/14/2023, 5:07 PMmain
after tagging what I currently have on there. Then I'll update and push svelte-kit-supertokens
and solid-start-supertokens
ITEnthusiasm
01/14/2023, 5:07 PMrp_st
01/14/2023, 5:08 PMrp_st
01/14/2023, 5:09 PMITEnthusiasm
01/14/2023, 5:10 PMrp_st
01/14/2023, 5:10 PMITEnthusiasm
01/14/2023, 5:12 PMapp
directory. When someone sees a /login
route and a /reset-password
route, they're probably going to be thinking, "Where are /logout.tsx
and /refresh.tsx
?" And there will be cognitive overhead with that. So I was trying to circumvent that as far as the remix-supertokens
example is concerned.
People in these SSR frameworks are trained to put as much into the "app" (main project) directory as possible for ease of use.rp_st
01/14/2023, 5:14 PMITEnthusiasm
01/14/2023, 5:34 PMrp_st
01/14/2023, 5:46 PMITEnthusiasm
01/18/2023, 8:58 PMnpm install > npm run dev
. Simpler startup than the Remix app. Still needs a custom .env
file though.
https://github.com/ITenthusiasm/svelte-kit-supertokensITEnthusiasm
01/18/2023, 9:00 PMITEnthusiasm
01/18/2023, 9:01 PMSolidStart
still has some server bugs to iron out. So I haven't been able to make any additional progress there. π I really wanna use SolidStart
, though. I would translate my other project from Remix to SolidStart if it was an option.ITEnthusiasm
01/18/2023, 9:05 PMrp_st
01/19/2023, 5:11 AMITEnthusiasm
02/08/2023, 4:54 PMrp_st
02/08/2023, 7:58 PMITEnthusiasm
02/08/2023, 9:55 PMITEnthusiasm
04/13/2023, 12:36 PMcreateNewSession
now requires a request object in order to function correctly. (This seems to be old news now. π
)
- https://github.com/supertokens/supertokens-node/blob/master/CHANGELOG.md#1300---2023-02-01
- https://github.com/ITenthusiasm/svelte-kit-supertokens/issues/1
This adds slightly extra effort for SvelteKit, Remix, etc., as now I need to update the example repos. π
Does anything in particular need to be tacked onto this request object for the session creation to work correctly? Or would a random request object without any meaningful information be sufficient?
I was hoping things would move more towards data-in/data-out than req-res-in/req-res-out. Was there a motivation for this change?rp_st
04/13/2023, 12:38 PMITEnthusiasm
04/13/2023, 12:39 PMrp_st
04/13/2023, 12:40 PMITEnthusiasm
04/13/2023, 12:42 PMrp_st
04/13/2023, 12:42 PMITEnthusiasm
05/30/2023, 12:36 PMSession.*WithoutRequestResponse()
methods now. Are these the functions you were talking about?rp_st
05/30/2023, 12:52 PMrp_st
05/30/2023, 12:52 PMrp_st
05/30/2023, 12:52 PMITEnthusiasm
05/30/2023, 1:05 PMsession
?ITEnthusiasm
05/30/2023, 1:33 PMITEnthusiasm
05/31/2023, 12:42 PMrp_st
05/31/2023, 12:46 PMrp_st
05/31/2023, 12:46 PMITEnthusiasm
05/31/2023, 12:49 PMdangeoruslySetInnerHTML
.ITEnthusiasm
05/31/2023, 12:49 PMrp_st
05/31/2023, 12:52 PMITEnthusiasm
06/06/2023, 6:38 PMUsing getSession without req / res objects
): Would it make sense to avoid let
and just put the entire success case in the try
block and let the catch
block handle the entire fail case? Just think it might be easier to read.ITEnthusiasm
06/06/2023, 6:39 PMrp_st
06/06/2023, 6:40 PMITEnthusiasm
06/06/2023, 6:44 PMSuperTokensError.type
is string
instead of Session.Error
. Is that intentional? I guess there could be errors for things unrelated to sessionsrp_st
06/06/2023, 6:44 PMITEnthusiasm
06/06/2023, 6:45 PMITEnthusiasm
06/06/2023, 6:50 PMtokens.accessAndFrontTokenUpdated
is false
. Is there a danger if we just set the tokens without checking this?ITEnthusiasm
06/06/2023, 6:50 PMrp_st
06/06/2023, 6:50 PMundefined
for those if this boolean is false.ITEnthusiasm
06/06/2023, 6:51 PMITEnthusiasm
06/06/2023, 6:51 PMITEnthusiasm
06/06/2023, 7:15 PMfrontToken
if the frontend isn't using the token right? Are the tokens just http cookies?ITEnthusiasm
06/06/2023, 7:21 PMrp_st
06/06/2023, 7:21 PMrp_st
06/06/2023, 7:21 PMITEnthusiasm
06/06/2023, 7:22 PMLoading supertokens config.
Completed config.yaml loading.
Loading storage layer.
Using in memory storage.
Loading supertokens version.yaml file.
Started SuperTokens on localhost:3567 with PID: 54029
^This, right?rp_st
06/06/2023, 7:22 PMITEnthusiasm
06/06/2023, 7:23 PMrp_st
06/06/2023, 7:26 PMITEnthusiasm
06/06/2023, 7:27 PMrp_st
06/06/2023, 7:28 PMrp_st
06/06/2023, 7:28 PMITEnthusiasm
06/06/2023, 7:42 PMITEnthusiasm
06/06/2023, 7:42 PMrp_st
06/06/2023, 7:43 PMITEnthusiasm
06/06/2023, 8:01 PMEmailPassword
. I don't have any updates to do related to the DB because I'm just trying to use the in-memory databaseITEnthusiasm
06/06/2023, 8:23 PMError: Initialisation not done. Did you forget to call the SuperTokens.init function?
at Recipe.getInstanceOrThrowError
ITEnthusiasm
06/06/2023, 8:23 PMSuperTokens.init()
π€ITEnthusiasm
06/06/2023, 8:28 PMITEnthusiasm
06/06/2023, 8:37 PMITEnthusiasm
06/06/2023, 8:43 PMrp_st
06/07/2023, 6:05 AMITEnthusiasm
06/07/2023, 12:08 PMITEnthusiasm
06/07/2023, 12:22 PMcreate-supertokens-app
and point to http://localhost:3567
, I get the same error:
Error: No SuperTokens core available to query
at Querier.<anonymous> (/Users/USERNAME/repos/not-actually-repos/my-app/backend/node_modules/supertokens-node/lib/build/querier.js:232:27)
at Generator.next (<anonymous>)
at /Users/USERNAME/repos/not-actually-repos/my-app/backend/node_modules/supertokens-node/lib/build/querier.js:30:75
at new Promise (<anonymous>)
at __awaiter (/Users/USERNAME/repos/not-actually-repos/my-app/backend/node_modules/supertokens-node/lib/build/querier.js:12:16)
at Querier.sendRequestHelper (/Users/USERNAME/repos/not-actually-repos/my-app/backend/node_modules/supertokens-node/lib/build/querier.js:225:13)
at Querier.<anonymous> (/Users/USERNAME/repos/not-actually-repos/my-app/backend/node_modules/supertokens-node/lib/build/querier.js:253:43)
at Generator.throw (<anonymous>)
at rejected (/Users/USERNAME/repos/not-actually-repos/my-app/backend/node_modules/supertokens-node/lib/build/querier.js:22:44)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
ITEnthusiasm
06/07/2023, 12:23 PMrp_st
06/07/2023, 12:23 PMrp_st
06/07/2023, 12:23 PMrp_st
06/07/2023, 12:24 PMhttps://try.supertokens.com
core insteadITEnthusiasm
06/07/2023, 12:27 PMhttps://try.supertokens.com
seems to work. Unfortunately, I'll still need a way to interact with my local, so I can't fully jump ship to the test URL, unfortunately. π
ITEnthusiasm
06/07/2023, 12:27 PMITEnthusiasm
06/07/2023, 12:27 PMrp_st
06/07/2023, 1:20 PMITEnthusiasm
06/07/2023, 1:27 PMrp_st
06/07/2023, 1:27 PMrp_st
06/07/2023, 1:27 PMITEnthusiasm
06/07/2023, 1:33 PMts
const result = await fetch("http://localhost:3567/hello").then((res) => res.text(), console.log);
console.log("Response: ", result);
yields this
TypeError: fetch failed
at fetch (/Users/USERNAME/repos/personal/svelte-kit-supertokens/node_modules/undici/index.js:109:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async load (/Users/USERNAME/repos/personal/svelte-kit-supertokens/src/routes/login/+page.server.ts:24:18)
at async Module.load_server_data (/Users/USERNAME/repos/personal/svelte-kit-supertokens/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js:57:17)
at async eval (/Users/USERNAME/repos/personal/svelte-kit-supertokens/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:150:13) {
cause: Error: connect ECONNREFUSED ::1:3567
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
errno: -61,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '::1',
port: 3567
}
}
Response: undefined
Maybe fits more in line with the firewall theory? But still odd since curl
and the browser can see Hello
just fine. Just throwing that out as extra info.ITEnthusiasm
06/07/2023, 1:47 PMrp_st
06/07/2023, 2:02 PMrp_st
06/07/2023, 2:02 PMITEnthusiasm
06/07/2023, 2:23 PMnode@16
to node@18
. That seems to be the problem. π https://github.com/node-fetch/node-fetch/issues/1624ITEnthusiasm
06/07/2023, 2:24 PM127.0.0.1:3567
instead of localhost
I can fetch
the endpoint fineITEnthusiasm
06/07/2023, 2:33 PMnode@18
issue.ITEnthusiasm
06/07/2023, 2:33 PMsIdToken
or something. Do we need to use specific names or can we create our own?
**Edit**: I'm assuming I can just use this for reference: https://supertokens.com/docs/emailpassword/common-customizations/sessions/cookie-consent.ITEnthusiasm
06/07/2023, 2:39 PMrp_st
06/07/2023, 3:22 PMsIdRefreshToken
- this is now eliminated.
> Do we need to use specific names or can we create our own?
If you are using our frontend sdk, then yea. Else no.
> Do we just set the cookies in the browser without an expiration date and let SuperTokens tell us when the token is expired during API calls?
You can set the cookie expiry to a long time ~10 years.. cause our getSession checks for access token expiry.ITEnthusiasm
06/07/2023, 3:30 PMgetSession
or getSession
and getSessionWithoutRequestResponse
?rp_st
06/07/2023, 3:34 PMITEnthusiasm
06/07/2023, 3:34 PMexpires
, then I'm assuming we're manually setting domain
, secure
, httpOnly
, path
, and sameSite
as well? (I think these are the cookie settings that were previously applied by SuperTokens's BaseResponse.setCookie
method.)rp_st
06/07/2023, 3:34 PMITEnthusiasm
06/07/2023, 3:35 PMpath
option at some point. Thanks as always π
ITEnthusiasm
06/07/2023, 3:51 PMSession.getAllSessionTokensDangerously
) didn't include settings for the cookies when they were written? For example, the recommended sameSite
or path
to use?
I know the docs give warnings about manually setting things like sameSite
, so I was a little surprised to see the information not be included somewhere in the tokens
object. Did the method just not have easy access to the recommended cookie settings? Or did it seem inconvenient to add that info to the object?rp_st
06/07/2023, 3:53 PMITEnthusiasm
06/07/2023, 3:54 PMITEnthusiasm
06/07/2023, 6:34 PMantiCsrf
get set? π€ Is it dynamic? Or is it dependent on the supertokens configuration?rp_st
06/07/2023, 6:36 PMITEnthusiasm
06/07/2023, 6:38 PMdisableAntiCsrf
is off, we get the token?rp_st
06/07/2023, 6:52 PMITEnthusiasm
06/07/2023, 8:58 PMSession.createNewSessionWithoutRequestResponse(userId)
a valid userId
, I shouldn't expect an error, right? Barring random unexpected errors?ITEnthusiasm
06/07/2023, 9:41 PMcatch
block we won't have access to a valid session? π€ITEnthusiasm
06/07/2023, 10:58 PMantiCsrf
token when I login. π€ Is it disabled by default?ITEnthusiasm
06/08/2023, 12:59 AMaccessToken
, getSessionWithoutRequestResponse
will give an UNAUTHORIZED
error even if the user had a refresh token.
Are we supposed to use refreshSessionWithoutRequestResponse
whenever a user triggers the UNAUTHORIZED
error?ITEnthusiasm
06/08/2023, 1:09 AMgetSessionWithoutRequestResponse
would just give an error saying that we should try a refresh if there's no access token at all, shouldn't it?rp_st
06/08/2023, 4:20 AMrp_st
06/08/2023, 4:20 AMrp_st
06/08/2023, 4:21 AMrp_st
06/08/2023, 4:21 AMrp_st
06/08/2023, 4:22 AMITEnthusiasm
06/08/2023, 12:07 PMgetSessionWithoutRequestResponse
to throw all 4 error types.ITEnthusiasm
06/08/2023, 12:07 PMantiCsrf
to be disabled by default? π€rp_st
06/08/2023, 12:08 PMrp_st
06/08/2023, 12:08 PMITEnthusiasm
06/08/2023, 12:09 PMrp_st
06/08/2023, 12:10 PMITEnthusiasm
06/08/2023, 12:11 PMITEnthusiasm
06/08/2023, 12:11 PMrp_st
06/08/2023, 12:20 PMcreateNewSessionWithoutRequestResponse
, and if you get an anti csrf token, then you should pass that in when using getSessionWithoutRequestResponse
.
If you do not get an anti csrf token, you don't need it (based on your apiDomain and websiteDomain setting) and should check for custom request header before calling getSessionWithoutRequestResponse
rp_st
06/08/2023, 12:20 PMITEnthusiasm
06/08/2023, 12:25 PMITEnthusiasm
06/08/2023, 12:27 PMITEnthusiasm
06/08/2023, 12:27 PMITEnthusiasm
06/08/2023, 12:29 PMTRY_REFRESH_TOKEN
error? But if the Access Token is missing or is invalid, then the user is Unauthorized and no refresh should be attempted at all. Just remove the user's cookies?rp_st
06/08/2023, 12:30 PMITEnthusiasm
06/08/2023, 12:30 PMITEnthusiasm
06/08/2023, 12:31 PMDevTools > Application Tab
and delete their access token cookie.ITEnthusiasm
06/08/2023, 12:44 PMTOKEN_THEFT_DETECTED
error... even if getSessionWithoutRequestResponse
doesn't throw that error like the example shows in the docs, I'm assuming that I'd still run into the issue that I described earlier with refreshSessionWithoutRequestResponse
. That is, I'd run into a situation where -- because an error was thrown
-- I wouldn't have access to the underlying session
so that I could revoke it. In that case, should I re-call the method and revoke the session instead?
Like this?
ts
try {
const session = Session.refreshSessionWithoutRequestResponse(...args);
return session.getAllSessionTokensDangerously();
} catch (error) {
if (!SuperTokensError.isErrorFromSuperTokens(error)) throw error;
if (error.type === Session.Error.TOKEN_THEFT_DETECTED) {
const session = Session.refreshSessionWithoutRequestResponse(...args, { sessionRequired: false });
session?.revokeSession();
// ...
}
// ...
}
rp_st
06/08/2023, 12:53 PMrp_st
06/08/2023, 12:54 PMITEnthusiasm
06/08/2023, 12:57 PMITEnthusiasm
06/08/2023, 12:57 PMrp_st
06/08/2023, 12:58 PMITEnthusiasm
06/08/2023, 12:59 PMrp_st
06/08/2023, 1:00 PMITEnthusiasm
06/08/2023, 1:02 PMITEnthusiasm
06/08/2023, 1:03 PMuserId
and sessionHandle
? Is it error.payload
?rp_st
06/08/2023, 1:08 PMITEnthusiasm
06/08/2023, 1:09 PMITEnthusiasm
06/08/2023, 1:09 PMany
in TS πrp_st
06/08/2023, 1:13 PMrp_st
06/08/2023, 1:13 PMrp_st
06/08/2023, 1:13 PMITEnthusiasm
06/08/2023, 1:18 PMts
export default class SuperTokensError extends Error {
private static errMagic;
static BAD_INPUT_ERROR: "BAD_INPUT_ERROR";
type: string;
payload: any;
fromRecipe: string | undefined;
private errMagic;
constructor(
options:
| {
message: string;
payload?: any;
type: string;
}
| {
message: string;
type: "BAD_INPUT_ERROR";
payload: undefined;
}
);
static isErrorFromSuperTokens(obj: any): obj is SuperTokensError;
}
rp_st
06/08/2023, 1:24 PMITEnthusiasm
06/08/2023, 4:02 PMantiCsrf
token be removed if someone's session is revoked? Does that matter?rp_st
06/08/2023, 4:16 PMITEnthusiasm
06/08/2023, 4:23 PMSession.refreshSessionWithoutRequestResponse
? π€
SessionError: javax.crypto.AEADBadTagException: Tag mismatch!
at Object.<anonymous> (/Users/USERNAME/repos/personal/svelte-kit-supertokens/node_modules/supertokens-node/lib/build/recipe/session/sessionFunctions.js:295:19)
at Generator.next (<anonymous>)
at fulfilled (/Users/USERNAME/repos/personal/svelte-kit-supertokens/node_modules/supertokens-node/lib/build/recipe/session/sessionFunctions.js:15:36)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'UNAUTHORISED',
payload: { clearTokens: true },
errMagic: 'ndskajfasndlfkj435234krjdsa',
fromRecipe: 'session'
}
Just logging in and immediately navigating to /auth/session/refresh
π€rp_st
06/08/2023, 4:23 PMrp_st
06/08/2023, 4:23 PMITEnthusiasm
06/08/2023, 4:25 PMrefreshToken
value when sending it back as a cookie, right?ITEnthusiasm
06/08/2023, 4:25 PMrp_st
06/08/2023, 4:28 PMITEnthusiasm
06/08/2023, 4:33 PMITEnthusiasm
06/08/2023, 4:55 PMITEnthusiasm
06/08/2023, 5:10 PMITEnthusiasm
06/08/2023, 5:34 PMITEnthusiasm
06/08/2023, 5:39 PMPath
need to be set when forcing a cookie to expire?rp_st
06/08/2023, 5:41 PMrp_st
06/08/2023, 5:41 PMITEnthusiasm
06/08/2023, 5:42 PMITEnthusiasm
06/08/2023, 5:42 PMPath
. π€ITEnthusiasm
06/08/2023, 6:00 PMPath
allows). At least, Chrome will. It probably also takes Path
into account when deleting cookies ... I'm assuming this is why I was experiencing buggy behavior during refreshing. This is helpful to know but kinda annoying. So I do indeed need Path
when forcing expire so that the Browser knows "which cookie" to delete.
https://stackoverflow.com/questions/23544138/2-cookies-with-the-same-name-and-domain-but-different-paths
https://stackoverflow.com/questions/4056306/how-to-handle-multiple-cookies-with-the-same-name/24214538#24214538rp_st
06/08/2023, 6:03 PMrp_st
06/08/2023, 6:04 PMITEnthusiasm
06/08/2023, 6:05 PMITEnthusiasm
06/08/2023, 10:50 PMITEnthusiasm
06/08/2023, 11:36 PMaccess_token_validity
doesn't seem to change anything π€ Even if I change the value to 60 seconds, the token remains valid after a minuterp_st
06/09/2023, 5:44 AMITEnthusiasm
06/09/2023, 12:20 PM{
"exp": 1686316731,
"iat": 1686313131,
"antiCsrfToken": null,
"iss": "http://localhost:5173/auth"
}
ITEnthusiasm
06/09/2023, 1:13 PMexp
and iat
are in milliseconds? But whatever the case is, it doesn't seem like this is acknowledged.rp_st
06/09/2023, 1:13 PMrp_st
06/09/2023, 1:14 PMrp_st
06/09/2023, 1:14 PMITEnthusiasm
06/09/2023, 1:15 PMsupertokens stop
supertokens list # Verify nothing is running
vi /usr/local/etc/supertokens/config.yaml # Then apply edits
supertokens start
npm run dev
ITEnthusiasm
06/09/2023, 1:16 PMrp_st
06/09/2023, 1:16 PMITEnthusiasm
06/09/2023, 1:16 PMrp_st
06/09/2023, 1:16 PMrp_st
06/09/2023, 1:16 PMsupertokens --help
and show me the output?ITEnthusiasm
06/09/2023, 1:17 PMYou are using SuperTokens Community
Usage: supertokens [command] [--help] [--version]
Commands:
-> hashingCalibrate [options] Used to calibrate the settings for
password hashing algorithms for a
specific machine
-> uninstall Uninstalls SuperTokens
-> stop [options] Stops all (if no options are provided)
or one specific instance of SuperTokens
-> start [options] Start an instance of SuperTokens
-> list List information about all currently
running SuperTokens instances
Files:
Installation location /usr/local/etc/supertokens/
Default config file /usr/local/etc/supertokens/config.yaml
Legal license /usr/local/etc/supertokens/LICENSE.md
Thank you for checking out SuperTokens :)
rp_st
06/09/2023, 1:17 PMrp_st
06/09/2023, 1:17 PMITEnthusiasm
06/09/2023, 1:17 PMrp_st
06/09/2023, 1:18 PMITEnthusiasm
06/09/2023, 1:20 PMITEnthusiasm
06/09/2023, 1:20 PMcat /usr/local/etc/supertokens/config.yaml
rp_st
06/09/2023, 1:20 PM#
from the fileITEnthusiasm
06/09/2023, 1:20 PMrp_st
06/09/2023, 1:20 PMITEnthusiasm
06/09/2023, 1:21 PMITEnthusiasm
06/09/2023, 1:23 PMITEnthusiasm
06/09/2023, 1:23 PMITEnthusiasm
06/09/2023, 1:24 PMrp_st
06/09/2023, 1:25 PMITEnthusiasm
06/09/2023, 1:26 PMgetSessionWithoutRequestResponse
ever throw any other error besides TRY_REFRESH_TOKEN
and UNAUTHORIZED
?rp_st
06/09/2023, 1:26 PMITEnthusiasm
06/09/2023, 1:30 PMITEnthusiasm
06/12/2023, 12:37 PMnode@14
using the *WithoutRequestResponse
methods. If anyone on the team is interested in testing it, it's on the next
branch of the repo: https://github.com/ITenthusiasm/svelte-kit-supertokens/tree/next. I tried to add a TEST_CASES.md
file to keep track of what made sense to support. Not sure if anything's missing.
I will try to update the Remix app at some point.
Also, next@13
is still in "pseudo-beta" in that they haven't figured out all their features yet. But it does look like what I predicted sometime back is actually happening: Next.js is becoming more and more like Remix + SvelteKit. The most important thing is that they're adopting Form Actions (e.g., https://remix.run/docs/en/main/route/action, https://kit.svelte.dev/docs/form-actions). So these new SuperTokens methods will be helpful in integrating cleanly with their Form Actions as well.
Once either the new Supertokens + SvelteKit
app or the new SuperTokens + Remix
app (not yet updated) is tested, I'll probably look into what can be done with Next.js. Their Form Actions are still experimental though.rp_st
06/12/2023, 12:49 PMrp_st
06/12/2023, 12:49 PMrp_st
06/12/2023, 12:51 PMITEnthusiasm
06/12/2023, 1:03 PMrp_st
06/12/2023, 1:16 PM