-
Notifications
You must be signed in to change notification settings - Fork 459
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
refactor: environment config for social wallet #2728
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a3fd150
refactor: environment config for social wallet
schmanu 0b0ea36
Merge remote-tracking branch 'origin/web3authcoresdk' into seedless-n…
schmanu 7cbb240
refactor: Use IS_PRODUCTION directly, adjust isSocialWalletOptions
usame-algan 64b959b
Merge remote-tracking branch 'origin/web3authcoresdk' into seedless-n…
usame-algan 5b92d4b
fix: Failing tests
usame-algan af1bc5d
fix: Adjust error message
usame-algan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { IS_PRODUCTION } from '@/config/constants' | ||
|
||
enum SocialWalletOptionsKeys { | ||
web3AuthClientId = 'web3AuthClientId', | ||
web3AuthAggregateVerifierId = 'web3AuthAggregateVerifierId', | ||
web3AuthSubverifierId = 'web3AuthSubverifierId', | ||
googleClientId = 'googleClientId', | ||
} | ||
|
||
export type SocialWalletOptions = { | ||
[SocialWalletOptionsKeys.web3AuthClientId]: string | ||
[SocialWalletOptionsKeys.web3AuthAggregateVerifierId]: string | ||
[SocialWalletOptionsKeys.web3AuthSubverifierId]: string | ||
[SocialWalletOptionsKeys.googleClientId]: string | ||
} | ||
|
||
export const isSocialWalletOptions = (options: unknown): options is SocialWalletOptions => { | ||
if (typeof options !== 'object' || options === null) { | ||
return false | ||
} | ||
|
||
const requiredKeys = Object.values(SocialWalletOptionsKeys) | ||
const hasRequiredKeys = requiredKeys.every((key) => key in options) | ||
const hasValues = Object.values(options).every(Boolean) | ||
|
||
return hasRequiredKeys && hasValues | ||
} | ||
|
||
/** env variables */ | ||
export const SOCIAL_WALLET_OPTIONS: any = (() => { | ||
const SOCIAL_WALLET_OPTIONS_PRODUCTION = process.env.NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_PRODUCTION || '' | ||
const SOCIAL_WALLET_OPTIONS_STAGING = process.env.NEXT_PUBLIC_SOCIAL_WALLET_OPTIONS_STAGING || '' | ||
|
||
try { | ||
return JSON.parse(IS_PRODUCTION ? SOCIAL_WALLET_OPTIONS_PRODUCTION : SOCIAL_WALLET_OPTIONS_STAGING) | ||
} catch (error) { | ||
console.error('Error parsing SOCIAL_WALLET_OPTIONS', error) | ||
return {} | ||
} | ||
})() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do this check at the entry point to this flow instead?
I.e. not even show the Google button if these env vars aren't set. This is important for forks.
Although, never mind. This feature needs to be explicitely toggled on in the config service anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the config service toggle only changes if the button is enabled or not. We could use the env vars to decide if the feature should be enabled or not though.