@zedtech/zedkit-server 0.0.0-stage → 0.0.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/LICENSE +21 -0
- package/README.md +50 -2
- package/package.json +40 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 zedtech-fr
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zedtech/zedkit-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Server-side helpers with a stable public surface. Original work by the
|
|
4
|
+
same author. Zero runtime dependencies.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
pnpm add @zedtech/zedkit-server
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { redactValue } from "@zedtech/zedkit-server";
|
|
12
|
+
|
|
13
|
+
logger.info({ event: "login", user: redactValue(user) });
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## API
|
|
17
|
+
|
|
18
|
+
- `MemoryRateLimiter` — fixed-window, in-process rate limiting:
|
|
19
|
+
`allow(key, limitPerMinute)`. Correct for single-instance deployments;
|
|
20
|
+
multi-instance enforcement needs a shared store behind the same shape.
|
|
21
|
+
- `redactValue(value, key?)` — recursively replace credential-looking
|
|
22
|
+
material with placeholders before logging. Secret-like keys become
|
|
23
|
+
`"[redacted]"`, bearer/basic tokens become `"<scheme> [redacted]"`,
|
|
24
|
+
cyclic references become `"[circular]"`. Scrubbing applies to every
|
|
25
|
+
field; truncation is volume control only, so `msg`/`message`/`stack`
|
|
26
|
+
are never truncated and everything else is bounded at 512 code points.
|
|
27
|
+
Dates pass through; Maps, Sets, prototypes, and symbol keys are
|
|
28
|
+
preserved.
|
|
29
|
+
- `computeBackoffMs(attemptNo, random?)` — exponential retry backoff
|
|
30
|
+
(2s × 3^(n-1), ±20% jitter, 1s floor, 1h cap).
|
|
31
|
+
- `webhookSignatureHeader(secret, body, timestamp)` /
|
|
32
|
+
`verifyWebhookSignatureHeader(secret, body, header, options?)` —
|
|
33
|
+
Stripe-style `t=…,v1=…` HMAC signatures over exact body bytes, with an
|
|
34
|
+
optional freshness check. Bring your own secret.
|
|
35
|
+
- `pgErrorCode(error)` — read the Postgres error code (`23505`
|
|
36
|
+
unique, `23503` FK, ...) from a thrown value, or `null` when it
|
|
37
|
+
has none. Lets callers decide conflict-vs-bug.
|
|
38
|
+
|
|
39
|
+
Find helpers by need in [CATALOG.md](CATALOG.md).
|
|
40
|
+
|
|
41
|
+
## Install or copy?
|
|
42
|
+
|
|
43
|
+
These modules are small and dependency-free: source-copying the files
|
|
44
|
+
is a sane alternative to installing (MIT allows it). Install the package
|
|
45
|
+
for versioned updates.
|
|
46
|
+
|
|
47
|
+
## Verify
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
pnpm --filter @zedtech/zedkit-server typecheck && pnpm --filter @zedtech/zedkit-server lint && pnpm --filter @zedtech/zedkit-server build && pnpm --filter @zedtech/zedkit-server test
|
|
51
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zedtech/zedkit-server",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"description": "Server helpers: in-process rate limiting, secret redaction. Original work by the same author.",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/zedtech-fr/zedkit",
|
|
13
|
+
"directory": "packages/server"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"imports": {
|
|
18
|
+
"#*": "./src/*"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "22.20.5",
|
|
34
|
+
"typescript": "5.9.3",
|
|
35
|
+
"vitest": "2.1.9"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"typecheck": "tsc --noEmit -p tsconfig.tests.json",
|
|
41
|
+
"lint": "eslint src tests"
|
|
42
|
+
}
|
|
6
43
|
}
|