Skip to content

Commit

Permalink
React-Native examples 0.15.2 (#1030)
Browse files Browse the repository at this point in the history
* Update the example for react-native

* Update the second example for react-native
  • Loading branch information
radetsky committed Oct 6, 2023
1 parent a0df866 commit aa3ad22
Show file tree
Hide file tree
Showing 171 changed files with 12,516 additions and 13,627 deletions.
4 changes: 4 additions & 0 deletions docs/examples/react-native/RNThemisExample/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
Expand All @@ -29,32 +30,37 @@ build/
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# CocoaPods
# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
arrowParens: 'avoid',
bracketSameLine: true,
bracketSpacing: false,
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
1 change: 1 addition & 0 deletions docs/examples/react-native/RNThemisExample/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @flow strict-local
*/

import React, { useState, useEffect } from 'react';
import type { Node } from 'react';
import React, {useState, useEffect} from 'react';
import type {ReactNode} from 'react';
import {
SafeAreaView,
ScrollView,
Expand Down Expand Up @@ -51,63 +51,61 @@ import {
COMPARATOR_ERROR
} from 'react-native-themis';

type SectionProps = {
children: ReactNode;
title: string;
};

const Section = ({ children, title }): Node => {
const Section: React.FC<SectionProps> = ({ children, title }) => {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={ styles.sectionContainer }>
<View style={styles.sectionContainer}>
<Text
style={ [
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
] }>
{ title }
]}>
{title}
</Text>
<Text
style={ [
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
] }>
{ children }
]}>
{children}
</Text>
</View>
);
};

