Skip to content

Commit 0e123fd

Browse files
committed
Merge tag 'decrypt-fail'
1.0.1
2 parents b051970 + f9efcff commit 0e123fd

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

Diff for: src/extension/background-script/CryptoService.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,16 @@ async function decryptFrom(
115115
return { signatureVerifyResult: false, content }
116116
}
117117
} else {
118+
const aesKeyEncrypted = await queryPostAESKey(salt, whoAmI)
119+
if (aesKeyEncrypted === undefined) {
120+
throw new Error(
121+
'Maskbook does not find key that you can used to decrypt this post. Maybe this post is not send to you?',
122+
)
123+
}
118124
const content = decodeText(
119125
await Alpha41.decryptMessage1ToNByOther({
120126
version: -41,
121-
AESKeyEncrypted: await queryPostAESKey(salt, whoAmI),
127+
AESKeyEncrypted: aesKeyEncrypted,
122128
authorsPublicKeyECDH: byKey.key.publicKey,
123129
encryptedContent: encryptedText,
124130
privateKeyECDH: mine.key.privateKey,

Diff for: src/extension/content-script/tasks.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
import { AutomatedTabTask, LiveSelector, MutationObserverWatcher } from '@holoflows/kit'
2-
import { BackgroundService } from './rpc'
1+
import { AutomatedTabTask, LiveSelector } from '@holoflows/kit'
2+
import { sleep } from '../../utils/utils'
33
export default AutomatedTabTask({
44
/**
55
* Access: https://www.facebook.com/${username}/posts/${postId}
66
* Or: https://www.facebook.com/permalink.php?story_fbid=${postId}&id=${userId}
77
*/
8-
getPostContent() {
9-
const post = new LiveSelector().querySelector<HTMLParagraphElement>('#contentArea p').map(x => x.innerText)
10-
return new Promise(resolve => {
11-
new MutationObserverWatcher(post).addListener('onAdd', event => resolve(event.data[0].node)).startWatch()
12-
})
8+
async getPostContent() {
9+
const post = new LiveSelector().querySelector<HTMLParagraphElement>('#contentArea p')
10+
while (!post.evaluateOnce()[0]) await sleep(200)
11+
return post.evaluateOnce()[0].innerText
1312
},
1413
/**
1514
* Access: https://www.facebook.com/profile.php?id=${userId}
1615
* Or: https://www.facebook.com/${username}?fref=pymk
1716
*/
18-
getBioContent() {
19-
const bio = new LiveSelector()
20-
.querySelector<HTMLDivElement>('#profile_timeline_intro_card')
21-
.map(x => x.innerText)
22-
return new Promise(resolve =>
23-
new MutationObserverWatcher(bio).addListener('onAdd', event => resolve(event.data[0].node)).startWatch(),
24-
)
17+
async getBioContent() {
18+
const bio = new LiveSelector().querySelector<HTMLDivElement>('#profile_timeline_intro_card')
19+
while (!bio.evaluateOnce()[0]) await sleep(200)
20+
return bio.evaluateOnce()[0].innerText
2521
},
2622
})!

Diff for: src/key-management/people-gun.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { queryPersonCryptoKey, PersonCryptoKey } from './keystore-db'
22
import { gun } from './gun'
33
import tasks from '../extension/content-script/tasks'
44
import { verifyOthersProve } from '../extension/background-script/CryptoService'
5+
import { sleep } from '../utils/utils'
56

67
export async function queryPerson(username: string) {
78
return gun
@@ -46,12 +47,14 @@ export async function addPersonPublicKey(username: string): Promise<PersonCrypto
4647
errors.push(e)
4748
proveRejected = true
4849
}
49-
if (bioRejected && proveRejected) {
50-
debugger
50+
// HACK
51+
await sleep(1000)
52+
const key = await queryPersonCryptoKey(username)
53+
if ((bioRejected && proveRejected) || !key) {
5154
console.error(...errors)
5255
throw new Error('Cannot find public key of ' + username)
5356
}
54-
return (await queryPersonCryptoKey(username))!
57+
return key
5558
}
5659

5760
export async function uploadProvePostUrl(username: string, postId: string) {

0 commit comments

Comments
 (0)