import type { BidderCode, StorageDisclosure } from "../../src/types/common"; import { STORAGE_TYPE_COOKIES, STORAGE_TYPE_LOCALSTORAGE, type StorageType } from "../../src/storageManager.ts"; import type { AllConsentData } from "../../src/consentHandler.ts"; import type { Ext } from '../../src/types/ortb/common'; import type { ORTBRequest } from "../../src/types/ortb/request"; export type UserIdProvider = string; export interface UserId { [idName: string]: unknown; } export interface ProvidersToId { } export type UserIdKeyFor
= P extends keyof ProvidersToId ? ProvidersToId[P] : unknown; export type UserIdFor
= P extends keyof ProvidersToId ? UserId[UserIdKeyFor
] : unknown; export interface ProviderParams { } export interface UserIdConfig
{
/**
* User ID provider name.
*/
name: P;
/**
* Module specific configuration parameters.
*/
params?: P extends keyof ProviderParams ? ProviderParams[P] : Record ;
}
type SerializableId = string | Record = P extends keyof ProvidersToId ? {
[K in UserIdKeyFor ]: UserIdFor ;
} & Partial ) => ORTBRequest['user']['eids'] | ORTBRequest['user']['eids'][number];
export type IdProviderSpec = StorageDisclosure & {
/**
* Name of your ID provider, used to match your module with the publisher’s userIds configuration
*/
name: P;
aliasName?: UserIdProvider;
/**
* GVL ID to use for TCF. If omitted your module may be excluded when TCF is in scope.
*/
gvlid?: number;
disclosureURL?: string;
/**
* Invoked when:
* - Prebid.js did not previously store your ID, or
* - your previously stored ID has expired (depending on the publisher’s expires and/or refreshInSecondsstorage configuration), or
* - consent data has changed since the last time it was stored, or
* - the publisher explicitly asked for a refresh using refreshUserIds.
* @param config Configuration for your module as provided by the publisher
* @param consentData available consent data (when the relevant modules are present)
* @param storedId Your previously stored ID data, if any, as was returned by getId or extendId
*/
getId: (config: UserIdConfig , consentData: AllConsentData, storedId?: SerializableId) => ProviderResponse;
/**
* If provided, it’s invoked when getId is not; namely:
*
* - Prebid.js previously stored your ID, and
* - the stored ID has not expired, and
* - consent data has not changed since it was stored, and
* - the publisher is not asking for a refresh.
*
* Takes the same arguments and should return an object in the same format as getId.
*/
extendId?: IdProviderSpec ['getId'];
/**
* Decode ID data. Invoked every time data from your module is available, either from storage or getId / extendId.
*/
decode: (id: SerializableId, config: UserIdConfig ) => DecodedId ;
onDataDeletionRequest?: (config: UserIdConfig , userId: UserId[P], ...cmpArgs: any[]) => void;
/**
* Domain to use for cookie storage.
*/
domainOverride?: () => string;
/**
* Return the topmost parent of `fullDomain` (which defaults to the current page) that will allow cookie writes.
* This method is attached by the base ID module on submodule registration.
*/
findRootDomain?: (fullDomain?: string) => string;
eids?: {
[K in keyof UserId]?: K extends string ? EIDConfig