Switch to new identity proof API

This commit is contained in:
silverpill 2022-11-10 11:08:53 +00:00
parent 989945ec9e
commit 989910a8f4
2 changed files with 8 additions and 8 deletions

View file

@ -266,24 +266,24 @@ export async function sendSignedUpdate(
export async function getIdentityClaim(
authToken: string,
walletAddress: string,
): Promise<string> {
): Promise<{ did: string, claim: string }> {
const url = `${BACKEND_URL}/api/v1/accounts/identity_proof`
const queryParams = { did: createDidFromEthereumAddress(walletAddress) }
const queryParams = { proof_type: "ethereum", signer: walletAddress }
const response = await http(url, { authToken, queryParams })
const data = await response.json()
return data.claim
return data
}
export async function createIdentityProof(
authToken: string,
walletAddress: string,
did: string,
signature: string,
): Promise<User> {
const url = `${BACKEND_URL}/api/v1/accounts/identity_proof`
const response = await http(url, {
method: "POST",
json: {
did: createDidFromEthereumAddress(walletAddress),
did: did,
signature: signature.replace(/0x/, ""),
},
authToken,

View file

@ -13,11 +13,11 @@ async function verifyEthereumAddress(): Promise<User | null> {
}
const walletAddress = await signer.getAddress()
const authToken = ensureAuthToken()
const message = await getIdentityClaim(authToken, walletAddress)
const signature = await getWalletSignature(signer, message)
const { did, claim } = await getIdentityClaim(authToken, walletAddress)
const signature = await getWalletSignature(signer, claim)
const user = await createIdentityProof(
authToken,
walletAddress,
did,
signature,
)
setCurrentUser(user)