JSFiddle - React, Tailwind, and code Playground

by vesvault

HTML

<script src="https://ves.host/pub/libVES.js"></script>
<script>

// libVES instance.
// VES domain identifies the namespace,
// and should be unique per integrator.
// Any DNS-style name starting with 'x-' can be used
// for experimental VES domains, single level is ok.
VES = new libVES({domain: 'x-myApp'});

function ves_unlock() {
// Unlock VES using a delegate popup
	VES.delegate().then(function() {

// VES item externalId, must be unique per VES domain.
  	var itemId = VES.externalId + '!my-item';

// Vaults to e2ee share the VES item with.
// An array of Vault References,
// A reference to an App Vault must have an externalId,
// which is normally a lowercase email of the vault owner.
// If the vault with a specified externalId doesn't exist yet
// and the externalId is in an email address format -
// a Temp Vault will be created, and can be claimed by the
// owner of the email address.
// An optional appUrl parameter will trigger a notification
// for a newly created Temp Vault, appUrl should point to the
// page that initiates VES authorization.
//
// The share list must include the owner of the Vault Item.
//
// A share list can be omitted (null) if the item is not shared
// with anyone besides its creator.
		var shareList = [
    	{externalId: VES.externalId},
      {externalId: '[email protected]'},
      {externalId: '[email protected]', appUrl: document.location.href}
    ];

// Store an e2ee value in VES repo
  	VES.putValue(itemId, 'my-value', shareList).then(function() {

// Retrieve an e2ee value from VES repo
    	VES.getValue(itemId).then(function(val) {
      	document.getElementById('val').innerHTML = itemId + ': ' + val;
      });
    });
	});
  return false;
}
</script>
<button type="button" onclick="ves_unlock();">
Unlock VES</button>
<div id="val"></div>