Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Supporting link[rel=monetization] #3

Open
sidvishnoi opened this issue Feb 22, 2021 · 0 comments
Open

Supporting link[rel=monetization] #3

sidvishnoi opened this issue Feb 22, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@sidvishnoi
Copy link
Owner

sidvishnoi commented Feb 22, 2021

Based on WICG/webmonetization#19, I decided to implement <link rel="monetization"> instead of <meta name="monetization"> as the "monetization element". The content in monetization element represents the payment pointer - a meta-data URL where to send the money to. More precisely, the payment pointer is a pointer - it needs to be fetched to get a destination account and a shared secret, where money is actually sent with ILP. By making using of the <link> element, we get some additional benefits, as described in WICG/webmonetization#19 (comment).

Following are the behavioral requirements from the link[rel=monetization] element:

Observable Mechanics

Based on our current understanding, we want a document/window/tab to have only a single payment stream. We make use of only the first valid monetization element at any time.

If the document is hidden, abort.

On initial page load, set the active monetization element (activeEl) to the first valid monetization element.

If a monetization element (el) is added to the <head> later on:

  • If there's no activeEl, set activeEl to el.
  • If el is appended to the <head>, do nothing.
  • If el is added before activeEl, set activeEl to el.

Fetch and Process steps for activeEl

Fetch(activeEl, bypassCache = false)

Fetch the content at activeEl.href as per the SPSP spec:

  • Respect the monetization-src CSP directive.
  • Respect Cache-control HTTP headers unless bypassCache is true.

Process(spspResponse)

  • Ensure spspResponse is valid as per SPSP spec.
  • Dispatch events to start/stop/pause/resume monetization.

Implementation in Firefox

For the basic "support", i.e., HTMLLinkElement.relList.supports("monetization"), see 43780b6

The Firefox implementation is written in JSM and makes use of JSWindowActor APIs. There can be some difficulties if one were to write it in C++ - specially due to the observable mechanics that I discussed above (along with the ability to manually request a re-fetch multiple times later). Additional details are explained in #4.

@sidvishnoi sidvishnoi added the documentation Improvements or additions to documentation label Feb 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant