Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions packages/icons/brands/NextID.svg

This file was deleted.

7 changes: 0 additions & 7 deletions packages/icons/brands/NextIDMini.dark.svg

This file was deleted.

7 changes: 0 additions & 7 deletions packages/icons/brands/NextIDMini.light.svg

This file was deleted.

7 changes: 0 additions & 7 deletions packages/icons/general/NextIdAvatar.dark.svg

This file was deleted.

7 changes: 0 additions & 7 deletions packages/icons/general/NextIdAvatar.light.svg

This file was deleted.

6 changes: 0 additions & 6 deletions packages/icons/general/NextIdPersonaWarning.svg

This file was deleted.

30 changes: 0 additions & 30 deletions packages/icons/icon-generated-as-jsx.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions packages/icons/icon-generated-as-url.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/mask/background/services/crypto/decryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async function* decryption(payload: string | Uint8Array, context: DecryptionCont
return Array.from((await deriveAESByECDH(pub)).values())
},
queryAuthorPublicKey(author, signal) {
// TODO: This should try to fetch publicKey from NextID
// TODO: This should try to fetch publicKey from external sources
// but it is not urgent because all new posts has their publicKey embedded
return queryPublicKey(author || authorHint)
},
Expand Down
21 changes: 2 additions & 19 deletions packages/mask/background/services/identity/persona/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import {
type EC_Public_JsonWebKey,
fromBase64URL,
isEC_Private_JsonWebKey,
type NextIDPlatform,
type PersonaIdentifier,
type PersonaInformation,
type ProfileIdentifier,
type SocialIdentity,
} from '@masknet/shared-base'
import type { IdentityResolved } from '@masknet/plugin-infra'
import { NextIDProof } from '@masknet/web3-providers'
import {
createPersonaDBReadonlyAccess,
queryPersonaDB,
Expand All @@ -24,6 +21,7 @@ import { recover_ECDH_256k1_KeyPair_ByMnemonicWord } from './utils.js'
import { bytesToHex, privateToPublic, publicToAddress } from '@ethereumjs/util'
import { decode } from '@msgpack/msgpack'
import { decodeArrayBuffer } from '@masknet/kit'
import type { IdentityResolved } from '@masknet/plugin-infra'

export async function queryOwnedPersonaInformation(initializedOnly: boolean): Promise<PersonaInformation[]> {
let result: Promise<PersonaInformation[]>
Expand Down Expand Up @@ -89,29 +87,14 @@ export async function queryPersonaEOAByPrivateKey(privateKeyString: string) {
}
}

export async function queryPersonasFromNextID(platform: NextIDPlatform, identityResolved: IdentityResolved) {
if (!identityResolved.identifier) return
return NextIDProof.queryAllExistedBindingsByPlatform(platform, identityResolved.identifier.userId)
}

export async function querySocialIdentity(
platform: NextIDPlatform,
identity: IdentityResolved | undefined,
): Promise<SocialIdentity | undefined> {
export async function querySocialIdentity(identity: IdentityResolved | undefined): Promise<SocialIdentity | undefined> {
if (!identity?.identifier) return
const persona = await queryPersonaByProfile(identity.identifier)
if (!persona) return identity

const bindings = await queryPersonasFromNextID(platform, identity)
if (!bindings) return identity

const personaBindings =
bindings?.filter((x) => x.persona === persona?.identifier.publicKeyAsHex.toLowerCase()) ?? []
return {
...identity,
publicKey: persona?.identifier.publicKeyAsHex,
hasBinding: personaBindings.length > 0,
binding: first(personaBindings),
}
}

Expand Down
83 changes: 1 addition & 82 deletions packages/mask/background/services/identity/profile/update.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
decompressK256Key,
type ECKeyIdentifier,
NextIDAction,
type PersonaIdentifier,
ProfileIdentifier,
type ProfileInformationFromNextID,
RelationFavor,
MaskMessages,
} from '@masknet/shared-base'
import { NextIDProof } from '@masknet/web3-providers'
import { type PersonaIdentifier, ProfileIdentifier } from '@masknet/shared-base'
import { storeAvatar } from '../../../database/avatar-cache/avatar.js'
import {
attachProfileDB,
Expand All @@ -18,12 +8,10 @@ import {
deleteProfileDB,
detachProfileDB,
type LinkedProfileDetails,
type PersonaRecord,
type ProfileRecord,
queryProfileDB,
queryProfilesDB,
} from '../../../database/persona/db.js'
import { createOrUpdatePersonaDB, createOrUpdateRelationDB } from '../../../database/persona/web.js'

interface UpdateProfileInfo {
nickname?: string | null
Expand All @@ -42,21 +30,6 @@ export async function updateProfileInfo(identifier: ProfileIdentifier, data: Upd
if (data.avatarURL) await storeAvatar(identifier, data.avatarURL)
}

export async function detachProfileWithNextID(
uuid: string,
personaPublicKey: string,
platform: string,
identity: string,
createdAt: string,
options?: {
signature?: string
},
): Promise<void> {
await NextIDProof.bindProof(uuid, personaPublicKey, NextIDAction.Delete, platform, identity, createdAt, {
signature: options?.signature,
})
MaskMessages.events.ownProofChanged.sendToAll(undefined)
}
const err = 'resolveUnknownLegacyIdentity should not be called on localhost'
/**
* In older version of Mask, identity is marked as `ProfileIdentifier(network, '$unknown')` or `ProfileIdentifier(network, '$self')`. After upgrading to the newer version of Mask, Mask will try to find the current user in that network and call this function to replace old identifier into a "resolved" identity.
Expand Down Expand Up @@ -98,57 +71,3 @@ export async function attachProfile(
export function detachProfile(identifier: ProfileIdentifier): Promise<void> {
return detachProfileDB(identifier)
}

/**
* Set NextID profile to profileDB
* */

export async function attachNextIDPersonaToProfile(item: ProfileInformationFromNextID, whoAmI: ECKeyIdentifier) {
if (!item.linkedPersona) throw new Error('LinkedPersona Not Found')
const now = new Date()
const personaRecord: PersonaRecord = {
createdAt: now,
updatedAt: now,
identifier: item.linkedPersona,
linkedProfiles: new Map(),
publicKey: await decompressK256Key(item.linkedPersona.rawPublicKey),
publicHexKey: item.linkedPersona.publicKeyAsHex,
nickname: item.nickname,
hasLogout: false,
uninitialized: false,
}

const profileRecord: ProfileRecord = {
identifier: item.identifier,
nickname: item.nickname,
linkedPersona: item.linkedPersona,
createdAt: now,
updatedAt: now,
}
try {
await consistentPersonaDBWriteAccess(async (t) => {
await createOrUpdatePersonaDB(
personaRecord,
{ explicitUndefinedField: 'ignore', linkedProfiles: 'merge' },
t,
)
await createOrUpdateProfileDB(profileRecord, t)
await attachProfileDB(
profileRecord.identifier,
item.linkedPersona!,
{ connectionConfirmState: 'confirmed' },
t,
)
await createOrUpdateRelationDB(
{
profile: profileRecord.identifier,
linked: whoAmI,
favor: RelationFavor.UNCOLLECTED,
},
t,
)
})
} catch {
// already exist
}
}
2 changes: 1 addition & 1 deletion packages/mask/background/services/site-adaptors/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function connectSite(
await browser.tabs.update(targetTab.id, { active: true })
await browser.windows.update(targetTab.windowId, { focused: true })
currentSetupGuideStatus[network].value = stringify({
status: SetupGuideStep.VerifyOnNextID,
status: SetupGuideStep.PinExtension,
persona: identifier.toText(),
username: profile?.userId,
tabId: targetTab.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { IdentityResolved } from '@masknet/plugin-infra'
import { MaskMessages, ValueRef, type NextIDPersonaBindings, type ProfileInformation } from '@masknet/shared-base'
import { MaskMessages, ValueRef, type ProfileInformation } from '@masknet/shared-base'
import { useValueRef } from '@masknet/shared-base-ui'
import { NextIDProof } from '@masknet/web3-providers'
import { FontSize, ThemeColor, ThemeMode, type ThemeSettings } from '@masknet/web3-shared-base'
import { useQuery } from '@tanstack/react-query'
import { first, isEqual } from 'lodash-es'
Expand All @@ -15,15 +14,6 @@ async function queryPersonaFromDB(identityResolved: IdentityResolved) {
return Services.Identity.queryPersonaByProfile(identityResolved.identifier)
}

async function queryPersonasFromNextID(identityResolved: IdentityResolved) {
if (!identityResolved.identifier) return
if (!activatedSiteAdaptorUI?.configuration.nextIDConfig?.platform) return
return NextIDProof.queryAllExistedBindingsByPlatform(
activatedSiteAdaptorUI.configuration.nextIDConfig.platform,
identityResolved.identifier.userId,
)
}

const CurrentIdentitySubscription: Subscription<ProfileInformation | undefined> = {
getCurrentValue() {
const all = activatedSiteAdaptor_state!.profiles.value
Expand Down Expand Up @@ -60,16 +50,11 @@ export function useCurrentVisitingIdentity() {
)
}

interface SocialIdentity extends IdentityResolved {
publicKey?: string
hasBinding?: boolean
binding?: NextIDPersonaBindings
}
/**
* Get the social identity of the given identity
*/
export function useSocialIdentity(identity: IdentityResolved | null | undefined) {
const result = useQuery<SocialIdentity | null>({
const result = useQuery({
enabled: !!identity,
queryKey: ['social-identity', identity],
queryFn: async () => {
Expand All @@ -79,16 +64,9 @@ export function useSocialIdentity(identity: IdentityResolved | null | undefined)
const persona = await queryPersonaFromDB(identity)
if (!persona) return identity

const bindings = await queryPersonasFromNextID(identity)
if (!bindings) return identity

const personaBindings =
bindings?.filter((x) => x.persona === persona?.identifier.publicKeyAsHex.toLowerCase()) ?? []
return {
...identity,
publicKey: persona?.identifier.publicKeyAsHex,
hasBinding: personaBindings.length > 0,
binding: first(personaBindings),
}
} catch {
return identity || null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ import { Trans } from '@lingui/react/macro'
import { Icons } from '@masknet/icons'
import { delay } from '@masknet/kit'
import { PostInfoContext, usePostInfoDetails, usePostInfoPostIVIdentifier } from '@masknet/plugin-infra/content-script'
import {
EMPTY_LIST,
MaskMessages,
type ProfileIdentifier,
type ProfileInformation,
type ProfileInformationFromNextID,
} from '@masknet/shared-base'
import { EMPTY_LIST, MaskMessages, type ProfileIdentifier, type ProfileInformation } from '@masknet/shared-base'
import { makeStyles } from '@masknet/theme'
import type { TypedMessage } from '@masknet/typed-message'
import { Typography, useTheme } from '@mui/material'
import { memo, useContext, useEffect, useState } from 'react'
import { attachNextIDToProfile } from '../../../../shared-ui/index.js'
import { activatedSiteAdaptorUI } from '../../../site-adaptor-infra/index.js'
import type { LazyRecipients } from '../../CompositionDialog/CompositionUI.js'
import { useRecipientsList } from '../../CompositionDialog/useRecipientsList.js'
Expand Down Expand Up @@ -157,9 +150,6 @@ function AppendShareDetail({ recipients, selectedRecipients, onClose, whoAmI, re
profiles={recipients.recipients || EMPTY_LIST}
onClose={onClose}
onSelect={async (profiles) => {
for (const item of profiles) {
await attachNextIDToProfile(item as ProfileInformationFromNextID)
}
await Services.Crypto.appendShareTarget(
info.version.getCurrentValue()!,
iv,
Expand Down
Loading
Loading