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
export const handler = async (event:any) => { | |
// Ge the token from Stytch | |
const token = event.queryStringParameters.token; | |
const client = loadStytch(); | |
// Grant JWT | |
const response:AuthenticateResponse = await client.oauth.authenticate(token,{ | |
session_duration_minutes: 60 | |
}); | |
const userId = response.user_id; | |
const sessionId = getSafeOrThrow(response.session?.session_id,'Session id cannot be null'); |
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
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)) { |
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
import {SSM} from "aws-sdk"; | |
export async function getParameterValue(parameterName: string) { | |
const param = await new SSM() | |
.getParameter({Name: parameterName,WithDecryption: true}) | |
.promise(); | |
const value = param.Parameter?.Value as string; | |
if (!value) throw new Error(`Can not find SSM parameter with name ${parameterName}`); | |
return value; | |
} |
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
export const handler = async (event:any) => { | |
// Get token from Stytch | |
const token = event.queryStringParameters.token; | |
// Get instance of client | |
const client = loadStytch(); | |
// Grant jwt | |
const response:AuthenticateResponse = await client.oauth.authenticate(token,{ | |
session_duration_minutes: 60 |
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
export const addUserApiGateway = (scope: Construct, options: InfrastructureOptions) => { | |
const api = new RestApi(scope, "ApiGatewayTutorial", { | |
deployOptions: { | |
cacheTtl: Duration.seconds(0), | |
throttlingBurstLimit: 1, // can ask JWT max 1 time! | |
throttlingRateLimit: 1, | |
}, | |
defaultCorsPreflightOptions: { |
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
const config:StytchLoginConfig = { | |
products: [ | |
Products.oauth | |
], | |
oauthOptions:{ | |
providers:[ | |
{ | |
type: OAuthProviders.Google, | |
one_tap:true, | |
position:OneTapPositions.embedded |
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
import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core'; | |
import {environment} from "../../environments/environment"; | |
import {stytchUIClient} from "../../environments/stytchClient"; | |
import {OAuthProviders, Products, StytchUIClient} from "@stytch/vanilla-js"; | |
import {OneTapPositions, StyleConfig, StytchLoginConfig} from "@stytch/core/public"; | |
@Component({ | |
selector: 'app-stytch-join', | |
templateUrl: './stytch-join.component.html', | |
styleUrls: ['./stytch-join.component.scss'] |
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
import {stytchUIClient} from "../../environments/stytchClient"; | |
@ViewChild('magic_stytch_login') | |
divLogin:any; | |
// ... | |
stytchUIClient.mountLogin({ | |
elementId: '#' + this.divLogin.nativeElement.id, | |
config: config, |
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
import {StytchUIClient} from "@stytch/vanilla-js"; | |
export const stytchUIClient = new StytchUIClient( | |
'<here the stytch public token>' | |
); |
NewerOlder