doipjs/dist/doip.core.min.js

21 lines
165 KiB
JavaScript
Raw Normal View History

2023-07-10 03:46:53 -06:00
var doip=function(e,t,A){"use strict";function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(A){if("default"!==A){var r=Object.getOwnPropertyDescriptor(e,A);Object.defineProperty(t,A,r.get?r:{enumerable:!0,get:function(){return e[A]}})}})),t.default=e,Object.freeze(t)}var i=r(t);const o={ADAPTIVE:"adaptive",ALWAYS:"always",NEVER:"never"},n={ACTIVITYPUB:"activitypub",DNS:"dns",GRAPHQL:"graphql",HTTP:"http",IRC:"irc",MATRIX:"matrix",TELEGRAM:"telegram",XMPP:"xmpp"},a={PLAIN:"plain",HTML:"html",XML:"xml"},s={NONE:"none",NOCORS:"nocors",GRANTED:"granted",SERVER:"server"},c={JSON:"json",TEXT:"text"},I={URI:"uri",FINGERPRINT:"fingerprint"},g={CONTAINS:"contains",EQUALS:"equals",ONEOF:"oneof"},h={INIT:100,MATCHED:101,VERIFIED:200,VERIFIED_VIA_PROXY:201,MATCHING_ERROR:300,NO_MATCHES:301,VERIFICATION_ERROR:400,NO_PROOF_FOUND:401},l={ASP:"asp",OPENPGP:"openpgp"},u={EDDSA:"eddsa",ES256:"es256",OPENPGP:"openpgp",NONE:"none"},B={PEM:"pem",JWK:"jwk",ARMORED_PGP:"armored_pgp",NONE:"none"},f={ASPE:"aspe",HKP:"hkp",WKD:"wkd",HTTP:"http",NONE:"none"};var C=Object.freeze({__proto__:null,ClaimFormat:I,ClaimRelation:g,ClaimStatus:h,EntityEncodingFormat:a,Fetcher:n,ProfileType:l,ProofAccessRestriction:s,ProofFormat:c,ProxyPolicy:o,PublicKeyEncoding:B,PublicKeyFetchMethod:f,PublicKeyType:u});class p{constructor(e,t,A){this.profileVersion=2,this.profileType=e,this.identifier=t,this.personas=A||[],this.primaryPersonaIndex=A.length>0?0:-1,this.publicKey={keyType:u.NONE,encoding:B.NONE,encodedKey:null,key:null,fetch:{method:f.NONE,query:null,resolvedUrl:null}},this.verifiers=[]}addVerifier(e,t){this.verifiers.push({name:e,url:t})}setOpenPgpPublicKey(e){}setJwkPublicKey(e){}toJSON(){return{profileVersion:this.profileVersion,profileType:this.profileType,identifier:this.identifier,personas:this.personas.map((e=>e.toJSON())),primaryPersonaIndex:this.primaryPersonaIndex,publicKey:{keyType:this.publicKey.keyType,encoding:this.publicKey.encoding,encodedKey:this.publicKey.encodedKey,fetch:{method:this.publicKey.fetch.method,query:this.publicKey.fetch.query,resolvedUrl:this.publicKey.fetch.resolvedUrl}},verifiers:this.verifiers}}}class d{constructor(e,t){this.identifier=null,this.name=e,this.email=null,this.description=null,this.avatarUrl=null,this.claims=t,this.isRevoked=!1}setIdentifier(e){this.identifier=e}setDescription(e){this.description=e}setEmailAddress(e){this.email=e}setAvatarUrl(e){this.avatarUrl=e}addClaim(e){this.claims.push(e)}revoke(){this.isRevoked=!0}toJSON(){return{identifier:this.identifier,name:this.name,email:this.email,description:this.description,avatarUrl:this.avatarUrl,isRevoked:this.isRevoked,claims:this.claims.map((e=>e.toJSON()))}}}var E="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Q(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function w(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var A=function e(){if(this instanceof e){var A=[null];return A.push.apply(A,arguments),new(Function.bind.apply(t,A))}return t.apply(this,arguments)};A.prototype=t.prototype}else A={};return Object.defineProperty(A,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(A,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),A}var y={},m={exports:{}};!function(e,t){function A(e){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},A(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t="string"==typeof e||e instanceof String;if(!t){var r=A(e);throw null===e?r="null":"object"===r&&(r=e.constructor.name),new TypeError("Expected a string but received a ".concat(r))}},e.exports=t.default,e.exports.default=t.default}(m,m.exports);var k=m.exports,F={};Object.defineProperty(F,"__esModule",{value:!0}),F.co
2023-07-08 00:36:57 -06:00
/*!
2023-07-09 04:05:21 -06:00
* hash-wasm (https://www.npmjs.com/package/hash-wasm)
* (c) Dani Biro
* @license MIT
*/
2023-07-08 00:36:57 -06:00
/*! *****************************************************************************
2023-07-09 04:05:21 -06:00
Copyright (c) Microsoft Corporation.
2023-07-08 00:36:57 -06:00
2023-07-09 04:05:21 -06:00
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
2023-07-08 00:36:57 -06:00
2023-07-09 04:05:21 -06:00
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
2023-07-10 03:46:53 -06:00
***************************************************************************** */function ot(e,t,A,r){return new(A||(A=Promise))((function(i,o){function n(e){try{s(r.next(e))}catch(e){o(e)}}function a(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof A?t:new A((function(e){e(t)}))).then(n,a)}s((r=r.apply(e,t||[])).next())}))}class nt{constructor(){this.mutex=Promise.resolve()}lock(){let e=()=>{};return this.mutex=this.mutex.then((()=>new Promise(e))),new Promise((t=>{e=t}))}dispatch(e){return ot(this,void 0,void 0,(function*(){const t=yield this.lock();try{return yield Promise.resolve(e())}finally{t()}}))}}const at="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:he,st=null!==(rt=at.Buffer)&&void 0!==rt?rt:null,ct=at.TextEncoder?new at.TextEncoder:null;function It(e,t){return(15&e)+(e>>6|e>>3&8)<<4|(15&t)+(t>>6|t>>3&8)}function gt(e,t){const A=t.length>>1;for(let r=0;r<A;r++){const A=r<<1;e[r]=It(t.charCodeAt(A),t.charCodeAt(A+1))}}const ht="a".charCodeAt(0)-10,lt="0".charCodeAt(0);function ut(e,t,A){let r=0;for(let i=0;i<A;i++){let A=t[i]>>>4;e[r++]=A>9?A+ht:A+lt,A=15&t[i],e[r++]=A>9?A+ht:A+lt}return String.fromCharCode.apply(null,e)}const Bt=null!==st?e=>{if("string"==typeof e){const t=st.from(e,"utf8");return new Uint8Array(t.buffer,t.byteOffset,t.length)}if(st.isBuffer(e))return new Uint8Array(e.buffer,e.byteOffset,e.length);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")}:e=>{if("string"==typeof e)return ct.encode(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Invalid data type!")},ft="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ct=new Uint8Array(256);for(let e=0;e<ft.length;e++)Ct[ft.charCodeAt(e)]=e;function pt(e,t=!0){const A=e.length,r=A%3,i=[],o=A-r;for(let t=0;t<o;t+=3){const A=(e[t]<<16&16711680)+(e[t+1]<<8&65280)+(255&e[t+2]),r=ft.charAt(A>>18&63)+ft.charAt(A>>12&63)+ft.charAt(A>>6&63)+ft.charAt(63&A);i.push(r)}if(1===r){const r=e[A-1],o=ft.charAt(r>>2),n=ft.charAt(r<<4&63);i.push(`${o}${n}`),t&&i.push("==")}else if(2===r){const r=(e[A-2]<<8)+e[A-1],o=ft.charAt(r>>10),n=ft.charAt(r>>4&63),a=ft.charAt(r<<2&63);i.push(`${o}${n}${a}`),t&&i.push("=")}return i.join("")}function dt(e){let t=Math.floor(.75*e.length);const A=e.length;return"="===e[A-1]&&(t-=1,"="===e[A-2]&&(t-=1)),t}function Et(e){const t=dt(e),A=e.length,r=new Uint8Array(t);let i=0;for(let t=0;t<A;t+=4){const A=Ct[e.charCodeAt(t)],o=Ct[e.charCodeAt(t+1)],n=Ct[e.charCodeAt(t+2)],a=Ct[e.charCodeAt(t+3)];r[i]=A<<2|o>>4,i+=1,r[i]=(15&o)<<4|n>>2,i+=1,r[i]=(3&n)<<6|63&a,i+=1}return r}const Qt=16384,wt=4,yt=new nt,mt=new Map;function kt(e,t){return ot(this,void 0,void 0,(function*(){let A=null,r=null,i=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const o=()=>new DataView(A.exports.memory.buffer).getUint32(A.exports.STATE_SIZE,!0),n=yt.dispatch((()=>ot(this,void 0,void 0,(function*(){if(!mt.has(e.name)){const t=Et(e.data),A=WebAssembly.compile(t);mt.set(e.name,A)}const t=yield mt.get(e.name);A=yield WebAssembly.instantiate(t,{})})))),a=(e=null)=>{i=!0,A.exports.Hash_Init(e)},s=e=>{if(!i)throw new Error("update() called before init()");(e=>{let t=0;for(;t<e.length;){const i=e.subarray(t,t+Qt);t+=i.length,r.set(i),A.exports.Hash_Update(i.length)}})(Bt(e))},c=new Uint8Array(2*t),I=(e,o=null)=>{if(!i)throw new Error("digest() called before init()");return i=!1,A.exports.Hash_Final(o),"binary"===e?r.slice(0,t):ut(c,r,t)},g=e=>"string"==typeof e?e.length<Qt/4:e.byteLength<Qt;let h=g;switch(e.name){case"argon2":case"scrypt":h=()=>!0;break;case"blake2b":case"blake2s":h=(e,t)=>t<=512&&g(e);break;case"blake3":h=(e,t)=>0===t&&g(e);break;case"xxhash64":case"xxhash3":case"xxhash128":h=()=>!1}return yield(()=>ot(this,void 0,void 0,(function*(){A||(yield n);const e=A.exports.Hash_GetBuffer(),t=A.exports.memory.buffer;r=new Uint8Array(t,e,Qt)})))(),{getMemor