| 41 | |
| 42 | export default { |
| 43 | async fetch(request: Request, env: Env, ctx: ExecutionContext) { |
| 44 | const result = await issuer({ |
| 45 | theme: MY_THEME, |
| 46 | providers: { |
| 47 | github: GithubProvider({ |
| 48 | clientID: Resource.GITHUB_CLIENT_ID_CONSOLE.value, |
| 49 | clientSecret: Resource.GITHUB_CLIENT_SECRET_CONSOLE.value, |
| 50 | scopes: ["read:user", "user:email"], |
| 51 | }), |
| 52 | google: GoogleOidcProvider({ |
| 53 | clientID: Resource.GOOGLE_CLIENT_ID.value, |
| 54 | scopes: ["openid", "email"], |
| 55 | }), |
| 56 | // email: CodeProvider({ |
| 57 | // async request(req, state, form, error) { |
| 58 | // console.log(state) |
| 59 | // const params = new URLSearchParams() |
| 60 | // if (error) { |
| 61 | // params.set("error", error.type) |
| 62 | // } |
| 63 | // if (state.type === "start") { |
| 64 | // return Response.redirect(process.env.AUTH_FRONTEND_URL + "/auth/email?" + params.toString(), 302) |
| 65 | // } |
| 66 | // |
| 67 | // if (state.type === "code") { |
| 68 | // return Response.redirect(process.env.AUTH_FRONTEND_URL + "/auth/code?" + params.toString(), 302) |
| 69 | // } |
| 70 | // |
| 71 | // return new Response("ok") |
| 72 | // }, |
| 73 | // async sendCode(claims, code) { |
| 74 | // const email = z.string().email().parse(claims.email) |
| 75 | // const cmd = new SendEmailCommand({ |
| 76 | // Destination: { |
| 77 | // ToAddresses: [email], |
| 78 | // }, |
| 79 | // FromEmailAddress: `SST <auth@${Resource.Email.sender}>`, |
| 80 | // Content: { |
| 81 | // Simple: { |
| 82 | // Body: { |
| 83 | // Html: { |
| 84 | // Data: `Your pin code is <strong>${code}</strong>`, |
| 85 | // }, |
| 86 | // Text: { |
| 87 | // Data: `Your pin code is ${code}`, |
| 88 | // }, |
| 89 | // }, |
| 90 | // Subject: { |
| 91 | // Data: "SST Console Pin Code: " + code, |
| 92 | // }, |
| 93 | // }, |
| 94 | // }, |
| 95 | // }) |
| 96 | // await ses.send(cmd) |
| 97 | // }, |
| 98 | // }), |
| 99 | }, |
| 100 | storage: CloudflareStorage({ |