Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade TypeScript to 3.7.0 #296

Merged
merged 2 commits into from Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions package.json
Expand Up @@ -39,16 +39,16 @@
"@types/bip39": "^2.4.2",
"@types/classnames": "^2.2.7",
"@types/gun": "^0.9.1",
"@types/jest": "^24.0.13",
"@types/jest": "^24.0.19",
"@types/json-stable-stringify": "^1.0.32",
"@types/lodash-es": "^4.17.3",
"@types/node": "^12.7.11",
"@types/node": "^12.12.7",
"@types/qrcode": "^1.3.3",
"@types/react": "^16.9.11",
"@types/react-dom": "^16.9.2",
"@types/react-router-dom": "^5.1.0",
"@types/tiny-secp256k1": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/eslint-plugin": "^2.6.1",
"anchorme": "^1.1.2",
"async-call-rpc": "^1.0.0",
"bip39": "^3.0.2",
Expand All @@ -57,7 +57,7 @@
"copy-webpack-plugin": "^5.0.3",
"elliptic": "^6.4.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-react-hooks": "^2.1.2",
"eslint-plugin-react-hooks": "^2.2.0",
"gun": "0.2019.930",
"husky": "^3.0.5",
"idb": "^4.0.3",
Expand All @@ -77,8 +77,8 @@
"react-scripts": "^3.2.0",
"serialijse": "^0.1.3",
"tiny-secp256k1": "^1.1.2",
"ts-loader": "^6.0.1",
"typescript": "^3.6.2",
"ts-loader": "^6.2.1",
"typescript": "^3.7.2",
"wallet.ts": "^0.2.8",
"web-ext-types": "^3.1.0",
"webcrypto-liner": "0.1.38",
Expand All @@ -97,17 +97,17 @@
"@storybook/theming": "^5.2.4",
"@types/storybook__addon-info": "^4.1.0",
"@types/storybook__react": "^4.0.1",
"@typescript-eslint/parser": "^2.0.0",
"@typescript-eslint/parser": "^2.6.1",
"awesome-typescript-loader": "^5.2.1",
"chrome-launcher": "^0.11.2",
"eslint": "^6.4.0",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-prettier": "^3.1.1",
"esm": "^3.2.25",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"puppeteer-core": "^1.20.0",
"react-devtools": "^4.2.0",
"prettier": "^1.19.0",
"storybook-addon-material-ui": "^0.9.0-alpha.19",
"ts-node": "^8.4.1",
"web-ext": "^3.2.0",
Expand Down
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 @@ -31,5 +31,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