Skip to content

Commit

Permalink
Fix verifyOthersProve return unexpected value
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works committed Jun 18, 2019
1 parent 5cfd9c3 commit 4f4affe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/extension/background-script/CryptoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ export async function getMyProveBio(whoami: PersonIdentifier): Promise<string |
const compressed = toCompressSecp256k1Point(pub.x!, pub.y!)
return `🔒${encodeArrayBuffer(compressed)}🔒`
}
export async function verifyOthersProve(bio: string, others: PersonIdentifier) {
export async function verifyOthersProve(bio: string, others: PersonIdentifier): Promise<boolean> {
const [_, compressedX, _2] = bio.split('🔒')
if (!compressedX) return null
if (!compressedX) return false
const { x, y } = unCompressSecp256k1Point(decodeArrayBuffer(compressedX))
const key: JsonWebKey = {
crv: 'K-256',
Expand All @@ -235,7 +235,7 @@ export async function verifyOthersProve(bio: string, others: PersonIdentifier) {
// TODO: Add relation verify at caller, then change to new Date()
relationLastCheckTime: new Date('Jan 1 2019'),
})
return publicKey
return true
}
//#endregion

Expand Down
4 changes: 2 additions & 2 deletions src/key-management/people-gun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export async function queryPersonFromGun(username: string) {
export async function addPersonPublicKey(user: PersonIdentifier): Promise<PersonUI> {
const fromBio = async () => {
const bio = await tasks(getProfilePageUrlAtFacebook(user)).getBioContent()
if ((await verifyOthersProve(bio, user)) === null) throw new Error('Not in bio!')
if ((await verifyOthersProve(bio, user)) === false) throw new Error('Not in bio!')
}
const fromPost = async () => {
const person = await queryPersonFromGun(user.userId)
if (!person || !person.provePostId) throw new Error('Not in gun!')
const post = await tasks(getPostUrlAtFacebook(new PostIdentifier(user, person.provePostId))).getPostContent()
if ((await verifyOthersProve(post, user)) === null) throw new Error('Not in prove post!')
if ((await verifyOthersProve(post, user)) === false) throw new Error('Not in prove post!')
}
let bioRejected = false
let proveRejected = false
Expand Down
2 changes: 1 addition & 1 deletion src/key-management/posts-gun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function queryPostAESKey(salt: string, myUsername: string) {
.get(salt)
.get(myUsername)
.once().then!()
if (result.encryptedKey && result.salt) return result
if (result && result.encryptedKey && result.salt) return result
return undefined
}

Expand Down

0 comments on commit 4f4affe

Please sign in to comment.