Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/euidSdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EventType, CallbackHandler } from './callbackManager';
import { CallbackContainer, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
import { CallbackContainer, IdHelper, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
import { ProductDetails } from './product';
import { UidSecureSignalProviderType } from './secureSignal_types';
import { loadConfig } from './configManager';
Expand Down Expand Up @@ -55,6 +55,7 @@ export class EUID extends SdkBase {
declare global {
interface Window {
__euid: EUID | SDKSetup | undefined;
__euidHelper: IdHelper | undefined;
__euidSecureSignalProvider?: UidSecureSignalProviderType;
}
}
Expand All @@ -80,6 +81,7 @@ export function __euidInternalHandleScriptLoad() {
const callbacks = window?.__euid?.callbacks || [];
const callbackContainer: CallbackContainer = {};
window.__euid = new EUID(callbacks, callbackContainer);
window.__euidHelper = new IdHelper();
if (callbackContainer.callback) callbackContainer.callback();
bootstrapInit();
}
Expand Down
20 changes: 19 additions & 1 deletion src/sdkBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { isNormalizedPhone, normalizeEmail } from './diiNormalization';
import { isBase64Hash } from './hashedDii';
import { PromiseHandler } from './promiseHandler';
import { StorageManager } from './storageManager';
import { hashAndEncodeIdentifier } from './encoding/hash';
import { hashAndEncodeIdentifier, hashIdentifier } from './encoding/hash';
import { ProductDetails, ProductName } from './product';
import { storeConfig, updateConfig } from './configManager';
import { loadIdentityFromCookieNoLegacy } from './cookieManager';
Expand All @@ -27,6 +27,24 @@ export type SDKSetup = {
};
export type CallbackContainer = { callback?: () => void };

export class IdHelper {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps UidHelper would be a better name? It is the generic term for UID2/EUID: https://unifiedid.com/docs/ref-info/glossary-uid#gl-uid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout, I've made this change

public normalizeEmail(email: string) {
return normalizeEmail(email);
}

public hashIdentifier(normalizedEmail: string) {
return hashIdentifier(normalizedEmail);
}

public async hashAndEncodeIdentifier(normalizedEmail: string) {
return await hashAndEncodeIdentifier(normalizedEmail);
}

public isNormalizedPhone(phone: string) {
return isNormalizedPhone(phone);
}
}

export abstract class SdkBase {
static get VERSION() {
return version;
Expand Down
26 changes: 3 additions & 23 deletions src/uid2Sdk.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { EventType, CallbackHandler } from './callbackManager';
import { isNormalizedPhone, normalizeEmail } from './diiNormalization';
import { hashAndEncodeIdentifier, hashIdentifier } from './encoding/hash';
import { CallbackContainer, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
import { CallbackContainer, IdHelper, sdkAssertErrorText, SdkBase, SDKSetup } from './sdkBase';
import { ProductDetails } from './product';
import { loadConfig } from './configManager';
import { UidSecureSignalProviderType } from './secureSignal_types';

export * from './exports';

export class UID2Helper {
public normalizeEmail(email: string) {
return normalizeEmail(email);
}

public hashIdentifier(normalizedEmail: string) {
return hashIdentifier(normalizedEmail);
}

public async hashAndEncodeIdentifier(normalizedEmail: string) {
return await hashAndEncodeIdentifier(normalizedEmail);
}

public isNormalizedPhone(phone: string) {
return isNormalizedPhone(phone);
}
}

const productDetails: ProductDetails = {
name: 'UID2',
defaultBaseUrl: 'https://prod.uidapi.com',
Expand Down Expand Up @@ -75,7 +55,7 @@ export class UID2 extends SdkBase {
declare global {
interface Window {
__uid2: UID2 | SDKSetup | undefined;
__uid2Helper: UID2Helper | undefined;
__uid2Helper: IdHelper | undefined;
__uid2SecureSignalProvider?: UidSecureSignalProviderType;
}
}
Expand All @@ -102,7 +82,7 @@ export function __uid2InternalHandleScriptLoad() {
const callbacks = window?.__uid2?.callbacks || [];
const callbackContainer: CallbackContainer = {};
window.__uid2 = new UID2(callbacks, callbackContainer);
window.__uid2Helper = new UID2Helper();
window.__uid2Helper = new IdHelper();
if (callbackContainer.callback) callbackContainer.callback();
bootstrapInit();
}
Expand Down