Skip to content

Commit 3c224a8

Browse files
Merge pull request #114 from IABTechLab/ans-UID2-4449-helper-for-euid-hashing-tool
UID2 Helper for Hashing generalized for EUID
2 parents e1182a5 + bd95942 commit 3c224a8

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/euidSdk.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EventType, CallbackHandler } from './callbackManager';
2-
import { CallbackContainer, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
2+
import { CallbackContainer, UIDHelper, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
33
import { ProductDetails } from './product';
44
import { UidSecureSignalProviderType } from './secureSignal_types';
55
import { loadConfig } from './configManager';
@@ -55,6 +55,7 @@ export class EUID extends SdkBase {
5555
declare global {
5656
interface Window {
5757
__euid: EUID | SDKSetup | undefined;
58+
__euidHelper: UIDHelper | undefined;
5859
__euidSecureSignalProvider?: UidSecureSignalProviderType;
5960
}
6061
}
@@ -80,6 +81,7 @@ export function __euidInternalHandleScriptLoad() {
8081
const callbacks = window?.__euid?.callbacks || [];
8182
const callbackContainer: CallbackContainer = {};
8283
window.__euid = new EUID(callbacks, callbackContainer);
84+
window.__euidHelper = new UIDHelper();
8385
if (callbackContainer.callback) callbackContainer.callback();
8486
bootstrapInit();
8587
}

src/sdkBase.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { isNormalizedPhone, normalizeEmail } from './diiNormalization';
1313
import { isBase64Hash } from './hashedDii';
1414
import { PromiseHandler } from './promiseHandler';
1515
import { StorageManager } from './storageManager';
16-
import { hashAndEncodeIdentifier } from './encoding/hash';
16+
import { hashAndEncodeIdentifier, hashIdentifier } from './encoding/hash';
1717
import { ProductDetails, ProductName } from './product';
1818
import { storeConfig, updateConfig } from './configManager';
1919
import { loadIdentityFromCookieNoLegacy } from './cookieManager';
@@ -27,6 +27,24 @@ export type SDKSetup = {
2727
};
2828
export type CallbackContainer = { callback?: () => void };
2929

30+
export class UIDHelper {
31+
public normalizeEmail(email: string) {
32+
return normalizeEmail(email);
33+
}
34+
35+
public hashIdentifier(normalizedEmail: string) {
36+
return hashIdentifier(normalizedEmail);
37+
}
38+
39+
public async hashAndEncodeIdentifier(normalizedEmail: string) {
40+
return await hashAndEncodeIdentifier(normalizedEmail);
41+
}
42+
43+
public isNormalizedPhone(phone: string) {
44+
return isNormalizedPhone(phone);
45+
}
46+
}
47+
3048
export abstract class SdkBase {
3149
static get VERSION() {
3250
return version;

src/uid2Sdk.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,11 @@
11
import { EventType, CallbackHandler } from './callbackManager';
2-
import { isNormalizedPhone, normalizeEmail } from './diiNormalization';
3-
import { hashAndEncodeIdentifier, hashIdentifier } from './encoding/hash';
4-
import { CallbackContainer, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
2+
import { CallbackContainer, UIDHelper, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
53
import { ProductDetails } from './product';
64
import { loadConfig } from './configManager';
75
import { UidSecureSignalProviderType } from './secureSignal_types';
86

97
export * from './exports';
108

11-
export class UID2Helper {
12-
public normalizeEmail(email: string) {
13-
return normalizeEmail(email);
14-
}
15-
16-
public hashIdentifier(normalizedEmail: string) {
17-
return hashIdentifier(normalizedEmail);
18-
}
19-
20-
public async hashAndEncodeIdentifier(normalizedEmail: string) {
21-
return await hashAndEncodeIdentifier(normalizedEmail);
22-
}
23-
24-
public isNormalizedPhone(phone: string) {
25-
return isNormalizedPhone(phone);
26-
}
27-
}
28-
299
const productDetails: ProductDetails = {
3010
name: 'UID2',
3111
defaultBaseUrl: 'https://prod.uidapi.com',
@@ -75,7 +55,7 @@ export class UID2 extends SdkBase {
7555
declare global {
7656
interface Window {
7757
__uid2: UID2 | SDKSetup | undefined;
78-
__uid2Helper: UID2Helper | undefined;
58+
__uid2Helper: UIDHelper | undefined;
7959
__uid2SecureSignalProvider?: UidSecureSignalProviderType;
8060
}
8161
}
@@ -102,7 +82,7 @@ export function __uid2InternalHandleScriptLoad() {
10282
const callbacks = window?.__uid2?.callbacks || [];
10383
const callbackContainer: CallbackContainer = {};
10484
window.__uid2 = new UID2(callbacks, callbackContainer);
105-
window.__uid2Helper = new UID2Helper();
85+
window.__uid2Helper = new UIDHelper();
10686
if (callbackContainer.callback) callbackContainer.callback();
10787
bootstrapInit();
10888
}

0 commit comments

Comments
 (0)