@l.x/privacy 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/.depcheckrc +9 -0
- package/.eslintrc.js +20 -0
- package/LICENSE +122 -0
- package/README.md +3 -0
- package/package.json +32 -0
- package/project.json +18 -0
- package/src/email.ts +40 -0
- package/src/fast-redact.d.ts +14 -0
- package/src/index.ts +6 -0
- package/src/scrub.ts +134 -0
- package/tsconfig.json +26 -0
- package/tsconfig.lint.json +8 -0
package/.depcheckrc
ADDED
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['@luxfi/eslint-config/lib'],
|
|
3
|
+
parserOptions: {
|
|
4
|
+
tsconfigRootDir: __dirname,
|
|
5
|
+
},
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ['*.ts', '*.tsx'],
|
|
9
|
+
rules: {
|
|
10
|
+
'no-relative-import-paths/no-relative-import-paths': [
|
|
11
|
+
'error',
|
|
12
|
+
{
|
|
13
|
+
allowSameFolder: false,
|
|
14
|
+
prefix: '@luxexchange/privacy',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
Lux Ecosystem License
|
|
2
|
+
Version 1.2, December 2025
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2020-2025 Lux Industries Inc.
|
|
5
|
+
All rights reserved.
|
|
6
|
+
|
|
7
|
+
TECHNOLOGY PORTFOLIO - PATENT APPLICATIONS PLANNED
|
|
8
|
+
Contact: licensing@lux.network
|
|
9
|
+
|
|
10
|
+
================================================================================
|
|
11
|
+
TERMS AND CONDITIONS
|
|
12
|
+
================================================================================
|
|
13
|
+
|
|
14
|
+
1. DEFINITIONS
|
|
15
|
+
|
|
16
|
+
"Lux Primary Network" means the official Lux blockchain with Network ID=1
|
|
17
|
+
and EVM Chain ID=96369.
|
|
18
|
+
|
|
19
|
+
"Authorized Network" means the Lux Primary Network, official testnets/devnets,
|
|
20
|
+
and any L1/L2/L3 chain descending from the Lux Primary Network.
|
|
21
|
+
|
|
22
|
+
"Descending Chain" means an L1/L2/L3 chain built on, anchored to, or deriving
|
|
23
|
+
security from the Lux Primary Network or its authorized testnets.
|
|
24
|
+
|
|
25
|
+
"Research Use" means non-commercial academic research, education, personal
|
|
26
|
+
study, or evaluation purposes.
|
|
27
|
+
|
|
28
|
+
"Commercial Use" means any use in connection with a product or service
|
|
29
|
+
offered for sale or fee, internal use by a for-profit entity, or any use
|
|
30
|
+
to generate revenue.
|
|
31
|
+
|
|
32
|
+
2. GRANT OF LICENSE
|
|
33
|
+
|
|
34
|
+
Subject to these terms, Lux Industries Inc grants you a non-exclusive,
|
|
35
|
+
royalty-free license to:
|
|
36
|
+
|
|
37
|
+
(a) Use for Research Use without restriction;
|
|
38
|
+
|
|
39
|
+
(b) Operate on the Lux Primary Network (Network ID=1, EVM Chain ID=96369);
|
|
40
|
+
|
|
41
|
+
(c) Operate on official Lux testnets and devnets;
|
|
42
|
+
|
|
43
|
+
(d) Operate L1/L2/L3 chains descending from the Lux Primary Network;
|
|
44
|
+
|
|
45
|
+
(e) Build applications within the Lux ecosystem;
|
|
46
|
+
|
|
47
|
+
(f) Contribute improvements back to the original repositories.
|
|
48
|
+
|
|
49
|
+
3. RESTRICTIONS
|
|
50
|
+
|
|
51
|
+
Without a commercial license from Lux Industries Inc, you may NOT:
|
|
52
|
+
|
|
53
|
+
(a) Fork the Lux Network or any Lux software;
|
|
54
|
+
|
|
55
|
+
(b) Create competing networks not descending from Lux Primary Network;
|
|
56
|
+
|
|
57
|
+
(c) Use for Commercial Use outside the Lux ecosystem;
|
|
58
|
+
|
|
59
|
+
(d) Sublicense or transfer rights outside the Lux ecosystem;
|
|
60
|
+
|
|
61
|
+
(e) Use to create competing blockchain networks, exchanges, custody
|
|
62
|
+
services, or cryptographic systems outside the Lux ecosystem.
|
|
63
|
+
|
|
64
|
+
4. NO FORKS POLICY
|
|
65
|
+
|
|
66
|
+
Lux Industries Inc maintains ZERO TOLERANCE for unauthorized forks.
|
|
67
|
+
Any fork or deployment on an unauthorized network constitutes:
|
|
68
|
+
|
|
69
|
+
(a) Breach of this license;
|
|
70
|
+
(b) Grounds for immediate legal action.
|
|
71
|
+
|
|
72
|
+
5. RIGHTS RESERVATION
|
|
73
|
+
|
|
74
|
+
All rights not explicitly granted are reserved by Lux Industries Inc.
|
|
75
|
+
|
|
76
|
+
We plan to apply for patent protection for the technology in this
|
|
77
|
+
repository. Any implementation outside the Lux ecosystem may require
|
|
78
|
+
a separate commercial license.
|
|
79
|
+
|
|
80
|
+
6. DISCLAIMER OF WARRANTY
|
|
81
|
+
|
|
82
|
+
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
83
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
84
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
85
|
+
|
|
86
|
+
7. LIMITATION OF LIABILITY
|
|
87
|
+
|
|
88
|
+
IN NO EVENT SHALL LUX INDUSTRIES INC BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
89
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
90
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE.
|
|
91
|
+
|
|
92
|
+
8. TERMINATION
|
|
93
|
+
|
|
94
|
+
This license terminates immediately upon any breach, including but not
|
|
95
|
+
limited to deployment on unauthorized networks or creation of forks.
|
|
96
|
+
|
|
97
|
+
9. GOVERNING LAW
|
|
98
|
+
|
|
99
|
+
This License shall be governed by the laws of the State of Delaware.
|
|
100
|
+
|
|
101
|
+
10. COMMERCIAL LICENSING
|
|
102
|
+
|
|
103
|
+
For commercial use outside the Lux ecosystem:
|
|
104
|
+
|
|
105
|
+
Lux Industries Inc.
|
|
106
|
+
Email: licensing@lux.network
|
|
107
|
+
Subject: Commercial License Request
|
|
108
|
+
|
|
109
|
+
================================================================================
|
|
110
|
+
TL;DR
|
|
111
|
+
================================================================================
|
|
112
|
+
|
|
113
|
+
- Research/academic use = OK
|
|
114
|
+
- Lux Primary Network (Network ID=1, Chain ID=96369) = OK
|
|
115
|
+
- L1/L2/L3 chains descending from Lux Primary Network = OK
|
|
116
|
+
- Commercial products outside Lux ecosystem = Contact licensing@lux.network
|
|
117
|
+
- Forks = Absolutely not
|
|
118
|
+
|
|
119
|
+
================================================================================
|
|
120
|
+
|
|
121
|
+
See LP-0012 for full licensing documentation:
|
|
122
|
+
https://github.com/luxfi/lps/blob/main/LPs/lp-0012-ecosystem-licensing.md
|
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@l.x/privacy",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"fast-redact": "3.5.0"
|
|
6
|
+
},
|
|
7
|
+
"devDependencies": {
|
|
8
|
+
"@types/node": "22.13.1",
|
|
9
|
+
"@typescript/native-preview": "7.0.0-dev.20260311.1",
|
|
10
|
+
"depcheck": "1.4.7",
|
|
11
|
+
"eslint": "8.57.1",
|
|
12
|
+
"typescript": "5.8.3",
|
|
13
|
+
"@luxfi/eslint-config": "^1.0.5"
|
|
14
|
+
},
|
|
15
|
+
"nx": {
|
|
16
|
+
"includedScripts": []
|
|
17
|
+
},
|
|
18
|
+
"main": "src/index.ts",
|
|
19
|
+
"private": false,
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"scripts": {
|
|
22
|
+
"typecheck": "nx typecheck privacy",
|
|
23
|
+
"typecheck:tsgo": "nx typecheck:tsgo privacy",
|
|
24
|
+
"lint": "nx lint privacy",
|
|
25
|
+
"lint:fix": "nx lint:fix privacy",
|
|
26
|
+
"lint:biome": "nx lint:biome privacy",
|
|
27
|
+
"lint:biome:fix": "nx lint:biome:fix privacy",
|
|
28
|
+
"lint:eslint": "nx lint:eslint privacy",
|
|
29
|
+
"lint:eslint:fix": "nx lint:eslint:fix privacy",
|
|
30
|
+
"check:deps:usage": "nx check:deps:usage privacy"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@l.x/privacy",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "pkgs/privacy/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"targets": {
|
|
8
|
+
"typecheck": {},
|
|
9
|
+
"typecheck:tsgo": {},
|
|
10
|
+
"lint:biome": {},
|
|
11
|
+
"lint:biome:fix": {},
|
|
12
|
+
"lint:eslint": {},
|
|
13
|
+
"lint:eslint:fix": {},
|
|
14
|
+
"lint": {},
|
|
15
|
+
"lint:fix": {},
|
|
16
|
+
"check:deps:usage": {}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/email.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email truncation utility for privacy-preserving display.
|
|
3
|
+
*
|
|
4
|
+
* Shows first character + asterisks + last character of local part,
|
|
5
|
+
* keeps full domain for recognition.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* truncateEmail("john.doe@gmail.com") // "j***e@gmail.com"
|
|
9
|
+
* truncateEmail("ab@company.org") // "a*@company.org"
|
|
10
|
+
* truncateEmail("x@test.com") // "x*@test.com"
|
|
11
|
+
*/
|
|
12
|
+
export function truncateEmail(email: string): string {
|
|
13
|
+
if (!email || typeof email !== 'string') {
|
|
14
|
+
return '***@***'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const atIndex = email.indexOf('@')
|
|
18
|
+
if (atIndex === -1) {
|
|
19
|
+
return '***@***'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const localPart = email.slice(0, atIndex)
|
|
23
|
+
const domain = email.slice(atIndex + 1)
|
|
24
|
+
|
|
25
|
+
if (!localPart || !domain) {
|
|
26
|
+
return '***@***'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Truncate local part: show first char + asterisks + last char (if > 2 chars)
|
|
30
|
+
let truncatedLocal: string
|
|
31
|
+
if (localPart.length <= 1) {
|
|
32
|
+
truncatedLocal = localPart + '*'
|
|
33
|
+
} else if (localPart.length === 2) {
|
|
34
|
+
truncatedLocal = localPart[0] + '*'
|
|
35
|
+
} else {
|
|
36
|
+
truncatedLocal = localPart[0] + '***' + localPart[localPart.length - 1]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return `${truncatedLocal}@${domain}`
|
|
40
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare module 'fast-redact' {
|
|
2
|
+
interface FastRedactOptions {
|
|
3
|
+
paths: string[]
|
|
4
|
+
serialize?: false | ((obj: Record<string, unknown>) => string)
|
|
5
|
+
censor?: string
|
|
6
|
+
strict?: boolean
|
|
7
|
+
remove?: boolean
|
|
8
|
+
}
|
|
9
|
+
function fastRedact(
|
|
10
|
+
options: FastRedactOptions & { serialize: false },
|
|
11
|
+
): (obj: Record<string, unknown>) => Record<string, unknown>
|
|
12
|
+
function fastRedact(options: FastRedactOptions): (obj: Record<string, unknown>) => string
|
|
13
|
+
export default fastRedact
|
|
14
|
+
}
|
package/src/index.ts
ADDED
package/src/scrub.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PII Scrubbing Layer
|
|
3
|
+
*
|
|
4
|
+
* Two-layer defense: path-based redaction (fast-redact) for known fields,
|
|
5
|
+
* then regex pattern scanning for PII in arbitrary string values.
|
|
6
|
+
*
|
|
7
|
+
* Explicit contract: configurable patterns, injectable into logger pipeline.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import fastRedact from 'fast-redact'
|
|
11
|
+
|
|
12
|
+
/** Pattern definition for regex-based string scanning */
|
|
13
|
+
export interface ScrubPattern {
|
|
14
|
+
/** Human-readable name for this pattern */
|
|
15
|
+
name: string
|
|
16
|
+
/** Regex to match sensitive data */
|
|
17
|
+
pattern: RegExp
|
|
18
|
+
/** Replacement string */
|
|
19
|
+
replacement: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Configuration for the scrubber factory */
|
|
23
|
+
export interface ScrubberOptions {
|
|
24
|
+
/** Paths to redact via fast-redact (e.g., 'headers.cookie') */
|
|
25
|
+
redactPaths?: string[]
|
|
26
|
+
/** Regex patterns for string scanning */
|
|
27
|
+
patterns?: ScrubPattern[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The scrubber function signature */
|
|
31
|
+
export type Scrubber = (obj: Record<string, unknown>) => Record<string, unknown>
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_REDACT_PATHS: string[] = [
|
|
34
|
+
'password',
|
|
35
|
+
'secret',
|
|
36
|
+
'authorization',
|
|
37
|
+
'cookie',
|
|
38
|
+
'["set-cookie"]',
|
|
39
|
+
'["x-api-key"]',
|
|
40
|
+
'credentials',
|
|
41
|
+
'email',
|
|
42
|
+
'identifier',
|
|
43
|
+
'*.email',
|
|
44
|
+
'*.identifier',
|
|
45
|
+
'*.password',
|
|
46
|
+
'*.secret',
|
|
47
|
+
'*.authorization',
|
|
48
|
+
'*.cookie',
|
|
49
|
+
'headers.cookie',
|
|
50
|
+
'headers.authorization',
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
export const DEFAULT_SCRUB_PATTERNS: ScrubPattern[] = [
|
|
54
|
+
{
|
|
55
|
+
name: 'email',
|
|
56
|
+
pattern: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,
|
|
57
|
+
replacement: '[EMAIL_REDACTED]',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'jwt',
|
|
61
|
+
pattern: /eyJ[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}\.[a-zA-Z0-9_-]{10,}/g,
|
|
62
|
+
replacement: '[JWT_REDACTED]',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'api_key',
|
|
66
|
+
pattern: /(?:api[_-]?key|token|secret|authorization)['":\s]*[a-zA-Z0-9_-]{32,}/gi,
|
|
67
|
+
replacement: '[API_KEY_REDACTED]',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'ethereum_address',
|
|
71
|
+
pattern: /0x[a-fA-F0-9]{40}/g,
|
|
72
|
+
replacement: '[WALLET_REDACTED]',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'ipv4',
|
|
76
|
+
pattern: /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,
|
|
77
|
+
replacement: '[IP_REDACTED]',
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
/** Scan a string value and replace all matching patterns */
|
|
82
|
+
function scrubString(value: string, patterns: ScrubPattern[]): string {
|
|
83
|
+
let result = value
|
|
84
|
+
for (const { pattern, replacement } of patterns) {
|
|
85
|
+
// Reset lastIndex for global regexps to ensure clean state
|
|
86
|
+
pattern.lastIndex = 0
|
|
87
|
+
result = result.replace(pattern, replacement)
|
|
88
|
+
}
|
|
89
|
+
return result
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Recursively walk an object and scrub all string values */
|
|
93
|
+
function scrubValue(value: unknown, patterns: ScrubPattern[]): unknown {
|
|
94
|
+
if (typeof value === 'string') {
|
|
95
|
+
return scrubString(value, patterns)
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(value)) {
|
|
98
|
+
return value.map((item) => scrubValue(item, patterns))
|
|
99
|
+
}
|
|
100
|
+
if (value !== null && typeof value === 'object') {
|
|
101
|
+
const result: Record<string, unknown> = {}
|
|
102
|
+
for (const [key, val] of Object.entries(value)) {
|
|
103
|
+
result[key] = scrubValue(val, patterns)
|
|
104
|
+
}
|
|
105
|
+
return result
|
|
106
|
+
}
|
|
107
|
+
// Numbers, booleans, null, undefined pass through untouched
|
|
108
|
+
return value
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Create a scrubber function with the given options.
|
|
113
|
+
*
|
|
114
|
+
* Layer 1: fast-redact replaces known sensitive paths with "[REDACTED]"
|
|
115
|
+
* Layer 2: regex patterns scan all remaining string values for PII
|
|
116
|
+
*/
|
|
117
|
+
export function createScrubber(options?: ScrubberOptions): Scrubber {
|
|
118
|
+
const redactPaths = options?.redactPaths ?? DEFAULT_REDACT_PATHS
|
|
119
|
+
const patterns = options?.patterns ?? DEFAULT_SCRUB_PATTERNS
|
|
120
|
+
|
|
121
|
+
const redact = fastRedact({
|
|
122
|
+
paths: redactPaths,
|
|
123
|
+
serialize: false,
|
|
124
|
+
censor: '[REDACTED]',
|
|
125
|
+
}) as (obj: Record<string, unknown>) => Record<string, unknown>
|
|
126
|
+
|
|
127
|
+
return (obj: Record<string, unknown>): Record<string, unknown> => {
|
|
128
|
+
// Layer 1: path-based redaction (mutates in place, returns same ref)
|
|
129
|
+
const redacted = redact(obj)
|
|
130
|
+
|
|
131
|
+
// Layer 2: pattern-based string scanning (returns new object)
|
|
132
|
+
return scrubValue(redacted, patterns) as Record<string, unknown>
|
|
133
|
+
}
|
|
134
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../config/tsconfig/app.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"src/**/*.ts",
|
|
5
|
+
"src/**/*.tsx",
|
|
6
|
+
"src/**/*.json",
|
|
7
|
+
"src/global.d.ts"
|
|
8
|
+
],
|
|
9
|
+
"exclude": [
|
|
10
|
+
"src/**/*.spec.ts",
|
|
11
|
+
"src/**/*.spec.tsx",
|
|
12
|
+
"src/**/*.test.ts",
|
|
13
|
+
"src/**/*.test.tsx"
|
|
14
|
+
],
|
|
15
|
+
"compilerOptions": {
|
|
16
|
+
"noEmit": false,
|
|
17
|
+
"emitDeclarationOnly": true,
|
|
18
|
+
"types": ["node"],
|
|
19
|
+
"paths": {}
|
|
20
|
+
},
|
|
21
|
+
"references": [
|
|
22
|
+
{
|
|
23
|
+
"path": "../eslint-config"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|