Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
feat: encryption works (probably)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodzonko committed Jun 29, 2023
1 parent d8e6dc1 commit f0f3fd1
Show file tree
Hide file tree
Showing 43 changed files with 944 additions and 503 deletions.
4 changes: 4 additions & 0 deletions sdex-encrypted-communicator/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ node_modules
dist
.expo
.vscode
.idea
android
assets
icons
9 changes: 8 additions & 1 deletion sdex-encrypted-communicator/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,21 @@
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"project": "./test.tsconfig.json",
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "react-native", "@typescript-eslint", "prettier"],
"ignorePatterns": [
"node_modules/",
"babel.config.js",
"metro.config.js",
"jest.config.js",
"tailwind.config.js"
],
"settings": {
"import/resolver": {
"node": {
Expand Down
34 changes: 0 additions & 34 deletions sdex-encrypted-communicator/App.tsx

This file was deleted.

1 change: 0 additions & 1 deletion sdex-encrypted-communicator/app.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions sdex-encrypted-communicator/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"plugins": ["expo-document-picker"],
"jsEngine": "hermes",
"updates": {
"fallbackToCacheTimeout": 0,
Expand Down
Binary file modified sdex-encrypted-communicator/assets/SqlDbTemplate.db
Binary file not shown.
1 change: 1 addition & 0 deletions sdex-encrypted-communicator/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference types="nativewind/types" />
declare module "*.db";
15 changes: 3 additions & 12 deletions sdex-encrypted-communicator/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
// prettier-ignore
// import "react-native-gesture-handler";
// prettier-ignore
// import { registerRootComponent } from "expo";
// import "expo-router/entry";
// import App from "./App";

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
// registerRootComponent(App);

/* eslint-disable react/react-in-jsx-scope */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { registerRootComponent } from "expo";
import { ExpoRoot } from "expo-router";

Expand Down
9 changes: 0 additions & 9 deletions sdex-encrypted-communicator/jest/setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import "react";
import { View } from "react-native";
import "react-native-gesture-handler/jestSetup";

// include this section and the NativeAnimatedHelper section for mocking react-native-reanimated
Expand Down Expand Up @@ -29,11 +28,3 @@ jest.mock("react-native-safe-area-context", () => {
useSafeAreaInsets: jest.fn().mockImplementation(() => inset),
};
});

jest.mock("react-native-paper", () => {
const RealModule = jest.requireActual("react-native-paper");
return {
...RealModule,
Portal: ({ children }) => <View>{children}</View>,
};
});
12 changes: 12 additions & 0 deletions sdex-encrypted-communicator/package-lock.json

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

10 changes: 6 additions & 4 deletions sdex-encrypted-communicator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
"scripts": {
"start": "SET NODE_OPTIONS=--openssl-legacy-provider && expo start --dev-client",
"android": "expo run:android --device Galaxy_S20_Plus_API_33",
"android-physical": "expo run:android --device SM_G985F",
"ios": "expo run:ios --device",
"web": "SET NODE_OPTIONS=--openssl-legacy-provider && expo start --web",
"lint": "eslint --fix --ext .ts --ext .tsx --ext .js --ext .jsx src",
"format": "prettier --ignore-path ../.gitignore --write \"(src/**/*.+(js|ts|jsx|tsx|json)|App.tsx)\"",
"format": "prettier --ignore-path ../.gitignore --write \"(src|tests)/**/*.+(js|ts|jsx|tsx|json)\"",
"test": "jest"
},
"jest": {
"preset": "jest-expo",
"verbose": true,
"expand": true,
"transformIgnorePatterns": [
"node_modules/(?!((jest-)?react-native|@react-native(-community)?)|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg)"
],
Expand All @@ -37,8 +39,7 @@
"jsx"
],
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"App.tsx"
"src/**/*.{js,jsx,ts,tsx}"
]
},
"dependencies": {
Expand Down Expand Up @@ -102,7 +103,8 @@
"tailwindcss": "^3.3.2",
"tslib": "^2.5.0",
"typescript": "^4.9.4",
"zustand": "^4.3.7"
"zustand": "^4.3.7",
"expo-crypto": "~12.2.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
1 change: 1 addition & 0 deletions sdex-encrypted-communicator/src/Messages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// UI
export const GENERIC_AUTHORIZATION_ERROR_MSG = "Błąd autoryzacji";
export const BUTTON_ACCEPT_TEXT = "Okej";
export const BUTTON_GO_BACK_TEXT = "Powrót";
export const GENERIC_DB_MISSING_DATA_ERROR_MSG = "Brak danych w bazie.";

// Backend
Expand Down
11 changes: 6 additions & 5 deletions sdex-encrypted-communicator/src/app/(auth)/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ export default function SignIn() {

React.useEffect((): void => {
(async () => {
const actualPin = await getSecure("userPIN");
if (!actualPin) {
logger.info("Fetching user PIN from SecureStore.");
const actualPinFromDb = await getSecure("userPIN");
if (!actualPinFromDb) {
logger.info(
"PIN missing or failed to fetch from SecureStore. Authorization won't be possible.",
);
} else {
logger.info("PIN fetched from SecureStore.");
setUserActualPIN(JSON.stringify(actualPin));
} else if (typeof actualPinFromDb === "string") {
setUserActualPIN(actualPinFromDb);
logger.info("PIN successfully fetched from SecureStore.");
}
})();
}, []);
Expand Down
6 changes: 0 additions & 6 deletions sdex-encrypted-communicator/src/app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ export default function TabsLayout() {
tabBarIcon: makeIcon("chatbubbles-outline", "chatbubbles"),
}}
/>
<Tabs.Screen
name="chats/[contactId]"
options={{
href: null,
}}
/>
<Tabs.Screen
name="contacts/index"
options={{
Expand Down
2 changes: 1 addition & 1 deletion sdex-encrypted-communicator/src/app/(tabs)/chats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function ChatRooms() {
renderItem={({ item }) => (
<Link
href={{
pathname: "/chats/[contactId]",
pathname: "/chat/[contactId]",
params: { contactId: item.contactId },
}}
asChild
Expand Down

This file was deleted.

47 changes: 25 additions & 22 deletions sdex-encrypted-communicator/src/app/(tabs)/contacts/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,17 @@ import { FlatList, SafeAreaView, StyleProp, ViewStyle } from "react-native";
import { Appbar, Divider, FAB, List } from "react-native-paper";

import { useIsFocused } from "@react-navigation/native";
import { Link, useRouter } from "expo-router";
import AddContactModal from "../../../components/AddContactModal";
import { Link } from "expo-router";
import { useSqlDbSessionStore } from "../../../contexts/DbSession";
import { getContacts } from "../../../storage/DataHandlers";
import styles from "../../../Styles";
import { ContactListItem } from "../../../Types";

export default function Contacts() {
// const contacts = useContactsStore((state) => state.contacts);
// const setContacts = useContactsStore((state) => state.setContacts);
// const getContact = useContactsStore((state) => state.getContact);
// const removeContact = useContactsStore((state) => state.removeContact);
const [contacts, setContacts] = React.useState<ContactListItem[]>([]);
const [contactId, setContactId] = React.useState<number | undefined>(undefined);

const isFocused = useIsFocused();

const [addContactModalVisible, setAddContactModalVisible] = React.useState(false);
const sqlDbSession = useSqlDbSessionStore((state) => state.sqlDbSession);
const router = useRouter();

const divider = () => <Divider />;
const leftIcon = (props: { color: string; style?: StyleProp<ViewStyle> }) => (
Expand All @@ -43,9 +34,6 @@ export default function Contacts() {
}
}, [sqlDbSession, isFocused]);

const showModal = () => setAddContactModalVisible(true);
const hideModal = () => setAddContactModalVisible(false);

return (
<SafeAreaView className="flex-1">
<Appbar.Header style={styles.appBarHeader}>
Expand All @@ -59,17 +47,32 @@ export default function Contacts() {
keyExtractor={(item, index) => (item.id ? item.id.toString() : index.toString())}
ItemSeparatorComponent={divider}
renderItem={({ item }) => (
<List.Item
className="my-2"
title={`${item.name} ${item.surname}`}
left={leftIcon}
right={rightIcon}
titleNumberOfLines={1}
/>
<Link
href={{
pathname: "/contact/[contactId]",
params: { contactId: item.id },
}}
asChild
>
<List.Item
className="my-2"
title={`${item.name} ${item.surname}`}
left={leftIcon}
right={rightIcon}
titleNumberOfLines={1}
/>
</Link>
)}
/>
<FAB icon="plus" style={styles.fab} onPress={showModal} />
<AddContactModal visible={addContactModalVisible} hideModalFunction={hideModal} />
<Link
href={{
pathname: "/contact/[contactId]",
params: { contactId: -1 },
}}
asChild
>
<FAB icon="plus" style={styles.fab} />
</Link>
</SafeAreaView>
);
}
Loading

0 comments on commit f0f3fd1

Please sign in to comment.