Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a TypeScript types definition package #759

Open
eroncastro opened this issue Aug 15, 2023 · 6 comments
Open

Creating a TypeScript types definition package #759

eroncastro opened this issue Aug 15, 2023 · 6 comments

Comments

@eroncastro
Copy link

Hi.

In our company, we are trying to implement a TypeScript types definition package to be used along implementations that use Protected Audience.

Should we follow https://wicg.github.io/turtledove?

Thanks!

@eroncastro eroncastro changed the title Types documentation Creating a TypeScript type definition Aug 15, 2023
@eroncastro eroncastro changed the title Creating a TypeScript type definition Creating a TypeScript types definition package Aug 15, 2023
@JensenPaul
Copy link
Collaborator

https://wicg.github.io/turtledove is Protected Audience's most up-to-date spec.
@eroncastro, could you please update your GitHub profile with your company affiliation?

@JacobGo
Copy link
Contributor

JacobGo commented Aug 16, 2023

+1 to Chrome contributing official TypeScript types for Privacy Sandbox APIs not included in the existing Microsoft @types/web package generated from browser specs. lib.dom.d.ts is a critical library when writing TypeScript on the browser. Manually maintained typings from the IDLs can fall out of sync and lead to errors as definitions evolve over time.

@eroncastro
Copy link
Author

eroncastro commented Aug 16, 2023

Hi @JensenPaul

https://wicg.github.io/turtledove is Protected Audience's most up-to-date spec.

Thanks for confirming.
I want to point out, however, that while walking through it I could not find some of the signatures described in the FLEDGE explainer. For functions generateBid, reportResult, and reportWin, for example, I have found their return types but not their arguments. Am I missing something?

@eroncastro, could you please update your GitHub profile with your company affiliation?

Absolutely. Updated.

@JensenPaul
Copy link
Collaborator

generateBid, scoreAd, reportResult, and reportWin are not directly callable from web pages. They are implemented by people wishing to participate in Protected Audience auctions and called by the browser in a JavaScript environment separate from the typical web page JavaScript execution contexts.

@eroncastro
Copy link
Author

eroncastro commented Aug 17, 2023

@JensenPaul I understand that.

But, for people that are going to write JavaScript code to participate on the auctions, these methods signatures will be useful. And, by leveraging TypeScript static types, they can ensure they are doing it in a type safe way, preventing runtime errors.

Are there any official documents including these signatures?

@fhoering
Copy link
Contributor

fhoering commented Aug 29, 2023

Most input types like interestGroup, perBuyerSignals, trustedBiddingSignals are custom. So it will be different for each implementer.

What about adding some index.d.ts file to this repo ? For browserSignals it seems useful to have the type of each field and as this is also different for generateBid & reportResult

Here is what we are using at Criteo as a buyer so far (no guarantee of correctness)

interface Ad {
    render_url: string
}

interface BidBrowserSignals {
    topWindowHostname: string;
    seller: string;
    topLevelSeller: string;
    joinCount: number;
    bidCount: number;
    prevWins: [number, Ad][];  
    dataVersion: number;
}

interface ReportWinBrowserSignals {
    topWindowHostname: string;
    interestGroupOwner: string;
    interestGroupName?: string;
    buyerReportingId?: string;
    buyerAndSellerReportingId?: string;
    renderUrl: string;
    bid: number;
    bidCurrency?: string;
    adCost: number;
    modelingSignals: number;
    joinCount: number;
    recency: number;
    highestScoringOtherBid: number;
    highestScoringOtherBidCurrency?: string;
    madeHighestScoringOtherBid: boolean;
    seller: string;
    topLevelSeller: string;    
    dataVersion: number;
}

interface GenerateBidAd {
    campaignId: number;
}

interface GenerateBidResult {
    ad?: GenerateBidAd;
    bid: number;
    render?: string,
    allowComponentAuction?: boolean,
    adComponents?: string[],
    modelingSignals?: number
}

declare function reportWin(auctionSignals: any, perBuyerSignals: any, sellerSignals: any, browserSignals: ReportWinBrowserSignals): void;
declare function generateBid(interestGroup: any, auctionSignals: any, perBuyerSignals: any, trustedBiddingSignals: any, browserSignals: BidBrowserSignals): GenerateBidResult;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants