react-native-privacy-guard-kit 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/PrivacyGuardKit.podspec +27 -0
- package/README.md +320 -0
- package/android/CMakeLists.txt +47 -0
- package/android/build.gradle +64 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/privacyguardkit/PrivacyGuardKitPackage.kt +17 -0
- package/android/src/main/java/com/privacyguardkit/Privacyguardkitmodule .kt +208 -0
- package/android/src/main/java/com/privacyguardkit/Screenshotobserver.kt +66 -0
- package/android/src/main/java/com/privacyguardkit/Secureview.kt +104 -0
- package/android/src/main/java/com/privacyguardkit/Secureviewmanager.kt +27 -0
- package/android/src/main/jni/react/renderer/components/PrivacyGuardKitViewSpec/RNSecureViewComponentDescriptor.h +25 -0
- package/ios/PrivacyGuardKit-Umbrella.h +14 -0
- package/ios/PrivacyGuardKit.m +38 -0
- package/ios/PrivacyGuardKit.swift +221 -0
- package/ios/RNSecureViewComponentView.h +16 -0
- package/ios/RNSecureViewComponentView.mm +84 -0
- package/ios/RNSecureViewManager.mm +48 -0
- package/lib/module/Hooks.js +119 -0
- package/lib/module/Hooks.js.map +1 -0
- package/lib/module/NativePrivacyGuardKit.js +12 -0
- package/lib/module/NativePrivacyGuardKit.js.map +1 -0
- package/lib/module/PrivacyGuardProvider.js +99 -0
- package/lib/module/PrivacyGuardProvider.js.map +1 -0
- package/lib/module/PrivacyGuardkitApi.js +104 -0
- package/lib/module/PrivacyGuardkitApi.js.map +1 -0
- package/lib/module/SecureView.js +24 -0
- package/lib/module/SecureView.js.map +1 -0
- package/lib/module/index.js +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/specs/RNSecureViewNativeComponent.ts +19 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Hooks.d.ts +29 -0
- package/lib/typescript/src/Hooks.d.ts.map +1 -0
- package/lib/typescript/src/NativePrivacyGuardKit.d.ts +4 -0
- package/lib/typescript/src/NativePrivacyGuardKit.d.ts.map +1 -0
- package/lib/typescript/src/PrivacyGuardProvider.d.ts +30 -0
- package/lib/typescript/src/PrivacyGuardProvider.d.ts.map +1 -0
- package/lib/typescript/src/PrivacyGuardkitApi.d.ts +45 -0
- package/lib/typescript/src/PrivacyGuardkitApi.d.ts.map +1 -0
- package/lib/typescript/src/SecureView.d.ts +10 -0
- package/lib/typescript/src/SecureView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/RNSecureViewNativeComponent.d.ts +11 -0
- package/lib/typescript/src/specs/RNSecureViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +29 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +174 -0
- package/src/Hooks.ts +138 -0
- package/src/NativePrivacyGuardKit.ts +13 -0
- package/src/PrivacyGuardProvider.tsx +134 -0
- package/src/PrivacyGuardkitApi.ts +123 -0
- package/src/SecureView.tsx +29 -0
- package/src/index.tsx +37 -0
- package/src/specs/RNSecureViewNativeComponent.ts +19 -0
- package/src/types.ts +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rushikesh Pandit
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "PrivacyGuardKit"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
s.platforms = { :ios => "13.0" }
|
|
13
|
+
s.source = { :git => package["repository"]["url"], :tag => "#{s.version}" }
|
|
14
|
+
|
|
15
|
+
# Include Swift files — PrivacyGuardKit.swift defines the main
|
|
16
|
+
# @objc(PrivacyGuardKit) class the linker needs for _OBJC_CLASS_$_PrivacyGuardKit
|
|
17
|
+
s.source_files = "ios/**/*.{swift,h,m,mm}"
|
|
18
|
+
s.public_header_files = "ios/**/*.h"
|
|
19
|
+
|
|
20
|
+
s.pod_target_xcconfig = {
|
|
21
|
+
"DEFINES_MODULE" => "YES",
|
|
22
|
+
"SWIFT_VERSION" => "5.0",
|
|
23
|
+
"CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER" => "NO",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
install_modules_dependencies(s)
|
|
27
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# react-native-privacy-guard-kit
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://img.shields.io/npm/v/react-native-privacy-guard-kit?color=crimson&style=for-the-badge" alt="npm version" />
|
|
5
|
+
<img src="https://img.shields.io/badge/Android-3DDC84?style=for-the-badge&logo=android&logoColor=white" alt="Android" />
|
|
6
|
+
<img src="https://img.shields.io/badge/iOS-000000?style=for-the-badge&logo=apple&logoColor=white" alt="iOS" />
|
|
7
|
+
<img src="https://img.shields.io/badge/New_Architecture-Ready-blue?style=for-the-badge" alt="New Architecture" />
|
|
8
|
+
<img src="https://img.shields.io/badge/16KB_Page_Size-Compatible-green?style=for-the-badge" alt="16KB Compatible" />
|
|
9
|
+
<img src="https://img.shields.io/badge/Open_Source-Forever-orange?style=for-the-badge" alt="Open Source" />
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
A production-ready, zero-dependency React Native library that protects your app's sensitive content from screenshots, screen recordings, app switcher previews, and clipboard leaks — with full hook, provider, and TypeScript support.
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Features
|
|
19
|
+
|
|
20
|
+
- **Disable Screenshots** — Prevent users or system tools from capturing your screen
|
|
21
|
+
- **Screen Recording Detection** — Detect and react to active screen recording in real time
|
|
22
|
+
- **App Switcher Protection** — Blur / cover sensitive content in the iOS & Android task switcher
|
|
23
|
+
- **Clipboard Protection** — Programmatically clear the system clipboard
|
|
24
|
+
- **Event Listeners** — Subscribe to screenshot taken, recording started, and recording stopped events
|
|
25
|
+
- **Hooks & Provider** — `usePrivacyGuard`, `useScreenRecording`, `useScreenshotListener`, and `<PrivacyGuardProvider>`
|
|
26
|
+
- **SecureView Component** — Drop-in `<View>` replacement that disables copy/paste for all children
|
|
27
|
+
- **Google 16KB Page Size Compatible** — Fully aligned with Android's new 16KB memory page size requirement mandatory from Android 15+
|
|
28
|
+
- **New Architecture Ready** — Built with React Native's new architecture (JSI / Fabric) in mind
|
|
29
|
+
- **Open Source Forever** — MIT licensed, community-driven, always free
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm install react-native-privacy-guard-kit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
or
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
yarn add react-native-privacy-guard-kit
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### iOS
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
cd ios && pod install
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Android
|
|
52
|
+
|
|
53
|
+
No extra steps required. Auto-linking handles everything.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
### Option 1 — Provider (Recommended)
|
|
60
|
+
|
|
61
|
+
Wrap your root component (or any sensitive screen) with `<PrivacyGuardProvider>`. Every child gets access to the full API via `usePrivacyGuardContext()`.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { PrivacyGuardProvider } from 'react-native-privacy-guard-kit';
|
|
65
|
+
|
|
66
|
+
export default function App() {
|
|
67
|
+
return (
|
|
68
|
+
<PrivacyGuardProvider
|
|
69
|
+
config={{
|
|
70
|
+
disableScreenCapture: true,
|
|
71
|
+
enableAppSwitcherProtection: true,
|
|
72
|
+
}}
|
|
73
|
+
onScreenshot={() => Alert.alert('Screenshot detected!')}
|
|
74
|
+
>
|
|
75
|
+
<YourApp />
|
|
76
|
+
</PrivacyGuardProvider>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Then inside any child component:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { usePrivacyGuardContext } from 'react-native-privacy-guard-kit';
|
|
85
|
+
|
|
86
|
+
function PaymentScreen() {
|
|
87
|
+
const { isRecording, clearClipboard } = usePrivacyGuardContext();
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View>
|
|
91
|
+
{isRecording && <Text>Screen recording is active</Text>}
|
|
92
|
+
<Button title="Clear clipboard" onPress={clearClipboard} />
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### Option 2 — Hooks
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import {
|
|
104
|
+
usePrivacyGuard,
|
|
105
|
+
useScreenshotListener,
|
|
106
|
+
useScreenRecording,
|
|
107
|
+
} from 'react-native-privacy-guard-kit';
|
|
108
|
+
|
|
109
|
+
function SecretScreen() {
|
|
110
|
+
// All-in-one hook
|
|
111
|
+
const { isRecording, disableScreenCapture, enableScreenCapture } = usePrivacyGuard({
|
|
112
|
+
disableScreenCapture: true,
|
|
113
|
+
enableAppSwitcherProtection: true,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Standalone screenshot listener
|
|
117
|
+
useScreenshotListener(() => {
|
|
118
|
+
console.log('User took a screenshot!');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Standalone recording state
|
|
122
|
+
const isBeingRecorded = useScreenRecording();
|
|
123
|
+
|
|
124
|
+
return <View />;
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### Option 3 — Imperative API
|
|
131
|
+
|
|
132
|
+
Full async/await API for manual control:
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import {
|
|
136
|
+
disableScreenCapture,
|
|
137
|
+
enableScreenCapture,
|
|
138
|
+
isScreenBeingRecorded,
|
|
139
|
+
enableAppSwitcherProtection,
|
|
140
|
+
disableAppSwitcherProtection,
|
|
141
|
+
clearClipboard,
|
|
142
|
+
onScreenshotTaken,
|
|
143
|
+
onScreenRecordingStarted,
|
|
144
|
+
onScreenRecordingStopped,
|
|
145
|
+
} from 'react-native-privacy-guard-kit';
|
|
146
|
+
|
|
147
|
+
// Disable capture on mount, re-enable on unmount
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
disableScreenCapture();
|
|
150
|
+
return () => enableScreenCapture();
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
153
|
+
// One-time check
|
|
154
|
+
const recording = await isScreenBeingRecorded(); // boolean
|
|
155
|
+
|
|
156
|
+
// Event listeners — each returns a cleanup function
|
|
157
|
+
const unsubscribe = onScreenshotTaken(() => {
|
|
158
|
+
console.log('Screenshot taken!');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// later...
|
|
162
|
+
unsubscribe();
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### Option 4 — SecureView (Copy/Paste Protection)
|
|
168
|
+
|
|
169
|
+
Drop-in replacement for `<View>` that disables text selection and copy/paste for all nested children, including `<Text>` and `<TextInput>`.
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import { SecureView } from 'react-native-privacy-guard-kit';
|
|
173
|
+
|
|
174
|
+
function SensitiveForm() {
|
|
175
|
+
return (
|
|
176
|
+
<SecureView disableCopyPaste>
|
|
177
|
+
<Text>Your account number: 1234-5678-9012</Text>
|
|
178
|
+
<TextInput
|
|
179
|
+
value={secretToken}
|
|
180
|
+
placeholder="Secret token (cannot be copied)"
|
|
181
|
+
/>
|
|
182
|
+
</SecureView>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 📖 API Reference
|
|
190
|
+
|
|
191
|
+
### `<PrivacyGuardProvider>`
|
|
192
|
+
|
|
193
|
+
| Prop | Type | Default | Description |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| `config` | `PrivacyGuardKitConfig` | `{}` | Feature flags applied on mount |
|
|
196
|
+
| `onScreenshot` | `() => void` | — | Fired every time a screenshot is taken |
|
|
197
|
+
| `children` | `ReactNode` | — | Your app tree |
|
|
198
|
+
|
|
199
|
+
**`PrivacyGuardKitConfig`**
|
|
200
|
+
|
|
201
|
+
| Key | Type | Description |
|
|
202
|
+
|---|---|---|
|
|
203
|
+
| `disableScreenCapture` | `boolean` | Disable screenshots + recording blur on mount |
|
|
204
|
+
| `enableAppSwitcherProtection` | `boolean` | Show blank overlay in task switcher |
|
|
205
|
+
| `disableCopyPaste` | `boolean` | Used with `<SecureView>` |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
### Hooks
|
|
210
|
+
|
|
211
|
+
#### `usePrivacyGuard(config?)`
|
|
212
|
+
|
|
213
|
+
All-in-one hook. Returns:
|
|
214
|
+
|
|
215
|
+
| Return value | Type | Description |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| `isScreenCaptureDisabled` | `boolean` | Current capture disabled state |
|
|
218
|
+
| `isRecording` | `boolean` | Whether screen is being recorded right now |
|
|
219
|
+
| `disableScreenCapture` | `() => Promise<void>` | Disable screenshots |
|
|
220
|
+
| `enableScreenCapture` | `() => Promise<void>` | Re-enable screenshots |
|
|
221
|
+
| `enableAppSwitcherProtection` | `() => Promise<void>` | Enable switcher overlay |
|
|
222
|
+
| `disableAppSwitcherProtection` | `() => Promise<void>` | Disable switcher overlay |
|
|
223
|
+
| `clearClipboard` | `() => Promise<void>` | Wipe clipboard contents |
|
|
224
|
+
|
|
225
|
+
#### `useScreenshotListener(callback)`
|
|
226
|
+
|
|
227
|
+
Subscribes to screenshot events. Automatically starts and stops the native observer.
|
|
228
|
+
|
|
229
|
+
#### `useScreenRecording()`
|
|
230
|
+
|
|
231
|
+
Returns a reactive `boolean` that is `true` whenever the screen is being recorded or mirrored.
|
|
232
|
+
|
|
233
|
+
#### `usePrivacyGuardContext()`
|
|
234
|
+
|
|
235
|
+
Must be used inside `<PrivacyGuardProvider>`. Returns the same shape as `usePrivacyGuard`.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
### Imperative Functions
|
|
240
|
+
|
|
241
|
+
| Function | Returns | Description |
|
|
242
|
+
|---|---|---|
|
|
243
|
+
| `disableScreenCapture()` | `Promise<void>` | Block screenshots and recording preview |
|
|
244
|
+
| `enableScreenCapture()` | `Promise<void>` | Unblock screenshots |
|
|
245
|
+
| `isScreenCaptureDisabled()` | `Promise<boolean>` | Check current state |
|
|
246
|
+
| `isScreenBeingRecorded()` | `Promise<boolean>` | Check if recording is active |
|
|
247
|
+
| `enableAppSwitcherProtection()` | `Promise<void>` | Show blank overlay in task switcher |
|
|
248
|
+
| `disableAppSwitcherProtection()` | `Promise<void>` | Remove the overlay |
|
|
249
|
+
| `clearClipboard()` | `Promise<void>` | Wipe the system clipboard |
|
|
250
|
+
| `onScreenshotTaken(cb)` | `() => void` | Subscribe — returns unsubscribe fn |
|
|
251
|
+
| `onScreenRecordingStarted(cb)` | `() => void` | Subscribe — returns unsubscribe fn |
|
|
252
|
+
| `onScreenRecordingStopped(cb)` | `() => void` | Subscribe — returns unsubscribe fn |
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
### `<SecureView>`
|
|
257
|
+
|
|
258
|
+
| Prop | Type | Default | Description |
|
|
259
|
+
|---|---|---|---|
|
|
260
|
+
| `disableCopyPaste` | `boolean` | `true` | Disables text selection and copy/paste for all children |
|
|
261
|
+
| `style` | `StyleProp<ViewStyle>` | — | Standard view styles |
|
|
262
|
+
| `children` | `ReactNode` | — | Any React Native content |
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## How It Works
|
|
267
|
+
|
|
268
|
+
### Android
|
|
269
|
+
- Uses `WindowManager.LayoutParams.FLAG_SECURE` to block screenshots, screen recording previews, and app switcher thumbnails in a single flag.
|
|
270
|
+
- Screenshot detection is powered by a `ContentObserver` watching `MediaStore.Images.Media` for new entries in the `Screenshots` folder.
|
|
271
|
+
- Copy/paste is blocked at the `View` level by overriding `ActionMode.Callback` on all `TextView` and `EditText` descendants within `SecureView`.
|
|
272
|
+
|
|
273
|
+
### iOS
|
|
274
|
+
- Screenshot and screen recording blur is achieved by embedding a `UITextField` with `isSecureTextEntry = true` into the window — a well-known and App Store-compliant technique that causes iOS to automatically blur any captured content.
|
|
275
|
+
- App switcher protection uses `UIApplication.willResignActiveNotification` to place a full-screen blank overlay before the system grabs the snapshot.
|
|
276
|
+
- Screenshot detection uses `UIApplication.userDidTakeScreenshotNotification`.
|
|
277
|
+
- Screen recording detection uses `UIScreen.capturedDidChangeNotification` and `UIScreen.main.isCaptured`.
|
|
278
|
+
- Copy/paste is blocked at the `UIView` level by overriding `canPerformAction(_:withSender:)`.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Google 16KB Page Size Compatible
|
|
283
|
+
|
|
284
|
+
Starting with **Android 15**, Google requires all apps and native libraries to support 16KB memory page alignment. `react-native-privacy-guard-kit` is fully compliant — no native `.so` files with non-standard alignment, no legacy memory assumptions. Your app stays on the Play Store without modification.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## New Architecture Support
|
|
289
|
+
|
|
290
|
+
This library is built with React Native's **New Architecture** in mind — compatible with the JSI bridge and Fabric renderer. If you have `newArchEnabled=true` in your project, everything works out of the box.
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## Open Source Forever
|
|
295
|
+
|
|
296
|
+
This project is and will always remain **MIT licensed**. No paywalls, no premium tiers, no license keys. Privacy is a right, not a feature.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Contributing
|
|
301
|
+
|
|
302
|
+
Contributions are what make the open source community such an amazing place. **Pull Requests are always welcome!**
|
|
303
|
+
|
|
304
|
+
1. Fork the repository
|
|
305
|
+
2. Create your feature branch (`git checkout -b feat/amazing-feature`)
|
|
306
|
+
3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
|
|
307
|
+
4. Push to the branch (`git push origin feat/amazing-feature`)
|
|
308
|
+
5. Open a Pull Request
|
|
309
|
+
|
|
310
|
+
Found a bug or have a feature request? **[File an issue on GitHub](https://github.com/rushikeshpandit/react-native-privacy-guard-kit/issues)** — we respond fast.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## License
|
|
315
|
+
|
|
316
|
+
MIT © [Rushikesh Pandit](https://github.com/rushikeshpandit)
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
<p align="center">Made with ❤️ in India for the React Native community</p>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# android/CMakeLists.txt
|
|
2
|
+
#
|
|
3
|
+
# This file is required for New Architecture.
|
|
4
|
+
# It creates the shared library target that autolinking.cpp links against,
|
|
5
|
+
# and — critically — exposes the codegen-generated headers as PUBLIC
|
|
6
|
+
# so the compiler can resolve RNSecureViewComponentDescriptor when
|
|
7
|
+
# compiling autolinking.cpp in the example app.
|
|
8
|
+
|
|
9
|
+
cmake_minimum_required(VERSION 3.13)
|
|
10
|
+
project(PrivacyGuardKit)
|
|
11
|
+
|
|
12
|
+
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
13
|
+
|
|
14
|
+
# The codegen output directory — set by the react gradle plugin
|
|
15
|
+
set(CODEGEN_DIR
|
|
16
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/build/generated/source/codegen"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Glob all generated .cpp files
|
|
20
|
+
file(GLOB_RECURSE CODEGEN_SRCS
|
|
21
|
+
"${CODEGEN_DIR}/jni/*.cpp"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
# This target name MUST be: react_codegen_<libraryName>
|
|
25
|
+
# where libraryName matches react { libraryName } in build.gradle
|
|
26
|
+
# and codegenConfig.name in package.json.
|
|
27
|
+
# autolinking finds and links this target by exactly this name.
|
|
28
|
+
add_library(
|
|
29
|
+
react_codegen_PrivacyGuardKitViewSpec
|
|
30
|
+
SHARED
|
|
31
|
+
${CODEGEN_SRCS}
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
# PUBLIC include dirs so autolinking.cpp (in the app module)
|
|
35
|
+
# can #include <react/renderer/components/PrivacyGuardKitViewSpec/ComponentDescriptors.h>
|
|
36
|
+
target_include_directories(
|
|
37
|
+
react_codegen_PrivacyGuardKitViewSpec
|
|
38
|
+
PUBLIC
|
|
39
|
+
"${CODEGEN_DIR}/jni"
|
|
40
|
+
"${CODEGEN_DIR}/jni/react/renderer/components/PrivacyGuardKitViewSpec"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
target_link_libraries(
|
|
44
|
+
react_codegen_PrivacyGuardKitViewSpec
|
|
45
|
+
ReactAndroid::jsi
|
|
46
|
+
ReactAndroid::reactnative
|
|
47
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// android/build.gradle
|
|
2
|
+
|
|
3
|
+
buildscript {
|
|
4
|
+
repositories {
|
|
5
|
+
google()
|
|
6
|
+
mavenCentral()
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
def isNewArchitectureEnabled() {
|
|
11
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
apply plugin: "com.android.library"
|
|
15
|
+
apply plugin: "org.jetbrains.kotlin.android"
|
|
16
|
+
|
|
17
|
+
// The react plugin MUST be applied for codegen to run.
|
|
18
|
+
// It reads codegenConfig from package.json and generates
|
|
19
|
+
// the C++ files that autolinking.cpp depends on.
|
|
20
|
+
apply plugin: "com.facebook.react"
|
|
21
|
+
|
|
22
|
+
android {
|
|
23
|
+
compileSdkVersion 35
|
|
24
|
+
namespace "com.privacyguardkit"
|
|
25
|
+
|
|
26
|
+
defaultConfig {
|
|
27
|
+
minSdkVersion 24
|
|
28
|
+
targetSdkVersion 35
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
compileOptions {
|
|
32
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
33
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
kotlinOptions {
|
|
37
|
+
jvmTarget = "17"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
sourceSets {
|
|
41
|
+
main {
|
|
42
|
+
java.srcDirs = ["src/main/java", "src/main/kotlin"]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// CRITICAL: This react block tells the codegen plugin:
|
|
48
|
+
// - WHERE to find JS spec files (jsRootDir)
|
|
49
|
+
// - WHAT to name the generated C++ library (libraryName)
|
|
50
|
+
// This MUST match codegenConfig.name in package.json
|
|
51
|
+
react {
|
|
52
|
+
jsRootDir = file("../src/specs")
|
|
53
|
+
libraryName = "PrivacyGuardKitViewSpec"
|
|
54
|
+
codegenJavaPackageName = "com.privacyguardkit"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
repositories {
|
|
58
|
+
mavenCentral()
|
|
59
|
+
google()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
dependencies {
|
|
63
|
+
implementation "com.facebook.react:react-android"
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package com.privacyguardkit
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
|
|
8
|
+
class PrivacyGuardKitPackage : ReactPackage {
|
|
9
|
+
|
|
10
|
+
override fun createNativeModules(
|
|
11
|
+
reactContext: ReactApplicationContext
|
|
12
|
+
): List<NativeModule> = listOf(PrivacyGuardKitModule(reactContext))
|
|
13
|
+
|
|
14
|
+
override fun createViewManagers(
|
|
15
|
+
reactContext: ReactApplicationContext
|
|
16
|
+
): List<ViewManager<*, *>> = listOf(SecureViewManager())
|
|
17
|
+
}
|