New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@magnite/fledge.polyfill

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@magnite/fledge.polyfill - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Changelog

### 0.3.0 (2021-05-14)
### Features
* convert all snake_case to camelCase ([#74](https://github.com/MagniteEngineering/fledge.polyfill/issues/74)) ([9f035d0](https://github.com/MagniteEngineering/fledge.polyfill/commit/9f035d0))
### 0.2.0 (2021-05-13)

@@ -7,0 +13,0 @@

5

dist/frame/cjs/index.js

@@ -295,6 +295,7 @@ 'use strict';

debug && echo.log(echo.asProcess('updating an interest group'));
await update(id, {
await update(id, (val) => ({
_expired: Date.now() + expiry,
...val,
...options,
}, customStore);
}), customStore);
} else {

@@ -301,0 +302,0 @@ debug && echo.log(echo.asProcess('creating a new interest group'));

@@ -273,6 +273,7 @@ /* eslint-disable no-console, compat/compat */

debug && echo.log(echo.asProcess('updating an interest group'));
await update(id, {
await update(id, (val) => ({
_expired: Date.now() + expiry,
...val,
...options,
}, customStore);
}), customStore);
} else {

@@ -279,0 +280,0 @@ debug && echo.log(echo.asProcess('creating a new interest group'));

2

dist/frame/iife/index.min.js

@@ -1,1 +0,1 @@

var fledgeframe=function(){"use strict";let e=[];const o={},n="%c ";function t(t){return function(...r){const s=[],a=[];r.forEach((t=>{if(t===o){const o=e.shift();s.push(`%c${o.value}`,n),a.push(o.css,"")}else"object"==typeof t||"function"==typeof t?(s.push("%o",n),a.push(t,"")):(s.push(`%c${t}`,n),a.push("",""))})),t(s.join(""),...a),e=[]}}const r={assert:t(console.assert),clear:t(console.clear),count:t(console.count),countReset:t(console.countReset),debug:t(console.debug),dir:t(console.dir),error:t(console.error),group:t(console.group),groupCollapsed:t(console.groupCollapsed),groupEnd:t(console.groupEnd),info:t(console.info),log:t(console.log),table:t(console.table),time:t(console.time),timeEnd:t(console.timeEnd),timeLog:t(console.timeLog),trace:t(console.trace),warn:t(console.warn),asAlert:function(n){return e.push({value:n,css:"display: inline-block; background-color: #dc3545; color: #ffffff; font-weight: bold; padding: 3px 7px 3px 7px; border-radius: 3px 3px 3px 3px;"}),o},asInfo:function(n){return e.push({value:n,css:"color: #0366d6; font-weight: bold;"}),o},asProcess:function(n){return e.push({value:`${n}…`,css:"color: #8c8c8c; font-style: italic;"}),o},asSuccess:function(n){return e.push({value:n,css:"color: #289d45; font-weight: bold;"}),o},asWarning:function(n){return e.push({value:n,css:"display: inline-block; background-color: #ffc107; color: black; font-weight: bold; padding: 3px 7px 3px 7px; border-radius: 3px 3px 3px 3px;"}),o}};function s(e){return new Promise(((o,n)=>{e.oncomplete=e.onsuccess=()=>o(e.result),e.onabort=e.onerror=()=>n(e.error)}))}function a(e,o){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(o);const t=s(n);return(e,n)=>t.then((t=>n(t.transaction(o,e).objectStore(o))))}let i;function c(){return i||(i=a("keyval-store","keyval")),i}function l(e=c()){const o=[];return function(e,o){return e("readonly",(e=>(e.openCursor().onsuccess=function(){this.result&&(o(this.result),this.result.continue())},s(e.transaction))))}(e,(e=>o.push([e.key,e.value]))).then((()=>o))}const u=a("fledge.v1","interest-groups"),g=(e,o)=>`${e}-${o}`;async function d(e,o,n){n&&r.groupCollapsed("Fledge API: joinAdInterest");const t=g(e.owner,e.name),a=await function(e,o=c()){return o("readonly",(o=>s(o.get(e))))}(t,u);return n&&r.log(r.asInfo("checking for an existing interest group:"),a),a?(n&&r.log(r.asProcess("updating an interest group")),await function(e,o,n=c()){return n("readwrite",(n=>new Promise(((t,r)=>{n.get(e).onsuccess=function(){try{n.put(o(this.result),e),t(s(n.transaction))}catch(e){r(e)}}}))))}(t,{_expired:Date.now()+o,...e},u)):(n&&r.log(r.asProcess("creating a new interest group")),await function(e,o,n=c()){return n("readwrite",(n=>(n.put(o,e),s(n.transaction))))}(t,{_created:Date.now(),_expired:Date.now()+o,_updated:Date.now(),...e},u)),n&&r.log(r.asSuccess("interest group id:"),t),n&&r.groupEnd(),!0}async function p(e,o){return o&&r.groupCollapsed("Fledge API: leaveAdInterest"),o&&r.log(r.asProcess("deleting an existing interest group")),await function(e,o=c()){return o("readwrite",(o=>(o.delete(e),s(o.transaction))))}(g(e.owner,e.name),u),o&&r.log(r.asSuccess("interest group deleted")),o&&r.groupEnd(),!0}const f=async(e,o,n)=>{n&&r.groupCollapsed("auction utils: getTrustedSignals");const t=`hostname=${window.top.location.hostname}`;if(!e||!o)return n&&r.log(r.asWarning("No 'url' or 'keys' found!")),void(n&&r.groupEnd());const s=await fetch(`${e}?${t}&keys=${o.join(",")}`).then((e=>{if(!e.ok)throw new Error("Something went wrong! The response returned was not ok.");if(!(e=>/\bapplication\/json\b/.test(e?.headers?.get("content-type")))(e))throw new Error("Response was not in the format of JSON.");return e.json()})).catch((e=>(n&&r.log(r.asAlert("There was a problem with your fetch operation:")),n&&r.log(e),null))),a={};for(const[e,n]of s)o.includes(e)&&(a[e]=n);return a&&0===Object.keys(a).length&&a.constructor===Object?(n&&r.groupEnd(),a):(n&&r.log(r.asWarning("No signals found!")),n&&r.groupEnd(),null)};async function w(e,o){o&&r.groupCollapsed("Fledge API: runAdAuction");const n=await l(u);o&&r.log(r.asInfo("all interest groups:"),n);const t=((e,o,n)=>{if(n&&r.groupCollapsed("auction utils: getEligible"),"*"===o)return n&&r.info("using the wildcard yields all groups"),n&&r.groupEnd(),e;const t=e.filter((([e,n])=>o.includes(n.owner)));return t.length?(n&&r.info("found some eligible buyers"),n&&r.groupEnd(),t):(n&&r.log(r.asWarning("No groups were eligible!")),n&&r.groupEnd(),null)})(n,e.interest_group_buyers,o);if(o&&r.log(r.asInfo('eligible buyers based on "interest_group_buyers":'),t),!t)return o&&r.log(r.asAlert("No eligible interest group buyers found!")),null;const s=await(async(e,o,n)=>Promise.all(e.map((async([e,t])=>{n&&r.groupCollapsed(`auction utils: getBids => ${e}`);const s=performance.now(),{generateBid:a,generate_bid:i}=await import(t.bidding_logic_url);let c=a;if(i&&!a&&(c=i),!c&&"function"!=typeof c)return n&&r.log(r.asWarning("No 'generateBid' function found!")),n&&r.groupEnd(),null;const l=await f(t?.trusted_bidding_signals_url,t?.trusted_bidding_signals_keys,n);let u;try{u=c(t,o?.auction_signals,o?.per_buyer_signals?.[t.owner],l,{top_window_hostname:window.top.location.hostname,seller:o.seller}),n&&r.log(r.asInfo("bid:"),u)}catch(e){return n&&r.log(r.asAlert("There was an error in the 'generateBid' function:")),n&&r.log(e),null}if(!(u.ad&&"object"==typeof u.ad&&u.bid&&"number"==typeof u.bid&&u.render)||"string"!=typeof u.render&&!Array.isArray(u.render))return n&&r.log(r.asWarning("No bid found!")),n&&r.groupEnd(),null;const g=performance.now();return n&&r.groupEnd(),{...t,...u,duration:g-s}}))))(t,e,o);o&&r.log(r.asInfo("all bids from each buyer:"),s);const a=s.filter((e=>e));if(o&&r.log(r.asInfo("filtered bids:"),a),!a.length)return o&&r.log(r.asAlert("No bids found!")),o&&r.groupEnd(),null;o&&r.log(r.asProcess("getting all scores, filtering and sorting"));const[i]=await(async(e,o,n)=>{n&&r.groupCollapsed("auction utils: getScores");const{scoreAd:t,score_ad:s}=await import(o.decision_logic_url);let a=t;return s&&!t&&(a=s),a||"function"==typeof a?e.map((e=>{let t;try{t=a(e?.ad,e?.bid,o,o?.trusted_scoring_signals,{top_window_hostname:window.top.location.hostname,interest_group_owner:e.owner,interest_group_name:e.name,bidding_duration_msec:e.duration}),n&&r.log(r.asInfo("score:"),t)}catch(e){n&&r.log(r.asAlert("There was an error in the 'scoreAd' function:")),n&&r.log(e),t=-1}return n&&r.groupEnd(),{bid:e,score:t}})).filter((({score:e})=>e>0)).sort(((e,o)=>e.score>o.score?1:-1)):(n&&r.log(r.asWarning("No 'scoreAd' function was found!")),null)})(a,e,o);if(o&&r.log(r.asInfo("winner:"),i),!i)return o&&r.log(r.asAlert("No winner found!")),o&&r.groupEnd(),null;o&&r.log(r.asProcess("creating an entry in the auction store"));const c=([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)));return sessionStorage.setItem(c,JSON.stringify({origin:`${window.top.location.origin}${window.top.location.pathname}`,timestamp:Date.now(),conf:e,...i})),o&&r.log(r.asSuccess("auction token:"),c),o&&r.groupEnd(),c}async function h({data:e,ports:o}){try{if(!Array.isArray(e))throw new Error(`The API expects the data to be in the form of an array, with index 0 set to the action, and index 1 set to the data. A ${typeof e} was passed instead.`);switch(e[0]){case"joinAdInterestGroup":{const[,o]=e,[n,t,r]=o;return await d(n,t,r),!0}case"leaveAdInterestGroup":{const[,o]=e,[n,t]=o;return await p(n,t),!0}case"runAdAuction":{const[,n]=e,[t,r]=n;if(1!==o.length)throw new Error(`Port transfer mismatch during request: expected 1 port, but received ${o.length}`);const[s]=o,a=[!0,await w(t,r)];return s.postMessage(a),s.close(),!0}default:return!1}}catch(e){const n=[!1];for(const e of o)e.postMessage(n);throw e}}return async function(){const{searchParams:e}=new URL(window.location),o=e.get("debug")||!1;if(o&&r.group("Fledge: Storage Frame"),!(e.get("admin")||!1)){const[e]=window.location.ancestorOrigins;if(void 0===e)throw o&&r.log(r.asWarning("It appears your attempting to access this from the top-level document")),o&&r.log({origin:e,location:window.location}),new Error("Can't call 'postMessage' on the Frame window when run as a top-level document");const{port1:n,port2:t}=new MessageChannel;o&&r.log("message channel receiver:",n),o&&r.log("message channel sender:",t),n.onmessage=h,window.parent.postMessage({"fledge.polyfill":1},e,[t])}o&&r.groupEnd()}}();
var fledgeframe=function(){"use strict";let e=[];const o={},n="%c ";function t(t){return function(...r){const s=[],a=[];r.forEach((t=>{if(t===o){const o=e.shift();s.push(`%c${o.value}`,n),a.push(o.css,"")}else"object"==typeof t||"function"==typeof t?(s.push("%o",n),a.push(t,"")):(s.push(`%c${t}`,n),a.push("",""))})),t(s.join(""),...a),e=[]}}const r={assert:t(console.assert),clear:t(console.clear),count:t(console.count),countReset:t(console.countReset),debug:t(console.debug),dir:t(console.dir),error:t(console.error),group:t(console.group),groupCollapsed:t(console.groupCollapsed),groupEnd:t(console.groupEnd),info:t(console.info),log:t(console.log),table:t(console.table),time:t(console.time),timeEnd:t(console.timeEnd),timeLog:t(console.timeLog),trace:t(console.trace),warn:t(console.warn),asAlert:function(n){return e.push({value:n,css:"display: inline-block; background-color: #dc3545; color: #ffffff; font-weight: bold; padding: 3px 7px 3px 7px; border-radius: 3px 3px 3px 3px;"}),o},asInfo:function(n){return e.push({value:n,css:"color: #0366d6; font-weight: bold;"}),o},asProcess:function(n){return e.push({value:`${n}…`,css:"color: #8c8c8c; font-style: italic;"}),o},asSuccess:function(n){return e.push({value:n,css:"color: #289d45; font-weight: bold;"}),o},asWarning:function(n){return e.push({value:n,css:"display: inline-block; background-color: #ffc107; color: black; font-weight: bold; padding: 3px 7px 3px 7px; border-radius: 3px 3px 3px 3px;"}),o}};function s(e){return new Promise(((o,n)=>{e.oncomplete=e.onsuccess=()=>o(e.result),e.onabort=e.onerror=()=>n(e.error)}))}function a(e,o){const n=indexedDB.open(e);n.onupgradeneeded=()=>n.result.createObjectStore(o);const t=s(n);return(e,n)=>t.then((t=>n(t.transaction(o,e).objectStore(o))))}let i;function c(){return i||(i=a("keyval-store","keyval")),i}function l(e=c()){const o=[];return function(e,o){return e("readonly",(e=>(e.openCursor().onsuccess=function(){this.result&&(o(this.result),this.result.continue())},s(e.transaction))))}(e,(e=>o.push([e.key,e.value]))).then((()=>o))}const u=a("fledge.v1","interest-groups"),g=(e,o)=>`${e}-${o}`;async function d(e,o,n){n&&r.groupCollapsed("Fledge API: joinAdInterest");const t=g(e.owner,e.name),a=await function(e,o=c()){return o("readonly",(o=>s(o.get(e))))}(t,u);return n&&r.log(r.asInfo("checking for an existing interest group:"),a),a?(n&&r.log(r.asProcess("updating an interest group")),await function(e,o,n=c()){return n("readwrite",(n=>new Promise(((t,r)=>{n.get(e).onsuccess=function(){try{n.put(o(this.result),e),t(s(n.transaction))}catch(e){r(e)}}}))))}(t,(n=>({_expired:Date.now()+o,...n,...e})),u)):(n&&r.log(r.asProcess("creating a new interest group")),await function(e,o,n=c()){return n("readwrite",(n=>(n.put(o,e),s(n.transaction))))}(t,{_created:Date.now(),_expired:Date.now()+o,_updated:Date.now(),...e},u)),n&&r.log(r.asSuccess("interest group id:"),t),n&&r.groupEnd(),!0}async function p(e,o){return o&&r.groupCollapsed("Fledge API: leaveAdInterest"),o&&r.log(r.asProcess("deleting an existing interest group")),await function(e,o=c()){return o("readwrite",(o=>(o.delete(e),s(o.transaction))))}(g(e.owner,e.name),u),o&&r.log(r.asSuccess("interest group deleted")),o&&r.groupEnd(),!0}const f=async(e,o,n)=>{n&&r.groupCollapsed("auction utils: getTrustedSignals");const t=`hostname=${window.top.location.hostname}`;if(!e||!o)return n&&r.log(r.asWarning("No 'url' or 'keys' found!")),void(n&&r.groupEnd());const s=await fetch(`${e}?${t}&keys=${o.join(",")}`).then((e=>{if(!e.ok)throw new Error("Something went wrong! The response returned was not ok.");if(!(e=>/\bapplication\/json\b/.test(e?.headers?.get("content-type")))(e))throw new Error("Response was not in the format of JSON.");return e.json()})).catch((e=>(n&&r.log(r.asAlert("There was a problem with your fetch operation:")),n&&r.log(e),null))),a={};for(const[e,n]of s)o.includes(e)&&(a[e]=n);return a&&0===Object.keys(a).length&&a.constructor===Object?(n&&r.groupEnd(),a):(n&&r.log(r.asWarning("No signals found!")),n&&r.groupEnd(),null)};async function w(e,o){o&&r.groupCollapsed("Fledge API: runAdAuction");const n=await l(u);o&&r.log(r.asInfo("all interest groups:"),n);const t=((e,o,n)=>{if(n&&r.groupCollapsed("auction utils: getEligible"),"*"===o)return n&&r.info("using the wildcard yields all groups"),n&&r.groupEnd(),e;const t=e.filter((([e,n])=>o.includes(n.owner)));return t.length?(n&&r.info("found some eligible buyers"),n&&r.groupEnd(),t):(n&&r.log(r.asWarning("No groups were eligible!")),n&&r.groupEnd(),null)})(n,e.interest_group_buyers,o);if(o&&r.log(r.asInfo('eligible buyers based on "interest_group_buyers":'),t),!t)return o&&r.log(r.asAlert("No eligible interest group buyers found!")),null;const s=await(async(e,o,n)=>Promise.all(e.map((async([e,t])=>{n&&r.groupCollapsed(`auction utils: getBids => ${e}`);const s=performance.now(),{generateBid:a,generate_bid:i}=await import(t.bidding_logic_url);let c=a;if(i&&!a&&(c=i),!c&&"function"!=typeof c)return n&&r.log(r.asWarning("No 'generateBid' function found!")),n&&r.groupEnd(),null;const l=await f(t?.trusted_bidding_signals_url,t?.trusted_bidding_signals_keys,n);let u;try{u=c(t,o?.auction_signals,o?.per_buyer_signals?.[t.owner],l,{top_window_hostname:window.top.location.hostname,seller:o.seller}),n&&r.log(r.asInfo("bid:"),u)}catch(e){return n&&r.log(r.asAlert("There was an error in the 'generateBid' function:")),n&&r.log(e),null}if(!(u.ad&&"object"==typeof u.ad&&u.bid&&"number"==typeof u.bid&&u.render)||"string"!=typeof u.render&&!Array.isArray(u.render))return n&&r.log(r.asWarning("No bid found!")),n&&r.groupEnd(),null;const g=performance.now();return n&&r.groupEnd(),{...t,...u,duration:g-s}}))))(t,e,o);o&&r.log(r.asInfo("all bids from each buyer:"),s);const a=s.filter((e=>e));if(o&&r.log(r.asInfo("filtered bids:"),a),!a.length)return o&&r.log(r.asAlert("No bids found!")),o&&r.groupEnd(),null;o&&r.log(r.asProcess("getting all scores, filtering and sorting"));const[i]=await(async(e,o,n)=>{n&&r.groupCollapsed("auction utils: getScores");const{scoreAd:t,score_ad:s}=await import(o.decision_logic_url);let a=t;return s&&!t&&(a=s),a||"function"==typeof a?e.map((e=>{let t;try{t=a(e?.ad,e?.bid,o,o?.trusted_scoring_signals,{top_window_hostname:window.top.location.hostname,interest_group_owner:e.owner,interest_group_name:e.name,bidding_duration_msec:e.duration}),n&&r.log(r.asInfo("score:"),t)}catch(e){n&&r.log(r.asAlert("There was an error in the 'scoreAd' function:")),n&&r.log(e),t=-1}return n&&r.groupEnd(),{bid:e,score:t}})).filter((({score:e})=>e>0)).sort(((e,o)=>e.score>o.score?1:-1)):(n&&r.log(r.asWarning("No 'scoreAd' function was found!")),null)})(a,e,o);if(o&&r.log(r.asInfo("winner:"),i),!i)return o&&r.log(r.asAlert("No winner found!")),o&&r.groupEnd(),null;o&&r.log(r.asProcess("creating an entry in the auction store"));const c=([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)));return sessionStorage.setItem(c,JSON.stringify({origin:`${window.top.location.origin}${window.top.location.pathname}`,timestamp:Date.now(),conf:e,...i})),o&&r.log(r.asSuccess("auction token:"),c),o&&r.groupEnd(),c}async function h({data:e,ports:o}){try{if(!Array.isArray(e))throw new Error(`The API expects the data to be in the form of an array, with index 0 set to the action, and index 1 set to the data. A ${typeof e} was passed instead.`);switch(e[0]){case"joinAdInterestGroup":{const[,o]=e,[n,t,r]=o;return await d(n,t,r),!0}case"leaveAdInterestGroup":{const[,o]=e,[n,t]=o;return await p(n,t),!0}case"runAdAuction":{const[,n]=e,[t,r]=n;if(1!==o.length)throw new Error(`Port transfer mismatch during request: expected 1 port, but received ${o.length}`);const[s]=o,a=[!0,await w(t,r)];return s.postMessage(a),s.close(),!0}default:return!1}}catch(e){const n=[!1];for(const e of o)e.postMessage(n);throw e}}return async function(){const{searchParams:e}=new URL(window.location),o=e.get("debug")||!1;if(o&&r.group("Fledge: Storage Frame"),!(e.get("admin")||!1)){const[e]=window.location.ancestorOrigins;if(void 0===e)throw o&&r.log(r.asWarning("It appears your attempting to access this from the top-level document")),o&&r.log({origin:e,location:window.location}),new Error("Can't call 'postMessage' on the Frame window when run as a top-level document");const{port1:n,port2:t}=new MessageChannel;o&&r.log("message channel receiver:",n),o&&r.log("message channel sender:",t),n.onmessage=h,window.parent.postMessage({"fledge.polyfill":1},e,[t])}o&&r.groupEnd()}}();

