Skip to content

Commit

Permalink
fix(cors): fix profile sdk env
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricmagne committed Sep 23, 2024
1 parent 32f25fb commit a0eb69a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 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
10 changes: 3 additions & 7 deletions src/lib/siwsrp/auth.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { SDK } from "@metamask/profile-sync-controller";
import jwt from "jsonwebtoken";

export const customFields = {
VERCEL_ENV: process.env.VERCEL_ENV,
};

type HydraEnv = {
authApiUrl: string;
oidcApiUrl: string;
Expand All @@ -14,8 +10,7 @@ type HydraEnv = {
};

const { AuthType, Env, getEnvUrls, JwtBearerAuth, Platform } = SDK;
const { VERCEL_ENV } = customFields;
console.log(VERCEL_ENV)
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";
Expand Down Expand Up @@ -59,8 +54,9 @@ export const auth = new JwtBearerAuth(
}
);

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 a0eb69a

Please sign in to comment.