From e67e48e2188354e13d28122c9bc1ebbc983527cd Mon Sep 17 00:00:00 2001 From: Chris Fisher Date: Tue, 14 Mar 2023 10:17:58 +1300 Subject: [PATCH] Allow passing base url to auth0 helper (#15) * Allow passing base url to auth0 helper * wip --- package.json | 2 +- src/integrations/auth0.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 20f2b3f..05edecb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@authsignal/node", - "version": "0.0.36", + "version": "0.0.37", "types": "dist/index.d.ts", "keywords": [ "authsignal", diff --git a/src/integrations/auth0.ts b/src/integrations/auth0.ts index 3954de0..d5c4f06 100644 --- a/src/integrations/auth0.ts +++ b/src/integrations/auth0.ts @@ -9,6 +9,7 @@ export interface ExecutePostLoginOptions { action?: string; redirectUrl?: string; custom?: object; + apiBaseUrl?: string; } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -25,9 +26,10 @@ export async function handleAuth0ExecutePostLogin(event: any, api: any, options: action = DEFAULT_ACTION_NAME, redirectUrl = `https://${event.request.hostname}/continue`, custom = {}, + apiBaseUrl, } = options ?? {}; - const authsignal = new Authsignal({secret}); + const authsignal = new Authsignal({secret, apiBaseUrl}); const result = await authsignal.track({ action, @@ -53,6 +55,7 @@ export interface ContinuePostLoginOptions { userId?: string; action?: string; failureMessage?: string; + apiBaseUrl?: string; } // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -62,11 +65,12 @@ export async function handleAuth0ContinuePostLogin(event: any, api: any, options userId = event.user.user_id, action = DEFAULT_ACTION_NAME, failureMessage = "MFA challenge failed", + apiBaseUrl, } = options ?? {}; const payload = api.redirect.validateToken({secret, tokenParameterName: "token"}); - const authsignal = new Authsignal({secret}); + const authsignal = new Authsignal({secret, apiBaseUrl}); const actionResult = await authsignal.getAction({ action,