Commit 557987e
authored
feat: implement PII encryption with AES-256-GCM and key rotation (#447)
* feat: implement PII encryption with AES-256-GCM and key rotation
- Added field-level AES-256-GCM encryption for PII fields (email, name, phoneNumber, address, etc.)
- Key management with automatic 90-day rotation via HKDF key derivation
- Blind indexing for searchable encrypted fields using HMAC-SHA256 with trigram tokenization
- PII access audit logging integrated with existing tamper-evident audit chain
- Data masking for non-production environments (email, phone, general PII)
- Compliance reporting with encryption status, key management, and access summaries
- Upgraded SecretsVault from base64 obfuscation to AES-256-GCM encryption at rest
* feat: implement batch subscription operations for bulk management
Add batch create from CSV/JSON, batch update with filtering, batch cancel with reason collection, and batch charge for manual billing runs.
- contracts/batch: Added CancelReason enum, BatchFilter struct, enhanced result types with skipped_operations tracking
- app/services/batchTransactionService.ts: Full rewrite with 4 operation types, CSV parsers, chunked processing, idempotent retry with backoff, result export (CSV/JSON), history persistence, per-item status tracking
- app/stores/batchStore.ts: Zustand store with draft management, CSV loading per operation type, execute/retry, export helpers
- app/screens/BatchOperationsScreen.tsx: Full UI with operation selector, CSV input, update params/filter modals, cancel reason picker, progress bar, per-item results with status coloring, export buttons, retry failed, history modal
- src/screens/ImportScreen.tsx: Added batch operations shortcut banner
- src/navigation: Added BatchOperations route to SettingsStack
- Updated useBatchTransactions hook and batchStore tests for new API
Edge cases handled: partial batch failure, idempotent retry of failed items, large batch memory management via chunked processing (default 50, max 200)
* feat: implement contract-level subscription tax calculation and remittance
- Add tax types to contracts/types (TaxJurisdiction, TaxExemption, TaxRemittanceReport, NexusRegion, TaxRateChangeEvent)
- Add 12 new StorageKey variants for tax state persistence
- Enhance invoice contract with full tax system:
- Multi-jurisdiction tax lookup (set_tax_jurisdiction/get_tax_jurisdiction_by_location)
- Tax exemption lifecycle (register/validate/revoke) with certificate validation
- Digital goods classification and taxability rules
- Mid-cycle tax rate change proration (calculate_prorated_tax)
- Nexus determination with economic thresholds per jurisdiction
- Tax remittance report generation and submission
- Add 10 contract test cases covering invoice generation, tax exemption, proration, nexus, and remittance
- Update frontend types with DigitalGoodsCategory, TaxRemittanceReport, NexusRegion, MidCycleTaxChange
* feat: implement subscription tax calculation and remittance system
- Add TaxType, TaxJurisdiction, TaxRateEntry, CustomerTaxStatus, DigitalGoodsClass, TaxRemittanceLineItem types
- Add new StorageKey variants: TaxRateEntry, CustomerTaxStatus, TaxRemittanceLine, DigitalGoodsClass, TaxRateChangeLogByJdx
- Fix StorageKey variant name length limits (ProxyPrevImplCount, TaxRemittanceReportByJdx)
- Enhance invoice contract with multi-jurisdiction tax lookup with fallback chain
- Add tax-exempt customer handling with certificate validation and expiry checks
- Implement mid-cycle tax rate change proration for existing subscriptions
- Add reverse-charge flagging and nexus threshold determination
- Add per-invoice/per-jurisdiction remittance line tracking
- Add 11 new contract functions and 10 comprehensive test cases
- Update subscription contract with new generate_invoice signature
- Create TaxService backend with built-in jurisdiction rates, caching, exemption validation, nexus checks, digital goods rules, and remittance report generation
- Create taxTypes.ts with full TypeScript type definitions
- Extend invoiceStore with tax state management (rates, exemptions, remittance lines, reports, mid-cycle changes)
- Add backend TaxService tests covering lookup, exemption, calculation, nexus, and reporting
- Update Invoice TypeScript types with TaxJurisdiction, CustomerTaxStatus, TaxRemittanceReport, MidCycleTaxChange and helper utilities
- Extend Invoice interface with taxJurisdiction, isTaxExempt, and reverseCharge fields
* fix: add @react-native/jest-preset dependency for jest-expo compatibility1 parent b1a6128 commit 557987e
11 files changed
Lines changed: 1359 additions & 60 deletions
File tree
- backend
- secrets
- services
- __tests__
- src/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
2 | 9 | | |
3 | 10 | | |
4 | 11 | | |
| |||
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
15 | | - | |
16 | 22 | | |
17 | | - | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | | - | |
24 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
| |||
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
51 | 63 | | |
52 | 64 | | |
53 | | - | |
54 | | - | |
| 65 | + | |
55 | 66 | | |
56 | 67 | | |
57 | | - | |
58 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
59 | 74 | | |
60 | 75 | | |
61 | | - | |
62 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
63 | 121 | | |
64 | 122 | | |
65 | 123 | | |
| |||
98 | 156 | | |
99 | 157 | | |
100 | 158 | | |
101 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
102 | 167 | | |
103 | 168 | | |
104 | 169 | | |
| |||
119 | 184 | | |
120 | 185 | | |
121 | 186 | | |
122 | | - | |
| 187 | + | |
123 | 188 | | |
124 | 189 | | |
125 | 190 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
0 commit comments