@edgedb/auth-sveltekit
Advanced tools
Comparing version 0.2.0-canary.20240503T160013 to 0.2.0-canary.20240503T172103
@@ -52,2 +52,4 @@ import { type RequestEvent, type Handle } from "@sveltejs/kit"; | ||
isPasswordResetTokenValid(resetToken: string): boolean | null; | ||
private setVerifierCookie; | ||
private setAuthCookie; | ||
getProvidersInfo(): Promise<{ | ||
@@ -54,0 +56,0 @@ oauth: { |
@@ -44,2 +44,20 @@ import { redirect, } from "@sveltejs/kit"; | ||
} | ||
setVerifierCookie(verifier) { | ||
const expires = new Date(Date.now() + 1000 * 60 * 24 * 7); // In 7 days | ||
this.cookies.set(this.config.pkceVerifierCookieName, verifier, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
expires, | ||
}); | ||
} | ||
setAuthCookie(authToken) { | ||
const expires = Auth.getTokenExpiration(authToken); | ||
this.cookies.set(this.config.authCookieName, authToken, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
expires: expires ?? undefined, | ||
}); | ||
} | ||
async getProvidersInfo() { | ||
@@ -51,14 +69,6 @@ return (await this.core).getProvidersInfo(); | ||
const result = await (await this.core).signupWithEmailPassword(email, password, `${this.config.authRoute}/emailpassword/verify`); | ||
this.cookies.set(this.config.pkceVerifierCookieName, result.verifier, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
}); | ||
this.setVerifierCookie(result.verifier); | ||
if (result.status === "complete") { | ||
const tokenData = result.tokenData; | ||
this.cookies.set(this.config.authCookieName, tokenData.auth_token, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
}); | ||
this.setAuthCookie(tokenData.auth_token); | ||
return { tokenData }; | ||
@@ -84,7 +94,3 @@ } | ||
const { verifier } = await (await this.core).resendVerificationEmailForEmail(email.toString(), `${this.config.authRoute}/emailpassword/verify`); | ||
this.cookies.set(this.config.pkceVerifierCookieName, verifier, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
}); | ||
this.setVerifierCookie(verifier); | ||
} | ||
@@ -98,7 +104,3 @@ else { | ||
const tokenData = await (await this.core).signinWithEmailPassword(email, password); | ||
this.cookies.set(this.config.authCookieName, tokenData.auth_token, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
}); | ||
this.setAuthCookie(tokenData.auth_token); | ||
return { tokenData }; | ||
@@ -112,7 +114,3 @@ } | ||
const { verifier } = await (await this.core).sendPasswordResetEmail(email, new URL(this.config.passwordResetPath, this.config.baseUrl).toString()); | ||
this.cookies.set(this.config.pkceVerifierCookieName, verifier, { | ||
httpOnly: true, | ||
sameSite: "strict", | ||
path: "/", | ||
}); | ||
this.setVerifierCookie(verifier); | ||
} | ||
@@ -126,7 +124,3 @@ async emailPasswordResetPassword(data) { | ||
const tokenData = await (await this.core).resetPasswordWithResetToken(resetToken, verifier, password); | ||
this.cookies.set(this.config.authCookieName, tokenData.auth_token, { | ||
httpOnly: true, | ||
sameSite: "lax", | ||
path: "/", | ||
}); | ||
this.setAuthCookie(tokenData.auth_token); | ||
this.cookies.delete(this.config.pkceVerifierCookieName, { | ||
@@ -133,0 +127,0 @@ path: "/", |
{ | ||
"name": "@edgedb/auth-sveltekit", | ||
"description": "Helper library to integrate the EdgeDB Auth extension with Sveltekit.", | ||
"version": "0.2.0-canary.20240503T160013", | ||
"version": "0.2.0-canary.20240503T172103", | ||
"author": "EdgeDB <info@edgedb.com>", | ||
@@ -6,0 +6,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28978
526