@blockcerts/blockcerts-verifier 1.72.3 → 1.73.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +8 -0
  2. package/bundle-stats.html +1 -1
  3. package/codecov +0 -0
  4. package/codecov.SHA256SUM +1 -0
  5. package/codecov.SHA256SUM.sig +16 -0
  6. package/coverage/lcov.info +475 -472
  7. package/dist/{DataIntegrityProof-BhL7Kkhm-affsdujn.js → DataIntegrityProof-D8TnXEkl-CGiIg0kn.js} +2 -2
  8. package/dist/{EcdsaSd2023-CUjrjGzC-Cx7ejHu-.js → EcdsaSd2023-D2eJBmaY-mHNjbn8h.js} +9 -13
  9. package/dist/EcdsaSecp256k1Signature2019-BRdQnZ0o-D_QN8KrS.js +1 -0
  10. package/dist/{Ed25519Signature2020-fJGvlbIp-B6XhFwr4.js → Ed25519Signature2020-D2tdrIA4-PSi5TCQH.js} +6 -6
  11. package/dist/EddsaRdfc2022-CpZAUc7W-BJP0532C.js +14 -0
  12. package/dist/{HashlinkVerifier-udsj5z09-BTqOkVoD.js → HashlinkVerifier-BcdAFe02-DMjUYzMR.js} +1 -1
  13. package/dist/MerkleProof2017-DW_9FhLr-C0dPtifx.js +1 -0
  14. package/dist/MerkleProof2019-DJbo7uW--CHlhsnHk.js +5 -0
  15. package/dist/Suite-BmP2Qu19-D1ucdMDB.js +1 -0
  16. package/dist/_polyfill-node.crypto-MVmI5M_M-exGcp6nW.js +1 -0
  17. package/dist/_polyfill-node.path-hKwMKLNw-B7aPtphV.js +1 -0
  18. package/dist/checkBitStringStatusList-BUPuVWy_-CYedocxJ.js +13 -0
  19. package/dist/checkCredentialSchemaConformity-CJdGwNcY-CaSak-bD.js +1 -0
  20. package/dist/controlVerificationMethod-C71lJp3H-n-AbzkO8.js +1 -0
  21. package/dist/{downloadPDF-UAsY-nU_.js → downloadPDF-BU6CfP-N.js} +2 -2
  22. package/dist/{ensureNotRevoked-ByWaYoog-BheL-ZKZ.js → ensureNotRevoked-BWp1jPEo-DSQMtjrj.js} +1 -1
  23. package/dist/ensureValidIssuingKey-BYAR3LEF-76kiqVKA.js +1 -0
  24. package/dist/{index-tlZQQ_rg-CYTlxhyY.js → index-BCu3PGuw-Dh4-8Ruv.js} +1 -1
  25. package/dist/index-CB7VaVsF-G_Mj6xql.js +30 -0
  26. package/dist/index-Jn9Q6fuB-uChPhl1c.js +56 -0
  27. package/dist/{index-DjD0A6uJ-BdFUkPCF.js → index-OtXtCWrq-CyttRwCk.js} +4 -4
  28. package/dist/{index.es-CnYWLNZV.js → index.es-C2GPR7m7.js} +1 -1
  29. package/dist/jsonld-DqC1oHcn-ruRlORc0.js +88 -0
  30. package/dist/main.js +84 -84
  31. package/dist/purify.es-C6IIzwyE.js +2 -0
  32. package/dist/{retrieveVerificationMethodPublicKey-D_autuwE-DGbK-RPm.js → retrieveVerificationMethodPublicKey-Dai7em0K-BqIH8qzD.js} +1 -1
  33. package/dist/verifyIssuerProfile-zkczSLpC-CTHpISfH.js +1 -0
  34. package/dist/webcrypto.es-9hytEjC6-gGk5JRJH.js +40 -0
  35. package/package.json +9 -9
  36. package/dist/EcdsaSecp256k1Signature2019-D90cAynb-Bf5kILPF.js +0 -1
  37. package/dist/EddsaRdfc2022-XufziFi3-D5IoKiRE.js +0 -14
  38. package/dist/MerkleProof2017-C0RhRNNx-zjQMRSQY.js +0 -1
  39. package/dist/MerkleProof2019-B7f1hhem-CjLDyx6Q.js +0 -5
  40. package/dist/Suite-Bu3gszvt-Dmvbh142.js +0 -33
  41. package/dist/_polyfill-node.crypto-DGISCHrB-C5-OOGc0.js +0 -1
  42. package/dist/checkCredentialSchemaConformity-CgpOS3eC-AjSPoJub.js +0 -1
  43. package/dist/checkRevocationStatusList2021-D4VNDRlW-DgNfOAoI.js +0 -13
  44. package/dist/controlVerificationMethod-CSwPoUL8-CvUADmjg.js +0 -1
  45. package/dist/ed25519-key-pair.esm-DxoBwwVJ-D8j8wFfG.js +0 -1
  46. package/dist/ensureValidIssuingKey-DEV9E0Ph-DY8BTObG.js +0 -1
  47. package/dist/index-DZ7aUhT_-D0G2DVsh.js +0 -29
  48. package/dist/jsonld-signatures-D4X_Irzi-D_wBqxSl.js +0 -56
  49. package/dist/pako.esm-BGRKTPxS-Bodm4Eha.js +0 -2
  50. package/dist/purify.es-Om653OSQ.js +0 -2
  51. package/dist/sha2-JcCWfgvE-By1_saxP.js +0 -2
  52. package/dist/tslib.es6--gQC4x5c-CmLYFWVC.js +0 -1
  53. package/dist/verifyIssuerProfile-2PhdMtQZ-CfqcAkBL.js +0 -1
  54. package/dist/webcrypto.es-BOyMRPOj-CAxP3jJR.js +0 -40
  55. /package/dist/{index-CyNtT_1q-Dgus2xdV.js → index-KzSDgEl9-Dgus2xdV.js} +0 -0
