Skip to content

Commit

Permalink
fixing nonce
Browse files Browse the repository at this point in the history
  • Loading branch information
corbanbrook committed Apr 26, 2024
1 parent 945519a commit 59b8313
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
<GoogleLogin
type="icon"
size="large"
nonce={(storage?.getItem(LocalStorageKey.WaasSessionHash) as string) ?? undefined}
nonce={JSON.parse(localStorage.getItem('wagmi.' + LocalStorageKey.WaasSessionHash) ?? '') || undefined}
onSuccess={credentialResponse => {
if (credentialResponse.credential) {
storage?.setItem(LocalStorageKey.WaasGoogleIdToken, credentialResponse.credential)
Expand All @@ -284,16 +284,16 @@ export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
<ConnectButton
connector={connector}
onConnect={() => {
const appleClientId = (storage?.getItem(LocalStorageKey.WaasAppleClientID) as string) || ''
const appleRedirectUri = (storage?.getItem(LocalStorageKey.WaasAppleRedirectURI) as string) || ''
const sessionHash = (storage?.getItem(LocalStorageKey.WaasSessionHash) as string) || ''
const appleClientId = localStorage.getItem('wagmi.' + LocalStorageKey.WaasAppleClientID) || ''
const appleRedirectUri = localStorage.getItem('wagmi.' + LocalStorageKey.WaasAppleRedirectURI) || ''
const sessionHash = localStorage.getItem('wagmi.' + LocalStorageKey.WaasSessionHash) || ''
appleAuthHelpers.signIn({
authOptions: {
clientId: appleClientId,
clientId: JSON.parse(appleClientId),
scope: 'openid email',
redirectURI: appleRedirectUri,
redirectURI: JSON.parse(appleRedirectUri),
usePopup: true,
nonce: sessionHash
nonce: JSON.parse(sessionHash)
},
onSuccess: (response: any) => {
if (response.authorization?.id_token) {
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/utils/ethAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import { EthAuthSettings } from '../components/KitProvider'
export const signEthAuthProof = async (walletClient: GetWalletClientData<any, any>): Promise<ETHAuthProof> => {
const wagmiConfig = useConfig()
const storage = wagmiConfig.storage as Storage<{ [key: string]: string }>
const proofInformation = storage?.getItem(LocalStorageKey.EthAuthProof) as string | undefined
const proofInformation = localStorage.getItem('wagmi.' + LocalStorageKey.EthAuthProof)
// if proof information was generated and saved upon wallet connection, use that
if (proofInformation) {
const proof = JSON.parse(proofInformation) as ETHAuthProof
return proof
}

// generate a new proof
const proofSettingsFromStorage = storage?.getItem(LocalStorageKey.EthAuthSettings) as string | undefined
const proofSettingsFromStorage = localStorage.getItem('wagmi.' + LocalStorageKey.EthAuthSettings) as string | undefined

if (!proofSettingsFromStorage) {
throw new Error('No ETHAuth settings found')
Expand Down

0 comments on commit 59b8313

Please sign in to comment.