forked from Mirrors/doipjs
1 line
30 KiB
JavaScript
1 line
30 KiB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).doip=e()}}((function(){return function e(t,r,i){function o(n,a){if(!r[n]){if(!t[n]){var c="function"==typeof require&&require;if(!a&&c)return c(n,!0);if(s)return s(n,!0);var l=new Error("Cannot find module '"+n+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[n]={exports:{}};t[n][0].call(u.exports,(function(e){return o(t[n][1][e]||e)}),u,u.exports,e,t,r,i)}return r[n].exports}for(var s="function"==typeof require&&require,n=0;n<i.length;n++)o(i[n]);return o}({1:[function(e,t,r){"use strict";const i=e("./core");class o extends Error{constructor(e,...t){let r;super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,o),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e);Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(const[t,r]of e.headers.entries())this.headers[t.toLowerCase()]=r}}t.exports=i(((e,t,r,i,s)=>async(n,a,c={})=>{n=s+(n||"");let l=new URL(n);if(i||(i={}),l.username&&(i.Authorization="Basic "+btoa(l.username+":"+l.password),l=new URL(l.protocol+"//"+l.host+l.pathname+l.search)),"https:"!==l.protocol&&"http:"!==l.protocol)throw new Error("Unknown protocol, "+l.protocol);if(a)if(a instanceof ArrayBuffer||ArrayBuffer.isView(a)||"string"==typeof a);else{if("object"!=typeof a)throw new Error("Unknown body type.");a=JSON.stringify(a),i["Content-Type"]="application/json"}c=new Headers({...i||{},...c});const u=await fetch(l,{method:t,headers:c,body:a});if(u.statusCode=u.status,!e.has(u.status))throw new o(u);return"json"===r?u.json():"buffer"===r?u.arrayBuffer():"string"===r?u.text():u}))},{"./core":2}],2:[function(e,t,r){"use strict";const i=new Set(["json","buffer","string"]);t.exports=e=>(...t)=>{const r=new Set;let o,s,n,a="";return t.forEach((e=>{if("string"==typeof e)if(e.toUpperCase()===e){if(o){throw new Error(`Can't set method to ${e}, already set to ${o}.`)}o=e}else if(e.startsWith("http:")||e.startsWith("https:"))a=e;else{if(!i.has(e))throw new Error("Unknown encoding, "+e);s=e}else if("number"==typeof e)r.add(e);else{if("object"!=typeof e)throw new Error("Unknown type: "+typeof e);if(Array.isArray(e)||e instanceof Set)e.forEach((e=>r.add(e)));else{if(n)throw new Error("Cannot set headers twice.");n=e}}})),o||(o="GET"),0===r.size&&r.add(200),e(r,o,s,n,a)}},{}],3:[function(e,t,r){},{}],4:[function(e,t,r){"use strict";t.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},{}],5:[function(e,t,r){"use strict";const i=e("is-plain-obj"),{hasOwnProperty:o}=Object.prototype,{propertyIsEnumerable:s}=Object,n=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},l=e=>{const t=[];for(const r in e)o.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const i of r)s.call(e,i)&&t.push(i)}return t};function u(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return l(e).forEach((r=>{n(t,r,u(e[r]))})),t}(e):i(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return l(e).forEach((r=>{n(t,r,u(e[r]))})),t}(e):e}const p=(e,t,r,i)=>(r.forEach((r=>{void 0===t[r]&&i.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?n(e,r,d(e[r],t[r],i)):n(e,r,u(t[r])))})),e);function d(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let i=e.slice(0,0),s=0;return[e,t].forEach((t=>{const a=[];for(let r=0;r<t.length;r++)o.call(t,r)&&(a.push(String(r)),n(i,s++,t===e?t[r]:u(t[r])));i=p(i,t,l(t).filter((e=>!a.includes(e))),r)})),i})(e,t,r):i(t)&&i(e)?p(e,t,l(t),r):u(t)}t.exports=function(...e){const t=d(u(c),this!==a&&this||{},c);let r={_:{}};for(const o of e)if(void 0!==o){if(!i(o))throw new TypeError("`"+o+"` is not an Option Object");r=d(r,{_:o},t)}return r._}},{"is-plain-obj":4}],6:[function(e,t,r){(function(e){(function(){"use strict";function r(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function i(e,t){for(var r,i="",o=0,s=-1,n=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(s===a-1||1===n);else if(s!==a-1&&2===n){if(i.length<2||2!==o||46!==i.charCodeAt(i.length-1)||46!==i.charCodeAt(i.length-2))if(i.length>2){var c=i.lastIndexOf("/");if(c!==i.length-1){-1===c?(i="",o=0):o=(i=i.slice(0,c)).length-1-i.lastIndexOf("/"),s=a,n=0;continue}}else if(2===i.length||1===i.length){i="",o=0,s=a,n=0;continue}t&&(i.length>0?i+="/..":i="..",o=2)}else i.length>0?i+="/"+e.slice(s+1,a):i=e.slice(s+1,a),o=a-s-1;s=a,n=0}else 46===r&&-1!==n?++n:n=-1}return i}var o={resolve:function(){for(var t,o="",s=!1,n=arguments.length-1;n>=-1&&!s;n--){var a;n>=0?a=arguments[n]:(void 0===t&&(t=e.cwd()),a=t),r(a),0!==a.length&&(o=a+"/"+o,s=47===a.charCodeAt(0))}return o=i(o,!s),s?o.length>0?"/"+o:"/":o.length>0?o:"."},normalize:function(e){if(r(e),0===e.length)return".";var t=47===e.charCodeAt(0),o=47===e.charCodeAt(e.length-1);return 0!==(e=i(e,!t)).length||t||(e="."),e.length>0&&o&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return r(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,t=0;t<arguments.length;++t){var i=arguments[t];r(i),i.length>0&&(void 0===e?e=i:e+="/"+i)}return void 0===e?".":o.normalize(e)},relative:function(e,t){if(r(e),r(t),e===t)return"";if((e=o.resolve(e))===(t=o.resolve(t)))return"";for(var i=1;i<e.length&&47===e.charCodeAt(i);++i);for(var s=e.length,n=s-i,a=1;a<t.length&&47===t.charCodeAt(a);++a);for(var c=t.length-a,l=n<c?n:c,u=-1,p=0;p<=l;++p){if(p===l){if(c>l){if(47===t.charCodeAt(a+p))return t.slice(a+p+1);if(0===p)return t.slice(a+p)}else n>l&&(47===e.charCodeAt(i+p)?u=p:0===p&&(u=0));break}var d=e.charCodeAt(i+p);if(d!==t.charCodeAt(a+p))break;47===d&&(u=p)}var h="";for(p=i+u+1;p<=s;++p)p!==s&&47!==e.charCodeAt(p)||(0===h.length?h+="..":h+="/..");return h.length>0?h+t.slice(a+u):(a+=u,47===t.charCodeAt(a)&&++a,t.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(r(e),0===e.length)return".";for(var t=e.charCodeAt(0),i=47===t,o=-1,s=!0,n=e.length-1;n>=1;--n)if(47===(t=e.charCodeAt(n))){if(!s){o=n;break}}else s=!1;return-1===o?i?"/":".":i&&1===o?"//":e.slice(0,o)},basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');r(e);var i,o=0,s=-1,n=!0;if(void 0!==t&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var a=t.length-1,c=-1;for(i=e.length-1;i>=0;--i){var l=e.charCodeAt(i);if(47===l){if(!n){o=i+1;break}}else-1===c&&(n=!1,c=i+1),a>=0&&(l===t.charCodeAt(a)?-1==--a&&(s=i):(a=-1,s=c))}return o===s?s=c:-1===s&&(s=e.length),e.slice(o,s)}for(i=e.length-1;i>=0;--i)if(47===e.charCodeAt(i)){if(!n){o=i+1;break}}else-1===s&&(n=!1,s=i+1);return-1===s?"":e.slice(o,s)},extname:function(e){r(e);for(var t=-1,i=0,o=-1,s=!0,n=0,a=e.length-1;a>=0;--a){var c=e.charCodeAt(a);if(47!==c)-1===o&&(s=!1,o=a+1),46===c?-1===t?t=a:1!==n&&(n=1):-1!==t&&(n=-1);else if(!s){i=a+1;break}}return-1===t||-1===o||0===n||1===n&&t===o-1&&t===i+1?"":e.slice(t,o)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+i:r+e+i:i}("/",e)},parse:function(e){r(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return t;var i,o=e.charCodeAt(0),s=47===o;s?(t.root="/",i=1):i=0;for(var n=-1,a=0,c=-1,l=!0,u=e.length-1,p=0;u>=i;--u)if(47!==(o=e.charCodeAt(u)))-1===c&&(l=!1,c=u+1),46===o?-1===n?n=u:1!==p&&(p=1):-1!==n&&(p=-1);else if(!l){a=u+1;break}return-1===n||-1===c||0===p||1===p&&n===c-1&&n===a+1?-1!==c&&(t.base=t.name=0===a&&s?e.slice(1,c):e.slice(a,c)):(0===a&&s?(t.name=e.slice(1,n),t.base=e.slice(1,c)):(t.name=e.slice(a,n),t.base=e.slice(a,c)),t.ext=e.slice(n,c)),a>0?t.dir=e.slice(0,a-1):s&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};o.posix=o,t.exports=o}).call(this)}).call(this,e("_process"))},{_process:7}],7:[function(e,t,r){var i,o,s=t.exports={};function n(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(i===setTimeout)return setTimeout(e,0);if((i===n||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:n}catch(e){i=n}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var l,u=[],p=!1,d=-1;function h(){p&&l&&(p=!1,l.length?u=l.concat(u):d=-1,u.length&&f())}function f(){if(!p){var e=c(h);p=!0;for(var t=u.length;t;){for(l=u,u=[];++d<t;)l&&l[d].run();d=-1,t=u.length}l=null,p=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function y(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new m(e,t)),1!==u.length||p||c(f)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=y,s.addListener=y,s.once=y,s.off=y,s.removeListener=y,s.removeAllListeners=y,s.emit=y,s.prependListener=y,s.prependOnceListener=y,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],8:[function(e,t,r){!function(e){"use strict";e.exports.is_uri=r,e.exports.is_http_uri=i,e.exports.is_https_uri=o,e.exports.is_web_uri=s,e.exports.isUri=r,e.exports.isHttpUri=i,e.exports.isHttpsUri=o,e.exports.isWebUri=s;var t=function(e){return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)};function r(e){if(e&&!/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)&&!/%[^0-9a-f]/i.test(e)&&!/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e)){var r,i,o,s,n,a="",c="";if(a=(r=t(e))[1],i=r[2],o=r[3],s=r[4],n=r[5],a&&a.length&&o.length>=0){if(i&&i.length){if(0!==o.length&&!/^\//.test(o))return}else if(/^\/\//.test(o))return;if(/^[a-z][a-z0-9\+\-\.]*$/.test(a.toLowerCase()))return c+=a+":",i&&i.length&&(c+="//"+i),c+=o,s&&s.length&&(c+="?"+s),n&&n.length&&(c+="#"+n),c}}}function i(e,i){if(r(e)){var o,s,n,a,c="",l="",u="",p="";if(c=(o=t(e))[1],l=o[2],s=o[3],n=o[4],a=o[5],c){if(i){if("https"!=c.toLowerCase())return}else if("http"!=c.toLowerCase())return;if(l)return/:(\d+)$/.test(l)&&(u=l.match(/:(\d+)$/)[0],l=l.replace(/:\d+$/,"")),p+=c+":",p+="//"+l,u&&(p+=u),p+=s,n&&n.length&&(p+="?"+n),a&&a.length&&(p+="#"+a),p}}}function o(e){return i(e,!0)}function s(e){return i(e)||o(e)}}(t)},{}],9:[function(e,t,r){t.exports={name:"doipjs",version:"0.8.0",description:"Decentralized OpenPGP Identity Proofs library in Node.js",main:"src/index.js",dependencies:{bent:"^7.3.12",browserify:"^17.0.0","merge-options":"^3.0.3",openpgp:"^4.10.9",prettier:"^2.1.2","valid-url":"^1.0.9"},devDependencies:{"browserify-shim":"^3.8.14",chai:"^4.2.0","chai-as-promised":"^7.1.1","chai-match-pattern":"^1.2.0","license-check-and-add":"^3.0.4",minify:"^6.0.1",mocha:"^8.2.0"},scripts:{"release:bundle":"./node_modules/browserify/bin/cmd.js ./src/index.js --standalone doip -x openpgp -o ./dist/doip.js","release:minify":"./node_modules/minify/bin/minify.js ./dist/doip.js > ./dist/doip.min.js","prettier:check":"./node_modules/prettier/bin-prettier.js --check .","prettier:write":"./node_modules/prettier/bin-prettier.js --write .","license:check":"./node_modules/license-check-and-add/dist/src/cli.js check","license:add":"./node_modules/license-check-and-add/dist/src/cli.js add","license:remove":"./node_modules/license-check-and-add/dist/src/cli.js remove",docs:"docsify serve ./docs",test:"./node_modules/mocha/bin/mocha"},repository:{type:"git",url:"https://codeberg.org/keyoxide/doipjs"},homepage:"https://js.doip.rocks",keywords:["pgp","gpg","openpgp","encryption","decentralized","identity"],author:"Yarmo Mackenbach <yarmo@yarmo.eu> (https://yarmo.eu)",license:"Apache-2.0",browserify:{transform:["browserify-shim"]},"browserify-shim":{openpgp:"global:openpgp"}}},{}],10:[function(e,t,r){(function(t){(function(){e("path");const i=e("merge-options"),o=e("valid-url"),s="undefined"!=typeof window?window.openpgp:void 0!==t?t.openpgp:null,n=e("./serviceproviders"),a=e("./keys"),c=e("./utils"),l=(e,t,r,i,o)=>{let s;if(e.isVerified||!t)return e;if(Array.isArray(t))return t.forEach(((t,s)=>{e=l(e,t,r,i,o)})),e;if(0==r.length){switch(o){default:case"contains":s=new RegExp(i,"gi"),e.isVerified=s.test(t.replace(/\r?\n|\r|\\/g,""));break;case"equals":e.isVerified=t.replace(/\r?\n|\r|\\/g,"").toLowerCase()==i.toLowerCase();break;case"oneOf":s=new RegExp(i,"gi"),e.isVerified=s.test(t.join("|"))}return e}try{r[0]}catch(t){return e.errors.push("err_data_structure_incorrect"),e}return e=l(e,t[r[0]],r.slice(1),i,o)},u=(e,t)=>{let r={isVerified:!1,errors:[]};switch(t.proof.format){case"json":r=l(r,e,t.claim.path,c.generateClaim(t.claim.fingerprint,t.claim.format),t.claim.relation);break;case"text":re=new RegExp(c.generateClaim(t.claim.fingerprint,t.claim.format),"gi"),r.isVerified=re.test(e.replace(/\r?\n|\r/,""))}return r},p=async(e,t,r)=>{if(e instanceof s.key.Key){const t=await a.getFingerprint(e),i=(await a.getUserData(e)).map((async(e,i)=>new Promise((async(i,o)=>{try{i(await p(e.notations,t,r))}catch(t){console.error("Claim verification failed: "+e.userData.id,t),o(t)}}))));return Promise.allSettled(i).then((e=>e.map(((e,t)=>e.value))))}if(e instanceof Array){const i=e.map((async(e,i)=>new Promise((async(i,o)=>{try{i(await p(e,t,r))}catch(t){console.error("Claim verification failed: "+e,t),o(t)}}))));return Promise.allSettled(i).then((e=>e.map(((e,t)=>e.value))))}const c=e.replace(/^\s+|\s+$/g,"");let l=[];t||(t=null);if(r=i({returnMatchesOnly:!1,proxyPolicy:"adaptive",doipProxyHostname:"proxy.keyoxide.org"},r||{}),!o.isUri(c))throw new Error("Invalid URI");const d=n.match(c,r);if("returnMatchesOnly"in r&&r.returnMatchesOnly)return d;let h,f,m,y,g=!1,w=0;for(;!g&&w<d.length;){if(y=d[w],y.claim.fingerprint=t,f=null,y.customRequestHandler instanceof Function)try{m=await y.customRequestHandler(y,r)}catch(e){l.push("custom_request_handler_failed")}else switch(r.proxyPolicy){case"adaptive":if(y.proof.useProxy)try{m=await n.proxyRequestHandler(y,r)}catch(e){}else{try{m=await n.directRequestHandler(y,r)}catch(e){}if(!m)try{m=await n.proxyRequestHandler(y,r)}catch(e){}}break;case"fallback":try{m=await n.directRequestHandler(y,r)}catch(e){}if(!m)try{m=await n.proxyRequestHandler(y,r)}catch(e){}break;case"always":try{m=await n.proxyRequestHandler(y,r)}catch(e){}break;case"never":try{m=await n.directRequestHandler(y,r)}catch(e){}break;default:l.push("invalid_proxy_policy")}m?(h=u(m,y),0==h.errors.length&&(g=!0)):l.push("unsuccessful_claim_verification"),w++}return h||(h={isVerified:!1}),{isVerified:h.isVerified,errors:l,serviceproviderData:y}};r.verify=p}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./keys":12,"./serviceproviders":13,"./utils":28,"merge-options":5,path:6,"valid-url":8}],11:[function(e,t,r){const i=e("./claims"),o=e("./keys"),s=e("./serviceproviders"),n=e("./utils");r.claims=i,r.keys=o,r.serviceproviders=s,r.utils=n},{"./claims":10,"./keys":12,"./serviceproviders":13,"./utils":28}],12:[function(e,t,r){(function(t){(function(){e("path");const i=e("bent")("GET"),o=e("valid-url"),s="undefined"!=typeof window?window.openpgp:void 0!==t?t.openpgp:null,n=(e("merge-options"),(e,t)=>new Promise((async(r,i)=>{t=t?`https://${t}/`:"https://keys.openpgp.org/";const o=new s.HKP(t),n={query:e};let a=await o.lookup(n);a=(await s.key.readArmored(a)).keys[0],null==a&&i("Key does not exist or could not be fetched"),r(a)}))),a=e=>new Promise((async(t,r)=>{const i=new s.WKD,o={email:e},n=(await i.lookup(o)).keys[0];null==n&&r("Key does not exist or could not be fetched"),t(n)})),c=(e,t)=>new Promise((async(e,t)=>{try{await i(opts.keyLink).then((e=>{if(200===e.status)return e})).then((e=>e.text()))}catch(e){t("Error fetching Keybase key: "+e.message)}const r=(await s.key.readArmored(rawKeyContent)).keys[0];null==r&&t("Key does not exist or could not be fetched"),e(r)})),l=e=>new Promise((async(t,r)=>{e||r("Invalid public key");const i=await e.primaryKey.getFingerprint(),o=await e.getPrimaryUser(),n=e.users;let a=[];n.forEach(((e,t)=>{a[t]={userData:{id:e.userId.userid,name:e.userId.name,email:e.userId.email,comment:e.userId.comment,isPrimary:o.index===t}};const r=e.selfCertifications[0].rawNotations;a[t].notations=r.map((({name:e,value:t,humanReadable:r})=>{if(r&&"proof@metacode.biz"===e)return s.util.decode_utf8(t)}))})),t({fingerprint:i,users:a,primaryUserIndex:o.index})}));r.fetch={uri:e=>new Promise((async(t,r)=>{o.isUri(e)||r("Invalid URI");const i=e.match(/([a-zA-Z0-9]*):([a-zA-Z0-9@._=+\-]*)(?:\:([a-zA-Z0-9@._=+\-]*))?/);switch(i[1]||r("Invalid URI"),i[1]){case"hkp":t(n(i[3]?i[3]:i[2],i[3]?i[2]:null));break;case"wkd":t(a(i[2]));break;case"kb":t(c(i[2],i.length>=4&&i[3]));break;default:r("Invalid URI protocol")}})),hkp:n,wkd:a,keybase:c,plaintext:e=>new Promise((async(t,r)=>{t((await s.key.readArmored(e)).keys[0])})),signature:(e,t)=>new Promise((async(r,i)=>{let o=await s.signature.readArmored(e);if("compressed"in o.packets[0]){o=o.packets[0];await s.stream.readToEnd(await o.packets[1].getText())}const a=o.packets[0].signersUserId,c=await o.packets[0].issuerKeyId.toHex();r(n(a||c,t))}))},r.process=l,r.getUserData=e=>new Promise((async(t,r)=>{t((await l(e)).users)})),r.getFingerprint=e=>new Promise((async(t,r)=>{t((await l(e)).fingerprint)}))}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{bent:1,"merge-options":5,path:6,"valid-url":8}],13:[function(e,t,r){const i=e("bent")("GET"),o=e("./utils"),s=["dns","xmpp","twitter","reddit","liberapay","hackernews","lobsters","devto","gitea","gitlab","github","mastodon","fediverse","discourse"],n={dns:e("./serviceproviders/dns"),xmpp:e("./serviceproviders/xmpp"),twitter:e("./serviceproviders/twitter"),reddit:e("./serviceproviders/reddit"),liberapay:e("./serviceproviders/liberapay"),hackernews:e("./serviceproviders/hackernews"),lobsters:e("./serviceproviders/lobsters"),devto:e("./serviceproviders/devto"),gitea:e("./serviceproviders/gitea"),gitlab:e("./serviceproviders/gitlab"),github:e("./serviceproviders/github"),mastodon:e("./serviceproviders/mastodon"),fediverse:e("./serviceproviders/fediverse"),discourse:e("./serviceproviders/discourse")};r.list=s,r.data=n,r.match=(e,t)=>{let r,i=[];return s.forEach(((o,s)=>{r=n[o],r.reURI.test(e)&&i.push(r.processURI(e,t))})),i},r.directRequestHandler=(t,r)=>new Promise((async(r,o)=>{const s=t.proof.fetch?t.proof.fetch:t.proof.uri;switch(t.proof.format){case"json":i(s,null,{Accept:"application/json","User-Agent":"doipjs/"+e("../package.json").version}).then((async e=>await e.json())).then((e=>{r(e)})).catch((e=>{o(e)}));break;case"text":i(s).then((async e=>await e.text())).then((e=>{r(e)})).catch((e=>{o(e)}));break;default:o("No specified proof data format")}})),r.proxyRequestHandler=(e,t)=>new Promise((async(r,s)=>{const n=e.proof.fetch?e.proof.fetch:e.proof.uri;i(o.generateProxyURL(e.proof.format,n,t),null,{Accept:"application/json"}).then((async e=>await e.json())).then((e=>{r(e.content)})).catch((e=>{s(e)}))}))},{"../package.json":9,"./serviceproviders/devto":14,"./serviceproviders/discourse":15,"./serviceproviders/dns":16,"./serviceproviders/fediverse":17,"./serviceproviders/gitea":18,"./serviceproviders/github":19,"./serviceproviders/gitlab":20,"./serviceproviders/hackernews":21,"./serviceproviders/liberapay":22,"./serviceproviders/lobsters":23,"./serviceproviders/mastodon":24,"./serviceproviders/reddit":25,"./serviceproviders/twitter":26,"./serviceproviders/xmpp":27,"./utils":28,bent:1}],14:[function(e,t,r){const i=/^https:\/\/dev\.to\/(.*)\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"devto"},profile:{display:r[1],uri:"https://dev.to/"+r[1],qr:null},proof:{uri:e,fetch:`https://dev.to/api/articles/${r[1]}/${r[2]}`,useProxy:!0,format:"json"},claim:{fingerprint:null,format:"message",path:["body_markdown"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://dev.to/alice/post",shouldMatch:!0},{uri:"https://dev.to/alice/post/",shouldMatch:!0},{uri:"https://domain.org/alice/post",shouldMatch:!1}]},{}],15:[function(e,t,r){const i=/^https:\/\/(.*)\/u\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"discourse"},profile:{display:`${r[2]}@${r[1]}`,uri:e,qr:null},proof:{uri:e,fetch:`https://${r[1]}/u/${r[2]}.json`,useProxy:!0,format:"json"},claim:{fingerprint:null,format:"message",path:["user","bio_raw"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://domain.org/u/alice",shouldMatch:!0},{uri:"https://domain.org/u/alice/",shouldMatch:!0},{uri:"https://domain.org/alice",shouldMatch:!1}]},{}],16:[function(e,t,r){const i=e("dns"),o=e("bent")("GET"),s=e("../utils"),n=/^dns:([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/,a=async(e,t)=>{if("resolveTxt"in i){const t=async()=>new Promise(((t,r)=>{i.resolveTxt(e.profile.display,((e,i)=>{e&&r(e),t(i)}))}));return{hostname:e.profile.display,records:{txt:await t()}}}{const t=await o(e.proof.uri,null,{Accept:"application/json"});return await t.json()}};r.reURI=n,r.processURI=(e,t)=>{t||(t={});const r=e.match(n);return{serviceprovider:{type:"web",name:"dns"},profile:{display:r[1],uri:"https://"+r[1],qr:null},proof:{uri:s.generateProxyURL("dns",r[1],t),fetch:null,useProxy:!1,format:"json"},claim:{fingerprint:null,format:"uri",path:["records","txt"],relation:"contains"},customRequestHandler:a}},r.tests=[{uri:"dns:domain.org",shouldMatch:!0},{uri:"dns:domain.org?type=TXT",shouldMatch:!0},{uri:"https://domain.org",shouldMatch:!1}]},{"../utils":28,bent:1,dns:3}],17:[function(e,t,r){const i=/^https:\/\/(.*)\/users\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"fediverse"},profile:{display:`@${r[2]}@${r[1]}`,uri:e,qr:null},proof:{uri:e,fetch:null,useProxy:!1,format:"json"},claim:{fingerprint:null,format:"fingerprint",path:["summary"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://domain.org/users/alice",shouldMatch:!0},{uri:"https://domain.org/users/alice/",shouldMatch:!0},{uri:"https://domain.org/alice",shouldMatch:!1}]},{}],18:[function(e,t,r){const i=/^https:\/\/(.*)\/(.*)\/gitea_proof\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"gitea"},profile:{display:`${r[2]}@${r[1]}`,uri:`https://${r[1]}/${r[2]}`,qr:null},proof:{uri:e,fetch:`https://${r[1]}/api/v1/repos/${r[2]}/gitea_proof`,useProxy:!0,format:"json"},claim:{fingerprint:null,format:"message",path:["description"],relation:"equals"},customRequestHandler:null}},r.tests=[{uri:"https://domain.org/alice/gitea_proof",shouldMatch:!0},{uri:"https://domain.org/alice/gitea_proof/",shouldMatch:!0},{uri:"https://domain.org/alice/other_proof",shouldMatch:!1}]},{}],19:[function(e,t,r){const i=/^https:\/\/gist\.github\.com\/(.*)\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"github"},profile:{display:r[1],uri:"https://github.com/"+r[1],qr:null},proof:{uri:e,fetch:"https://api.github.com/gists/"+r[2],useProxy:!1,format:"json"},claim:{fingerprint:null,format:"message",path:["files","openpgp.md","content"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://gist.github.com/Alice/123456789",shouldMatch:!0},{uri:"https://gist.github.com/Alice/123456789/",shouldMatch:!0},{uri:"https://domain.org/Alice/123456789",shouldMatch:!1}]},{}],20:[function(e,t,r){const i=e("bent")("GET"),o=/^https:\/\/(.*)\/(.*)\/gitlab_proof\/?/,s=async(e,t)=>{const r=e.proof.uri.match(o),s=`https://${r[1]}/api/v4/users?username=${r[2]}`;let n;try{n=await i(s,null,{Accept:"application/json"})}catch(e){n=await i(utils.generateProxyURL("web",s,t),null,{Accept:"application/json"})}const a=(await n.json()).find((e=>e.username===r[2]));if(!a)throw new Error("No user with username "+r[2]);const c=`https://${r[1]}/api/v4/users/${a.id}/projects`;let l;try{l=await i(c,null,{Accept:"application/json"})}catch(e){l=await i(utils.generateProxyURL("web",c,t),null,{Accept:"application/json"})}const u=(await l.json()).find((e=>"gitlab_proof"===e.path));if(!u)throw new Error("No project at "+e.proof.uri);return u};r.reURI=o,r.processURI=(e,t)=>{t||(t={});const r=e.match(o);return{serviceprovider:{type:"web",name:"gitlab"},profile:{display:`${r[2]}@${r[1]}`,uri:`https://${r[1]}/${r[2]}`,qr:null},proof:{uri:e,fetch:null,useProxy:!1,format:"json"},claim:{fingerprint:null,format:"message",path:["description"],relation:"equals"},customRequestHandler:s}},r.tests=[{uri:"https://gitlab.domain.org/alice/gitlab_proof",shouldMatch:!0},{uri:"https://gitlab.domain.org/alice/gitlab_proof/",shouldMatch:!0},{uri:"https://domain.org/alice/other_proof",shouldMatch:!1}]},{bent:1}],21:[function(e,t,r){const i=/^https:\/\/news\.ycombinator\.com\/user\?id=(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"hackernews"},profile:{display:r[1],uri:e,qr:null},proof:{uri:`https://hacker-news.firebaseio.com/v0/user/${r[1]}.json`,fetch:null,useProxy:!0,format:"json"},claim:{fingerprint:null,format:"uri",path:["about"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://news.ycombinator.com/user?id=Alice",shouldMatch:!0},{uri:"https://news.ycombinator.com/user?id=Alice/",shouldMatch:!0},{uri:"https://domain.org/user?id=Alice",shouldMatch:!1}]},{}],22:[function(e,t,r){const i=/^https:\/\/liberapay\.com\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"liberapay"},profile:{display:r[1],uri:e,qr:null},proof:{uri:e,fetch:`https://liberapay.com/${r[1]}/public.json`,useProxy:!1,format:"json"},claim:{fingerprint:null,format:"message",path:["statements","content"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://liberapay.com/alice",shouldMatch:!0},{uri:"https://liberapay.com/alice/",shouldMatch:!0},{uri:"https://domain.org/alice",shouldMatch:!1}]},{}],23:[function(e,t,r){const i=/^https:\/\/lobste\.rs\/u\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"lobsters"},profile:{display:r[1],uri:e,qr:null},proof:{uri:`https://lobste.rs/u/${r[1]}.json`,fetch:null,useProxy:!0,format:"json"},claim:{fingerprint:null,format:"message",path:["about"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://lobste.rs/u/Alice",shouldMatch:!0},{uri:"https://lobste.rs/u/Alice/",shouldMatch:!0},{uri:"https://domain.org/u/Alice",shouldMatch:!1}]},{}],24:[function(e,t,r){const i=/^https:\/\/(.*)\/@(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"mastodon"},profile:{display:`@${r[2]}@${r[1]}`,uri:e,qr:null},proof:{uri:e,fetch:null,useProxy:!1,format:"json"},claim:{fingerprint:null,format:"fingerprint",path:["attachment","value"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://domain.org/@alice",shouldMatch:!0},{uri:"https://domain.org/@alice/",shouldMatch:!0},{uri:"https://domain.org/alice",shouldMatch:!1}]},{}],25:[function(e,t,r){const i=/^https:\/\/(?:www\.)?reddit\.com\/user\/(.*)\/comments\/(.*)\/(.*)\/?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"reddit"},profile:{display:r[1],uri:"https://www.reddit.com/user/"+r[1],qr:null},proof:{uri:e,fetch:`https://www.reddit.com/user/${r[1]}/comments/${r[2]}.json`,useProxy:!0,format:"json"},claim:{fingerprint:null,format:"message",path:["data","children","data","selftext"],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://www.reddit.com/user/Alice/comments/123456/post",shouldMatch:!0},{uri:"https://www.reddit.com/user/Alice/comments/123456/post/",shouldMatch:!0},{uri:"https://reddit.com/user/Alice/comments/123456/post",shouldMatch:!0},{uri:"https://reddit.com/user/Alice/comments/123456/post/",shouldMatch:!0},{uri:"https://domain.org/user/Alice/comments/123456/post",shouldMatch:!1}]},{}],26:[function(e,t,r){const i=/^https:\/\/twitter\.com\/(.*)\/status\/([0-9]*)(?:\?.*)?/;r.reURI=i,r.processURI=(e,t)=>{t||(t={});const r=e.match(i);return{serviceprovider:{type:"web",name:"twitter"},profile:{display:"@"+r[1],uri:"https://twitter.com/"+r[1],qr:null},proof:{uri:e,fetch:`https://mobile.twitter.com/${r[1]}/status/${r[2]}`,useProxy:!0,format:"text"},claim:{fingerprint:null,format:"message",path:[],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"https://twitter.com/alice/status/1234567890123456789",shouldMatch:!0},{uri:"https://twitter.com/alice/status/1234567890123456789/",shouldMatch:!0},{uri:"https://domain.org/alice/status/1234567890123456789",shouldMatch:!1}]},{}],27:[function(e,t,r){const i=e("../utils"),o=/^xmpp:([a-zA-Z0-9\.\-\_]*)@([a-zA-Z0-9\.\-\_]*)(?:\?(.*))?/;r.reURI=o,r.processURI=(e,t)=>{t||(t={});const r=e.match(o);return{serviceprovider:{type:"communication",name:"xmpp"},profile:{display:`${r[1]}@${r[2]}`,uri:e,qr:e},proof:{uri:i.generateProxyURL("xmpp",`${r[1]}@${r[2]}`,t),fetch:null,useProxy:!1,format:"json"},claim:{fingerprint:null,format:"message",path:[],relation:"contains"},customRequestHandler:null}},r.tests=[{uri:"xmpp:alice@domain.org",shouldMatch:!0},{uri:"xmpp:alice@domain.org?omemo-sid-123456789=A1B2C3D4E5F6G7H8I9",shouldMatch:!0},{uri:"https://domain.org",shouldMatch:!1}]},{"../utils":28}],28:[function(e,t,r){r.generateProxyURL=(e,t,r)=>{if(!r||!r.doipProxyHostname)return null;let i="";return"xmpp"==e&&(i+="/DESC"),`https://${r.doipProxyHostname}/api/1/get/${e}/${encodeURIComponent(t)}${i}`},r.generateClaim=(e,t)=>{switch(t){case"uri":return"openpgp4fpr:"+e;case"message":return`[Verifying my OpenPGP key: openpgp4fpr:${e}]`;case"fingerprint":return e;default:throw new Error("No valid claim format")}}},{}]},{},[11])(11)}));
|