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

feat: siwx cloud auth config flag #3424

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4559f59
refactor: add params in getNonce function
zoruka Nov 4, 2024
4938fdb
feat: add map to siwx function
zoruka Nov 4, 2024
2ce57a2
refactor: apply siwx over siwe
zoruka Nov 4, 2024
07a6605
Merge branch 'main' of github.com:WalletConnect/web3modal into chore/…
zoruka Nov 6, 2024
63c34ef
Merge branch 'main' of github.com:WalletConnect/web3modal into chore/…
zoruka Nov 7, 2024
6e4cbed
fix: issues after rebase
zoruka Nov 7, 2024
2e01a07
chore: revert ts issue changes on solana adapter
zoruka Nov 7, 2024
04a1c90
fix: formating issue
zoruka Nov 7, 2024
3190dcf
Merge branch 'main' of github.com:WalletConnect/web3modal into chore/…
zoruka Nov 7, 2024
36598e9
fix: missing siwx initialization
zoruka Nov 7, 2024
edb0fe5
refactor: move validation to LocalStorage to keep independent from si…
zoruka Nov 7, 2024
b72b68d
fix: fix LocalStorage validation
zoruka Nov 7, 2024
fc061f2
Merge branch 'main' of github.com:WalletConnect/web3modal into chore/…
zoruka Nov 8, 2024
7bec91c
fix: missing setClientId
zoruka Nov 8, 2024
c30c03a
feat: add siwx cloud auth storage
zoruka Nov 8, 2024
2b511f7
Merge branch 'chore/siwe-to-siwx-migration' of github.com:WalletConne…
zoruka Nov 8, 2024
bd8aab5
chore: update branch and adde clientId in the request
zoruka Nov 8, 2024
bbb3561
fix: formating issue
zoruka Nov 8, 2024
18760c2
Merge branch 'main' of github.com:WalletConnect/web3modal into feat/s…
zoruka Dec 3, 2024
4c5806e
wip: get correct nonce and set token
zoruka Dec 3, 2024
ed1f6d9
fix(siwx-msg): chain ID should be after version
Cali93 Dec 3, 2024
3a4f132
refactor: create CloudAuthSIWX config instead of extending DefaultSIWX
zoruka Dec 3, 2024
260d1da
fix(auth): fix auth flow to set token
Cali93 Dec 5, 2024
6fc6e42
fix: informal message clear chain id namespace
zoruka Dec 5, 2024
3113939
fix: setSessions logic to clear session and get correct session from …
zoruka Dec 5, 2024
ebc7a1d
fix: universalProviderAuthenticate to only accept eip155 and show aut…
zoruka Dec 5, 2024
4f78505
feat: add autoClose flag for snackbar
zoruka Dec 5, 2024
975ff8b
Merge branch 'main' of github.com:WalletConnect/web3modal into feat/s…
zoruka Dec 5, 2024
e318f4d
test: add tests for CloudAuthSIWX
zoruka Dec 5, 2024
b752093
fix: dependecy static version and formatting
zoruka Dec 5, 2024
75e3934
Merge branch 'main' of github.com:WalletConnect/web3modal into feat/s…
zoruka Dec 5, 2024
7fa8841
chore: add page for siwx cloud auth
zoruka Dec 5, 2024
aea0bdf
test: fix SnackController tests and add test for autoClose
zoruka Dec 5, 2024
f6d5742
test: fix SnackController tests and add test for autoClose
zoruka Dec 5, 2024
8670737
test: mock host and href
zoruka Dec 5, 2024
22dd48d
Merge branch 'main' of github.com:WalletConnect/web3modal into feat/s…
zoruka Dec 5, 2024
3dae36b
Merge branch 'main' into feat/siwx-cloud-auth
zoruka Dec 10, 2024
0c0e557
Merge branch 'main' into feat/siwx-cloud-auth
zoruka Dec 10, 2024
4e2b45a
feat: add setup for auth flag and siwx usage
zoruka Dec 10, 2024
bd70839
Merge branch 'main' of github.com:WalletConnect/web3modal into feat/s…
zoruka Dec 10, 2024
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
3 changes: 2 additions & 1 deletion apps/laboratory/src/pages/library/wagmi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const modal = createAppKit({
networks: ConstantsUtil.EvmNetworks,
projectId: ConstantsUtil.ProjectId,
features: {
analytics: true
analytics: true,
auth: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this flag here if we already have the siwx param?

Suggested change
auth: true
auth: true

},
customWallets: ConstantsUtil.CustomWallets
})
Expand Down
1 change: 1 addition & 0 deletions packages/appkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"@reown/appkit-polyfills": "workspace:*",
"@reown/appkit-scaffold-ui": "workspace:*",
"@reown/appkit-siwe": "workspace:*",
"@reown/appkit-siwx": "workspace:*",
"@reown/appkit-ui": "workspace:*",
"@reown/appkit-utils": "workspace:*",
"@reown/appkit-wallet": "workspace:*",
Expand Down
15 changes: 14 additions & 1 deletion packages/appkit/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ export class AppKit {
OptionsController.setTermsConditionsUrl(options.termsConditionsUrl)
OptionsController.setPrivacyPolicyUrl(options.privacyPolicyUrl)
OptionsController.setCustomWallets(options.customWallets)
OptionsController.setFeatures(options.features)
OptionsController.setEnableWalletConnect(options.enableWalletConnect !== false)
OptionsController.setEnableWallets(options.enableWallets !== false)
OptionsController.setEIP6963Enabled(options.enableEIP6963 !== false)
Expand Down Expand Up @@ -724,6 +723,20 @@ export class AppKit {
OptionsController.setSIWX(siwe.mapToSIWX(options.siweConfig))
}
}

