Skip to content

Commit dffc558

Browse files
add dockerfile and update readme instructions for hashing tool
1 parent 2aa3de9 commit dffc558

File tree

11 files changed

+155
-1534
lines changed

11 files changed

+155
-1534
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ See the list below for the name of all individual services.
8989
| `prebid-client-server` | Prebid Client Server | 3052 | http://localhost:3052 |
9090
| `prebid-client-side-deferred` | Prebid Client Side Deferred | 3053 | http://localhost:3053 |
9191
| `prebid-secure-signals-client-side` | Prebid Secure Signals | 3061 | http://localhost:3061 |
92+
| `hashing-tool` | Hashing Tool | 3071 | http://localhost:3071 |
9293

9394
---
9495

docker-compose.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,13 @@ services:
139139
env_file:
140140
- .env
141141

142-
142+
# tools
143+
hashing-tool:
144+
build:
145+
context: tools/hashing-tool
146+
dockerfile: Dockerfile
147+
ports:
148+
- "3071:3071"
149+
container_name: hashing-tool
150+
env_file:
151+
- .env

siteDetails.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ const sites = [
8585
port: 3061,
8686
description: 'Prebid Secure Signals Client Side',
8787
},
88+
89+
// Tools
90+
{
91+
name: 'hashing-tool',
92+
domain: 'hashing-tool.sample-dev.com',
93+
port: 3071,
94+
description: 'Hashing Tool',
95+
},
8896
];
8997

9098
// Export for CommonJS (used by createCA.ts)

tools/hashing-tool/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM nginx:alpine
2+
3+
# Install gettext for envsubst
4+
RUN apk add --no-cache gettext
5+
6+
# Copy static files
7+
COPY index.html /usr/share/nginx/html/index.html
8+
COPY app.css /usr/share/nginx/html/app.css
9+
10+
# Copy entrypoint script
11+
COPY entrypoint.sh /entrypoint.sh
12+
RUN chmod +x /entrypoint.sh
13+
14+
# Configure nginx to serve on port 3071
15+
RUN echo 'server { \
16+
listen 3071; \
17+
location / { \
18+
root /usr/share/nginx/html; \
19+
index index.html; \
20+
} \
21+
}' > /etc/nginx/conf.d/default.conf
22+
23+
EXPOSE 3071
24+
25+
ENTRYPOINT ["/entrypoint.sh"]

