dphelper 4.5.2 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COPYRIGHT.md +6 -6
- package/FUNDING.yml +12 -12
- package/LICENSE.md +21 -21
- package/README.md +397 -397
- package/SECURITY.md +26 -26
- package/SUMMARY.md +83 -83
- package/index.cjs +2 -2
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/llms.txt +73 -73
- package/modules/ai.cjs +1 -1
- package/modules/ai.d.ts +11 -11
- package/modules/ai.js +1 -1
- package/modules/anchor.cjs +1 -1
- package/modules/anchor.d.ts +6 -6
- package/modules/anchor.js +1 -1
- package/modules/array.cjs +1 -1
- package/modules/array.d.ts +21 -21
- package/modules/array.js +1 -1
- package/modules/audio.cjs +1 -1
- package/modules/audio.d.ts +10 -10
- package/modules/audio.js +1 -1
- package/modules/avoid.cjs +1 -1
- package/modules/avoid.d.ts +2 -2
- package/modules/avoid.js +1 -1
- package/modules/biometric.cjs +1 -1
- package/modules/biometric.d.ts +14 -14
- package/modules/biometric.js +1 -1
- package/modules/browser.cjs +1 -1
- package/modules/browser.d.ts +10 -10
- package/modules/browser.js +1 -1
- package/modules/check.cjs +1 -1
- package/modules/check.d.ts +4 -4
- package/modules/check.js +1 -1
- package/modules/color.cjs +1 -1
- package/modules/color.d.ts +6 -6
- package/modules/color.js +1 -1
- package/modules/compress.cjs +1 -1
- package/modules/compress.d.ts +13 -13
- package/modules/compress.js +1 -1
- package/modules/cookie.cjs +1 -1
- package/modules/cookie.d.ts +12 -12
- package/modules/cookie.js +1 -1
- package/modules/coords.cjs +1 -1
- package/modules/coords.d.ts +8 -8
- package/modules/coords.js +1 -1
- package/modules/credits.cjs +1 -1
- package/modules/credits.d.ts +11 -11
- package/modules/credits.js +1 -1
- package/modules/date.cjs +1 -1
- package/modules/date.d.ts +25 -25
- package/modules/date.js +1 -1
- package/modules/disable.cjs +1 -1
- package/modules/disable.d.ts +8 -8
- package/modules/disable.js +1 -1
- package/modules/dispatch.cjs +1 -1
- package/modules/dispatch.d.ts +4 -4
- package/modules/dispatch.js +1 -1
- package/modules/elements.cjs +1 -1
- package/modules/elements.d.ts +3 -3
- package/modules/elements.js +1 -1
- package/modules/events.cjs +1 -1
- package/modules/events.d.ts +6 -6
- package/modules/events.js +1 -1
- package/modules/fetch.cjs +1 -1
- package/modules/fetch.d.ts +15 -15
- package/modules/fetch.js +1 -1
- package/modules/form.cjs +1 -1
- package/modules/form.d.ts +13 -13
- package/modules/form.js +1 -1
- package/modules/format.cjs +1 -1
- package/modules/format.d.ts +3 -3
- package/modules/format.js +1 -1
- package/modules/i18n.cjs +1 -1
- package/modules/i18n.d.ts +11 -11
- package/modules/i18n.js +1 -1
- package/modules/image.cjs +1 -1
- package/modules/image.d.ts +13 -13
- package/modules/image.js +1 -1
- package/modules/json.cjs +1 -1
- package/modules/json.d.ts +8 -8
- package/modules/json.js +1 -1
- package/modules/load.cjs +1 -1
- package/modules/load.d.ts +8 -8
- package/modules/load.js +1 -1
- package/modules/logging.cjs +1 -1
- package/modules/logging.d.ts +8 -8
- package/modules/logging.js +1 -1
- package/modules/math.cjs +1 -1
- package/modules/math.d.ts +13 -13
- package/modules/math.js +1 -1
- package/modules/memory.cjs +1 -1
- package/modules/memory.d.ts +3 -3
- package/modules/memory.js +1 -1
- package/modules/navigation.cjs +1 -1
- package/modules/navigation.d.ts +4 -4
- package/modules/navigation.js +1 -1
- package/modules/net.cjs +1 -1
- package/modules/net.d.ts +10 -10
- package/modules/net.js +1 -1
- package/modules/objects.cjs +1 -1
- package/modules/objects.d.ts +15 -15
- package/modules/objects.js +1 -1
- package/modules/path.cjs +1 -1
- package/modules/path.d.ts +4 -4
- package/modules/path.js +1 -1
- package/modules/promise.cjs +1 -1
- package/modules/promise.d.ts +3 -3
- package/modules/promise.js +1 -1
- package/modules/sanitize.cjs +1 -1
- package/modules/sanitize.d.ts +2 -2
- package/modules/sanitize.js +1 -1
- package/modules/screen.cjs +1 -1
- package/modules/screen.d.ts +11 -11
- package/modules/screen.js +1 -1
- package/modules/scrollbar.cjs +1 -1
- package/modules/scrollbar.d.ts +9 -9
- package/modules/scrollbar.js +1 -1
- package/modules/security.cjs +1 -1
- package/modules/security.d.ts +15 -15
- package/modules/security.js +1 -1
- package/modules/shortcut.cjs +1 -1
- package/modules/shortcut.d.ts +2 -2
- package/modules/shortcut.js +1 -1
- package/modules/socket.cjs +1 -1
- package/modules/socket.d.ts +13 -13
- package/modules/socket.js +1 -1
- package/modules/sse.cjs +1 -1
- package/modules/sse.d.ts +8 -8
- package/modules/sse.js +1 -1
- package/modules/svg.cjs +1 -1
- package/modules/svg.d.ts +12 -12
- package/modules/svg.js +1 -1
- package/modules/sync.cjs +1 -1
- package/modules/sync.d.ts +13 -13
- package/modules/sync.js +1 -1
- package/modules/system.cjs +1 -1
- package/modules/system.d.ts +2 -2
- package/modules/system.js +1 -1
- package/modules/text.cjs +2 -2
- package/modules/text.d.ts +13 -12
- package/modules/text.js +2 -2
- package/modules/timer.cjs +1 -1
- package/modules/timer.d.ts +3 -3
- package/modules/timer.js +1 -1
- package/modules/tools.cjs +1 -1
- package/modules/tools.d.ts +5 -5
- package/modules/tools.js +1 -1
- package/modules/translators.cjs +1 -1
- package/modules/translators.d.ts +2 -2
- package/modules/translators.js +1 -1
- package/modules/triggers.cjs +1 -1
- package/modules/triggers.d.ts +43 -43
- package/modules/triggers.js +1 -1
- package/modules/types.cjs +1 -1
- package/modules/types.d.ts +5 -5
- package/modules/types.js +1 -1
- package/modules/ui.cjs +1 -1
- package/modules/ui.d.ts +3 -3
- package/modules/ui.js +1 -1
- package/modules/window.cjs +1 -1
- package/modules/window.d.ts +9 -9
- package/modules/window.js +1 -1
- package/modules/worker.cjs +1 -1
- package/modules/worker.d.ts +16 -16
- package/modules/worker.js +1 -1
- package/package.json +2 -2
- package/sbom.json +14 -9
- package/types/dphelper.d.ts +546 -545
- package/types/global.d.ts +8 -8
package/README.md
CHANGED
|
@@ -1,397 +1,397 @@
|
|
|
1
|
-
# [dphelper](https://npmjs.com/package/dphelper)
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
|
|
5
|
-
> **The supercharged toolkit for modern web development, AI engineering & DevTools.**
|
|
6
|
-
|
|
7
|
-
[](https://npmjs.org/package/dphelper)
|
|
8
|
-
[](https://npmjs.org/package/dphelper)
|
|
9
|
-
|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
|
|
13
|
-

|
|
14
|
-

|
|
15
|
-

|
|
16
|
-
|
|
17
|
-

|
|
18
|
-

|
|
19
|
-
[](https://playwright.dev/)
|
|
20
|
-
|
|
21
|
-

|
|
22
|
-

|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
## Table of Contents
|
|
27
|
-
|
|
28
|
-
1. [About](#about)
|
|
29
|
-
2. [Installation](#installation)
|
|
30
|
-
3. [AI Power User Guide](#ai-power-user-guide)
|
|
31
|
-
4. [Modular Architecture](#modular-architecture)
|
|
32
|
-
5. [Browser Extension (Chrome/Edge)](#browser-extension-chromeedge)
|
|
33
|
-
6. [Environment Compatibility](#environment-compatibility)
|
|
34
|
-
7. [Security](#security)
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## About
|
|
39
|
-
|
|
40
|
-
**dphelper** is a powerful, zero-dependency utility library that brings together **production-ready tools** for web developers, AI engineers, and DevTools creators.
|
|
41
|
-
|
|
42
|
-
Think of it as your **universal toolbox** - from DOM manipulation to cryptographic operations, from real-time WebSocket handling to AI-powered token optimization. No more juggling multiple packages. One import, infinite possibilities.
|
|
43
|
-
|
|
44
|
-
### Why dphelper?
|
|
45
|
-
|
|
46
|
-
- **⚡ Zero Dependencies** - Pure vanilla JavaScript/TypeScript. No bloat, no surprises.
|
|
47
|
-
- **🤖 AI-First Design** - Built for LLM apps with TOON optimization, token counting, and RAG support.
|
|
48
|
-
- **🌐 Universal** - Works in browser, Node.js, Bun, and Deno.
|
|
49
|
-
- **🔒 Type-Safe** - Full TypeScript definitions auto-generated for every tool.
|
|
50
|
-
- **📦 Tiny Bundle** - Only ~171KB minified, tree-shakeable.
|
|
51
|
-
- **🔐 Security First** - NIST/NSA compliant, CNSA algorithms, PBKDF2 310k iterations
|
|
52
|
-
|
|
53
|
-
> [!NOTE]
|
|
54
|
-
> **Network Access:** This library includes networking primitives (`fetch`, `sse`, `socket`) by design for modern web development. Callers are responsible for validating and sanitizing URLs before use. See the [Security](#security) section for best practices.
|
|
55
|
-
|
|
56
|
-
> *"dphelper is what you'd build if you combined lodash, socket.io, and an AI SDK - but lighter."*
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## State and Store removed from dpHelper
|
|
61
|
-
|
|
62
|
-
> [!IMPORTANT]
|
|
63
|
-
> dpHelper do not integrate state management directly anymore
|
|
64
|
-
>
|
|
65
|
-
> Application state is currently handled through **Memorio** or **RGS**.
|
|
66
|
-
|
|
67
|
-
If you need to use state/store management please consider:
|
|
68
|
-
|
|
69
|
-
- [Memorio](http://www.npmjs.com/package/memorio) - State and Store Manager
|
|
70
|
-
- [Argis RGS](https://www.npmjs.com/package/@biglogic/rgs) - Enterprise Lever State Manager
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## Installation
|
|
75
|
-
|
|
76
|
-
```shell
|
|
77
|
-
npm i dphelper --save-dev
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Usage
|
|
81
|
-
|
|
82
|
-
Import it precisely **once** in your entry point (e.g., `index.js`, `main.ts`, or `App.tsx`):
|
|
83
|
-
|
|
84
|
-
```js
|
|
85
|
-
// IMPORT ONCE AT YOUR APP ENTRY POINT
|
|
86
|
-
|
|
87
|
-
import "dphelper";
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Modular imports
|
|
91
|
-
|
|
92
|
-
For a smaller bundle or cleaner tree-shaking, import only the tool you need. Each modular entry point exposes the tool both as a **named export** and on the **global `dphelper`** object, so existing global-usage code keeps working unchanged.
|
|
93
|
-
|
|
94
|
-
```ts
|
|
95
|
-
import { sanitize } from "dphelper/sanitize"
|
|
96
|
-
import { format } from "dphelper/format"
|
|
97
|
-
import { fetch } from "dphelper/fetch"
|
|
98
|
-
import { security } from "dphelper/security"
|
|
99
|
-
|
|
100
|
-
sanitize.html("<strong>safe text</strong>")
|
|
101
|
-
format.currency(1234.56, "en-US", "USD")
|
|
102
|
-
await fetch.get("https://api.example.com")
|
|
103
|
-
security.ulid()
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
The same tool is also available on the global after import:
|
|
107
|
-
|
|
108
|
-
```ts
|
|
109
|
-
import "dphelper/format"
|
|
110
|
-
|
|
111
|
-
// Identical to the named export above
|
|
112
|
-
dphelper.format.currency(1234.56, "en-US", "USD")
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
> [!NOTE]
|
|
116
|
-
> Every tool under `tools/` is published as `dphelper/<tool>` (e.g. `dphelper/array`, `dphelper/i18n`, `dphelper/worker`). The full list is generated automatically from the `tools/` directory at build time, so adding a new tool creates its modular entry point with no extra configuration.
|
|
117
|
-
|
|
118
|
-
> [!IMPORTANT]
|
|
119
|
-
> **TypeScript + `resolvePackageJsonExports`:** Modular subpath imports (e.g. `import { sanitize } from "dphelper/sanitize"`) are resolved through the `exports` map in `dphelper`'s `package.json`. If your `tsconfig.json` sets `"resolvePackageJsonExports": false`, TypeScript will fall back to physical path resolution and fail with `Cannot find module 'dphelper/<tool>' or its corresponding type declarations` (TS2307), because the tool actually lives under `modules/<tool>` rather than at the package root.
|
|
120
|
-
>
|
|
121
|
-
> To fix it, either:
|
|
122
|
-
> - keep `"resolvePackageJsonExports": true` (the default for `moduleResolution: "bundler"`), or
|
|
123
|
-
> - import from the physical path: `import { sanitize } from "dphelper/modules/sanitize"`.
|
|
124
|
-
>
|
|
125
|
-
> Note: this is a TypeScript-only resolution issue. Vite and other bundlers resolve the subpath correctly at build/runtime via the `exports` map regardless of that flag.
|
|
126
|
-
|
|
127
|
-
For plain HTML/CDN:
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<script src="https://unpkg.com/dphelper/dphelper.js"></script>
|
|
131
|
-
|
|
132
|
-
<!-- Optional check -->
|
|
133
|
-
<script>
|
|
134
|
-
console.debug(dphelper.version); // latest version
|
|
135
|
-
console.debug(dphelper.isBrowser); // true
|
|
136
|
-
</script>
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## ⚙️ Web Worker Module
|
|
142
|
-
|
|
143
|
-
```javascript
|
|
144
|
-
// Create worker from file
|
|
145
|
-
const worker = dphelper.worker.create('worker.js', {
|
|
146
|
-
onmessage: (e) => console.log(e.data)
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Create inline worker
|
|
150
|
-
const inlineWorker = dphelper.worker.createInline(`
|
|
151
|
-
self.onmessage = e => postMessage(e.data * 2);
|
|
152
|
-
`);
|
|
153
|
-
|
|
154
|
-
// Worker pool for parallel processing
|
|
155
|
-
const pool = dphelper.worker.pool('worker.js', 4);
|
|
156
|
-
const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
|
|
157
|
-
|
|
158
|
-
// SharedWorker for cross-tab communication
|
|
159
|
-
const shared = dphelper.worker.shared('worker.js', { name: 'my-shared' });
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 🌍 i18n Module
|
|
165
|
-
|
|
166
|
-
```javascript
|
|
167
|
-
// Set locale
|
|
168
|
-
dphelper.i18n.setLocale('it');
|
|
169
|
-
|
|
170
|
-
// Add translations
|
|
171
|
-
dphelper.i18n.addTranslations('it', {
|
|
172
|
-
hello: 'Ciao {name}!',
|
|
173
|
-
items: '{count, plural, one{# item} other{# items}}'
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
// Translate with interpolation
|
|
177
|
-
dphelper.i18n.t('hello', { name: 'World' }); // "Ciao World!"
|
|
178
|
-
|
|
179
|
-
// Pluralize
|
|
180
|
-
dphelper.i18n.pluralize(5, { one: 'item', other: 'items' }); // "items"
|
|
181
|
-
|
|
182
|
-
// Format number/currency
|
|
183
|
-
dphelper.i18n.number(1234.56, 'de-DE', { style: 'currency', currency: 'EUR' });
|
|
184
|
-
|
|
185
|
-
// Relative time
|
|
186
|
-
dphelper.i18n.relativeTime(Date.now() - 3600000); // "1 hour ago"
|
|
187
|
-
```
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
## 🗜️ Compression Module
|
|
191
|
-
|
|
192
|
-
```javascript
|
|
193
|
-
// Gzip compression
|
|
194
|
-
const compressed = await dphelper.compress.gzip('Hello World');
|
|
195
|
-
const decompressed = await dphelper.compress.gunzip(compressed);
|
|
196
|
-
|
|
197
|
-
// Base64 encoding
|
|
198
|
-
const encoded = dphelper.compress.base64Encode('Hello');
|
|
199
|
-
const decoded = dphelper.compress.base64Decode(encoded);
|
|
200
|
-
|
|
201
|
-
// URL encoding
|
|
202
|
-
const urlEncoded = dphelper.compress.urlEncode('Hello World!');
|
|
203
|
-
const urlDecoded = dphelper.compress.urlDecode(urlEncoded);
|
|
204
|
-
|
|
205
|
-
// HTML encoding
|
|
206
|
-
const htmlEncoded = dphelper.compress.htmlEncode('<script>');
|
|
207
|
-
const htmlDecoded = dphelper.compress.htmlDecode('<script>');
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## 🔐 Biometric Module (WebAuthn)
|
|
213
|
-
|
|
214
|
-
```javascript
|
|
215
|
-
// Check availability
|
|
216
|
-
const available = dphelper.biometric.isAvailable();
|
|
217
|
-
|
|
218
|
-
// Get support details
|
|
219
|
-
const support = dphelper.biometric.getWebAuthnSupport();
|
|
220
|
-
|
|
221
|
-
// Register credential
|
|
222
|
-
const { success, credentialId } = await dphelper.biometric.register('user123');
|
|
223
|
-
|
|
224
|
-
// Authenticate
|
|
225
|
-
const { success } = await dphelper.biometric.authenticate('user123');
|
|
226
|
-
|
|
227
|
-
// Check specific sensor
|
|
228
|
-
const hasFingerprint = await dphelper.biometric.isSensorAvailable('fingerprint');
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
233
|
-
## AI Power User Guide
|
|
234
|
-
|
|
235
|
-
The new `dphelper.ai` module is designed for the modern AI stack (LLMs, RAG, Vector Search).
|
|
236
|
-
|
|
237
|
-
```javascript
|
|
238
|
-
// ⚡ TOON: The ultimate JSON alternative for prompts
|
|
239
|
-
const toonData = dphelper.ai.toon(myJsonObject);
|
|
240
|
-
// Efficient, compact, and deterministic.
|
|
241
|
-
|
|
242
|
-
// 📏 Context-Aware Token Counting
|
|
243
|
-
const tokens = dphelper.ai.tokenCount(myJsonObject);
|
|
244
|
-
// Automatically calculates tokens based on the optimal TOON representation.
|
|
245
|
-
|
|
246
|
-
// 🧩 Smart Chunker (RAG Ready)
|
|
247
|
-
const chunks = dphelper.ai.chunker(longText, { size: 1000, overlap: 200 });
|
|
248
|
-
|
|
249
|
-
// 🔍 Semantic Similarity
|
|
250
|
-
const score = dphelper.ai.similarity(embeddingA, embeddingB);
|
|
251
|
-
|
|
252
|
-
// 🧠 Reasoning Extractor (DeepSeek/O1 support)
|
|
253
|
-
const { reasoning, content } = dphelper.ai.extractReasoning(rawAiReply);
|
|
254
|
-
|
|
255
|
-
// 📸 The AI Black Box (Snapshot)
|
|
256
|
-
const appStateToon = dphelper.ai.snapshot();
|
|
257
|
-
// Generates a complete app "mental dump" (URL, gState, Logs) optimized for LLMs.
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
---
|
|
261
|
-
|
|
262
|
-
## Modular Architecture
|
|
263
|
-
|
|
264
|
-
Every tool in `dphelper` is now a self-contained module. Our new build system automatically:
|
|
265
|
-
|
|
266
|
-
1. Scans the `tools/` directory.
|
|
267
|
-
2. Generates dynamic imports for the core.
|
|
268
|
-
3. Synchronizes TypeScript interfaces in `dphelper.d.ts`.
|
|
269
|
-
|
|
270
|
-
This ensures that adding new tools is instantaneous and always documented with full Intellisense support.
|
|
271
|
-
|
|
272
|
-
---
|
|
273
|
-
|
|
274
|
-
## 🔄 UI Mirror & Auto-Recovery
|
|
275
|
-
|
|
276
|
-
`dphelper` makes your web app feel like a native desktop application with cross-tab intelligence.
|
|
277
|
-
|
|
278
|
-
```javascript
|
|
279
|
-
// ⚓ Auto-Recovery: Save scroll and input values across reloads/crashes
|
|
280
|
-
dphelper.UI.anchorContext();
|
|
281
|
-
|
|
282
|
-
// 💓 Pulse: Real-time event bus between all open tabs (No Backend needed!)
|
|
283
|
-
const bus = dphelper.sync.pulse('my-app', (msg) => {
|
|
284
|
-
console.debug('Received from another tab:', msg);
|
|
285
|
-
});
|
|
286
|
-
bus.emit({ action: 'theme-change', value: 'dark' });
|
|
287
|
-
|
|
288
|
-
// 🔒 Interlock: Monitor how many tabs of your app are active
|
|
289
|
-
dphelper.browser.interlock((count) => {
|
|
290
|
-
console.debug(`Active tabs: ${count}`);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
// 🌊 SSE: Modern streaming (Support for POST & Headers)
|
|
294
|
-
const stream = dphelper.sse.open('/api/ai', {
|
|
295
|
-
method: 'POST',
|
|
296
|
-
headers: { 'Authorization': 'Bearer ...' },
|
|
297
|
-
body: JSON.stringify({ prompt: 'Hello AI' })
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
stream.on('message', (data) => console.debug('Chunk:', data));
|
|
301
|
-
stream.on('error', (err) => console.error('Stream failure:', err));
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
## Browser Extension (Chrome/Edge)
|
|
307
|
-
|
|
308
|
-

|
|
309
|
-
|
|
310
|
-
Manage your `dphelper` environment, monitor memory usage, and access documentation directly from your browser.
|
|
311
|
-
|
|
312
|
-
- [Download for Chrome](https://chrome.google.com/webstore/detail/dphelper-manager-dev-tool/oppppldaoknfddeikfloonnialijngbk)
|
|
313
|
-
- [Download for Edge](https://microsoftedge.microsoft.com/addons/detail/dphelper-manager-dev-to/kphabkbdpaljlfagldhojilhfammepnk)
|
|
314
|
-
|
|
315
|
-
---
|
|
316
|
-
|
|
317
|
-
## Environment Compatibility
|
|
318
|
-
|
|
319
|
-
`dphelper` tools are classified by their execution target to ensure stability across the stack.
|
|
320
|
-
|
|
321
|
-
| Icon | Type | Description |
|
|
322
|
-
| :--- | :--- | :--- |
|
|
323
|
-
| 🌐 | **Client** | Browser only (requires DOM, window, or navigator). |
|
|
324
|
-
| 🖥️ | **Server** | Node.js / Bun / Deno only (access to process, fs, etc). |
|
|
325
|
-
| 🧬 | **Isomorphic** | Universal. Works in both Browser and Server (AI, Logic, Math). |
|
|
326
|
-
|
|
327
|
-
### Core Module Status
|
|
328
|
-
|
|
329
|
-
- `dphelper.ai`: 🧬 Isomorphic
|
|
330
|
-
- `dphelper.fetch`: 🧬 Isomorphic (Supports Node 18+)
|
|
331
|
-
- `dphelper.sse`: 🌐 Client (Streaming fetch)
|
|
332
|
-
- `dphelper.socket`: 🌐 Client (WebSocket)
|
|
333
|
-
- `dphelper.sync`: 🌐 Client (BroadcastChannel)
|
|
334
|
-
- `dphelper.UI`: 🌐 Client (DOM based)
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## Security
|
|
339
|
-
|
|
340
|
-
dphelper follows **NIST SP 800-53** and **NSA** security standards:
|
|
341
|
-
|
|
342
|
-
### Cryptography (CNSA Compliant)
|
|
343
|
-
- **AES-256-GCM** encryption
|
|
344
|
-
- **SHA-256** only (SHA-1 deprecated)
|
|
345
|
-
- **PBKDF2** with 310,000 iterations (OWASP 2023)
|
|
346
|
-
|
|
347
|
-
### Network Security
|
|
348
|
-
- HTTPS required for `fetch` and `SSE`
|
|
349
|
-
- TLS enforced for `socket` (wss:// only)
|
|
350
|
-
- URL validation built-in
|
|
351
|
-
|
|
352
|
-
> [!IMPORTANT]
|
|
353
|
-
> **For Library Users:** Network functions require **input validation** by the caller. Always sanitize URLs before passing to dphelper networking tools.
|
|
354
|
-
|
|
355
|
-
```javascript
|
|
356
|
-
// Correct
|
|
357
|
-
const safeUrl = dphelper.sanitize.url(userInput);
|
|
358
|
-
await dphelper.fetch.get(safeUrl);
|
|
359
|
-
|
|
360
|
-
// Never do this
|
|
361
|
-
await dphelper.fetch.get(userInput); // ❌ Unvalidated
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
### Compliance
|
|
365
|
-
- 100% NIST/NSA compliant
|
|
366
|
-
- No known vulnerabilities
|
|
367
|
-
- Automated security scanning in CI
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
### 🧬 The Core Architectural Ecosystem
|
|
372
|
-
|
|
373
|
-
`dphelper` operates as a completely stateless, high-performance toolkit. To ensure clean separation of concerns and prevent race conditions or state contamination across asynchronous modules, state management has been extracted into dedicated standalone libraries.
|
|
374
|
-
|
|
375
|
-
Always map your application architecture according to the following layout:
|
|
376
|
-
|
|
377
|
-
| Layer & Purpose | Package | Operational Target | Design Philosophy |
|
|
378
|
-
| :--- | :--- | :--- | :--- |
|
|
379
|
-
| **Stateless Utilities & AI Tools** | `dphelper` | Isomorphic (Browser, Node.js, Bun, Deno) | **Zero-Dependency Universal Core.** Packs 303 production-ready modules including `ai` (TOON optimization, smart chunking), `worker` multi-threaded pools, `biometric` WebAuthn, `i18n`, desktop-grade cross-tab `sync.pulse`, and NIST-compliant cryptography. |
|
|
380
|
-
| **Simple Global State** | `memorio` | Application-Wide Runtime | **Global Singleton Pattern.** High-performance, lightweight state management that eliminates boilerplate. It registers globally upon initial import and removes the need for custom context providers, actions, or dispatch files. |
|
|
381
|
-
| **Enterprise State Architecture** | `Argis RGS` | Distributed / Complex SaaS Systems | **Heavy-Duty Reactive Structure.** Built for multi-module, enterprise-grade applications requiring strict state rules, relational data synchronization, and heavy concurrent data pipelines. |
|
|
382
|
-
|
|
383
|
-
---
|
|
384
|
-
|
|
385
|
-
### ⚠️ Integration Best Practices for AI & Humans
|
|
386
|
-
|
|
387
|
-
1. **Do Not Bundle State Logic in dphelper:** Any legacy codebase referencing `dphelper.store` or namespace getters/setters must be migrated to `memorio` or `Argis RGS`.
|
|
388
|
-
2. **Single-Entry Side Effect:** `dphelper` is designed to be imported exactly once in your root file (`import "dphelper";`). It will automatically map its 303 tools safely to the global scope.
|
|
389
|
-
3. **State Integrity:** When building micro-frontends or multi-tab web applications, use `dphelper.sync` primitives to handle cross-tab events, while allowing `memorio` to manage the underlying atomic state memory.
|
|
390
|
-
|
|
391
|
-
## License
|
|
392
|
-
|
|
393
|
-
MIT License
|
|
394
|
-
|
|
395
|
-
## Credits
|
|
396
|
-
|
|
397
|
-
Copyrigth (c) [Dario Passariello](https://dario.passariello.ca/)
|
|
1
|
+
# [dphelper](https://npmjs.com/package/dphelper)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
> **The supercharged toolkit for modern web development, AI engineering & DevTools.**
|
|
6
|
+
|
|
7
|
+
[](https://npmjs.org/package/dphelper)
|
|
8
|
+
[](https://npmjs.org/package/dphelper)
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+
|
|
13
|
+

|
|
14
|
+

|
|
15
|
+

|
|
16
|
+
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+
[](https://playwright.dev/)
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Table of Contents
|
|
27
|
+
|
|
28
|
+
1. [About](#about)
|
|
29
|
+
2. [Installation](#installation)
|
|
30
|
+
3. [AI Power User Guide](#ai-power-user-guide)
|
|
31
|
+
4. [Modular Architecture](#modular-architecture)
|
|
32
|
+
5. [Browser Extension (Chrome/Edge)](#browser-extension-chromeedge)
|
|
33
|
+
6. [Environment Compatibility](#environment-compatibility)
|
|
34
|
+
7. [Security](#security)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## About
|
|
39
|
+
|
|
40
|
+
**dphelper** is a powerful, zero-dependency utility library that brings together **production-ready tools** for web developers, AI engineers, and DevTools creators.
|
|
41
|
+
|
|
42
|
+
Think of it as your **universal toolbox** - from DOM manipulation to cryptographic operations, from real-time WebSocket handling to AI-powered token optimization. No more juggling multiple packages. One import, infinite possibilities.
|
|
43
|
+
|
|
44
|
+
### Why dphelper?
|
|
45
|
+
|
|
46
|
+
- **⚡ Zero Dependencies** - Pure vanilla JavaScript/TypeScript. No bloat, no surprises.
|
|
47
|
+
- **🤖 AI-First Design** - Built for LLM apps with TOON optimization, token counting, and RAG support.
|
|
48
|
+
- **🌐 Universal** - Works in browser, Node.js, Bun, and Deno.
|
|
49
|
+
- **🔒 Type-Safe** - Full TypeScript definitions auto-generated for every tool.
|
|
50
|
+
- **📦 Tiny Bundle** - Only ~171KB minified, tree-shakeable.
|
|
51
|
+
- **🔐 Security First** - NIST/NSA compliant, CNSA algorithms, PBKDF2 310k iterations
|
|
52
|
+
|
|
53
|
+
> [!NOTE]
|
|
54
|
+
> **Network Access:** This library includes networking primitives (`fetch`, `sse`, `socket`) by design for modern web development. Callers are responsible for validating and sanitizing URLs before use. See the [Security](#security) section for best practices.
|
|
55
|
+
|
|
56
|
+
> *"dphelper is what you'd build if you combined lodash, socket.io, and an AI SDK - but lighter."*
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## State and Store removed from dpHelper
|
|
61
|
+
|
|
62
|
+
> [!IMPORTANT]
|
|
63
|
+
> dpHelper do not integrate state management directly anymore
|
|
64
|
+
>
|
|
65
|
+
> Application state is currently handled through **Memorio** or **RGS**.
|
|
66
|
+
|
|
67
|
+
If you need to use state/store management please consider:
|
|
68
|
+
|
|
69
|
+
- [Memorio](http://www.npmjs.com/package/memorio) - State and Store Manager
|
|
70
|
+
- [Argis RGS](https://www.npmjs.com/package/@biglogic/rgs) - Enterprise Lever State Manager
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
```shell
|
|
77
|
+
npm i dphelper --save-dev
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Usage
|
|
81
|
+
|
|
82
|
+
Import it precisely **once** in your entry point (e.g., `index.js`, `main.ts`, or `App.tsx`):
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
// IMPORT ONCE AT YOUR APP ENTRY POINT
|
|
86
|
+
|
|
87
|
+
import "dphelper";
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Modular imports
|
|
91
|
+
|
|
92
|
+
For a smaller bundle or cleaner tree-shaking, import only the tool you need. Each modular entry point exposes the tool both as a **named export** and on the **global `dphelper`** object, so existing global-usage code keeps working unchanged.
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { sanitize } from "dphelper/sanitize"
|
|
96
|
+
import { format } from "dphelper/format"
|
|
97
|
+
import { fetch } from "dphelper/fetch"
|
|
98
|
+
import { security } from "dphelper/security"
|
|
99
|
+
|
|
100
|
+
sanitize.html("<strong>safe text</strong>")
|
|
101
|
+
format.currency(1234.56, "en-US", "USD")
|
|
102
|
+
await fetch.get("https://api.example.com")
|
|
103
|
+
security.ulid()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The same tool is also available on the global after import:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import "dphelper/format"
|
|
110
|
+
|
|
111
|
+
// Identical to the named export above
|
|
112
|
+
dphelper.format.currency(1234.56, "en-US", "USD")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
> [!NOTE]
|
|
116
|
+
> Every tool under `tools/` is published as `dphelper/<tool>` (e.g. `dphelper/array`, `dphelper/i18n`, `dphelper/worker`). The full list is generated automatically from the `tools/` directory at build time, so adding a new tool creates its modular entry point with no extra configuration.
|
|
117
|
+
|
|
118
|
+
> [!IMPORTANT]
|
|
119
|
+
> **TypeScript + `resolvePackageJsonExports`:** Modular subpath imports (e.g. `import { sanitize } from "dphelper/sanitize"`) are resolved through the `exports` map in `dphelper`'s `package.json`. If your `tsconfig.json` sets `"resolvePackageJsonExports": false`, TypeScript will fall back to physical path resolution and fail with `Cannot find module 'dphelper/<tool>' or its corresponding type declarations` (TS2307), because the tool actually lives under `modules/<tool>` rather than at the package root.
|
|
120
|
+
>
|
|
121
|
+
> To fix it, either:
|
|
122
|
+
> - keep `"resolvePackageJsonExports": true` (the default for `moduleResolution: "bundler"`), or
|
|
123
|
+
> - import from the physical path: `import { sanitize } from "dphelper/modules/sanitize"`.
|
|
124
|
+
>
|
|
125
|
+
> Note: this is a TypeScript-only resolution issue. Vite and other bundlers resolve the subpath correctly at build/runtime via the `exports` map regardless of that flag.
|
|
126
|
+
|
|
127
|
+
For plain HTML/CDN:
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<script src="https://unpkg.com/dphelper/dphelper.js"></script>
|
|
131
|
+
|
|
132
|
+
<!-- Optional check -->
|
|
133
|
+
<script>
|
|
134
|
+
console.debug(dphelper.version); // latest version
|
|
135
|
+
console.debug(dphelper.isBrowser); // true
|
|
136
|
+
</script>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## ⚙️ Web Worker Module
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
// Create worker from file
|
|
145
|
+
const worker = dphelper.worker.create('worker.js', {
|
|
146
|
+
onmessage: (e) => console.log(e.data)
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Create inline worker
|
|
150
|
+
const inlineWorker = dphelper.worker.createInline(`
|
|
151
|
+
self.onmessage = e => postMessage(e.data * 2);
|
|
152
|
+
`);
|
|
153
|
+
|
|
154
|
+
// Worker pool for parallel processing
|
|
155
|
+
const pool = dphelper.worker.pool('worker.js', 4);
|
|
156
|
+
const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
|
|
157
|
+
|
|
158
|
+
// SharedWorker for cross-tab communication
|
|
159
|
+
const shared = dphelper.worker.shared('worker.js', { name: 'my-shared' });
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## 🌍 i18n Module
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// Set locale
|
|
168
|
+
dphelper.i18n.setLocale('it');
|
|
169
|
+
|
|
170
|
+
// Add translations
|
|
171
|
+
dphelper.i18n.addTranslations('it', {
|
|
172
|
+
hello: 'Ciao {name}!',
|
|
173
|
+
items: '{count, plural, one{# item} other{# items}}'
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Translate with interpolation
|
|
177
|
+
dphelper.i18n.t('hello', { name: 'World' }); // "Ciao World!"
|
|
178
|
+
|
|
179
|
+
// Pluralize
|
|
180
|
+
dphelper.i18n.pluralize(5, { one: 'item', other: 'items' }); // "items"
|
|
181
|
+
|
|
182
|
+
// Format number/currency
|
|
183
|
+
dphelper.i18n.number(1234.56, 'de-DE', { style: 'currency', currency: 'EUR' });
|
|
184
|
+
|
|
185
|
+
// Relative time
|
|
186
|
+
dphelper.i18n.relativeTime(Date.now() - 3600000); // "1 hour ago"
|
|
187
|
+
```
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## 🗜️ Compression Module
|
|
191
|
+
|
|
192
|
+
```javascript
|
|
193
|
+
// Gzip compression
|
|
194
|
+
const compressed = await dphelper.compress.gzip('Hello World');
|
|
195
|
+
const decompressed = await dphelper.compress.gunzip(compressed);
|
|
196
|
+
|
|
197
|
+
// Base64 encoding
|
|
198
|
+
const encoded = dphelper.compress.base64Encode('Hello');
|
|
199
|
+
const decoded = dphelper.compress.base64Decode(encoded);
|
|
200
|
+
|
|
201
|
+
// URL encoding
|
|
202
|
+
const urlEncoded = dphelper.compress.urlEncode('Hello World!');
|
|
203
|
+
const urlDecoded = dphelper.compress.urlDecode(urlEncoded);
|
|
204
|
+
|
|
205
|
+
// HTML encoding
|
|
206
|
+
const htmlEncoded = dphelper.compress.htmlEncode('<script>');
|
|
207
|
+
const htmlDecoded = dphelper.compress.htmlDecode('<script>');
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## 🔐 Biometric Module (WebAuthn)
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
// Check availability
|
|
216
|
+
const available = dphelper.biometric.isAvailable();
|
|
217
|
+
|
|
218
|
+
// Get support details
|
|
219
|
+
const support = dphelper.biometric.getWebAuthnSupport();
|
|
220
|
+
|
|
221
|
+
// Register credential
|
|
222
|
+
const { success, credentialId } = await dphelper.biometric.register('user123');
|
|
223
|
+
|
|
224
|
+
// Authenticate
|
|
225
|
+
const { success } = await dphelper.biometric.authenticate('user123');
|
|
226
|
+
|
|
227
|
+
// Check specific sensor
|
|
228
|
+
const hasFingerprint = await dphelper.biometric.isSensorAvailable('fingerprint');
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## AI Power User Guide
|
|
234
|
+
|
|
235
|
+
The new `dphelper.ai` module is designed for the modern AI stack (LLMs, RAG, Vector Search).
|
|
236
|
+
|
|
237
|
+
```javascript
|
|
238
|
+
// ⚡ TOON: The ultimate JSON alternative for prompts
|
|
239
|
+
const toonData = dphelper.ai.toon(myJsonObject);
|
|
240
|
+
// Efficient, compact, and deterministic.
|
|
241
|
+
|
|
242
|
+
// 📏 Context-Aware Token Counting
|
|
243
|
+
const tokens = dphelper.ai.tokenCount(myJsonObject);
|
|
244
|
+
// Automatically calculates tokens based on the optimal TOON representation.
|
|
245
|
+
|
|
246
|
+
// 🧩 Smart Chunker (RAG Ready)
|
|
247
|
+
const chunks = dphelper.ai.chunker(longText, { size: 1000, overlap: 200 });
|
|
248
|
+
|
|
249
|
+
// 🔍 Semantic Similarity
|
|
250
|
+
const score = dphelper.ai.similarity(embeddingA, embeddingB);
|
|
251
|
+
|
|
252
|
+
// 🧠 Reasoning Extractor (DeepSeek/O1 support)
|
|
253
|
+
const { reasoning, content } = dphelper.ai.extractReasoning(rawAiReply);
|
|
254
|
+
|
|
255
|
+
// 📸 The AI Black Box (Snapshot)
|
|
256
|
+
const appStateToon = dphelper.ai.snapshot();
|
|
257
|
+
// Generates a complete app "mental dump" (URL, gState, Logs) optimized for LLMs.
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Modular Architecture
|
|
263
|
+
|
|
264
|
+
Every tool in `dphelper` is now a self-contained module. Our new build system automatically:
|
|
265
|
+
|
|
266
|
+
1. Scans the `tools/` directory.
|
|
267
|
+
2. Generates dynamic imports for the core.
|
|
268
|
+
3. Synchronizes TypeScript interfaces in `dphelper.d.ts`.
|
|
269
|
+
|
|
270
|
+
This ensures that adding new tools is instantaneous and always documented with full Intellisense support.
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## 🔄 UI Mirror & Auto-Recovery
|
|
275
|
+
|
|
276
|
+
`dphelper` makes your web app feel like a native desktop application with cross-tab intelligence.
|
|
277
|
+
|
|
278
|
+
```javascript
|
|
279
|
+
// ⚓ Auto-Recovery: Save scroll and input values across reloads/crashes
|
|
280
|
+
dphelper.UI.anchorContext();
|
|
281
|
+
|
|
282
|
+
// 💓 Pulse: Real-time event bus between all open tabs (No Backend needed!)
|
|
283
|
+
const bus = dphelper.sync.pulse('my-app', (msg) => {
|
|
284
|
+
console.debug('Received from another tab:', msg);
|
|
285
|
+
});
|
|
286
|
+
bus.emit({ action: 'theme-change', value: 'dark' });
|
|
287
|
+
|
|
288
|
+
// 🔒 Interlock: Monitor how many tabs of your app are active
|
|
289
|
+
dphelper.browser.interlock((count) => {
|
|
290
|
+
console.debug(`Active tabs: ${count}`);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// 🌊 SSE: Modern streaming (Support for POST & Headers)
|
|
294
|
+
const stream = dphelper.sse.open('/api/ai', {
|
|
295
|
+
method: 'POST',
|
|
296
|
+
headers: { 'Authorization': 'Bearer ...' },
|
|
297
|
+
body: JSON.stringify({ prompt: 'Hello AI' })
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
stream.on('message', (data) => console.debug('Chunk:', data));
|
|
301
|
+
stream.on('error', (err) => console.error('Stream failure:', err));
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## Browser Extension (Chrome/Edge)
|
|
307
|
+
|
|
308
|
+

|
|
309
|
+
|
|
310
|
+
Manage your `dphelper` environment, monitor memory usage, and access documentation directly from your browser.
|
|
311
|
+
|
|
312
|
+
- [Download for Chrome](https://chrome.google.com/webstore/detail/dphelper-manager-dev-tool/oppppldaoknfddeikfloonnialijngbk)
|
|
313
|
+
- [Download for Edge](https://microsoftedge.microsoft.com/addons/detail/dphelper-manager-dev-to/kphabkbdpaljlfagldhojilhfammepnk)
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Environment Compatibility
|
|
318
|
+
|
|
319
|
+
`dphelper` tools are classified by their execution target to ensure stability across the stack.
|
|
320
|
+
|
|
321
|
+
| Icon | Type | Description |
|
|
322
|
+
| :--- | :--- | :--- |
|
|
323
|
+
| 🌐 | **Client** | Browser only (requires DOM, window, or navigator). |
|
|
324
|
+
| 🖥️ | **Server** | Node.js / Bun / Deno only (access to process, fs, etc). |
|
|
325
|
+
| 🧬 | **Isomorphic** | Universal. Works in both Browser and Server (AI, Logic, Math). |
|
|
326
|
+
|
|
327
|
+
### Core Module Status
|
|
328
|
+
|
|
329
|
+
- `dphelper.ai`: 🧬 Isomorphic
|
|
330
|
+
- `dphelper.fetch`: 🧬 Isomorphic (Supports Node 18+)
|
|
331
|
+
- `dphelper.sse`: 🌐 Client (Streaming fetch)
|
|
332
|
+
- `dphelper.socket`: 🌐 Client (WebSocket)
|
|
333
|
+
- `dphelper.sync`: 🌐 Client (BroadcastChannel)
|
|
334
|
+
- `dphelper.UI`: 🌐 Client (DOM based)
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
## Security
|
|
339
|
+
|
|
340
|
+
dphelper follows **NIST SP 800-53** and **NSA** security standards:
|
|
341
|
+
|
|
342
|
+
### Cryptography (CNSA Compliant)
|
|
343
|
+
- **AES-256-GCM** encryption
|
|
344
|
+
- **SHA-256** only (SHA-1 deprecated)
|
|
345
|
+
- **PBKDF2** with 310,000 iterations (OWASP 2023)
|
|
346
|
+
|
|
347
|
+
### Network Security
|
|
348
|
+
- HTTPS required for `fetch` and `SSE`
|
|
349
|
+
- TLS enforced for `socket` (wss:// only)
|
|
350
|
+
- URL validation built-in
|
|
351
|
+
|
|
352
|
+
> [!IMPORTANT]
|
|
353
|
+
> **For Library Users:** Network functions require **input validation** by the caller. Always sanitize URLs before passing to dphelper networking tools.
|
|
354
|
+
|
|
355
|
+
```javascript
|
|
356
|
+
// Correct
|
|
357
|
+
const safeUrl = dphelper.sanitize.url(userInput);
|
|
358
|
+
await dphelper.fetch.get(safeUrl);
|
|
359
|
+
|
|
360
|
+
// Never do this
|
|
361
|
+
await dphelper.fetch.get(userInput); // ❌ Unvalidated
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Compliance
|
|
365
|
+
- 100% NIST/NSA compliant
|
|
366
|
+
- No known vulnerabilities
|
|
367
|
+
- Automated security scanning in CI
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
### 🧬 The Core Architectural Ecosystem
|
|
372
|
+
|
|
373
|
+
`dphelper` operates as a completely stateless, high-performance toolkit. To ensure clean separation of concerns and prevent race conditions or state contamination across asynchronous modules, state management has been extracted into dedicated standalone libraries.
|
|
374
|
+
|
|
375
|
+
Always map your application architecture according to the following layout:
|
|
376
|
+
|
|
377
|
+
| Layer & Purpose | Package | Operational Target | Design Philosophy |
|
|
378
|
+
| :--- | :--- | :--- | :--- |
|
|
379
|
+
| **Stateless Utilities & AI Tools** | `dphelper` | Isomorphic (Browser, Node.js, Bun, Deno) | **Zero-Dependency Universal Core.** Packs 303 production-ready modules including `ai` (TOON optimization, smart chunking), `worker` multi-threaded pools, `biometric` WebAuthn, `i18n`, desktop-grade cross-tab `sync.pulse`, and NIST-compliant cryptography. |
|
|
380
|
+
| **Simple Global State** | `memorio` | Application-Wide Runtime | **Global Singleton Pattern.** High-performance, lightweight state management that eliminates boilerplate. It registers globally upon initial import and removes the need for custom context providers, actions, or dispatch files. |
|
|
381
|
+
| **Enterprise State Architecture** | `Argis RGS` | Distributed / Complex SaaS Systems | **Heavy-Duty Reactive Structure.** Built for multi-module, enterprise-grade applications requiring strict state rules, relational data synchronization, and heavy concurrent data pipelines. |
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
### ⚠️ Integration Best Practices for AI & Humans
|
|
386
|
+
|
|
387
|
+
1. **Do Not Bundle State Logic in dphelper:** Any legacy codebase referencing `dphelper.store` or namespace getters/setters must be migrated to `memorio` or `Argis RGS`.
|
|
388
|
+
2. **Single-Entry Side Effect:** `dphelper` is designed to be imported exactly once in your root file (`import "dphelper";`). It will automatically map its 303 tools safely to the global scope.
|
|
389
|
+
3. **State Integrity:** When building micro-frontends or multi-tab web applications, use `dphelper.sync` primitives to handle cross-tab events, while allowing `memorio` to manage the underlying atomic state memory.
|
|
390
|
+
|
|
391
|
+
## License
|
|
392
|
+
|
|
393
|
+
MIT License
|
|
394
|
+
|
|
395
|
+
## Credits
|
|
396
|
+
|
|
397
|
+
Copyrigth (c) [Dario Passariello](https://dario.passariello.ca/)
|