<commit_before>## Open Web Apps Helper

This is a (currently) small library to do helpful things for your
[Mozilla Web Apps](https://www.mozilla.org/en-US/apps/partners/) app.

Right now it does validation of receipts, specifically targetted at
HTML-only applications (i.e., applications where the server doesn't do
anything but serve static files).<commit_msg>expand example<commit_after>## Open Web Apps Helper

This is a (currently) small library to do helpful things for your
[Mozilla Web Apps](https://www.mozilla.org/en-US/apps/partners/) app.

Right now it does validation of receipts, specifically targetted at
HTML-only applications (i.e., applications where the server doesn't do
anything but serve static files).

To use this, you'd do something like:

    var cache = new OWAHelper.Cache();
    var pending = navigator.mozApps.getSelf();
    pending.onsuccess = function () {
      if (! this.result) {
        forcePurchase('You must install this app');
        return;
      }
      cache.verifyReceipts(app, ["https://marketplace.mozilla.org"], function (error, result) {
        if (error && error.code != OWAHelper.errors.RECEIPT_NETWORK_ERRORS) {
          forcePurchase(error.detail);
        }
      });
    };
    pending.onerror = function () {
      forcePurchase('There is an error with your apps environment: ' + this.error);
    };

    function forcePurchase(reason) {
      // Of course, this is kind of terrible, but you can do better yourself ;)
      alert('You must install!\n' + reason);
      location.href = 'https://marketplace.mozilla.org/en-US/app/myapp';
    }
{'fraction_non_alphanumeric': 0.11069418386491557, 'fraction_numerical': 0.0, 'mean_word_length': 3.347826086956522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3326976', 'n_tokens_mistral': 472, 'n_tokens_neox': 447, 'n_words': 156}