rviscomi / capo.js

Get your <head> in order

Home Page:https://rviscomi.github.io/capo.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Log origin trial metadata

rviscomi opened this issue · comments

The blanket rule for all meta[http-equiv] tags is to put them first, but there's more nuance than that. Some origin trials alter the behavior or feature support of the page and their meta tags really would benefit from coming first. Other origin trials are less consequential.

To help differentiate between them and for developers to get a better sense of urgency if a super important OT is too low in the head, include some metadata logging.

@samdutton created this excellent OT debug tool, which includes a decoder function for the OT token:

function decodeToken(token) {
    const buf = base64decode(token);
    const view = new DataView(buf.buffer)
    const version = view.getUint8()
    const signature = buf.slice(1, 65)
    const length = view.getUint32(65, false)
    const payload = JSON.parse((new TextDecoder()).decode(buf.slice(69, 69 + length)))
    return {payload, version, length, signature}
}

It doesn't look like there would be any licensing incompatibilities if we integrated that into the tool with proper attribution.

Proof of concept

image

Might also be interesting to add a warning if the OT has expired, as in this example.

Edit: Done

image