@hammr/normalizer 1.0.0 → 1.0.2
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/README.md +98 -0
- package/package.json +7 -2
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @hammr/normalizer
|
|
2
|
+
|
|
3
|
+
PII normalization and SHA256 hashing for ad platforms (Meta CAPI, Google, TikTok).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @hammr/normalizer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Normalizer } from '@hammr/normalizer';
|
|
15
|
+
|
|
16
|
+
const normalizer = new Normalizer();
|
|
17
|
+
|
|
18
|
+
// Normalize and hash user data
|
|
19
|
+
const result = await normalizer.normalize({
|
|
20
|
+
email: ' Test@Example.COM ',
|
|
21
|
+
phone: '+1 (555) 123-4567',
|
|
22
|
+
firstName: 'John',
|
|
23
|
+
lastName: 'Doe',
|
|
24
|
+
city: 'San Francisco',
|
|
25
|
+
state: 'CA',
|
|
26
|
+
zipCode: '94102',
|
|
27
|
+
country: 'US'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
console.log(result);
|
|
31
|
+
// {
|
|
32
|
+
// em: 'b4c9a289323b21a01c3e807f0769a8be...', // SHA256 hash
|
|
33
|
+
// ph: '15551234567', // E.164 format
|
|
34
|
+
// fn: 'john',
|
|
35
|
+
// ln: 'doe',
|
|
36
|
+
// ct: 'sanfrancisco',
|
|
37
|
+
// st: 'ca',
|
|
38
|
+
// zp: '94102',
|
|
39
|
+
// country: 'us'
|
|
40
|
+
// }
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- Email normalization (trim, lowercase, hash)
|
|
46
|
+
- Phone normalization (E.164 format, hash)
|
|
47
|
+
- Name normalization (lowercase, no spaces)
|
|
48
|
+
- Address normalization (city, state, zip, country)
|
|
49
|
+
- SHA256 hashing via Web Crypto API
|
|
50
|
+
- Gender and DOB normalization
|
|
51
|
+
- Type-safe with TypeScript
|
|
52
|
+
|
|
53
|
+
## API
|
|
54
|
+
|
|
55
|
+
### `Normalizer`
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const normalizer = new Normalizer();
|
|
59
|
+
|
|
60
|
+
// Normalize full user data
|
|
61
|
+
const result = await normalizer.normalize(userData);
|
|
62
|
+
|
|
63
|
+
// Individual normalizers
|
|
64
|
+
normalizer.normalizeEmail('test@example.com'); // 'test@example.com'
|
|
65
|
+
normalizer.normalizePhone('+1 555-123-4567'); // '15551234567'
|
|
66
|
+
normalizer.normalizeName('John Doe'); // 'johndoe'
|
|
67
|
+
normalizer.normalizeCity('San Francisco'); // 'sanfrancisco'
|
|
68
|
+
normalizer.normalizeState('CA'); // 'ca'
|
|
69
|
+
normalizer.normalizeZipCode('94102-1234'); // '94102'
|
|
70
|
+
normalizer.normalizeCountry('United States'); // 'us'
|
|
71
|
+
normalizer.normalizeGender('Male'); // 'm'
|
|
72
|
+
normalizer.normalizeDateOfBirth('1990-01-15'); // '19900115'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### `sha256(input: string): Promise<string>`
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { sha256 } from '@hammr/normalizer';
|
|
79
|
+
|
|
80
|
+
const hash = await sha256('test@example.com');
|
|
81
|
+
// 'b4c9a289323b21a01c3e807f0769a8be7e60c8ece9eb35e14e9f3b7e5c1d2e3f'
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Use Cases
|
|
85
|
+
|
|
86
|
+
- CDN Artifact Hashing
|
|
87
|
+
- Authentication systems
|
|
88
|
+
- Meta Conversions API (CAPI)
|
|
89
|
+
- Google Enhanced Conversions
|
|
90
|
+
- TikTok Events API
|
|
91
|
+
- Snapchat Conversions API
|
|
92
|
+
- Any platform requiring hashed PII
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
Apache-2.0
|
|
97
|
+
|
|
98
|
+
Copyright 2026 Edge Foundry, Inc.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hammr/normalizer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "PII normalization and SHA256 hashing for Meta CAPI and ad platforms",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -48,5 +48,10 @@
|
|
|
48
48
|
"node": ">=18"
|
|
49
49
|
},
|
|
50
50
|
"author": "Edge Foundry, Inc.",
|
|
51
|
-
"license": "Apache-2.0"
|
|
51
|
+
"license": "Apache-2.0",
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "https://github.com/edgefoundryinc/normalizer"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://hammrcdn.com/"
|
|
52
57
|
}
|