@@ -6,3 +6,3 @@ {

"author": "Newton Koumantzelis",
"version": "0.2.0",
"version": "0.3.0",
"main": "dist/api/cjs/index.js",

@@ -9,0 +9,0 @@ "module": "dist/api/esm/index.js",

@@ -39,3 +39,3 @@ # fledge.polyfill [![npm version](https://badge.fury.io/js/%40magnite%2Ffledge.polyfill.svg)](https://badge.fury.io/js/%40magnite%2Ffledge.polyfill) [![codecov](https://codecov.io/gh/MagniteEngineering/fledge.polyfill/branch/main/graph/badge.svg?token=8NUU67BFAH)](https://codecov.io/gh/MagniteEngineering/fledge.polyfill) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=the-holocron/threepio)](https://dependabot.com)

name: "an-interest-group",
bidding_logic_url: "https://dsp.com/bidding",
biddingLogicUrl: "https://dsp.com/bidding",
};

@@ -60,4 +60,4 @@

seller: "www.seller.com",
decision_logic_url: "https://ssp.com/auction",
interest_group_buyers: [
decisionLogicUrl: "https://ssp.com/auction",
interestGroupBuyers: [
"www.buyer1.com",

@@ -74,3 +74,3 @@ "www.buyer2.com",

In the future, rendering an ad will be handled by the Fledge API and would be passed to a Fenced Frame (which hasn't be established yet). In the polyfill world, we don't have access to a Fenced Frame and so its required for the consumer of this library to create their own `iframe` and pass the results from the auction to it. Thankfully, we've created a temporary feature for you to handle this in a way that respects the intention of the proposal by keeping the results opaque in the form of a token that represents the winning ad `rendering_url`.
In the future, rendering an ad will be handled by the Fledge API and would be passed to a Fenced Frame (which hasn't be established yet). In the polyfill world, we don't have access to a Fenced Frame and so its required for the consumer of this library to create their own `iframe` and pass the results from the auction to it. Thankfully, we've created a temporary feature for you to handle this in a way that respects the intention of the proposal by keeping the results opaque in the form of a token that represents the winning ad `renderingUrl`.

@@ -110,9 +110,9 @@ ```html

seller: typeof string;
decision_logic_url: typeof url;
interest_group_buyers: typeof array;
trusted_scoring_signals_url?; typeof url;
additional_bids?: typeof array;
auction_signals?: typeof object;
seller_signals?: typeof object;
per_buyer_signals?: typeof object;
decisionLogicUrl: typeof url;
interestGroupBuyers: typeof array;
trustedScoringSignalsUrl?; typeof url;
additionalBids?: typeof array;
auctionSignals?: typeof object;
sellerSignals?: typeof object;
perBuyerSignals?: typeof object;
}

@@ -137,7 +137,7 @@ ```

name: typeof string;
bidding_logic_url: typeof url;
daily_update_url?: typeof url;
trusted_bidding_signals_url?; typeof url;
trusted_bidding_signals_keys?: typeof array;
user_bidding_signals?: typeof object;
biddingLogicUrl: typeof url;
dailyUpdateUrl?: typeof url;
trustedBiddingSignalsUrl?; typeof url;
trustedBiddingSignalsKeys?: typeof array;
userBiddingSignals?: typeof object;
ads?: typeof array;

@@ -169,7 +169,7 @@ }

name: typeof string;
bidding_logic_url?: typeof url;
daily_update_url?: typeof url;
trusted_bidding_signals_url?; typeof url;
trusted_bidding_signals_keys?: typeof array;
user_bidding_signals?: typeof object;
biddingLogicUrl?: typeof url;
dailyUpdateUrl?: typeof url;
trustedBiddingSignalsUrl?; typeof url;
trustedBiddingSignalsKeys?: typeof array;
userBiddingSignals?: typeof object;
ads?: typeof array;

@@ -176,0 +176,0 @@ }

@@ -64,3 +64,3 @@ import { echo } from '@theholocron/klaxon';

* @example
* joinAdInterestGroup({ owner: 'foo', name: 'bar', bidding_logic_url: 'http://example.com/bid' }, 2592000000);
* joinAdInterestGroup({ owner: 'foo', name: 'bar', biddingLogicUrl: 'http://example.com/bid' }, 2592000000);
*/

@@ -73,3 +73,3 @@ async joinAdInterestGroup (options, expiry) {

validate.param(expiry, 'number');
validate.hasRequiredKeys(options, [ 'owner', 'name', 'bidding_logic_url' ]);
validate.hasRequiredKeys(options, [ 'owner', 'name', 'biddingLogicUrl' ]);
validate.hasInvalidOptionTypes(options, InterestGroup);

@@ -105,3 +105,3 @@

* @example
* leaveAdInterestGroup({ owner: 'foo', name: 'bar', bidding_logic_url: 'http://example.com/bid' });
* leaveAdInterestGroup({ owner: 'foo', name: 'bar', biddingLogicUrl: 'http://example.com/bid' });
*/

@@ -138,3 +138,3 @@ async leaveAdInterestGroup (group) {

* @example
* runAdAuction({ seller: 'foo', decision_logic_url: 'http://example.com/auction', interst_group_buyers: [ 'www.buyer.com' ] });
* runAdAuction({ seller: 'foo', decisionLogicUrl: 'http://example.com/auction', interstGroupBuyers: [ 'www.buyer.com' ] });
*/

@@ -145,3 +145,3 @@ async runAdAuction (conf) {

validate.param(conf, 'object');
validate.hasRequiredKeys(conf, [ 'seller', 'decision_logic_url', 'interest_group_buyers' ]);
validate.hasRequiredKeys(conf, [ 'seller', 'decisionLogicUrl', 'interestGroupBuyers' ]);
validate.hasInvalidOptionTypes(conf, AuctionConf);

@@ -148,0 +148,0 @@

@@ -1,2 +0,2 @@

/* eslint-disable camelcase, no-cond-assign */
/* eslint-disable no-cond-assign */
import { echo } from '@theholocron/klaxon';

@@ -15,11 +15,6 @@

debug && echo.groupCollapsed('render utils: getSellerReport');
const { report_result, reportResult } = await import(conf.decision_logic_url);
let runReport = reportResult;
const { reportResult } = await import(conf.decisionLogicUrl);
if (report_result) {
runReport = report_result;
}
// check if there is even a function
if (!runReport || typeof runReport !== 'function') {
if (!reportResult || typeof reportResult !== 'function') {
debug && echo.log(echo.asWarning(`No 'reportResult' function found!`));

@@ -34,7 +29,7 @@ debug && echo.groupEnd();

debug && echo.log(echo.asProcess('fetching seller reporting'));
report = runReport(conf, {
top_window_hostname: window.top.location.hostname,
interest_group_owner: results.bid.owner,
interest_group_name: results.bid.name,
render_url: results.bid.render,
report = reportResult(conf, {
topWindowHostname: window.top.location.hostname,
interestGroupOwner: results.bid.owner,
interestGroupName: results.bid.name,
renderUrl: results.bid.render,
bid: results.bid.bid,

@@ -65,12 +60,6 @@ });

debug && echo.groupCollapsed('render utils: getBuyerReport');
const wins = import(results.bid.bidding_logic_url)
.then(({ reportWin, report_win }) => {
let runReport = reportWin;
if (report_win) {
runReport = report_win;
}
const wins = import(results.bid.biddingLogicUrl)
.then(({ reportWin }) => {
// check if there is even a function
if (!runReport || typeof runReport !== 'function') {
if (!reportWin || typeof reportWin !== 'function') {
debug && echo.log(echo.asWarning(`No 'reportWin' function found!`));

@@ -85,7 +74,7 @@ return null;

// generate a report by providing all of the necessary information
report = runReport(conf?.auction_signals, conf?.per_buyer_signals?.[results.bid.owner], sellersReport, {
top_window_hostname: window.top.location.hostname,
interest_group_owner: results.bid.owner,
interest_group_name: results.bid.name,
render_url: results.bid.render,
report = reportWin(conf?.auctionSignals, conf?.perBuyerSignals?.[results.bid.owner], sellersReport, {
topWindowHostname: window.top.location.hostname,
interestGroupOwner: results.bid.owner,
interestGroupName: results.bid.name,
renderUrl: results.bid.render,
bid: results.bid.bid,

@@ -92,0 +81,0 @@ });

export const AuctionConf = {
seller: 'string',
decision_logic_url: 'url',
interest_group_buyers: 'mixed',
trusted_scoring_signals_url: 'url',
additional_bids: 'array',
auction_signals: 'object',
seller_signals: 'object',
per_buyer_signals: 'object',
decisionLogicUrl: 'url',
interestGroupBuyers: 'mixed',
trustedScoringSignalsUrl: 'url',
additionalBids: 'array',
auctionSignals: 'object',
sellerSignals: 'object',
perBuyerSignals: 'object',
};

@@ -15,8 +15,8 @@

name: 'string',
bidding_logic_url: 'url',
daily_update_url: 'url', // @TODO: support this potentially on the auction, grabbing the latest interest group data, and updating the IDB store with it
trusted_bidding_signals_url: 'url',
trusted_bidding_signals_keys: 'array',
user_bidding_signals: 'object',
biddingLogicUrl: 'url',
dailyUpdateUrl: 'url', // @TODO: support this potentially on the auction, grabbing the latest interest group data, and updating the IDB store with it
trustedBiddingSignalsUrl: 'url',
trustedBiddingSignalsKeys: 'array',
userBiddingSignals: 'object',
ads: 'array',
};

@@ -21,3 +21,3 @@ import { echo } from '@theholocron/klaxon';

* @example
* runAdAuction({ seller: 'foo', decision_logic_url: 'http://example.com/auction', interst_group_buyers: [ 'www.buyer.com' ] });
* runAdAuction({ seller: 'foo', decisionLogicUrl: 'http://example.com/auction', interestGroupBuyers: [ 'www.buyer.com' ] });
*/

@@ -29,4 +29,4 @@ export default async function runAdAuction (conf, debug) {

const eligible = getEligible(interestGroups, conf.interest_group_buyers, debug);
debug && echo.log(echo.asInfo('eligible buyers based on "interest_group_buyers":'), eligible);
const eligible = getEligible(interestGroups, conf.interestGroupBuyers, debug);
debug && echo.log(echo.asInfo('eligible buyers based on "interestGroupBuyers":'), eligible);
if (!eligible) {

@@ -33,0 +33,0 @@ debug && echo.log(echo.asAlert('No eligible interest group buyers found!'));

@@ -32,3 +32,3 @@ import { echo } from '@theholocron/klaxon';

* @example
* joinAdInterestGroup({ owner: 'foo', name: 'bar', bidding_logic_url: 'http://example.com/bid' }, 2592000000);
* joinAdInterestGroup({ owner: 'foo', name: 'bar', biddingLogicUrl: 'http://example.com/bid' }, 2592000000);
*/

@@ -39,9 +39,11 @@ export async function joinAdInterestGroup (options, expiry, debug) {

const group = await idb.get(id, customStore);
console.log({group});
debug && echo.log(echo.asInfo('checking for an existing interest group:'), group);
if (group) {
debug && echo.log(echo.asProcess('updating an interest group'));
await idb.update(id, {
await idb.update(id, (val) => ({
...val,
...options,
_expired: Date.now() + expiry,
...options,
}, customStore);
}), customStore);
} else {

@@ -72,3 +74,3 @@ debug && echo.log(echo.asProcess('creating a new interest group'));

* @example
* leaveAdInterestGroup({ owner: 'foo', name: 'bar', bidding_logic_url: 'http://example.com/bid' });
* leaveAdInterestGroup({ owner: 'foo', name: 'bar', biddingLogicUrl: 'http://example.com/bid' });
*/

@@ -75,0 +77,0 @@ export async function leaveAdInterestGroup (group, debug) {

@@ -1,2 +0,1 @@

/* eslint-disable camelcase */
import { echo } from '@theholocron/klaxon';

@@ -46,12 +45,7 @@

const time0 = performance.now();
const { generateBid, generate_bid } = await import(bidder.bidding_logic_url);
let callBid = generateBid;
const { generateBid } = await import(bidder.biddingLogicUrl);
if (generate_bid && !generateBid) {
callBid = generate_bid;
}
// check if there is even a generateBid function
// if not, removed bidder from elibility
if (!callBid && typeof callBid !== 'function') {
if (!generateBid && typeof generateBid !== 'function') {
debug && echo.log(echo.asWarning(`No 'generateBid' function found!`));

@@ -62,3 +56,3 @@ debug && echo.groupEnd();

const trustedSignals = await getTrustedSignals(bidder?.trusted_bidding_signals_url, bidder?.trusted_bidding_signals_keys, debug);
const trustedSignals = await getTrustedSignals(bidder?.trustedBiddingSignalsUrl, bidder?.trustedBiddingSignalsKeys, debug);

@@ -68,4 +62,4 @@ // generate a bid by providing all of the necessary information

try {
bid = callBid(bidder, conf?.auction_signals, conf?.per_buyer_signals?.[bidder.owner], trustedSignals, {
top_window_hostname: window.top.location.hostname,
bid = generateBid(bidder, conf?.auctionSignals, conf?.perBuyerSignals?.[bidder.owner], trustedSignals, {
topWindowHostname: window.top.location.hostname,
seller: conf.seller,

@@ -113,12 +107,7 @@ });

debug && echo.groupCollapsed(`auction utils: getScores`);
const { scoreAd, score_ad } = await import(conf.decision_logic_url);
let callScore = scoreAd;
const { scoreAd } = await import(conf.decisionLogicUrl);
if (score_ad && !scoreAd) {
callScore = score_ad;
}
// check if there is even a scoreAd function
// if not, return null
if (!callScore && typeof callScore !== 'function') {
if (!scoreAd && typeof scoreAd !== 'function') {
debug && echo.log(echo.asWarning(`No 'scoreAd' function was found!`));

@@ -132,7 +121,7 @@ return null;

try {
score = callScore(bid?.ad, bid?.bid, conf, conf?.trusted_scoring_signals, {
top_window_hostname: window.top.location.hostname,
interest_group_owner: bid.owner,
interest_group_name: bid.name,
bidding_duration_msec: bid.duration,
score = scoreAd(bid?.ad, bid?.bid, conf, conf?.trustedScoringSignals, {
topWindowHostname: window.top.location.hostname,
interestGroupOwner: bid.owner,
interestGroupName: bid.name,
biddingDurationMsec: bid.duration,
});

@@ -139,0 +128,0 @@ debug && echo.log(echo.asInfo(`score:`), score);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc