Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <h4>request user to sign a </h4>
<button onclick="signCertID()">cert-identification</button>
<button onclick="signCertAg()">cert-agreement</button>


<h4>signer:</h4>
<p id="signer">null</p>

<input type="button" value="enforce signer" onclick="enforceSigning()">

<pre id="result"></pre>
              
            
!

CSS

              
                
              
            
!

JS

              
                const vendor = new Connex.Vendor("test");
const disclaimer =
  "Disclaimer: Before you start using Sync2, you should fully understand the essence of decentralization. Sync2 will not store your private key/mnemonic words/password or other confidential information anywhere except on this device. You are solely responsible for properly backing up the above-mentioned confidential information and keeping it in a secure place. Sync2 developers and their affiliated companies or organizations will not be held liable for any consequences, including but not limited to the loss, forgotten, or stolen of private keys/mnemonic words/passwords.";

const resultDetails = document.getElementById("result");
function signCertID() {
  resultDetails.innerText = "";
  vendor
    .sign("cert", {
      purpose: "identification",
      payload: {
        type: "text",
        content: "hello world"
      }
    })
    // .accepted(() => alert("accepted"))
    .request()
    .then((r) => {
      document.getElementById("signer").innerText = r.annex.signer;
      resultDetails.innerText = JSON.stringify(r, null, 4);
    })
    .catch((e) => alert("error:" + e.message));
}

function signCertAg() {
  resultDetails.innerText = "";
  vendor
    .sign("cert", {
      purpose: "agreement",
      payload: {
        type: "text",
        content: disclaimer
      }
    })
    // .accepted(() => alert("accepted"))
    .request()
    .then((r) => {
      document.getElementById("signer").innerText = r.annex.signer;
      resultDetails.innerText = JSON.stringify(r, null, 4);
    })
    .catch((e) => console.log("error:" + e.message));
}

function enforceSigning() {
  const signer = document.getElementById("signer").innerText;
  resultDetails.innerText = "";
  if (signer == "null") {
    return alert("ERROR: need to request a cert beforehand");
  }
  vendor
    .sign("cert", {
      purpose: "identification",
      payload: {
        type: "text",
        content: "hello world"
      }
    })
    .signer(document.getElementById("signer").innerText)
    // .accepted(() => alert("accepted"))
    .request()
    .then((r) => {
      document.getElementById("signer").innerText = r.annex.signer;
      resultDetails.innerText = JSON.stringify(r, null, 4);
    })
    .catch((e) => console.log("error:" + e.message));
}

              
            
!
999px

Console