Private
httpPrivate
keyPrivate
projectPrivate
sessionPrivate
tokensThe callback will be called when the session information changes
auth.authStateChange(session => {
// when session === undefined => loading
// when session === null => no session
// otherwise we have a valid {@link SessionInfo}
})
This method is used in combination with the passwordless method and is used to confim the authentication link
let params = new URLSearchParams(window.location.search)
auth.confirmPasswordless(
id: params.get("id"),
token: params.get("token"),
)
Optional
config: Partial<Request>Private
emailOptional
config: Partial<Request>Private
gethandle the OAuth callback and sign in the user if the code and csrf_token are valid
let params = new URLSearchParams(window.location.search)
auth.oAuthConfirm(params.get("state"), params.get("code"))
Optional
config: Partial<Request>Create new session using an authentication link, if the user does not exits, a new user will be created
Optional
config: Partial<Request>Private
removeOptional
sessionId: stringOptional
config: Partial<Request>Request to reset the current user password, if the user exists a rest email will be send to the given email address, no email will be send if the user does not exits, however the success screen will be shown in both cases
the user email address
Optional
config: Partial<Request>This method is use in combination with the resetPassword method, the generated link to reset your password contains a token id and the token value that will be used to reset the password
let params = new URLSearchParams(window.location.search)
auth.setResetPassword({
id: params.get("id"),
token: params.get("token"),
password1: 'new-password',
password2: 'new-password',
})
Optional
config: Partial<Request>Create a new session with Email and Password
<form id="signIn">
<section>
<label>Email</label>
<input name="email" type="email" />
</section>
<section>
<label>Password</label>
<input name="password" type="password" />
</section>
<button>Sign In</button>
</form>
<script>
let auth = Auth.create({ /\* config */})
let signIn = document.querySelector("#signIn")
signIn.addEventListener("submit", async (event) => {
event.preventDefault()
let formData = new FormData(event.target)
let user = await auth.signIn(
formData.get("email"),
formData.get("password"),
)
})
</script>
the user
The user email address
The user password *
Optional
config: Partial<Request>Create a new session with Email and Password and create the user if not exists
<form id="signUp">
<section>
<label>Email</label>
<input name="email" type="email" />
</section>
<section>
<label>Password</label>
<input name="password" type="password" />
</section>
<button>Sign Up</button>
</form>
<script>
let auth = Auth.create({ /\* config */})
let signUp = document.querySelector("#signUp")
signUp.addEventListener("submit", async (event) => {
event.preventDefault()
let formData = new FormData(event.target)
let user = await auth.signUp(
formData.get("email"),
formData.get("password"),
)
})
</script>
The user email address
The user password
Optional
config: Partial<Request>Verify a users email address
When the VerifyEmail flag is set, an email will be send to the user containing a link to verify the email.
```js let params = new URLSearchParams(window.location.search)
auth.verifyEmail( id: params.get("id"), token: params.get("token"), )
Optional
config: Partial<Request>This method is used in combination witht the passwordless method, it polls the server for update and resolves the promise once the authentication link has been confirmed
let { id, session } = await auth.passwordless("email@vulpo.dev")
let user = await auth.verifyPasswordless(id, session)
Optional
config: Partial<Request>This method is used in combination with the setPassword method and is used to valid whether the given token is valid or not
let params = new URLSearchParams(window.location.search)
auth.verifyToken(
id: params.get("id"),
token: params.get("token"),
)
Optional
config: Partial<Request>withToken
can be used to handle authenticated http calls, the callback will receive the
current access token.
When the request returns a 401
, a new access token will be requested and the request will
be retried once.
let res = await auth.withToken(token => {
return fetch('api.your.app', {
headers: {
'Authorization': `Bearer ${token}`,
}
})
})
Optional
session: stringGenerated using TypeDoc
Get the current session information