-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91a8f76
commit 2242489
Showing
27 changed files
with
1,014 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
# @authhero/demo | ||
|
||
## 0.5.4 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- Updated dependencies | ||
- [email protected] | ||
- @authhero/kysely-adapter@0.25.3 | ||
|
||
## 0.5.3 | ||
|
||
### Patch Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "authhero", | ||
"version": "0.25.2", | ||
"version": "0.26.0", | ||
"files": [ | ||
"dist" | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const JWKS_CACHE_TIMEOUT_IN_SECONDS = 60 * 5; // 5 minutes | ||
export const SILENT_AUTH_MAX_AGE = 30 * 24 * 60 * 60; // 30 days | ||
export const UNIVERSAL_AUTH_SESSION_EXPIRES_IN_SECONDS = 24 * 60 * 60; // 1 day | ||
export const SILENT_COOKIE_NAME = "auth-token"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Context } from "hono"; | ||
import { Bindings, Variables } from "../types"; | ||
import { User } from "@authhero/adapter-interfaces"; | ||
import { HTTPException } from "hono/http-exception"; | ||
|
||
export async function sendEmail( | ||
ctx: Context<{ Bindings: Bindings; Variables: Variables }>, | ||
tenant_id: string, | ||
to: string, | ||
subject: string, | ||
html: string, | ||
) { | ||
const emailProvider = await ctx.env.data.emailProviders.get(tenant_id); | ||
|
||
if (!emailProvider) { | ||
throw new HTTPException(500, { message: "Email provider not found" }); | ||
} | ||
|
||
const emailService = ctx.env.emailProvders?.[emailProvider.name]; | ||
if (!emailService) { | ||
throw new HTTPException(500, { message: "Email provider not found" }); | ||
} | ||
|
||
emailService({ | ||
to, | ||
from: emailProvider.default_from_address || `login@${ctx.env.ISSUER}`, | ||
subject, | ||
html, | ||
}); | ||
} | ||
|
||
export async function sendResetPassword( | ||
ctx: Context<{ Bindings: Bindings; Variables: Variables }>, | ||
tenant_id: string, | ||
to: string, | ||
// auth0 just has a ticket, but we have a code and a state | ||
code: string, | ||
state?: string, | ||
) { | ||
await sendEmail( | ||
ctx, | ||
tenant_id, | ||
to, | ||
`Reset your password`, | ||
`Click here to reset your password: ${ctx.env.ISSUER}u/reset-password?state=${state}&code=${code}`, | ||
); | ||
} | ||
|
||
export async function sendValidateEmailAddress( | ||
ctx: Context<{ Bindings: Bindings; Variables: Variables }>, | ||
tenant_id: string, | ||
user: User, | ||
) { | ||
await sendEmail( | ||
ctx, | ||
tenant_id, | ||
user.email, | ||
`Validate your email address`, | ||
`Click here to validate your email: ${ctx.env.ISSUER}u/validate-email`, | ||
); | ||
} |
Oops, something went wrong.