Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cors): fix profile sdk env #1568

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading