Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bf5110a
chore: bump version to 2.8.0
guanbinrui May 17, 2022
8035aac
fix: persona sign length (#6277)
Jack-Works May 18, 2022
aed19b5
fix: serializer bug (#6278)
Jack-Works May 18, 2022
4f98f53
fix: twitter id selector (#6279)
hanszhoou May 18, 2022
195ed03
fix: wrong call order of localeCompare (#6286)
Jack-Works May 18, 2022
ed6ab9c
fix: css style (#6292)
lelenei May 18, 2022
77c1350
fix: show switch chainid button (#6295)
lelenei May 18, 2022
bb36efe
fix: css style (#6297)
lelenei May 18, 2022
4562da6
fix: chain name of okex (#6298)
Randolph314 May 18, 2022
946ad03
fix: support publicHex & rawPublickey in compose share search (#6273)
BillySh1 May 18, 2022
ad93061
fix: 752
BillySh1 May 18, 2022
34b2672
fix: css style (#6300)
lelenei May 18, 2022
645aa8c
fix(ins): css style (#6301)
lelenei May 18, 2022
38e3312
fix: no need to check is contract
hanszhoou May 19, 2022
9f9b397
fix: ts type
hanszhoou May 19, 2022
4ce209c
feat: use Cross-chain in production environment (#6303)
Randolph314 May 19, 2022
952f498
fix: ito fetch availability when no connect
hanszhoou May 19, 2022
e0bd3c9
Merge branch 'release/2.8.0' of https://github.com/DimensionDev/Maskb…
hanszhoou May 19, 2022
2a838de
fix: 765 (#6304)
BillySh1 May 19, 2022
86436b1
fix: temp revert to build
BillySh1 May 19, 2022
c907903
fix: 765 (#6304)
BillySh1 May 19, 2022
4286ff4
fix: profile selector (#6305)
yanzhihong23 May 19, 2022
5089204
fix: bugfix for theme (#6299)
nuanyang233 May 19, 2022
b1b786b
fix: remove hard code width (#6306)
nuanyang233 May 19, 2022
e33d98a
fix: config for network tab
hanszhoou May 18, 2022
84bd276
fix: build error
nuanyang233 May 19, 2022
c45242c
fix: config find truman
hanszhoou May 19, 2022
ba675b2
fix: some 2.8.0 ui issues (#6308)
BillySh1 May 19, 2022
a202a32
fix: boundary style in timeline (#6307)
nuanyang233 May 19, 2022
571a718
fix: timeline plugin render (#6310)
lelenei May 19, 2022
d902544
fix: bugfix for git coin boundary
nuanyang233 May 19, 2022
5699a7e
fix: add props to render conrrect style in timeline
nuanyang233 May 19, 2022
62754ff
fix: fix compose bottom nav style (#6313)
BillySh1 May 19, 2022
41bd50d
fix: add props to render conrrect style in timeline
nuanyang233 May 19, 2022
e20eb0e
fix: fix compose bottom nav style (#6313)
BillySh1 May 19, 2022
caf8930
fix: miss dependency
hanszhoou May 20, 2022
df55277
Merge branch 'release/2.8.0' of github.com:DimensionDev/Maskbook into…
BillySh1 May 20, 2022
96ff59b
fix: conflict
BillySh1 May 20, 2022
20428fd
fix: tips some ui issues (#6320)
BillySh1 May 20, 2022
ca9cd90
fix: proxy for coingecko api (#6321)
UncleBill May 20, 2022
d5691aa
fix: mf-782
nuanyang233 May 20, 2022
e8d80b2
fix(facebook): selector for toolbar (#6322)
lelenei May 20, 2022
7085a43
chore: bump version to 2.8.1
guanbinrui May 26, 2022
25aae27
fix: kill no connect when no localkey (#6352)
BillySh1 May 26, 2022
dca240c
hotfix: some ui issues (#6354)
BillySh1 May 26, 2022
278776f
fix: build err
BillySh1 May 26, 2022
44efea9
fix: e2e key partition compat (#6230)
Jack-Works May 23, 2022
a0b39e3
refactor: match more links on opensea (#6351)
guanbinrui May 26, 2022
38580e1
fix: collectible loading icon position (#6353)
hanszhoou May 26, 2022
9f5fac6
fix: big number to string as react node
hanszhoou May 26, 2022
82e3822
fix(ui): claim button && mind fb tool box hint (#6337)
hanszhoou May 26, 2022
e66dbd9
fix: personaActionButton display error (#6361)
Randolph314 May 26, 2022
5cb97d9
revert: button style
nuanyang233 May 26, 2022
7fb8cf4
chore: i18n
nuanyang233 May 26, 2022
70d3442
fix: image url
Lanttcat Jun 2, 2022
4d1d17f
feat: update ci
Lanttcat Jun 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/deploy-proxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Publish Proxy Package

on:
workflow_dispatch:
push:
branches: [fix/nftscan-image-url]
jobs:
build:
runs-on: ubuntu-20.04
Expand Down
2 changes: 2 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
"nrge",
"nrgt",
"nyfi",
"okex",
"openocean",
"pausable",
"pkts",
Expand All @@ -287,6 +288,7 @@
"redpackets",
"renfil",
"shapeclip",
"ssrb",
"steth",
"swaptoken",
"testweb",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.7.0",
"version": "2.8.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you merge correctly? it contains a lot of unrelated changes

"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ export const Balance = memo<BalanceCardProps>(
</Box>
{showOperations && (
<ButtonGroup>
<Button size="small" onClick={onSend} endIcon={<SendIcon fontSize="inherit" />}>
<Button
size="small"
onClick={onSend}
endIcon={<SendIcon style={{ fill: '#fff' }} fontSize="inherit" />}>
{t.wallets_balance_Send()}
</Button>
<Button size="small" onClick={onBuy} endIcon={<CardIcon fill="none" fontSize="inherit" />}>
<Button size="small" onClick={onBuy} endIcon={<CardIcon fontSize="inherit" />}>
{t.wallets_balance_Buy()}
</Button>
<Button size="small" onClick={onSwap} endIcon={<SwapIcon fontSize="inherit" />}>
Expand Down
2 changes: 0 additions & 2 deletions packages/icons/general/Copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ export const CopyIcon = createIcon(
fillRule="evenodd"
clipRule="evenodd"
d="M7.736 12.538c-.898 0-1.68-.267-2.244-.793-.566-.53-.858-1.273-.858-2.117V4.882c0-.84.29-1.58.852-2.109.558-.525 1.335-.795 2.226-.8h.003l4.383-.001c.898 0 1.68.267 2.244.793.566.53.858 1.273.858 2.117v4.746c0 .84-.29 1.58-.852 2.109-.558.525-1.335.794-2.226.8h-.003l-4.383.001v-.533.533Zm0-1.066c-.689 0-1.19-.203-1.516-.507-.32-.3-.52-.745-.52-1.337V4.882c0-.588.198-1.032.516-1.332.322-.303.82-.506 1.5-.51h.002l4.38-.002c.689 0 1.19.203 1.515.507.321.3.52.745.52 1.337v4.746c0 .588-.197 1.032-.516 1.332-.321.302-.818.506-1.5.51l-4.381.002Z"
fill="#767F8D"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M5.41 14.615c-.898 0-1.68-.267-2.243-.793-.567-.53-.86-1.273-.86-2.117V6.959c0-1.084.484-1.986 1.37-2.489a.533.533 0 1 1 .526.928c-.514.292-.828.816-.828 1.561v4.746c0 .592.199 1.037.52 1.337.325.304.826.507 1.515.507l4.382-.002c.763-.005 1.295-.259 1.612-.628a.533.533 0 1 1 .81.695c-.563.654-1.418.994-2.418 1h-.003l-4.383.001v-.533.533Z"
fill="#767F8D"
/>
</g>,
'0 0 16 17',
Expand Down
73 changes: 50 additions & 23 deletions packages/mask/background/network/gun/encryption/queryPostKey.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { decodeArrayBuffer, encodeArrayBuffer } from '@dimensiondev/kit'
import type { DecryptStaticECDH_PostKey, EncryptionResultE2EMap } from '@masknet/encryption'
import { decodeArrayBuffer, encodeArrayBuffer, isNonNull, unreachable } from '@dimensiondev/kit'
import { type DecryptStaticECDH_PostKey, type EncryptionResultE2EMap, SocialNetworkEnum } from '@masknet/encryption'
import type { EC_Public_CryptoKey, EC_Public_JsonWebKey } from '@masknet/shared-base'
import { CryptoKeyToJsonWebKey } from '../../../../utils-pure'
import { getGunData, pushToGunDataArray, subscribeGunMapData } from '@masknet/gun-utils'
import { EventIterator } from 'event-iterator'
import { noop } from 'lodash-unified'
import { isObject, noop, uniq } from 'lodash-unified'
import { queryPublicKey } from '../../../database/persona/helper'

// !!! Change how this file access Gun will break the compatibility of v40 payload decryption.
Expand Down Expand Up @@ -36,31 +36,47 @@ namespace Version38Or39 {
version: -38 | -39,
iv: Uint8Array,
minePublicKey: EC_Public_CryptoKey,
networkHint: string,
network: SocialNetworkEnum,
abortSignal: AbortSignal,
): AsyncGenerator<DecryptStaticECDH_PostKey, void, undefined> {
const minePublicKeyJWK = await CryptoKeyToJsonWebKey(minePublicKey)
const { keyHash, postHash } = await calculatePostKeyPartition(version, networkHint, iv, minePublicKeyJWK)
const { keyHash, postHash } = await calculatePostKeyPartition(version, network, iv, minePublicKeyJWK)

/* cspell:disable-next-line */
// ? In this step we get something like ["jzarhbyjtexiE7aB1DvQ", "jzarhuse6xlTAtblKRx9"]
console.log(`[@masknet/encryption] Reading key partition [${postHash}][${keyHash}]`)
const internalNodeNames = Object.keys((await getGunData(postHash, keyHash)) || {}).filter((x) => x !== '_')
console.log(
`[@masknet/encryption] Reading key partition [${postHash[0]}][${keyHash}] and [${postHash[1]}][${keyHash}]`,
)
const internalNodeNames = uniq(
(
await Promise.all([
//
getGunData(postHash[0], keyHash),
getGunData(postHash[1], keyHash),
])
)
.filter(isNonNull)
.filter(isObject)
.map(Object.keys)
.flat()
.filter((x) => x !== '_'),
)
// ? In this step we get all keys in this category (gun2[postHash][keyHash])
const resultPromise = internalNodeNames.map((key) => getGunData(key))

const iter = new EventIterator<DecryptStaticECDH_PostKey>((queue) => {
// immediate results
for (const result of resultPromise) result.then(emit, noop)

async function main() {
const iter = subscribeGunMapData([postHash], isValidData, abortSignal)
for await (const data of iter) emit(data)
queue.stop()
// future results
Promise.all([
main(subscribeGunMapData([postHash[1]], isValidData, abortSignal)),
main(subscribeGunMapData([postHash[0]], isValidData, abortSignal)),
]).then(() => queue.stop())

async function main(keyProvider: AsyncGenerator<unknown>) {
for await (const data of keyProvider) emit(data)
}

main()

function emit(result: any) {
function emit(result: unknown) {
if (abortSignal.aborted) return
if (!isValidData(result)) return
queue.push({
Expand All @@ -86,10 +102,10 @@ namespace Version38Or39 {
export async function publishPostAESKey_version39Or38(
version: -39 | -38,
postIV: Uint8Array,
networkHint: string,
network: SocialNetworkEnum,
receiversKeys: PublishedAESKeyRecord[] | EncryptionResultE2EMap,
) {
const postHash = await hashIV(networkHint, postIV)
const [postHash] = await hashIV(network, postIV)
if (Array.isArray(receiversKeys)) {
// Store AES key to gun
receiversKeys.forEach(async ({ aesKey, receiverKey }) => {
Expand Down Expand Up @@ -137,23 +153,34 @@ namespace Version38Or39 {

async function calculatePostKeyPartition(
version: -38 | -39,
networkHint: string,
network: SocialNetworkEnum,
iv: Uint8Array,
key: EC_Public_JsonWebKey,
) {
const postHash = await hashIV(networkHint, iv)
const postHash = await hashIV(network, iv)
// In version > -39, we will use stable hash to prevent unstable result for key hashing

const keyHash = version === -39 ? await hashKey39(key) : await hashKey38(key)
return { postHash, keyHash }
}

async function hashIV(networkHint: string, iv: Uint8Array) {
async function hashIV(network: SocialNetworkEnum, iv: Uint8Array): Promise<[string, string]> {
const hashPair = '9283464d-ee4e-4e8d-a7f3-cf392a88133f'
const N = 2

const hash = await work(encodeArrayBuffer(iv), hashPair)
return networkHint + '-' + hash.slice(0, N)
const hash = (await work(encodeArrayBuffer(iv), hashPair)).slice(0, N)
const networkHint = getNetworkHint(network)
return [`${networkHint}${hash}`, `${networkHint}-${hash}`]
}

function getNetworkHint(x: SocialNetworkEnum) {
if (x === SocialNetworkEnum.Facebook) return ''
if (x === SocialNetworkEnum.Twitter) return 'twitter-'
if (x === SocialNetworkEnum.Minds) return 'minds-'
if (x === SocialNetworkEnum.Instagram) return 'instagram-'
if (x === SocialNetworkEnum.Unknown)
throw new TypeError('[@masknet/encryption] Current SNS network is not correctly configured.')
unreachable(x)
}

// The difference between V38 and V39 is: V39 is not stable (JSON.stringify)
Expand Down
11 changes: 9 additions & 2 deletions packages/mask/background/services/crypto/appendEncryption.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { appendEncryptionTarget, EC_Key, EC_KeyCurveEnum, SupportedPayloadVersions } from '@masknet/encryption'
import {
appendEncryptionTarget,
EC_Key,
EC_KeyCurveEnum,
SocialNetworkEnum,
SupportedPayloadVersions,
} from '@masknet/encryption'
import type { EC_Public_CryptoKey, PostIVIdentifier, ProfileIdentifier } from '@masknet/shared-base'
import { deriveAESByECDH, queryPublicKey } from '../../database/persona/helper'
import { updatePostDB, queryPostDB } from '../../database/post'
Expand All @@ -10,6 +16,7 @@ export async function appendShareTarget(
post: PostIVIdentifier,
target: ProfileIdentifier[],
whoAmI: ProfileIdentifier,
network: SocialNetworkEnum,
): Promise<void> {
if (version === -39 || version === -40) throw new TypeError('invalid version')
const key = await getPostKeyCache(post)
Expand Down Expand Up @@ -38,7 +45,7 @@ export async function appendShareTarget(
},
)

publishPostAESKey_version39Or38(-38, post.toIV(), whoAmI.network, e2e)
publishPostAESKey_version39Or38(-38, post.toIV(), network, e2e)

updatePostDB(
{
Expand Down
16 changes: 3 additions & 13 deletions packages/mask/background/services/crypto/decryption.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encodeArrayBuffer, unreachable } from '@dimensiondev/kit'
import { encodeArrayBuffer } from '@dimensiondev/kit'
import {
decrypt,
parsePayload,
Expand Down Expand Up @@ -158,7 +158,7 @@ async function* decryption(payload: string | Uint8Array, context: DecryptionCont
-38,
iv,
author,
getNetworkHint(context.currentSocialNetwork),
context.currentSocialNetwork,
signal || new AbortController().signal,
)
},
Expand All @@ -170,7 +170,7 @@ async function* decryption(payload: string | Uint8Array, context: DecryptionCont
-39,
iv,
author,
getNetworkHint(context.currentSocialNetwork),
context.currentSocialNetwork,
signal || new AbortController().signal,
)
},
Expand All @@ -185,16 +185,6 @@ async function* decryption(payload: string | Uint8Array, context: DecryptionCont
return null
}

function getNetworkHint(x: SocialNetworkEnum) {
if (x === SocialNetworkEnum.Facebook) return ''
if (x === SocialNetworkEnum.Twitter) return 'twitter-'
if (x === SocialNetworkEnum.Minds) return 'minds-'
if (x === SocialNetworkEnum.Instagram) return 'instagram-'
if (x === SocialNetworkEnum.Unknown)
throw new TypeError('[@masknet/encryption] Current SNS network is not correctly configured.')
unreachable(x)
}

/** @internal */
export async function getPostKeyCache(id: PostIVIdentifier) {
const post = await queryPostDB(id)
Expand Down
10 changes: 5 additions & 5 deletions packages/mask/background/services/crypto/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
EncryptionResultE2EMap,
EncryptTargetE2E,
EncryptTargetPublic,
SocialNetworkEnum,
SocialNetworkEnumToProfileDomain,
} from '@masknet/encryption'
import { encryptByLocalKey, deriveAESByECDH, queryPublicKey } from '../../database/persona/helper'
import { savePostKeyToDB } from '../../database/post/helper'
Expand All @@ -18,13 +20,11 @@ export async function encryptTo(
content: SerializableTypedMessages,
target: EncryptTargetPublic | EncryptTargetE2E,
whoAmI: ProfileIdentifier | undefined,
IdentifierNetwork: string,
network: SocialNetworkEnum,
): Promise<string> {
// always use identifier network from ProfileIdentifier if possible.
if (whoAmI) IdentifierNetwork = whoAmI.network
const { identifier, output, postKey, e2e } = await encrypt(
{
network: IdentifierNetwork,
network: whoAmI?.network || SocialNetworkEnumToProfileDomain(network),
author: whoAmI,
message: content,
target,
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function encryptTo(
})().catch((error) => console.error('[@masknet/encryption] Failed to save post key to DB', error))

if (target.type === 'E2E') {
publishPostAESKey_version39Or38(-38, identifier.toIV(), IdentifierNetwork, e2e!)
publishPostAESKey_version39Or38(-38, identifier.toIV(), network, e2e!)
}
if (typeof output !== 'string') throw new Error('version -37 is not enabled yet!')
return output
Expand Down
5 changes: 2 additions & 3 deletions packages/mask/background/services/identity/persona/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { MaskMessages } from '../../../../shared'
import { PersonaIdentifier, fromBase64URL, PopupRoutes, ECKeyIdentifier } from '@masknet/shared-base'
import { queryPersonasWithPrivateKey } from '../../../../background/database/persona/db'
import { openPopupWindow } from '../../../../background/services/helper'
import { delay } from '@dimensiondev/kit'
import { delay, encodeText } from '@dimensiondev/kit'
export interface SignRequest {
/** Use that who to sign this message. */
identifier?: PersonaIdentifier
Expand Down Expand Up @@ -56,8 +56,7 @@ export async function generateSignResult(signer: ECKeyIdentifier, message: strin
const persona = (await queryPersonasWithPrivateKey()).find((x) => x.identifier === signer)
if (!persona) throw new Error('Persona not found')

// will have problem with UTF-8?
const length = message.length
const length = encodeText(message).length
const messageHash = keccakFromString(`\x19Ethereum Signed Message:\n${length}${message}`, 256)
const privateKey = Buffer.from(fromBase64URL(persona.privateKey.d!))
const signature = ecsign(messageHash, privateKey)
Expand Down
7 changes: 4 additions & 3 deletions packages/mask/shared-ui/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"compose_encrypt_visible_to_all_sub": "Everyone",
"compose_encrypt_visible_to_private": "Private",
"compose_encrypt_visible_to_private_sub": "Just Me",
"compose_shared_friends": "1 friend",
"compose_shared_friends_one": "1 friend",
"compose_shared_friends_other": "{{count}} friends",
"compose_encrypt_visible_to_share": "Share with",
"compose_encrypt_visible_to_share_sub": "Just Selected Contacts",
"compose_encrypt_share_dialog_empty": "No encrypted friends, you can try searching.",
Expand Down Expand Up @@ -336,14 +337,14 @@
"plugin_wallet_name_placeholder": "Enter 1-12 characters",
"plugin_wallet_fail_to_sign": "Failed to sign password.",
"plugin_wallet_cancel_sign": "Signature canceled.",
"plugin_nft_avatar_recommend_feature_description": "Set your NFT as profile picture with exclusive aura",
"plugin_nft_avatar_recommend_feature_description": "Set your NFT as profile picture with exclusive aura.",
"plugin_red_packet_display_name": "Plugin: Lucky Drop",
"application_hint": "Socialize and show off your NFTs. People can bid,buy, view your valuable NFTs without leaving Twitter.",
"plugin_red_packet_claimed": "Claimed",
"plugin_red_packet_erc20_tab_title": "Token",
"plugin_red_packet_erc721_tab_title": "Collectibles",
"plugin_red_packet_name": "Lucky Drop",
"plugin_red_packet_recommend_feature_description": "Astonish your friends with a surprise gift",
"plugin_red_packet_recommend_feature_description": "Astonish your friends with a surprise gift.",
"plugin_red_packet_description": "Gift crypto or NFTs to any users, first come, first served.",
"plugin_red_packet_erc721_insufficient_balance": "Insufficient Balance",
"plugin_red_packet_details": "Lucky Drop Details",
Expand Down
10 changes: 8 additions & 2 deletions packages/mask/src/components/CompositionDialog/CompositionUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const useStyles = makeStyles()((theme) => ({
position: 'absolute',
bottom: 0,
width: '100%',
left: '50%',
transform: 'translateX(-50%)',
display: 'flex',
padding: '14px 16px',
boxSizing: 'border-box',
Expand All @@ -47,7 +49,6 @@ const useStyles = makeStyles()((theme) => ({
alignItems: 'center',
background: theme.palette.background.paper,
boxShadow: `0px 0px 20px 0px ${theme.palette.background.messageShadow}`,
transform: 'translateX(-16px)',
},
between: {
justifyContent: 'space-between',
Expand Down Expand Up @@ -78,6 +79,11 @@ const useStyles = makeStyles()((theme) => ({
boxSizing: 'border-box',
borderRadius: 8,
},
sendIcon: {
width: 18,
height: 18,
fill: theme.palette.text.buttonText,
},
}))

export interface LazyRecipients {
Expand Down Expand Up @@ -239,7 +245,7 @@ export const CompositionDialogUI = forwardRef<CompositionRef, CompositionProps>(
loadingPosition="start"
variant="roundedContained"
onClick={onSubmit}
startIcon={<SendIcon style={{ width: 18, height: 18 }} />}>
startIcon={<SendIcon className={classes.sendIcon} />}>
{t('post_dialog__button')}
</LoadingButton>
</div>
Expand Down
Loading