doipjs/dist/doip.core.min.js

21 lines
167 KiB
JavaScript
Raw Normal View History

2023-09-18 09:46:54 -06:00
var doip=function(e,t,r){"use strict";function A(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var A=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,A.get?A:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var i=A(doipFetchers);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",UNKNOWN:"unknown",NONE:"none"},f={PEM:"pem",JWK:"jwk",ARMORED_PGP:"armored_pgp",NONE:"none"},B={ASPE:"aspe",HKP:"hkp",WKD:"wkd",HTTP:"http",NONE:"none"};var p=Object.freeze({__proto__:null,ClaimFormat:I,ClaimRelation:g,ClaimStatus:h,EntityEncodingFormat:a,Fetcher:n,ProfileType:l,ProofAccessRestriction:s,ProofFormat:c,ProxyPolicy:o,PublicKeyEncoding:f,PublicKeyFetchMethod:B,PublicKeyType:u});class C{constructor(e,t,r){this.profileVersion=2,this.profileType=e,this.identifier=t,this.personas=r||[],this.primaryPersonaIndex=r.length>0?0:-1,this.publicKey={keyType:u.NONE,fingerprint:null,encoding:f.NONE,encodedKey:null,key:null,fetch:{method:B.NONE,query:null,resolvedUrl:null}},this.verifiers=[]}addVerifier(e,t){this.verifiers.push({name:e,url:t})}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,fingerprint:this.publicKey.fingerprint,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 r=function e(){if(this instanceof e){var r=[null];return r.push.apply(r,arguments),new(Function.bind.apply(t,r))}return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var A=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,A.get?A:{enumerable:!0,get:function(){return e[t]}})})),r}var m={},y={exports:{}};!function(e,t){function r(e){return r="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},r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t="string"==typeof e||e instanceof String;if(!t){var A=r(e);throw null===e?A="null":"object"===A&&(A=e.constructor.name),new TypeError("Expected a string but received a ".concat(A))}},e.exports=t.default,e.exports.default=t.default}(y,y.exports);var k=y.exports,F={};Object.defin
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-09-18 09:46:54 -06:00
***************************************************************************** */function ot(e,t,r,A){return new(r||(r=Promise))((function(i,o){function n(e){try{s(A.next(e))}catch(e){o(e)}}function a(e){try{s(A.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,a)}s((A=A.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!==(At=at.Buffer)&&void 0!==At?At: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 r=t.length>>1;for(let A=0;A<r;A++){const r=A<<1;e[A]=It(t.charCodeAt(r),t.charCodeAt(r+1))}}const ht="a".charCodeAt(0)-10,lt="0".charCodeAt(0);function ut(e,t,r){let A=0;for(let i=0;i<r;i++){let r=t[i]>>>4;e[A++]=r>9?r+ht:r+lt,r=15&t[i],e[A++]=r>9?r+ht:r+lt}return String.fromCharCode.apply(null,e)}const ft=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!")},Bt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pt=new Uint8Array(256);for(let e=0;e<Bt.length;e++)pt[Bt.charCodeAt(e)]=e;function Ct(e,t=!0){const r=e.length,A=r%3,i=[],o=r-A;for(let t=0;t<o;t+=3){const r=(e[t]<<16&16711680)+(e[t+1]<<8&65280)+(255&e[t+2]),A=Bt.charAt(r>>18&63)+Bt.charAt(r>>12&63)+Bt.charAt(r>>6&63)+Bt.charAt(63&r);i.push(A)}if(1===A){const A=e[r-1],o=Bt.charAt(A>>2),n=Bt.charAt(A<<4&63);i.push(`${o}${n}`),t&&i.push("==")}else if(2===A){const A=(e[r-2]<<8)+e[r-1],o=Bt.charAt(A>>10),n=Bt.charAt(A>>4&63),a=Bt.charAt(A<<2&63);i.push(`${o}${n}${a}`),t&&i.push("=")}return i.join("")}function dt(e){let t=Math.floor(.75*e.length);const r=e.length;return"="===e[r-1]&&(t-=1,"="===e[r-2]&&(t-=1)),t}function Et(e){const t=dt(e),r=e.length,A=new Uint8Array(t);let i=0;for(let t=0;t<r;t+=4){const r=pt[e.charCodeAt(t)],o=pt[e.charCodeAt(t+1)],n=pt[e.charCodeAt(t+2)],a=pt[e.charCodeAt(t+3)];A[i]=r<<2|o>>4,i+=1,A[i]=(15&o)<<4|n>>2,i+=1,A[i]=(3&n)<<6|63&a,i+=1}return A}const Qt=16384,wt=4,mt=new nt,yt=new Map;function kt(e,t){return ot(this,void 0,void 0,(function*(){let r=null,A=null,i=!1;if("undefined"==typeof WebAssembly)throw new Error("WebAssembly is not supported in this environment!");const o=()=>new DataView(r.exports.memory.buffer).getUint32(r.exports.STATE_SIZE,!0),n=mt.dispatch((()=>ot(this,void 0,void 0,(function*(){if(!yt.has(e.name)){const t=Et(e.data),r=WebAssembly.compile(t);yt.set(e.name,r)}const t=yield yt.get(e.name);r=yield WebAssembly.instantiate(t,{})})))),a=(e=null)=>{i=!0,r.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,A.set(i),r.exports.Hash_Update(i.length)}})(ft(e))},c=new Uint8Array(2*t),I=(e,o=null)=>{if(!i)throw new Error("digest() called before init()");return i=!1,r.exports.Hash_Final(o),"binary"===e?A.slice(0,t):ut(c,A,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*(){r||(yield n);const e=r.exports.Hash_GetBuffer(),t=r.exports.memory.buffer;A=new Uint8Array(t,e,Qt)})))(),{getMemor