@katlux/toolkit 0.1.1-alpha.146 → 0.1.1-alpha.148
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 +32 -22
- package/bin/ai-init.mjs +71 -13
- package/bin/ai-tokens/adapters/antigravityAdapter.mjs +22 -0
- package/bin/ai-tokens/adapters/claudeCodeAdapter.mjs +192 -0
- package/bin/ai-tokens/adapters/codexAdapter.mjs +176 -0
- package/bin/ai-tokens/adapters/cursorAdapter.mjs +202 -0
- package/bin/ai-tokens/adapters/index.mjs +30 -0
- package/bin/ai-tokens/cliViews.mjs +301 -0
- package/bin/ai-tokens/formatAndDates.mjs +89 -0
- package/bin/ai-tokens/reportGenerator.mjs +232 -0
- package/bin/ai-tokens/transcriptParser.mjs +299 -0
- package/bin/ai-tokens.mjs +38 -1030
- package/bin/cli.mjs +14 -10
- package/bin/preset-contracts.json +66 -10
- package/dist/compiled/composables/locales/asianAndPacific.mjs +296 -0
- package/dist/compiled/composables/locales/northernAndEasternEuropean.mjs +342 -0
- package/dist/compiled/composables/locales/westernEuropean.mjs +268 -0
- package/dist/compiled/composables/locales.mjs +28 -895
- package/dist/compiled/composables/useDataProvider.mjs +3 -1
- package/dist/compiled/composables/useKatluxForm.mjs +7 -7
- package/dist/compiled/composables/usePresetComponent.mjs +2 -0
- package/dist/compiled/composables/useRequestQueue.mjs +3 -1
- package/dist/compiled/composables/useVirtualDataset.mjs +322 -354
- package/dist/compiled/composables/useVirtualScroll.mjs +69 -62
- package/dist/compiled/composables/virtualDataset/cacheStateHelpers.mjs +76 -0
- package/dist/compiled/composables/virtualDataset/keyboardNavHelpers.mjs +60 -0
- package/dist/compiled/composables/virtualDataset/treeSelectionHelpers.mjs +103 -0
- package/dist/compiled/composables/virtualDataset/types.mjs +0 -0
- package/dist/compiled/utils/deprecation.mjs +44 -0
- package/dist/compiled/utils/dom.mjs +124 -0
- package/dist/module.cjs +0 -5
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -6
- package/dist/runtime/app.config.d.ts +3 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.d.ts +8 -0
- package/dist/runtime/components/KBulkActions/KBulkActions.logic.js +21 -55
- package/dist/runtime/components/KButton/KButton.global.d.vue.ts +1 -1
- package/dist/runtime/components/KButton/KButton.global.vue.d.ts +1 -1
- package/dist/runtime/components/KButton/KButton.logic.d.ts +1 -1
- package/dist/runtime/components/KCalendar/KCalendar.global.d.vue.ts +4 -4
- package/dist/runtime/components/KCalendar/KCalendar.global.vue.d.ts +4 -4
- package/dist/runtime/components/KCalendar/KCalendar.logic.js +8 -4
- package/dist/runtime/components/KCalendar/KCalendarMonth.global.vue +4 -0
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.d.ts +2 -0
- package/dist/runtime/components/KCalendar/KCalendarMonth.logic.js +41 -26
- package/dist/runtime/components/KCalendar/recurringUtils.js +6 -5
- package/dist/runtime/components/KCheckbox/KCheckbox.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCheckbox/KCheckbox.global.vue.d.ts +1 -1
- package/dist/runtime/components/KCombobox/KCombobox.global.d.vue.ts +17 -2
- package/dist/runtime/components/KCombobox/KCombobox.global.vue +9 -4
- package/dist/runtime/components/KCombobox/KCombobox.global.vue.d.ts +17 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.d.ts +10 -2
- package/dist/runtime/components/KCombobox/KCombobox.logic.js +32 -13
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.d.vue.ts +1 -1
- package/dist/runtime/components/KCompositeInput/KCompositeInput.global.vue.d.ts +1 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.d.vue.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue +4 -1
- package/dist/runtime/components/KContextMenu/KContextMenu.global.vue.d.ts +3 -3
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.d.ts +24 -4
- package/dist/runtime/components/KContextMenu/KContextMenu.logic.js +43 -27
- package/dist/runtime/components/KDatatable/KDataIterator.global.d.vue.ts +24 -1
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue +19 -7
- package/dist/runtime/components/KDatatable/KDataIterator.global.vue.d.ts +24 -1
- package/dist/runtime/components/KDatatable/KDataIterator.logic.d.ts +20 -0
- package/dist/runtime/components/KDatatable/KDataIterator.logic.js +54 -14
- package/dist/runtime/components/KDatatable/KDatatable.global.d.vue.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.global.vue.d.ts +1 -1
- package/dist/runtime/components/KDatatable/KDatatable.logic.js +6 -5
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +6 -4
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue +45 -26
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +6 -4
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.d.ts +2 -0
- package/dist/runtime/components/KDatePicker/KDatePicker.logic.js +66 -20
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +3 -3
- package/dist/runtime/components/KDropdown/KDropdown.global.d.vue.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.global.vue.d.ts +4 -4
- package/dist/runtime/components/KDropdown/KDropdown.logic.d.ts +3 -2
- package/dist/runtime/components/KDropdown/KDropdown.logic.js +14 -13
- package/dist/runtime/components/KGantt/KGantt.global.d.vue.ts +3 -1
- package/dist/runtime/components/KGantt/KGantt.global.vue +7 -1
- package/dist/runtime/components/KGantt/KGantt.global.vue.d.ts +3 -1
- package/dist/runtime/components/KGrid/KGrid.global.d.vue.ts +1 -1
- package/dist/runtime/components/KGrid/KGrid.global.vue.d.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.d.vue.ts +1 -1
- package/dist/runtime/components/KHourPicker/KHourPicker.global.vue.d.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.d.vue.ts +1 -1
- package/dist/runtime/components/KIcon/KIcon.global.vue.d.ts +1 -1
- package/dist/runtime/components/KLayout/KLayout.global.d.vue.ts +4 -1
- package/dist/runtime/components/KLayout/KLayout.global.vue +4 -1
- package/dist/runtime/components/KLayout/KLayout.global.vue.d.ts +4 -1
- package/dist/runtime/components/KLoader/KLoader.global.d.vue.ts +9 -0
- package/dist/runtime/components/KLoader/KLoader.global.vue +1 -0
- package/dist/runtime/components/KLoader/KLoader.global.vue.d.ts +9 -0
- package/dist/runtime/components/KLoader/KLoader.logic.d.ts +5 -0
- package/dist/runtime/components/KLoader/KLoader.logic.js +4 -0
- package/dist/runtime/components/KMaskTextbox/KMaskTextbox.logic.js +30 -7
- package/dist/runtime/components/KMultiTabs/KMultiTabs.logic.d.ts +1 -0
- package/dist/runtime/components/KMultiTabs/MultiTabs.global.vue +6 -4
- package/dist/runtime/components/KPagination/KPagination.logic.d.ts +1 -1
- package/dist/runtime/components/KPagination/KPagination.logic.js +17 -9
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KRangeSlider/KRangeSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.d.vue.ts +1 -1
- package/dist/runtime/components/KSlider/KSlider.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTabs/KTabs.logic.js +33 -11
- package/dist/runtime/components/KTextarea/KTextarea.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTextarea/KTextarea.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.d.vue.ts +12 -1
- package/dist/runtime/components/KTextbox/KTextbox.global.vue +8 -2
- package/dist/runtime/components/KTextbox/KTextbox.global.vue.d.ts +12 -1
- package/dist/runtime/components/KTextbox/KTextbox.logic.d.ts +5 -0
- package/dist/runtime/components/KTextbox/KTextbox.logic.js +4 -0
- package/dist/runtime/components/KTooltip/KTooltip.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTooltip/KTooltip.logic.d.ts +11 -2
- package/dist/runtime/components/KTooltip/KTooltip.logic.js +7 -5
- package/dist/runtime/components/KTree/KTree.global.d.vue.ts +1 -1
- package/dist/runtime/components/KTree/KTree.global.vue.d.ts +1 -1
- package/dist/runtime/components/KTree/KTree.logic.js +21 -1
- package/dist/runtime/components/KTreePicker/KTreePicker.global.d.vue.ts +8 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue +4 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.global.vue.d.ts +8 -4
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.d.ts +3 -2
- package/dist/runtime/components/KTreePicker/KTreePicker.logic.js +10 -1
- package/dist/runtime/components/KTreeView/KTreeView.global.d.vue.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.global.vue.d.ts +3 -3
- package/dist/runtime/components/KTreeView/KTreeView.logic.d.ts +1 -1
- package/dist/runtime/components/KTreeView/KTreeView.logic.js +36 -12
- package/dist/runtime/composables/locales/asianAndPacific.d.ts +11 -0
- package/dist/runtime/composables/locales/asianAndPacific.js +296 -0
- package/dist/runtime/composables/locales/northernAndEasternEuropean.d.ts +12 -0
- package/dist/runtime/composables/locales/northernAndEasternEuropean.js +342 -0
- package/dist/runtime/composables/locales/westernEuropean.d.ts +10 -0
- package/dist/runtime/composables/locales/westernEuropean.js +268 -0
- package/dist/runtime/composables/locales.d.ts +4 -24
- package/dist/runtime/composables/locales.js +28 -895
- package/dist/runtime/composables/useDataProvider.js +3 -1
- package/dist/runtime/composables/useKatluxForm.js +7 -7
- package/dist/runtime/composables/usePresetComponent.js +2 -0
- package/dist/runtime/composables/useRequestQueue.d.ts +2 -0
- package/dist/runtime/composables/useRequestQueue.js +3 -1
- package/dist/runtime/composables/useVirtualDataset.d.ts +6 -118
- package/dist/runtime/composables/useVirtualDataset.js +322 -354
- package/dist/runtime/composables/useVirtualScroll.d.ts +9 -9
- package/dist/runtime/composables/useVirtualScroll.js +69 -62
- package/dist/runtime/composables/virtualDataset/cacheStateHelpers.d.ts +49 -0
- package/dist/runtime/composables/virtualDataset/cacheStateHelpers.js +76 -0
- package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.d.ts +26 -0
- package/dist/runtime/composables/virtualDataset/keyboardNavHelpers.js +60 -0
- package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.d.ts +24 -0
- package/dist/runtime/composables/virtualDataset/treeSelectionHelpers.js +103 -0
- package/dist/runtime/composables/virtualDataset/types.d.ts +113 -0
- package/dist/runtime/composables/virtualDataset/types.js +0 -0
- package/dist/runtime/directives/clickOutside.d.ts +1 -1
- package/dist/runtime/directives/clickOutside.js +41 -13
- package/dist/runtime/plugins/nuxtCompatPlugin.d.ts +2 -1
- package/dist/runtime/plugins/nuxtCompatPlugin.js +7 -0
- package/dist/runtime/plugins/toastPlugin.client.js +2 -2
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue +24 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarMonth.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KCalendar/KCalendarWeek.vue +6 -5
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue +27 -17
- package/dist/runtime/presets/default/components/KCombobox/KCombobox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue +10 -10
- package/dist/runtime/presets/default/components/KCombobox/KComboboxList.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.d.vue.ts +2 -0
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue +60 -21
- package/dist/runtime/presets/default/components/KContextMenu/KContextMenu.vue.d.ts +2 -0
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.d.vue.ts +12 -1
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue +109 -15
- package/dist/runtime/presets/default/components/KDataIterator/KDataIterator.vue.d.ts +12 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue +14 -0
- package/dist/runtime/presets/default/components/KDatatable/KDatatable.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.d.vue.ts +5 -2
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue +15 -12
- package/dist/runtime/presets/default/components/KDropdown/KDropdown.vue.d.ts +5 -2
- package/dist/runtime/presets/default/components/KGantt/KGantt.d.vue.ts +10 -0
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue +23 -69
- package/dist/runtime/presets/default/components/KGantt/KGantt.vue.d.ts +10 -0
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.d.vue.ts +6 -2
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue +22 -8
- package/dist/runtime/presets/default/components/KGantt/KGanttTimeline.vue.d.ts +6 -2
- package/dist/runtime/presets/default/components/KLayout/KLayout.vue +2 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue +13 -2
- package/dist/runtime/presets/default/components/KLoader/KLoader.vue.d.ts +1 -0
- package/dist/runtime/presets/default/components/KMaskTextbox/KMaskTextbox.vue +1 -94
- package/dist/runtime/presets/default/components/KMultiTabs/KMultiTabs.vue +69 -4
- package/dist/runtime/presets/default/components/KRangeSlider/KRangeSlider.vue +18 -46
- package/dist/runtime/presets/default/components/KSlider/KSlider.vue +11 -23
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.d.vue.ts +4 -1
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue +24 -8
- package/dist/runtime/presets/default/components/KTextbox/KTextbox.vue.d.ts +4 -1
- package/dist/runtime/presets/default/components/KTree/KTree.d.vue.ts +1 -1
- package/dist/runtime/presets/default/components/KTree/KTree.vue +51 -80
- package/dist/runtime/presets/default/components/KTree/KTree.vue.d.ts +1 -1
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.d.vue.ts +1 -0
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue +12 -2
- package/dist/runtime/presets/default/components/KTree/KTreeNodeItem.vue.d.ts +1 -0
- package/dist/runtime/server/middleware/session.js +7 -0
- package/dist/runtime/utils/deprecation.d.ts +14 -0
- package/dist/runtime/utils/deprecation.js +44 -0
- package/dist/runtime/utils/dom.d.ts +31 -0
- package/dist/runtime/utils/dom.js +124 -0
- package/dist/skills/KATLUX_INDEX.md +15 -19
- package/dist/skills/katlux-components/components/KBulkActions.md +1 -1
- package/dist/skills/katlux-components/components/KDataIterator.md +5 -0
- package/dist/skills/katlux-components/components/KLayout.md +4 -0
- package/dist/skills/katlux-components/components/KLoader.md +3 -0
- package/dist/skills/katlux-components/components/KTextbox.md +1 -0
- package/dist/skills/katlux-config/SKILL.md +15 -7
- package/dist/skills/katlux-presets/SKILL.md +42 -2
- package/dist/skills/katlux-providers/SKILL.md +12 -0
- package/dist/skills/katlux-providers/providers/ADataProvider.md +1 -0
- package/dist/skills/katlux-providers/providers/CAPITreeServerDataProvider.md +13 -0
- package/dist/skills/katlux-providers/providers/RequestProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +5 -2
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +5 -2
- package/dist/skills/katlux-providers/providers/encryption-searchable.md +150 -27
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +4 -1
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +12 -6
- package/dist/skills/katlux-providers/providers/encryption.md +1 -1
- package/package.json +3 -3
|
@@ -50,12 +50,14 @@ Katlux solves privacy-preserving queries through a decoupled, multi-tiered searc
|
|
|
50
50
|
- **Security Warning**:
|
|
51
51
|
> [!WARNING]
|
|
52
52
|
> Do not enable trigrams on confidential tokens, passwords, or short secrets. Substring queries $< 3$ characters throw `ERR_TRIGRAM_QUERY_TOO_SHORT` to enforce vocabulary integrity.
|
|
53
|
-
3. **`rangeBuckets` (`_bucket`) [Toggle 3 - Opt-In]**:
|
|
53
|
+
3. **`rangeBuckets` (`_bucket`) [Toggle 3 - Opt-In Deterministic Shadow-Bucket Range Index]**:
|
|
54
54
|
- **Enables**: Range operators (`<`, `<=`, `>`, `>=`, `between`) and coarse bucket sorting.
|
|
55
|
-
- **Controlled Leak**:
|
|
56
|
-
- **
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
- **Controlled Leak**: **Not IND-CPA / Not Zero-Leakage.** Deterministic bucket tokens reveal record value frequency distributions, bucket ordering relations, and distribution profiles (coarse Order-Preserving Encryption equivalence) in companion persistence columns.
|
|
56
|
+
- **Sensitive-Field Block & Per-Class Policy (`ERR_RANGE_BUCKET_SENSITIVE_FIELD`, `ERR_BUCKET_STEP_TOO_NARROW`)**: Fields in `SENSITIVE_RANGE_BUCKET_FIELDS` (`salary`, `income`, `compensation`, `netWorth`, `creditScore`, `ssn`, `age`, `birthDate`, `dateOfBirth`, `dob`) throw `ERR_RANGE_BUCKET_SENSITIVE_FIELD` by default unless `allowSensitiveBucket: true` is explicitly configured. Even with `allowSensitiveBucket: true`, `RANGE_BUCKET_POLICY` (`rangeBucketPolicy`) enforces per-class minimum floors (`10,000` for financial, `1,000,000` for `ssn`, `100` for `creditScore`, `10` for `age`, `'year'`/`'quarter'` for sensitive dates; `DEFAULT_MIN_BUCKET_STEP = 100` for general numeric fields) unless `allowNarrowStep: true` / `allowNarrowGranularity: true` is passed.
|
|
57
|
+
- **Sound-or-Throw Open-Ended Range Contract (`ERR_BUCKET_RANGE_UNBOUNDED`)**: Open-ended range queries (`>`, `>=`, `<`, `<=`) and bucket-universe negations (`!=`, `nin`) on `stepped` or `date` buckets require either `knownBuckets` or explicit domain bounds (`min`/`floor`, `max`/`ceiling`, `minDate`, `maxDate`), throwing `ERR_BUCKET_RANGE_UNBOUNDED` otherwise (no silent truncation).
|
|
58
|
+
- **Security Warning ("Do Not Use" Sensitive Field Guidance)**:
|
|
59
|
+
> [!CAUTION]
|
|
60
|
+
> **DO NOT USE deterministic range buckets on high-sensitivity personal data** (`salary`, `age`, `birthDate`, `dob`, `creditScore`, `income`, `ssn`) unless explicitly authorized by compliance (`allowSensitiveBucket: true`) — distribution profiling and order inference attacks apply. Prefer keeping these columns as unindexed **AES-256-GCM** envelope ciphertext (filtered client-side after decryption), or restrict opt-in usage to broad tier bands (`$25,000+` salary bands) and `'year'`/`'quarter'` date granularity.
|
|
59
61
|
4. **`decryptedCache` [Toggle 4 - Opt-In Client Memory]**:
|
|
60
62
|
- **Enables**: Re-rendering and navigating back and forth across previously loaded pages without re-running CPU-intensive WebCrypto AES decryption.
|
|
61
63
|
- **Controlled Leak**: Decrypted rows are retained in client JavaScript memory (`WeakMap`/RAM) until page unmount.
|
|
@@ -95,7 +97,7 @@ Selecting an appropriate cryptographic representation for application fields req
|
|
|
95
97
|
| **Standard AES-256-GCM Envelope Encryption** | Highly sensitive PII, passwords, private keys, medical notes, credit card CVVs, rich text payloads (e.g. `medical_notes`, `api_secret`, `cvv`) | High or Low | None (direct ciphertext storage only; decrypted in client memory or authorized application layer) | Zero index leakage. Randomized IV/nonce ensures identical plaintexts yield completely different ciphertexts. Immune to frequency analysis. | **Gold standard for confidential data**. Use whenever fields do not require server-side filtering, searching, or indexing. |
|
|
96
98
|
| **Blind Index Equality Token (HMAC-SHA256)** | High-entropy unique / semi-unique identifiers: `email`, `ssn`, `tax_id`, `phone_number`, `national_id`, `uuid` | **High Entropy Only** | Exact match (`==`, `!=`, `IN`, `NOT IN`) via B-Tree index on `*_bidx` column | Deterministic token preserves equality and frequency distributions. Duplicates and recurring values are observable. | **Use strictly for exact lookups of high-entropy identifiers**. Always use a dedicated HMAC key separated from the DEK. Never apply to low-cardinality fields. |
|
|
97
99
|
| **Trigram Substring Search** | Long, high-entropy textual strings requiring substring/contains queries: `full_name`, `address_line`, `company_name` | **High to Medium Entropy** | Substring / Contains search via GIN inverted index (`@>` array containment) on `*_trigrams` | Leaks approximate string length and character co-occurrence frequencies. | **Use with caution on high-entropy text**. Enforce 3+ character minimum query length in client UI. Do not apply to small discrete enum sets. |
|
|
98
|
-
| **Shadow
|
|
100
|
+
| **Deterministic Shadow-Bucket Range Index (`RFC-001` / `TASK-031` / `DEBT-042` / `BUG-093`)** | Coarse dates (`created_at` by year/quarter), non-PII amounts/counters, or compliance-approved broad bands | Low to Medium | Range queries (`>`, `<`, `>=`, `<=`, `BETWEEN`) on discretized bucket keys | **Not zero-leakage.** Reveals bucket membership frequency, bucket order relations, and value distribution profiles (coarse OPE-equivalent leakage). | **Prohibited by default on high-sensitivity PII** (`ERR_RANGE_BUCKET_SENSITIVE_FIELD` on `salary`, `age`, `birthDate`, `dob`, `creditScore`, `ssn`). Leave sensitive attributes unindexed (`AES-256-GCM`) or require explicit `allowSensitiveBucket: true` + per-class floors; supply `knownBuckets` or domain bounds (`min`/`max`, `minDate`/`maxDate`) for open-ended queries (`ERR_BUCKET_RANGE_UNBOUNDED`). |
|
|
99
101
|
|
|
100
102
|
---
|
|
101
103
|
|
|
@@ -118,7 +120,7 @@ const blindIndexKeyring = {
|
|
|
118
120
|
const filters: IDataFilter[] = [
|
|
119
121
|
{ operator: EDataFilterOperator.Equal, field: { email: 'alice@securesuite.io' }, active: true },
|
|
120
122
|
{ operator: 'contains' as any, field: { name: 'Elena' }, active: true },
|
|
121
|
-
{ operator: EDataFilterOperator.GreaterThanOrEqual, field: {
|
|
123
|
+
{ operator: EDataFilterOperator.GreaterThanOrEqual, field: { orderTotal: 82000 }, active: true }
|
|
122
124
|
]
|
|
123
125
|
|
|
124
126
|
// Pure AST transformation (no SQL / no ORM coupling):
|
|
@@ -130,22 +132,78 @@ const rewritten = await rewriteEncryptedFilters(filters, {
|
|
|
130
132
|
name: { column: 'name_trigrams', keyring: blindIndexKeyring }
|
|
131
133
|
},
|
|
132
134
|
rangeBuckets: {
|
|
133
|
-
|
|
135
|
+
// Open-ended >= without knownBuckets requires explicit max/ceiling (or tier config)
|
|
136
|
+
orderTotal: { type: 'stepped', step: 25000, min: 0, max: 150000 }
|
|
134
137
|
}
|
|
135
138
|
})
|
|
136
139
|
|
|
137
140
|
// Output AST:
|
|
138
141
|
// [
|
|
139
142
|
// { operator: EDataFilterOperator.In, field: { email_bidx: ['token_k2026...', 'token_k2025...'] }, active: true },
|
|
140
|
-
// {
|
|
141
|
-
//
|
|
143
|
+
// {
|
|
144
|
+
// operator: EDataFilterOperator.Or,
|
|
145
|
+
// field: [
|
|
146
|
+
// { operator: 'contains', field: { name_trigrams: ['ele_k2026...', 'len_k2026...', 'ena_k2026...'] }, active: true },
|
|
147
|
+
// { operator: 'contains', field: { name_trigrams: ['ele_k2025...', 'len_k2025...', 'ena_k2025...'] }, active: true }
|
|
148
|
+
// ],
|
|
149
|
+
// active: true
|
|
150
|
+
// },
|
|
151
|
+
// { operator: EDataFilterOperator.In, field: { orderTotal_bucket: ['75000-99999', '100000-124999', '125000-149999', '150000-174999'] }, active: true }
|
|
142
152
|
// ]
|
|
143
153
|
```
|
|
144
154
|
|
|
155
|
+
### Exact Write-Side Token Recipe (Write↔Query Parity)
|
|
156
|
+
|
|
157
|
+
Every writer (`CKeyManager.computeWriteBlindIndex`, `CSearchIndex`, `reencryptBatch`/`reencryptDataset`) MUST pass the exact same domain separation, normalization, and version options as `rewriteEncryptedFilters`:
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { CKeyManager, extractTrigrams, computeBlindIndexSchemeId } from '@katlux/providers'
|
|
161
|
+
|
|
162
|
+
const normalizeOpts = { locale: 'tr', asciiFold: false, normalizerId: 'default' } // must match rewriter!
|
|
163
|
+
const versionOpts = { version: 'v2', versionTag: true } // optional: emits `v2:<hex>`
|
|
164
|
+
|
|
165
|
+
// 1. Exact-match equality token (`_bidx`):
|
|
166
|
+
const emailBidx = await CKeyManager.computeWriteBlindIndex(user.email, blindIndexKeyring, {
|
|
167
|
+
field: 'email',
|
|
168
|
+
type: 'eq',
|
|
169
|
+
...normalizeOpts,
|
|
170
|
+
...versionOpts
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
// 2. Substring trigram tokens (`_trigrams`):
|
|
174
|
+
const nameTrigrams = await Promise.all(
|
|
175
|
+
extractTrigrams(user.name, normalizeOpts).map(tri =>
|
|
176
|
+
CKeyManager.computeWriteBlindIndex(tri, blindIndexKeyring, {
|
|
177
|
+
field: 'name',
|
|
178
|
+
type: 'tri',
|
|
179
|
+
...normalizeOpts,
|
|
180
|
+
...versionOpts
|
|
181
|
+
})
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
// 3. Persist scheme identifier to detect normalization/scope/framing drift:
|
|
186
|
+
const emailScheme = computeBlindIndexSchemeId(normalizeOpts) // e.g. 'lp1|scope=field-type|locale=tr|asciiFold=0|norm=default'
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
- **`kid` Framing Convention (Unified Across Writers & Rewriter)**: Neither writers (`computeWriteBlindIndex`, `reencryptField`, `CSearchIndex`) nor `rewriteEncryptedFilters` include `kid` in the HMAC input by default, because each `kid` in `IBlindIndexKeyring` already maps to a separate cryptographic HMAC key. Pass `kid` explicitly to `computeBlindIndex` only if multiple logical key IDs intentionally share the same raw HMAC key.
|
|
190
|
+
- **Versioned Tokens & Multi-Version Querying**: Pass `version` + `versionTag` (and `previousVersions: ['v1', 'unversioned']` during rolling migrations) to `rewriteEncryptedFilters` (or `IProviderEncryptionOptions`) so queries match both newly migrated `v2:<hex>` rows and older rows. Pass `expectedTokenScheme` to `rewriteEncryptedFilters` to fail fast with `ERR_BIDX_SCHEME_MISMATCH` if query normalization or scope diverges from persisted tokens.
|
|
191
|
+
|
|
192
|
+
### Open-Ended Range & Bucket Negation Behavior
|
|
193
|
+
- **Sound-or-Throw Open-Ended Ranges (`ERR_BUCKET_RANGE_UNBOUNDED`)**:
|
|
194
|
+
- `tier` configs have finite bucket universes and always resolve without `knownBuckets`.
|
|
195
|
+
- `stepped` and `date` configs resolve open-ended queries (`>`, `>=`, `<`, `<=`) against `knownBuckets` when provided, or require explicit domain bounds (`max`/`ceiling` for `>`/`>=`, `min`/`floor` for `<`/`<=` on `stepped`; `maxDate`/`minDate` on `date`). Unbounded open-ended queries throw `ERR_BUCKET_RANGE_UNBOUNDED` instead of silently truncating.
|
|
196
|
+
- **Bucket-Only `!=` and `nin` (Scalar & Array)**:
|
|
197
|
+
- Because coarse buckets contain multiple plaintext values, `!=` and `nin` cannot exclude buckets safely. When `knownBuckets`, `tier`, or fully bounded (`min`+`max` / `minDate`+`maxDate`) config is present, `rewriteEncryptedFilters` emits `IN <all buckets>`; when unbounded without `knownBuckets`, it emits a no-op tautology (`{ operator: 'and', field: [], active: true }`) so it never produces `IN []`.
|
|
198
|
+
|
|
145
199
|
### Safety Guards
|
|
200
|
+
- **Keyring Integrity Guard (`ERR_BIDX_KEYRING_INVALID`)**: Validates `blindIndexFields` and `trigramFields` keyrings (`activeKid` presence, single `'active'` key, and valid HMAC `CryptoKey` objects on every `'active'` and `'search-only'` entry) — missing keys never degrade into empty `contains []` queries.
|
|
146
201
|
- **Unsupported Operators Guard (`ERR_BIDX_UNSUPPORTED_OPERATOR`)**: Attempting range operations on a blind index column without shadow bucketing throws `ERR_BIDX_UNSUPPORTED_OPERATOR` to prevent unencrypted plaintext leakage.
|
|
202
|
+
- **Unbounded Range Guard (`ERR_BUCKET_RANGE_UNBOUNDED`)**: Open-ended range queries on `stepped` or `date` buckets without `knownBuckets` and without required domain bounds throw `ERR_BUCKET_RANGE_UNBOUNDED`.
|
|
203
|
+
- **Sensitive-Field & Per-Class Width Guards (`ERR_RANGE_BUCKET_SENSITIVE_FIELD`, `ERR_BUCKET_STEP_TOO_NARROW`)**: Sensitive fields (`salary`, `age`, `birthDate`, `dob`, `ssn`, `creditScore`, etc.) are rejected by default unless `allowSensitiveBucket: true` is passed, and per-class minimum floors (`RANGE_BUCKET_POLICY`) are enforced.
|
|
147
204
|
- **Short Query Guard (`ERR_TRIGRAM_QUERY_TOO_SHORT`)**: Substring queries with fewer than 3 characters throw `ERR_TRIGRAM_QUERY_TOO_SHORT` to enforce vocabulary integrity.
|
|
148
205
|
- **Candidate Token Cap (`maxCandidateTokens`)**: Protects against query explosion by limiting generated tokens (default: 500).
|
|
206
|
+
- **Edge / Serverless `kdfIterations` Limit**: `CKeyManager.deriveBlindIndexHmacKey` and `CSearchIndex` default to `310,000` PBKDF2 iterations for browser E2EE. Edge runtimes such as **Cloudflare Workers** cap WebCrypto PBKDF2 at `100,000` iterations (`NotSupportedError`); pass `{ kdfIterations: 100_000 }` (matching between client and server if deriving from the same passphrase) or supply a pre-imported HMAC `CryptoKey`.
|
|
149
207
|
|
|
150
208
|
---
|
|
151
209
|
|
|
@@ -154,10 +212,14 @@ const rewritten = await rewriteEncryptedFilters(filters, {
|
|
|
154
212
|
```sql
|
|
155
213
|
CREATE TABLE users (
|
|
156
214
|
id SERIAL PRIMARY KEY,
|
|
157
|
-
email_encrypted
|
|
158
|
-
email_bidx
|
|
159
|
-
|
|
160
|
-
|
|
215
|
+
email_encrypted JSONB NOT NULL,
|
|
216
|
+
email_bidx VARCHAR(96) NOT NULL, -- CHAR(64) for unversioned, VARCHAR(96) for tagged e.g. 'v2:<64-hex>'
|
|
217
|
+
email_bidx_version VARCHAR(32), -- optional token version ('v2')
|
|
218
|
+
email_bidx_scheme VARCHAR(128), -- optional scheme id from computeBlindIndexSchemeId()
|
|
219
|
+
email_trigrams TEXT[] NOT NULL,
|
|
220
|
+
email_trigrams_version VARCHAR(32),
|
|
221
|
+
email_trigrams_scheme VARCHAR(128),
|
|
222
|
+
status VARCHAR(50) DEFAULT 'Active'
|
|
161
223
|
);
|
|
162
224
|
|
|
163
225
|
-- Fast B-Tree index for exact lookups:
|
|
@@ -169,19 +231,69 @@ CREATE INDEX idx_users_email_trigrams ON users USING GIN (email_trigrams);
|
|
|
169
231
|
|
|
170
232
|
Exact match query:
|
|
171
233
|
```sql
|
|
172
|
-
SELECT id, email_encrypted FROM users WHERE email_bidx = ANY($1::
|
|
234
|
+
SELECT id, email_encrypted FROM users WHERE email_bidx = ANY($1::text[]);
|
|
173
235
|
```
|
|
174
236
|
|
|
175
237
|
Substring query:
|
|
176
238
|
```sql
|
|
239
|
+
-- Single active key & version:
|
|
177
240
|
SELECT id, email_encrypted FROM users WHERE email_trigrams @> $1::text[];
|
|
241
|
+
|
|
242
|
+
-- Multi-era keyring / multi-version (matches the rewritten OR AST across active + search-only kids & previousVersions):
|
|
243
|
+
SELECT id, email_encrypted FROM users
|
|
244
|
+
WHERE email_trigrams @> $1::text[]
|
|
245
|
+
OR email_trigrams @> $2::text[];
|
|
178
246
|
```
|
|
179
247
|
|
|
248
|
+
### 5.1 Migration Path: Unframed (Pre-DEBT-036), Unscoped & Unversioned Tokens (Lazy Re-Index)
|
|
249
|
+
|
|
250
|
+
When upgrading existing datasets that contain **pre-DEBT-036 unframed tokens**, **legacy unscoped tokens**, or **unversioned tokens** (or after changing `locale`, `asciiFold`, or `normalizerId`):
|
|
251
|
+
|
|
252
|
+
1. **Zero-Downtime Query Compatibility During Rollout**:
|
|
253
|
+
- **Unscoped tokens**: Set `allowLegacyUnscopedTokens: true` on `CSearchIndex` and/or `IEncryptedFilterRewriteOptions` during migration (keep `false` by default in steady state).
|
|
254
|
+
- **Unversioned / prior-version tokens**: Set `version: 'v2', versionTag: true, previousVersions: ['v1', 'unversioned']` on `rewriteEncryptedFilters` so queries match both migrated (`v2:<hex>`) and legacy (`v1:<hex>` / `<hex>`) rows.
|
|
255
|
+
- **Pre-DEBT-036 unframed tokens**: Unframed tokens are not query-compatible with length-prefixed (`lp1`) HMAC tokens; re-index them from the AES-GCM ciphertext via `reencryptDataset` (or lazily via `reencryptBatch` on read/login).
|
|
256
|
+
2. **Background or Lazy Re-Index via `reencryptDataset` (No AES Churn Required)**:
|
|
257
|
+
`reencryptDataset` / `reencryptBatch` automatically detects stale `_version`, missing `versionTag:` prefixes, or drifted `_scheme` values even when `envelope.kid === targetKid` (recomputing only the blind-index columns without re-encrypting AES envelopes):
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import { reencryptDataset } from '@katlux/providers'
|
|
261
|
+
|
|
262
|
+
await reencryptDataset({
|
|
263
|
+
targetKid: 'aes-v2',
|
|
264
|
+
keyring: { 'aes-v1': aesKeyV1, 'aes-v2': aesKeyV2 },
|
|
265
|
+
encryptedFields: ['email', 'name'],
|
|
266
|
+
trigramFields: ['name'],
|
|
267
|
+
locale: 'tr',
|
|
268
|
+
// Select only rows with missing/old token versions (or omit to auto-detect any version/scheme drift):
|
|
269
|
+
staleTokenVersions: ['unversioned', 'v1'],
|
|
270
|
+
blindIndex: {
|
|
271
|
+
fields: ['email'],
|
|
272
|
+
keyring: blindIndexKeyring,
|
|
273
|
+
version: 'v2',
|
|
274
|
+
versionTag: true,
|
|
275
|
+
persistScheme: true // writes `${col}_scheme` using computeBlindIndexSchemeId()
|
|
276
|
+
},
|
|
277
|
+
// Opt out of field+type domain separation ONLY if targeting a legacy unscoped schema:
|
|
278
|
+
// legacyUnscopedTokens: true,
|
|
279
|
+
fetchBatch: (cursor, limit) => db.fetchStaleUsers(cursor, limit),
|
|
280
|
+
updateRow: (id, patch, expectedVersion) => db.updateUserCas(id, patch, expectedVersion)
|
|
281
|
+
})
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
For **lazy on-read migration**, pass `[row]` to `reencryptBatch([row], { ...sameOptions })` when `isFieldBlindIndexStale(row, 'email', opts)` is true (or `row.email_bidx_version !== 'v2'`), persist `result.rows[0].patch`, and then remove `allowLegacyUnscopedTokens` / `previousVersions` once backfill completes.
|
|
285
|
+
|
|
180
286
|
---
|
|
181
287
|
|
|
182
|
-
## 6.
|
|
288
|
+
## 6. Deterministic Shadow-Bucket Range Index Recipes & Security Disclaimer (`TASK-031` / `DEBT-042` / `BUG-093`)
|
|
289
|
+
|
|
290
|
+
> [!CAUTION]
|
|
291
|
+
> **Security Disclaimer & Sensitive Field Policy (`ERR_RANGE_BUCKET_SENSITIVE_FIELD`)**:
|
|
292
|
+
> `rangeBuckets` implements a **Deterministic Shadow-Bucket Range Index**, NOT a zero-leakage or IND-CPA scheme. Observers with access to persistence columns or queries can infer **value frequency distributions**, **bucket ordering relations**, and **empirical distribution profiles** across records.
|
|
293
|
+
> - **Default Sensitive-Field Prohibition**: Fields in `SENSITIVE_RANGE_BUCKET_FIELDS` (`salary`, `income`, `compensation`, `netWorth`, `creditScore`, `ssn`, `age`, `birthDate`, `dateOfBirth`, `dob`) throw `ERR_RANGE_BUCKET_SENSITIVE_FIELD` by default unless `allowSensitiveBucket: true` is explicitly configured.
|
|
294
|
+
> - **Per-Class Minimum Width Floors (`RANGE_BUCKET_POLICY` / `ERR_BUCKET_STEP_TOO_NARROW`)**: Even with `allowSensitiveBucket: true`, per-class floors are enforced (`10,000` for financial, `1,000,000` for `ssn`, `100` for `creditScore`, `10` for `age`, `'year'`/`'quarter'` for sensitive dates; `DEFAULT_MIN_BUCKET_STEP = 100` for non-sensitive fields) unless `allowNarrowStep: true` / `allowNarrowGranularity: true` is also opted into.
|
|
183
295
|
|
|
184
|
-
To support range filtering (`<`, `<=`, `>`, `>=`, `between`)
|
|
296
|
+
To support coarse range filtering (`<`, `<=`, `>`, `>=`, `between`) on encrypted numeric or date columns under these constraints, configure `rangeBuckets` on non-sensitive fields with explicit bounds (or `knownBuckets`):
|
|
185
297
|
|
|
186
298
|
```ts
|
|
187
299
|
import { CFlatClientDataProvider, EDataFilterOperator } from '@katlux/providers'
|
|
@@ -192,27 +304,38 @@ const provider = new CFlatClientDataProvider({
|
|
|
192
304
|
encryption: {
|
|
193
305
|
enabled: true,
|
|
194
306
|
key: 'master-encryption-secret',
|
|
195
|
-
fields: ['
|
|
307
|
+
fields: ['orderTotal', 'createdAt'],
|
|
196
308
|
rangeBuckets: {
|
|
197
|
-
|
|
198
|
-
|
|
309
|
+
// Broad tier bands for commercial order amounts
|
|
310
|
+
orderTotal: { type: 'tier', thresholds: [0, 25000, 50000, 75000, 100000, 250000] },
|
|
311
|
+
createdAt: { type: 'date', granularity: 'quarter', minDate: '2024-01-01', maxDate: '2027-12-31' }
|
|
199
312
|
}
|
|
200
313
|
}
|
|
201
314
|
})
|
|
202
315
|
|
|
203
|
-
// Query:
|
|
204
|
-
// Stage 1 (Coarse Matching): CSearchIndex resolves eligible
|
|
316
|
+
// Query: orderTotal >= 82000
|
|
317
|
+
// Stage 1 (Coarse Matching): CSearchIndex resolves eligible tier keys ('75000-99999', '100000-249999', '>=250000')
|
|
205
318
|
// Stage 2 (Fine-Grained Verification): Provider lazily decrypts the current page slice and eliminates false positives (e.g. 76k)
|
|
206
319
|
provider.setFilter({
|
|
207
320
|
operator: EDataFilterOperator.GreaterThanOrEqual,
|
|
208
|
-
field: {
|
|
321
|
+
field: { orderTotal: 82000 },
|
|
209
322
|
active: true
|
|
210
323
|
})
|
|
211
324
|
```
|
|
212
325
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
326
|
+
If compliance explicitly permits coarse bucketing on a sensitive field (e.g. broad `$25,000+` compensation tiers or `'year'` birth dates), opt in with `allowSensitiveBucket: true`:
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
rangeBuckets: {
|
|
330
|
+
salary: { type: 'tier', thresholds: [0, 25000, 50000, 100000, 250000], allowSensitiveBucket: true },
|
|
331
|
+
birthDate: { type: 'date', granularity: 'year', allowSensitiveBucket: true, minDate: '1920-01-01', maxDate: '2026-12-31' }
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Supported Bucketing Strategies & Date Parsing Rules
|
|
336
|
+
- **Date Granularities**: `'year'` (`2026`), `'quarter'` (`2026-Q1`), `'month'` (`2026-03`), `'week'` (`2026-W08`), `'day'` (`2026-03-15`). Sensitive date fields (`birthDate`, `dateOfBirth`, `dob`) require `allowSensitiveBucket: true` and reject `'month'`, `'week'`, and `'day'` with `ERR_BUCKET_STEP_TOO_NARROW` unless `allowNarrowGranularity: true` is also set. Open-ended `>`/`>=` requires `maxDate` (or `knownBuckets`) and `<`/`<=` requires `minDate` (or `knownBuckets`), throwing `ERR_BUCKET_RANGE_UNBOUNDED` otherwise.
|
|
337
|
+
- **`parseDateValue` Timestamp Heuristic & UTC Anchoring**: Numeric timestamps with `|v| < 1e10` are treated as **Unix seconds** (covering ~1653..2286 in seconds, including negative pre-1970 seconds) and multiplied by `1000`; values with `|v| >= 1e10` are treated as **Unix milliseconds** (including negative pre-1973 ms timestamps such as `1960-01-01`: `-315619200000`). Timezone-naive ISO/SQL strings (`'2023-05-15'`, `'2023-05-15 00:30:00'`) are parsed deterministically as **UTC** so bucket keys do not shift across host timezones.
|
|
338
|
+
- **Stepped Numeric**: `{ type: 'stepped', step: 25000, min?: 0, max?: 250000, minStep?: number, allowNarrowStep?: boolean, allowSensitiveBucket?: boolean }` -> `'0-24999'`, `'25000-49999'`, `'75000-99999'`. Rejects widths below `DEFAULT_MIN_BUCKET_STEP` (`100`) or per-class floor with `ERR_BUCKET_STEP_TOO_NARROW`. Open-ended `>`/`>=` requires `max`/`ceiling` (or `knownBuckets`) and `<`/`<=` requires `min`/`floor` (or `knownBuckets`), throwing `ERR_BUCKET_RANGE_UNBOUNDED` otherwise.
|
|
339
|
+
- **Threshold / Tier Numeric (Recommended when coarse bands suffice)**: `{ type: 'tier', thresholds: [0, 25000, 50000, 100000, 250000] }` -> `'<0'`, `'0-24999'`, `'25000-49999'`, `'50000-99999'`, `'>=250000'`. Enforces minimum threshold gaps unless overridden and resolves open-ended ranges natively without `knownBuckets`.
|
|
217
340
|
|
|
218
341
|
|
|
@@ -27,7 +27,7 @@ const cipher = new CWebCryptoEncryptionProvider({
|
|
|
27
27
|
// In production, supply credentials dynamically via environment variables, KMS, or runtime config:
|
|
28
28
|
key: process.env.DATA_KEY, // or useRuntimeConfig().public.dataEncryptionKey, or dynamic callback
|
|
29
29
|
kid: 'tenant-v1',
|
|
30
|
-
kdf: 'pbkdf2', // 'pbkdf2'
|
|
30
|
+
kdf: 'pbkdf2', // 'pbkdf2' or 'hkdf' for derivation (raw 256-bit keys bypass KDF; 'none' is decryption-only with allowInsecureKdf: true)
|
|
31
31
|
kdfIterations: 310000
|
|
32
32
|
})
|
|
33
33
|
|
|
@@ -41,6 +41,9 @@ const data = await cipher.decrypt(envelope)
|
|
|
41
41
|
> [!IMPORTANT]
|
|
42
42
|
> **Production Key Security**: Never hardcode secret passphrases or keys in frontend bundles or source code. Always source credentials dynamically from secure runtime environments (`process.env`), KMS key agreement, authenticated sessions, or interactive user prompts.
|
|
43
43
|
|
|
44
|
+
> [!WARNING]
|
|
45
|
+
> **Edge / Serverless Runtime PBKDF2 Limit (`kdfIterations`)**: `kdfIterations` defaults to `310,000` (OWASP recommendation for browser E2EE). Cloud/edge runtimes such as **Cloudflare Workers (`workerd`)** cap WebCrypto PBKDF2 at `100,000` iterations and fail with `NotSupportedError` on server-side derivation unless `kdfIterations: 100_000` is specified or `kdf: 'hkdf'` is used with high-entropy server secrets.
|
|
46
|
+
|
|
44
47
|
---
|
|
45
48
|
|
|
46
49
|
## 3. `CWebCryptoAESCBCProvider` (AES-CBC-256 + HMAC-SHA-256)
|
|
@@ -70,13 +70,15 @@ export interface IProviderEncryptionOptions {
|
|
|
70
70
|
decryptedCache?: boolean // default: false. Enables in-memory decrypted row cache for local filtering without blind index
|
|
71
71
|
preEncrypted?: boolean // Set to true if API endpoints return pre-encrypted ciphertext envelopes; enables in-memory index decryption
|
|
72
72
|
hmacKey?: TKeyProvider // Optional dedicated HMAC key for search indexing (defaults to encryption key)
|
|
73
|
+
rangeBuckets?: Record<string, TRangeBucketConfig> // Deterministic shadow-bucket range index config
|
|
74
|
+
allowSensitiveBucket?: boolean // Explicit opt-in required for rangeBuckets on high-sensitivity PII fields
|
|
73
75
|
algorithm?: 'AES-GCM' | string // default: 'AES-GCM'
|
|
74
76
|
customProvider?: IEncryptionProvider // Custom cipher adapter (e.g. CRSA, CECDH, AES-CBC)
|
|
75
77
|
kdf?: 'none' | 'pbkdf2' | 'hkdf' // Key derivation strategy:
|
|
76
78
|
// - 'pbkdf2': Recommended for human passphrases/passwords (OWASP recommended rounds)
|
|
77
79
|
// - 'hkdf': For high-entropy IKM / subkey derivation (warns if used with string passwords)
|
|
78
80
|
// - 'none': When supplying pre-derived 256-bit raw keys, Buffers, or CryptoKeys
|
|
79
|
-
kdfIterations?: number // PBKDF2 rounds (default: 310,000 per OWASP, clamped [1,000, 600,000])
|
|
81
|
+
kdfIterations?: number // PBKDF2 rounds (default: 310,000 per OWASP, clamped [1,000, 600,000]; also forwarded to CSearchIndex)
|
|
80
82
|
kdfHash?: 'SHA-256' | 'SHA-512' // KDF hash algorithm
|
|
81
83
|
kdfSalt?: string | Uint8Array | ArrayBuffer // Optional static salt (random salt in envelope if omitted)
|
|
82
84
|
publicKey?: CryptoKey // Optional public key for asymmetric encryption
|
|
@@ -88,6 +90,9 @@ export interface IProviderEncryptionOptions {
|
|
|
88
90
|
}
|
|
89
91
|
```
|
|
90
92
|
|
|
93
|
+
> [!WARNING]
|
|
94
|
+
> **Cloud & Edge Runtime PBKDF2 Limit (`kdfIterations`)**: While `310,000` is the default for browser E2EE, certain serverless/edge runtimes — notably **Cloudflare Workers (`workerd`)** — enforce a hard `100,000`-iteration ceiling on WebCrypto `crypto.subtle` PBKDF2 and throw `NotSupportedError` when deriving keys on the server with `310,000` iterations. When deriving cipher or `CSearchIndex` blind-index keys on edge runtimes, explicitly set `kdfIterations: 100_000` (or use `kdf: 'hkdf'` / pre-imported `CryptoKey` instances for high-entropy server secrets).
|
|
95
|
+
|
|
91
96
|
---
|
|
92
97
|
|
|
93
98
|
## 4. Factory & Base Provider Creation
|
|
@@ -130,7 +135,7 @@ In enterprise cryptography, Searchable Symmetric Encryption (SSE) always introdu
|
|
|
130
135
|
|
|
131
136
|
1. **`blindIndex` (`_bidx`)**: Enables exact match (`==`, `!=`, `in`, `nin`). Leaks frequency distribution. **Strictly prohibited on low-cardinality columns** (status, gender, boolean, small enums).
|
|
132
137
|
2. **`trigrams` (`_trigrams`)**: Enables substring search (`contains`, `like`) $\ge 3$ characters. Leaks approximate term length and character overlap patterns. Disabled by default.
|
|
133
|
-
3. **`rangeBuckets` (`_bucket`)**: Enables range queries (`<`, `<=`, `>`, `>=`, `between`) and coarse sorting
|
|
138
|
+
3. **`rangeBuckets` (`_bucket`)**: Enables range queries (`<`, `<=`, `>`, `>=`, `between`) and coarse sorting via a **Deterministic Shadow-Bucket Range Index** (NOT IND-CPA / NOT zero-leakage). Reveals value frequency distributions, bucket order relations, and empirical distribution profiles. High-sensitivity fields (`salary`, `age`, `birthDate`, `dob`, `creditScore`, `ssn`) throw `ERR_RANGE_BUCKET_SENSITIVE_FIELD` by default unless `allowSensitiveBucket: true` is passed, and `RANGE_BUCKET_POLICY` enforces per-class minimum floors (`10,000` financial, `1,000,000` `ssn`, `100` `creditScore`, `10` `age`, `'year'`/`'quarter'` sensitive dates; `DEFAULT_MIN_BUCKET_STEP = 100` general). Open-ended queries without `knownBuckets` require domain bounds (`min`/`max`, `minDate`/`maxDate`) or throw `ERR_BUCKET_RANGE_UNBOUNDED`.
|
|
134
139
|
4. **`decryptedCache`**: Client-side in-memory cache for fast paging. Leaks decrypted plaintext to browser RAM until page unmount. Disabled by default.
|
|
135
140
|
|
|
136
141
|
### Client-Side Lazy Decryption Lifecycle (Zero-Bulk Plaintext in Memory)
|
|
@@ -151,9 +156,10 @@ In enterprise cryptography, Searchable Symmetric Encryption (SSE) always introdu
|
|
|
151
156
|
- Substring matching via character trigram sets leaks approximate term lengths and character co-occurrence patterns.
|
|
152
157
|
- An attacker observing trigram sets across rows can deduce language, spelling patterns, and common affixes.
|
|
153
158
|
- UI client queries must enforce a minimum query threshold (≥ 3 characters) to avoid generating trivial or overly broad candidate sets.
|
|
154
|
-
- **Shadow
|
|
155
|
-
-
|
|
156
|
-
-
|
|
159
|
+
- **Deterministic Shadow-Bucket Range Index (Range Query Leakage)**:
|
|
160
|
+
- Deterministic bucket tokens (`2026-Q1`, `50000-74999`) are stored alongside ciphertext. They do **not** provide zero-leakage guarantees: any observer with database read access learns bucket membership frequencies, relative order relations between records in different buckets, and distribution profiles (equivalent to coarse Order-Preserving Encryption / known SSE inference attacks).
|
|
161
|
+
- **Sensitive-Field Block & Per-Class Floors**: Fields in `SENSITIVE_RANGE_BUCKET_FIELDS` (`salary`, `age`, `birthDate`, `dob`, `creditScore`, `income`, `ssn`, etc.) throw `ERR_RANGE_BUCKET_SENSITIVE_FIELD` by default unless `allowSensitiveBucket: true` is passed. `RANGE_BUCKET_POLICY` enforces per-class minimum floors (`10,000` for financial fields, `1,000,000` for `ssn`, `100` for `creditScore`, `10` for `age`, `'year'`/`'quarter'` for sensitive dates, and `DEFAULT_MIN_BUCKET_STEP = 100` otherwise), throwing `ERR_BUCKET_STEP_TOO_NARROW` when violated.
|
|
162
|
+
- **Sound-or-Throw Open-Ended Ranges**: Open-ended stepped/date queries without `knownBuckets` require explicit domain bounds (`min`/`max`, `minDate`/`maxDate`) or throw `ERR_BUCKET_RANGE_UNBOUNDED` instead of silently truncating.
|
|
157
163
|
- **Entropy Separation & Scope Recommendations**:
|
|
158
164
|
- **Safe & Recommended**: High-entropy, unique or semi-unique identifiers with dedicated, domain-isolated HMAC keys (`email`, `ssn`, `tax_id`, `phone_number`, `uuid`, `account_number`).
|
|
159
165
|
- **Actively Discouraged / Unsafe**: Low-entropy enum fields, statuses, boolean flags, small categorical datasets, or common dictionary words.
|
|
@@ -168,6 +174,6 @@ In enterprise cryptography, Searchable Symmetric Encryption (SSE) always introdu
|
|
|
168
174
|
| **Standard AES-256-GCM Envelope Encryption** | Highly sensitive PII, passwords, private keys, medical notes, credit card CVVs, rich text payloads (e.g. `medical_notes`, `api_secret`, `cvv`) | High or Low | None (direct ciphertext storage only; decrypted in client memory or authorized application layer) | Zero index leakage. Randomized IV/nonce ensures identical plaintexts yield completely different ciphertexts. Immune to frequency analysis. | **Gold standard for confidential data**. Use whenever fields do not require server-side filtering, searching, or indexing. |
|
|
169
175
|
| **Blind Index Equality Token (HMAC-SHA256)** | High-entropy unique / semi-unique identifiers: `email`, `ssn`, `tax_id`, `phone_number`, `national_id`, `uuid` | **High Entropy Only** | Exact match (`==`, `!=`, `IN`, `NOT IN`) via B-Tree index on `*_bidx` column | Deterministic token preserves equality and frequency distributions. Duplicates and recurring values are observable. | **Use strictly for exact lookups of high-entropy identifiers**. Always use a dedicated HMAC key separated from the DEK. Never apply to low-cardinality fields. |
|
|
170
176
|
| **Trigram Substring Search** | Long, high-entropy textual strings requiring substring/contains queries: `full_name`, `address_line`, `company_name` | **High to Medium Entropy** | Substring / Contains search via GIN inverted index (`@>` array containment) on `*_trigrams` | Leaks approximate string length and character co-occurrence frequencies. | **Use with caution on high-entropy text**. Enforce 3+ character minimum query length in client UI. Do not apply to small discrete enum sets. |
|
|
171
|
-
| **Shadow
|
|
177
|
+
| **Deterministic Shadow-Bucket Range Index (`RFC-001` / `TASK-031` / `DEBT-042` / `BUG-093`)** | Coarse dates (`created_at` by year/quarter), non-PII quantities, or compliance-approved broad bands | Low to Medium | Range queries (`>`, `<`, `>=`, `<=`, `BETWEEN`) on discretized bucket tokens | **Not zero-leakage.** Reveals value frequency distributions, bucket order relations, and distribution profiles across buckets. | **Prohibited by default on high-sensitivity PII** (`ERR_RANGE_BUCKET_SENSITIVE_FIELD` on `salary`, `age`, `birthDate`, `dob`, `creditScore`, `ssn`). Leave sensitive PII unindexed (`AES-256-GCM`) or require `allowSensitiveBucket: true` + per-class floors; supply `knownBuckets` or domain bounds (`ERR_BUCKET_RANGE_UNBOUNDED`). |
|
|
172
178
|
|
|
173
179
|
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
> Searchable Symmetric Encryption (SSE) always involves deliberate, controlled metadata leakage. In Katlux, all searchable features are **opt-in dials** so developers maintain governance over exposure:
|
|
63
63
|
> - **`blindIndex` (`_bidx`)**: Enables `==`, `!=`, `in`, `nin`. Leaks frequency distribution. **Strictly forbidden on low-cardinality fields** (status, gender, boolean, small enums).
|
|
64
64
|
> - **`trigrams` (`_trigrams`)**: Enables substring `contains`, `like` $\ge 3$ characters. Leaks substring overlap patterns and length.
|
|
65
|
-
> - **`rangeBuckets` (`_bucket`)**:
|
|
65
|
+
> - **`rangeBuckets` (`_bucket`)**: Deterministic Shadow-Bucket Range Index enabling `<`, `<=`, `>`, `>=`, `between` and coarse sorting. **Not IND-CPA / not zero-leakage**: reveals bucket frequency distributions, bucket order relations, and empirical distribution profiles. Narrow widths (`< 100`) throw `ERR_BUCKET_STEP_TOO_NARROW` by default. **Do not use** narrow buckets on sensitive PII (`salary`, `age`, `birthDate`, `creditScore`); prefer unindexed `AES-256-GCM` or broad `$25,000+` tiers / `'year'` dates.
|
|
66
66
|
> - **`decryptedCache`**: Enables fast client-side paging. Retains decrypted rows in browser RAM until page unmount. Disabled by default for zero-trust terminal security.
|
|
67
67
|
> - **Client Memory Lifecycle**: Client data providers keep the entire dataset encrypted in RAM (`allData`). Queries filter ciphertext tags via `CSearchIndex`, and only the visible page slice (e.g. 20-50 rows) is decrypted on the fly with candidate false-positive pruning.
|
|
68
68
|
> - **Server Limitations**: In backend SQL databases, encrypted columns cannot be sorted (`ORDER BY`) or aggregated (`SUM`, `AVG`) without client-side decryption.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@katlux/toolkit",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.148",
|
|
4
4
|
"description": "Core UI toolkit and utilities for the Katlux ecosystem",
|
|
5
5
|
"author": "Katlux",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"**/*.sass"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@katlux/providers": "^0.1.1-alpha.
|
|
60
|
+
"@katlux/providers": "^0.1.1-alpha.135",
|
|
61
61
|
"@nuxt/kit": "^3.12.0",
|
|
62
62
|
"@nuxtjs/i18n": "^10.4.0",
|
|
63
63
|
"pug": "^3.0.0",
|
|
64
64
|
"sass": "^1.80.0"
|
|
65
65
|
},
|
|
66
66
|
"katlux": {
|
|
67
|
-
"mcpVersion": "0.1.0-alpha.
|
|
67
|
+
"mcpVersion": "0.1.0-alpha.27"
|
|
68
68
|
},
|
|
69
69
|
"files": [
|
|
70
70
|
"dist",
|