secure-redact 1.0.0 → 1.0.2
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/README.md +51 -58
- package/dist/lib.d.ts +1 -1
- package/dist/secure-redact.es.js +8623 -7028
- package/dist/secure-redact.es.js.map +1 -1
- package/dist/secure-redact.umd.js +1578 -28
- package/dist/secure-redact.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/assets/advanced.worker-DSVrF0gl.js +0 -890
- package/dist/assets/nlp.worker-u7Lr_A3c.js +0 -521
- package/dist/assets/ocr.worker-D5s6dY7M.js +0 -139
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> Client-side PII detection and redaction React component. Upload documents, automatically detect sensitive information using OCR + AI, review detections, and download redacted copies — **all without sending originals to any server**.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/secure-redact)
|
|
6
|
-
[](https://github.com/
|
|
6
|
+
[](https://github.com/johhhnnnnyyyyy/Hack-Bell/blob/main/LICENSE)
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
@@ -24,108 +24,101 @@ npm install secure-redact
|
|
|
24
24
|
|
|
25
25
|
## Quick Start
|
|
26
26
|
|
|
27
|
+
The component provides a complete document type selector out of the box. Users select their document type (Aadhaar, PAN, Health Report, etc.), choose which fields to keep visible, upload the file, and receive a redacted version.
|
|
28
|
+
|
|
27
29
|
```tsx
|
|
28
30
|
import { SecureRedact } from 'secure-redact';
|
|
29
31
|
import 'secure-redact/style.css';
|
|
30
32
|
|
|
31
33
|
function App() {
|
|
34
|
+
const handleComplete = (maskedFile, evidence) => {
|
|
35
|
+
// maskedFile: File — the redacted document ready to download/upload
|
|
36
|
+
console.log('Redacted file:', maskedFile.name, maskedFile.size);
|
|
37
|
+
|
|
38
|
+
// evidence: EvidenceLog — audit trail of detections
|
|
39
|
+
console.log('Entities detected:', evidence.detectedEntities.length);
|
|
40
|
+
|
|
41
|
+
// Download the redacted file
|
|
42
|
+
const url = URL.createObjectURL(maskedFile);
|
|
43
|
+
const a = document.createElement('a');
|
|
44
|
+
a.href = url;
|
|
45
|
+
a.download = maskedFile.name;
|
|
46
|
+
a.click();
|
|
47
|
+
};
|
|
48
|
+
|
|
32
49
|
return (
|
|
33
50
|
<SecureRedact
|
|
34
51
|
apiKey="your-gemini-api-key"
|
|
35
|
-
|
|
36
|
-
onComplete={(maskedFile, evidence) => {
|
|
37
|
-
// maskedFile: File — the redacted document ready to download/upload
|
|
38
|
-
console.log('Redacted file:', maskedFile.name, maskedFile.size);
|
|
39
|
-
|
|
40
|
-
// evidence: EvidenceLog — audit trail of detections
|
|
41
|
-
console.log('Entities detected:', evidence.detectedEntities.length);
|
|
42
|
-
}}
|
|
52
|
+
onComplete={handleComplete}
|
|
43
53
|
/>
|
|
44
54
|
);
|
|
45
55
|
}
|
|
46
56
|
```
|
|
47
57
|
|
|
58
|
+
**That's it!** The component automatically shows:
|
|
59
|
+
1. **Step 1** — Document Type selector (Aadhaar Card, PAN Card, Health Report, Income Tax Return, Invoice, Bank Statement)
|
|
60
|
+
2. **Step 2** — Field selection (choose which fields to keep visible, everything else is redacted)
|
|
61
|
+
3. **Step 3** — File upload dropzone
|
|
62
|
+
4. **Step 4** — Review modal (preview detections, toggle individual entities)
|
|
63
|
+
5. **Step 5** — Returns the redacted `File` + `EvidenceLog`
|
|
64
|
+
|
|
65
|
+
## Supported Document Types
|
|
66
|
+
|
|
67
|
+
| Document | Fields |
|
|
68
|
+
|----------|--------|
|
|
69
|
+
| 🪪 **Aadhaar Card** | Name, Address, DOB, Aadhaar Number, Phone, Gender, Photo, QR Code |
|
|
70
|
+
| 💳 **PAN Card** | Name, Father's Name, DOB, PAN Number, Photo, Signature |
|
|
71
|
+
| 🏥 **Health Report** | Patient Name, Age, DOB, Doctor, Hospital, Diagnosis, Medications, Test Results, Blood Group |
|
|
72
|
+
| 📊 **Income Tax Return** | Name, PAN, Address, Income, Tax Amount, Assessment Year, TAN, Employer |
|
|
73
|
+
| 🧾 **Invoice** | Company, Customer, Address, Invoice No, Date, Amount, GST, Line Items, Bank Details |
|
|
74
|
+
| 🏦 **Bank Statement** | Account Holder, Account No, IFSC, Address, Transactions, Balance, Bank Name, Branch, Date |
|
|
75
|
+
|
|
48
76
|
## Props
|
|
49
77
|
|
|
50
78
|
| Prop | Type | Default | Description |
|
|
51
79
|
|------|------|---------|-------------|
|
|
52
80
|
| `apiKey` | `string` | *required* | Gemini API key ([get one here](https://aistudio.google.com/apikey)) |
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
81
|
+
| `onComplete` | `(file, evidence) => void` | *required* | Called when redaction is complete |
|
|
82
|
+
| `requiredFields` | `string[]` | `[]` | PII types to KEEP visible (when not using doc type UI) |
|
|
55
83
|
| `confidenceThreshold` | `number` | `0.5` | Minimum confidence (0-1) for PII detection |
|
|
56
84
|
| `maxFileSizeMB` | `number` | `25` | Maximum file size in MB |
|
|
85
|
+
| `showDocTypeSelector` | `boolean` | `true` | Show document type picker UI |
|
|
57
86
|
| `acceptedTypes` | `string[]` | Images + PDF | Accepted MIME types |
|
|
58
|
-
| `showDocTypeSelector` | `boolean` | `false` | Show document type picker UI |
|
|
59
87
|
| `className` | `string` | — | Custom CSS class for root container |
|
|
60
88
|
|
|
61
|
-
## Available PII Types
|
|
62
|
-
|
|
63
|
-
Use these values in the `requiredFields` array:
|
|
64
|
-
|
|
65
|
-
| Type | Description |
|
|
66
|
-
|------|-------------|
|
|
67
|
-
| `NAME` | Person/organization names |
|
|
68
|
-
| `PHONE` | Phone/mobile numbers |
|
|
69
|
-
| `EMAIL` | Email addresses |
|
|
70
|
-
| `ADDRESS` | Physical addresses |
|
|
71
|
-
| `AADHAAR` | Aadhaar (UID) numbers |
|
|
72
|
-
| `PAN` | PAN card numbers |
|
|
73
|
-
| `CREDIT_CARD` | Credit/debit card numbers |
|
|
74
|
-
| `DOB` | Dates of birth |
|
|
75
|
-
| `MEDICAL` | Medical information |
|
|
76
|
-
| `ACCOUNT_NUMBER` | Bank account numbers |
|
|
77
|
-
| `IFSC` | IFSC codes |
|
|
78
|
-
| `INVOICE_NO` | Invoice numbers |
|
|
79
|
-
| `GST` | GST/GSTIN numbers |
|
|
80
|
-
|
|
81
89
|
## Examples
|
|
82
90
|
|
|
83
|
-
###
|
|
91
|
+
### Default (with document type selector)
|
|
84
92
|
|
|
85
93
|
```tsx
|
|
86
94
|
<SecureRedact
|
|
87
95
|
apiKey="your-key"
|
|
88
|
-
requiredFields={[]} // nothing kept visible
|
|
89
|
-
onComplete={(file) => downloadFile(file)}
|
|
90
|
-
/>
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Keep only name and address visible
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
<SecureRedact
|
|
97
|
-
apiKey="your-key"
|
|
98
|
-
requiredFields={['NAME', 'ADDRESS']}
|
|
99
96
|
onComplete={(file, evidence) => {
|
|
100
|
-
|
|
97
|
+
// User picks doc type → selects fields → uploads → reviews → gets redacted file
|
|
98
|
+
downloadFile(file);
|
|
101
99
|
}}
|
|
102
100
|
/>
|
|
103
101
|
```
|
|
104
102
|
|
|
105
|
-
###
|
|
103
|
+
### Without document type selector (developer controls fields)
|
|
106
104
|
|
|
107
105
|
```tsx
|
|
108
106
|
<SecureRedact
|
|
109
107
|
apiKey="your-key"
|
|
110
|
-
showDocTypeSelector={
|
|
108
|
+
showDocTypeSelector={false}
|
|
109
|
+
requiredFields={['NAME', 'DOB']} // only keep name and DOB visible
|
|
111
110
|
onComplete={(file) => uploadToServer(file)}
|
|
112
111
|
/>
|
|
113
112
|
```
|
|
114
113
|
|
|
115
|
-
###
|
|
114
|
+
### Redact everything (maximum privacy)
|
|
116
115
|
|
|
117
116
|
```tsx
|
|
118
|
-
|
|
119
|
-
import 'secure-redact/style.css';
|
|
120
|
-
|
|
121
|
-
<SecureUploader
|
|
117
|
+
<SecureRedact
|
|
122
118
|
apiKey="your-key"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const evidence = JSON.parse(evidenceJson);
|
|
127
|
-
// ...
|
|
128
|
-
}}
|
|
119
|
+
showDocTypeSelector={false}
|
|
120
|
+
requiredFields={[]} // nothing kept visible
|
|
121
|
+
onComplete={(file) => downloadFile(file)}
|
|
129
122
|
/>
|
|
130
123
|
```
|
|
131
124
|
|
package/dist/lib.d.ts
CHANGED
|
@@ -135,7 +135,7 @@ export declare interface SecureRedactProps {
|
|
|
135
135
|
* Whether to show the document type selector UI.
|
|
136
136
|
* When true, users can pick a document type and select which fields to keep.
|
|
137
137
|
* When false, only the uploader is shown and `requiredFields` prop is used directly.
|
|
138
|
-
* @default
|
|
138
|
+
* @default true
|
|
139
139
|
*/
|
|
140
140
|
showDocTypeSelector?: boolean;
|
|
141
141
|
/**
|