Skip to content

Commit

Permalink
chore: run yarn lint to fix styles
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Works authored and Artoria2e5 committed Nov 11, 2019
1 parent 9ebbc50 commit ad721f7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 20 deletions.
Expand Up @@ -98,9 +98,9 @@ export function SelectPeopleAndGroupsUI<ServeType extends Group | Person = Perso
key={item.identifier.toText()}
item={item}
onDelete={() =>
onSetSelected(selected.filter(
x => !x.identifier.equals(item.identifier),
) as ServeType[])
onSetSelected(
selected.filter(x => !x.identifier.equals(item.identifier)) as ServeType[],
)
}
{...props.PersonOrGroupInChipProps}
/>
Expand Down
12 changes: 7 additions & 5 deletions src/crypto/crypto-alpha-40.ts
Expand Up @@ -151,11 +151,13 @@ export async function encrypt1ToN(info: {
)

const exportedAESKey = encodeText(JSON.stringify(await crypto.subtle.exportKey('jwk', AESKey)))
const ownersAESKeyEncrypted = (await encryptWithAES({
aesKey: ownersLocalKey,
content: exportedAESKey,
iv,
})).content
const ownersAESKeyEncrypted = (
await encryptWithAES({
aesKey: ownersLocalKey,
content: exportedAESKey,
iv,
})
).content
const othersAESKeyEncrypted = await generateOthersAESKeyEncrypted(-40, AESKey, privateKeyECDH, othersPublicKeyECDH)
return { encryptedContent, iv, version: -40, ownersAESKeyEncrypted, othersAESKeyEncrypted, postAESKey: AESKey }
}
Expand Down
8 changes: 4 additions & 4 deletions src/extension/background-script/CryptoServices/encryptTo.ts
Expand Up @@ -17,7 +17,7 @@ type OthersAESKeyEncryptedToken = string
/**
* This map stores <iv, othersAESKeyEncrypted>.
*/
const OthersAESKeyEncryptedMap = new Map<OthersAESKeyEncryptedToken, (Alpha38.PublishedAESKeyRecordV39OrV38)[]>()
const OthersAESKeyEncryptedMap = new Map<OthersAESKeyEncryptedToken, Alpha38.PublishedAESKeyRecordV39OrV38[]>()

/**
* Encrypt to a user
Expand Down Expand Up @@ -53,9 +53,9 @@ export async function encryptTo(
}
}

const toKey = await prepareOthersKeyForEncryptionV39OrV38(Object.keys(recipients).map(
Identifier.fromString,
) as PersonIdentifier[])
const toKey = await prepareOthersKeyForEncryptionV39OrV38(
Object.keys(recipients).map(Identifier.fromString) as PersonIdentifier[],
)
const mine = await getMyPrivateKey(whoAmI)
if (!mine) throw new TypeError('Not inited yet')
const {
Expand Down
Expand Up @@ -87,7 +87,7 @@ export async function pasteIntoPostBoxFacebook(
if (e) e.style.display = 'none'
}
// Prevent Custom Paste failed, this will cause service not available to user.
if (element.innerText.indexOf(text) === -1 && ('value' in element && element.value.indexOf(text) === -1)) {
if (element.innerText.indexOf(text) === -1 && 'value' in element && element.value.indexOf(text) === -1) {
copyFailed()
}
} catch {
Expand Down
14 changes: 12 additions & 2 deletions src/social-network-provider/twitter.com/encoding.ts
Expand Up @@ -51,13 +51,23 @@ export const twitterEncoding = {
* @link https://github.com/DimensionDev/Maskbook/issues/198
*/
payloadEncoder: (text: string) =>
`https://google.com/${batchReplace(text, [['🎼', '%20'], [':||', '%40'], ['+', '-'], ['=', '_'], ['|', '.']])}`,
`https://google.com/${batchReplace(text, [
['🎼', '%20'],
[':||', '%40'],
['+', '-'],
['=', '_'],
['|', '.'],
])}`,
payloadDecoder: (text: string) => {
let r = regexMatch(text, /https:\/\/google\.com\/%20(.+)%40/, 1)
if (isNil(r)) {
return 'null'
}
r = batchReplace(r, [['-', '+'], ['_', '='], ['.', '|']])
r = batchReplace(r, [
['-', '+'],
['_', '='],
['.', '|'],
])
return `🎼${r}:||`
},
}
5 changes: 4 additions & 1 deletion src/tests/1toN.ts
Expand Up @@ -14,7 +14,10 @@ async function test1toN(msg: string = 'test string') {
content: msg,
iv: crypto.getRandomValues(new Uint8Array(16)),
privateKeyECDH: alice.privateKey,
othersPublicKeyECDH: [{ key: bob.publicKey, name: 'bob' }, { key: david.publicKey, name: 'david' }],
othersPublicKeyECDH: [
{ key: bob.publicKey, name: 'bob' },
{ key: david.publicKey, name: 'david' },
],
ownersLocalKey: aliceLocal,
})

Expand Down
10 changes: 8 additions & 2 deletions src/utils/components/AsyncComponent.tsx
Expand Up @@ -16,7 +16,10 @@ export default function AsyncComponent<Return>(props: {
// eslint-disable-next-line
const promise = React.useMemo(() => props.promise(), props.dependencies)
if (state.status === 'not-started') {
promise.then(data => setState({ status: 'complete', data }), error => setState({ status: 'fail', error }))
promise.then(
data => setState({ status: 'complete', data }),
error => setState({ status: 'fail', error }),
)
setState({ status: 'await' })
}
const Component = React.useMemo(
Expand Down Expand Up @@ -61,7 +64,10 @@ export function useAsync<T>(fn: () => PromiseLike<T>, dep: ReadonlyArray<unknown
rej: Parameters<ConstructorParameters<typeof Promise>[0]>[1] = () => {}
React.useEffect(() => {
let unmounted = false
fn().then(x => unmounted || res(x), err => unmounted || rej(err))
fn().then(
x => unmounted || res(x),
err => unmounted || rej(err),
)
return () => {
unmounted = true
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dom.ts
Expand Up @@ -50,5 +50,5 @@ export const nthChild = (n: HTMLElement, ...childrenIndex: number[]) => {
if (isUndefined(r)) break
r = r.children[v] as HTMLElement
}
return r as (HTMLElement | undefined)
return r as HTMLElement | undefined
}
2 changes: 1 addition & 1 deletion src/utils/type-transform/CryptoKey-JsonWebKey.ts
Expand Up @@ -19,7 +19,7 @@ type Algorithms =
*/
export async function JsonWebKeyToCryptoKey(
key: JsonWebKey,
usage: (Usages)[] = ['deriveKey'],
usage: Usages[] = ['deriveKey'],
algorithm: Algorithms = { name: 'ECDH', namedCurve: 'K-256' },
) {
const _key = stableStringify(key) + usage.sort().join(',')
Expand Down

0 comments on commit ad721f7

Please sign in to comment.