cipher-logger 1.0.0 → 1.2.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/.editorconfig +19 -0
- package/.gitattributes +0 -0
- package/.github/workflows/pre-publish.yml +36 -0
- package/.github/workflows/publish.yml +6 -6
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +11 -0
- package/README.md +14 -4
- package/assets/cipherlogger_logo_mono.png +0 -0
- package/assets/cipherlogger_logo_mono.svg +12 -0
- package/commitlint.config.mjs +26 -0
- package/dist/index.js +7 -2
- package/dist/index.mjs +7 -2
- package/eslint.config.mjs +69 -0
- package/package.json +17 -5
- package/prettier.config.mjs +18 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
end_of_line = lf
|
|
7
|
+
insert_final_newline = true
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 2
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.md]
|
|
13
|
+
trim_trailing_whitespace = false
|
|
14
|
+
|
|
15
|
+
[Makefile]
|
|
16
|
+
indent_style = tab
|
|
17
|
+
|
|
18
|
+
[*.{yml,yaml}]
|
|
19
|
+
indent_size = 2
|
package/.gitattributes
ADDED
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Pre-publish validation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
pull_request:
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
validate:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Setup pnpm
|
|
19
|
+
uses: pnpm/action-setup@v4
|
|
20
|
+
with:
|
|
21
|
+
version: 10
|
|
22
|
+
|
|
23
|
+
- name: Setup Node.js
|
|
24
|
+
uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version: 24
|
|
27
|
+
cache: pnpm
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: pnpm install --frozen-lockfile
|
|
31
|
+
|
|
32
|
+
- name: Run validation suite
|
|
33
|
+
run: pnpm run test
|
|
34
|
+
|
|
35
|
+
- name: Dry run package publish
|
|
36
|
+
run: npm pack --dry-run
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
name: Publish to npm
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: ["Pre-publish validation"]
|
|
6
|
+
types: [completed]
|
|
7
7
|
|
|
8
8
|
permissions:
|
|
9
9
|
contents: read
|
|
@@ -11,11 +11,14 @@ permissions:
|
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
13
|
publish:
|
|
14
|
+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
14
15
|
runs-on: ubuntu-latest
|
|
15
16
|
|
|
16
17
|
steps:
|
|
17
18
|
- name: Checkout
|
|
18
19
|
uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
ref: ${{ github.event.workflow_run.head_sha }}
|
|
19
22
|
|
|
20
23
|
- name: Setup pnpm
|
|
21
24
|
uses: pnpm/action-setup@v4
|
|
@@ -41,9 +44,6 @@ jobs:
|
|
|
41
44
|
- name: Install dependencies
|
|
42
45
|
run: pnpm install --frozen-lockfile
|
|
43
46
|
|
|
44
|
-
- name: Build
|
|
45
|
-
run: pnpm run build
|
|
46
|
-
|
|
47
47
|
- name: Publish
|
|
48
48
|
run: |
|
|
49
49
|
NAME=$(node -p "require('./package.json').name")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pnpm exec commitlint --edit "$1"
|
package/.prettierignore
ADDED
package/README.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img
|
|
3
|
+
src="./assets/cipherlogger_logo_mono.png"
|
|
4
|
+
alt="Fusion Snippet"
|
|
5
|
+
width="120"
|
|
6
|
+
style="border-radius: 18px;"
|
|
7
|
+
/>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<h1 align="center">Cipher Logger</h1>
|
|
11
|
+
|
|
2
12
|
|
|
3
13
|
<p align="center">
|
|
4
14
|
<strong>See every request. Capture every error. Understand your application.</strong>
|
|
@@ -468,6 +478,6 @@ Contributions are welcome and appreciated.
|
|
|
468
478
|
|
|
469
479
|
[MIT](./LICENSE) © Cipher Unit
|
|
470
480
|
|
|
471
|
-
<p align="center">
|
|
472
|
-
<i>
|
|
473
|
-
</p>
|
|
481
|
+
<p align="center" style="margin-top: 100px;">
|
|
482
|
+
<b><i>Made with ❤️ for developers by CipherUnit</i></b>
|
|
483
|
+
</p>
|
|
Binary file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg width="100%" viewBox="0 0 522 522" role="img" xmlns="http://www.w3.org/2000/svg" style="">
|
|
2
|
+
<title style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:anthropic-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto">CipherLogger monochrome logo</title>
|
|
3
|
+
<desc style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:anthropic-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto">A black rounded square badge with a white ring open on the right side like the letter C, and a small white cursor bar filling part of the gap, evoking both a cipher lock and a terminal prompt.</desc>
|
|
4
|
+
<defs>
|
|
5
|
+
<clipPath id="badge2"><rect x="0" y="0" width="512" height="512" rx="96"/></clipPath>
|
|
6
|
+
</defs>
|
|
7
|
+
<g clip-path="url(#badge2)" style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:anthropic-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto">
|
|
8
|
+
<rect x="0" y="0" width="512" height="512" fill="#000000" style="fill:rgb(0, 0, 0);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:anthropic-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto"/>
|
|
9
|
+
<path d="M 362.5 191.4 A 130 130 0 1 0 362.5 340.6" fill="none" stroke="#ffffff" stroke-width="46" stroke-linecap="butt" style="fill:none;stroke:rgb(255, 255, 255);color:rgb(11, 11, 11);stroke-width:46px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:anthropic-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto"/>
|
|
10
|
+
<rect x="374" y="238" width="30" height="56" rx="3" fill="#ffffff" style="fill:rgb(255, 255, 255);stroke:none;color:rgb(11, 11, 11);stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;opacity:1;font-family:anthropic-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;font-size:16px;font-weight:400;text-anchor:start;dominant-baseline:auto"/>
|
|
11
|
+
</g>
|
|
12
|
+
</svg>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** @type {import('@commitlint/types').UserConfig} */
|
|
2
|
+
export default {
|
|
3
|
+
extends: ['@commitlint/config-conventional'],
|
|
4
|
+
rules: {
|
|
5
|
+
'type-enum': [
|
|
6
|
+
2,
|
|
7
|
+
'always',
|
|
8
|
+
[
|
|
9
|
+
'feat',
|
|
10
|
+
'fix',
|
|
11
|
+
'docs',
|
|
12
|
+
'i18n',
|
|
13
|
+
'style',
|
|
14
|
+
'refactor',
|
|
15
|
+
'perf',
|
|
16
|
+
'test',
|
|
17
|
+
'build',
|
|
18
|
+
'ci',
|
|
19
|
+
'chore',
|
|
20
|
+
'revert',
|
|
21
|
+
],
|
|
22
|
+
],
|
|
23
|
+
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
|
|
24
|
+
'header-max-length': [2, 'always', 100],
|
|
25
|
+
},
|
|
26
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -312,7 +312,9 @@ function createNestMiddleware(cipher) {
|
|
|
312
312
|
|
|
313
313
|
// src/adapters/hono/middleware.ts
|
|
314
314
|
function getHeader5(request, name) {
|
|
315
|
-
if (!request)
|
|
315
|
+
if (!request) {
|
|
316
|
+
return void 0;
|
|
317
|
+
}
|
|
316
318
|
if (typeof request.header === "function") {
|
|
317
319
|
return request.header(name) ?? void 0;
|
|
318
320
|
}
|
|
@@ -321,6 +323,9 @@ function getHeader5(request, name) {
|
|
|
321
323
|
}
|
|
322
324
|
return void 0;
|
|
323
325
|
}
|
|
326
|
+
function hasHeader(request, name) {
|
|
327
|
+
return Boolean(getHeader5(request, name));
|
|
328
|
+
}
|
|
324
329
|
function parseQuery5(urlString) {
|
|
325
330
|
try {
|
|
326
331
|
const url = new URL(urlString);
|
|
@@ -348,7 +353,7 @@ function createHonoMiddleware(cipher) {
|
|
|
348
353
|
status = cres.statusCode;
|
|
349
354
|
}
|
|
350
355
|
const xfwd = getHeader5(req, "x-forwarded-for");
|
|
351
|
-
const ip =
|
|
356
|
+
const ip = hasHeader(req, "x-forwarded-for") ? String(xfwd).split(",")[0].trim() : getHeader5(req, "x-real-ip") ?? void 0;
|
|
352
357
|
cipher.logRequest({
|
|
353
358
|
method: req?.method,
|
|
354
359
|
path: parsed.pathname + parsed.search,
|
package/dist/index.mjs
CHANGED
|
@@ -279,7 +279,9 @@ function createNestMiddleware(cipher) {
|
|
|
279
279
|
|
|
280
280
|
// src/adapters/hono/middleware.ts
|
|
281
281
|
function getHeader5(request, name) {
|
|
282
|
-
if (!request)
|
|
282
|
+
if (!request) {
|
|
283
|
+
return void 0;
|
|
284
|
+
}
|
|
283
285
|
if (typeof request.header === "function") {
|
|
284
286
|
return request.header(name) ?? void 0;
|
|
285
287
|
}
|
|
@@ -288,6 +290,9 @@ function getHeader5(request, name) {
|
|
|
288
290
|
}
|
|
289
291
|
return void 0;
|
|
290
292
|
}
|
|
293
|
+
function hasHeader(request, name) {
|
|
294
|
+
return Boolean(getHeader5(request, name));
|
|
295
|
+
}
|
|
291
296
|
function parseQuery5(urlString) {
|
|
292
297
|
try {
|
|
293
298
|
const url = new URL(urlString);
|
|
@@ -315,7 +320,7 @@ function createHonoMiddleware(cipher) {
|
|
|
315
320
|
status = cres.statusCode;
|
|
316
321
|
}
|
|
317
322
|
const xfwd = getHeader5(req, "x-forwarded-for");
|
|
318
|
-
const ip =
|
|
323
|
+
const ip = hasHeader(req, "x-forwarded-for") ? String(xfwd).split(",")[0].trim() : getHeader5(req, "x-real-ip") ?? void 0;
|
|
319
324
|
cipher.logRequest({
|
|
320
325
|
method: req?.method,
|
|
321
326
|
path: parsed.pathname + parsed.search,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { defineConfig, globalIgnores } from "eslint/config";
|
|
2
|
+
import nextVitals from "eslint-config-next/core-web-vitals";
|
|
3
|
+
import nextTs from "eslint-config-next/typescript";
|
|
4
|
+
|
|
5
|
+
export default defineConfig([
|
|
6
|
+
...nextVitals,
|
|
7
|
+
...nextTs,
|
|
8
|
+
|
|
9
|
+
{
|
|
10
|
+
rules: {
|
|
11
|
+
// ===== JavaScript =====
|
|
12
|
+
eqeqeq: ["error", "always"],
|
|
13
|
+
curly: ["error", "all"],
|
|
14
|
+
"no-var": "error",
|
|
15
|
+
"prefer-const": "error",
|
|
16
|
+
"no-console":
|
|
17
|
+
process.env.NODE_ENV === "production"
|
|
18
|
+
? ["warn", { allow: ["warn", "error"] }]
|
|
19
|
+
: "off",
|
|
20
|
+
|
|
21
|
+
// ===== TypeScript =====
|
|
22
|
+
"@typescript-eslint/no-unused-vars": [
|
|
23
|
+
"warn",
|
|
24
|
+
{
|
|
25
|
+
argsIgnorePattern: "^_",
|
|
26
|
+
varsIgnorePattern: "^_",
|
|
27
|
+
ignoreRestSiblings: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
31
|
+
"error",
|
|
32
|
+
{
|
|
33
|
+
prefer: "type-imports",
|
|
34
|
+
fixStyle: "inline-type-imports",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
38
|
+
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
39
|
+
|
|
40
|
+
// ===== Import =====
|
|
41
|
+
"sort-imports": [
|
|
42
|
+
"warn",
|
|
43
|
+
{
|
|
44
|
+
ignoreDeclarationSort: true,
|
|
45
|
+
ignoreCase: true,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
// ===== React =====
|
|
50
|
+
"react/jsx-key": "error",
|
|
51
|
+
"react/self-closing-comp": "warn",
|
|
52
|
+
|
|
53
|
+
// ===== Next =====
|
|
54
|
+
"@next/next/no-img-element": "warn",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
globalIgnores([
|
|
59
|
+
".next/**",
|
|
60
|
+
"out/**",
|
|
61
|
+
"build/**",
|
|
62
|
+
"next-env.d.ts",
|
|
63
|
+
"coverage/**",
|
|
64
|
+
"dist/**",
|
|
65
|
+
"*.config.js",
|
|
66
|
+
"*.config.cjs",
|
|
67
|
+
"*.config.mjs",
|
|
68
|
+
]),
|
|
69
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cipher-logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "See every request. Capture every error. Understand your application.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsup",
|
|
10
|
-
"
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"lint:fix": "eslint --fix .",
|
|
12
|
+
"test": "pnpm run lint && pnpm run build",
|
|
13
|
+
"prepublishOnly": "pnpm run test",
|
|
14
|
+
"commitlint": "commitlint --edit",
|
|
15
|
+
"clean": "rm -rf out dist node_modules/.cache",
|
|
16
|
+
"prepare": "husky"
|
|
11
17
|
},
|
|
12
18
|
"repository": {
|
|
13
19
|
"type": "git",
|
|
@@ -73,8 +79,7 @@
|
|
|
73
79
|
},
|
|
74
80
|
"next": {
|
|
75
81
|
"optional": true
|
|
76
|
-
}
|
|
77
|
-
,
|
|
82
|
+
},
|
|
78
83
|
"fastify": {
|
|
79
84
|
"optional": true
|
|
80
85
|
},
|
|
@@ -89,11 +94,18 @@
|
|
|
89
94
|
}
|
|
90
95
|
},
|
|
91
96
|
"devDependencies": {
|
|
97
|
+
"@commitlint/cli": "^20.1.0",
|
|
98
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
92
99
|
"@types/express": "^5.0.3",
|
|
93
100
|
"@types/node": "^26.1.2",
|
|
94
101
|
"express": "^5.1.0",
|
|
95
102
|
"next": "^15.5.2",
|
|
103
|
+
"fastify": "^4.27.0",
|
|
104
|
+
"hono": "^3.3.0",
|
|
96
105
|
"tsup": "^8.5.1",
|
|
106
|
+
"eslint": "^9",
|
|
107
|
+
"eslint-config-next": "16.3.0",
|
|
108
|
+
"husky": "^9.1.7",
|
|
97
109
|
"typescript": "^6.0.3"
|
|
98
110
|
}
|
|
99
|
-
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @type {import("prettier").Config} */
|
|
2
|
+
const config = {
|
|
3
|
+
semi: true,
|
|
4
|
+
singleQuote: false,
|
|
5
|
+
jsxSingleQuote: false,
|
|
6
|
+
trailingComma: "all",
|
|
7
|
+
tabWidth: 2,
|
|
8
|
+
useTabs: false,
|
|
9
|
+
printWidth: 80,
|
|
10
|
+
bracketSpacing: true,
|
|
11
|
+
bracketSameLine: false,
|
|
12
|
+
arrowParens: "always",
|
|
13
|
+
endOfLine: "lf",
|
|
14
|
+
|
|
15
|
+
plugins: ["prettier-plugin-tailwindcss"],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default config;
|