Summary - Security
- React Native course
- Expert
- Lesson 42/47
- 5 min
Combine obfuscation, API key and pinning to write a secure app.
Summary - Security
In this group you saw obfuscation, API key security, certificate pinning, anti-tamper and secure coding. Security is layered: obfuscation hides code, env carries keys, pinning guards traffic, anti-tamper checks the device, secure coding shrinks the attack surface.
In the last lesson you will write two integration tasks: first adds obfuscation plus API key settings to app.json, second ties an input validation function into a component. This way you see how the security layers come together.
Practice Combine security settings
Add two security settings to an app.json skeleton: "jsEngine": "hermes" and "extra": { "apiKey": "placeholder" }. Both live inside the "expo" section.
Starter code
{
"expo": {
"name": "App"
// add jsEngine and extra settings here
}
}Sample solution
{
"expo": {
"name": "App",
"jsEngine": "hermes",
"extra": {
"apiKey": "placeholder"
}
}
}Practice Tie validation into a component
Write an EmailInput component. Define a validateEmail function (with a regex). In TextInput's onChangeText validate the entered text; write the result to a valid state.
Starter code
import React, { useState } from 'react';
import { TextInput, View } from 'react-native';
function EmailInput() {
const [valid, setValid] = useState(false);
// add validateEmail function and onChangeText
return (
<View>
<TextInput onChangeText={(t) => {}} />
</View>
);
}Sample solution
import React, { useState } from 'react';
import { TextInput, View } from 'react-native';
function validateEmail(email) {
return /.+@.+\..+/.test(email);
}
function EmailInput() {
const [valid, setValid] = useState(false);
return (
<View>
<TextInput onChangeText={(t) => setValid(validateEmail(t))} />
</View>
);
}Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which one guards traffic?
certificate pinning- Jailbreak detect
- Certificate pinning Correct answer
- Obfuscation
- Minification
Explanation: Certificate pinning stops the MITM attack.
2 Match each layer to its role
| Term | Meaning |
|---|---|
obfuscation |
Hides code |
API key env |
Carries the key |
pinning |
Guards traffic |
anti-tamper |
Checks the device |