@@ -0,0 +1,2 @@
1
+ /*! @license DOMPurify 3.4.13 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.13/LICENSE */
2
+ function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,l=[],c=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(c=(o=i.call(n)).done)&&(l.push(o.value),l.length!==t);c=!0);}catch(e){s=!0,r=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw r}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var o={}.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const n=Object.entries,o=Object.setPrototypeOf,r=Object.isFrozen,i=Object.getPrototypeOf,a=Object.getOwnPropertyDescriptor;let l=Object.freeze,c=Object.seal,s=Object.create,u="undefined"!=typeof Reflect&&Reflect,f=u.apply,p=u.construct;l||(l=function(e){return e}),c||(c=function(e){return e}),f||(f=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),p||(p=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const m=L(Array.prototype.forEach),d=L(Array.prototype.lastIndexOf),h=L(Array.prototype.pop),g=L(Array.prototype.push),y=L(Array.prototype.splice),b=Array.isArray,T=L(String.prototype.toLowerCase),S=L(String.prototype.toString),E=L(String.prototype.match),A=L(String.prototype.replace),N=L(String.prototype.indexOf),_=L(String.prototype.trim),w=L(Number.prototype.toString),O=L(Boolean.prototype.toString),v="undefined"==typeof BigInt?null:L(BigInt.prototype.toString),D="undefined"==typeof Symbol?null:L(Symbol.prototype.toString),R=L(Object.prototype.hasOwnProperty),C=L(Object.prototype.toString),I=L(RegExp.prototype.test),k=(x=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return p(x,t)});var x;function L(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return f(e,t,o)}}function M(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;if(o&&o(e,null),!b(t))return e;let i=t.length;for(;i--;){let o=t[i];if("string"==typeof o){const e=n(o);e!==o&&(r(t)||(t[i]=e),o=e)}e[o]=!0}return e}function z(e){for(let t=0;t<e.length;t++){R(e,t)||(e[t]=null)}return e}function P(e){const o=s(null);for(const i of n(e)){var r=t(i,2);const n=r[0],a=r[1];R(e,n)&&(b(a)?o[n]=z(a):a&&"object"==typeof a&&a.constructor===Object?o[n]=P(a):o[n]=a)}return o}function U(e,t){for(;null!==e;){const n=a(e,t);if(n){if(n.get)return L(n.get);if("function"==typeof n.value)return L(n.value)}e=i(e)}return function(){return null}}const F=l(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),H=l(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),j=l(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),B=l(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),G=l(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),W=l(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Y=l(["#text"]),q=l(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),X=l(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),$=l(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),K=l(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),V=c(/{{[\w\W]*|^[\w\W]*}}/g),Z=c(/<%[\w\W]*|^[\w\W]*%>/g),J=c(/\${[\w\W]*/g),Q=c(/^data-[\-\w.\u00B7-\uFFFF]+$/),ee=c(/^aria-[\-\w]+$/),te=c(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ne=c(/^(?:\w+script|data):/i),oe=c(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),re=c(/^html$/i),ie=c(/^[a-z][.\w]*(-[.\w]+)+$/i),ae=c(/<[/\w!]/g),le=c(/<[/\w]/g),ce=c(/<\/no(script|embed|frames)/i),se=c(/\/>/i),ue=1,fe=3,pe=7,me=8,de=9,he=11,ge=function(){return"undefined"==typeof window?null:window},ye=function(e,t,n,o){return R(e,t)&&b(e[t])?M(o.base?P(o.base):{},e[t],o.transform):n};var be=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ge();const o=t=>e(t);if(o.version="3.4.13",o.removed=[],!t||!t.document||t.document.nodeType!==de||!t.Element)return o.isSupported=!1,o;let r=t.document;const i=r,a=i.currentScript;t.DocumentFragment;const u=t.HTMLTemplateElement,f=t.Node,p=t.Element,x=t.NodeFilter,L=t.NamedNodeMap;void 0===L&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const z=t.DOMParser,be=t.trustedTypes,Te=p.prototype,Se=U(Te,"cloneNode"),Ee=U(Te,"remove"),Ae=U(Te,"nextSibling"),Ne=U(Te,"childNodes"),_e=U(Te,"parentNode"),we=U(Te,"shadowRoot"),Oe=U(Te,"attributes"),ve=f&&f.prototype?U(f.prototype,"nodeType"):null,De=f&&f.prototype?U(f.prototype,"nodeName"):null,Re=f&&f.prototype?U(f.prototype,"ownerDocument"):null;if("function"==typeof u){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let Ce,Ie,ke="",xe=!1,Le=0;const Me=function(){if(Le>0)throw k('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},ze=function(e){Me(),Le++;try{return Ce.createHTML(e)}finally{Le--}},Pe=function(){return xe||(Ie=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(be,a),xe=!0),Ie},Ue=r,Fe=Ue.implementation,He=Ue.createNodeIterator,je=Ue.createDocumentFragment,Be=Ue.getElementsByTagName,Ge=i.importNode;let We={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};o.isSupported="function"==typeof n&&"function"==typeof _e&&Fe&&void 0!==Fe.createHTMLDocument;const Ye=V,qe=Z,Xe=J,$e=Q,Ke=ee,Ve=ne,Ze=oe,Je=ie;let Qe=te,et=null;const tt=M({},[...F,...H,...j,...G,...Y]);let nt=null;const ot=M({},[...q,...X,...$,...K]);let rt=Object.seal(s(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),it=null,at=null;const lt=Object.seal(s(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ct=!0,st=!0,ut=!1,ft=!0,pt=!1,mt=!0,dt=!1,ht=!1,gt=null,yt=null,bt=!1,Tt=!1,St=!1,Et=!1,At=!0,Nt=!1;const _t="user-content-";let wt=!0,Ot=!1,vt={},Dt=null;const Rt=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ct=null;const It=M({},["audio","video","img","source","image","track"]);let kt=null;const xt=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Lt="http://www.w3.org/1998/Math/MathML",Mt="http://www.w3.org/2000/svg",zt="http://www.w3.org/1999/xhtml";let Pt=zt,Ut=!1,Ft=null;const Ht=M({},[Lt,Mt,zt],S),jt=l(["mi","mo","mn","ms","mtext"]);let Bt=M({},jt);const Gt=l(["annotation-xml"]);let Wt=M({},Gt);const Yt=M({},["title","style","font","a","script"]);let qt=null;const Xt=["application/xhtml+xml","text/html"];let $t=null,Kt=null;const Vt=r.createElement("form"),Zt=function(e){return e instanceof RegExp||e instanceof Function},Jt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Kt&&Kt===e)return;e&&"object"==typeof e||(e={}),e=P(e),qt=-1===Xt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,$t="application/xhtml+xml"===qt?S:T,et=ye(e,"ALLOWED_TAGS",tt,{transform:$t}),nt=ye(e,"ALLOWED_ATTR",ot,{transform:$t}),Ft=ye(e,"ALLOWED_NAMESPACES",Ht,{transform:S}),kt=ye(e,"ADD_URI_SAFE_ATTR",xt,{transform:$t,base:xt}),Ct=ye(e,"ADD_DATA_URI_TAGS",It,{transform:$t,base:It}),Dt=ye(e,"FORBID_CONTENTS",Rt,{transform:$t}),it=ye(e,"FORBID_TAGS",P({}),{transform:$t}),at=ye(e,"FORBID_ATTR",P({}),{transform:$t}),vt=!!R(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?P(e.USE_PROFILES):e.USE_PROFILES),ct=!1!==e.ALLOW_ARIA_ATTR,st=!1!==e.ALLOW_DATA_ATTR,ut=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ft=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,pt=e.SAFE_FOR_TEMPLATES||!1,mt=!1!==e.SAFE_FOR_XML,dt=e.WHOLE_DOCUMENT||!1,Tt=e.RETURN_DOM||!1,St=e.RETURN_DOM_FRAGMENT||!1,Et=e.RETURN_TRUSTED_TYPE||!1,bt=e.FORCE_BODY||!1,At=!1!==e.SANITIZE_DOM,Nt=e.SANITIZE_NAMED_PROPS||!1,wt=!1!==e.KEEP_CONTENT,Ot=e.IN_PLACE||!1,Qe=function(e){try{return I(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:te,Pt="string"==typeof e.NAMESPACE?e.NAMESPACE:zt,Bt=R(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?P(e.MATHML_TEXT_INTEGRATION_POINTS):M({},jt),Wt=R(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?P(e.HTML_INTEGRATION_POINTS):M({},Gt);const t=R(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?P(e.CUSTOM_ELEMENT_HANDLING):s(null);if(rt=s(null),R(t,"tagNameCheck")&&Zt(t.tagNameCheck)&&(rt.tagNameCheck=t.tagNameCheck),R(t,"attributeNameCheck")&&Zt(t.attributeNameCheck)&&(rt.attributeNameCheck=t.attributeNameCheck),R(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(rt.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),c(rt),pt&&(st=!1),St&&(Tt=!0),vt&&(et=M({},Y),nt=s(null),!0===vt.html&&(M(et,F),M(nt,q)),!0===vt.svg&&(M(et,H),M(nt,X),M(nt,K)),!0===vt.svgFilters&&(M(et,j),M(nt,X),M(nt,K)),!0===vt.mathMl&&(M(et,G),M(nt,$),M(nt,K))),lt.tagCheck=null,lt.attributeCheck=null,R(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?lt.tagCheck=e.ADD_TAGS:b(e.ADD_TAGS)&&(et===tt&&(et=P(et)),M(et,e.ADD_TAGS,$t))),R(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?lt.attributeCheck=e.ADD_ATTR:b(e.ADD_ATTR)&&(nt===ot&&(nt=P(nt)),M(nt,e.ADD_ATTR,$t))),R(e,"ADD_URI_SAFE_ATTR")&&b(e.ADD_URI_SAFE_ATTR)&&M(kt,e.ADD_URI_SAFE_ATTR,$t),R(e,"FORBID_CONTENTS")&&b(e.FORBID_CONTENTS)&&(Dt===Rt&&(Dt=P(Dt)),M(Dt,e.FORBID_CONTENTS,$t)),R(e,"ADD_FORBID_CONTENTS")&&b(e.ADD_FORBID_CONTENTS)&&(Dt===Rt&&(Dt=P(Dt)),M(Dt,e.ADD_FORBID_CONTENTS,$t)),wt&&(et["#text"]=!0),dt&&M(et,["html","head","body"]),et.table&&(M(et,["tbody"]),delete it.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw k('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=Ce;Ce=e.TRUSTED_TYPES_POLICY;try{ke=ze("")}catch(e){throw Ce=t,e}}else null===e.TRUSTED_TYPES_POLICY?(Ce=void 0,ke=""):(void 0===Ce&&(Ce=Pe()),Ce&&"string"==typeof ke&&(ke=ze("")));l&&l(e),Kt=e},Qt=M({},[...H,...j,...B]),en=M({},[...G,...W]),tn=function(e){let t=_e(e);t&&t.tagName||(t={namespaceURI:Pt,tagName:"template"});const n=T(e.tagName),o=T(t.tagName);return!!Ft[e.namespaceURI]&&(e.namespaceURI===Mt?function(e,t,n){return t.namespaceURI===zt?"svg"===e:t.namespaceURI===Lt?"svg"===e&&("annotation-xml"===n||Bt[n]):Boolean(Qt[e])}(n,t,o):e.namespaceURI===Lt?function(e,t,n){return t.namespaceURI===zt?"math"===e:t.namespaceURI===Mt?"math"===e&&Wt[n]:Boolean(en[e])}(n,t,o):e.namespaceURI===zt?function(e,t,n){return!(t.namespaceURI===Mt&&!Wt[n])&&!(t.namespaceURI===Lt&&!Bt[n])&&!en[e]&&(Yt[e]||!Qt[e])}(n,t,o):!("application/xhtml+xml"!==qt||!Ft[e.namespaceURI]))},nn=function(e){g(o.removed,{element:e});try{_e(e).removeChild(e)}catch(t){if(Ee(e),!_e(e))throw k("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},on=function(e){ln(e);const t=Ne(e);if(t){const e=[];m(t,t=>{g(e,t)}),m(e,e=>{try{Ee(e)}catch(e){}})}const n=Oe(e);if(n)for(let t=n.length-1;t>=0;--t){const o=n[t],r=o&&o.name;if("string"==typeof r)try{e.removeAttribute(r)}catch(e){}}},rn=function(e,t){try{g(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){g(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Tt||St)try{nn(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},an=function(e){const t=Oe(e);if(t)for(let n=t.length-1;n>=0;--n){const o=t[n],r=o&&o.name;if("string"==typeof r&&!nt[$t(r)])try{e.removeAttribute(r)}catch(e){}}},ln=function(e){const t=[e];for(;t.length>0;){const e=t.pop();(ve?ve(e):e.nodeType)===ue&&an(e);const n=Ne(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},cn=function(e){let t=null,n=null;if(bt)e="<remove></remove>"+e;else{const t=E(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===qt&&Pt===zt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const o=Ce?ze(e):e;if(Pt===zt)try{t=(new z).parseFromString(o,qt)}catch(e){}if(!t||!t.documentElement){t=Fe.createDocument(Pt,"template",null);try{t.documentElement.innerHTML=Ut?ke:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),Pt===zt?Be.call(t,dt?"html":"body")[0]:dt?t.documentElement:i},sn=function(e){const t=Re?Re(e):e.ownerDocument;return He.call(t||e,e,x.SHOW_ELEMENT|x.SHOW_COMMENT|x.SHOW_TEXT|x.SHOW_PROCESSING_INSTRUCTION|x.SHOW_CDATA_SECTION,null)},un=function(e){return e=A(e,Ye," "),e=A(e,qe," "),e=A(e,Xe," ")},fn=function(e){var t;e.normalize();const n=Re?Re(e):e.ownerDocument,o=He.call(n||e,e,x.SHOW_TEXT|x.SHOW_COMMENT|x.SHOW_CDATA_SECTION|x.SHOW_PROCESSING_INSTRUCTION,null);let r=o.nextNode();for(;r;)r.data=un(r.data),r=o.nextNode();const i=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");i&&m(i,e=>{mn(e.content)&&fn(e.content)})},pn=function(e){const t=De?De(e):null;return"string"==typeof t&&("form"===$t(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==Oe(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==ve(e)||e.childNodes!==Ne(e)))},mn=function(e){if(!ve||"object"!=typeof e||null===e)return!1;try{return ve(e)===he}catch(e){return!1}},dn=function(e){if(!ve||"object"!=typeof e||null===e)return!1;try{return"number"==typeof ve(e)}catch(e){return!1}};function hn(e,t,n){0!==e.length&&m(e,e=>{e.call(o,t,n,Kt)})}const gn=function(e,t,n,o){return 0===e.length?t:t===n||t===o?P(t):t},yn=function(e,t){if(hn(We.beforeSanitizeElements,e,null),e!==t&&null===_e(e))return Ot&&ln(e),!0;if(pn(e))return nn(e),!0;const n=$t(De?De(e):e.nodeName);if(et=gn(We.uponSanitizeElement,et,tt,gt),hn(We.uponSanitizeElement,e,{tagName:n,allowedTags:et}),e!==t&&null===_e(e))return Ot&&ln(e),!0;if(function(e,t){return!!(mt&&e.hasChildNodes()&&!dn(e.firstElementChild)&&I(ae,e.textContent)&&I(ae,e.innerHTML))||!(!mt||e.namespaceURI!==zt||"style"!==t||!dn(e.firstElementChild))||e.nodeType===pe||!(!mt||e.nodeType!==me||!I(le,e.data))}(e,n))return nn(e),!0;if(it[n]||!(lt.tagCheck instanceof Function&&lt.tagCheck(n))&&!et[n]){const o=function(e,t,n){if(!it[t]&&Sn(t)){if(rt.tagNameCheck instanceof RegExp&&I(rt.tagNameCheck,t))return!1;if(rt.tagNameCheck instanceof Function&&rt.tagNameCheck(t))return!1}if(wt&&!Dt[t]){const t=_e(e),o=Ne(e);if(o&&t)for(let r=o.length-1;r>=0;--r){const i=e===n?Se(o[r],!0):o[r];t.insertBefore(i,Ae(e))}}return nn(e),!0}(e,n,t);return!1===o&&hn(We.afterSanitizeElements,e,null),o}if((ve?ve(e):e.nodeType)===ue&&!tn(e))return nn(e),!0;if(("noscript"===n||"noembed"===n||"noframes"===n)&&I(ce,e.innerHTML))return nn(e),!0;if(pt&&e.nodeType===fe){const t=un(e.textContent);e.textContent!==t&&(g(o.removed,{element:e.cloneNode()}),e.textContent=t)}return hn(We.afterSanitizeElements,e,null),!1},bn=function(e,t,n){if(at[t])return!1;if(mt&&"patchsrc"===t)return!1;if(mt&&"for"===t&&"label"!==e&&"output"!==e)return!1;if(At&&("id"===t||"name"===t)&&(n in r||n in Vt))return!1;const o=nt[t]||lt.attributeCheck instanceof Function&&lt.attributeCheck(t,e);if(st&&I($e,t));else if(ct&&I(Ke,t));else if(o)if(kt[t]);else if(I(Qe,A(n,Ze,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==N(n,"data:")||!Ct[e]){if(ut&&!I(Ve,A(n,Ze,"")));else if(n)return!1}else;else if(!(Sn(e)&&(rt.tagNameCheck instanceof RegExp&&I(rt.tagNameCheck,e)||rt.tagNameCheck instanceof Function&&rt.tagNameCheck(e))&&(rt.attributeNameCheck instanceof RegExp&&I(rt.attributeNameCheck,t)||rt.attributeNameCheck instanceof Function&&rt.attributeNameCheck(t,e))||"is"===t&&rt.allowCustomizedBuiltInElements&&(rt.tagNameCheck instanceof RegExp&&I(rt.tagNameCheck,n)||rt.tagNameCheck instanceof Function&&rt.tagNameCheck(n))))return!1;return!0},Tn=M({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Sn=function(e){return!Tn[T(e)]&&I(Je,e)},En=function(e,t,n,o){if(Ce&&"object"==typeof be&&"function"==typeof be.getAttributeType&&!n)switch(be.getAttributeType(e,t)){case"TrustedHTML":return ze(o);case"TrustedScriptURL":return function(e){Me(),Le++;try{return Ce.createScriptURL(e)}finally{Le--}}(o)}return o},An=function(e,t,n,r){try{n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),pn(e)?nn(e):h(o.removed)}catch(n){rn(t,e)}},Nn=function(e){hn(We.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||pn(e))return;nt=gn(We.uponSanitizeAttribute,nt,ot,yt);const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:nt,forceKeepAttr:void 0};let o=t.length;const r=$t(e.nodeName);for(;o--;){const i=t[o],a=i.name,l=i.namespaceURI,c=i.value,s=$t(a),u=c;let f="value"===a?u:_(u);n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,hn(We.uponSanitizeAttribute,e,n),f=n.attrValue,!Nt||"id"!==s&&"name"!==s||0===N(f,_t)||(rn(a,e),f=_t+f),mt&&I(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)?rn(a,e):"attributename"===s&&E(f,"href")?rn(a,e):n.forceKeepAttr||(n.keepAttr&&(ft||!I(se,f))?(pt&&(f=un(f)),bn(r,s,f)?(f=En(r,s,l,f),f!==u&&An(e,a,l,f)):rn(a,e)):rn(a,e))}hn(We.afterSanitizeAttributes,e,null)},_n=function(e){let t=null;const n=sn(e);for(hn(We.beforeSanitizeShadowDOM,e,null);t=n.nextNode();){hn(We.uponSanitizeShadowNode,t,null),yn(t,e),Nn(t),mn(t.content)&&_n(t.content);if((ve?ve(t):t.nodeType)===ue){const e=we(t);mn(e)&&(wn(e),_n(e))}}hn(We.afterSanitizeShadowDOM,e,null)},wn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){_n(e.shadow);continue}const n=e.node,o=(ve?ve(n):n.nodeType)===ue,r=Ne(n);if(r)for(let e=r.length-1;e>=0;--e)t.push({node:r[e],shadow:null});if(o){const e=De?De(n):null;if("string"==typeof e&&"template"===$t(e)){const e=n.content;mn(e)&&t.push({node:e,shadow:null})}}if(o){const e=we(n);mn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,a=null,l=null;if(Ut=!e,Ut&&(e="\x3c!--\x3e"),"string"!=typeof e&&!dn(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return w(e);case"boolean":return O(e);case"bigint":return v?v(e):"0";case"symbol":return D?D(e):"Symbol()";case"undefined":default:return C(e);case"function":case"object":{if(null===e)return C(e);const t=e,n=U(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:C(e)}return C(e)}}}(e)))throw k("dirty is not a string, aborting");if(!o.isSupported)return e;ht?(et=gt,nt=yt):Jt(t),(We.uponSanitizeElement.length>0||We.uponSanitizeAttribute.length>0)&&(et=P(et)),We.uponSanitizeAttribute.length>0&&(nt=P(nt)),o.removed=[];const c=Ot&&"string"!=typeof e&&dn(e);if(c){!function(e){if(!mt)return;const t=[e];for(;t.length>0;){const e=t.pop(),n=ve?ve(e):e.nodeType;if(n===pe||n===me&&I(le,e.data)){try{Ee(e)}catch(e){}continue}if(n===ue){const t=e,n=$t(De?De(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute("patchsrc")&&t.removeAttribute("patchsrc"),t.hasAttribute&&t.hasAttribute("for")&&"label"!==n&&"output"!==n&&t.removeAttribute("for")}catch(e){}}const o=Ne(e);if(o)for(let e=o.length-1;e>=0;--e)t.push(o[e])}}(e);const t=De?De(e):e.nodeName;if("string"==typeof t){const n=$t(t);if(!et[n]||it[n])throw on(e),k("root node is forbidden and cannot be sanitized in-place")}if(pn(e))throw on(e),k("root node is clobbered and cannot be sanitized in-place");try{wn(e)}catch(t){throw on(e),t}}else if(dn(e))n=cn("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),r.nodeType===ue&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r),wn(r);else{if(!Tt&&!pt&&!dt&&-1===e.indexOf("<"))return Ce&&Et?ze(e):e;if(n=cn(e),!n)return Tt?null:Et?ke:""}n&&bt&&nn(n.firstChild);const s=c?e:n;try{const e=sn(s);for(;a=e.nextNode();)yn(a,s),Nn(a),mn(a.content)&&_n(a.content)}catch(t){throw c&&(on(e),m(o.removed,e=>{e.element&&ln(e.element)})),t}if(c)return m(o.removed,e=>{e.element&&ln(e.element)}),pt&&fn(e),e;if(Tt){if(pt&&fn(n),St)for(l=je.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(nt.shadowroot||nt.shadowrootmode)&&(l=Ge.call(i,l,!0)),l}let u=dt?n.outerHTML:n.innerHTML;return dt&&et["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&I(re,n.ownerDocument.doctype.name)&&(u="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+u),pt&&(u=un(u)),Ce&&Et?ze(u):u},o.setConfig=function(){Jt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ht=!0,gt=et,yt=nt},o.clearConfig=function(){Kt=null,ht=!1,gt=null,yt=null,Ce=Ie,ke=""},o.isValidAttribute=function(e,t,n){Kt||Jt({});const o=$t(e),r=$t(t);return bn(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&R(We,e)&&g(We[e],t)},o.removeHook=function(e,t){if(R(We,e)){if(void 0!==t){const n=d(We[e],t);return-1===n?void 0:y(We[e],n,1)[0]}return h(We[e])}},o.removeHooks=function(e){R(We,e)&&(We[e]=[])},o.removeAllHooks=function(){We={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},o}();export{be as default};
@@ -1 +1 @@
1
- import{V as e,d as i}from"./main.js";import{b as r}from"./index-CyNtT_1q-Dgus2xdV.js";function t(t,o){if(!t.verificationMethod)return void console.warn("No verification method found in the issuer document. This will likely become a requirement in the near future");const n=o.split("#")[1],a=t.verificationMethod.find(e=>e.id===`#${n}`||e.id===o);if(!a)throw new e("retrieveVerificationMethodPublicKey",`${r} - ${i.i18n.getText("errors","retrieveVerificationMethodPublicKey")}`);return{...a}}export{t as r};
1
+ import{V as e,d as i}from"./main.js";import{b as r}from"./index-KzSDgEl9-Dgus2xdV.js";function t(t,o){if(!t.verificationMethod)return void console.warn("No verification method found in the issuer document. This will likely become a requirement in the near future");const n=o.split("#")[1],a=t.verificationMethod.find(e=>e.id===`#${n}`||e.id===o);if(!a)throw new e("retrieveVerificationMethodPublicKey",`${r} - ${i.i18n.getText("errors","retrieveVerificationMethodPublicKey")}`);return{...a}}export{t as r};
@@ -0,0 +1 @@
1
+ import{H as r,I as t}from"./main.js";async function e(e){if(!e.proof)return void console.warn("No proof found in the issuer profile.");let o=e.proof.type;"DataIntegrityProof"===o&&(o=r(e.proof.cryptosuite));const a=await async function(r){if(r===t.MerkleProof2019){const{default:r}=await import("./MerkleProof2019-DJbo7uW--CHlhsnHk.js");return r}if(r===t.Ed25519Signature2020){const{default:r}=await import("./Ed25519Signature2020-D2tdrIA4-PSi5TCQH.js");return r}if(r===t.EcdsaSecp256k1Signature2019){const{default:r}=await import("./EcdsaSecp256k1Signature2019-BRdQnZ0o-D_QN8KrS.js");return r}if(r===t.EcdsaSd2023){const{default:r}=await import("./EcdsaSd2023-D2eJBmaY-mHNjbn8h.js");return r}}(o),i=new a({document:e,proof:e.proof,issuer:e.issuer?e.issuer:e,executeStep:async(r,t,e)=>t()});await i.init();try{await i.verifyProof()}catch(r){throw new Error(`Issuer profile verification failed: ${r.message}`)}}export{e as default};
@@ -0,0 +1,40 @@
1
+ import{B as e,J as t}from"./main.js";import{c as r}from"./_polyfill-node.crypto-MVmI5M_M-exGcp6nW.js";var n,s={};var i=function(){if(n)return s;n=1;class t{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,r){const n=t.toUint8Array(e),s=t.toUint8Array(r);if(n.length!==s.byteLength)return!1;for(let e=0;e<n.length;e++)if(n[e]!==s[e])return!1;return!0}static concat(...e){let t;t=!Array.isArray(e[0])||e[1]instanceof Function?Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e:e[0];let r=0;for(const e of t)r+=e.byteLength;const n=new Uint8Array(r);let s=0;for(const e of t){const t=this.toUint8Array(e);n.set(t,s),s+=t.length}return e[e.length-1]instanceof Function?this.toView(n,e[e.length-1]):n.buffer}}const r="string",i=/^[0-9a-f\s]+$/i,o=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;class c{static fromString(e){const t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer}static toString(e){const r=t.toUint8Array(e);let n="";for(let e=0;e<r.length;e++)n+=String.fromCharCode(r[e]);return decodeURIComponent(escape(n))}}class u{static toString(e,r=!1){const n=t.toArrayBuffer(e),s=new DataView(n);let i="";for(let e=0;e<n.byteLength;e+=2){const t=s.getUint16(e,r);i+=String.fromCharCode(t)}return i}static fromString(e,t=!1){const r=new ArrayBuffer(2*e.length),n=new DataView(r);for(let r=0;r<e.length;r++)n.setUint16(2*r,e.charCodeAt(r),t);return r}}class l{static isHex(e){return typeof e===r&&i.test(e)}static isBase64(e){return typeof e===r&&o.test(e)}static isBase64Url(e){return typeof e===r&&a.test(e)}static ToString(e,r="utf8"){const n=t.toUint8Array(e);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return u.toString(n,!0);case"utf16":case"utf16be":return u.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return u.fromString(e,!0);case"utf16":case"utf16be":return u.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(r){const n=t.toUint8Array(r);if("undefined"!=typeof btoa){const e=this.ToString(n,"binary");return btoa(e)}return e.from(n).toString("base64")}static FromBase64(t){const r=this.formatString(t);if(!r)return new ArrayBuffer(0);if(!l.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?this.FromBinary(atob(r)):new Uint8Array(e.from(r,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!l.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=l.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return c.fromString(e);case"utf16":case"utf16be":return u.fromString(e);case"utf16le":case"usc2":return u.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=l.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return c.toString(e);case"utf16":case"utf16be":return u.toString(e);case"utf16le":case"usc2":return u.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return r.buffer}static ToBinary(e){const r=t.toUint8Array(e);let n="";for(let e=0;e<r.length;e++)n+=String.fromCharCode(r[e]);return n}static ToHex(e){const r=t.toUint8Array(e);let n="";const s=r.length;for(let e=0;e<s;e++){const t=r[e];t<16&&(n+="0"),n+=t.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!l.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2){const n=t.slice(e,e+2);r[e/2]=parseInt(n,16)}return r.buffer}static ToUtf16String(e,t=!1){return u.toString(e,t)}static FromUtf16String(e,t=!1){return u.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return(null==e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}return l.DEFAULT_UTF8_ENCODING="utf8",s.BufferSourceConverter=t,s.Convert=l,s.assign=function(e,...t){const r=arguments[0];for(let e=1;e<arguments.length;e++){const t=arguments[e];for(const e in t)r[e]=t[e]}return r},s.combine=function(...e){const t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(t);let n=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(const t of e)r[n++]=t}),r.buffer},s.isEqual=function(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==n[t])return!1;return!0},s}();
2
+ /*!
3
+ Copyright (c) Peculiar Ventures, LLC
4
+ */function o(e,t){let r=0;if(1===e.length)return e[0];for(let n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}function a(e,t,r=-1){const n=r;let s=e,i=0,o=Math.pow(2,t);for(let r=1;r<8;r++){if(e<o){let e;if(n<0)e=new ArrayBuffer(r),i=r;else{if(n<r)return new ArrayBuffer(0);e=new ArrayBuffer(n),i=n}const o=new Uint8Array(e);for(let e=r-1;e>=0;e--){const r=Math.pow(2,e*t);o[i-e-1]=Math.floor(s/r),s-=o[i-e-1]*r}return e}o*=Math.pow(2,t)}return new ArrayBuffer(0)}function c(...e){let t=0,r=0;for(const r of e)t+=r.length;const n=new ArrayBuffer(t),s=new Uint8Array(n);for(const t of e)s.set(t,r),r+=t.length;return s}function u(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&!(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)r[e]=0;r[0]=128&e[0];const n=o(r,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let t=0;t<this.valueHex.byteLength;t++)i[t]=e[t];i[0]&=127;return o(i,8)-n}function l(e,t){const r=e.toString(10);if(t<r.length)return"";const n=t-r.length,s=new Array(n);for(let e=0;e<n;e++)s[e]="0";return s.join("").concat(r)}
5
+ /*!
6
+ * Copyright (c) 2014, GMO GlobalSign
7
+ * Copyright (c) 2015-2022, Peculiar Ventures
8
+ * All rights reserved.
9
+ *
10
+ * Author 2014-2019, Yury Strozhevsky
11
+ *
12
+ * Redistribution and use in source and binary forms, with or without modification,
13
+ * are permitted provided that the following conditions are met:
14
+ *
15
+ * * Redistributions of source code must retain the above copyright notice, this
16
+ * list of conditions and the following disclaimer.
17
+ *
18
+ * * Redistributions in binary form must reproduce the above copyright notice, this
19
+ * list of conditions and the following disclaimer in the documentation and/or
20
+ * other materials provided with the distribution.
21
+ *
22
+ * * Neither the name of the copyright holder nor the names of its
23
+ * contributors may be used to endorse or promote products derived from
24
+ * this software without specific prior written permission.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
30
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
33
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+ *
37
+ */function h(){if("undefined"==typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function y(e){let t=0,r=0;for(let r=0;r<e.length;r++){t+=e[r].byteLength}const n=new Uint8Array(t);for(let t=0;t<e.length;t++){const s=e[t];n.set(new Uint8Array(s),r),r+=s.byteLength}return n.buffer}function f(e,t,r,n){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):n<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-n<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class p{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return y(this.items)}}const g=[new Uint8Array([1])],m="0123456789",d="name",w="valueHexView",v="",A=new ArrayBuffer(0),b=new Uint8Array(0),k="EndOfContent",S="OCTET STRING",B="BIT STRING";function E(e){var t;return(t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){var t;super(...e);const r=e[0]||{};this.isHexOnly=null!==(t=r.isHexOnly)&&void 0!==t&&t,this.valueHexView=r.valueHex?i.BufferSourceConverter.toUint8Array(r.valueHex):b}fromBER(e,t,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!f(this,n,t,r))return-1;const s=t+r;return this.valueHexView=n.subarray(t,s),this.valueHexView.length?(this.blockLength=r,s):(this.warnings.push("Zero buffer length"),t)}toBER(e=!1){return this.isHexOnly?e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",A)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:i.Convert.ToHex(this.valueHexView)}}}).NAME="hexBlock",t}class K{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t="",warnings:r=[],valueBeforeDecode:n=b}={}){this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=i.BufferSourceConverter.toUint8Array(n)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:i.Convert.ToHex(this.valueBeforeDecodeView)}}}K.NAME="baseBlock";class C extends K{fromBER(e,t,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}C.NAME="valueBlock";class x extends(E(K)){constructor({idBlock:e={}}={}){var t,r,n,s;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?i.BufferSourceConverter.toUint8Array(e.valueHex):b,this.tagClass=null!==(r=e.tagClass)&&void 0!==r?r:-1,this.tagNumber=null!==(n=e.tagNumber)&&void 0!==n?n:-1,this.isConstructed=null!==(s=e.isConstructed)&&void 0!==s&&s):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",A}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,r[0]=t}return r.buffer}if(!this.isHexOnly){const r=a(this.tagNumber,7),n=new Uint8Array(r),s=r.byteLength,i=new Uint8Array(s+1);if(i[0]=31|t,!e){for(let e=0;e<s-1;e++)i[e+1]=128|n[e];i[s]=n[s-1]}return i.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)r[t+1]=128|e[t];r[this.valueHexView.byteLength]=e[e.length-1]}return r.buffer}fromBER(e,t,r){const n=i.BufferSourceConverter.toUint8Array(e);if(!f(this,n,t,r))return-1;const s=n.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;switch(192&s[0]){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=!(32&~s[0]),this.isHexOnly=!1;const a=31&s[0];if(31!==a)this.tagNumber=a,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),r=255;for(;128&s[e];){if(t[e-1]=127&s[e],e++,e>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r<t.length;r++)e[r]=t[r];t=this.valueHexView=new Uint8Array(r)}}this.blockLength=e+1,t[e-1]=127&s[e];const n=new Uint8Array(e);for(let r=0;r<e;r++)n[r]=t[r];t=this.valueHexView=new Uint8Array(e),t.set(n),this.blockLength<=9?this.tagNumber=o(t,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}x.NAME="identificationBlock";class N extends K{constructor({lenBlock:e={}}={}){var t,r,n;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(r=e.longFormUsed)&&void 0!==r&&r,this.length=null!==(n=e.length)&&void 0!==n?n:0}fromBER(e,t,r){const n=i.BufferSourceConverter.toUint8Array(e);if(!f(this,n,t,r))return-1;const s=n.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;if(255===s[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===s[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&s[0]),!1===this.longFormUsed)return this.length=s[0],this.blockLength=1,t+this.blockLength;const a=127&s[0];if(a>8)return this.error="Too big integer",-1;if(a+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,u=n.subarray(c,c+a);return 0===u[a-1]&&this.warnings.push("Needlessly long encoded length"),this.length=o(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=a+1,t+this.blockLength}toBER(e=!1){let t,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=128),t;if(this.longFormUsed){const n=a(this.length,8);if(n.byteLength>127)return this.error="Too big length",A;if(t=new ArrayBuffer(n.byteLength+1),e)return t;const s=new Uint8Array(n);r=new Uint8Array(t),r[0]=128|n.byteLength;for(let e=0;e<n.byteLength;e++)r[e+1]=s[e];return t}return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}N.NAME="lengthBlock";const U={};class P extends K{constructor({name:e="",optional:t=!1,primitiveSchema:r,...n}={},s){super(n),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new x(n),this.lenBlock=new N(n),this.valueBlock=s?new s(n):new C(n)}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}toBER(e,t){const r=t||new p;t||I(this);const n=this.idBlock.toBER(e);if(r.write(n),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const n=this.lenBlock.toBER(e);r.write(n),r.write(t)}return t?A:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return"ascii"===e?this.onAsciiEncoding():i.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;return function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let e=0;e<r.length;e++)if(r[e]!==n[e])return!1;return!0}(this.toBER(),e.toBER())}}function I(e){var t;if(e instanceof U.Constructed)for(const t of e.valueBlock.value)I(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!(null===(t=e.lenBlock)||void 0===t?void 0:t.isIndefiniteForm)}P.NAME="BaseBlock";class O extends P{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e="",...t}={},r){super(t,r),e&&this.fromString(e)}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}O.NAME="BaseStringBlock";class H extends(E(C)){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}var T,L,D,V,R,M;H.NAME="PrimitiveValueBlock";class $ extends P{constructor(e={}){super(e,H),this.idBlock.isConstructed=!1}}function J(e,t=0,r=e.length){const n=t;let s=new P({},C);const i=new K;if(!f(i,e,t,r))return s.error=i.error,{offset:-1,result:s};if(!e.subarray(t,t+r).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(e,t,r);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),-1===o)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=o,r-=s.idBlock.blockLength,o=s.lenBlock.fromBER(e,t,r),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),-1===o)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=o,r-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let a=P;if(1===s.idBlock.tagClass){if(s.idBlock.tagNumber>=37&&!1===s.idBlock.isHexOnly)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};a=U.EndOfContent;break;case 1:a=U.Boolean;break;case 2:a=U.Integer;break;case 3:a=U.BitString;break;case 4:a=U.OctetString;break;case 5:a=U.Null;break;case 6:a=U.ObjectIdentifier;break;case 10:a=U.Enumerated;break;case 12:a=U.Utf8String;break;case 13:a=U.RelativeObjectIdentifier;break;case 14:a=U.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:a=U.Sequence;break;case 17:a=U.Set;break;case 18:a=U.NumericString;break;case 19:a=U.PrintableString;break;case 20:a=U.TeletexString;break;case 21:a=U.VideotexString;break;case 22:a=U.IA5String;break;case 23:a=U.UTCTime;break;case 24:a=U.GeneralizedTime;break;case 25:a=U.GraphicString;break;case 26:a=U.VisibleString;break;case 27:a=U.GeneralString;break;case 28:a=U.UniversalString;break;case 29:a=U.CharacterString;break;case 30:a=U.BmpString;break;case 31:a=U.DATE;break;case 32:a=U.TimeOfDay;break;case 33:a=U.DateTime;break;case 34:a=U.Duration;break;default:{const e=s.idBlock.isConstructed?new U.Constructed:new U.Primitive;e.idBlock=s.idBlock,e.lenBlock=s.lenBlock,e.warnings=s.warnings,s=e}}}else a=s.idBlock.isConstructed?U.Constructed:U.Primitive;return s=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(s,a),o=s.fromBER(e,t,s.lenBlock.isIndefiniteForm?r:s.lenBlock.length),s.valueBeforeDecodeView=e.subarray(n,n+s.blockLength),{offset:o,result:s}}function j(e){if(!e.byteLength){const e=new P({},C);return e.error="Input buffer has zero length",{offset:-1,result:e}}return J(i.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength)}function z(e,t){return e?1:t}T=$,U.Primitive=T,$.NAME="PRIMITIVE";class F extends C{constructor({value:e=[],isIndefiniteForm:t=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const n=i.BufferSourceConverter.toUint8Array(e);if(!f(this,n,t,r))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let s=t;for(;z(this.isIndefiniteForm,r)>0;){const e=J(n,s,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===k)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===k?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const r=t||new p;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,r);return t?A:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}F.NAME="ConstructedValueBlock";class G extends P{constructor(e={}){super(e,F),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){const e=[];for(const t of this.valueBlock.value)e.push(t.toString("ascii").split("\n").map(e=>` ${e}`).join("\n"));const t=3===this.idBlock.tagClass?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join("\n")}`:`${t} :`}}L=G,U.Constructed=L,G.NAME="CONSTRUCTED";class _ extends C{fromBER(e,t,r){return t}toBER(e){return A}}_.override="EndOfContentValueBlock";class q extends P{constructor(e={}){super(e,_),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}D=q,U.EndOfContent=D,q.NAME=k;class W extends P{constructor(e={}){super(e,C),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}V=W,U.Null=V,W.NAME="NULL";class Y extends(E(C)){get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=i.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,r){const n=i.BufferSourceConverter.toUint8Array(e);return f(this,n,t,r)?(this.valueHexView=n.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,u.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Y.NAME="BooleanValueBlock";class X extends P{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,Y),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}R=X,U.Boolean=R,X.NAME="BOOLEAN";class Z extends(E(F)){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,r){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=F.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===k){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==S)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,n=super.fromBER(e,t,r),this.blockLength=r;return n}toBER(e,t){return this.isConstructed?F.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Z.NAME="OctetStringValueBlock";let Q=class extends P{constructor({idBlock:e={},lenBlock:t={},...r}={}){var n,s;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(s=r.value)||void 0===s?void 0:s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},Z),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const n=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(n.byteLength){const e=J(n,0,n.byteLength);-1!==e.offset&&e.offset===r&&(this.valueBlock.value=[e.result])}}catch{}}return super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return G.prototype.onAsciiEncoding.call(this);return`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof M&&e.push(t.valueBlock.valueHexView);return i.BufferSourceConverter.concat(e)}};M=Q,U.OctetString=M,Q.NAME=S;class ee extends(E(F)){constructor({unusedBits:e=0,isConstructed:t=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;let n=-1;if(this.isConstructed){if(n=F.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(const e of this.value){const t=e.constructor.NAME;if(t===k){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==B)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const r=e.valueBlock;if(this.unusedBits>0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return n}const s=i.BufferSourceConverter.toUint8Array(e);if(!f(this,s,t,r))return-1;const o=s.subarray(t,t+r);if(this.unusedBits=o[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=o.subarray(1);try{if(e.byteLength){const t=J(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch{}}return this.valueHexView=o.subarray(1),this.blockLength=o.length,t+r}toBER(e,t){if(this.isConstructed)return F.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return A;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}var te;ee.NAME="BitStringValueBlock";let re=class extends P{constructor({idBlock:e={},lenBlock:t={},...r}={}){var n,s;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(s=r.value)||void 0===s?void 0:s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return G.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};var ne,se,ie,oe;function ae(e,t){const r=new Uint8Array([0]),n=new Uint8Array(e),s=new Uint8Array(t);let i=n.slice(0);const o=i.length-1,a=s.slice(0),u=a.length-1;let l=0;let h=0;for(let e=u<o?o:u;e>=0;e--,h++){if(!0==h<a.length)l=i[o-h]+a[u-h]+r[0];else l=i[o-h]+r[0];if(r[0]=l/10,!0==h>=i.length)i=c(new Uint8Array([l%10]),i);else i[o-h]=l%10}return r[0]>0&&(i=c(r,i)),i}function ce(e){if(e>=g.length)for(let t=g.length;t<=e;t++){const e=new Uint8Array([0]);let r=g[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const n=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=n[0]/10,r[t]=n[0]%10}e[0]>0&&(r=c(e,r)),g.push(r)}return g[e]}function ue(e,t){let r=0;const n=new Uint8Array(e),s=new Uint8Array(t),i=n.slice(0),o=i.length-1,a=s.slice(0),c=a.length-1;let u,l=0;for(let e=c;e>=0;e--,l++)if(u=i[o-l]-a[c-l]-r,!0==u<0)r=1,i[o-l]=u+10;else r=0,i[o-l]=u;if(r>0)for(let e=o-c+1;e>=0;e--,l++){if(u=i[o-l]-r,!(u<0)){r=0,i[o-l]=u;break}r=1,i[o-l]=u+10}return i.slice()}te=re,U.BitString=te,re.NAME=B;class le extends(E(C)){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=u.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let n=1;n<8;n++){if(t<=r){if(e<0){const e=a(r-t,8,n);return new Uint8Array(e)[0]|=128,e}let s=a(t,8,n),i=new Uint8Array(s);if(128&i[0]){const e=s.slice(0),t=new Uint8Array(e);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let r=0;r<e.byteLength;r++)i[r+1]=t[r];i[0]=0}return s}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r,n=0){const s=this.fromBER(e,t,r);if(-1===s)return s;const i=this.valueHexView;return 0===i[0]&&128&i[1]?this.valueHexView=i.subarray(1):0!==n&&i.length<n&&(n-i.length>1&&(n=i.length+1),this.valueHexView=i.subarray(n-i.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case!!(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&!(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const n=super.fromBER(e,t,r);return-1===n||this.setValueHex(),n}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),n=0;const s=this.valueHexView;let i="",o=!1;for(let o=s.byteLength-1;o>=0;o--){t=s[o];for(let s=0;s<8;s++){if(!(1&~t))if(n===e)r=ue(ce(n),r),i="-";else r=ae(r,ce(n));n++,t>>=1}}for(let e=0;e<r.length;e++)r[e]&&(o=!0),o&&(i+=m.charAt(r[e]));return!1===o&&(i+=m.charAt(0)),i}}ne=le,le.NAME="IntegerValueBlock",Object.defineProperty(ne.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class he extends P{constructor(e={}){super(e,le),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return h(),BigInt(this.valueBlock.toString())}static fromBigInt(e){h();const t=BigInt(e),r=new p,n=t.toString(16).replace(/^-/,""),s=new Uint8Array(i.Convert.FromHex(n));if(t<0){const e=new Uint8Array(s.length+(128&s[0]?1:0));e[0]|=128;const n=BigInt(`0x${i.Convert.ToHex(e)}`)+t,o=i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(n.toString(16)));o[0]|=128,r.write(o)}else 128&s[0]&&r.write(new Uint8Array([0])),r.write(s);return new se({valueHex:r.final()})}convertToDER(){const e=new se({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new se({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}se=he,U.Integer=se,he.NAME="INTEGER";class ye extends he{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}ie=ye,U.Enumerated=ie,ye.NAME="ENUMERATED";class fe extends(E(C)){constructor({valueDec:e=-1,isFirstSid:t=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;const n=i.BufferSourceConverter.toUint8Array(e);if(!f(this,n,t,r))return-1;const s=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,128&s[e]);e++);const a=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)a[e]=this.valueHexView[e];return this.valueHexView=a,128&s[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=o(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){h();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const r=new Uint8Array(t.length/7);for(let e=0;e<r.length;e++)r[e]=parseInt(t.slice(7*e,7*e+7),2)+(e+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=a(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",A;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r}toString(){let e="";if(this.isHexOnly)e=i.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}fe.NAME="sidBlock";class pe extends C{constructor({value:e="",...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new fe;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e){const t=[];for(let r=0;r<this.value.length;r++){const n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,A;t.push(n)}return y(t)}fromString(e){this.value=[];let t=0,r=0,n="",s=!1;do{if(r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1,s){const e=this.value[0];let t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:return void(this.value=[])}const r=parseInt(n,10);if(isNaN(r))return;e.valueDec=r+t,s=!1}else{const e=new fe;if(n>Number.MAX_SAFE_INTEGER){h();const t=BigInt(n);e.valueBigInt=t}else if(e.valueDec=parseInt(n,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,s=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e=`${e}.`),t?(n=`{${n}}`,this.value[r].isFirstSid?e=`2.{${n} - 80}`:e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}pe.NAME="ObjectIdentifierValueBlock";let ge=class extends P{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,pe),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};oe=ge,U.ObjectIdentifier=oe,ge.NAME="OBJECT IDENTIFIER";class me extends(E(K)){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,r){if(0===r)return t;const n=i.BufferSourceConverter.toUint8Array(e);if(!f(this,n,t,r))return-1;const s=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,128&s[e]);e++);const a=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)a[e]=this.valueHexView[e];return this.valueHexView=a,128&s[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=o(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=a(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",A;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r.buffer}toString(){let e="";return e=this.isHexOnly?i.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}me.NAME="relativeSidBlock";class de extends C{constructor({value:e="",...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new me;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e,t){const r=[];for(let t=0;t<this.value.length;t++){const n=this.value[t].toBER(e);if(0===n.byteLength)return this.error=this.value[t].error,A;r.push(n)}return y(r)}fromString(e){this.value=[];let t=0,r=0,n="";do{r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1;const s=new me;if(s.valueDec=parseInt(n,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(-1!==r);return!0}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e=`${e}.`),t?(n=`{${n}}`,e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}var we,ve,Ae,be,ke,Se,Be,Ee,Ke,Ce,xe,Ne,Ue,Pe,Ie,Oe,He,Te,Le,De,Ve,Re;de.NAME="RelativeObjectIdentifierValueBlock";class Me extends P{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,de),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}we=Me,U.RelativeObjectIdentifier=we,Me.NAME="RelativeObjectIdentifier";class $e extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}ve=$e,U.Sequence=ve,$e.NAME="SEQUENCE";class Je extends G{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}Ae=Je,U.Set=Ae,Je.NAME="SET";class je extends(E(C)){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=v}toJSON(){return{...super.toJSON(),value:this.value}}}je.NAME="StringValueBlock";class ze extends je{}ze.NAME="SimpleStringValueBlock";class Fe extends O{constructor({...e}={}){super(e,ze)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);this.valueBlock.value=e}}Fe.NAME="SIMPLE STRING";class Ge extends Fe{fromBuffer(e){this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=i.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=i.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf8String(e)),this.valueBlock.value=e}}Ge.NAME="Utf8StringValueBlock";class _e extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}be=_e,U.Utf8String=be,_e.NAME="UTF8String";class qe extends Fe{fromBuffer(e){this.valueBlock.value=i.Convert.ToUtf16String(e),this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf16String(e))}}qe.NAME="BmpStringValueBlock";class We extends qe{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}ke=We,U.BmpString=ke,We.NAME="BMPString";class Ye extends Fe{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t);for(let e=0;e<r.length;e+=4)r[e]=r[e+3],r[e+1]=r[e+2],r[e+2]=0,r[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let n=0;n<t;n++){const t=a(e.charCodeAt(n),8),s=new Uint8Array(t);if(s.length>4)continue;const i=4-s.length;for(let e=s.length-1;e>=0;e--)r[4*n+e+i]=s[e]}this.valueBlock.value=e}}Ye.NAME="UniversalStringValueBlock";class Xe extends Ye{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Se=Xe,U.UniversalString=Se,Xe.NAME="UniversalString";class Ze extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Be=Ze,U.NumericString=Be,Ze.NAME="NumericString";class Qe extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ee=Qe,U.PrintableString=Ee,Qe.NAME="PrintableString";class et extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ke=et,U.TeletexString=Ke,et.NAME="TeletexString";class tt extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ce=tt,U.VideotexString=Ce,tt.NAME="VideotexString";class rt extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}xe=rt,U.IA5String=xe,rt.NAME="IA5String";class nt extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Ne=nt,U.GraphicString=Ne,nt.NAME="GraphicString";class st extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Ue=st,U.VisibleString=Ue,st.NAME="VisibleString";class it extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Pe=it,U.GeneralString=Pe,it.NAME="GeneralString";class ot extends Fe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Ie=ot,U.CharacterString=Ie,ot.NAME="CharacterString";class at extends st{constructor({value:e,valueDate:t,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null===t)return void(this.error="Wrong input string for conversion");const r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e="iso"){if("iso"===e){const e=new Array(7);return e[0]=l(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=l(this.month,2),e[2]=l(this.day,2),e[3]=l(this.hour,2),e[4]=l(this.minute,2),e[5]=l(this.second,2),e[6]="Z",e.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}Oe=at,U.UTCTime=Oe,at.NAME="UTCTime";class ct extends at{constructor(e={}){var t;super(e),null!==(t=this.millisecond)&&void 0!==t||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){const e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t,r=!1,n="",s="",i=0,o=0,a=0;if("Z"===e[e.length-1])n=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(-1!==n.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==n.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=n.indexOf("+"),r="";if(-1===t&&(t=n.indexOf("-"),e=-1),-1!==t){if(r=n.substring(t+1),n=n.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let s=parseInt(r.substring(0,2),10);if(isNaN(s.valueOf()))throw new Error("Wrong input string for conversion");if(o=e*s,4===r.length){if(s=parseInt(r.substring(2,4),10),isNaN(s.valueOf()))throw new Error("Wrong input string for conversion");a=e*s}}}let c=n.indexOf(".");if(-1===c&&(c=n.indexOf(",")),-1!==c){const e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");i=e.valueOf(),s=n.substring(0,c)}else s=n;switch(!0){case 8===s.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===s.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*i;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===s.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===s.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const u=t.exec(s);if(null===u)throw new Error("Wrong input string for conversion");for(let e=1;e<u.length;e++)switch(e){case 1:this.year=parseInt(u[e],10);break;case 2:this.month=parseInt(u[e],10);break;case 3:this.day=parseInt(u[e],10);break;case 4:this.hour=parseInt(u[e],10)+o;break;case 5:this.minute=parseInt(u[e],10)+a;break;case 6:this.second=parseInt(u[e],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){const e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e="iso"){if("iso"===e){const e=[];return e.push(l(this.year,4)),e.push(l(this.month,2)),e.push(l(this.day,2)),e.push(l(this.hour,2)),e.push(l(this.minute,2)),e.push(l(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(l(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}He=ct,U.GeneralizedTime=He,ct.NAME="GeneralizedTime";class ut extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Te=ut,U.DATE=Te,ut.NAME="DATE";class lt extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Le=lt,U.TimeOfDay=Le,lt.NAME="TimeOfDay";class ht extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}De=ht,U.DateTime=De,ht.NAME="DateTime";class yt extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Ve=yt,U.Duration=Ve,yt.NAME="Duration";class ft extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Re=ft,U.TIME=Re,ft.NAME="TIME";class pt{constructor({name:e="",optional:t=!1}={}){this.name=e,this.optional=t}}class gt extends pt{constructor({value:e=[],...t}={}){super(t),this.value=e}}class mt extends pt{constructor({value:e=new pt,local:t=!1,...r}={}){super(r),this.value=e,this.local=t}}function dt(e,t,r){if(r instanceof gt){for(const n of r.value){if(dt(e,t,n).verified)return{verified:!0,result:e}}{const e={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(d)&&(e.name=r.name),e}}if(r instanceof pt)return r.hasOwnProperty(d)&&(e[r.name]=t),{verified:!0,result:e};if(e instanceof Object==!1)return{verified:!1,result:{error:"Wrong root object"}};if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("idBlock"in r==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("fromBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("toBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=r.idBlock.toBER(!1);if(0===n.byteLength)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(-1===r.idBlock.fromBER(n,0,n.byteLength))return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(!1===r.idBlock.hasOwnProperty("tagClass"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("tagNumber"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("isConstructed"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!("isHexOnly"in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(r.idBlock.isHexOnly){if(w in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=r.idBlock.valueHexView,s=t.idBlock.valueHexView;if(n.length!==s.length)return{verified:!1,result:e};for(let t=0;t<n.length;t++)if(n[t]!==s[1])return{verified:!1,result:e}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&(e[r.name]=t)),r instanceof U.Constructed){let n=0,s={verified:!1,result:{error:"Unknown error"}},i=r.valueBlock.value.length;if(i>0&&r.valueBlock.value[0]instanceof mt&&(i=t.valueBlock.value.length),0===i)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){let t=!0;for(let e=0;e<r.valueBlock.value.length;e++)t=t&&(r.valueBlock.value[e].optional||!1);return t?{verified:!0,result:e}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&delete e[r.name]),e.error="Inconsistent object length",{verified:!1,result:e})}for(let o=0;o<i;o++)if(o-n>=t.valueBlock.value.length){if(!1===r.valueBlock.value[o].optional){const t={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&(delete e[r.name],t.name=r.name)),t}}else if(r.valueBlock.value[0]instanceof mt){if(s=dt(e,t.valueBlock.value[o],r.valueBlock.value[0].value),!1===s.verified){if(!r.valueBlock.value[0].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&delete e[r.name]),s;n++}if(d in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let n={};n="local"in r.valueBlock.value[0]&&r.valueBlock.value[0].local?t:e,void 0===n[r.valueBlock.value[0].name]&&(n[r.valueBlock.value[0].name]=[]),n[r.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(s=dt(e,t.valueBlock.value[o-n],r.valueBlock.value[o]),!1===s.verified){if(!r.valueBlock.value[o].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&delete e[r.name]),s;n++}if(!1===s.verified){const t={verified:!1,result:e};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&(delete e[r.name],t.name=r.name)),t}return{verified:!0,result:e}}if(r.primitiveSchema&&w in t.valueBlock){const n=J(t.valueBlock.valueHexView);if(-1===n.offset){const t={verified:!1,result:n.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,v),r.name&&(delete e[r.name],t.name=r.name)),t}return dt(e,n.result,r.primitiveSchema)}return{verified:!0,result:e}}var wt,vt,At=Object.freeze({__proto__:null,Any:pt,BaseBlock:P,BaseStringBlock:O,BitString:re,BmpString:We,Boolean:X,CharacterString:ot,Choice:gt,Constructed:G,DATE:ut,DateTime:ht,Duration:yt,EndOfContent:q,Enumerated:ye,GeneralString:it,GeneralizedTime:ct,GraphicString:nt,HexBlock:E,IA5String:rt,Integer:he,Null:W,NumericString:Ze,ObjectIdentifier:ge,OctetString:Q,Primitive:$,PrintableString:Qe,RawData:class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=i.BufferSourceConverter.toUint8Array(e)}constructor({data:e=b}={}){this.dataView=i.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,r){const n=t+r;return this.dataView=i.BufferSourceConverter.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}},RelativeObjectIdentifier:Me,Repeated:mt,Sequence:$e,Set:Je,TIME:ft,TeletexString:et,TimeOfDay:lt,UTCTime:at,UniversalString:Xe,Utf8String:_e,ValueBlock:C,VideotexString:tt,ViewWriter:p,VisibleString:st,compareSchema:dt,fromBER:j,verifySchema:function(e,t){if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const r=J(i.BufferSourceConverter.toUint8Array(e));return-1===r.offset?{verified:!1,result:r.result}:dt(r.result,r.result,t)}});!function(e){e[e.Sequence=0]="Sequence",e[e.Set=1]="Set",e[e.Choice=2]="Choice"}(wt||(wt={})),function(e){e[e.Any=1]="Any",e[e.Boolean=2]="Boolean",e[e.OctetString=3]="OctetString",e[e.BitString=4]="BitString",e[e.Integer=5]="Integer",e[e.Enumerated=6]="Enumerated",e[e.ObjectIdentifier=7]="ObjectIdentifier",e[e.Utf8String=8]="Utf8String",e[e.BmpString=9]="BmpString",e[e.UniversalString=10]="UniversalString",e[e.NumericString=11]="NumericString",e[e.PrintableString=12]="PrintableString",e[e.TeletexString=13]="TeletexString",e[e.VideotexString=14]="VideotexString",e[e.IA5String=15]="IA5String",e[e.GraphicString=16]="GraphicString",e[e.VisibleString=17]="VisibleString",e[e.GeneralString=18]="GeneralString",e[e.CharacterString=19]="CharacterString",e[e.UTCTime=20]="UTCTime",e[e.GeneralizedTime=21]="GeneralizedTime",e[e.DATE=22]="DATE",e[e.TimeOfDay=23]="TimeOfDay",e[e.DateTime=24]="DateTime",e[e.Duration=25]="Duration",e[e.TIME=26]="TIME",e[e.Null=27]="Null"}(vt||(vt={}));const bt={fromASN:e=>e instanceof W?null:e.valueBeforeDecodeView,toASN:e=>{if(null===e)return new W;const t=j(e);if(t.result.error)throw new Error(t.result.error);return t.result}},kt={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new he({value:+e})},St={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new ye({value:e})},Bt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new re({valueHex:e})},Et={fromASN:e=>e.valueBlock.toString(),toASN:e=>new ge({value:e})},Kt={fromASN:e=>e.valueBlock.value,toASN:e=>new X({value:e})},Ct={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new Q({valueHex:e})};function xt(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}const Nt=xt(_e),Ut=xt(We),Pt=xt(Xe),It=xt(Ze),Ot=xt(Qe),Ht=xt(et),Tt=xt(tt),Lt=xt(rt),Dt=xt(nt),Vt=xt(st),Rt=xt(it),Mt=xt(ot),$t={fromASN:e=>e.toDate(),toASN:e=>new at({valueDate:e})},Jt={fromASN:e=>e.toDate(),toASN:e=>new ct({valueDate:e})},jt={fromASN:()=>null,toASN:()=>new W};function zt(e){switch(e){case vt.Any:return bt;case vt.BitString:return Bt;case vt.BmpString:return Ut;case vt.Boolean:return Kt;case vt.CharacterString:return Mt;case vt.Enumerated:return St;case vt.GeneralString:return Rt;case vt.GeneralizedTime:return Jt;case vt.GraphicString:return Dt;case vt.IA5String:return Lt;case vt.Integer:return kt;case vt.Null:return jt;case vt.NumericString:return It;case vt.ObjectIdentifier:return Et;case vt.OctetString:return Ct;case vt.PrintableString:return Ot;case vt.TeletexString:return Ht;case vt.UTCTime:return $t;case vt.UniversalString:return Pt;case vt.Utf8String:return Nt;case vt.VideotexString:return Tt;case vt.VisibleString:return Vt;default:return null}}function Ft(e){return"function"==typeof e&&e.prototype?!(!e.prototype.toASN||!e.prototype.fromASN)||Ft(e.prototype):!!(e&&"object"==typeof e&&"toASN"in e&&"fromASN"in e)}function Gt(e){var t;if(e){const r=Object.getPrototypeOf(e);return(null===(t=null==r?void 0:r.prototype)||void 0===t?void 0:t.constructor)===Array||Gt(r)}return!1}function _t(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}const qt=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:wt.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,t){const r=this.items.get(e)||this.createDefault(e),n=[];for(const e in r.items){const s=r.items[e],i=t?e:"";let o;if("number"==typeof s.type){const e=vt[s.type],t=At[e];if(!t)throw new Error(`Cannot get ASN1 class by name '${e}'`);o=new t({name:i})}else if(Ft(s.type)){o=(new s.type).toSchema(i)}else if(s.optional){this.get(s.type).type===wt.Choice?o=new pt({name:i}):(o=this.create(s.type,!1),o.name=i)}else o=new pt({name:i});const a=!!s.optional||void 0!==s.defaultValue;if(s.repeated){o.name="";o=new("set"===s.repeated?Je:$e)({name:"",value:[new mt({name:i,value:o})]})}if(null!==s.context&&void 0!==s.context)if(s.implicit)if("number"==typeof s.type||Ft(s.type)){const e=s.repeated?G:$;n.push(new e({name:i,optional:a,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);const e=!!s.repeated;let t=e?o:this.get(s.type,!0).schema;t="valueBlock"in t?t.valueBlock.value:t.value,n.push(new G({name:e?"":i,optional:a,idBlock:{tagClass:3,tagNumber:s.context},value:t}))}else n.push(new G({optional:a,idBlock:{tagClass:3,tagNumber:s.context},value:[o]}));else o.optional=a,n.push(o)}switch(r.type){case wt.Sequence:return new $e({value:n,name:""});case wt.Set:return new Je({value:n,name:""});case wt.Choice:return new gt({value:n,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);if(t){return this.items.get(t)||this.findParentSchema(t)}return null}},Wt=e=>t=>{let r;qt.has(t)?r=qt.get(t):(r=qt.createDefault(t),qt.set(t,r)),Object.assign(r,e)},Yt=e=>(t,r)=>{let n;qt.has(t.constructor)?n=qt.get(t.constructor):(n=qt.createDefault(t.constructor),qt.set(t.constructor,n));const s=Object.assign({},e);if("number"==typeof s.type&&!s.converter){const n=zt(e.type);if(!n)throw new Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);s.converter=n}n.items[r]=s};class Xt extends Error{constructor(){super(...arguments),this.schemas=[]}}class Zt{static parse(e,t){const r=j(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,t)}static fromASN(e,t){var r;try{if(Ft(t)){return(new t).fromASN(e)}const n=qt.get(t);qt.cache(t);let s=n.schema;if(e.constructor===G&&n.type!==wt.Choice){s=new G({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:n.schema.valueBlock.value});for(const t in n.items)delete e[t]}const i=dt({},e,s);if(!i.verified)throw new Xt(`Data does not match to ${t.name} ASN1 schema. ${i.result.error}`);const o=new t;if(Gt(t)){if(!("value"in e.valueBlock)||!Array.isArray(e.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const r=n.itemType;if("number"==typeof r){const n=zt(r);if(!n)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,e=>n.fromASN(e))}return t.from(e.valueBlock.value,e=>this.fromASN(e,r))}for(const e in n.items){const t=i.result[e];if(!t)continue;const s=n.items[e],a=s.type;if("number"==typeof a||Ft(a)){const n=null!==(r=s.converter)&&void 0!==r?r:Ft(a)?new a:null;if(!n)throw new Error("Converter is empty");if(s.repeated)if(s.implicit){const r=new("sequence"===s.repeated?$e:Je);r.valueBlock=t.valueBlock;const i=j(r.toBER(!1));if(-1===i.offset)throw new Error(`Cannot parse the child item. ${i.result.error}`);if(!("value"in i.result.valueBlock)||!Array.isArray(i.result.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const a=i.result.valueBlock.value;o[e]=Array.from(a,e=>n.fromASN(e))}else o[e]=Array.from(t,e=>n.fromASN(e));else{let r=t;if(s.implicit){let e;if(Ft(a))e=(new a).toSchema("");else{const t=vt[a],r=At[t];if(!r)throw new Error(`Cannot get '${t}' class from asn1js module`);e=new r}e.valueBlock=r.valueBlock,r=j(e.toBER(!1)).result}o[e]=n.fromASN(r)}}else if(s.repeated){if(!Array.isArray(t))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");o[e]=Array.from(t,e=>this.fromASN(e,a))}else o[e]=this.fromASN(t,a)}return o}catch(e){throw e instanceof Xt&&e.schemas.push(t.name),e}}}class Qt{static serialize(e){return e instanceof P?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&"object"==typeof e&&Ft(e))return e.toASN();if(!e||"object"!=typeof e)throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,r=qt.get(t);qt.cache(t);let n,s=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if("number"==typeof r.itemType){const n=zt(r.itemType);if(!n)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);s=e.map(e=>n.toASN(e))}else s=e.map(e=>this.toAsnItem({type:r.itemType},"[]",t,e))}else for(const n in r.items){const i=r.items[n],o=e[n];if(void 0===o||i.defaultValue===o||"object"==typeof i.defaultValue&&"object"==typeof o&&_t(this.serialize(i.defaultValue),this.serialize(o)))continue;const a=Qt.toAsnItem(i,n,t,o);if("number"==typeof i.context)if(i.implicit)if(i.repeated||"number"!=typeof i.type&&!Ft(i.type))s.push(new G({optional:i.optional,idBlock:{tagClass:3,tagNumber:i.context},value:a.valueBlock.value}));else{const e={};e.valueHex=a instanceof W?a.valueBeforeDecodeView:a.valueBlock.toBER(),s.push(new $({optional:i.optional,idBlock:{tagClass:3,tagNumber:i.context},...e}))}else s.push(new G({optional:i.optional,idBlock:{tagClass:3,tagNumber:i.context},value:[a]}));else i.repeated?s=s.concat(a):s.push(a)}switch(r.type){case wt.Sequence:n=new $e({value:s});break;case wt.Set:n=new Je({value:s});break;case wt.Choice:if(!s[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);n=s[0]}return n}static toAsnItem(e,t,r,n){let s;if("number"==typeof e.type){const i=e.converter;if(!i)throw new Error(`Property '${t}' doesn't have converter for type ${vt[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(n,e=>i.toASN(e));s=new("sequence"===e.repeated?$e:Je)({value:t})}else s=i.toASN(n)}else if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(n,e=>this.toASN(e));s=new("sequence"===e.repeated?$e:Je)({value:t})}else s=this.toASN(n);return s}}class er{static serialize(e){return Qt.serialize(e)}static parse(e,t){return Zt.parse(e,t)}static toString(e){const t=j(i.BufferSourceConverter.isBufferSource(e)?i.BufferSourceConverter.toArrayBuffer(e):er.serialize(e));if(-1===t.offset)throw new Error(`Cannot decode ASN.1 data. ${t.result.error}`);return t.result.toString()}}function tr(e,t,r,n){var s,i=arguments.length,o=i<3?t:n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(i<3?s(o):i>3?s(t,r,o):s(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}"function"==typeof SuppressedError&&SuppressedError;class rr extends Error{constructor(e,t){super(t?`${e}. See the inner exception for more details.`:e),this.message=e,this.innerError=t}}class nr extends rr{constructor(e,t,r){super(t,r),this.schema=e}}class sr extends nr{constructor(e,t,r){super(e,`JSON doesn't match to '${e.target.name}' schema. ${t}`,r)}}class ir extends rr{}class or extends rr{constructor(e,t,r){super(`Cannot serialize by '${e}' schema. ${t}`,r),this.schemaName=e}}class ar extends sr{constructor(e,t,r={}){super(e,"Some keys doesn't match to schema"),this.keys=t,this.errors=r}}var cr;function ur(e,t){if(!function(e,t){switch(t){case cr.Boolean:return"boolean"==typeof e;case cr.Number:return"number"==typeof e;case cr.String:return"string"==typeof e}return!0}(e,t))throw new TypeError(`Value must be ${cr[t]}`)}function lr(e){return e&&e.prototype?!(!e.prototype.toJSON||!e.prototype.fromJSON)||lr(e.prototype):!!(e&&e.toJSON&&e.fromJSON)}!function(e){e[e.Any=0]="Any",e[e.Boolean=1]="Boolean",e[e.Number=2]="Number",e[e.String=3]="String"}(cr||(cr={}));const hr="default",yr=new class{constructor(){this.items=new Map}has(e){return this.items.has(e)||!!this.findParentSchema(e)}get(e){const t=this.items.get(e)||this.findParentSchema(e);if(!t)throw new Error("Cannot get schema for current target");return t}create(e){const t={names:{}},r=this.findParentSchema(e);if(r){Object.assign(t,r),t.names={};for(const e in r.names)t.names[e]=Object.assign({},r.names[e])}return t.target=e,t}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=e.__proto__;if(t){return this.items.get(t)||this.findParentSchema(t)}return null}};class fr{constructor(e){this.pattern=new RegExp(e)}validate(e){const t=new RegExp(this.pattern.source,this.pattern.flags);if("string"!=typeof e)throw new ir("Incoming value must be string");if(!t.exec(e))throw new ir(`Value doesn't match to pattern '${t.toString()}'`)}}class pr{constructor(e=Number.MIN_VALUE,t=Number.MAX_VALUE){this.min=e,this.max=t}validate(e){if(ur(e,cr.Number),!(this.min<=e&&e<=this.max)){const e=this.min===Number.MIN_VALUE?"MIN":this.min,t=this.max===Number.MAX_VALUE?"MAX":this.max;throw new ir(`Value doesn't match to diapason [${e},${t}]`)}}}class gr{constructor(e=Number.MIN_VALUE,t=Number.MAX_VALUE){this.min=e,this.max=t}validate(e){if(ur(e,cr.Number),!(this.min<e&&e<this.max)){const e=this.min===Number.MIN_VALUE?"MIN":this.min,t=this.max===Number.MAX_VALUE?"MAX":this.max;throw new ir(`Value doesn't match to diapason (${e},${t})`)}}}class mr{constructor(e,t,r){this.length=e,this.minLength=t,this.maxLength=r}validate(e){if(void 0===this.length){if(void 0!==this.minLength&&e.length<this.minLength)throw new ir(`Value length must be more than ${this.minLength}.`);if(void 0!==this.maxLength&&e.length>this.maxLength)throw new ir(`Value length must be less than ${this.maxLength}.`)}else if(e.length!==this.length)throw new ir(`Value length must be exactly ${this.length}.`)}}class dr{constructor(e){this.enumeration=e}validate(e){if(ur(e,cr.String),!this.enumeration.includes(e))throw new ir(`Value must be one of ${this.enumeration.map(e=>`'${e}'`).join(", ")}`)}}class wr{static checkValues(e,t){const r=Array.isArray(e)?e:[e];for(const n of r)for(const r of t.validations)r instanceof mr&&t.repeated?r.validate(e):r.validate(n)}static checkTypes(e,t){if(t.repeated&&!Array.isArray(e))throw new TypeError("Value must be Array");if("number"==typeof t.type){const r=Array.isArray(e)?e:[e];for(const e of r)ur(e,t.type)}}static getSchemaByName(e,t=hr){return{...e.names[hr],...e.names[t]}}}class vr extends wr{static serialize(e,t,r,n){const s=this.toJSON(e,t);return JSON.stringify(s,r,n)}static toJSON(e,t={}){let r,n=t.targetSchema;const s=t.schemaName||hr;if(lr(e))return e.toJSON();if(Array.isArray(e)){r=[];for(const n of e)r.push(this.toJSON(n,t))}else if("object"==typeof e){if(n&&!yr.has(n))throw new rr("Cannot get schema for `targetSchema` param");if(n=n||e.constructor,yr.has(n)){const t=yr.get(n);r={};const i=this.getSchemaByName(t,s);for(const o in i)try{const t=i[o],a=e[o];let c;if(t.optional&&void 0===a||void 0!==t.defaultValue&&a===t.defaultValue)continue;if(!t.optional&&void 0===a)throw new or(n.name,`Property '${o}' is required.`);c="number"==typeof t.type?t.converter?t.repeated?a.map(r=>t.converter.toJSON(r,e)):t.converter.toJSON(a,e):a:t.repeated?a.map(e=>this.toJSON(e,{schemaName:s})):this.toJSON(a,{schemaName:s}),this.checkTypes(c,t),this.checkValues(c,t),r[t.name||o]=c}catch(e){throw e instanceof or?e:new or(t.target.name,`Property '${o}' is wrong. ${e.message}`,e)}}else{r={};for(const t in e)r[t]=this.toJSON(e[t],{schemaName:s})}}else r=e;return r}}class Ar extends wr{static parse(e,t){const r=JSON.parse(e);return this.fromJSON(r,t)}static fromJSON(e,t){const r=t.targetSchema,n=t.schemaName||hr,s=new r;if(lr(s))return s.fromJSON(e);const i=yr.get(r),o=this.getSchemaByName(i,n),a={};t.strictProperty&&!Array.isArray(e)&&Ar.checkStrictProperty(e,o,i);for(const r in o)try{const a=o[r],c=a.name||r,u=e[c];if(void 0===u&&(a.optional||void 0!==a.defaultValue))continue;if(!a.optional&&void 0===u)throw new sr(i,`Property '${c}' is required.`);if(this.checkTypes(u,a),this.checkValues(u,a),"number"==typeof a.type)a.converter?a.repeated?s[r]=u.map(e=>a.converter.fromJSON(e,s)):s[r]=a.converter.fromJSON(u,s):s[r]=u;else{const e={...t,targetSchema:a.type,schemaName:n};a.repeated?s[r]=u.map(t=>this.fromJSON(t,e)):s[r]=this.fromJSON(u,e)}}catch(e){if(e instanceof sr||(e=new sr(i,`Property '${r}' is wrong. ${e.message}`,e)),!t.strictAllKeys)throw e;a[r]=e}const c=Object.keys(a);if(c.length)throw new ar(i,c,a);return s}static checkStrictProperty(e,t,r){const n=Object.keys(e),s=Object.keys(t),i=[];for(const e of n)-1===s.indexOf(e)&&i.push(e);if(i.length)throw new ar(r,i)}}const br=(e={})=>(t,r)=>{const n=`Cannot set type for ${r} property of ${t.constructor.name} schema`;let s;yr.has(t.constructor)?(s=yr.get(t.constructor),s.target!==t.constructor&&(s=yr.create(t.constructor),yr.set(t.constructor,s))):(s=yr.create(t.constructor),yr.set(t.constructor,s));const i={type:cr.Any,validations:[]},o=Object.assign(i,e);if(o.validations=function(e){const t=[];return e.pattern&&t.push(new fr(e.pattern)),e.type!==cr.Number&&e.type!==cr.Any||(void 0===e.minInclusive&&void 0===e.maxInclusive||t.push(new pr(e.minInclusive,e.maxInclusive)),void 0===e.minExclusive&&void 0===e.maxExclusive||t.push(new gr(e.minExclusive,e.maxExclusive)),void 0!==e.enumeration&&t.push(new dr(e.enumeration))),(e.type===cr.String||e.repeated||e.type===cr.Any)&&(void 0===e.length&&void 0===e.minLength&&void 0===e.maxLength||t.push(new mr(e.length,e.minLength,e.maxLength))),t}(o),"number"!=typeof o.type&&!yr.has(o.type)&&!lr(o.type))throw new Error(`${n}. Assigning type doesn't have schema.`);let a;a=Array.isArray(e.schema)?e.schema:[e.schema||hr];for(const e of a){s.names[e]||(s.names[e]={});s.names[e][r]=o}};
38
+ /*!
39
+ Copyright (c) Peculiar Ventures, LLC
40
+ */class kr extends Error{}class Sr extends kr{}class Br extends kr{constructor(e){super("Unsupported operation: "+(e?`${e}`:""))}}class Er extends kr{}class Kr extends kr{constructor(e){super(`${e}: Missing required property`)}}class Cr{static toArrayBuffer(e){const t=e.replace(/-{5}(BEGIN|END) .*-{5}/g,"").replace("\r","").replace("\n","");return i.Convert.FromBase64(t)}static toUint8Array(e){const t=this.toArrayBuffer(e);return new Uint8Array(t)}static fromBufferSource(e,t){const r=i.Convert.ToBase64(e);let n,s=0;const o=[];for(;s<r.length&&(n=r.slice(s,s+64),n.length);)o.push(n),s+=64;const a=t.toUpperCase();return`-----BEGIN ${a}-----\n${o.join("\n")}\n-----END ${a}-----`}static isPEM(e){return/-----BEGIN .+-----[A-Za-z0-9+/+=\s\n]+-----END .+-----/i.test(e)}static getTagName(e){if(!this.isPEM(e))throw new Error("Bad parameter. Incoming data is not right PEM");const t=/-----BEGIN (.+)-----/.exec(e);if(!t)throw new Error("Cannot get tag from PEM");return t[1]}static hasTagName(e,t){const r=this.getTagName(e);return t.toLowerCase()===r.toLowerCase()}static isCertificate(e){return this.hasTagName(e,"certificate")}static isCertificateRequest(e){return this.hasTagName(e,"certificate request")}static isCRL(e){return this.hasTagName(e,"x509 crl")}static isPublicKey(e){return this.hasTagName(e,"public key")}}class xr{async digest(...e){return this.checkDigest.apply(this,e),this.onDigest.apply(this,e)}checkDigest(e,t){this.checkAlgorithmName(e)}async onDigest(e,t){throw new Br("digest")}async generateKey(...e){return this.checkGenerateKey.apply(this,e),this.onGenerateKey.apply(this,e)}checkGenerateKey(e,t,r,...n){if(this.checkAlgorithmName(e),this.checkGenerateKeyParams(e),!r||!r.length)throw new TypeError("Usages cannot be empty when creating a key.");let s;s=Array.isArray(this.usages)?this.usages:this.usages.privateKey.concat(this.usages.publicKey),this.checkKeyUsages(r,s)}checkGenerateKeyParams(e){}async onGenerateKey(e,t,r,...n){throw new Br("generateKey")}async sign(...e){return this.checkSign.apply(this,e),this.onSign.apply(this,e)}checkSign(e,t,r,...n){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,"sign")}async onSign(e,t,r,...n){throw new Br("sign")}async verify(...e){return this.checkVerify.apply(this,e),this.onVerify.apply(this,e)}checkVerify(e,t,r,n,...s){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,"verify")}async onVerify(e,t,r,n,...s){throw new Br("verify")}async encrypt(...e){return this.checkEncrypt.apply(this,e),this.onEncrypt.apply(this,e)}checkEncrypt(e,t,r,n={},...s){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,n.keyUsage?"encrypt":void 0)}async onEncrypt(e,t,r,...n){throw new Br("encrypt")}async decrypt(...e){return this.checkDecrypt.apply(this,e),this.onDecrypt.apply(this,e)}checkDecrypt(e,t,r,n={},...s){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,n.keyUsage?"decrypt":void 0)}async onDecrypt(e,t,r,...n){throw new Br("decrypt")}async deriveBits(...e){return this.checkDeriveBits.apply(this,e),this.onDeriveBits.apply(this,e)}checkDeriveBits(e,t,r,n={},...s){if(this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,n.keyUsage?"deriveBits":void 0),r%8!=0)throw new Er("length: Is not multiple of 8")}async onDeriveBits(e,t,r,...n){throw new Br("deriveBits")}async exportKey(...e){return this.checkExportKey.apply(this,e),this.onExportKey.apply(this,e)}checkExportKey(e,t,...r){if(this.checkKeyFormat(e),this.checkCryptoKey(t),!t.extractable)throw new kr("key: Is not extractable")}async onExportKey(e,t,...r){throw new Br("exportKey")}async importKey(...e){return this.checkImportKey.apply(this,e),this.onImportKey.apply(this,e)}checkImportKey(e,t,r,n,s,...i){this.checkKeyFormat(e),this.checkKeyData(e,t),this.checkAlgorithmName(r),this.checkImportParams(r),Array.isArray(this.usages)&&this.checkKeyUsages(s,this.usages)}async onImportKey(e,t,r,n,s,...i){throw new Br("importKey")}checkAlgorithmName(e){if(e.name.toLowerCase()!==this.name.toLowerCase())throw new Sr("Unrecognized name")}checkAlgorithmParams(e){}checkDerivedKeyParams(e){}checkKeyUsages(e,t){for(const r of e)if(-1===t.indexOf(r))throw new TypeError("Cannot create a key using the specified key usages")}checkCryptoKey(e,t){if(this.checkAlgorithmName(e.algorithm),t&&-1===e.usages.indexOf(t))throw new kr("key does not match that of operation")}checkRequiredProperty(e,t){if(!(t in e))throw new Kr(t)}checkHashAlgorithm(e,t){for(const r of t)if(r.toLowerCase()===e.name.toLowerCase())return;throw new Er(`hash: Must be one of ${t.join(", ")}`)}checkImportParams(e){}checkKeyFormat(e){switch(e){case"raw":case"pkcs8":case"spki":case"jwk":break;default:throw new TypeError("format: Is invalid value. Must be 'jwk', 'raw', 'spki', or 'pkcs8'")}}checkKeyData(e,t){if(!t)throw new TypeError("keyData: Cannot be empty on empty on key importing");if("jwk"===e){if("object"!=typeof(r=t)||!("kty"in r))throw new TypeError("keyData: Is not JsonWebToken")}else if(!i.BufferSourceConverter.isBufferSource(t))throw new TypeError("keyData: Is not ArrayBufferView or ArrayBuffer");var r}prepareData(e){return i.BufferSourceConverter.toArrayBuffer(e)}}class Nr extends xr{checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not of type Number");switch(e.length){case 128:case 192:case 256:break;default:throw new TypeError("length: Must be 128, 192, or 256")}}checkDerivedKeyParams(e){this.checkGenerateKeyParams(e)}}let Ur=class extends Nr{constructor(){super(...arguments),this.name="AES-CBC",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"iv"),!(e.iv instanceof ArrayBuffer||ArrayBuffer.isView(e.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(16!==e.iv.byteLength)throw new TypeError("iv: Must have length 16 bytes")}},Pr=class extends Nr{constructor(){super(...arguments),this.name="AES-CMAC",this.usages=["sign","verify"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not a Number");if(e.length<1)throw new Er("length: Must be more than 0")}},Ir=class extends Nr{constructor(){super(...arguments),this.name="AES-CTR",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"counter"),!(e.counter instanceof ArrayBuffer||ArrayBuffer.isView(e.counter)))throw new TypeError("counter: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(16!==e.counter.byteLength)throw new TypeError("iv: Must have length 16 bytes");if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not a Number");if(e.length<1)throw new Er("length: Must be more than 0")}},Or=class extends Nr{constructor(){super(...arguments),this.name="AES-ECB",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}},Hr=class extends Nr{constructor(){super(...arguments),this.name="AES-GCM",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){var t;if(this.checkRequiredProperty(e,"iv"),!(e.iv instanceof ArrayBuffer||ArrayBuffer.isView(e.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(e.iv.byteLength<1)throw new Er("iv: Must have length more than 0 and less than 2^64 - 1");switch(null!==(t=e.tagLength)&&void 0!==t||(e.tagLength=128),e.tagLength){case 32:case 64:case 96:case 104:case 112:case 120:case 128:break;default:throw new Er("tagLength: Must be one of 32, 64, 96, 104, 112, 120 or 128")}}},Tr=class extends Nr{constructor(){super(...arguments),this.name="AES-KW",this.usages=["wrapKey","unwrapKey"]}};class Lr extends xr{constructor(){super(...arguments),this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){if(this.ivSize){if(this.checkRequiredProperty(e,"iv"),!(e.iv instanceof ArrayBuffer||ArrayBuffer.isView(e.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(e.iv.byteLength!==this.ivSize)throw new TypeError(`iv: Must have length ${this.ivSize} bytes`)}}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not of type Number");if(e.length!==this.keySizeBits)throw new Er(`algorithm.length: Must be ${this.keySizeBits}`)}checkDerivedKeyParams(e){this.checkGenerateKeyParams(e)}}class Dr extends xr{constructor(){super(...arguments),this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"]}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),this.checkRequiredProperty(e,"publicExponent"),!(e.publicExponent&&e.publicExponent instanceof Uint8Array))throw new TypeError("publicExponent: Missing or not a Uint8Array");const t=i.Convert.ToBase64(e.publicExponent);if("Aw=="!==t&&"AQAB"!==t)throw new TypeError("publicExponent: Must be [3] or [1,0,1]");if(this.checkRequiredProperty(e,"modulusLength"),e.modulusLength%8||e.modulusLength<256||e.modulusLength>16384)throw new TypeError("The modulus length must be a multiple of 8 bits and >= 256 and <= 16384")}checkImportParams(e){this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms)}}let Vr=class extends Dr{constructor(){super(...arguments),this.name="RSASSA-PKCS1-v1_5",this.usages={privateKey:["sign"],publicKey:["verify"]}}},Rr=class extends Dr{constructor(){super(...arguments),this.name="RSA-PSS",this.usages={privateKey:["sign"],publicKey:["verify"]}}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"saltLength"),"number"!=typeof e.saltLength)throw new TypeError("saltLength: Is not a Number");if(e.saltLength<0)throw new RangeError("saltLength: Must be positive number")}},Mr=class extends Dr{constructor(){super(...arguments),this.name="RSA-OAEP",this.usages={privateKey:["decrypt","unwrapKey"],publicKey:["encrypt","wrapKey"]}}checkAlgorithmParams(e){if(e.label&&!(e.label instanceof ArrayBuffer||ArrayBuffer.isView(e.label)))throw new TypeError("label: Is not of type '(ArrayBuffer or ArrayBufferView)'")}};class $r extends xr{checkGenerateKeyParams(e){this.checkRequiredProperty(e,"namedCurve"),this.checkNamedCurve(e.namedCurve)}checkNamedCurve(e){for(const t of this.namedCurves)if(t.toLowerCase()===e.toLowerCase())return;throw new Er(`namedCurve: Must be one of ${this.namedCurves.join(", ")}`)}}let Jr=class extends $r{constructor(){super(...arguments),this.name="ECDSA",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages={privateKey:["sign"],publicKey:["verify"]},this.namedCurves=["P-256","P-384","P-521","K-256"]}checkAlgorithmParams(e){this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms)}};const jr=["secret","private","public"];let zr=class{static create(e,t,r,n){const s=new this;return s.algorithm=e,s.type=t,s.extractable=r,s.usages=n,s}static isKeyType(e){return-1!==jr.indexOf(e)}get[Symbol.toStringTag](){return"CryptoKey"}},Fr=class extends $r{constructor(){super(...arguments),this.name="ECDH",this.usages={privateKey:["deriveBits","deriveKey"],publicKey:[]},this.namedCurves=["P-256","P-384","P-521","K-256"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"public"),!(e.public instanceof zr))throw new TypeError("public: Is not a CryptoKey");if("public"!==e.public.type)throw new Er("public: Is not a public key");if(e.public.algorithm.name!==this.name)throw new Er(`public: Is not ${this.name} key`)}},Gr=class extends Fr{constructor(){super(...arguments),this.name="ECDH-ES",this.namedCurves=["X25519","X448"]}},_r=class extends $r{constructor(){super(...arguments),this.name="EdDSA",this.usages={privateKey:["sign"],publicKey:["verify"]},this.namedCurves=["Ed25519","Ed448"]}},qr=class{constructor(e){e&&(this.value=e)}};tr([Yt({type:vt.ObjectIdentifier})],qr.prototype,"value",void 0),qr=tr([Wt({type:wt.Choice})],qr);class Wr{constructor(e){Object.assign(this,e)}}tr([Yt({type:vt.ObjectIdentifier})],Wr.prototype,"algorithm",void 0),tr([Yt({type:vt.Any,optional:!0})],Wr.prototype,"parameters",void 0);class Yr{constructor(){this.version=0,this.privateKeyAlgorithm=new Wr,this.privateKey=new ArrayBuffer(0)}}tr([Yt({type:vt.Integer})],Yr.prototype,"version",void 0),tr([Yt({type:Wr})],Yr.prototype,"privateKeyAlgorithm",void 0),tr([Yt({type:vt.OctetString})],Yr.prototype,"privateKey",void 0),tr([Yt({type:vt.Any,optional:!0})],Yr.prototype,"attributes",void 0);class Xr{constructor(){this.publicKeyAlgorithm=new Wr,this.publicKey=new ArrayBuffer(0)}}tr([Yt({type:Wr})],Xr.prototype,"publicKeyAlgorithm",void 0),tr([Yt({type:vt.BitString})],Xr.prototype,"publicKey",void 0);const Zr={fromJSON:e=>i.Convert.FromBase64Url(e),toJSON:e=>i.Convert.ToBase64Url(new Uint8Array(e))},Qr={fromASN:e=>{const t=e.valueBlock.valueHex;return new Uint8Array(t)[0]?e.valueBlock.valueHex:e.valueBlock.valueHex.slice(1)},toASN:e=>{const t=new Uint8Array(e)[0]>127?i.combine(new Uint8Array([0]).buffer,e):e;return new he({valueHex:t})}};let en=class{constructor(){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0)}};tr([Yt({type:vt.Integer,converter:kt})],en.prototype,"version",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"n",converter:Zr})],en.prototype,"modulus",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"e",converter:Zr})],en.prototype,"publicExponent",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"d",converter:Zr})],en.prototype,"privateExponent",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"p",converter:Zr})],en.prototype,"prime1",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"q",converter:Zr})],en.prototype,"prime2",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"dp",converter:Zr})],en.prototype,"exponent1",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"dq",converter:Zr})],en.prototype,"exponent2",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"qi",converter:Zr})],en.prototype,"coefficient",void 0),tr([Yt({type:vt.Any,optional:!0})],en.prototype,"otherPrimeInfos",void 0);let tn=class{constructor(){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0)}};tr([Yt({type:vt.Integer,converter:Qr}),br({name:"n",converter:Zr})],tn.prototype,"modulus",void 0),tr([Yt({type:vt.Integer,converter:Qr}),br({name:"e",converter:Zr})],tn.prototype,"publicExponent",void 0);let rn=class{constructor(e){this.value=new ArrayBuffer(0),e&&(this.value=e)}toJSON(){let e=new Uint8Array(this.value);if(4!==e[0])throw new kr("Wrong ECPoint. Current version supports only Uncompressed (0x04) point");e=new Uint8Array(this.value.slice(1));const t=e.length/2;return{x:i.Convert.ToBase64Url(e.buffer.slice(0,0+t)),y:i.Convert.ToBase64Url(e.buffer.slice(0+t,0+t+t))}}fromJSON(e){if(!("x"in e))throw new Error("x: Missing required property");if(!("y"in e))throw new Error("y: Missing required property");const t=i.Convert.FromBase64Url(e.x),r=i.Convert.FromBase64Url(e.y),n=i.combine(new Uint8Array([4]).buffer,t,r);return this.value=new Uint8Array(n).buffer,this}};tr([Yt({type:vt.OctetString})],rn.prototype,"value",void 0),rn=tr([Wt({type:wt.Choice})],rn);let nn=class{constructor(){this.version=1,this.privateKey=new ArrayBuffer(0)}fromJSON(e){if(!("d"in e))throw new Error("d: Missing required property");if(this.privateKey=i.Convert.FromBase64Url(e.d),"x"in e){const t=new rn;t.fromJSON(e);const r=Qt.toASN(t);"valueHex"in r.valueBlock&&(this.publicKey=r.valueBlock.valueHex)}return this}toJSON(){const e={};return e.d=i.Convert.ToBase64Url(this.privateKey),this.publicKey&&Object.assign(e,new rn(this.publicKey).toJSON()),e}};tr([Yt({type:vt.Integer,converter:kt})],nn.prototype,"version",void 0),tr([Yt({type:vt.OctetString})],nn.prototype,"privateKey",void 0),tr([Yt({context:0,type:vt.Any,optional:!0})],nn.prototype,"parameters",void 0),tr([Yt({context:1,type:vt.BitString,optional:!0})],nn.prototype,"publicKey",void 0);const sn={fromASN:e=>{const t=new Uint8Array(e.valueBlock.valueHex);return 0===t[0]?t.buffer.slice(1):t.buffer},toASN:e=>{const t=new Uint8Array(e);if(t[0]>127){const e=new Uint8Array(t.length+1);return e.set(t,1),new he({valueHex:e.buffer})}return new he({valueHex:e})}};var on=Object.freeze({__proto__:null,AsnIntegerWithoutPaddingConverter:sn});class an{static decodePoint(e,t){const r=i.BufferSourceConverter.toUint8Array(e);if(0===r.length||4!==r[0])throw new Error("Only uncompressed point format supported");const n=(r.length-1)/2;if(n!==Math.ceil(t/8))throw new Error("Point does not match field size");return{x:r.slice(1,n+1),y:r.slice(n+1,n+1+n)}}static encodePoint(e,t){const r=Math.ceil(t/8);if(e.x.byteLength!==r||e.y.byteLength!==r)throw new Error("X,Y coordinates don't match point size criteria");const n=i.BufferSourceConverter.toUint8Array(e.x),s=i.BufferSourceConverter.toUint8Array(e.y),o=new Uint8Array(2*r+1);return o[0]=4,o.set(n,1),o.set(s,r+1),o}static getSize(e){return Math.ceil(e/8)}static encodeSignature(e,t){const r=this.getSize(t),n=i.BufferSourceConverter.toUint8Array(e.r),s=i.BufferSourceConverter.toUint8Array(e.s),o=new Uint8Array(2*r);return o.set(this.padStart(n,r)),o.set(this.padStart(s,r),r),o}static decodeSignature(e,t){const r=this.getSize(t),n=i.BufferSourceConverter.toUint8Array(e);if(n.length!==2*r)throw new Error("Incorrect size of the signature");const s=n.slice(0,r),o=n.slice(r);return{r:this.trimStart(s),s:this.trimStart(o)}}static trimStart(e){let t=0;for(;t<e.length-1&&0===e[t];)t++;return 0===t?e:e.slice(t,e.length)}static padStart(e,t){if(t===e.length)return e;const r=new Uint8Array(t);return r.set(e,t-e.length),r}}class cn{constructor(){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0)}static fromWebCryptoSignature(e){const t=e.byteLength/2,r=an.decodeSignature(e,8*t),n=new cn;return n.r=i.BufferSourceConverter.toArrayBuffer(r.r),n.s=i.BufferSourceConverter.toArrayBuffer(r.s),n}toWebCryptoSignature(e){if(!e){const t=Math.max(this.r.byteLength,this.s.byteLength);e=t<=32?256:t<=48?384:521}return an.encodeSignature(this,e).buffer}}tr([Yt({type:vt.Integer,converter:sn})],cn.prototype,"r",void 0),tr([Yt({type:vt.Integer,converter:sn})],cn.prototype,"s",void 0);class un extends Yr{}tr([Yt({context:1,implicit:!0,type:vt.BitString,optional:!0})],un.prototype,"publicKey",void 0);let ln=class{constructor(){this.value=new ArrayBuffer(0)}fromJSON(e){if(!e.d)throw new Error("d: Missing required property");return this.value=i.Convert.FromBase64Url(e.d),this}toJSON(){return{d:i.Convert.ToBase64Url(this.value)}}};tr([Yt({type:vt.OctetString})],ln.prototype,"value",void 0),ln=tr([Wt({type:wt.Choice})],ln);let hn=class{constructor(e){this.value=new ArrayBuffer(0),e&&(this.value=e)}toJSON(){return{x:i.Convert.ToBase64Url(this.value)}}fromJSON(e){if(!("x"in e))throw new Error("x: Missing required property");return this.value=i.Convert.FromBase64Url(e.x),this}};tr([Yt({type:vt.BitString})],hn.prototype,"value",void 0),hn=tr([Wt({type:wt.Choice})],hn);let yn=class{};tr([Yt({type:vt.OctetString}),br({type:cr.String,converter:Zr})],yn.prototype,"d",void 0),yn=tr([Wt({type:wt.Choice})],yn);const fn="1.2.840.10045.3.1.7",pn="1.3.132.0",gn=`${pn}.34`,mn=`${pn}.35`,dn=`${pn}.10`,wn="1.3.36.3.3.2.8.1.1",vn=`${wn}.1`,An=`${wn}.2`,bn=`${wn}.3`,kn=`${wn}.4`,Sn=`${wn}.5`,Bn=`${wn}.6`,En=`${wn}.7`,Kn=`${wn}.8`,Cn=`${wn}.9`,xn=`${wn}.10`,Nn=`${wn}.11`,Un=`${wn}.12`,Pn=`${wn}.13`,In=`${wn}.14`;var On=Object.freeze({__proto__:null,AlgorithmIdentifier:Wr,get CurvePrivateKey(){return yn},EcDsaSignature:cn,EcPrivateKey:nn,get EcPublicKey(){return rn},get EdPrivateKey(){return ln},get EdPublicKey(){return hn},get ObjectIdentifier(){return qr},OneAsymmetricKey:un,PrivateKeyInfo:Yr,PublicKeyInfo:Xr,RsaPrivateKey:en,RsaPublicKey:tn,converters:on,idBrainpoolP160r1:vn,idBrainpoolP160t1:An,idBrainpoolP192r1:bn,idBrainpoolP192t1:kn,idBrainpoolP224r1:Sn,idBrainpoolP224t1:Bn,idBrainpoolP256r1:En,idBrainpoolP256t1:Kn,idBrainpoolP320r1:Cn,idBrainpoolP320t1:xn,idBrainpoolP384r1:Nn,idBrainpoolP384t1:Un,idBrainpoolP512r1:Pn,idBrainpoolP512t1:In,idEd25519:"1.3.101.112",idEd448:"1.3.101.113",idEllipticCurve:pn,idSecp256k1:dn,idSecp256r1:fn,idSecp384r1:gn,idSecp521r1:mn,idVersionOne:wn,idX25519:"1.3.101.110",idX448:"1.3.101.111"});class Hn{constructor(){}static register(e){const t=new qr;t.value=e.id;const r=er.serialize(t);this.items.push({...e,raw:r}),this.names.push(e.name)}static find(e){e=e.toUpperCase();for(const t of this.items)if(t.name.toUpperCase()===e||t.id.toUpperCase()===e)return t;return null}static get(e){const t=this.find(e);if(!t)throw new Error(`Unsupported EC named curve '${e}'`);return t}}Hn.items=[],Hn.names=[],Hn.register({name:"P-256",id:fn,size:256}),Hn.register({name:"P-384",id:gn,size:384}),Hn.register({name:"P-521",id:mn,size:521}),Hn.register({name:"K-256",id:dn,size:256}),Hn.register({name:"brainpoolP160r1",id:vn,size:160}),Hn.register({name:"brainpoolP160t1",id:An,size:160}),Hn.register({name:"brainpoolP192r1",id:bn,size:192}),Hn.register({name:"brainpoolP192t1",id:kn,size:192}),Hn.register({name:"brainpoolP224r1",id:Sn,size:224}),Hn.register({name:"brainpoolP224t1",id:Bn,size:224}),Hn.register({name:"brainpoolP256r1",id:En,size:256}),Hn.register({name:"brainpoolP256t1",id:Kn,size:256}),Hn.register({name:"brainpoolP320r1",id:Cn,size:320}),Hn.register({name:"brainpoolP320t1",id:xn,size:320}),Hn.register({name:"brainpoolP384r1",id:Nn,size:384}),Hn.register({name:"brainpoolP384t1",id:Un,size:384}),Hn.register({name:"brainpoolP512r1",id:Pn,size:512}),Hn.register({name:"brainpoolP512t1",id:In,size:512});let Tn=class extends xr{constructor(){super(...arguments),this.name="X25519",this.usages={privateKey:["deriveKey","deriveBits"],publicKey:[]}}checkAlgorithmParams(e){this.checkRequiredProperty(e,"public")}},Ln=class extends xr{constructor(){super(...arguments),this.name="Ed25519",this.usages={privateKey:["sign"],publicKey:["verify"]}}},Dn=class extends xr{constructor(){super(...arguments),this.name="HMAC",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages=["sign","verify"]}getDefaultLength(e){switch(e.toUpperCase()){case"SHA-1":case"SHA-256":case"SHA-384":case"SHA-512":return 512;default:throw new Error(`Unknown algorithm name '${e}'`)}}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),"length"in e){if("number"!=typeof e.length)throw new TypeError("length: Is not a Number");if(e.length<1)throw new RangeError("length: Number is out of range")}}checkImportParams(e){this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms)}},Vn=class extends xr{constructor(){super(...arguments),this.name="PBKDF2",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages=["deriveBits","deriveKey"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),this.checkRequiredProperty(e,"salt"),!(e.salt instanceof ArrayBuffer||ArrayBuffer.isView(e.salt)))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(this.checkRequiredProperty(e,"iterations"),"number"!=typeof e.iterations)throw new TypeError("iterations: Is not a Number");if(e.iterations<1)throw new TypeError("iterations: Is less than 1")}checkImportKey(e,t,r,n,s,...i){if(super.checkImportKey(e,t,r,n,s,...i),n)throw new SyntaxError("extractable: Must be 'false'")}},Rn=class extends xr{constructor(){super(...arguments),this.name="HKDF",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages=["deriveKey","deriveBits"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),this.checkRequiredProperty(e,"salt"),!i.BufferSourceConverter.isBufferSource(e.salt))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(this.checkRequiredProperty(e,"info"),!i.BufferSourceConverter.isBufferSource(e.info))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'")}checkImportKey(e,t,r,n,s,...i){if(super.checkImportKey(e,t,r,n,s,...i),n)throw new SyntaxError("extractable: Must be 'false'")}};class Mn extends xr{constructor(){super(...arguments),this.usages=[],this.defaultLength=0}digest(...e){return e[0]={length:this.defaultLength,...e[0]},super.digest.apply(this,e)}checkDigest(e,t){super.checkDigest(e,t);const r=e.length||0;if("number"!=typeof r)throw new TypeError("length: Is not a Number");if(r<0)throw new TypeError("length: Is negative")}}let $n=class extends Mn{constructor(){super(...arguments),this.name="shake128",this.defaultLength=16}},Jn=class extends Mn{constructor(){super(...arguments),this.name="shake256",this.defaultLength=32}},jn=class{get[Symbol.toStringTag](){return"Crypto"}randomUUID(){const e=this.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=i.Convert.ToHex(e).toLowerCase();return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}};class zn{constructor(){this.items={}}get(e){return this.items[e.toLowerCase()]||null}set(e){this.items[e.name.toLowerCase()]=e}removeAt(e){const t=this.get(e.toLowerCase());return t&&delete this.items[e],t}has(e){return!!this.get(e)}get length(){return Object.keys(this.items).length}get algorithms(){const e=[];for(const t in this.items){const r=this.items[t];e.push(r.name)}return e.sort()}}const Fn={jwk:["private","public","secret"],pkcs8:["private"],spki:["public"],raw:["secret","public"]},Gn=["pkcs8","spki","raw"];let _n=class e{constructor(){this.providers=new zn}static isHashedAlgorithm(e){return!!(e&&"object"==typeof e&&"name"in e&&"hash"in e)}get[Symbol.toStringTag](){return"SubtleCrypto"}async digest(...e){this.checkRequiredArguments(e,2,"digest");const[t,r,...n]=e,s=this.prepareAlgorithm(t),o=i.BufferSourceConverter.toArrayBuffer(r),a=this.getProvider(s.name);return await a.digest(s,o,...n)}async generateKey(...e){this.checkRequiredArguments(e,3,"generateKey");const[t,r,n,...s]=e,i=this.prepareAlgorithm(t),o=this.getProvider(i.name);return await o.generateKey({...i,name:o.name},r,n,...s)}async sign(...e){this.checkRequiredArguments(e,3,"sign");const[t,r,n,...s]=e;this.checkCryptoKey(r);const o=this.prepareAlgorithm(t),a=i.BufferSourceConverter.toArrayBuffer(n),c=this.getProvider(o.name);return await c.sign({...o,name:c.name},r,a,...s)}async verify(...e){this.checkRequiredArguments(e,4,"verify");const[t,r,n,s,...o]=e;this.checkCryptoKey(r);const a=this.prepareAlgorithm(t),c=i.BufferSourceConverter.toArrayBuffer(s),u=i.BufferSourceConverter.toArrayBuffer(n),l=this.getProvider(a.name);return await l.verify({...a,name:l.name},r,u,c,...o)}async encrypt(...e){this.checkRequiredArguments(e,3,"encrypt");const[t,r,n,...s]=e;this.checkCryptoKey(r);const o=this.prepareAlgorithm(t),a=i.BufferSourceConverter.toArrayBuffer(n),c=this.getProvider(o.name);return await c.encrypt({...o,name:c.name},r,a,{keyUsage:!0},...s)}async decrypt(...e){this.checkRequiredArguments(e,3,"decrypt");const[t,r,n,...s]=e;this.checkCryptoKey(r);const o=this.prepareAlgorithm(t),a=i.BufferSourceConverter.toArrayBuffer(n),c=this.getProvider(o.name);return await c.decrypt({...o,name:c.name},r,a,{keyUsage:!0},...s)}async deriveBits(...e){this.checkRequiredArguments(e,3,"deriveBits");const[t,r,n,...s]=e;this.checkCryptoKey(r);const i=this.prepareAlgorithm(t),o=this.getProvider(i.name);return await o.deriveBits({...i,name:o.name},r,n,{keyUsage:!0},...s)}async deriveKey(...e){this.checkRequiredArguments(e,5,"deriveKey");const[t,r,n,s,i,...o]=e,a=this.prepareAlgorithm(n);this.getProvider(a.name).checkDerivedKeyParams(a);const c=this.prepareAlgorithm(t),u=this.getProvider(c.name);u.checkCryptoKey(r,"deriveKey");const l=await u.deriveBits({...c,name:u.name},r,n.length||512,{keyUsage:!1},...o);return this.importKey("raw",l,n,s,i,...o)}async exportKey(...e){this.checkRequiredArguments(e,2,"exportKey");const[t,r,...n]=e;if(this.checkCryptoKey(r),!Fn[t])throw new TypeError("Invalid keyFormat argument");if(!Fn[t].includes(r.type))throw new DOMException("The key is not of the expected type");const s=this.getProvider(r.algorithm.name);return await s.exportKey(t,r,...n)}async importKey(...e){this.checkRequiredArguments(e,5,"importKey");const[t,r,n,s,o,...a]=e,c=this.prepareAlgorithm(n),u=this.getProvider(c.name);if("jwk"===t){if("object"!=typeof r||!r.kty)throw new TypeError("Key data must be an object for JWK import")}else{if(!Gn.includes(t))throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView or JsonWebKey)'");if(!i.BufferSourceConverter.isBufferSource(r))throw new TypeError("Key data must be a BufferSource for non-JWK formats")}return u.importKey(t,r,{...c,name:u.name},s,o,...a)}async wrapKey(e,t,r,n,...s){let o=await this.exportKey(e,t,...s);if("jwk"===e){const e=JSON.stringify(o);o=i.Convert.FromUtf8String(e)}const a=this.prepareAlgorithm(n),c=i.BufferSourceConverter.toArrayBuffer(o),u=this.getProvider(a.name);return u.encrypt({...a,name:u.name},r,c,{keyUsage:!1},...s)}async unwrapKey(e,t,r,n,s,o,a,...c){const u=this.prepareAlgorithm(n),l=i.BufferSourceConverter.toArrayBuffer(t),h=this.getProvider(u.name);let y=await h.decrypt({...u,name:h.name},r,l,{keyUsage:!1},...c);if("jwk"===e)try{y=JSON.parse(i.Convert.ToUtf8String(y))}catch(e){const t=new TypeError("wrappedKey: Is not a JSON");throw t.internal=e,t}return this.importKey(e,y,s,o,a,...c)}checkRequiredArguments(e,t,r){if(e.length<t)throw new TypeError(`Failed to execute '${r}' on 'SubtleCrypto': ${t} arguments required, but only ${e.length} present`)}prepareAlgorithm(t){if("string"==typeof t)return{name:t};if(e.isHashedAlgorithm(t)){const e={...t};return e.hash=this.prepareAlgorithm(t.hash),e}return{...t}}getProvider(e){const t=this.providers.get(e);if(!t)throw new Sr("Unrecognized name");return t}checkCryptoKey(e){if(!(e instanceof zr))throw new TypeError("Key is not of type 'CryptoKey'")}};const qn={fromJSON:t=>e.from(i.Convert.FromBase64Url(t)),toJSON:e=>i.Convert.ToBase64Url(e)};class Wn extends zr{constructor(){super(...arguments),this.data=e.alloc(0),this.algorithm={name:""},this.extractable=!1,this.type="secret",this.usages=[],this.kty="oct",this.alg=""}}tr([br({name:"ext",type:cr.Boolean,optional:!0})],Wn.prototype,"extractable",void 0),tr([br({name:"key_ops",type:cr.String,repeated:!0,optional:!0})],Wn.prototype,"usages",void 0),tr([br({type:cr.String})],Wn.prototype,"kty",void 0),tr([br({type:cr.String,optional:!0})],Wn.prototype,"alg",void 0);class Yn extends Wn{constructor(){super(...arguments),this.kty="oct",this.type="secret"}}class Xn extends Wn{}class Zn extends Yn{get alg(){switch(this.algorithm.name.toUpperCase()){case"AES-CBC":return`A${this.algorithm.length}CBC`;case"AES-CTR":return`A${this.algorithm.length}CTR`;case"AES-GCM":return`A${this.algorithm.length}GCM`;case"AES-KW":return`A${this.algorithm.length}KW`;case"AES-CMAC":return`A${this.algorithm.length}CMAC`;case"AES-ECB":return`A${this.algorithm.length}ECB`;default:throw new Sr("Unsupported algorithm name")}}set alg(e){}}tr([br({name:"k",converter:qn})],Zn.prototype,"data",void 0);class Qn{static async generateKey(e,t,n){const s=new Zn;return s.algorithm=e,s.extractable=t,s.usages=n,s.data=r.randomBytes(e.length>>3),s}static async exportKey(e,t){if(!(t instanceof Zn))throw new Error("key: Is not AesCryptoKey");switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"raw":return new Uint8Array(t.data).buffer;default:throw new Er("format: Must be 'jwk' or 'raw'")}}static async importKey(t,r,n,s,i){let o;switch(t.toLowerCase()){case"jwk":o=Ar.fromJSON(r,{targetSchema:Zn});break;case"raw":o=new Zn,o.data=e.from(r);break;default:throw new Er("format: Must be 'jwk' or 'raw'")}switch(o.algorithm=n,o.algorithm.length=o.data.length<<3,o.extractable=s,o.usages=i,o.algorithm.length){case 128:case 192:case 256:break;default:throw new Er("keyData: Is wrong key length")}return o}static async encrypt(t,r,n){switch(t.name.toUpperCase()){case"AES-CBC":return this.encryptAesCBC(t,r,e.from(n));case"AES-CTR":return this.encryptAesCTR(t,r,e.from(n));case"AES-GCM":return this.encryptAesGCM(t,r,e.from(n));case"AES-KW":return this.encryptAesKW(t,r,e.from(n));case"AES-ECB":return this.encryptAesECB(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async decrypt(t,r,n){if(!(r instanceof Zn))throw new Error("key: Is not AesCryptoKey");switch(t.name.toUpperCase()){case"AES-CBC":return this.decryptAesCBC(t,r,e.from(n));case"AES-CTR":return this.decryptAesCTR(t,r,e.from(n));case"AES-GCM":return this.decryptAesGCM(t,r,e.from(n));case"AES-KW":return this.decryptAesKW(t,r,e.from(n));case"AES-ECB":return this.decryptAesECB(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async encryptAesCBC(t,n,s){const i=r.createCipheriv(`aes-${n.algorithm.length}-cbc`,n.data,new Uint8Array(t.iv));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptAesCBC(t,n,s){const i=r.createDecipheriv(`aes-${n.algorithm.length}-cbc`,n.data,new Uint8Array(t.iv));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptAesCTR(t,n,s){const i=r.createCipheriv(`aes-${n.algorithm.length}-ctr`,n.data,e.from(t.counter));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptAesCTR(t,n,s){const i=r.createDecipheriv(`aes-${n.algorithm.length}-ctr`,n.data,new Uint8Array(t.counter));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptAesGCM(t,n,s){const i=r.createCipheriv(`aes-${n.algorithm.length}-gcm`,n.data,e.from(t.iv),{authTagLength:(t.tagLength||128)>>3});t.additionalData&&i.setAAD(e.from(t.additionalData));let o=i.update(s);o=e.concat([o,i.final(),i.getAuthTag()]);return new Uint8Array(o).buffer}static async decryptAesGCM(t,n,s){const i=(t.tagLength||128)>>3,o=r.createDecipheriv(`aes-${n.algorithm.length}-gcm`,n.data,new Uint8Array(t.iv),{authTagLength:i}),a=s.slice(0,s.length-i),c=s.slice(s.length-i);t.additionalData&&o.setAAD(e.from(t.additionalData)),o.setAuthTag(c);let u=o.update(a);return u=e.concat([u,o.final()]),new Uint8Array(u).buffer}static async encryptAesKW(t,n,s){const i=r.createCipheriv(`id-aes${n.algorithm.length}-wrap`,n.data,this.AES_KW_IV);let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async decryptAesKW(t,n,s){const i=r.createDecipheriv(`id-aes${n.algorithm.length}-wrap`,n.data,this.AES_KW_IV);let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptAesECB(t,n,s){const i=r.createCipheriv(`aes-${n.algorithm.length}-ecb`,n.data,new Uint8Array(0));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptAesECB(t,n,s){const i=r.createDecipheriv(`aes-${n.algorithm.length}-ecb`,n.data,new Uint8Array(0));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}}Qn.AES_KW_IV=e.from("A6A6A6A6A6A6A6A6","hex");const es=new WeakMap;function ts(e){const t=es.get(e);if(!t)throw new Er("Cannot get CryptoKey from secure storage");return t}function rs(e){const t=zr.create(e.algorithm,e.type,e.extractable,e.usages);return Object.freeze(t),es.set(t,e),t}class ns extends Ur{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}const ss=e.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),is=e.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135]),os=16;function as(t){const r=e.alloc(t.length),n=t.length-1;for(let e=0;e<n;e++)r[e]=t[e]<<1,128&t[e+1]&&(r[e]+=1);return r[n]=t[n]<<1,r}function cs(t,r){const n=Math.min(t.length,r.length),s=e.alloc(n);for(let e=0;e<n;e++)s[e]=t[e]^r[e];return s}function us(e,t){const n=r.createCipheriv("aes"+(e.length<<3),e,ss),s=n.update(t);return n.final(),s}function ls(t,r){const n=e.alloc(os),s=r*os,i=s+os;return t.copy(n,0,s,i),n}function hs(t,r){const n=function(e){const t=us(e,ss);let r=as(t);128&t[0]&&(r=cs(r,is));let n=as(r);return 128&r[0]&&(n=cs(n,is)),{subkey1:r,subkey2:n}}(t);let s,i,o=Math.ceil(r.length/os);0===o?(o=1,s=!1):s=r.length%os===0;const a=o-1;i=s?cs(ls(r,a),n.subkey1):cs(function(t,r){const n=e.alloc(os),s=r*os,i=t.length;return n.fill(0),t.copy(n,0,s,i),n[i-s]=128,n}(r,a),n.subkey2);let c,u=ss;for(let e=0;e<a;e++)c=cs(u,ls(r,e)),u=us(t,c);return c=cs(i,u),us(t,c)}class ys extends Pr{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onSign(t,r,n){const s=hs(ts(r).data,e.from(n));return new Uint8Array(s).buffer}async onVerify(t,r,n,s){const i=await this.sign(t,r,s);return 0===e.from(n).compare(e.from(i))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class fs extends Ir{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class ps extends Hr{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class gs extends Tr{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class ms extends Or{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class ds extends Yn{get alg(){switch(this.algorithm.name.toUpperCase()){case"DES-CBC":return"DES-CBC";case"DES-EDE3-CBC":return"3DES-CBC";default:throw new Sr("Unsupported algorithm name")}}set alg(e){}}tr([br({name:"k",converter:qn})],ds.prototype,"data",void 0);class ws{static async generateKey(e,t,n){const s=new ds;return s.algorithm=e,s.extractable=t,s.usages=n,s.data=r.randomBytes(e.length>>3),s}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"raw":return new Uint8Array(t.data).buffer;default:throw new Er("format: Must be 'jwk' or 'raw'")}}static async importKey(t,r,n,s,i){let o;switch(t.toLowerCase()){case"jwk":o=Ar.fromJSON(r,{targetSchema:ds});break;case"raw":o=new ds,o.data=e.from(r);break;default:throw new Er("format: Must be 'jwk' or 'raw'")}return o.algorithm=n,o.extractable=s,o.usages=i,o}static async encrypt(t,r,n){switch(t.name.toUpperCase()){case"DES-CBC":return this.encryptDesCBC(t,r,e.from(n));case"DES-EDE3-CBC":return this.encryptDesEDE3CBC(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async decrypt(t,r,n){if(!(r instanceof ds))throw new Error("key: Is not DesCryptoKey");switch(t.name.toUpperCase()){case"DES-CBC":return this.decryptDesCBC(t,r,e.from(n));case"DES-EDE3-CBC":return this.decryptDesEDE3CBC(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async encryptDesCBC(t,n,s){const i=r.createCipheriv("des-cbc",n.data,new Uint8Array(t.iv));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptDesCBC(t,n,s){const i=r.createDecipheriv("des-cbc",n.data,new Uint8Array(t.iv));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptDesEDE3CBC(t,n,s){const i=r.createCipheriv("des-ede3-cbc",n.data,e.from(t.iv));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptDesEDE3CBC(t,n,s){const i=r.createDecipheriv("des-ede3-cbc",n.data,new Uint8Array(t.iv));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}}class vs extends Lr{constructor(){super(...arguments),this.keySizeBits=64,this.ivSize=8,this.name="DES-CBC"}async onGenerateKey(e,t,r){return rs(await ws.generateKey({name:this.name,length:this.keySizeBits},t,r))}async onEncrypt(e,t,r){return ws.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return ws.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return ws.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){const i=await ws.importKey(e,t,{name:this.name,length:this.keySizeBits},n,s);if(i.data.length!==this.keySizeBits>>3)throw new Er("keyData: Wrong key size");return rs(i)}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ds))throw new TypeError("key: Is not a DesCryptoKey")}}class As extends Lr{constructor(){super(...arguments),this.keySizeBits=192,this.ivSize=8,this.name="DES-EDE3-CBC"}async onGenerateKey(e,t,r){return rs(await ws.generateKey({name:this.name,length:this.keySizeBits},t,r))}async onEncrypt(e,t,r){return ws.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return ws.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return ws.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){const i=await ws.importKey(e,t,{name:this.name,length:this.keySizeBits},n,s);if(i.data.length!==this.keySizeBits>>3)throw new Er("keyData: Wrong key size");return rs(i)}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ds))throw new TypeError("key: Is not a DesCryptoKey")}}function bs(e){switch(e.name.toUpperCase()){case"RSA-OAEP":{const t=/(\d+)$/.exec(e.hash.name)[1];return"RSA-OAEP"+("1"!==t?`-${t}`:"")}case"RSASSA-PKCS1-V1_5":return`RS${/(\d+)$/.exec(e.hash.name)[1]}`;case"RSA-PSS":return`PS${/(\d+)$/.exec(e.hash.name)[1]}`;case"RSA-PKCS1":return"RS1";default:throw new Er("algorithm: Is not recognized")}}class ks extends Xn{constructor(){super(...arguments),this.type="private"}getKey(){const e=Zt.parse(this.data,On.PrivateKeyInfo);return Zt.parse(e.privateKey,On.RsaPrivateKey)}toJSON(){const e=this.getKey(),t={kty:"RSA",alg:bs(this.algorithm),key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){const r=Ar.fromJSON(t,{targetSchema:On.RsaPrivateKey}),n=new On.PrivateKeyInfo;n.privateKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",n.privateKeyAlgorithm.parameters=null,n.privateKey=Qt.serialize(r),this.data=e.from(Qt.serialize(n))}}class Ss extends Xn{constructor(){super(...arguments),this.type="public"}getKey(){const e=Zt.parse(this.data,On.PublicKeyInfo);return Zt.parse(e.publicKey,On.RsaPublicKey)}toJSON(){const e=this.getKey(),t={kty:"RSA",alg:bs(this.algorithm),key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){const r=Ar.fromJSON(t,{targetSchema:On.RsaPublicKey}),n=new On.PublicKeyInfo;n.publicKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",n.publicKeyAlgorithm.parameters=null,n.publicKey=Qt.serialize(r),this.data=e.from(Qt.serialize(n))}}class Bs{static async generateKey(t,n,s){const i=new ks;i.algorithm=t,i.extractable=n,i.usages=s.filter(e=>-1!==this.privateKeyUsages.indexOf(e));const o=new Ss;o.algorithm=t,o.extractable=!0,o.usages=s.filter(e=>-1!==this.publicKeyUsages.indexOf(e));const a=e.concat([e.alloc(4-t.publicExponent.byteLength,0),e.from(t.publicExponent)]).readInt32BE(0),c=r.generateKeyPairSync("rsa",{modulusLength:t.modulusLength,publicExponent:a,publicKeyEncoding:{format:"der",type:"spki"},privateKeyEncoding:{format:"der",type:"pkcs8"}});i.data=c.privateKey,o.data=c.publicKey;return{privateKey:i,publicKey:o}}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"pkcs8":case"spki":return new Uint8Array(t.data).buffer;default:throw new Er("format: Must be 'jwk', 'pkcs8' or 'spki'")}}static async importKey(e,t,r,n,s){switch(e.toLowerCase()){case"jwk":if(t.d){const e=Ar.fromJSON(t,{targetSchema:On.RsaPrivateKey});return this.importPrivateKey(e,r,n,s)}{const e=Ar.fromJSON(t,{targetSchema:On.RsaPublicKey});return this.importPublicKey(e,r,n,s)}case"spki":{const e=Zt.parse(new Uint8Array(t),On.PublicKeyInfo),i=Zt.parse(e.publicKey,On.RsaPublicKey);return this.importPublicKey(i,r,n,s)}case"pkcs8":{const e=Zt.parse(new Uint8Array(t),On.PrivateKeyInfo),i=Zt.parse(e.privateKey,On.RsaPrivateKey);return this.importPrivateKey(i,r,n,s)}default:throw new Er("format: Must be 'jwk', 'pkcs8' or 'spki'")}}static async sign(e,t,r){switch(e.name.toUpperCase()){case"RSA-PSS":case"RSASSA-PKCS1-V1_5":return this.signRsa(e,t,r);default:throw new Er("algorithm: Is not recognized")}}static async verify(e,t,r,n){switch(e.name.toUpperCase()){case"RSA-PSS":case"RSASSA-PKCS1-V1_5":return this.verifySSA(e,t,n,r);default:throw new Er("algorithm: Is not recognized")}}static async encrypt(e,t,r){if("RSA-OAEP"===e.name.toUpperCase())return this.encryptOAEP(e,t,r);throw new Er("algorithm: Is not recognized")}static async decrypt(e,t,r){if("RSA-OAEP"===e.name.toUpperCase())return this.decryptOAEP(e,t,r);throw new Er("algorithm: Is not recognized")}static importPrivateKey(t,r,n,s){const i=new On.PrivateKeyInfo;i.privateKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",i.privateKeyAlgorithm.parameters=null,i.privateKey=Qt.serialize(t);const o=new ks;return o.data=e.from(Qt.serialize(i)),o.algorithm=Object.assign({},r),o.algorithm.publicExponent=new Uint8Array(t.publicExponent),o.algorithm.modulusLength=t.modulus.byteLength<<3,o.extractable=n,o.usages=s,o}static importPublicKey(t,r,n,s){const i=new On.PublicKeyInfo;i.publicKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",i.publicKeyAlgorithm.parameters=null,i.publicKey=Qt.serialize(t);const o=new Ss;return o.data=e.from(Qt.serialize(i)),o.algorithm=Object.assign({},r),o.algorithm.publicExponent=new Uint8Array(t.publicExponent),o.algorithm.modulusLength=t.modulus.byteLength<<3,o.extractable=n,o.usages=s,o}static getCryptoAlgorithm(e){switch(e.hash.name.toUpperCase()){case"SHA-1":return"RSA-SHA1";case"SHA-256":return"RSA-SHA256";case"SHA-384":return"RSA-SHA384";case"SHA-512":return"RSA-SHA512";case"SHA3-256":return"RSA-SHA3-256";case"SHA3-384":return"RSA-SHA3-384";case"SHA3-512":return"RSA-SHA3-512";default:throw new Er("algorithm.hash: Is not recognized")}}static signRsa(t,n,s){const i=this.getCryptoAlgorithm(n.algorithm),o=r.createSign(i);o.update(e.from(s)),n.pem||(n.pem=`-----BEGIN PRIVATE KEY-----\n${n.data.toString("base64")}\n-----END PRIVATE KEY-----`);const a={key:n.pem};"RSA-PSS"===t.name.toUpperCase()&&(a.padding=r.constants.RSA_PKCS1_PSS_PADDING,a.saltLength=t.saltLength);const c=o.sign(a);return new Uint8Array(c).buffer}static verifySSA(t,n,s,i){const o=this.getCryptoAlgorithm(n.algorithm),a=r.createVerify(o);a.update(e.from(s)),n.pem||(n.pem=`-----BEGIN PUBLIC KEY-----\n${n.data.toString("base64")}\n-----END PUBLIC KEY-----`);const c={key:n.pem};"RSA-PSS"===t.name.toUpperCase()&&(c.padding=r.constants.RSA_PKCS1_PSS_PADDING,c.saltLength=t.saltLength);return a.verify(c,i)}static encryptOAEP(e,t,n){const s={key:`-----BEGIN PUBLIC KEY-----\n${t.data.toString("base64")}\n-----END PUBLIC KEY-----`,padding:r.constants.RSA_PKCS1_OAEP_PADDING};return e.label,new Uint8Array(r.publicEncrypt(s,n)).buffer}static decryptOAEP(e,t,n){const s={key:`-----BEGIN PRIVATE KEY-----\n${t.data.toString("base64")}\n-----END PRIVATE KEY-----`,padding:r.constants.RSA_PKCS1_OAEP_PADDING};return e.label,new Uint8Array(r.privateDecrypt(s,n)).buffer}}Bs.publicKeyUsages=["verify","encrypt","wrapKey"],Bs.privateKeyUsages=["sign","decrypt","unwrapKey"];class Es extends Vr{constructor(){super(...arguments),this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","shake128","shake256","SHA3-256","SHA3-384","SHA3-512"]}async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return Bs.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return Bs.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}}class Ks extends Rr{constructor(){super(...arguments),this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","shake128","shake256","SHA3-256","SHA3-384","SHA3-512"]}async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return Bs.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return Bs.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}}class Cs{static size(e){switch(e.name.toUpperCase()){case"SHA-1":return 160;case"SHA-256":case"SHA3-256":return 256;case"SHA-384":case"SHA3-384":return 384;case"SHA-512":case"SHA3-512":return 512;default:throw new Error("Unrecognized name")}}static getAlgorithmName(e){switch(e.name.toUpperCase()){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512";case"SHA3-256":return"sha3-256";case"SHA3-384":return"sha3-384";case"SHA3-512":return"sha3-512";default:throw new Error("Unrecognized name")}}static digest(t,n){const s=this.getAlgorithmName(t),i=r.createHash(s).update(e.from(n)).digest();return new Uint8Array(i).buffer}}class xs extends Mr{async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onEncrypt(t,n,s){const o=ts(n),a=new Uint8Array(s),c=Math.ceil(o.algorithm.modulusLength>>3),u=Cs.size(o.algorithm.hash)>>3,l=a.byteLength,h=c-l-2*u-2;if(l>c-2*u-2)throw new Error("Data too large");const y=new Uint8Array(c),f=y.subarray(1,u+1),p=y.subarray(u+1);p.set(a,u+h+1);const g=r.createHash(o.algorithm.hash.name.replace("-","")).update(i.BufferSourceConverter.toUint8Array(t.label||new Uint8Array(0))).digest();p.set(g,0),p[u+h]=1,r.randomFillSync(f);const m=this.mgf1(o.algorithm.hash,f,p.length);for(let e=0;e<p.length;e++)p[e]^=m[e];const d=this.mgf1(o.algorithm.hash,p,f.length);for(let e=0;e<f.length;e++)f[e]^=d[e];o.pem||(o.pem=`-----BEGIN PUBLIC KEY-----\n${o.data.toString("base64")}\n-----END PUBLIC KEY-----`);const w=r.publicEncrypt({key:o.pem,padding:r.constants.RSA_NO_PADDING},e.from(y));return new Uint8Array(w).buffer}async onDecrypt(t,n,s){const o=ts(n),a=Math.ceil(o.algorithm.modulusLength>>3),c=Cs.size(o.algorithm.hash)>>3;if(s.byteLength!==a)throw new Error("Bad data");o.pem||(o.pem=`-----BEGIN PRIVATE KEY-----\n${o.data.toString("base64")}\n-----END PRIVATE KEY-----`);let u=r.privateDecrypt({key:o.pem,padding:r.constants.RSA_NO_PADDING},e.from(s));const l=u[0],h=u.subarray(1,c+1),y=u.subarray(c+1);if(0!==l)throw new Error("Decryption failed");const f=this.mgf1(o.algorithm.hash,y,h.length);for(let e=0;e<h.length;e++)h[e]^=f[e];const p=this.mgf1(o.algorithm.hash,h,y.length);for(let e=0;e<y.length;e++)y[e]^=p[e];const g=r.createHash(o.algorithm.hash.name.replace("-","")).update(i.BufferSourceConverter.toUint8Array(t.label||new Uint8Array(0))).digest();for(let e=0;e<c;e++)if(g[e]!==y[e])throw new Error("Decryption failed");let m=c;for(;m<y.length;m++){const e=y[m];if(1===e)break;if(0!==e)throw new Error("Decryption failed")}if(m===y.length)throw new Error("Decryption failed");return u=y.subarray(m+1),new Uint8Array(u).buffer}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}mgf1(e,t,n=0){const s=Cs.size(e)>>3,i=new Uint8Array(n),o=new Uint8Array(4),a=Math.ceil(n/s);for(let n=0;n<a;n++){o[0]=n>>>24,o[1]=n>>>16&255,o[2]=n>>>8&255,o[3]=255&n;const a=i.subarray(n*s);let c=r.createHash(e.name.replace("-","")).update(t).update(o).digest();c.length>a.length&&(c=c.subarray(0,a.length)),a.set(c)}return i}}class Ns extends xr{constructor(){super(...arguments),this.name="RSAES-PKCS1-v1_5",this.usages={publicKey:["encrypt","wrapKey"],privateKey:["decrypt","unwrapKey"]}}async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"publicExponent"),!(e.publicExponent&&e.publicExponent instanceof Uint8Array))throw new TypeError("publicExponent: Missing or not a Uint8Array");const t=i.Convert.ToBase64(e.publicExponent);if("Aw=="!==t&&"AQAB"!==t)throw new TypeError("publicExponent: Must be [3] or [1,0,1]");switch(this.checkRequiredProperty(e,"modulusLength"),e.modulusLength){case 1024:case 2048:case 4096:break;default:throw new TypeError("modulusLength: Must be 1024, 2048, or 4096")}}async onEncrypt(e,t,n){const s=this.toCryptoOptions(t),i=r.publicEncrypt(s,new Uint8Array(n));return new Uint8Array(i).buffer}async onDecrypt(e,t,n){const s=this.toCryptoOptions(t),i=r.privateDecrypt(s,new Uint8Array(n));return new Uint8Array(i).buffer}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}toCryptoOptions(e){const t=e.type.toUpperCase();return{key:`-----BEGIN ${t} KEY-----\n${ts(e).data.toString("base64")}\n-----END ${t} KEY-----`,padding:r.constants.RSA_PKCS1_PADDING}}}const Us={"1.2.840.10045.3.1.7":"P-256","P-256":"1.2.840.10045.3.1.7","1.3.132.0.34":"P-384","P-384":"1.3.132.0.34","1.3.132.0.35":"P-521","P-521":"1.3.132.0.35","1.3.132.0.10":"K-256","K-256":"1.3.132.0.10",brainpoolP160r1:"1.3.36.3.3.2.8.1.1.1","1.3.36.3.3.2.8.1.1.1":"brainpoolP160r1",brainpoolP160t1:"1.3.36.3.3.2.8.1.1.2","1.3.36.3.3.2.8.1.1.2":"brainpoolP160t1",brainpoolP192r1:"1.3.36.3.3.2.8.1.1.3","1.3.36.3.3.2.8.1.1.3":"brainpoolP192r1",brainpoolP192t1:"1.3.36.3.3.2.8.1.1.4","1.3.36.3.3.2.8.1.1.4":"brainpoolP192t1",brainpoolP224r1:"1.3.36.3.3.2.8.1.1.5","1.3.36.3.3.2.8.1.1.5":"brainpoolP224r1",brainpoolP224t1:"1.3.36.3.3.2.8.1.1.6","1.3.36.3.3.2.8.1.1.6":"brainpoolP224t1",brainpoolP256r1:"1.3.36.3.3.2.8.1.1.7","1.3.36.3.3.2.8.1.1.7":"brainpoolP256r1",brainpoolP256t1:"1.3.36.3.3.2.8.1.1.8","1.3.36.3.3.2.8.1.1.8":"brainpoolP256t1",brainpoolP320r1:"1.3.36.3.3.2.8.1.1.9","1.3.36.3.3.2.8.1.1.9":"brainpoolP320r1",brainpoolP320t1:"1.3.36.3.3.2.8.1.1.10","1.3.36.3.3.2.8.1.1.10":"brainpoolP320t1",brainpoolP384r1:"1.3.36.3.3.2.8.1.1.11","1.3.36.3.3.2.8.1.1.11":"brainpoolP384r1",brainpoolP384t1:"1.3.36.3.3.2.8.1.1.12","1.3.36.3.3.2.8.1.1.12":"brainpoolP384t1",brainpoolP512r1:"1.3.36.3.3.2.8.1.1.13","1.3.36.3.3.2.8.1.1.13":"brainpoolP512r1",brainpoolP512t1:"1.3.36.3.3.2.8.1.1.14","1.3.36.3.3.2.8.1.1.14":"brainpoolP512t1"};function Ps(e){const t=Us[e];if(!t)throw new Er(`Cannot convert WebCrypto named curve '${e}' to OID`);return t}class Is extends Xn{constructor(){super(...arguments),this.type="private"}getKey(){const e=Zt.parse(this.data,On.PrivateKeyInfo);return Zt.parse(e.privateKey,On.EcPrivateKey)}toJSON(){const e=this.getKey(),t={kty:"EC",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");const r=new On.PrivateKeyInfo;r.privateKeyAlgorithm.algorithm="1.2.840.10045.2.1",r.privateKeyAlgorithm.parameters=Qt.serialize(new On.ObjectIdentifier(Ps(t.crv)));const n=Ar.fromJSON(t,{targetSchema:On.EcPrivateKey});return r.privateKey=Qt.serialize(n),this.data=e.from(Qt.serialize(r)),this}}class Os extends Xn{constructor(){super(...arguments),this.type="public"}getKey(){const e=Zt.parse(this.data,On.PublicKeyInfo);return new On.EcPublicKey(e.publicKey)}toJSON(){const e=this.getKey(),t={kty:"EC",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");const r=Ar.fromJSON(t,{targetSchema:On.EcPublicKey}),n=new On.PublicKeyInfo;return n.publicKeyAlgorithm.algorithm="1.2.840.10045.2.1",n.publicKeyAlgorithm.parameters=Qt.serialize(new On.ObjectIdentifier(Ps(t.crv))),n.publicKey=Qt.toASN(r).valueHex,this.data=e.from(Qt.serialize(n)),this}}class Hs extends xr{constructor(){super(...arguments),this.name="SHA-1",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ts extends xr{constructor(){super(...arguments),this.name="SHA-256",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ls extends xr{constructor(){super(...arguments),this.name="SHA-384",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ds extends xr{constructor(){super(...arguments),this.name="SHA-512",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Vs extends xr{constructor(){super(...arguments),this.name="SHA3-256",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Rs extends xr{constructor(){super(...arguments),this.name="SHA3-384",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ms extends xr{constructor(){super(...arguments),this.name="SHA3-512",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class $s{static async generateKey(e,t,n){const s=new Is;s.algorithm=e,s.extractable=t,s.usages=n.filter(e=>-1!==this.privateKeyUsages.indexOf(e));const i=new Os;i.algorithm=e,i.extractable=!0,i.usages=n.filter(e=>-1!==this.publicKeyUsages.indexOf(e));const o=r.generateKeyPairSync("ec",{namedCurve:this.getOpenSSLNamedCurve(e.namedCurve),publicKeyEncoding:{format:"der",type:"spki"},privateKeyEncoding:{format:"der",type:"pkcs8"}});s.data=o.privateKey,i.data=o.publicKey;return{privateKey:s,publicKey:i}}static async sign(t,n,s){const i=Cs.getAlgorithmName(t.hash),o=r.createSign(i);o.update(e.from(s)),n.pem||(n.pem=`-----BEGIN PRIVATE KEY-----\n${n.data.toString("base64")}\n-----END PRIVATE KEY-----`);const a={key:n.pem},c=o.sign(a),u=Zt.parse(c,On.EcDsaSignature);return an.encodeSignature(u,Hn.get(n.algorithm.namedCurve).size).buffer}static async verify(t,n,s,o){const a=Cs.getAlgorithmName(t.hash),c=r.createVerify(a);c.update(e.from(o)),n.pem||(n.pem=`-----BEGIN PUBLIC KEY-----\n${n.data.toString("base64")}\n-----END PUBLIC KEY-----`);const u={key:n.pem},l=new On.EcDsaSignature,h=Hn.get(n.algorithm.namedCurve),y=an.decodeSignature(s,h.size);l.r=i.BufferSourceConverter.toArrayBuffer(y.r),l.s=i.BufferSourceConverter.toArrayBuffer(y.s);const f=e.from(Qt.serialize(l));return c.verify(u,f)}static async deriveBits(t,n,s){const i=this.getOpenSSLNamedCurve(n.algorithm.namedCurve),o=r.createECDH(i),a=Zt.parse(n.data,On.PrivateKeyInfo),c=Zt.parse(a.privateKey,On.EcPrivateKey);o.setPrivateKey(e.from(c.privateKey));const u=Zt.parse(t.public.data,On.PublicKeyInfo),l=o.computeSecret(e.from(u.publicKey));return null===s?l:new Uint8Array(l).buffer.slice(0,s>>3)}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"pkcs8":case"spki":return new Uint8Array(t.data).buffer;case"raw":return Zt.parse(t.data,On.PublicKeyInfo).publicKey;default:throw new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'")}}static async importKey(e,t,r,n,s){switch(e.toLowerCase()){case"jwk":if(t.d){const e=Ar.fromJSON(t,{targetSchema:On.EcPrivateKey});return this.importPrivateKey(e,r,n,s)}{const e=Ar.fromJSON(t,{targetSchema:On.EcPublicKey});return this.importPublicKey(e,r,n,s)}case"raw":{const e=new On.EcPublicKey(t);return this.importPublicKey(e,r,n,s)}case"spki":{const e=Zt.parse(new Uint8Array(t),On.PublicKeyInfo),i=new On.EcPublicKey(e.publicKey);return this.assertKeyParameters(e.publicKeyAlgorithm.parameters,r.namedCurve),this.importPublicKey(i,r,n,s)}case"pkcs8":{const e=Zt.parse(new Uint8Array(t),On.PrivateKeyInfo),i=Zt.parse(e.privateKey,On.EcPrivateKey);return this.assertKeyParameters(e.privateKeyAlgorithm.parameters,r.namedCurve),this.importPrivateKey(i,r,n,s)}default:throw new Er("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'")}}static assertKeyParameters(e,t){if(!e)throw new kr("Key info doesn't have required parameters");let r="";try{r=Zt.parse(e,On.ObjectIdentifier).value}catch(e){throw new kr("Cannot read key info parameters")}if(Ps(t)!==r)throw new kr("Key info parameter doesn't match to named curve")}static async importPrivateKey(t,r,n,s){const i=new On.PrivateKeyInfo;i.privateKeyAlgorithm.algorithm="1.2.840.10045.2.1",i.privateKeyAlgorithm.parameters=Qt.serialize(new On.ObjectIdentifier(Ps(r.namedCurve))),i.privateKey=Qt.serialize(t);const o=new Is;return o.data=e.from(Qt.serialize(i)),o.algorithm=Object.assign({},r),o.extractable=n,o.usages=s,o}static async importPublicKey(t,r,n,s){const i=new On.PublicKeyInfo;i.publicKeyAlgorithm.algorithm="1.2.840.10045.2.1";const o=Ps(r.namedCurve);i.publicKeyAlgorithm.parameters=Qt.serialize(new On.ObjectIdentifier(o)),i.publicKey=t.value;const a=new Os;return a.data=e.from(Qt.serialize(i)),a.algorithm=Object.assign({},r),a.extractable=n,a.usages=s,a}static getOpenSSLNamedCurve(e){switch(e.toUpperCase()){case"P-256":return"prime256v1";case"K-256":return"secp256k1";case"P-384":return"secp384r1";case"P-521":return"secp521r1";default:return e}}}$s.publicKeyUsages=["verify"],$s.privateKeyUsages=["sign","deriveKey","deriveBits"];class Js extends Jr{constructor(){super(...arguments),this.namedCurves=Hn.names,this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","shake128","shake256","SHA3-256","SHA3-384","SHA3-512"]}async onGenerateKey(e,t,r){const n=await $s.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return $s.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return $s.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return $s.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await $s.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof Is||r instanceof Os))throw new TypeError("key: Is not EC CryptoKey")}}class js extends Fr{constructor(){super(...arguments),this.namedCurves=Hn.names}async onGenerateKey(e,t,r){const n=await $s.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onExportKey(e,t){return $s.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await $s.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof Is||r instanceof Os))throw new TypeError("key: Is not EC CryptoKey")}async onDeriveBits(e,t,r){return await $s.deriveBits({...e,public:ts(e.public)},ts(t),r)}}const zs={[On.idEd448]:"Ed448",ed448:On.idEd448,[On.idX448]:"X448",x448:On.idX448,[On.idEd25519]:"Ed25519",ed25519:On.idEd25519,[On.idX25519]:"X25519",x25519:On.idX25519};function Fs(e){const t=zs[e.toLowerCase()];if(!t)throw new Er(`Cannot convert WebCrypto named curve '${e}' to OID`);return t}class Gs extends Xn{constructor(){super(...arguments),this.type="private"}getKey(){const e=Zt.parse(this.data,On.PrivateKeyInfo);return Zt.parse(e.privateKey,On.CurvePrivateKey)}toJSON(){const e=this.getKey(),t={kty:"OKP",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");const r=new On.PrivateKeyInfo;r.privateKeyAlgorithm.algorithm=Fs(t.crv);const n=Ar.fromJSON(t,{targetSchema:On.CurvePrivateKey});return r.privateKey=Qt.serialize(n),this.data=e.from(Qt.serialize(r)),this}}class _s extends Xn{constructor(){super(...arguments),this.type="public"}getKey(){return Zt.parse(this.data,On.PublicKeyInfo).publicKey}toJSON(){const e=this.getKey(),t={kty:"OKP",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,{x:i.Convert.ToBase64Url(e)})}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");if(!t.x)throw new Er("Cannot get property from JWK. Property 'x' is required");const r=new On.PublicKeyInfo;return r.publicKeyAlgorithm.algorithm=Fs(t.crv),r.publicKey=i.Convert.FromBase64Url(t.x),this.data=e.from(Qt.serialize(r)),this}}class qs{static async generateKey(e,t,n){const s=new Gs;s.algorithm=e,s.extractable=t,s.usages=n.filter(e=>-1!==this.privateKeyUsages.indexOf(e));const i=new _s;i.algorithm=e,i.extractable=!0,i.usages=n.filter(e=>-1!==this.publicKeyUsages.indexOf(e));const o=e.namedCurve.toLowerCase(),a=r.generateKeyPairSync(o,{publicKeyEncoding:{format:"der",type:"spki"},privateKeyEncoding:{format:"der",type:"pkcs8"}});s.data=a.privateKey,i.data=a.publicKey;return{privateKey:s,publicKey:i}}static async sign(t,n,s){n.pem||(n.pem=`-----BEGIN PRIVATE KEY-----\n${n.data.toString("base64")}\n-----END PRIVATE KEY-----`);const o={key:n.pem},a=r.sign(null,e.from(s),o);return i.BufferSourceConverter.toArrayBuffer(a)}static async verify(t,n,s,i){n.pem||(n.pem=`-----BEGIN PUBLIC KEY-----\n${n.data.toString("base64")}\n-----END PUBLIC KEY-----`);const o={key:n.pem};return r.verify(null,e.from(i),o,e.from(s))}static async deriveBits(e,t,n){const s=r.createPublicKey({key:e.public.data,format:"der",type:"spki"}),i=r.createPrivateKey({key:t.data,format:"der",type:"pkcs8"}),o=r.diffieHellman({publicKey:s,privateKey:i});return new Uint8Array(o).buffer.slice(0,n>>3)}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"pkcs8":case"spki":return new Uint8Array(t.data).buffer;case"raw":return Zt.parse(t.data,On.PublicKeyInfo).publicKey;default:throw new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'")}}static async importKey(e,t,r,n,s){switch(e.toLowerCase()){case"jwk":{const e=t;if(e.d){const e=Ar.fromJSON(t,{targetSchema:On.CurvePrivateKey});return this.importPrivateKey(e,r,n,s)}if(!e.x)throw new TypeError("keyData: Cannot get required 'x' filed");return this.importPublicKey(i.Convert.FromBase64Url(e.x),r,n,s)}case"raw":return this.importPublicKey(t,r,n,s);case"spki":{const e=Zt.parse(new Uint8Array(t),On.PublicKeyInfo);return this.importPublicKey(e.publicKey,r,n,s)}case"pkcs8":{const e=Zt.parse(new Uint8Array(t),On.PrivateKeyInfo),i=Zt.parse(e.privateKey,On.CurvePrivateKey);return this.importPrivateKey(i,r,n,s)}default:throw new Er("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'")}}static importPrivateKey(e,t,r,n){const s=new Gs;return s.fromJSON({crv:t.namedCurve,d:i.Convert.ToBase64Url(e.d)}),s.algorithm=Object.assign({},t),s.extractable=r,s.usages=n,s}static async importPublicKey(e,t,r,n){const s=new _s;return s.fromJSON({crv:t.namedCurve,x:i.Convert.ToBase64Url(e)}),s.algorithm=Object.assign({},t),s.extractable=r,s.usages=n,s}}qs.publicKeyUsages=["verify"],qs.privateKeyUsages=["sign","deriveKey","deriveBits"];class Ws extends _r{async onGenerateKey(e,t,r){const n=await qs.generateKey({name:this.name,namedCurve:e.namedCurve.replace(/^ed/i,"Ed")},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return qs.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return qs.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return qs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await qs.importKey(e,t,{...r,name:this.name},n,s))}}class Ys extends Gr{async onGenerateKey(e,t,r){const n=await qs.generateKey({name:this.name,namedCurve:e.namedCurve.toUpperCase()},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onDeriveBits(e,t,r){return await qs.deriveBits({...e,public:ts(e.public)},ts(t),r)}async onExportKey(e,t){return qs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await qs.importKey(e,t,{...r,name:this.name},n,s))}}class Xs extends Wn{constructor(t,r,n,s){super(),this.algorithm=t,this.extractable=r,this.usages=n,this.data=e.from(s)}toJWK(){return{kty:"OKP",crv:this.algorithm.name,key_ops:this.usages,ext:this.extractable}}}class Zs extends Xs{constructor(){super(...arguments),this.type="private"}toJWK(){const t=r.createPublicKey({key:this.data,format:"pem"}).export({format:"jwk"}),n=Cr.toUint8Array(this.data.toString()),s=er.parse(n,On.PrivateKeyInfo),i=er.parse(s.privateKey,On.EdPrivateKey).value;return{...super.toJWK(),...t,d:e.from(new Uint8Array(i)).toString("base64url")}}}class Qs extends Xs{constructor(){super(...arguments),this.type="public"}toJWK(){const e=r.createPublicKey({key:this.data,format:"pem"}).export({format:"jwk"});return{...super.toJWK(),...e}}}class ei{static async generateKey(e,t,n){const s=e.name.toLowerCase(),i=r.generateKeyPairSync(s,{publicKeyEncoding:{format:"pem",type:"spki"},privateKeyEncoding:{format:"pem",type:"pkcs8"}}),o={name:"ed25519"===s?"Ed25519":"X25519"},a=n.filter(e=>this.privateKeyUsages.includes(e)),c=n.filter(e=>this.publicKeyUsages.includes(e));return{privateKey:new Zs(o,t,a,i.privateKey),publicKey:new Qs(o,!0,c,i.publicKey)}}static async sign(t,n,s){const o=r.sign(null,e.from(s),n.data);return i.BufferSourceConverter.toArrayBuffer(o)}static async verify(t,n,s,i){return r.verify(null,e.from(i),n.data,s)}static async exportKey(e,t){switch(e){case"jwk":return t.toJWK();case"pkcs8":case"spki":return Cr.toArrayBuffer(t.data.toString());case"raw":{const e=t.toJWK();return i.Convert.FromBase64Url(e.x)}default:return Promise.reject(new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'"))}}static async importKey(t,n,s,o,a){switch(t){case"jwk":{const t=n;if(t.d){const r=new On.EdPrivateKey;r.value=i.BufferSourceConverter.toArrayBuffer(e.from(t.d,"base64url"));const n=new On.PrivateKeyInfo;n.privateKeyAlgorithm.algorithm="ed25519"===s.name.toLowerCase()?On.idEd25519:On.idX25519,n.privateKey=er.serialize(r);const c=er.serialize(n),u=Cr.fromBufferSource(c,"PRIVATE KEY");return new Zs(s,o,a,u)}if(t.x){const e=r.createPublicKey({format:"jwk",key:t}).export({format:"pem",type:"spki"});return new Qs(s,o,a,e)}throw new Er("keyData: Cannot import JWK. 'd' or 'x' must be presented")}case"pkcs8":{const e=Cr.fromBufferSource(n,"PRIVATE KEY");return new Zs(s,o,a,e)}case"spki":{const e=Cr.fromBufferSource(n,"PUBLIC KEY");return new Qs(s,o,a,e)}case"raw":{const e=n,t=r.createPublicKey({format:"jwk",key:{kty:"OKP",crv:"ed25519"===s.name.toLowerCase()?"Ed25519":"X25519",x:i.Convert.ToBase64Url(e)}}).export({format:"pem",type:"spki"});return new Qs(s,o,a,t)}default:return Promise.reject(new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'"))}}}ei.privateKeyUsages=["sign","deriveBits","deriveKey"],ei.publicKeyUsages=["verify"];class ti extends Ln{async onGenerateKey(e,t,r){const n=await ei.generateKey(e,t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){const n=ts(t);return ei.sign(e,n,new Uint8Array(r))}onVerify(e,t,r,n){const s=ts(t);return ei.verify(e,s,new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){const r=ts(t);return ei.exportKey(e,r)}async onImportKey(e,t,r,n,s){return rs(await ei.importKey(e,t,r,n,s))}}class ri extends Tn{async onGenerateKey(e,t,r){const n=await ei.generateKey(e,t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onDeriveBits(e,t,n){const s=ts(t),i=ts(e.public),o=r.createPublicKey({key:i.data.toString(),format:"pem",type:"spki"}),a=r.createPrivateKey({key:s.data.toString(),format:"pem",type:"pkcs8"}),c=r.diffieHellman({publicKey:o,privateKey:a});return new Uint8Array(c).buffer.slice(0,n>>3)}async onExportKey(e,t){const r=ts(t);return ei.exportKey(e,r)}async onImportKey(e,t,r,n,s){return rs(await ei.importKey(e,t,r,n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Xs))throw new TypeError("key: Is not a Ed25519CryptoKey")}}class ni extends Wn{}class si extends Vn{async onDeriveBits(t,n,s){return new Promise((o,a)=>{const c=i.BufferSourceConverter.toArrayBuffer(t.salt),u=t.hash.name.replace("-","");r.pbkdf2(ts(n).data,e.from(c),t.iterations,s>>3,u,(e,t)=>{e?a(e):o(new Uint8Array(t).buffer)})})}async onImportKey(t,r,n,s,i){if("raw"===t){const t=new ni;return t.data=e.from(r),t.algorithm={name:this.name},t.extractable=!1,t.usages=i,rs(t)}throw new Er("format: Must be 'raw'")}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ni))throw new TypeError("key: Is not PBKDF CryptoKey")}}class ii extends Wn{get alg(){return`HS${this.algorithm.hash.name.toUpperCase().replace("SHA-","")}`}set alg(e){}}tr([br({name:"k",converter:qn})],ii.prototype,"data",void 0);class oi extends Dn{async onGenerateKey(e,t,n){const s=(e.length||this.getDefaultLength(e.hash.name))>>3<<3,i=new ii;return i.algorithm={...e,length:s,name:this.name},i.extractable=t,i.usages=n,i.data=r.randomBytes(s>>3),rs(i)}async onSign(t,n,s){const i=Cs.getAlgorithmName(n.algorithm.hash),o=r.createHmac(i,ts(n).data).update(e.from(s)).digest();return new Uint8Array(o).buffer}async onVerify(t,n,s,i){const o=Cs.getAlgorithmName(n.algorithm.hash);return 0===r.createHmac(o,ts(n).data).update(e.from(i)).digest().compare(e.from(s))}async onImportKey(t,r,n,s,i){let o;switch(t.toLowerCase()){case"jwk":o=Ar.fromJSON(r,{targetSchema:ii});break;case"raw":o=new ii,o.data=e.from(r);break;default:throw new Er("format: Must be 'jwk' or 'raw'")}return o.algorithm={hash:{name:n.hash.name},name:this.name,length:o.data.length<<3},o.extractable=s,o.usages=i,rs(o)}async onExportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(ts(t));case"raw":return new Uint8Array(ts(t).data).buffer;default:throw new Er("format: Must be 'jwk' or 'raw'")}}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ii))throw new TypeError("key: Is not HMAC CryptoKey")}}class ai extends Wn{}class ci extends Rn{async onImportKey(t,r,n,s,i){if("raw"!==t.toLowerCase())throw new Er("Operation not supported");const o=new ai;return o.data=e.from(r),o.algorithm={name:this.name},o.extractable=s,o.usages=i,rs(o)}async onDeriveBits(t,n,s){const o=t.hash.name.replace("-",""),a=r.createHash(o).digest().length,c=s/8,u=i.BufferSourceConverter.toUint8Array(t.info),l=r.createHmac(o,i.BufferSourceConverter.toUint8Array(t.salt)).update(i.BufferSourceConverter.toUint8Array(ts(n).data)).digest(),h=[e.alloc(0)],y=Math.ceil(c/a)+1;for(let t=1;t<y;++t)h.push(r.createHmac(o,l).update(e.concat([h[t-1],u,e.from([t])])).digest());return e.concat(h).slice(0,c)}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ai))throw new TypeError("key: Is not HKDF CryptoKey")}}class ui{static digest(t,n){const s=r.createHash(t.name.toLowerCase(),{outputLength:t.length}).update(e.from(n)).digest();return new Uint8Array(s).buffer}}class li extends $n{async onDigest(e,t){return ui.digest(e,t)}}class hi extends Jn{async onDigest(e,t){return ui.digest(e,t)}}class yi extends _n{constructor(){var e;super(),this.providers.set(new ns),this.providers.set(new fs),this.providers.set(new ps),this.providers.set(new ys),this.providers.set(new gs),this.providers.set(new ms);r.getCiphers().includes("des-cbc")&&this.providers.set(new vs),this.providers.set(new As),this.providers.set(new Es),this.providers.set(new Ks),this.providers.set(new xs),this.providers.set(new Ns),this.providers.set(new Js),this.providers.set(new js),this.providers.set(new Hs),this.providers.set(new Ts),this.providers.set(new Ls),this.providers.set(new Ds),this.providers.set(new si),this.providers.set(new oi),this.providers.set(new ci);const n=null===(e=/^v(\d+)/.exec(t))||void 0===e?void 0:e[1];n&&parseInt(n,10)>=12&&(this.providers.set(new li),this.providers.set(new hi));const s=r.getHashes();s.includes("sha3-256")&&this.providers.set(new Vs),s.includes("sha3-384")&&this.providers.set(new Rs),s.includes("sha3-512")&&this.providers.set(new Ms),n&&parseInt(n,10)>=14&&(this.providers.set(new Ws),this.providers.set(new Ys),this.providers.set(new ti),this.providers.set(new ri))}}class fi extends jn{constructor(){super(...arguments),this.subtle=new yi}getRandomValues(t){if(!ArrayBuffer.isView(t))throw new TypeError("Failed to execute 'getRandomValues' on 'Crypto': parameter 1 is not of type 'ArrayBufferView'");const n=e.from(t.buffer,t.byteOffset,t.byteLength);return r.randomFillSync(n),t}}export{fi as Crypto,zr as CryptoKey};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockcerts/blockcerts-verifier",
3
- "version": "1.72.3",
3
+ "version": "1.73.0",
4
4
  "description": "A standalone universal viewer and verifier for blockcerts credentials",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,7 +11,7 @@
11
11
  "node": ">=20.0.0"
12
12
  },
13
13
  "dependencies": {
14
- "@blockcerts/cert-verifier-js": "^6.35.1",
14
+ "@blockcerts/cert-verifier-js": "^6.36.0",
15
15
  "@blockcerts/cert-verifier-js-v1-legacy": "^4.0.2",
16
16
  "@polymer/lit-element": "0.5.1",
17
17
  "@polymer/polymer": "3.5.2",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@commitlint/cli": "^20.1.0",
34
- "@commitlint/config-conventional": "^20.5.0",
34
+ "@commitlint/config-conventional": "^21.2.0",
35
35
  "@eslint/js": "^10.0.1",
36
36
  "@open-wc/testing": "^4.0.0",
37
37
  "@rollup/plugin-commonjs": "^29.0.2",
@@ -41,11 +41,11 @@
41
41
  "@rollup/plugin-typescript": "^12.1.2",
42
42
  "@types/mocha": "^10.0.10",
43
43
  "@types/qrcode-svg": "^1.1.1",
44
- "@types/sinon": "^21.0.0",
44
+ "@types/sinon": "^22.0.0",
45
45
  "@typescript-eslint/eslint-plugin": "^8.30.1",
46
46
  "@typescript-eslint/parser": "^8.23.0",
47
- "@vitest/coverage-istanbul": "^4.0.6",
48
- "@web/test-runner": "^0.20.1",
47
+ "@vitest/coverage-istanbul": "^4.1.10",
48
+ "@web/test-runner": "^1.0.0",
49
49
  "concurrently": "^9.1.2",
50
50
  "eslint": "^10.0.3",
51
51
  "express": "^5.1.0",
@@ -56,12 +56,12 @@
56
56
  "rollup-plugin-livereload": "^2.0.0",
57
57
  "rollup-plugin-serve": "^3.0.0",
58
58
  "rollup-plugin-visualizer": "^7.0.0",
59
- "sinon": "^21.0.0",
60
- "stylelint": "^16.9.0",
59
+ "sinon": "^22.0.0",
60
+ "stylelint": "^17.7.0",
61
61
  "stylelint-config-standard-scss": "^15.0.1",
62
62
  "typescript": "^5.8.3",
63
63
  "typescript-eslint": "^8.29.1",
64
- "vitest": "^4.0.6",
64
+ "vitest": "^4.1.10",
65
65
  "wc-sass-render": "blockchain-certificates/wc-sass-render"
66
66
  },
67
67
  "scripts": {