https://supertokens.com/ logo
#support-questions
Title
# support-questions
s

sharma

07/11/2022, 1:07 AM
Is there any documentation for the breaking changes? I am using email/password recipe for node backend and vanila js frontend. I see certain changes on the docs site and trying to follow that. 1. To install on frontend,
supertokens-website.js
import seems to be replaced with
supertokens.js
and
session.js
But this replacement had breaking changes, few I can see as following on the frontend side 2.
supertokens.init()
function now seems to have different options schema.
supertokens.init({apiDomain: ....})
seems to be replaced with
supertokens.init({appInfo: {apiDomain: ....}})
. 3.
appInfo
object
appName
and
recipeList
property seems to have become mandatory (earlier they were optional) 4.
supertokens.signOut
fn seems to be removed. Will need to dig through doc for the replacement. I am figuring these out as I see the errors popping up. It will be great if we can have a documentation of the breaking changes and if possible, a migration guide
Also it is not completely clear - From docs, it looks like
supertokens-web-js
is needed only if I want add login UI? If I just want the sessions and reset password functionality, can I skip adding that?
n

nkshah2

07/11/2022, 2:34 AM
Hi @sharma, supertokens-web-js contains only business logic so if you just want functionality and want to build your own UI that’s the SDK you want to use
s

sharma

07/11/2022, 6:31 AM
Ok. What about the breaking changes? Specially the point #4
I do see signOut fn in web sdk ref\
But this throws error -
await supertokens.signOut();
n

nkshah2

07/11/2022, 6:33 AM
If you are using the
supertokens-web-js
SDK then the sign out functions is exposed by the recipe you use. For example if you are using the EmailPassword recipe you would do:
Copy code
import EmailPassword from "supertokens-web-js/recipe/emailpassword"

await EmailPassword.signOut()
In general
supertokens-website
should not be required unless you plan on using SuperTokens just for session management and not use any of our recipes The migration might be a little tricky so if you have any questions moving from the website SDK to the web-js SDK feel free to ask them here
s

sharma

07/11/2022, 4:05 PM
similar question for attemptRefreshToken
supertokens.attemptRefresh.. doesn't work
n

nkshah2

07/11/2022, 4:09 PM
Copy code
import Session from "supertokens-web-js/recipe/session"

await Session.attemptRefreshingSession()
s

sharma

07/13/2022, 7:59 PM
It's little confusing to see 1.
supertokensSession
vs
Session
references. Could we have used
Session
everywhere instead. Also could Session have been property of
supertokens
object itself i.e.
supertokens.session
would have been more intuitive for me 2. Also
signout
fn at first seemed to be related to
Session
and hence thought
Session.logout
would have been more intuitive. Is there any diff between session.logout vs emailpassword.logout ? I might be wrong but that's what I'd have assumed the structure of APIs when struggling to find the right info
n

nkshah2

07/14/2022, 2:02 AM
If you’re using the SDK as an npm package, the supertokensSession object does not apply to you (those are the docs for using it as an html script)
You only use the Session reference
signOut is exposed by the Session recipe as well as the others, you can call it from either Session or the recipe you use depending on which is more convenient for importing and which feels more intuitive
s

sharma

07/14/2022, 3:01 PM
when using via html script, how to call EmailPassword methods?
n

nkshah2

07/14/2022, 3:03 PM
When using as an html script you have to import multiple scripts (this isn’t documented as of yet). Along with SuperTokens and SuperTokens session bundles you would have to import the email password bundle
I can send you the full url if you need it
s

sharma

07/14/2022, 3:07 PM
yes please
n

nkshah2

07/14/2022, 3:13 PM
Copy code
// Session (use with supertokensSession)
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/session.js"></script>

// Email Password (use with supertokensEmailPassword)
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/emailpassword.js"></script>

// Third Party (use with supertokensThirdParty)
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/thirdparty.js"></script>

// Third Party Email Password (use with supertokensThirdPartyEmailPassword)
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/thirdpartyemailpassword.js"></script>

// Passwordless (use with supertokensPasswordless)
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/passwordless.js"></script>

// Third party passwordless (use with supertokensThirdPartyPasswordless)
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/thirdpartypasswordless.js"></script>
Depending on the recipes you need you can load the bundles
In addition to those you will always need to add the main supertokens bundle
Copy code
<script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/supertokens.js"></script>
If you have any questions feel free to ask
s

sharma

07/14/2022, 4:18 PM
how do we exactly call web js sdk functions for email password recipe. e.g.
sendPasswordResetEmail
fn
n

nkshah2

07/14/2022, 4:20 PM
After adding the script, you can do
Copy code
supertokensEmailPassword.sendPasswordResetEmail(...)
s

sharma

07/14/2022, 4:21 PM
cool. thanks
n

nkshah2

07/14/2022, 4:21 PM
Happy to help
s

sharma

07/14/2022, 4:37 PM
getting 400 error on
supertokensEmailPassword.sendPasswordResetEmail({formFields: [{....}]})
n

nkshah2

07/14/2022, 6:00 PM
What’s the full error?