OptionsController.subscribeKey('features', async features => {
if (features?.auth) {
if (OptionsController.state.siwx) {
console.warn("SIWX config already enabled, 'auth' feature will not be enabled")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.warn("SIWX config already enabled, 'auth' feature will not be enabled")
console.warn("SIWX config already provided, the default Reown Auth feature will not be used.")


return
}

const siwx = await import('@reown/appkit-siwx')
OptionsController.setSIWX(new siwx.CloudAuthSIWX())
}
})
OptionsController.setFeatures(options.features)
}

private getDefaultMetaData() {
Expand Down
13 changes: 12 additions & 1 deletion packages/core/src/controllers/ApiController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { FetchUtil } from '../utils/FetchUtil.js'
import { StorageUtil } from '../utils/StorageUtil.js'
import type {
ApiGetAnalyticsConfigResponse,
ApiGetProjectConfigResponse,
ApiGetWalletsRequest,
ApiGetWalletsResponse,
WcWallet
Expand Down Expand Up @@ -276,7 +277,8 @@ export const ApiController = {
ApiController.fetchFeaturedWallets(),
ApiController.fetchRecommendedWallets(),
ApiController.fetchNetworkImages(),
ApiController.fetchConnectorImages()
ApiController.fetchConnectorImages(),
ApiController.fetchProjectConfig()
]
if (OptionsController.state.features?.analytics) {
promises.push(ApiController.fetchAnalyticsConfig())
Expand All @@ -290,5 +292,14 @@ export const ApiController = {
params: ApiController._getSdkProperties()
})
OptionsController.setFeatures({ analytics: isAnalyticsEnabled })
},

async fetchProjectConfig() {
const { isAnalyticsEnabled, isAppKitAuthEnabled } = await api.get<ApiGetProjectConfigResponse>({
path: '/getProjectConfig',
params: ApiController._getSdkProperties()
})
console.log({ isAnalyticsEnabled, isAppKitAuthEnabled })
OptionsController.setFeatures({ analytics: isAnalyticsEnabled, auth: isAppKitAuthEnabled })
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we set siwx's value to the CloudAuthSIWX instance if it's enabled ?

}
}
3 changes: 2 additions & 1 deletion packages/core/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export const ConstantsUtil = {
smartSessions: false,
collapseWallets: false,
connectMethodsOrder: ['email', 'social', 'wallet'],
walletFeaturesOrder: ['onramp', 'swaps', 'receive', 'send']
walletFeaturesOrder: ['onramp', 'swaps', 'receive', 'send'],
auth: false
} satisfies Features
}
9 changes: 8 additions & 1 deletion packages/core/src/utils/TypeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ export interface ApiGetWalletsResponse {
count: number
}

export interface ApiGetAnalyticsConfigResponse {
export interface ApiGetProjectConfigResponse {
isAnalyticsEnabled: boolean
isAppKitAuthEnabled: boolean
}

export type ThemeMode = 'dark' | 'light'
Expand Down Expand Up @@ -1068,6 +1069,12 @@ export type Features = {
* @default false
*/
collapseWallets?: boolean
/**
* @description Enable or disable the AppKit Auth feature. Disabled by default.
* This will enable SIWX configuration using Cloud Auth. You can configure this flag through the Project Cloud dashboard.
* @default false
*/
auth?: boolean
}

export type FeaturesKeys = keyof Features
Expand Down
Loading
Loading