LUCCHETTO_PROVIDERS

⚠ This may only be useful when connecting to users' remote-storage instances through a non-null remoteStorage constructor parameter.

List of lucchetto providing servers for production: these are shown as options in the RS widget dropdown, when the Lucchetto class is constructed with !isTest:

  • @rs.overhide.io
LUCCHETTO_PROVIDERS

LUCCHETTO_PROVIDERS_4_TEST

⚠ This may only be useful when connecting to users' remote-storage instances through a non-null remoteStorage constructor parameter.

List of lucchetto providing servers for testnets: these are shown as options in the RS widget dropdown, when the Lucchetto class is constructed with isTest:

  • @test.rs.overhide.io
  • @localhost:8000
LUCCHETTO_PROVIDERS_4_TEST

Lucchetto

This class provides utility functions to fetch in-app purchase data from the app-developer's RS (+Lucchetto) connection. The in-app purchase data must first be onboarded onto a Lucchetto extended RS server.

A typical usage of this class with pay2my.app widgets might look like:


  var lucchetto = new Lucchetto({
      overhideIsTest: true, 
      pay2myAppHub: document.getElementById('hub-id-in-dom'),
      overhideApiKey: '0x42..cb'});
  ...
  window.addEventListener('pay2myapp-appsell-sku-clicked', async (e) => { 
    ...
    const result = await lucchetto.getSku(`https://test.rs.overhide.io`, e.detail);
    console.log(`got SKU results`, { sku: e.detail.sku , result });
    ...
 }, false);

  • Above, we're passing in the overhideApiKey for our use — get an API key for the right network, either testnet or mainnet. This is not a secret.

⚠ In the context of being connected to your users' remote-storage instances through a non-null remoteStorage constructor (first) parameter:

Reacts to remotestorage.js onConnected events to parse metadata out of newly available RS tokens.

If the connected RS server is Lucchetto extended, the token will provide metadata useful to pay2my.app in-app purchase widgets — making for a nicer end-user experience.

This class enriches the dropdown of the RS widget, if any, embedded in the DOM. The enrichment provides server hints as per LUCCHETTO_PROVIDERS and LUCCHETTO_PROVIDERS_4_TEST.

A typical usage of this class along with remotestorage.js and pay2my.app widgets might look like:


  var rsClient = new RemoteStorage();
  var lucchetto = new Lucchetto({
      remoteStorage: rsClient,
      overhideIsTest: true, 
      pay2myAppHub: document.getElementById('hub-id-in-dom'),
      overhideApiKey: '0x42..cb'});
  ...
  window.addEventListener('pay2myapp-appsell-sku-clicked', async (e) => { 
    ...
    const result = await lucchetto.getSku(`https://test.rs.overhide.io`, e.detail);
    console.log(`got SKU results`, { sku: e.detail.sku , result });
    ...
 }, false);

  • Above, we're also passing in the overhideApiKey for our use — get an API key for the right network, either testnet or mainnet. The overhideApiKey is optional since we'll usually leverage an overhide token from remoteStorage. But if the remoteStorage connected to our application is not to a Lucchetto extended RS server, it won't have the overhide token, and we need to fail back to this default key. This is not a secret.

new Lucchetto(options: Object)
Parameters
options (Object = {remoteStorage:null,overhideIsTest:false,pay2myAppHub:null,overhideApiKey:null}) the construction options
Name Description
options.remoteStorage Object the RS instance available from client. This is an RS instance connected to the the client-user's data. Set this to null if you're using lucchetto outside of a remote-storage app, just for the getSku(..) endpoint.
options.overhideIsTest bool flag whether this is all working against testnets or mainnets/prod servers.
options.pay2myAppHub Object pay2my.app hub to instrument with credentials coming out of the remoteStorage instance. If user connects with a Lucchetto extended remoteStorage , this hub will be instrumented. Otherwise the hub will need to ask for credentials on in-app purchase use.
options.overhideApiKey Object the API key to use, get an API key for the right network, either testnet or mainnet. If the remoteStorage instance is provided and is a Lucchetto extended RS server, you may leave this as null : a Lucchetto extended RS server will provide a user-specific token to use with getSku(..) overhide connections. *
Instance Members
getMetadata
getUserAddress
getNamespace
getPath
getSku