Skip to content

Commit

Permalink
fix(cors): fix profile sdk env (#1568)
Browse files Browse the repository at this point in the history
* fix(cors): fix profile sdk env

* fix(cors): fix profile sdk env

* fix(cors): fix profile sdk env
  • Loading branch information
cedricmagne authored Sep 23, 2024
1 parent 4db208f commit 3a8b07e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/AuthLogin/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const AuthModal = ({

// Call Profile SDK API to retrieve Hydra Access Token & Wallet userProfile
// Hydra Access Token will be used to fetch Infura API
const { accessToken, userProfile } = await authenticateAndAuthorize();
const { accessToken, userProfile } = await authenticateAndAuthorize(VERCEL_ENV as string);

const loginResponse = await (
await fetch(
Expand Down
8 changes: 5 additions & 3 deletions src/lib/siwsrp/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ type HydraEnv = {
};

const { AuthType, Env, getEnvUrls, JwtBearerAuth, Platform } = SDK;
let VERCEL_ENV = 'development'
export const AUTH_WALLET_SESSION_NAME = "auth.wallet.session";
export const AUTH_WALLET_TOKEN = "auth.wallet.token";
export const AUTH_WALLET_PROJECTS = "auth.wallet.projects";

export const getHydraEnv = (): HydraEnv => {
const platform = Platform.INFURA;

if (process.env.VERCEL_ENV === "production") {
if (VERCEL_ENV === "production") {
return {
...getEnvUrls(Env.PRD),
env: Env.PRD,
Expand Down Expand Up @@ -50,11 +51,12 @@ export const auth = new JwtBearerAuth(
},
{
storage,
},
}
);

export const authenticateAndAuthorize = async () => {
export const authenticateAndAuthorize = async (env: string) => {
let accessToken: string, userProfile: SDK.UserProfile;
VERCEL_ENV = env;
try {
await auth.connectSnap();
accessToken = await auth.getAccessToken();
Expand Down

0 comments on commit 3a8b07e

Please sign in to comment.