@magnite/fledge.polyfill
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -5,2 +5,20 @@ # Changelog | ||
### 0.2.0 (2021-05-13) | ||
### Features | ||
* `runAdAuction` ([#45](https://github.com/MagniteEngineering/fledge.polyfill/issues/45)) ([9e75f5a](https://github.com/MagniteEngineering/fledge.polyfill/commit/9e75f5a9b55df6e2d031fd8e747206ce821569bc)) | ||
* add in reporting functions ([#58](https://github.com/MagniteEngineering/fledge.polyfill/issues/58)) ([11de768](https://github.com/MagniteEngineering/fledge.polyfill/commit/11de76852aa11e06f5e8ea82d8b70858ad74b817)) | ||
* add in support for URL in constructor ([#73](https://github.com/MagniteEngineering/fledge.polyfill/issues/73)) ([6292392](https://github.com/MagniteEngineering/fledge.polyfill/commit/6292392eacc55fcab03253a15fb64d5bc238af29)) | ||
* create interest groups ([#30](https://github.com/MagniteEngineering/fledge.polyfill/issues/30)) ([0ef68ca](https://github.com/MagniteEngineering/fledge.polyfill/commit/0ef68ca9432394365e1d81a91f491c21f6ccb2c3)), closes [#31](https://github.com/MagniteEngineering/fledge.polyfill/issues/31) [#35](https://github.com/MagniteEngineering/fledge.polyfill/issues/35) [#32](https://github.com/MagniteEngineering/fledge.polyfill/issues/32) [#38](https://github.com/MagniteEngineering/fledge.polyfill/issues/38) | ||
* cross-domain iframe post ([#61](https://github.com/MagniteEngineering/fledge.polyfill/issues/61)) ([5cc38ed](https://github.com/MagniteEngineering/fledge.polyfill/commit/5cc38ed5ab2c4910a6577d06d3df84ce58ce6ad5)) | ||
* move to `idb-keyval` ([#72](https://github.com/MagniteEngineering/fledge.polyfill/issues/72)) ([30cbf84](https://github.com/MagniteEngineering/fledge.polyfill/commit/30cbf84af803950923ba956f55dd00d78dab262f)) | ||
* rendering the winning ad ([#53](https://github.com/MagniteEngineering/fledge.polyfill/issues/53)) ([f1c7892](https://github.com/MagniteEngineering/fledge.polyfill/commit/f1c7892bd5ac32f698c63777b3f39b1fc230689a)) | ||
### Bug Fixes | ||
* restrict package to dist ([cdc0404](https://github.com/MagniteEngineering/fledge.polyfill/commit/cdc0404b3a3ef7cfb39ad37a8e96a0465507de86)) | ||
## 0.1.0 (2021-04-20) | ||
@@ -7,0 +25,0 @@ |
@@ -6,5 +6,19 @@ { | ||
"author": "Newton Koumantzelis", | ||
"version": "0.1.0", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"version": "0.2.0", | ||
"main": "dist/api/cjs/index.js", | ||
"module": "dist/api/esm/index.js", | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"keywords": [ | ||
"fledge", | ||
"turtledove", | ||
"sparrow", | ||
"dovekey", | ||
"parrrot", | ||
"tern", | ||
"advertising", | ||
"w3c web advertising business group" | ||
], | ||
"repository": "https://github.com/MagniteEngineering/fledge.polyfill.git", | ||
@@ -15,2 +29,11 @@ "bugs": "https://github.com/MagniteEngineering/fledge.polyfill/issues", | ||
"license": "MIT", | ||
"alex": { | ||
"allow": [ | ||
"color", | ||
"colors", | ||
"dead", | ||
"disabled", | ||
"invalid" | ||
] | ||
}, | ||
"babel": { | ||
@@ -27,6 +50,9 @@ "presets": [ | ||
"engines": { | ||
"node": "^12.16.0 || >=13.2.0" | ||
"node": "^14.x" | ||
}, | ||
"eslintConfig": { | ||
"extends": "@theholocron" | ||
"extends": "@theholocron", | ||
"rules": { | ||
"compat/compat": "off" | ||
} | ||
}, | ||
@@ -42,5 +68,7 @@ "husky": { | ||
{ | ||
"resetMocks": false, | ||
"preset": "@theholocron/jest-preset", | ||
"setupFiles": [ | ||
"fake-indexeddb/auto" | ||
"fake-indexeddb/auto", | ||
"jest-localstorage-mock" | ||
] | ||
@@ -59,2 +87,3 @@ }, | ||
}, | ||
"prettier": "@rubicon/prettier-config", | ||
"publishConfig": { | ||
@@ -70,14 +99,21 @@ "access": "public" | ||
"scripts": { | ||
"audit": "bundlesize --config ./node_modules/@theholocron/bundlewatch-config/index.js", | ||
"commit": "commit", | ||
"dist": "rollup -c node:@theholocron/rollup-config --name=fledge", | ||
"predist": "rollup -c node:@theholocron/rollup-config --input=src/frame --output=dist/frame --name=fledgeframe --exports=default", | ||
"dist": "rollup -c node:@theholocron/rollup-config --input=src/api --output=dist/api --name=fledge --exports=default", | ||
"predocs": "rollup -c node:@theholocron/rollup-config --input=src/frame --output=docs/scripts/frame --name=fledgeframe --exports=default", | ||
"docs": "rollup -c node:@theholocron/rollup-config --input=src/api --output=docs/scripts/api --name=fledge --exports=default", | ||
"lint": "eslint .", | ||
"release": "semantic-release", | ||
"test:unit": "jest test/unit --passWithNoTests", | ||
"serve": "serve . -l 3000", | ||
"start": "serve docs -l 8000", | ||
"test": "npm run test:docs && npm run test:unit && npm run test:e2e", | ||
"test:docs": "alex .", | ||
"pretest:e2e": "npm run dist", | ||
"test:e2e": "jest --config test/e2e/jest.config.js", | ||
"test": "npm run test:unit && npm run test:e2e", | ||
"serve": "./node_modules/.bin/serve . -l 3000" | ||
"test:e2e": "jest --config test/e2e/jest.config.js --runInBand", | ||
"test:unit": "jest test/unit --passWithNoTests" | ||
}, | ||
"devDependencies": { | ||
"@theholocron/babel-preset": "^0.4.1", | ||
"@theholocron/bundlewatch-config": "^0.3.1", | ||
"@theholocron/commitlint-config": "^0.1.13", | ||
@@ -87,12 +123,16 @@ "@theholocron/eslint-config": "^0.4.3", | ||
"@theholocron/lint-staged-config": "^0.1.7", | ||
"@theholocron/rollup-config": "^0.2.4", | ||
"@theholocron/prettier-config": "^0.2.0", | ||
"@theholocron/rollup-config": "^0.4.0", | ||
"@theholocron/semantic-release-config": "^0.3.0", | ||
"alex": "^9.1.0", | ||
"fake-indexeddb": "^3.1.2", | ||
"jest-puppeteer": "^4.4.0", | ||
"puppeteer": "^8.0.0", | ||
"jest-localstorage-mock": "^2.4.10", | ||
"jest-puppeteer": "^5.0.3", | ||
"puppeteer": "^9.1.0", | ||
"serve": "^11.3.2" | ||
}, | ||
"dependencies": { | ||
"idb": "^6.0.0" | ||
"@theholocron/klaxon": "^1.1.0", | ||
"idb-keyval": "^5.0.5" | ||
} | ||
} |
134
README.md
@@ -25,9 +25,12 @@ # fledge.polyfill [](https://badge.fury.io/js/%40magnite%2Ffledge.polyfill) [](https://codecov.io/gh/MagniteEngineering/fledge.polyfill) [](https://dependabot.com) | ||
As of this moment, the polyfill is intended to work within the Chrome browser at a version greater than 91. There are several ways to invoke the polyfill, but given the modern capabilities of support required, the following is the recommended way to invoke the API. | ||
Even though the examples below point to a `node_modules` directory, you should probably have a build process in place that compiles it to your preferred sites location. | ||
### Interest Groups | ||
As of this moment, the polyfill is intended to work within the Chrome browser at a version greater than 91. There are several ways to invoke the polyfill, but given the modern capabilities of support required, the following is the recoommended way to invoke the API. | ||
```html | ||
<script type="module"> | ||
import { fledge } from "./node_modules/@magnite/fledge.polyfill/esm/index.js"; | ||
import Fledge from "./node_modules/@magnite/fledge.polyfill/dist/api/esm/index.js"; | ||
const fledge = new Fledge(); | ||
@@ -41,15 +44,132 @@ const options = { | ||
// join an interest group | ||
fledge.joinAdInterestGroup(options, 864000000).then(response => console.log(response)); | ||
await fledge.joinAdInterestGroup(options, 864000000); | ||
// leave an interest group | ||
fledge.leaveAdInterestGroup(options).then(response => console.log(response)); | ||
await fledge.leaveAdInterestGroup(options); | ||
</script> | ||
``` | ||
### Auctions | ||
```html | ||
<script type="module"> | ||
import Fledge from "./node_modules/@magnite/fledge.polyfill/dist/api/esm/index.js"; | ||
const fledge = new Fledge(); | ||
const options = { | ||
seller: "www.seller.com", | ||
decision_logic_url: "https://ssp.com/auction", | ||
interest_group_buyers: [ | ||
"www.buyer1.com", | ||
"www.buyer2.com", | ||
], | ||
}; | ||
const auctionResults = await fledge.runAdAuction(options); | ||
</script> | ||
``` | ||
### Render the Ad | ||
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`. | ||
```html | ||
<script type="module"> | ||
import Fledge from "./node_modules/@magnite/fledge.polyfill/dist/api/esm/index.js"; | ||
const fledge = new Fledge(); | ||
// ...run the auction; see above for full example | ||
const auctionResults = await fledge.runAdAuction(options); | ||
await fledge.renderAd(id, auctionResults); | ||
</script> | ||
``` | ||
## Where to Find Documentation | ||
The best way to find out what's available is to dig through source code, as each directory has a README file to describe each feature. | ||
The best way to find out what's available is to dig through source code, but the following is the API documentation. | ||
* [Interest Groups](./src/interest-groups/README.md) | ||
### API | ||
#### runAdAuction(conf) | ||
Returns `null` if no winning bid is found. Returns a `Promise` with a token representation of the winning bids rendering URL. | ||
If an invalid option is passed, then an `Error` will be thrown with a reason to help debug. | ||
##### conf | ||
Type: [`<Object>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
The following is the data structure with types for the options: | ||
```ts | ||
interface AuctionOptions { | ||
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; | ||
} | ||
``` | ||
#### joinAdInterestGroup(options, expiry) | ||
Returns `true` and creates an entry in a cross-domain Indexed dB store. | ||
If an invalid option is passed, then an `Error` will be thrown with a reason to help debug. | ||
##### options | ||
Type: [`<Object>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
The following is the data structure with types for the options: | ||
```ts | ||
interface InterestGroup { | ||
owner: typeof string; | ||
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; | ||
ads?: typeof array; | ||
} | ||
``` | ||
##### expiry | ||
Type: [`<Number>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) | ||
A number of days (set in milliseconds) that the Interest Group will stay active, with a maximum of 30 days (or 2592000000). | ||
#### leaveAdInterestGroup(group) | ||
Returns `true` and removes an entry in a cross-domain Indexed dB store. | ||
If an invalid option is passed, then an `Error` will be thrown with a reason to help debug. | ||
##### options | ||
Type: [`<Object>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
The following is the data structure with types for the options: | ||
```ts | ||
interface InterestGroup { | ||
owner: typeof string; | ||
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; | ||
ads?: typeof array; | ||
} | ||
``` | ||
## How We Track Changes [](https://keepachangelog.com/en/1.0.0/) | ||
@@ -56,0 +176,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
3545
243
163360
2
15
21
5
5
+ Added@theholocron/klaxon@^1.1.0
+ Addedidb-keyval@^5.0.5
+ Added@theholocron/klaxon@1.1.0(transitive)
+ Addedidb-keyval@5.1.5(transitive)
+ Addedsafari-14-idb-fix@1.0.6(transitive)
- Removedidb@^6.0.0
- Removedidb@6.1.5(transitive)