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( export async function getIdentityClaim(
authToken: string, authToken: string,
walletAddress: string, walletAddress: string,
): Promise<string> { ): Promise<{ did: string, claim: string }> {
const url = `${BACKEND_URL}/api/v1/accounts/identity_proof` 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 response = await http(url, { authToken, queryParams })
const data = await response.json() const data = await response.json()
return data.claim return data
} }
export async function createIdentityProof( export async function createIdentityProof(
authToken: string, authToken: string,
walletAddress: string, did: string,
signature: string, signature: string,
): Promise<User> { ): Promise<User> {
const url = `${BACKEND_URL}/api/v1/accounts/identity_proof` const url = `${BACKEND_URL}/api/v1/accounts/identity_proof`
const response = await http(url, { const response = await http(url, {
method: "POST", method: "POST",
json: { json: {
did: createDidFromEthereumAddress(walletAddress), did: did,
signature: signature.replace(/0x/, ""), signature: signature.replace(/0x/, ""),
}, },
authToken, authToken,

View file

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