diff --git a/app/mobile/src/context/useAppContext.hook.js b/app/mobile/src/context/useAppContext.hook.js index d5945c3f..d02e6fc7 100644 --- a/app/mobile/src/context/useAppContext.hook.js +++ b/app/mobile/src/context/useAppContext.hook.js @@ -46,12 +46,17 @@ export function useAppContext() { const setDeviceToken = async () => { if (!deviceToken.current) { - const token = await messaging().getToken(); - if (!token) { - throw new Error('null push token'); + try { + const token = await messaging().getToken(); + if (!token) { + throw new Error('null push token'); + } + deviceToken.current = token; + pushType.current = "fcm"; + } + catch(err) { + console.log(err); } - deviceToken.current = token; - pushType.current = "fcm"; } } @@ -64,12 +69,7 @@ export function useAppContext() { }); (async () => { - try { - await setDeviceToken(); - } - catch (err) { - console.log(err); - } + await setDeviceToken(); access.current = await store.actions.init(); if (access.current) { await setSession(); diff --git a/app/mobile/src/session/cards/Cards.jsx b/app/mobile/src/session/cards/Cards.jsx index 1234142e..115ee2cb 100644 --- a/app/mobile/src/session/cards/Cards.jsx +++ b/app/mobile/src/session/cards/Cards.jsx @@ -91,7 +91,8 @@ export function Cards({ navigation, openContact, openRegistry, addChannel }) { data={state.cards} initialNumToRender={25} renderItem={({ item }) => call(item)} message={() => addChannel(item.cardId)} />} + enableIce={state.enableIce} call={() => call(item)} message={() => addChannel(item.cardId)} + canMessage={(item.seal && state.sealable) || state.allowUnsealed} />} keyExtractor={item => item.cardId} /> )} diff --git a/app/mobile/src/session/cards/cardItem/CardItem.jsx b/app/mobile/src/session/cards/cardItem/CardItem.jsx index b2869159..d512052d 100644 --- a/app/mobile/src/session/cards/cardItem/CardItem.jsx +++ b/app/mobile/src/session/cards/cardItem/CardItem.jsx @@ -6,7 +6,7 @@ import Colors from 'constants/Colors'; import { Menu, MenuOptions, MenuOption, MenuTrigger } from 'react-native-popup-menu'; import { getLanguageStrings } from 'constants/Strings'; -export function CardItem({ item, openContact, enableIce, call, message }) { +export function CardItem({ item, openContact, enableIce, call, message, canMessage }) { const strings = getLanguageStrings(); @@ -43,12 +43,16 @@ export function CardItem({ item, openContact, enableIce, call, message }) { { strings.viewProfile } - - { strings.messageContact } - - - { strings.callContact } - + { canMessage && ( + + { strings.messageContact } + + )} + { enableIce && ( + + { strings.callContact } + + )} )} diff --git a/app/mobile/src/session/cards/useCards.hook.js b/app/mobile/src/session/cards/useCards.hook.js index 9c6c51b0..1d1271f5 100644 --- a/app/mobile/src/session/cards/useCards.hook.js +++ b/app/mobile/src/session/cards/useCards.hook.js @@ -10,6 +10,8 @@ export function useCards() { const [state, setState] = useState({ cards: [], enableIce: false, + sealable: false, + allowUnsealed: false, strings: getLanguageStrings(), sort: false, filter: null, @@ -25,13 +27,19 @@ export function useCards() { } useEffect(() => { - const { enableIce } = account.state.status || {}; - updateState({ enableIce }); + const { enableIce, allowUnsealed } = account.state.status || {}; + const { status, sealKey } = account.state; + if (status?.seal?.publicKey && sealKey?.public && sealKey?.private && sealKey?.public === status.seal.publicKey) { + updateState({ sealable: true, allowUnsealed, enableIce }); + } + else { + updateState({ sealable: false, allowUnsealed, enableIce }); + } }, [account.state]); const setCardItem = (item) => { const { profile, detail, cardId, blocked, offsync } = item.card || { profile: {}, detail: {} } - const { name, handle, node, guid, location, description, imageSet } = profile; + const { name, handle, node, guid, location, description, imageSet, seal } = profile; return { cardId: cardId, @@ -44,6 +52,7 @@ export function useCards() { description: description, status: detail.status, token: detail.token, + seal: seal, offsync: offsync, blocked: blocked, updated: detail.statusUpdated, @@ -111,8 +120,6 @@ export function useCards() { updateState({ filter }); }, setSort: (sort) => { -console.log("SETTTING : ", sort); - updateState({ sort }); }, }; diff --git a/app/mobile/src/session/useSession.hook.js b/app/mobile/src/session/useSession.hook.js index f3c2cb75..7546bbca 100644 --- a/app/mobile/src/session/useSession.hook.js +++ b/app/mobile/src/session/useSession.hook.js @@ -3,10 +3,12 @@ import { useWindowDimensions } from 'react-native'; import config from 'constants/Config'; import { StoreContext } from 'context/StoreContext'; import { CardContext } from 'context/CardContext'; +import { AccountContext } from 'context/AccountContext'; import { ChannelContext } from 'context/ChannelContext'; import { RingContext } from 'context/RingContext'; import { ProfileContext } from 'context/ProfileContext'; import { getLanguageStrings } from 'constants/Strings'; +import { encryptChannelSubject } from 'context/sealUtil'; export function useSession() { @@ -30,6 +32,7 @@ export function useSession() { }); const ring = useContext(RingContext); + const account = useContext(AccountContext); const channel = useContext(ChannelContext); const card = useContext(CardContext); const profile = useContext(ProfileContext); @@ -70,6 +73,18 @@ export function useSession() { updateState({ ringing, callStatus, callLogo, localStream, localVideo, localAudio, remoteStream, remoteVideo, remoteAudio }); }, [ring.state]); + useEffect(() => { + const { allowUnsealed } = account.state.status || {}; + const { status, sealKey } = account.state; + if (status?.seal?.publicKey && sealKey?.public && sealKey?.private && sealKey?.public === status.seal.publicKey) { + updateState({ sealable: true, allowUnsealed }); + } + else { + updateState({ sealable: false, allowUnsealed }); + } + }, [account.state]); + + useEffect(() => { checkFirstRun(); }, []); @@ -140,8 +155,17 @@ export function useSession() { if (channelId != null) { return channelId; } - const conversation = await channel.actions.addChannel('superbasic', { subject: null }, [ cardId ]); - return conversation.id; + if (state.sealable && !state.allowUnsealed) { + const keys = [ account.state.sealKey.public ]; + keys.push(card.state.cards.get(cardId).card.profile.seal); + const sealed = encryptChannelSubject(state.subject, keys); + const conversation = await channel.actions.addChannel('sealed', sealed, [ cardId ]); + return conversation.id; + } + else { + const conversation = await channel.actions.addChannel('superbasic', { subject: null }, [ cardId ]); + return conversation.id; + } }, }; diff --git a/net/host/Dockerfile b/net/host/Dockerfile index 7ec8dd8d..7d8be9db 100644 --- a/net/host/Dockerfile +++ b/net/host/Dockerfile @@ -7,7 +7,7 @@ EXPOSE 7000 ENV TZ=America/Los_Angeles RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -RUN apt-get update +RUN apt-get update RUN apt-get -y install curl RUN apt-get -y install net-tools @@ -36,7 +36,7 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then ARCHITECTURE=amd64; elif [ "$ && wget -P /app https://go.dev/dl/go1.18.10.linux-${ARCHITECTURE}.tar.gz \ && tar -C /usr/local -xzf /app/go1.18.10.linux-${ARCHITECTURE}.tar.gz -RUN git clone https://github.com/balzack/databag.git -b openwrt /app/databag +RUN git clone https://github.com/balzack/databag.git /app/databag RUN yarn config set network-timeout 300000 RUN yarn --cwd /app/databag/net/web install