diff --git a/pwa/app.js b/pwa/app.js new file mode 100644 index 0000000..cb3f348 --- /dev/null +++ b/pwa/app.js @@ -0,0 +1,48 @@ +function base32_nopad_encode(slice) { + const encoder = new base32.Encoder({ type: "rfc4648", lc: true }); + const code = encoder.write(slice).finalize(); + return code.replaceAll('=', ''); +} + +function base64_decode(str_b64) { + const raw_str = atob(str_b64); + const length = raw_str.length; + var b = []; + for (var i = 0; i < length; i++) { + b.push(raw_str.charCodeAt(i)); + } + return b; +} + +class KeyedAddress { + constructor(local_part, separator, domain, key_b64) { + this.local_part = local_part; + this.domain = domain; + this.separator = separator; + this.key = base64_decode(key_b64); + } + + genSubAddr(sub_addr_name) { + var hasher = sha256.hmac.create(this.key); + hasher.update(this.local_part); + hasher.update(this.separator); + hasher.update(sub_addr_name); + const hash = hasher.array(); + const offset = hash[hash.length - 1] & 0xf; + const reduced_hash = hash.slice(offset, offset + 5); + const code = base32_nopad_encode(reduced_hash); + return `${this.local_part}${this.separator}${sub_addr_name}${this.separator}${code}@${this.domain}` + } +} + +['a', 'b'].forEach((e) => { + const test_addr = new KeyedAddress(e, '+', 'example.org', '11voiefK5PgCX5F1TTcuoQ=='); + console.log(test1); + console.log('Sub-addr: ' + test_addr.genSubAddr('test')); +}); + +window.addEventListener('load', () => { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register('/sw.js'); + } +}); diff --git a/pwa/index.html b/pwa/index.html new file mode 100644 index 0000000..9f846aa --- /dev/null +++ b/pwa/index.html @@ -0,0 +1,15 @@ + + + + + + + Sub-Address KEy + + + + + + + + diff --git a/pwa/manifest.webmanifest b/pwa/manifest.webmanifest new file mode 100644 index 0000000..321916a --- /dev/null +++ b/pwa/manifest.webmanifest @@ -0,0 +1,9 @@ +{ + "name": "Sub-Address KEy", + "short_name": "sake", + "id": "sub-address-key", + "description": "Sub-address generator for the Sub-Address KEy (SAKE) filter.", + "start_url": "/", + "lang": "en", + "display": "standalone" +} diff --git a/pwa/sw.js b/pwa/sw.js new file mode 100644 index 0000000..ccda683 --- /dev/null +++ b/pwa/sw.js @@ -0,0 +1,43 @@ +const sw_version = '0.1.0'; +const cache_name = `sake-v${sw_version}`; +const cached_files = [ + '/app.js', + '/index.html', + '/vendor/base32.min.js', + '/vendor/base32.min.js.map', + '/vendor/sha256.min.js', +]; + +function log_message(msg) { + console.log(`[Service Worker] v${sw_version}: ${msg}`); +} + +self.addEventListener('install', (e) => { + log_message('Install'); + e.waitUntil((async () => { + const cache = await caches.open(cache_name); + log_message('Caching all'); + await cache.addAll(cached_files); + })()); +}); + +self.addEventListener('fetch', (e) => { + if (!(e.request.url.startsWith('https:') || e.request.url.startsWith('http:'))) { + log_message(`Fetching resource failed: invalid protocol: ${e.request.url}`); + return; + } + + e.respondWith((async () => { + log_message(`Fetching resource: ${e.request.url}`); + const cache_promise = await caches.match(e.request); + if (cache_promise) { + log_message(`Resource retrieved from cache: ${e.request.url}`); + return cache_promise; + } + const fetch_promise = await fetch(e.request); + const cache = await caches.open(cache_name); + log_message(`Caching new resource: ${e.request.url}`); + cache.put(e.request, fetch_promise.clone()); + return fetch_promise; + })()); +}); diff --git a/pwa/vendor/base32.min.js b/pwa/vendor/base32.min.js new file mode 100644 index 0000000..8e69343 --- /dev/null +++ b/pwa/vendor/base32.min.js @@ -0,0 +1,10 @@ +/** + * [base32.js]{@link https://github.com/speakeasyjs/base32.js} + * + * @version 0.1.0 + * @author Michael Phan-Ba + * @copyright Michael Phan-Ba + * @license MIT + */ +this.base32=function(t){function a(h){if(r[h])return r[h].exports;var i=r[h]={exports:{},id:h,loaded:!1};return t[h].call(i.exports,i,i.exports,a),i.loaded=!0,i.exports}var r={};return a.m=t,a.c=r,a.p="",a(0)}([function(t,a){"use strict";function r(t){if(this.buf=[],this.shift=8,this.carry=0,t){switch(t.type){case"rfc4648":this.charmap=a.rfc4648.charmap;break;case"crockford":this.charmap=a.crockford.charmap;break;case"base32hex":this.charmap=a.base32hex.charmap;break;default:throw new Error("invalid type")}t.charmap&&(this.charmap=t.charmap)}}function h(t){if(this.buf="",this.shift=3,this.carry=0,t){switch(t.type){case"rfc4648":this.alphabet=a.rfc4648.alphabet;break;case"crockford":this.alphabet=a.crockford.alphabet;break;case"base32hex":this.alphabet=a.base32hex.alphabet;break;default:throw new Error("invalid type")}t.alphabet?this.alphabet=t.alphabet:t.lc&&(this.alphabet=this.alphabet.toLowerCase())}}var i=function(t,a){return a||(a={}),t.split("").forEach(function(t,r){t in a||(a[t]=r)}),a},e={alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",charmap:{0:14,1:8}};e.charmap=i(e.alphabet,e.charmap);var s={alphabet:"0123456789ABCDEFGHJKMNPQRSTVWXYZ",charmap:{O:0,I:1,L:1}};s.charmap=i(s.alphabet,s.charmap);var c={alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",charmap:{}};c.charmap=i(c.alphabet,c.charmap),r.prototype.charmap=e.charmap,r.prototype.write=function(t){var a=this.charmap,r=this.buf,h=this.shift,i=this.carry;return t.toUpperCase().split("").forEach(function(t){if("="!=t){var e=255&a[t];h-=5,h>0?i|=e<h?(r.push(i|e>>-h),h+=8,i=e<>i,this.buf+=this.alphabet[31&a],i>5&&(i-=5,a=r>>i,this.buf+=this.alphabet[31&a]),i=5-i,e=r< 0) {\\n carry |= symbol << shift;\\n } else if (shift < 0) {\\n buf.push(carry | (symbol >> -shift));\\n shift += 8;\\n carry = (symbol << shift) & 0xff;\\n } else {\\n buf.push(carry | symbol);\\n shift = 8;\\n carry = 0;\\n }\\n });\\n\\n // save state\\n this.shift = shift;\\n this.carry = carry;\\n\\n // for chaining\\n return this;\\n};\\n\\n/**\\n * Finish decoding.\\n *\\n * @param {string} [str] The final string to decode.\\n * @return {Array} Decoded byte array.\\n */\\n\\nDecoder.prototype.finalize = function (str) {\\n if (str) {\\n this.write(str);\\n }\\n if (this.shift !== 8 && this.carry !== 0) {\\n this.buf.push(this.carry);\\n this.shift = 8;\\n this.carry = 0;\\n }\\n return this.buf;\\n};\\n\\n/**\\n * Create a new `Encoder` with the given options.\\n *\\n * @param {object} [options]\\n * @param {string} [type] Supported Base-32 variants are \\\"rfc4648\\\" and\\n * \\\"crockford\\\".\\n * @param {object} [alphabet] Override the alphabet used in encoding.\\n * @constructor\\n */\\n\\nfunction Encoder (options) {\\n this.buf = \\\"\\\";\\n this.shift = 3;\\n this.carry = 0;\\n\\n if (options) {\\n\\n switch (options.type) {\\n case \\\"rfc4648\\\":\\n this.alphabet = exports.rfc4648.alphabet;\\n break;\\n case \\\"crockford\\\":\\n this.alphabet = exports.crockford.alphabet;\\n break;\\n case \\\"base32hex\\\":\\n this.alphabet = exports.base32hex.alphabet;\\n break;\\n default:\\n throw new Error(\\\"invalid type\\\");\\n }\\n\\n if (options.alphabet) this.alphabet = options.alphabet;\\n else if (options.lc) this.alphabet = this.alphabet.toLowerCase();\\n }\\n}\\n\\n/**\\n * The default alphabet coresponds to RFC4648.\\n */\\n\\nEncoder.prototype.alphabet = rfc4648.alphabet;\\n\\n/**\\n * Encode a byte array, continuing from the previous state.\\n *\\n * @param {byte[]} buf The byte array to encode.\\n * @return {Encoder} this\\n */\\n\\nEncoder.prototype.write = function (buf) {\\n var shift = this.shift;\\n var carry = this.carry;\\n var symbol;\\n var byte;\\n var i;\\n\\n // encode each byte in buf\\n for (i = 0; i < buf.length; i++) {\\n byte = buf[i];\\n\\n // 1: 00000 000\\n // 2: 00 00000 0\\n // 3: 0000 0000\\n // 4: 0 00000 00\\n // 5: 000 00000\\n // 6: 00000 000\\n // 7: 00 00000 0\\n\\n symbol = carry | (byte >> shift);\\n this.buf += this.alphabet[symbol & 0x1f];\\n\\n if (shift > 5) {\\n shift -= 5;\\n symbol = byte >> shift;\\n this.buf += this.alphabet[symbol & 0x1f];\\n }\\n\\n shift = 5 - shift;\\n carry = byte << shift;\\n shift = 8 - shift;\\n }\\n\\n // save state\\n this.shift = shift;\\n this.carry = carry;\\n\\n // for chaining\\n return this;\\n};\\n\\n/**\\n * Finish encoding.\\n *\\n * @param {byte[]} [buf] The final byte array to encode.\\n * @return {string} The encoded byte array.\\n */\\n\\nEncoder.prototype.finalize = function (buf) {\\n if (buf) {\\n this.write(buf);\\n }\\n if (this.shift !== 3) {\\n this.buf += this.alphabet[this.carry & 0x1f];\\n this.shift = 3;\\n this.carry = 0;\\n }\\n return this.buf;\\n};\\n\\n/**\\n * Convenience encoder.\\n *\\n * @param {byte[]} buf The byte array to encode.\\n * @param {object} [options] Options to pass to the encoder.\\n * @return {string} The encoded string.\\n */\\n\\nexports.encode = function (buf, options) {\\n return new Encoder(options).finalize(buf);\\n};\\n\\n/**\\n * Convenience decoder.\\n *\\n * @param {string} str The string to decode.\\n * @param {object} [options] Options to pass to the decoder.\\n * @return {byte[]} The decoded byte array.\\n */\\n\\nexports.decode = function (str, options) {\\n return new Decoder(options).finalize(str);\\n};\\n\\n// Exports.\\nexports.Decoder = Decoder;\\nexports.Encoder = Encoder;\\nexports.charmap = charmap;\\nexports.crockford = crockford;\\nexports.rfc4648 = rfc4648;\\nexports.base32hex = base32hex;\\n\\n\\n/***/ }\\n/******/ ])\\n\\n\\n/** WEBPACK FOOTER **\\n ** base32.min.js\\n **/\",\" \\t// The module cache\\n \\tvar installedModules = {};\\n\\n \\t// The require function\\n \\tfunction __webpack_require__(moduleId) {\\n\\n \\t\\t// Check if module is in cache\\n \\t\\tif(installedModules[moduleId])\\n \\t\\t\\treturn installedModules[moduleId].exports;\\n\\n \\t\\t// Create a new module (and put it into the cache)\\n \\t\\tvar module = installedModules[moduleId] = {\\n \\t\\t\\texports: {},\\n \\t\\t\\tid: moduleId,\\n \\t\\t\\tloaded: false\\n \\t\\t};\\n\\n \\t\\t// Execute the module function\\n \\t\\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\\n\\n \\t\\t// Flag the module as loaded\\n \\t\\tmodule.loaded = true;\\n\\n \\t\\t// Return the exports of the module\\n \\t\\treturn module.exports;\\n \\t}\\n\\n\\n \\t// expose the modules object (__webpack_modules__)\\n \\t__webpack_require__.m = modules;\\n\\n \\t// expose the module cache\\n \\t__webpack_require__.c = installedModules;\\n\\n \\t// __webpack_public_path__\\n \\t__webpack_require__.p = \\\"\\\";\\n\\n \\t// Load entry module and return exports\\n \\treturn __webpack_require__(0);\\n\\n\\n/** WEBPACK FOOTER **\\n ** webpack/bootstrap da2e7e41f8f005e65df6\\n **/\",\"\\\"use strict\\\";\\n\\n/**\\n * Generate a character map.\\n * @param {string} alphabet e.g. \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\\\"\\n * @param {object} mappings map overrides from key to value\\n * @method\\n */\\n\\nvar charmap = function (alphabet, mappings) {\\n mappings || (mappings = {});\\n alphabet.split(\\\"\\\").forEach(function (c, i) {\\n if (!(c in mappings)) mappings[c] = i;\\n });\\n return mappings;\\n}\\n\\n/**\\n * The RFC 4648 base 32 alphabet and character map.\\n * @see {@link https://tools.ietf.org/html/rfc4648}\\n */\\n\\nvar rfc4648 = {\\n alphabet: \\\"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567\\\",\\n charmap: {\\n 0: 14,\\n 1: 8\\n }\\n};\\n\\nrfc4648.charmap = charmap(rfc4648.alphabet, rfc4648.charmap);\\n\\n/**\\n * The Crockford base 32 alphabet and character map.\\n * @see {@link http://www.crockford.com/wrmg/base32.html}\\n */\\n\\nvar crockford = {\\n alphabet: \\\"0123456789ABCDEFGHJKMNPQRSTVWXYZ\\\",\\n charmap: {\\n O: 0,\\n I: 1,\\n L: 1\\n }\\n};\\n\\ncrockford.charmap = charmap(crockford.alphabet, crockford.charmap);\\n\\n/**\\n * base32hex\\n * @see {@link https://en.wikipedia.org/wiki/Base32#base32hex}\\n */\\n\\nvar base32hex = {\\n alphabet: \\\"0123456789ABCDEFGHIJKLMNOPQRSTUV\\\",\\n charmap: {}\\n};\\n\\nbase32hex.charmap = charmap(base32hex.alphabet, base32hex.charmap);\\n\\n/**\\n * Create a new `Decoder` with the given options.\\n *\\n * @param {object} [options]\\n * @param {string} [type] Supported Base-32 variants are \\\"rfc4648\\\" and\\n * \\\"crockford\\\".\\n * @param {object} [charmap] Override the character map used in decoding.\\n * @constructor\\n */\\n\\nfunction Decoder (options) {\\n this.buf = [];\\n this.shift = 8;\\n this.carry = 0;\\n\\n if (options) {\\n\\n switch (options.type) {\\n case \\\"rfc4648\\\":\\n this.charmap = exports.rfc4648.charmap;\\n break;\\n case \\\"crockford\\\":\\n this.charmap = exports.crockford.charmap;\\n break;\\n case \\\"base32hex\\\":\\n this.charmap = exports.base32hex.charmap;\\n break;\\n default:\\n throw new Error(\\\"invalid type\\\");\\n }\\n\\n if (options.charmap) this.charmap = options.charmap;\\n }\\n}\\n\\n/**\\n * The default character map coresponds to RFC4648.\\n */\\n\\nDecoder.prototype.charmap = rfc4648.charmap;\\n\\n/**\\n * Decode a string, continuing from the previous state.\\n *\\n * @param {string} str\\n * @return {Decoder} this\\n */\\n\\nDecoder.prototype.write = function (str) {\\n var charmap = this.charmap;\\n var buf = this.buf;\\n var shift = this.shift;\\n var carry = this.carry;\\n\\n // decode string\\n str.toUpperCase().split(\\\"\\\").forEach(function (char) {\\n\\n // ignore padding\\n if (char == \\\"=\\\") return;\\n\\n // lookup symbol\\n var symbol = charmap[char] & 0xff;\\n\\n // 1: 00000 000\\n // 2: 00 00000 0\\n // 3: 0000 0000\\n // 4: 0 00000 00\\n // 5: 000 00000\\n // 6: 00000 000\\n // 7: 00 00000 0\\n\\n shift -= 5;\\n if (shift > 0) {\\n carry |= symbol << shift;\\n } else if (shift < 0) {\\n buf.push(carry | (symbol >> -shift));\\n shift += 8;\\n carry = (symbol << shift) & 0xff;\\n } else {\\n buf.push(carry | symbol);\\n shift = 8;\\n carry = 0;\\n }\\n });\\n\\n // save state\\n this.shift = shift;\\n this.carry = carry;\\n\\n // for chaining\\n return this;\\n};\\n\\n/**\\n * Finish decoding.\\n *\\n * @param {string} [str] The final string to decode.\\n * @return {Array} Decoded byte array.\\n */\\n\\nDecoder.prototype.finalize = function (str) {\\n if (str) {\\n this.write(str);\\n }\\n if (this.shift !== 8 && this.carry !== 0) {\\n this.buf.push(this.carry);\\n this.shift = 8;\\n this.carry = 0;\\n }\\n return this.buf;\\n};\\n\\n/**\\n * Create a new `Encoder` with the given options.\\n *\\n * @param {object} [options]\\n * @param {string} [type] Supported Base-32 variants are \\\"rfc4648\\\" and\\n * \\\"crockford\\\".\\n * @param {object} [alphabet] Override the alphabet used in encoding.\\n * @constructor\\n */\\n\\nfunction Encoder (options) {\\n this.buf = \\\"\\\";\\n this.shift = 3;\\n this.carry = 0;\\n\\n if (options) {\\n\\n switch (options.type) {\\n case \\\"rfc4648\\\":\\n this.alphabet = exports.rfc4648.alphabet;\\n break;\\n case \\\"crockford\\\":\\n this.alphabet = exports.crockford.alphabet;\\n break;\\n case \\\"base32hex\\\":\\n this.alphabet = exports.base32hex.alphabet;\\n break;\\n default:\\n throw new Error(\\\"invalid type\\\");\\n }\\n\\n if (options.alphabet) this.alphabet = options.alphabet;\\n else if (options.lc) this.alphabet = this.alphabet.toLowerCase();\\n }\\n}\\n\\n/**\\n * The default alphabet coresponds to RFC4648.\\n */\\n\\nEncoder.prototype.alphabet = rfc4648.alphabet;\\n\\n/**\\n * Encode a byte array, continuing from the previous state.\\n *\\n * @param {byte[]} buf The byte array to encode.\\n * @return {Encoder} this\\n */\\n\\nEncoder.prototype.write = function (buf) {\\n var shift = this.shift;\\n var carry = this.carry;\\n var symbol;\\n var byte;\\n var i;\\n\\n // encode each byte in buf\\n for (i = 0; i < buf.length; i++) {\\n byte = buf[i];\\n\\n // 1: 00000 000\\n // 2: 00 00000 0\\n // 3: 0000 0000\\n // 4: 0 00000 00\\n // 5: 000 00000\\n // 6: 00000 000\\n // 7: 00 00000 0\\n\\n symbol = carry | (byte >> shift);\\n this.buf += this.alphabet[symbol & 0x1f];\\n\\n if (shift > 5) {\\n shift -= 5;\\n symbol = byte >> shift;\\n this.buf += this.alphabet[symbol & 0x1f];\\n }\\n\\n shift = 5 - shift;\\n carry = byte << shift;\\n shift = 8 - shift;\\n }\\n\\n // save state\\n this.shift = shift;\\n this.carry = carry;\\n\\n // for chaining\\n return this;\\n};\\n\\n/**\\n * Finish encoding.\\n *\\n * @param {byte[]} [buf] The final byte array to encode.\\n * @return {string} The encoded byte array.\\n */\\n\\nEncoder.prototype.finalize = function (buf) {\\n if (buf) {\\n this.write(buf);\\n }\\n if (this.shift !== 3) {\\n this.buf += this.alphabet[this.carry & 0x1f];\\n this.shift = 3;\\n this.carry = 0;\\n }\\n return this.buf;\\n};\\n\\n/**\\n * Convenience encoder.\\n *\\n * @param {byte[]} buf The byte array to encode.\\n * @param {object} [options] Options to pass to the encoder.\\n * @return {string} The encoded string.\\n */\\n\\nexports.encode = function (buf, options) {\\n return new Encoder(options).finalize(buf);\\n};\\n\\n/**\\n * Convenience decoder.\\n *\\n * @param {string} str The string to decode.\\n * @param {object} [options] Options to pass to the decoder.\\n * @return {byte[]} The decoded byte array.\\n */\\n\\nexports.decode = function (str, options) {\\n return new Decoder(options).finalize(str);\\n};\\n\\n// Exports.\\nexports.Decoder = Decoder;\\nexports.Encoder = Encoder;\\nexports.charmap = charmap;\\nexports.crockford = crockford;\\nexports.rfc4648 = rfc4648;\\nexports.base32hex = base32hex;\\n\\n\\n\\n/*****************\\n ** WEBPACK FOOTER\\n ** ./base32.js\\n ** module id = 0\\n ** module chunks = 0\\n **/\"],\"sourceRoot\":\"\"}"],"stylingDirectives":[[]],"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/speakeasyjs/base32.js/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null,"repoAlertsPath":"/speakeasyjs/base32.js/security/dependabot","repoSecurityAndAnalysisPath":"/speakeasyjs/base32.js/settings/security_analysis","repoOwnerIsOrg":true,"currentUserCanAdminRepo":false},"displayName":"base32.min.js.map","displayUrl":"https://github.com/speakeasyjs/base32.js/blob/master/dist/base32.min.js.map?raw=true","headerInfo":{"blobSize":"20.1 KB","deleteInfo":{"deletePath":null,"deleteTooltip":"You must be signed in to make or propose changes"},"editInfo":{"editTooltip":"You must be signed in to make or propose changes"},"ghDesktopPath":"https://desktop.github.com","gitLfsPath":null,"onBranch":true,"shortPath":"43957a5","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fspeakeasyjs%2Fbase32.js%2Fblob%2Fmaster%2Fdist%2Fbase32.min.js.map","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"1","truncatedSloc":"1"},"mode":"file"},"image":false,"isCodeownersFile":null,"isValidLegacyIssueTemplate":false,"issueTemplateHelpUrl":"https://docs.github.com/articles/about-issue-and-pull-request-templates","issueTemplate":null,"discussionTemplate":null,"language":null,"large":false,"loggedIn":false,"newDiscussionPath":"/speakeasyjs/base32.js/discussions/new","newIssuePath":"/speakeasyjs/base32.js/issues/new","planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/speakeasyjs/base32.js/blob/master/dist/base32.min.js.map","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","dismissStackNoticePath":"/settings/dismiss-notice/publish_stack_from_file","releasePath":"/speakeasyjs/base32.js/releases/new?marketplace=true","showPublishActionBanner":false,"showPublishStackBanner":false},"renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"repoOwner":"speakeasyjs","repoName":"base32.js","showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","showDependabotConfigurationBanner":false,"actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timedOut":false,"notAnalyzed":true,"symbols":[]}},"copilotUserAccess":null,"csrf_tokens":{"/speakeasyjs/base32.js/branches":{"post":"aR4a5BpVe1arwLQ4Hrz92_qul1uFrcRqH9JSzTzzxSS4rmOzL2cV50da0_RZ4mopUcTMrENxX5h6EJLEr0_o0A"}}},"title":"base32.js/dist/base32.min.js.map at master ยท speakeasyjs/base32.js","locale":"en"} \ No newline at end of file diff --git a/pwa/vendor/sha256.min.js b/pwa/vendor/sha256.min.js new file mode 100644 index 0000000..74bcdf5 --- /dev/null +++ b/pwa/vendor/sha256.min.js @@ -0,0 +1,9 @@ +/** + * [js-sha256]{@link https://github.com/emn178/js-sha256} + * + * @version 0.9.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2014-2017 + * @license MIT + */ +!function(){"use strict";function t(t,i){i?(d[0]=d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,this.blocks=d):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=t}function i(i,r,s){var e,n=typeof i;if("string"===n){var o,a=[],u=i.length,c=0;for(e=0;e>6,a[c++]=128|63&o):o<55296||o>=57344?(a[c++]=224|o>>12,a[c++]=128|o>>6&63,a[c++]=128|63&o):(o=65536+((1023&o)<<10|1023&i.charCodeAt(++e)),a[c++]=240|o>>18,a[c++]=128|o>>12&63,a[c++]=128|o>>6&63,a[c++]=128|63&o);i=a}else{if("object"!==n)throw new Error(h);if(null===i)throw new Error(h);if(f&&i.constructor===ArrayBuffer)i=new Uint8Array(i);else if(!(Array.isArray(i)||f&&ArrayBuffer.isView(i)))throw new Error(h)}i.length>64&&(i=new t(r,!0).update(i).array());var y=[],p=[];for(e=0;e<64;++e){var l=i[e]||0;y[e]=92^l,p[e]=54^l}t.call(this,r,s),this.update(p),this.oKeyPad=y,this.inner=!0,this.sharedMemory=s}var h="input is invalid type",r="object"==typeof window,s=r?window:{};s.JS_SHA256_NO_WINDOW&&(r=!1);var e=!r&&"object"==typeof self,n=!s.JS_SHA256_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;n?s=global:e&&(s=self);var o=!s.JS_SHA256_NO_COMMON_JS&&"object"==typeof module&&module.exports,a="function"==typeof define&&define.amd,f=!s.JS_SHA256_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,u="0123456789abcdef".split(""),c=[-2147483648,8388608,32768,128],y=[24,16,8,0],p=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],l=["hex","array","digest","arrayBuffer"],d=[];!s.JS_SHA256_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!f||!s.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});var A=function(i,h){return function(r){return new t(h,!0).update(r)[i]()}},w=function(i){var h=A("hex",i);n&&(h=b(h,i)),h.create=function(){return new t(i)},h.update=function(t){return h.create().update(t)};for(var r=0;r>2]|=t[n]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(a[e>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=64?(this.block=a[16],this.start=e-64,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},t.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var t=this.blocks,i=this.lastByteIndex;t[16]=this.block,t[i>>2]|=c[3&i],this.block=t[16],i>=56&&(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}},t.prototype.hash=function(){var t,i,h,r,s,e,n,o,a,f=this.h0,u=this.h1,c=this.h2,y=this.h3,l=this.h4,d=this.h5,A=this.h6,w=this.h7,b=this.blocks;for(t=16;t<64;++t)i=((s=b[t-15])>>>7|s<<25)^(s>>>18|s<<14)^s>>>3,h=((s=b[t-2])>>>17|s<<15)^(s>>>19|s<<13)^s>>>10,b[t]=b[t-16]+i+b[t-7]+h<<0;for(a=u&c,t=0;t<64;t+=4)this.first?(this.is224?(e=300032,w=(s=b[0]-1413257819)-150054599<<0,y=s+24177077<<0):(e=704751109,w=(s=b[0]-210244248)-1521486534<<0,y=s+143694565<<0),this.first=!1):(i=(f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10),r=(e=f&u)^f&c^a,w=y+(s=w+(h=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&d^~l&A)+p[t]+b[t])<<0,y=s+(i+r)<<0),i=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),r=(n=y&f)^y&u^e,A=c+(s=A+(h=(w>>>6|w<<26)^(w>>>11|w<<21)^(w>>>25|w<<7))+(w&l^~w&d)+p[t+1]+b[t+1])<<0,i=((c=s+(i+r)<<0)>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),r=(o=c&y)^c&f^n,d=u+(s=d+(h=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7))+(A&w^~A&l)+p[t+2]+b[t+2])<<0,i=((u=s+(i+r)<<0)>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),r=(a=u&c)^u&y^o,l=f+(s=l+(h=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7))+(d&A^~d&w)+p[t+3]+b[t+3])<<0,f=s+(i+r)<<0;this.h0=this.h0+f<<0,this.h1=this.h1+u<<0,this.h2=this.h2+c<<0,this.h3=this.h3+y<<0,this.h4=this.h4+l<<0,this.h5=this.h5+d<<0,this.h6=this.h6+A<<0,this.h7=this.h7+w<<0},t.prototype.hex=function(){this.finalize();var t=this.h0,i=this.h1,h=this.h2,r=this.h3,s=this.h4,e=this.h5,n=this.h6,o=this.h7,a=u[t>>28&15]+u[t>>24&15]+u[t>>20&15]+u[t>>16&15]+u[t>>12&15]+u[t>>8&15]+u[t>>4&15]+u[15&t]+u[i>>28&15]+u[i>>24&15]+u[i>>20&15]+u[i>>16&15]+u[i>>12&15]+u[i>>8&15]+u[i>>4&15]+u[15&i]+u[h>>28&15]+u[h>>24&15]+u[h>>20&15]+u[h>>16&15]+u[h>>12&15]+u[h>>8&15]+u[h>>4&15]+u[15&h]+u[r>>28&15]+u[r>>24&15]+u[r>>20&15]+u[r>>16&15]+u[r>>12&15]+u[r>>8&15]+u[r>>4&15]+u[15&r]+u[s>>28&15]+u[s>>24&15]+u[s>>20&15]+u[s>>16&15]+u[s>>12&15]+u[s>>8&15]+u[s>>4&15]+u[15&s]+u[e>>28&15]+u[e>>24&15]+u[e>>20&15]+u[e>>16&15]+u[e>>12&15]+u[e>>8&15]+u[e>>4&15]+u[15&e]+u[n>>28&15]+u[n>>24&15]+u[n>>20&15]+u[n>>16&15]+u[n>>12&15]+u[n>>8&15]+u[n>>4&15]+u[15&n];return this.is224||(a+=u[o>>28&15]+u[o>>24&15]+u[o>>20&15]+u[o>>16&15]+u[o>>12&15]+u[o>>8&15]+u[o>>4&15]+u[15&o]),a},t.prototype.toString=t.prototype.hex,t.prototype.digest=function(){this.finalize();var t=this.h0,i=this.h1,h=this.h2,r=this.h3,s=this.h4,e=this.h5,n=this.h6,o=this.h7,a=[t>>24&255,t>>16&255,t>>8&255,255&t,i>>24&255,i>>16&255,i>>8&255,255&i,h>>24&255,h>>16&255,h>>8&255,255&h,r>>24&255,r>>16&255,r>>8&255,255&r,s>>24&255,s>>16&255,s>>8&255,255&s,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24&255,n>>16&255,n>>8&255,255&n];return this.is224||a.push(o>>24&255,o>>16&255,o>>8&255,255&o),a},t.prototype.array=t.prototype.digest,t.prototype.arrayBuffer=function(){this.finalize();var t=new ArrayBuffer(this.is224?28:32),i=new DataView(t);return i.setUint32(0,this.h0),i.setUint32(4,this.h1),i.setUint32(8,this.h2),i.setUint32(12,this.h3),i.setUint32(16,this.h4),i.setUint32(20,this.h5),i.setUint32(24,this.h6),this.is224||i.setUint32(28,this.h7),t},i.prototype=new t,i.prototype.finalize=function(){if(t.prototype.finalize.call(this),this.inner){this.inner=!1;var i=this.array();t.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(i),t.prototype.finalize.call(this)}};var B=w();B.sha256=B,B.sha224=w(!0),B.sha256.hmac=_(),B.sha224.hmac=_(!0),o?module.exports=B:(s.sha256=B.sha256,s.sha224=B.sha224,a&&define(function(){return B}))}(); \ No newline at end of file