const App: () => Node = () => {
const App: React.FC = () => {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

const [privateKey, setPrivateKey] = useState('');
const [publicKey, setPublicKey] = useState('');
const [masterKey, setMasterKey] = useState('');
const [encryptedWithKey, setEncryptedWithKey] = useState('');
const [encryptedWithPassphrase, setEncryptedWithPassphrase] = useState('');
const [encryptedWithTokenProtect, setEncryptedWithTokenProtect] = useState('');
const [tokenProtect, setTokenProtect] = useState('');
const [encryptedWithContextImprint, setEncryptedWithContextImprint] = useState('');
const [signedSecureMessage, setSignedSecureMessage] = useState('');
const [encryptedSecureMessage, setEncryptedSecureMessage] = useState('');
const [privateKey, setPrivateKey] = useState<string>('');
const [publicKey, setPublicKey] = useState<string>('');
const [masterKey, setMasterKey] = useState<string>('');
const [encryptedWithKey, setEncryptedWithKey] = useState<string>('');
const [encryptedWithPassphrase, setEncryptedWithPassphrase] = useState<string>('');
const [encryptedWithTokenProtect, setEncryptedWithTokenProtect] = useState<string>('');
const [tokenProtect, setTokenProtect] = useState<string>('');
const [encryptedWithContextImprint, setEncryptedWithContextImprint] = useState<string>('');
const [signedSecureMessage, setSignedSecureMessage] = useState<string>('');
const [encryptedSecureMessage, setEncryptedSecureMessage] = useState<string>('');

const plaintext = "Hello, Themis!";
const context = "Themis context";
const passphrase = "Passphrase for Themis!";

useEffect(() => {

// Just converting incoming base64 string to UTF-8 encoded string
const cat = "0JrQvtGI0LrQsCDRjdGC0LAg0LHRi9C70LAg0LDQsdGB0L7Qu9GO0YLQvdC+INGH0LXRgNC90LDRjywg0LPQu9Cw0LTQutCw0Y8sINC60LDQuiDQv9Cw0L3RgtC10YDQsCwg0LrRgNCw0YHQuNCy0LDRjyDQuCwg0L/Qvi3QstC40LTQuNC80L7QvNGDLCDRhdC+0YDQvtGI0LjRhSDQutGA0L7QstC10LkuINCd0L4g0LXQuSDQvdC1INC/0L7QstC10LfQu9C+INCyINC20LjQt9C90LggKNGB0LrQvtGA0LXQtSDQstGB0LXQs9C+LCDQutGC0L4t0YLQviDQstGL0LPQvdCw0Lsg0LjQtyDQtNC+0LzRgykg0Lgg0L7QvdCwINGB0LDQvNCwINC/0YDQvtC80YvRiNC70Y/Qu9CwINC/0YDQvtC/0LjRgtCw0L3QuNC1Lg0K0JvQtdGC0L7QvCDQvdCwINCx0LvQuNC20LDQudGI0LjRhSDQtNCw0YfQvdGL0YUg0YPRh9Cw0YHRgtC60LDRhSwg0LAg0LfQuNC80L7QuSDQvdCwINC+0LrRgNC10YHRgtC90YvRhSDQv9C+0LzQvtC50LrQsNGFINCyINC/0L7RgdC10LvQutC1LiDQm9GO0LTQtdC5INC90LUg0LHQvtGP0LvQsNGB0YwsINC90L4g0Lgg0L3QtSDQt9Cw0LjRgdC60LjQstCw0LvQsCwg0Lgg0LIg0YDRg9C60Lgg0L3QtSDQtNCw0LLQsNC70LDRgdGMLiDQl9CwINC/0L7QvNC+0LnQutC4INGB0LLQuNGA0LXQv9C+INC00YDQsNC70LDRgdGMINCyINC+0LrRgNC10YHRgtC90YvQvNC4INC60L7RgtCw0LzQuCwg0LrQvtGC0L7RgNGL0LUg0LXQtSDRgdC40LvRjNC90L4g0YPQstCw0LbQsNC70LguINCt0LTQsNC60LDRjyDRhdCy0L7RgdGC0LDRgtCw0Y8gwqvQu9C10LTQuC3QvNCw0YTQuNGPwrsg0LIg0YfQtdGA0L3QvtC8LCDRgSDRgNC10LLQvtC70YzQstC10YDQvtC8INC30LAg0L/QvtGP0YHQvtC8LCDQutC+0YLQvtGA0LDRjyDQtNGA0LDQuiDQvdC1INC30LDRgtC10LLQsNC10YIsINC90L4g0LIg0YHQu9GD0YfQsNC1INGH0LXQs9C+INC/0YDQuNGB0YLRgNC10LvQuNGCLCDQvdC1INC80L7RgNCz0L3Rg9CyINCz0LvQsNC30L7QvC4=";
const buf = Buffer.from(cat, 'base64').toString("utf-8");
console.log("==> Cat <==:", buf);
// End of converting example

// Async Themis keyPair64 example. It resolves with asymmetric key pair anyway.
// Always return base64 encoded strings
keyPair64(KEYTYPE_EC)
Expand Down Expand Up @@ -236,7 +234,7 @@ const App: () => Node = () => {
const lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam aliquam dictum tellus, eget malesuada lectus scelerisque non. Curabitur at nibh vestibulum, sagittis felis non, convallis magna. Vestibulum fringilla a urna quis facilisis. Etiam rhoncus hendrerit diam, at elementum nisi condimentum dignissim. Nam eleifend libero accumsan pharetra cursus. Phasellus eget nulla pellentesque, elementum dui eu, malesuada mi. Quisque dolor augue, mattis ut mauris id, sollicitudin fermentum elit. Suspendisse nulla velit, tincidunt a viverra interdum, cursus vitae nunc. Proin turpis ante, consectetur nec nisl consequat, rhoncus congue risus. Sed mattis tempus mi quis hendrerit. Nullam sit amet arcu dapibus, dignissim risus nec, tempus metus. Morbi condimentum sagittis metus eu eleifend. Duis scelerisque eu tellus non porta. Duis viverra tincidunt congue.";
const lorem64 = string64(lorem);

async function proceedCompare(data64: String, serverID: String, clientID: String): Promise<Number> {
async function proceedCompare(data64: string, serverID: string, clientID: string): Promise<number> {
console.log("Before server part of comparator", serverID, data64);
const serverResult = await comparatorProceed64(serverID, data64);
console.log("Server proceeded with result:", serverResult);
Expand Down Expand Up @@ -384,8 +382,8 @@ const App: () => Node = () => {
</Text>
</Section>
</View>
</ScrollView >
</SafeAreaView >
</ScrollView>
</SafeAreaView>
);
};

Expand All @@ -407,11 +405,11 @@ const styles = StyleSheet.create({
fontWeight: '700',
},
blob: {
fontSize: 14,
fontFamily: Platform.OS === 'ios' ? 'Courier' : 'monospace',
flexWrap: 'nowrap',
flexShrink: 1,
}
fontFamily: "Courier",
backgroundColor: 'lightgray',
borderRadius: 5,
padding: 5,
},
});

export default App;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.4'
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.12'
gem 'activesupport', '~> 7.0', '<= 7.0.8'

gem 'cocoapods', '~> 1.11', '>= 1.11.2'
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.5)
CFPropertyList (3.0.6)
rexml
activesupport (6.1.4.6)
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.11.2)
cocoapods (1.13.0)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.11.2)
cocoapods-core (= 1.13.0)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.4.0, < 2.0)
cocoapods-downloader (>= 1.6.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 1.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.11.2)
activesupport (>= 5.0, < 7)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.13.0)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
Expand All @@ -45,7 +44,7 @@ GEM
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.5.1)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
Expand All @@ -54,47 +53,47 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.1.9)
concurrent-ruby (1.2.2)
escape (0.0.4)
ethon (0.15.0)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.15.5)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.10.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.1)
minitest (5.15.0)
json (2.6.3)
minitest (5.20.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.6)
rexml (3.2.5)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.4)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.21.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
zeitwerk (2.5.4)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.11, >= 1.11.2)
activesupport (~> 7.0, <= 7.0.8)
cocoapods (~> 1.12)

RUBY VERSION
ruby 2.7.4p191
ruby 3.2.2p53

BUNDLED WITH
2.2.27
2.4.10
Loading

0 comments on commit aa3ad22

Please sign in to comment.