@katlux/toolkit 0.1.1-alpha.140 → 0.1.1-alpha.142
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/dist/compiled/composables/useKatluxForm.mjs +29 -21
- package/dist/module.json +1 -1
- package/dist/runtime/components/KDatePicker/KDatePicker.global.d.vue.ts +3 -3
- package/dist/runtime/components/KDatePicker/KDatePicker.global.vue.d.ts +3 -3
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.d.vue.ts +2 -2
- package/dist/runtime/components/KDateTimePicker/KDateTimePicker.global.vue.d.ts +2 -2
- package/dist/runtime/composables/useKatluxForm.d.ts +11 -11
- package/dist/runtime/composables/useKatluxForm.js +29 -21
- package/dist/skills/katlux-components/components/KAreaChart.md +1 -1
- package/dist/skills/katlux-components/components/KBarChart.md +1 -1
- package/dist/skills/katlux-components/components/KBulkActions.md +3 -3
- package/dist/skills/katlux-components/components/KCheckbox.md +2 -2
- package/dist/skills/katlux-components/components/KCombobox.md +3 -3
- package/dist/skills/katlux-components/components/KCompositeInput.md +4 -4
- package/dist/skills/katlux-components/components/KDataIterator.md +3 -3
- package/dist/skills/katlux-components/components/KDatatable.md +7 -7
- package/dist/skills/katlux-components/components/KDatePicker.md +3 -3
- package/dist/skills/katlux-components/components/KGantt.md +12 -12
- package/dist/skills/katlux-components/components/KHeatMap.md +1 -1
- package/dist/skills/katlux-components/components/KLineChart.md +1 -1
- package/dist/skills/katlux-components/components/KPieChart.md +1 -1
- package/dist/skills/katlux-components/components/KScatterChart.md +1 -1
- package/dist/skills/katlux-components/components/KTree.md +8 -8
- package/dist/skills/katlux-components/components/KTreePicker.md +3 -3
- package/dist/skills/katlux-components/components/KTreeView.md +3 -3
- package/dist/skills/katlux-config/SKILL.md +7 -7
- package/dist/skills/katlux-presets/SKILL.md +1 -1
- package/dist/skills/katlux-presets/creating-a-preset.md +1 -1
- package/dist/skills/katlux-providers/SKILL.md +1 -1
- package/dist/skills/katlux-providers/providers/ADataProvider.md +3 -3
- package/dist/skills/katlux-providers/providers/CAPIFlatClientDataProvider.md +3 -3
- package/dist/skills/katlux-providers/providers/CAPIFlatServerDataProvider.md +3 -3
- package/dist/skills/katlux-providers/providers/CFlatClientDataProvider.md +4 -4
- package/dist/skills/katlux-providers/providers/CFlatServerDataProvider.md +1 -1
- package/dist/skills/katlux-providers/providers/CTreeClientDataProvider.md +2 -2
- package/dist/skills/katlux-providers/providers/RequestProvider.md +4 -4
- package/dist/skills/katlux-providers/providers/caching.md +11 -11
- package/dist/skills/katlux-providers/providers/encryption-asymmetric.md +102 -0
- package/dist/skills/katlux-providers/providers/encryption-field-level.md +260 -0
- package/dist/skills/katlux-providers/providers/encryption-key-management.md +196 -0
- package/dist/skills/katlux-providers/providers/encryption-key-pinning.md +115 -0
- package/dist/skills/katlux-providers/providers/encryption-streaming.md +84 -0
- package/dist/skills/katlux-providers/providers/encryption-symmetric.md +139 -0
- package/dist/skills/katlux-providers/providers/encryption-threat-model.md +110 -0
- package/dist/skills/katlux-providers/providers/encryption.md +44 -267
- package/dist/skills/katlux-providers/providers/types.md +5 -5
- package/dist/skills/katlux-providers/providers/useDataProvider.md +1 -1
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
| `multiSelect` | `boolean` | `false` | Enable node checkboxes |
|
|
11
11
|
| `isNodeSelected`| `Function` | `() => false` | Custom selection logic handler |
|
|
12
12
|
| `selectable` | `boolean` | `false` | Enable node clicking for selection |
|
|
13
|
-
| `v-model` / `v-model:selectedNode` / `selectedNode` | `
|
|
13
|
+
| `v-model` / `v-model:selectedNode` / `selectedNode` | `ITreeNode \| string \| number \| null` | `null` | Selected node with two-way binding |
|
|
14
14
|
| `v-model:expandedNodes` / `expandedNodes` | `Set<string \| number> \| (string \| number)[]` | `undefined` | Expanded node IDs with two-way binding |
|
|
15
15
|
| `v-model:searchtext` / `searchtext` | `string` | `''` | Live filtering search text with two-way binding |
|
|
16
16
|
| `virtualScroll` | `boolean` | `false` | Enable virtual windowing for massive hierarchies (5,000+ nodes) |
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
- **Events / Emits**:
|
|
21
21
|
| Event | Payload | Description |
|
|
22
22
|
| --- | --- | --- |
|
|
23
|
-
| `@update:modelValue` | `node:
|
|
24
|
-
| `@update:selectedNode` | `node:
|
|
25
|
-
| `@select` | `node:
|
|
26
|
-
| `@node-click` | `node:
|
|
23
|
+
| `@update:modelValue` | `node: ITreeNode \| null` | Emitted when selected node changes (`v-model`) |
|
|
24
|
+
| `@update:selectedNode` | `node: ITreeNode \| null` | Emitted when selected node changes (`v-model:selectedNode`) |
|
|
25
|
+
| `@select` | `node: ITreeNode` | Emitted when a node is selected / clicked |
|
|
26
|
+
| `@node-click` | `node: ITreeNode` | Emitted when a node is clicked |
|
|
27
27
|
| `@node-toggle` | `nodeId: string \| number` | Emitted when a node's chevron is toggled |
|
|
28
28
|
| `@update:expandedNodes`| `nodes: Set<string \| number> \| (string \| number)[]` | Emitted when expansion state changes (`v-model:expandedNodes`) |
|
|
29
29
|
| `@update:searchtext` | `text: string` | Emitted when search text changes (`v-model:searchtext`) |
|
|
30
30
|
- **Slots**:
|
|
31
31
|
| Slot | Scope | Description |
|
|
32
32
|
| --- | --- | --- |
|
|
33
|
-
| `#node` | `{ node: ITreeNode, data:
|
|
34
|
-
| `#item` | `{ node: ITreeNode, data:
|
|
35
|
-
| `#default` | `{ node: ITreeNode, data:
|
|
33
|
+
| `#node` | `{ node: ITreeNode, data: Record<string, unknown> }` | Top-priority slot for custom node content |
|
|
34
|
+
| `#item` | `{ node: ITreeNode, data: Record<string, unknown> }` | Custom content for node (falls back to `#node`) |
|
|
35
|
+
| `#default` | `{ node: ITreeNode, data: Record<string, unknown> }` | Fallback for `#item` slot |
|
|
36
36
|
- **WAI-ARIA Tree View Keyboard Accessibility**:
|
|
37
37
|
- `ArrowRight`: On a closed parent, expands the node without moving focus. On an open parent, moves focus to the first child. On a leaf node, does nothing.
|
|
38
38
|
- `ArrowLeft`: On an open parent, collapses the node without moving focus. On a child node or closed node, moves focus to its parent node.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
| Prop | Type | Default | Description |
|
|
5
5
|
| --- | --- | --- | --- |
|
|
6
6
|
| `label` | `string` | `''` | There will be a label. |
|
|
7
|
-
| `v-model` | `
|
|
7
|
+
| `v-model` | `ITreeNode \| string \| number \| null` | `null` | Selected node(s) |
|
|
8
8
|
| `v-model:isOptionsOpen` | `boolean` | `false` | Controls the visibility of the dropdown |
|
|
9
9
|
| `v-model:searchtext` / `searchtext` | `string` | `''` | Live search text with two-way binding |
|
|
10
10
|
| `v-model:expandedNodes` / `expandedNodes` | `(string \| number)[]` | `[]` | Expanded node IDs with two-way binding |
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
- **Events / Emits**:
|
|
28
28
|
| Event | Payload | Description |
|
|
29
29
|
| --- | --- | --- |
|
|
30
|
-
| `@update:modelValue` | `value:
|
|
30
|
+
| `@update:modelValue` | `value: ITreeNode \| string \| number \| null` | Emitted when selected node changes |
|
|
31
31
|
| `@update:isOptionsOpen` | `open: boolean` | Emitted when dropdown opens/closes |
|
|
32
32
|
| `@update:searchtext` | `text: string` | Emitted when search changes (`v-model:searchtext`) |
|
|
33
33
|
| `@update:expandedNodes` | `nodes: (string \| number)[]` | Emitted when expansion changes (`v-model:expandedNodes`) |
|
|
34
|
-
| `@change` | `node:
|
|
34
|
+
| `@change` | `node: ITreeNode \| null` | Emitted on selection change |
|
|
35
35
|
- **Slots**: Forwards all slots to its internal `KTree` (e.g., `#item`, `#default`).
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
| `v-model:expandedNodes` / `expandedNodes` | `(string \| number)[]` | `[]` | Array of expanded node IDs with two-way binding |
|
|
12
12
|
| `rowActions` | `IKDatatableAction[]` | `[]` | Per-row action menu |
|
|
13
13
|
| `bulkActions` | `IKDatatableAction[]` | `[]` | Global actions for selected rows |
|
|
14
|
-
| `selectedRows` | `
|
|
14
|
+
| `selectedRows` | `Record<string, unknown>[]` | `[]` | Currently selected rows (supports `v-model:selectedRows`) |
|
|
15
15
|
| `selectAll` | `boolean` | `false` | Header select-all state (supports `v-model:selectAll`) |
|
|
16
16
|
| `loading` | `boolean` | `false` | Manual loading state toggle |
|
|
17
17
|
| `multiSelect` | `boolean` | `false` | Enable node checkboxes |
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
| Event | Payload | Description |
|
|
22
22
|
| --- | --- | --- |
|
|
23
23
|
| `@update:expandedNodes` | `value: (string \| number)[]` | Emitted when node expansion changes (`v-model:expandedNodes`) |
|
|
24
|
-
| `@update:selectedRows` | `value:
|
|
24
|
+
| `@update:selectedRows` | `value: Record<string, unknown>[]` | Emitted when row selection changes (`v-model:selectedRows`) |
|
|
25
25
|
| `@update:selectAll` | `value: boolean` | Emitted when select-all state toggles (`v-model:selectAll`) |
|
|
26
26
|
- **Slots**:
|
|
27
27
|
| Slot | Scope | Description |
|
|
28
28
|
| --- | --- | --- |
|
|
29
|
-
| `#cell-[field]` | `{ row:
|
|
29
|
+
| `#cell-[field]` | `{ row: Record<string, unknown>, field: string, value: unknown }` | Custom cell renderer for a column |
|
|
30
30
|
| `#header-[field]` | `{ field: string }` | Custom header renderer for a column |
|
|
@@ -104,13 +104,13 @@ export default defineAppConfig({
|
|
|
104
104
|
|
|
105
105
|
| Package Name | Current Version | Description | Installation Command |
|
|
106
106
|
| --- | --- | --- | --- |
|
|
107
|
-
| `@katlux/toolkit` | `0.1.1-alpha.
|
|
108
|
-
| `@katlux/providers` | `0.1.1-alpha.
|
|
109
|
-
| `@katlux/preset-modern` | `0.1.1-alpha.
|
|
110
|
-
| `@katlux/preset-dark` | `0.1.1-alpha.
|
|
111
|
-
| `@katlux/block-charts` | `0.1.1-alpha.
|
|
112
|
-
| `@katlux/block-ecommerce` | `0.1.1-alpha.
|
|
113
|
-
| `@katlux/mcp` | `0.1.0-alpha.
|
|
107
|
+
| `@katlux/toolkit` | `0.1.1-alpha.141` | Core Nuxt module, UI toolkit, presets, and components | `npm install @katlux/toolkit@alpha` |
|
|
108
|
+
| `@katlux/providers` | `0.1.1-alpha.129` | Core data providers, client caching, and state structures | `npm install @katlux/providers@alpha` |
|
|
109
|
+
| `@katlux/preset-modern` | `0.1.1-alpha.116` | Modern design preset and styling variables | `npm install @katlux/preset-modern@alpha` |
|
|
110
|
+
| `@katlux/preset-dark` | `0.1.1-alpha.47` | Sleek Dark Mode design preset | `npm install @katlux/preset-dark@alpha` |
|
|
111
|
+
| `@katlux/block-charts` | `0.1.1-alpha.116` | Pre-built charting block components | `npm install @katlux/block-charts@alpha` |
|
|
112
|
+
| `@katlux/block-ecommerce` | `0.1.1-alpha.116` | Pre-built eCommerce block components | `npm install @katlux/block-ecommerce@alpha` |
|
|
113
|
+
| `@katlux/mcp` | `0.1.0-alpha.21` | Model Context Protocol server for AI assistant integration | `npm install @katlux/mcp@alpha` |
|
|
114
114
|
|
|
115
115
|
> [!NOTE]
|
|
116
116
|
> Katlux packages are currently published under the `@alpha` tag on NPM. Always append `@alpha` or the specific version tag when adding dependencies.
|
|
@@ -163,7 +163,7 @@ button.KButton.my-brand(:class="buttonClasses" @click="onClick")
|
|
|
163
163
|
|
|
164
164
|
<script lang="ts" setup>
|
|
165
165
|
defineProps<{
|
|
166
|
-
buttonClasses:
|
|
166
|
+
buttonClasses: string | string[] | Record<string, boolean>
|
|
167
167
|
onClick: (e: MouseEvent) => void
|
|
168
168
|
// ... same props as the default KButton template
|
|
169
169
|
}>()
|
|
@@ -127,7 +127,7 @@ button.KButton.my-brand(
|
|
|
127
127
|
<script lang="ts" setup>
|
|
128
128
|
interface ButtonProps {
|
|
129
129
|
type?: 'button' | 'submit' | 'reset'
|
|
130
|
-
buttonClasses?:
|
|
130
|
+
buttonClasses?: string | string[] | Record<string, boolean>
|
|
131
131
|
disabled?: boolean
|
|
132
132
|
loading?: boolean
|
|
133
133
|
customClasses?: string
|
|
@@ -50,7 +50,7 @@ description: Complete reference and atomic index for Katlux data management arch
|
|
|
50
50
|
| `RequestQueue` | Offline PWA operation queue | Queues mutations offline in IndexedDB, auto-flushes on reconnect | [RequestQueue.md](providers/RequestQueue.md) |
|
|
51
51
|
| `KatluxIndexedDB` | High-performance IndexedDB wrapper | Client-side persistent storage for offline data and large cache entries | [KatluxIndexedDB.md](providers/KatluxIndexedDB.md) |
|
|
52
52
|
| `CacheProvider` | Tiered multi-layer caching engine | Memory, BrowserSession, LocalStorage, IndexedDB, Cookie tiers | [caching.md](providers/caching.md) |
|
|
53
|
-
| `EncryptionProvider` & `CKeyManager` | WebCrypto & NodeCrypto cryptographic suite | AES-GCM
|
|
53
|
+
| `EncryptionProvider` & `CKeyManager` | WebCrypto & NodeCrypto cryptographic suite | AES-GCM, asymmetric hybrid, ADEK re-wrapping, RFC 8785 grants, domain KDF, TOFU pinning, streaming AEAD, blind indexing | [encryption.md](providers/encryption.md) (Index: [threat-model](providers/encryption-threat-model.md) · [symmetric](providers/encryption-symmetric.md) · [asymmetric](providers/encryption-asymmetric.md) · [key-mgmt](providers/encryption-key-management.md) · [key-pinning](providers/encryption-key-pinning.md) · [streaming](providers/encryption-streaming.md) · [field-level](providers/encryption-field-level.md)) |
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
| `cacheLifetime` | `number` | `undefined` | Cache expiration in milliseconds |
|
|
24
24
|
| `filterDebounce` | `number` | `300` | Debounce time in ms for `setFilter` |
|
|
25
25
|
| `sortDebounce` | `number` | `200` | Debounce time in ms for `setSortList` |
|
|
26
|
-
| `context` | `
|
|
27
|
-
| `nuxtApp` | `
|
|
26
|
+
| `context` | `Record<string, unknown>` | `undefined` | Framework-agnostic SSR context (React SSR state, Next.js context, or Nuxt app instance) |
|
|
27
|
+
| `nuxtApp` | `unknown` | `undefined` | *(Deprecated, use `context`)* Nuxt app instance for backward compatibility |
|
|
28
28
|
| `refreshOnMutation` | `boolean` | `true` | Reload data after `create`/`update`/`delete` |
|
|
29
29
|
|
|
30
30
|
### State Properties (Pure native TypeScript properties)
|
|
31
31
|
- **`pageData`**: `T[]` - Current visible slice of data.
|
|
32
32
|
- **`rowCount`**: `number` - Total results (filtered count or server total).
|
|
33
33
|
- **`loading`**: `boolean` - Active data operation status.
|
|
34
|
-
- **`error`**: `
|
|
34
|
+
- **`error`**: `Error | unknown` - Last error encountered during fetch.
|
|
35
35
|
- **`currentPage`**: `number` - Active page index (1-based).
|
|
36
36
|
- **`pageSize`**: `number` - Items per page.
|
|
37
37
|
- **`filter`**: `IDataFilter | null` - Active filter configuration.
|
|
@@ -7,9 +7,9 @@ Specialized versions that fetch a dataset **once** from an API and then manage i
|
|
|
7
7
|
| `setAPIUrl(url)` | `string` | Sets endpoint and triggers initial fetch |
|
|
8
8
|
| `refresh(hardRefresh?)`| `boolean` | Manually refetch the entire dataset. Cache will only be overridden if `hardRefresh` parameter is true. |
|
|
9
9
|
| `setFilter(filter)` | `IDataFilter \| null` | Applies a structured filter to the locally cached dataset. Filtering runs client-side via `useFilterLogic()`. Resets to page 1. |
|
|
10
|
-
| `create(item)` | `
|
|
11
|
-
| `update(item)` | `
|
|
12
|
-
| `delete(items)` | `
|
|
10
|
+
| `create(item)` | `TRow` | POST to API and update local state |
|
|
11
|
+
| `update(item)` | `TRow` | PUT to API and update local item |
|
|
12
|
+
| `delete(items)` | `TRow[]` | DELETE from API and remove locally |
|
|
13
13
|
- **`filter`**: `Ref<IDataFilter | null>` - The currently active filter configuration.
|
|
14
14
|
|
|
15
15
|
### Tree-Specific methods (Client Providers)
|
|
@@ -16,9 +16,9 @@ Handle full API integration with automatic query generation. Pagination, filteri
|
|
|
16
16
|
| --- | --- | --- |
|
|
17
17
|
| `refresh(hardRefresh?)`| `boolean` | Manual trigger for reload. Cache will only be overridden if `hardRefresh` parameter is true. |
|
|
18
18
|
| `loadPageData(opts)` | `{ disableCache?: boolean }` | Core logic for data retrieval |
|
|
19
|
-
| `create(item)` | `
|
|
20
|
-
| `update(item)` | `
|
|
21
|
-
| `delete(items)` | `
|
|
19
|
+
| `create(item)` | `TRow` | Async POST request to creation endpoint |
|
|
20
|
+
| `update(item)` | `TRow` | Async PUT request to update endpoint |
|
|
21
|
+
| `delete(items)` | `TRow[]` | Async batch deletion via endpoint |
|
|
22
22
|
|
|
23
23
|
#### Server-Side Encrypted Datatable & Search Integration
|
|
24
24
|
When querying backend persistence endpoints (e.g. server-side datatable backends or Cloudflare stateless edge workers) that store and return encrypted records:
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
### `CFlatClientDataProvider`
|
|
2
2
|
Manages local arrays with client-side logic, extending `AEncryptedClientProvider`.
|
|
3
|
-
- **`setData(data:
|
|
4
|
-
- **`setDataChunked(data:
|
|
3
|
+
- **`setData(data: TRow[]): Promise<void> | void`**: Ingests dataset into provider. When encryption is enabled, eagerly encrypts designated `fields` before storing in `allData`. Plaintext never persists in `allData`. Pre-encrypted envelopes (`__encrypted: true`) pass through unchanged (idempotent). Zero overhead synchronous fast-path when encryption is disabled.
|
|
4
|
+
- **`setDataChunked(data: TRow[], options?: ISetDataChunkedOptions): Promise<void>`**: Ingests massive datasets in batches, yielding to the event loop between chunks to keep the browser UI responsive (`chunkSize`, `onProgress`, `yieldStrategy`).
|
|
5
5
|
- **`setEncryption(options)` / `clearEncryption()`**: Dynamically updates, rotates, or wipes cryptographic keys and cached ciphers at runtime.
|
|
6
|
-
- **`allData`**: `Ref<
|
|
7
|
-
- **`pageData`**: `Ref<
|
|
6
|
+
- **`allData`**: `Ref<TRow[]>` - The complete source dataset (holds ciphertext for encrypted fields in JS memory).
|
|
7
|
+
- **`pageData`**: `Ref<TRow[]>` - Active visible page slice (lazily decrypted into plaintext on active page render). Only `pageSize` rows are plaintext in JS memory.
|
|
8
8
|
- **`rowMap`**: `readonly TRow[]` - Reference map array maintaining the active filtered & sorted row references. When a page is requested, a portion of this array is served directly in $O(1)$ without re-evaluating filters or sorts.
|
|
9
9
|
- **`updateMap()`**: Explicitly forces recalculation of the `rowMap` if items inside `allData` were modified in-place.
|
|
10
10
|
- **`setFilter(filter: IDataFilter | null, immediate: boolean = false)`**: Applies a structured filter. When `encryption.searchIndex: true`, performs exact match (`==`, `!=`) and substring search (`in`) on encrypted fields using HMAC-SHA256 blind index tokens and trigram sets via `CSearchIndex`. Resets to page 1.
|
|
@@ -15,7 +15,7 @@ Handler-based server-side flat data provider that delegates pagination, filterin
|
|
|
15
15
|
- **Reactive Properties**:
|
|
16
16
|
| Property | Type | Description |
|
|
17
17
|
| --- | --- | --- |
|
|
18
|
-
| `pageData` | `Ref<
|
|
18
|
+
| `pageData` | `Ref<TRow[]>` | Current page slice of records |
|
|
19
19
|
| `rowCount` | `Ref<number>` | Total matching record count returned by the handler |
|
|
20
20
|
| `loading` | `Ref<boolean>` | Reactive fetching indicator |
|
|
21
21
|
| `currentPage` | `Ref<number>` | Current page index (triggers reload when modified) |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
### `CTreeClientDataProvider`
|
|
2
2
|
Builds and manages reactive trees from flat arrays, extending `CFlatClientDataProvider`.
|
|
3
|
-
- **`setData(data:
|
|
4
|
-
- **`setDataChunked(data:
|
|
3
|
+
- **`setData(data: TRow[]): Promise<void> | void`**: Ingests hierarchical items. Encrypts sensitive fields eagerly while preserving structural keys (`idKey`, `parentKey`) in plaintext.
|
|
4
|
+
- **`setDataChunked(data: TRow[], options?: ISetDataChunkedOptions)`**: Non-blocking chunked ingestion for large trees.
|
|
5
5
|
- **Constructor Options (`ITreeDataProviderOptions`)**:
|
|
6
6
|
| Option | Type | Default | Description |
|
|
7
7
|
| --- | --- | --- | --- |
|
|
@@ -7,7 +7,7 @@ The core engine for all HTTP communication, supporting deduplication, tag-based
|
|
|
7
7
|
| `setCacheProvider(provider)` | `ACacheProvider \| ECacheStrategy` | Configures global caching strategy |
|
|
8
8
|
| `setCacheLifetime(ms)` | `number` | Sets default global expiration (milliseconds) |
|
|
9
9
|
| `setDeduplicate(bool)` | `boolean` | Toggle request deduplication |
|
|
10
|
-
| `onDataReceived(cb)` |
|
|
10
|
+
| `onDataReceived(cb)` | `<T = unknown>(data: T, generation?: number) => void` | Registers a callback triggered when data is successfully received (passes request generation if available) |
|
|
11
11
|
| `refresh(hardRefresh)` | `boolean` | Re-runs the last request. Cache will only be overridden if `hardRefresh` parameter is true. |
|
|
12
12
|
|
|
13
13
|
- **Constructor**: `new RequestProvider(provider?, lifetime?, deduplicate?, tags?)`
|
|
@@ -20,8 +20,8 @@ The core engine for all HTTP communication, supporting deduplication, tag-based
|
|
|
20
20
|
| Property | Type | Description |
|
|
21
21
|
| --- | --- | --- |
|
|
22
22
|
| `method` | `string` | HTTP method (`'GET'`, `'POST'`, `'PUT'`, `'DELETE'`, `'PATCH'`. Default: `'GET'`) |
|
|
23
|
-
| `body` | `any` | Request body data |
|
|
24
|
-
| `query` | `Record<string,
|
|
23
|
+
| `body` | `any` | Request body data (transport payload) |
|
|
24
|
+
| `query` | `Record<string, unknown>` | URL query parameters |
|
|
25
25
|
| `headers` | `Record<string, string>` | Custom HTTP headers |
|
|
26
26
|
| `cacheStrategy` | `ECacheStrategy` | Override global strategy for this request |
|
|
27
27
|
| `lifetime` | `number` | Override global expiration for this request |
|
|
@@ -32,7 +32,7 @@ The core engine for all HTTP communication, supporting deduplication, tag-based
|
|
|
32
32
|
| `tags` | `string[]` | Associated tags for invalidation / auto-refresh upon mutation |
|
|
33
33
|
| `queue` | `boolean` | When true (for non-GET requests), enqueues the mutation into `RequestQueue` instead of dispatching immediately |
|
|
34
34
|
| `label` | `string` | Human-readable description for queued mutation display in UI |
|
|
35
|
-
| `nuxtApp` | `
|
|
35
|
+
| `nuxtApp` | `unknown` | Nuxt app instance — enables SSR cookie forwarding via h3 |
|
|
36
36
|
| `_generation` | `number` | Internal request generation counter to discard stale responses |
|
|
37
37
|
|
|
38
38
|
### `RequestProviderRegistry`
|
|
@@ -25,7 +25,7 @@ Standard interface for persistence strategies. **Note**: `ACacheProvider` is an
|
|
|
25
25
|
| Method | Params | Description |
|
|
26
26
|
| --- | --- | --- |
|
|
27
27
|
| `get<T>(key)` | `string` | Retrieves cached value |
|
|
28
|
-
| `set<T>(key, val, life)`| `string,
|
|
28
|
+
| `set<T>(key, val, life)`| `string, T, number`| Persists value with lifetime (ms) |
|
|
29
29
|
| `remove(key)` | `string` | Evicts specific entry |
|
|
30
30
|
| `removeByPrefix(pre)`| `string` | Bulk eviction (e.g., by resource URL) |
|
|
31
31
|
| `getRemainingTime(key)`| `string` | Returns remaining TTL in ms |
|
|
@@ -66,7 +66,7 @@ import { ACacheProvider, type ICacheEntry } from '@katlux/providers'
|
|
|
66
66
|
|
|
67
67
|
export class CMyCustomCache extends ACacheProvider {
|
|
68
68
|
private static instance: CMyCustomCache | null = null
|
|
69
|
-
private storage = new Map<string, ICacheEntry<
|
|
69
|
+
private storage = new Map<string, ICacheEntry<unknown>>()
|
|
70
70
|
|
|
71
71
|
public static getInstance(): CMyCustomCache {
|
|
72
72
|
if (!this.instance) {
|
|
@@ -75,11 +75,11 @@ export class CMyCustomCache extends ACacheProvider {
|
|
|
75
75
|
return this.instance
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
async getKeyList(nuxtApp?:
|
|
78
|
+
async getKeyList(nuxtApp?: unknown): Promise<string[]> {
|
|
79
79
|
return Array.from(this.storage.keys())
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
async get<T>(key: string, nuxtApp?:
|
|
82
|
+
async get<T>(key: string, nuxtApp?: unknown): Promise<T | null> {
|
|
83
83
|
const entry = this.storage.get(key)
|
|
84
84
|
if (!entry) return null
|
|
85
85
|
if (Date.now() > entry.timestamp + entry.lifetime) {
|
|
@@ -89,21 +89,21 @@ export class CMyCustomCache extends ACacheProvider {
|
|
|
89
89
|
return entry.data as T
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
async set<T>(key: string, data: T, lifetime: number, nuxtApp?:
|
|
92
|
+
async set<T>(key: string, data: T, lifetime: number, nuxtApp?: unknown): Promise<void> {
|
|
93
93
|
this.storage.set(key, { data, timestamp: Date.now(), lifetime })
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
async remove(key: string, nuxtApp?:
|
|
96
|
+
async remove(key: string, nuxtApp?: unknown): Promise<void> {
|
|
97
97
|
this.storage.delete(key)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
async removeByPrefix(prefix: string, nuxtApp?:
|
|
100
|
+
async removeByPrefix(prefix: string, nuxtApp?: unknown): Promise<void> {
|
|
101
101
|
for (const key of this.storage.keys()) {
|
|
102
102
|
if (key.startsWith(prefix)) this.storage.delete(key)
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
async getRemainingTime(key: string, nuxtApp?:
|
|
106
|
+
async getRemainingTime(key: string, nuxtApp?: unknown): Promise<number | null> {
|
|
107
107
|
const entry = this.storage.get(key)
|
|
108
108
|
if (!entry) return null
|
|
109
109
|
const remaining = (entry.timestamp + entry.lifetime) - Date.now()
|
|
@@ -151,14 +151,14 @@ Pass the strategy name to any provider or fetch directly via `CacheProviderFacto
|
|
|
151
151
|
|
|
152
152
|
```typescript
|
|
153
153
|
// 1. With RequestProvider:
|
|
154
|
-
const request = new RequestProvider('MyCustom' as
|
|
154
|
+
const request = new RequestProvider('MyCustom' as unknown as ECacheStrategy, 60_000)
|
|
155
155
|
// or dynamically:
|
|
156
|
-
request.setCacheProvider('MyCustom' as
|
|
156
|
+
request.setCacheProvider('MyCustom' as unknown as ECacheStrategy)
|
|
157
157
|
|
|
158
158
|
// 2. With Data Providers:
|
|
159
159
|
const dataProvider = new CAPIFlatServerDataProvider({
|
|
160
160
|
pageSize: 20,
|
|
161
|
-
cacheStrategy: 'MyCustom' as
|
|
161
|
+
cacheStrategy: 'MyCustom' as unknown as ECacheStrategy,
|
|
162
162
|
cacheLifetime: 300_000
|
|
163
163
|
})
|
|
164
164
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Katlux Encryption Architecture: Asymmetric & Hybrid Cipher Providers
|
|
2
|
+
|
|
3
|
+
> Part of the Katlux Cryptographic Architecture (`@katlux/providers`).
|
|
4
|
+
> See [encryption.md](encryption.md) for the master index.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 1. Overview of Hybrid Asymmetric Ciphers
|
|
9
|
+
|
|
10
|
+
Asymmetric cryptography alone cannot efficiently encrypt arbitrary-sized payloads. Katlux hybrid providers combine public-key cryptography with AES-256-GCM symmetric session keys:
|
|
11
|
+
- The sender generates a random 256-bit AES-GCM Data Encryption Key (DEK).
|
|
12
|
+
- The DEK encrypts the payload.
|
|
13
|
+
- The recipient's public key encrypts/derives the DEK.
|
|
14
|
+
- Only the holder of the recipient's private key can decrypt the DEK and recover the payload.
|
|
15
|
+
|
|
16
|
+
| Provider | Asymmetric Primitive | Symmetric Primitive | Primary Use Case |
|
|
17
|
+
| :--- | :--- | :--- | :--- |
|
|
18
|
+
| `CRSAEncryptionProvider` | RSA-OAEP-4096 / 2048 | AES-GCM-256 | Single-recipient arbitrary payload encryption, user keypair delivery |
|
|
19
|
+
| `CECDHEncryptionProvider` | ECDH (P-256, P-384, P-521) + HKDF | AES-GCM-256 | Forward-secure ephemeral key exchange, role-based key sharing |
|
|
20
|
+
|
|
21
|
+
> [!IMPORTANT]
|
|
22
|
+
> **Sender Authenticity Boundary**:
|
|
23
|
+
> Asymmetric hybrid encryption provides **recipient confidentiality**, not sender authenticity. Anyone with the recipient's public key can encrypt envelopes. For write authenticity, combine with digital signatures (`CKeyManager.sign` / `CKeyManager.verify`) or symmetric role keys.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 2. `CRSAEncryptionProvider` (RSA-OAEP-4096 Hybrid)
|
|
28
|
+
|
|
29
|
+
Combines RSA-OAEP key wrapping with AES-256-GCM payload encryption.
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
```ts
|
|
33
|
+
import { CRSAEncryptionProvider, CKeyManager } from '@katlux/providers'
|
|
34
|
+
|
|
35
|
+
// 1. Generate or import recipient keypair:
|
|
36
|
+
const keypair = await CKeyManager.generateRSAKeyPair(4096, 'SHA-256', true)
|
|
37
|
+
|
|
38
|
+
// 2. Sender configures provider with recipient public key:
|
|
39
|
+
const senderCipher = new CRSAEncryptionProvider({
|
|
40
|
+
recipientPublicKey: keypair.publicKey
|
|
41
|
+
})
|
|
42
|
+
const envelope = await senderCipher.encrypt({ secretDocument: 'Confidential content' })
|
|
43
|
+
|
|
44
|
+
// 3. Recipient configures provider with private key:
|
|
45
|
+
const recipientCipher = new CRSAEncryptionProvider({
|
|
46
|
+
recipientPrivateKey: keypair.privateKey
|
|
47
|
+
})
|
|
48
|
+
const data = await recipientCipher.decrypt(envelope)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 3. `CECDHEncryptionProvider` (ECDH Ephemeral Hybrid)
|
|
54
|
+
|
|
55
|
+
Uses Elliptic Curve Diffie-Hellman (P-256 by default) with an ephemeral keypair per encryption operation, stretched via HKDF to derive an AES-256-GCM key.
|
|
56
|
+
|
|
57
|
+
### Basic Usage
|
|
58
|
+
```ts
|
|
59
|
+
import { CECDHEncryptionProvider, CKeyManager } from '@katlux/providers'
|
|
60
|
+
|
|
61
|
+
// 1. Recipient generates ECDH keypair:
|
|
62
|
+
const keypair = await CKeyManager.generateECDHKeyPair('P-256')
|
|
63
|
+
|
|
64
|
+
// 2. Sender encrypts using recipient's public key (generates fresh ephemeral key):
|
|
65
|
+
const senderCipher = new CECDHEncryptionProvider({
|
|
66
|
+
recipientPublicKey: keypair.publicKey,
|
|
67
|
+
curve: 'P-256',
|
|
68
|
+
info: 'tenant-sharing-v1'
|
|
69
|
+
})
|
|
70
|
+
const envelope = await senderCipher.encrypt({ tenantKey: 'wrapped-bytes' })
|
|
71
|
+
// Envelope contains `epk` (ephemeral public key in JWK format)
|
|
72
|
+
|
|
73
|
+
// 3. Recipient derives matching shared secret and decrypts:
|
|
74
|
+
const recipientCipher = new CECDHEncryptionProvider({
|
|
75
|
+
recipientPrivateKey: keypair.privateKey,
|
|
76
|
+
curve: 'P-256',
|
|
77
|
+
info: 'tenant-sharing-v1'
|
|
78
|
+
})
|
|
79
|
+
const decrypted = await recipientCipher.decrypt(envelope)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## 4. PEM Key Import & Export (`CKeyManager`)
|
|
85
|
+
|
|
86
|
+
Katlux providers natively support standard SPKI and PKCS#8 PEM strings without third-party libraries:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { CKeyManager } from '@katlux/providers'
|
|
90
|
+
|
|
91
|
+
// Exporting keys:
|
|
92
|
+
const publicPem = await CKeyManager.exportPublicKeyToPEM(keypair.publicKey)
|
|
93
|
+
const privatePem = await CKeyManager.exportPrivateKeyToPEM(keypair.privateKey)
|
|
94
|
+
|
|
95
|
+
// Importing keys:
|
|
96
|
+
const importedPubKey = await CKeyManager.importPublicKeyFromPEM(publicPem, 'RSA-OAEP', undefined, 'SHA-256')
|
|
97
|
+
const importedPrivKey = await CKeyManager.importPrivateKeyFromPEM(privatePem, 'RSA-OAEP', undefined, 'SHA-256')
|
|
98
|
+
|
|
99
|
+
// ECDSA signing keys:
|
|
100
|
+
const ecdsaPubKey = await CKeyManager.importECDSAPublicKeyFromPEM(ecdsaPubPem, 'P-256')
|
|
101
|
+
const ecdsaPrivKey = await CKeyManager.importECDSAPrivateKeyFromPEM(ecdsaPrivPem, 'P-256')
|
|
102
|
+
```
|