Last active
December 12, 2022 20:51
-
-
Save fl0wo/d615b7f151f4f7308e2f11c4004c5c9e to your computer and use it in GitHub Desktop.
Integration of token.ts
This file contains hidden or 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
| export const handler: any = async (event:any) => { | |
| try { | |
| const code = event.queryStringParameters!.code; | |
| const jwtKey = await getParameterValue( | |
| wrapCodeWithPrefix(code) | |
| ); | |
| const expiresIn = whenJwtExpiresLocal(jwtKey); | |
| if (Number.isInteger(expiresIn)) { | |
| const removed = await removeParameterValue( | |
| wrapCodeWithPrefix(code) | |
| ); | |
| } | |
| return { | |
| statusCode: 200, | |
| body: JSON.stringify({ | |
| success: true, | |
| data: { | |
| access_token:jwtKey, | |
| id_token:jwtKey, | |
| expires_in: expiresIn | |
| }, | |
| }), | |
| headers: { | |
| "Access-Control-Allow-Headers": "*", | |
| "Access-Control-Allow-Origin": "*", | |
| "Access-Control-Allow-Methods": "*", | |
| }, | |
| }; | |
| } catch (e) { | |
| console.error(e); | |
| return { | |
| statusCode: 500, | |
| body: JSON.stringify(e, null, 2), | |
| headers: { | |
| "Access-Control-Allow-Headers": "*", | |
| "Access-Control-Allow-Origin": "*", | |
| "Access-Control-Allow-Methods": "*", | |
| }, | |
| }; | |
| } | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The rest of the code is here