tools/hashing-tool/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# UID2/EUID Hashing Tool
2+
3+
A tool to verify that your implementation is normalizing and hashing email addresses and phone numbers correctly for UID2 and EUID.
4+
5+
> **Note:** The normalization and hashing logic is identical for both UID2 and EUID.
6+
7+
## Running Locally
8+
9+
### Using Docker Compose
10+
11+
From the repository root:
12+
13+
```bash
14+
docker-compose up -d hashing-tool
15+
```
16+
17+
Access at: http://localhost:3071
18+
19+
### Using the Reverse Proxy (HTTPS)
20+
21+
```bash
22+
docker-compose up -d
23+
```
24+
25+
Access at: https://hashing-tool.sample-dev.com (requires hosts file and certificate setup — see [reverse-proxy README](../reverse-proxy/README.md))
26+
27+
## Usage
28+
29+
1. Select **Email** or **Phone Number**
30+
2. Enter the value to hash
31+
3. Click **Enter**
32+
4. View the normalized value, SHA-256 hash, and base64-encoded result
33+
34+
## Documentation
35+
36+
- [UID2 Normalization and Encoding](https://unifiedid.com/docs/getting-started/gs-normalization-encoding)
37+
- [EUID Normalization and Encoding](https://euid.eu/docs/getting-started/gs-normalization-encoding)
38+

tools/hashing-tool/entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
# Set default values if not provided
4+
export UID_JS_SDK_URL=${UID_JS_SDK_URL:-"https://cdn.integ.uidapi.com/uid2-sdk-4.0.1.js"}
5+
export UID_JS_SDK_NAME=${UID_JS_SDK_NAME:-"__uid2"}
6+
export IDENTITY_NAME=${IDENTITY_NAME:-"UID2"}
7+
export DOCS_BASE_URL=${DOCS_BASE_URL:-"https://unifiedid.com/docs"}
8+
9+
# Process index.html template with environment variables
10+
envsubst < /usr/share/nginx/html/index.html > /usr/share/nginx/html/index.temp.html
11+
mv /usr/share/nginx/html/index.temp.html /usr/share/nginx/html/index.html
12+
13+
# Start nginx
14+
exec nginx -g "daemon off;"
15+

tools/hashing-tool/index.html

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,30 @@
22
<html>
33
<head>
44
<meta charset="UTF-8" />
5-
<title>UID2 Hashing Tool</title>
5+
<title>${IDENTITY_NAME} Hashing Tool</title>
66
<link rel="stylesheet" type="text/css" href="./app.css" />
7-
<link rel="shortcut icon" href="/img/favicon.ico" />
8-
<script src="./uid2-sdk-3.3.0.js"></script>
7+
<script src="${UID_JS_SDK_URL}"></script>
98
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
109
</head>
1110
<script>
12-
console.log('Initializing example.');
11+
console.log('Initializing ${IDENTITY_NAME} Hashing Tool.');
12+
13+
// __uid2 for UID2 SDK, __euid for EUID SDK
14+
const sdkName = '${UID_JS_SDK_NAME}';
15+
16+
// Helper object is named __uid2Helper or __euidHelper based on SDK
17+
function getHelper() {
18+
return window[sdkName + 'Helper'];
19+
}
1320

1421
async function updateGuiElements(normalizedInput, inputType) {
1522
console.log('Updating displayed values.');
23+
const helper = getHelper();
1624

17-
if (normalizedInput) {
18-
const hashedValue = await window.__uid2Helper.hashIdentifier(normalizedInput);
25+
if (normalizedInput && helper) {
26+
const hashedValue = await helper.hashIdentifier(normalizedInput);
1927
$('#hashed').text(hashedValue);
20-
const encodedValue = await window.__uid2Helper.hashAndEncodeIdentifier(normalizedInput);
28+
const encodedValue = await helper.hashAndEncodeIdentifier(normalizedInput);
2129
$('#base64_encoded').text(encodedValue);
2230
}
2331
else {
@@ -73,15 +81,22 @@
7381
$('.alert').hide();
7482
const inputValue = $('#input_value').val();
7583
const inputType = document.querySelector('input[name="toggle_input_type"]:checked').value;
84+
const helper = getHelper();
7685
let normalizedInput = undefined;
86+
87+
if (!helper) {
88+
console.error('SDK helper not loaded yet');
89+
return;
90+
}
91+
7792
if (inputType == "mobile") {
78-
const isNormalizedPhone = window.__uid2Helper.isNormalizedPhone(inputValue)
93+
const isNormalizedPhone = helper.isNormalizedPhone(inputValue)
7994
if (isNormalizedPhone) {
8095
normalizedInput = inputValue;
8196
}
8297
}
8398
if (inputType === "email") {
84-
normalizedInput = window.__uid2Helper.normalizeEmail(inputValue);
99+
normalizedInput = helper.normalizeEmail(inputValue);
85100
$('#normalization_value').text(normalizedInput);
86101
}
87102
updateGuiElements(normalizedInput, inputType);
@@ -91,13 +106,13 @@
91106

92107
</script>
93108
<body>
94-
<h1>UID2 Hashing Tool</h1>
109+
<h1>${IDENTITY_NAME} Hashing Tool</h1>
95110
<p class="intro">
96111
Use this tool to verify that your own implementation is normalizing and
97112
encoding correctly. Choose Email or Phone Number, then type or paste the
98113
value and click Enter. <br><br>
99114
<b>NOTE:</b> Normalize phone numbers before using the tool.
100-
For details and examples, see <a href="https://unifiedid.com/docs/getting-started/gs-normalization-encoding">Normalization and Encoding</a>.
115+
For details and examples, see <a href="${DOCS_BASE_URL}/getting-started/gs-normalization-encoding" target="_blank">Normalization and Encoding</a>.
101116
</p>
102117

103118
<input type="radio" id="toggle_email" name="toggle_input_type" value="email" onclick="handleRadioClick(this)" checked>

0 commit comments

Comments
 (0)