signify-ts 0.1.1 → 0.2.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 (115) hide show
  1. package/README.md +96 -47
  2. package/dist/buffer-polyfill.d.ts +1 -0
  3. package/dist/exports.d.ts +40 -0
  4. package/dist/index.d.ts +4 -3
  5. package/dist/keri/app/aiding.d.ts +138 -0
  6. package/dist/keri/app/clienting.d.ts +182 -0
  7. package/dist/keri/app/contacting.d.ts +93 -0
  8. package/dist/keri/app/controller.d.ts +49 -0
  9. package/dist/keri/app/coring.d.ts +121 -0
  10. package/dist/keri/app/credentialing.d.ts +239 -0
  11. package/dist/keri/app/escrowing.d.ts +19 -0
  12. package/dist/keri/app/exchanging.d.ts +60 -0
  13. package/dist/keri/app/grouping.d.ts +44 -0
  14. package/dist/keri/app/habery.d.ts +48 -47
  15. package/dist/keri/app/notifying.d.ts +34 -0
  16. package/dist/keri/core/authing.d.ts +10 -9
  17. package/dist/keri/core/bexter.d.ts +7 -0
  18. package/dist/keri/core/cigar.d.ts +8 -8
  19. package/dist/keri/core/cipher.d.ts +5 -5
  20. package/dist/keri/core/core.d.ts +59 -53
  21. package/dist/keri/core/counter.d.ts +43 -43
  22. package/dist/keri/core/decrypter.d.ts +10 -10
  23. package/dist/keri/core/diger.d.ts +21 -21
  24. package/dist/keri/core/encrypter.d.ts +9 -9
  25. package/dist/keri/core/eventing.d.ts +54 -21
  26. package/dist/keri/core/httping.d.ts +44 -34
  27. package/dist/keri/core/indexer.d.ts +98 -88
  28. package/dist/keri/core/keeping.d.ts +103 -1
  29. package/dist/keri/core/kering.d.ts +5 -5
  30. package/dist/keri/core/manager.d.ts +174 -172
  31. package/dist/keri/core/matter.d.ts +116 -69
  32. package/dist/keri/core/number.d.ts +7 -6
  33. package/dist/keri/core/pather.d.ts +7 -0
  34. package/dist/keri/core/prefixer.d.ts +15 -15
  35. package/dist/keri/core/saider.d.ts +23 -23
  36. package/dist/keri/core/salter.d.ts +23 -23
  37. package/dist/keri/core/seqner.d.ts +15 -0
  38. package/dist/keri/core/serder.d.ts +31 -23
  39. package/dist/keri/core/siger.d.ts +18 -18
  40. package/dist/keri/core/signer.d.ts +34 -34
  41. package/dist/keri/core/tholder.d.ts +29 -14
  42. package/dist/keri/core/utils.d.ts +20 -15
  43. package/dist/keri/core/vdring.d.ts +16 -0
  44. package/dist/keri/core/verfer.d.ts +13 -12
  45. package/dist/keri/end/ending.d.ts +13 -13
  46. package/dist/math.d.ts +1 -0
  47. package/dist/ready.d.ts +1 -0
  48. package/dist/signify-ts.cjs +7835 -0
  49. package/dist/signify-ts.cjs.development.js +6369 -256
  50. package/dist/signify-ts.cjs.development.js.map +1 -1
  51. package/dist/signify-ts.cjs.map +7 -0
  52. package/dist/signify-ts.cjs.production.min.js +1 -1
  53. package/dist/signify-ts.cjs.production.min.js.map +1 -1
  54. package/dist/signify-ts.esm.js +6205 -229
  55. package/dist/signify-ts.esm.js.map +1 -1
  56. package/dist/signify-ts.mjs +7811 -0
  57. package/dist/signify-ts.mjs.map +7 -0
  58. package/package.json +49 -49
  59. package/src/buffer-polyfill.ts +5 -0
  60. package/src/exports.ts +44 -0
  61. package/src/index.ts +4 -5
  62. package/src/keri/app/aiding.ts +493 -0
  63. package/src/keri/app/clienting.ts +492 -0
  64. package/src/keri/app/contacting.ts +188 -0
  65. package/src/keri/app/controller.ts +372 -0
  66. package/src/keri/app/coring.ts +225 -0
  67. package/src/keri/app/credentialing.ts +820 -0
  68. package/src/keri/app/escrowing.ts +34 -0
  69. package/src/keri/app/exchanging.ts +220 -0
  70. package/src/keri/app/grouping.ts +90 -0
  71. package/src/keri/app/habery.ts +118 -85
  72. package/src/keri/app/notifying.ts +69 -0
  73. package/src/keri/core/authing.ts +73 -85
  74. package/src/keri/core/bexter.ts +138 -0
  75. package/src/keri/core/cigar.ts +10 -11
  76. package/src/keri/core/cipher.ts +23 -14
  77. package/src/keri/core/core.ts +223 -81
  78. package/src/keri/core/counter.ts +182 -116
  79. package/src/keri/core/decrypter.ts +48 -34
  80. package/src/keri/core/diger.ts +23 -22
  81. package/src/keri/core/encrypter.ts +37 -27
  82. package/src/keri/core/eventing.ts +468 -106
  83. package/src/keri/core/httping.ts +151 -105
  84. package/src/keri/core/indexer.ts +313 -211
  85. package/src/keri/core/keeping.ts +679 -3
  86. package/src/keri/core/kering.ts +4 -6
  87. package/src/keri/core/manager.ts +660 -499
  88. package/src/keri/core/matter.ts +382 -148
  89. package/src/keri/core/number.ts +56 -11
  90. package/src/keri/core/pather.ts +98 -0
  91. package/src/keri/core/prefixer.ts +122 -101
  92. package/src/keri/core/saider.ts +104 -76
  93. package/src/keri/core/salter.ts +71 -40
  94. package/src/keri/core/seqner.ts +46 -0
  95. package/src/keri/core/serder.ts +102 -38
  96. package/src/keri/core/siger.ts +19 -18
  97. package/src/keri/core/signer.ts +73 -53
  98. package/src/keri/core/tholder.ts +196 -30
  99. package/src/keri/core/utils.ts +121 -50
  100. package/src/keri/core/vdring.ts +94 -0
  101. package/src/keri/core/verfer.ts +22 -9
  102. package/src/keri/end/ending.ts +111 -101
  103. package/src/math.ts +3 -0
  104. package/src/ready.ts +5 -0
  105. package/dist/keri/app/accountant.d.ts +0 -10
  106. package/dist/keri/app/apping.d.ts +0 -1
  107. package/dist/keri/app/client.d.ts +0 -7
  108. package/dist/keri/app/signify.d.ts +0 -6
  109. package/src/keri/app/accountant.ts +0 -35
  110. package/src/keri/app/apping.ts +0 -12
  111. package/src/keri/app/client.ts +0 -30
  112. package/src/keri/app/signify.ts +0 -12
  113. package/src/keri/app/tsconfig.json +0 -100
  114. package/src/keri/core/tsconfig.json +0 -100
  115. package/src/keri/end/tsconfig.json +0 -100
@@ -1,2 +1,2 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("libsodium-wrappers-sumo")),t=require("util"),n=e(require("urlsafe-base64")),i=require("buffer"),o=require("blake3");function s(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e,r){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?i:String(i),n)}var i}function a(e,r,t){return r&&s(e.prototype,r),t&&s(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function h(){return(h=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)}function d(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,u(e,r)}function u(e,r){return(u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e})(e,r)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function c(e,r,t){return(c=l()?Reflect.construct.bind():function(e,r,t){var n=[null];n.push.apply(n,r);var i=new(Function.bind.apply(e,n));return t&&u(i,t.prototype),i}).apply(null,arguments)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function w(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return p(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?p(e,void 0):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var v,_,g=function(){function e(e){this._err=new Error(e)}return a(e,[{key:"err",get:function(){return this._err}}]),e}();!function(e){e.JSON="JSON"}(v||(v={})),function(e){e.KERI="KERI"}(_||(_={}));var b=new function(e,r){void 0===e&&(e=1),void 0===r&&(r=0),this.major=e,this.minor=r},y=new t.TextEncoder,E=new t.TextDecoder;function m(e){var r,t,n=b,i=new RegExp("KERI([0-9a-f])([0-9a-f])([A-Z]{4})([0-9a-f]{6})_").exec(e);if(i){var o=[+i[1],+i[2],i[3],i[4]];if(n.major=o[0],n.minor=o[1],r=o[2],t=o[3],!Object.values(v).includes(r))throw new Error("Invalid serialization kind = "+r);return[r=v[r],n,t]}throw new Error("Invalid version string = "+e)}function k(e,r,t,n){return void 0===e&&(e=_.KERI),void 0===t&&(t=v.JSON),void 0===n&&(n=0),""+e+(r=null==r?b:r).major.toString(16)+r.minor.toString()+t+n.toString(16).padStart(6,"0")+"_"}var S=new Map([[0,"A"],[1,"B"],[2,"C"],[3,"D"],[4,"E"],[5,"F"],[6,"G"],[7,"H"],[8,"I"],[9,"J"],[10,"K"],[11,"L"],[12,"M"],[13,"N"],[14,"O"],[15,"P"],[16,"Q"],[17,"R"],[18,"S"],[19,"T"],[20,"U"],[21,"V"],[22,"W"],[23,"X"],[24,"Y"],[25,"Z"],[26,"a"],[27,"b"],[28,"c"],[29,"d"],[30,"e"],[31,"f"],[32,"g"],[33,"h"],[34,"i"],[35,"j"],[36,"k"],[37,"l"],[38,"m"],[39,"n"],[40,"o"],[41,"p"],[42,"q"],[43,"r"],[44,"s"],[45,"t"],[46,"u"],[47,"v"],[48,"w"],[49,"x"],[50,"y"],[51,"z"],[52,"0"],[53,"1"],[54,"2"],[55,"3"],[56,"4"],[57,"5"],[58,"6"],[59,"7"],[60,"8"],[61,"9"],[62,"-"],[63,"_"]]),q=new Map(Array.from(S,(function(e){return[e[1],e[0]]})));function x(e,r){void 0===r&&(r=1);for(var t="";0!=r&&(t=S.get(e%64)+t,0!=(e=Math.floor(e/64))););for(var n=r-t.length,i=0;i<n;i++)t="A"+t;return t}function A(e){if(0==e.length)throw new Error("Empty string, conversion undefined.");var r=0;return[].concat(e).reverse().forEach((function(e,t){r|=q.get(e)<<6*t})),r}function M(e){return y.encode(e)}function I(e){return E.decode(e)}function B(e){for(var r=0,t=0;t<e.length;t++)r=256*r+e[t];return r}var z=function(){function e(){}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}(),N=function(e){function r(){var r;return(r=e.apply(this,arguments)||this).Ed25519_Seed="A",r.Ed25519N="B",r.X25519="C",r.Ed25519="D",r.Blake3_256="E",r.X25519_Private="O",r.X25519_Cipher_Seed="P",r.X25519_Cipher_Salt="1AAH",r.Salt_128="0A",r.Ed25519_Sig="0B",r}return d(r,e),r}(z),P=new N,C=function(e){function r(){var r;return(r=e.apply(this,arguments)||this).Ed25519N="B",r.ECDSA_256k1N="1AAA",r.Ed448N="1AAC",r}return d(r,e),r}(z),D=new C,O=function(e){function r(){var r;return(r=e.apply(this,arguments)||this).Blake3_256="E",r.Blake2b_256="F",r.Blake2s_256="G",r.SHA3_256="H",r.SHA2_256="I",r.Blake3_512="0D",r.Blake2b_512="0E",r.SHA3_512="0F",r.SHA2_512="0G",r}return d(r,e),r}(z),U=new O,T=function(e,r,t,n){this.hs=e,this.ss=r,this.fs=t,this.ls=n},j=function(){function e(r){var t=r.raw,n=r.code,i=void 0===n?P.Ed25519N:n,o=r.qb64b,s=r.qb64,a=r.qb2;if(this._code="",this._size=-1,this._raw=new Uint8Array(0),null!=t){if(0==i.length)throw new Error("Improper initialization need either (raw and code) or qb64b or qb64 or qb2.");if(-1==e.Sizes.get(i).fs)throw new Error("Unsupported variable size code="+i);var h=e._rawSize(i);if((t=t.slice(0,h)).length!=h)throw new Error("Not enougth raw bytes for code="+i+" expected "+h+" got "+t.length+".");this._code=i,this._size=-1,this._raw=t}else if(void 0!==s)this._exfil(s);else if(void 0!==o){var d=I(o);this._exfil(d)}else{if(void 0===a)throw new g("EmptyMaterialError");this._bexfil(a)}}e._rawSize=function(e){var r=this.Sizes.get(e),t=r.hs+r.ss;if(-1===r.fs)throw Error("Non-fixed raw size code "+e+".");return Math.floor(3*(r.fs-t)/4)-r.ls},e._leadSize=function(e){return this.Sizes.get(e).ls};var r=e.prototype;return r._infil=function(){var r=this.code,t=this.raw,o=(3-t.length%3)%3,s=e.Sizes.get(r);if(-1===s.fs)throw new Error("Variable sized codes not supported... yet");var a=r,h=a.length;if(h%4!=o-s.ls)throw new Error("Invalid code="+a+" for converted raw pad size="+o+", "+t.length+".");for(var d=new Uint8Array(o+t.length),u=0;u<o;u++)d[u]=0;for(var l=0;l<t.length;l++)d[l+o]=t[l];return a+n.encode(i.Buffer.from(d)).slice(h%4)},r._exfil=function(r){if(0==r.length)throw new Error("Empty Material");var t=r[0];if(!Array.from(e.Hards.keys()).includes(t))throw new Error("Unexpected code "+t);var i=e.Hards.get(t);if(r.length<i)throw new Error("Shortage Error");var o=r.slice(0,i);if(!Array.from(e.Sizes.keys()).includes(o))throw new Error("Unsupported code "+o);var s,a=e.Sizes.get(o),h=a.hs+a.ss;if(-1==a.fs)throw new Error("Variable size codes not supported yet");if(s=a.fs,r.length<a.fs)throw new Error("Need "+(a.fs-r.length)+" more chars.");r=r.slice(0,a.fs);var d,u=h%4,l=2*(0==u?a.ls:u);if(0!=u){var c=new Array(u+1).join("A")+r.slice(h),f=n.decode(c);if(B(f.subarray(0,u))&Math.pow(2,l)-1)throw new Error("Non zeroed prepad bits = {pi & (2 ** pbs - 1 ):<06b} in {qb64b[cs:cs+1]}.");d=f.subarray(u)}else{var p=r.slice(h),w=n.decode(p),v=B(w.subarray(0,a.ls));if(0!=v)throw 1==v?new Error("Non zeroed lead byte = 0x{li:02x}."):new Error("Non zeroed lead bytes = 0x{li:04x}");d=w.subarray(a.ls)}this._code=o,this._size=s,this._raw=Uint8Array.from(d)},r._bexfil=function(e){throw new Error("qb2 not yet supported: "+e)},a(e,[{key:"code",get:function(){return this._code}},{key:"size",get:function(){return this._size}},{key:"raw",get:function(){return this._raw}},{key:"qb64",get:function(){return this._infil()}},{key:"qb64b",get:function(){return M(this.qb64)}},{key:"transferable",get:function(){return!D.has(this.code)}},{key:"digestive",get:function(){return U.has(this.code)}},{key:"both",get:function(){var r=e.Sizes.get(this.code);return""+this.code+x(this.size,r.ls)}}]),e}();j.Sizes=new Map(Object.entries({A:new T(1,0,44,0),B:new T(1,0,44,0),C:new T(1,0,44,0),D:new T(1,0,44,0),E:new T(1,0,44,0),O:new T(1,0,44,0),P:new T(1,0,124,0),"0A":new T(2,0,24,0),"0B":new T(2,0,88,0),"1AAH":new T(4,0,100,0)})),j.Hards=new Map([["A",1],["B",1],["C",1],["D",1],["E",1],["F",1],["G",1],["H",1],["I",1],["J",1],["K",1],["L",1],["M",1],["N",1],["O",1],["P",1],["Q",1],["R",1],["S",1],["T",1],["U",1],["V",1],["W",1],["X",1],["Y",1],["Z",1],["a",1],["b",1],["c",1],["d",1],["e",1],["f",1],["g",1],["h",1],["i",1],["j",1],["k",1],["l",1],["m",1],["n",1],["o",1],["p",1],["q",1],["r",1],["s",1],["t",1],["u",1],["v",1],["w",1],["x",1],["y",1],["z",1],["0",2],["1",4],["2",4],["3",4],["4",2],["5",2],["6",2],["7",4],["8",4],["9",4]]);var R=function(e){function t(r){var t;if(t=e.call(this,{raw:r.raw,code:r.code,qb64:r.qb64,qb64b:r.qb64b,qb2:r.qb2})||this,!Array.from([P.Ed25519N,P.Ed25519]).includes(t.code))throw new Error("Unsupported code = "+t.code+" for verifier.");return t._verify=t._ed25519,t}d(t,e);var n=t.prototype;return n.verify=function(e,r){return this._verify(e,r,this.raw)},n._ed25519=function(e,t,n){try{return r.crypto_sign_verify_detached(e,t,n)}catch(e){throw new Error(e)}},t}(j),H=function(e){function r(r,t){var n;return(n=e.call(this,{raw:r.raw,code:r.code,qb64:r.qb64,qb64b:r.qb64b,qb2:r.qb2})||this)._verfer=t,n}return d(r,e),a(r,[{key:"verfer",get:function(){return this._verfer},set:function(e){this._verfer=e}}]),r}(j),X=new function(){this.Ed25519_Sig="A",this.Ed25519_Crt_Sig="B",this.ECDSA_256k1_Sig="C",this.ECDSA_256k1_Crt_Sig="D",this.Ed448_Sig="0A",this.Ed448_Crt_Sig="0B",this.Ed25519_Big_Sig="2A",this.Ed25519_Big_Crt_Sig="2B",this.ECDSA_256k1_Big_Sig="2C",this.ECDSA_256k1_Big_Crt_Sig="2D",this.Ed448_Big_Sig="3A",this.Ed448_Big_Crt_Sig="3B"},G=new(function(){function e(){this.Ed25519_Sig="A",this.Ed25519_Crt_Sig="B",this.ECDSA_256k1_Sig="C",this.ECDSA_256k1_Crt_Sig="D",this.Ed448_Sig="0A",this.Ed448_Crt_Sig="0B",this.Ed25519_Big_Sig="2A",this.Ed25519_Big_Crt_Sig="2B",this.ECDSA_256k1_Big_Sig="2C",this.ECDSA_256k1_Big_Crt_Sig="2D",this.Ed448_Big_Sig="3A",this.Ed448_Big_Crt_Sig="3B"}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}()),L=new(function(){function e(){this.Ed25519_Crt_Sig="B",this.ECDSA_256k1_Crt_Sig="D",this.Ed448_Crt_Sig="0B",this.Ed25519_Big_Crt_Sig="2B",this.ECDSA_256k1_Big_Crt_Sig="2D",this.Ed448_Big_Crt_Sig="3B"}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}()),J=new(function(){function e(){this.Ed25519_Sig="A",this.ECDSA_256k1_Sig="C",this.Ed448_Sig="0A",this.Ed25519_Big_Sig="2A",this.ECDSA_256k1_Big_Sig="2C",this.Ed448_Big_Sig="3A"}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}()),F=function(e,r,t,n,i){this.hs=e,this.ss=r,this.os=t,this.fs=n,this.ls=i},K=function(){function e(r){var t=r.raw,n=void 0===t?void 0:t,i=r.code,o=void 0===i?X.Ed25519_Sig:i,s=r.index,a=void 0===s?0:s,h=r.ondex,d=void 0===h?void 0:h,u=r.qb64b,l=void 0===u?void 0:u,c=r.qb64,f=void 0===c?void 0:c,p=r.qb2,w=void 0===p?void 0:p;if(this.Codex=X,this._code="",this._index=-1,this._raw=new Uint8Array(0),null!=n){if(null==o)throw new g("Improper initialization need either (raw and code) or qb64b or qb64 or qb2.");if(!e.Sizes.has(o))throw new Error("Unsupported code="+o+".");var v=e.Sizes.get(o),_=v.os,b=v.fs,y=v.hs+v.ss,E=v.ss-v.os;if(!Number.isInteger(a)||a<0||a>Math.pow(64,E)-1)throw new Error("Invalid index="+a+" for code="+o+".");if(null!=d&&0!=v.os&&!(d>=0&&d<=Math.pow(64,_)-1))throw new Error("Invalid ondex="+d+" for code="+o+".");if(L.has(o)&&null!=d)throw new Error("Non None ondex="+d+" for code="+o+".");if(J.has(o))if(null==d)d=a;else if(d!=a&&0==_)throw new Error("Non matching ondex="+d+" and index="+a+" for code="+o+".");if(null==b)throw new Error("variable length unsupported");var m=Math.floor(3*(b-y)/4);if((n=n.slice(0,m)).length!=m)throw new Error("Not enougth raw bytes for code="+o+" and index="+a+" ,expected "+m+" got "+n.length+".");this._code=o,this._index=a,this._ondex=d,this._raw=n}else if(null!=l){var k=I(l);this._exfil(k)}else if(null!=f)this._exfil(f);else{if(null==w)throw new g("Improper initialization need either (raw and code and index) or qb64b or qb64 or qb2.");this._bexfil(w)}}var r=e.prototype;return r._bexfil=function(e){throw new Error("qb2 not yet supported: "+e)},e._rawSize=function(r){var t=e.Sizes.get(r);return Math.floor(t.fs-3*(t.hs+t.ss)/4)},r._infil=function(){var r=this.code,t=this.index,o=this.ondex,s=this.raw,a=(3-s.length%3)%3,h=e.Sizes.get(r),d=h.hs+h.ss,u=h.ss-h.os;if(t<0||t>Math.pow(64,u)-1)throw new Error("Invalid index="+t+" for code="+r+".");if(null!=o&&0!=h.os&&!(o>=0&&o<=Math.pow(64,h.os)-1))throw new Error("Invalid ondex="+o+" for os="+h.os+" and code="+r+".");var l=""+r+x(t,u)+x(null==o?0:o,h.os);if(l.length!=d)throw new Error("Mismatch code size = "+d+" with table = "+l.length+".");if(d%4!=a-h.ls)throw new Error("Invalid code="+l+" for converted raw pad size="+a+".");for(var c=new Uint8Array(a+s.length),f=0;f<a;f++)c[f]=0;for(var p=0;p<s.length;p++)c[p+a]=s[p];var w=l+n.encode(i.Buffer.from(c)).slice(a-h.ls);if(w.length!=h.fs)throw new Error("Invalid code="+l+" for raw size="+s.length+".");return w},r._exfil=function(r){if(0==r.length)throw new Error("Empty Material");var t=r[0];if(!Array.from(e.Hards.keys()).includes(t))throw new Error("Unexpected code "+t);var i=e.Hards.get(t);if(r.length<i)throw new Error("Need "+(i-r.length)+" more characters.");var o=r.slice(0,i);if(!Array.from(e.Sizes.keys()).includes(o))throw new Error("Unsupported code "+o);var s=e.Sizes.get(o),a=s.hs+s.ss,h=s.ss-s.os;if(r.length<a)throw new Error("Need "+(a-r.length)+" more characters.");var d,u=A(r.slice(i,i+h)),l=r.slice(i+h,i+h+s.os);if(L.has(o)){if(0!=(d=0!=s.os?A(l):void 0)&&null!=d)throw new Error("Invalid ondex="+d+" for code="+o+".");d=void 0}else d=0!=s.os?A(l):u;if(null==s.fs)throw new Error("variable length not supported");if(r.length<s.fs)throw new Error("Need "+(s.fs-r.length)+" more chars.");r=r.slice(0,s.fs);var c,f=a%4,p=2*f!=0?f:s.ls;if(0!=f){var w=new Array(f+1).join("A")+r.slice(a),v=n.decode(w);if(B(v.slice(0,f))&Math.pow(2,p)-1)throw new Error("Non zeroed prepad bits = {pi & (2 ** pbs - 1 ):<06b} in {qb64b[cs:cs+1]}.");c=v.slice(f)}else{var _=r.slice(a),g=n.decode(_),b=B(g.slice(0,s.ls));if(0!=b)throw 1==b?new Error("Non zeroed lead byte = 0x{li:02x}."):new Error("Non zeroed lead bytes = 0x{li:04x}");c=g.slice(s.ls)}if(c.length!=Math.floor(3*(r.length-a)/4))throw new Error("Improperly qualified material = "+r);this._code=o,this._index=u,this._ondex=d,this._raw=new Uint8Array(c)},a(e,[{key:"code",get:function(){return this._code}},{key:"raw",get:function(){return this._raw}},{key:"index",get:function(){return this._index}},{key:"ondex",get:function(){return this._ondex}},{key:"qb64",get:function(){return this._infil()}},{key:"qb64b",get:function(){return M(this.qb64)}}]),e}();K.Hards=new Map([["A",1],["B",1],["C",1],["D",1],["E",1],["F",1],["G",1],["H",1],["I",1],["J",1],["K",1],["L",1],["M",1],["N",1],["O",1],["P",1],["Q",1],["R",1],["S",1],["T",1],["U",1],["V",1],["W",1],["X",1],["Y",1],["Z",1],["a",1],["b",1],["c",1],["d",1],["e",1],["f",1],["g",1],["h",1],["i",1],["j",1],["k",1],["l",1],["m",1],["n",1],["o",1],["p",1],["q",1],["r",1],["s",1],["t",1],["u",1],["v",1],["w",1],["x",1],["y",1],["z",1],["0",2],["1",2],["2",2],["3",2],["4",2]]),K.Sizes=new Map(Object.entries({A:new F(1,1,0,88,0),B:new F(1,1,0,88,0),C:new F(1,1,0,88,0),D:new F(1,1,0,88,0),"0A":new F(2,2,1,156,0),"0B":new F(2,2,1,156,0),"2A":new F(2,4,2,92,0),"2B":new F(2,4,2,92,0),"2C":new F(2,4,2,92,0),"2D":new F(2,4,2,92,0),"3A":new F(2,6,3,160,0),"3B":new F(2,6,3,160,0),"0z":new F(2,2,0,void 0,0),"1z":new F(2,2,1,76,1),"4z":new F(2,6,3,80,1)}));var V,Y=function(e){function r(r,t){var n;if(n=e.call(this,{raw:r.raw,code:r.code,index:r.index,ondex:r.ondex,qb64:r.qb64,qb64b:r.qb64b,qb2:r.qb2})||this,!G.has(n.code))throw new Error("Invalid code = "+n.code+" for Siger.");return n._verfer=t,n}return d(r,e),a(r,[{key:"verfer",get:function(){return this._verfer},set:function(e){this._verfer=e}}]),r}(K),Z=function(e){function t(t){var n,i,o=t.raw,s=t.code,a=void 0===s?P.Ed25519_Seed:s,h=t.qb64,d=t.qb64b,u=t.qb2,l=t.transferable,c=void 0===l||l;try{n=e.call(this,{raw:o,code:a,qb64:h,qb64b:d,qb2:u})||this}catch(t){if(!(t instanceof g))throw t;if(a!=P.Ed25519_Seed)throw new Error("Unsupported signer code = "+a+".");var p=r.randombytes_buf(r.crypto_sign_SEEDBYTES);n=e.call(this,{raw:p,code:a,qb64:h,qb64b:d,qb2:u})||this}if(n.code!=P.Ed25519_Seed)throw new Error("Unsupported signer code = "+n.code+".");n._sign=n._ed25519;var w=r.crypto_sign_seed_keypair(n.raw);return i=new R({raw:w.publicKey,code:c?P.Ed25519:P.Ed25519N}),n._verfer=i,f(n)}d(t,e);var n=t.prototype;return n.sign=function(e,r,t,n){return void 0===r&&(r=null),void 0===t&&(t=!1),void 0===n&&(n=void 0),this._sign(e,this.raw,this.verfer,r,t,n)},n._ed25519=function(e,t,n,o,s,a){void 0===s&&(s=!1);var h,d=r.crypto_sign_detached(e,i.Buffer.concat([t,n.raw]));return null==o?new H({raw:d,code:P.Ed25519_Sig},n):(s?(a=void 0,h=o<=63?X.Ed25519_Crt_Sig:X.Ed25519_Big_Crt_Sig):(null==a&&(a=o),h=a==o&&o<=63?X.Ed25519_Sig:X.Ed25519_Big_Sig),new Y({raw:d,code:h,index:o,ondex:a},n))},a(t,[{key:"verfer",get:function(){return this._verfer}}]),t}(j),Q=function(e){function t(t){var n,i=t.raw,o=t.code,s=void 0===o?P.Salt_128:o,a=t.tier,h=void 0===a?"low":a,d=t.qb64,u=t.qb64b,l=t.qb2;try{n=e.call(this,{raw:i,code:s,qb64:d,qb64b:u,qb2:l})||this}catch(t){if(!(t instanceof g))throw t;if(s!=P.Salt_128)throw new Error("invalid code for Salter, only Salt_128 accepted");var c=r.randombytes_buf(r.crypto_pwhash_SALTBYTES);n=e.call(this,{raw:c,code:s})||this}if(n.code!=P.Salt_128)throw new Error("invalid code for Salter, only Salt_128 accepted");return n._tier=null!==h?h:"low",f(n)}d(t,e);var n=t.prototype;return n.stretch=function(e,t,n,i){var o,s;if(void 0===e&&(e=32),void 0===t&&(t=""),void 0===n&&(n=null),void 0===i&&(i=!1),n=null==n?this.tier:n,i)o=r.crypto_pwhash_OPSLIMIT_MIN,s=r.crypto_pwhash_MEMLIMIT_MIN;else switch(n){case"low":o=r.crypto_pwhash_OPSLIMIT_INTERACTIVE,s=r.crypto_pwhash_MEMLIMIT_INTERACTIVE;break;case"med":o=r.crypto_pwhash_OPSLIMIT_MODERATE,s=r.crypto_pwhash_MEMLIMIT_MODERATE;break;case"high":o=r.crypto_pwhash_OPSLIMIT_SENSITIVE,s=r.crypto_pwhash_MEMLIMIT_SENSITIVE;break;default:throw new Error("Unsupported security tier = "+n+".")}return r.crypto_pwhash(e,t,this.raw,o,s,r.crypto_pwhash_ALG_DEFAULT)},n.signer=function(e,r,t,n,i){void 0===e&&(e=P.Ed25519_Seed),void 0===r&&(r=!0),void 0===t&&(t=""),void 0===n&&(n=null),void 0===i&&(i=!1);var o=this.stretch(j._rawSize(e),t,n,i);return new Z({raw:o,code:e,transferable:r})},a(t,[{key:"tier",get:function(){return this._tier}}]),t}(j),W=function(e){function t(t,n){var i,o=t.raw,s=t.code,a=void 0===s?P.X25519_Private:s,h=t.qb64,d=t.qb64b,u=t.qb2;void 0===n&&(n=void 0);try{i=e.call(this,{raw:o,code:a,qb64:h,qb64b:d,qb2:u})||this}catch(t){if(!(t instanceof g))throw t;if(null==n)throw t;var l=new Z({qb64b:n});if(l.code!=P.Ed25519_Seed)throw new Error("Unsupported signing seed derivation code "+l.code);var c=new Uint8Array(l.raw.length+l.verfer.raw.length);c.set(l.raw),c.set(l.verfer.raw,l.raw.length),o=r.crypto_sign_ed25519_sk_to_curve25519(c),i=e.call(this,{raw:o,code:a,qb64:h,qb64b:d,qb2:u})||this}if(i.code!=P.X25519_Private)throw new Error("Unsupported decrypter code = "+i.code+".");return i._decrypt=i._x25519,f(i)}d(t,e);var n=t.prototype;return n.decrypt=function(e,r,t){if(void 0===e&&(e=null),void 0===r&&(r=null),void 0===t&&(t=!1),null==e&&null==r)throw new g("Neither ser or cipher were provided");return null!=e&&(r=new $({qb64b:e})),this._decrypt(r,this.raw,t)},n._x25519=function(e,t,n){void 0===n&&(n=!1);var i=r.crypto_scalarmult_base(t),o=r.crypto_box_seal_open(e.raw,i,t);if(e.code==P.X25519_Cipher_Salt)return new Q({qb64b:o});if(e.code==P.X25519_Cipher_Seed)return new Z({qb64b:o,transferable:n});throw new Error("Unsupported cipher text code == "+e.code)},t}(j),$=function(e){function r(r){var t,n=r.raw,i=r.code,o=r.qb64,s=r.qb64b,a=r.qb2;if(null!=n&&null==i&&(n.length==j._rawSize(P.X25519_Cipher_Salt)||n.length==j._rawSize(P.X25519_Cipher_Seed))&&(i=P.X25519_Cipher_Salt),t=e.call(this,{raw:n,code:i,qb64b:s,qb64:o,qb2:a})||this,!Array.from([P.X25519_Cipher_Salt,P.X25519_Cipher_Seed]).includes(t.code))throw new Error("Unsupported Cipher code == "+t.code);return t}return d(r,e),r.prototype.decrypt=function(e,r){return void 0===e&&(e=void 0),void 0===r&&(r=void 0),new W({qb64b:e},r).decrypt(this.qb64b)},r}(j),ee=function(e){function t(t,n){var i,o=t.raw,s=t.code,a=void 0===s?P.X25519:s,h=t.qb64,d=t.qb64b,u=t.qb2;if(void 0===n&&(n=null),null==o&&null!=n){var l=new R({qb64b:n});if(!Array.from([P.Ed25519N,P.Ed25519]).includes(l.code))throw new Error("Unsupported verkey derivation code = "+l.code+".");o=r.crypto_sign_ed25519_pk_to_curve25519(l.raw)}if((i=e.call(this,{raw:o,code:a,qb64:h,qb64b:d,qb2:u})||this).code!=P.X25519)throw new Error("Unsupported encrypter code = "+i.code+".");return i._encrypt=i._x25519,i}d(t,e);var n=t.prototype;return n.verifySeed=function(e){var t,n,i=new Z({qb64b:e}),o=r.crypto_sign_seed_keypair(i.raw);return(t=r.crypto_sign_ed25519_pk_to_curve25519(o.publicKey)).length===(n=this.raw).length&&t.every((function(e,r){return e===n[r]}))},n.encrypt=function(e,r){if(void 0===e&&(e=null),void 0===r&&(r=null),null==e&&null==r)throw new Error("Neither ser nor matter are provided.");return null!=e&&(r=new j({qb64b:e})),this._encrypt(r.qb64,this.raw,r.code==P.Salt_128?P.X25519_Cipher_Salt:P.X25519_Cipher_Seed)},n._x25519=function(e,t,n){var i=r.crypto_box_seal(e,t);return new $({raw:i,code:n})},t}(j),re=function(e){function r(r,t){var n,i=r.raw,s=r.code,a=void 0===s?P.Blake3_256:s,h=r.qb64,d=r.qb64b,u=r.qb2;void 0===t&&(t=null);try{n=e.call(this,{raw:i,code:a,qb64:h,qb64b:d,qb2:u})||this}catch(r){if(null==t)throw r;if(a!==P.Blake3_256)throw new Error("Unsupported code = "+a+" for digester.");var l=o.createHash().update(t).digest("");n=e.call(this,{raw:l,code:a})||this}if(a!==P.Blake3_256)throw new Error("Unsupported code = "+a+" for digester.");return n._verify=n.blake3_256,f(n)}d(r,e);var t=r.prototype;return t.verify=function(e){return this._verify(e,this.raw)},t.compare=function(e,t,n){if(void 0===t&&(t=null),void 0===n&&(n=null),null!=t){if(t.toString()==this.qb64)return!0;n=new r({qb64b:t})}else{if(null==n)throw new Error("Both dig and diger may not be None.");if(n.qb64b==this.qb64b)return!0}return n.code!=this.code&&n.verify(e)&&this.verify(e)},t.blake3_256=function(e,r){return o.createHash().update(e).digest("").toString()===r.toString()},r}(j);!function(e){e.randy="randy",e.salty="salty"}(V||(V={}));var te=function(){this.pubs=new Array,this.ridx=0,this.kidx=0,this.dt=""},ne=function(){this.old=new te,this.new=new te,this.nxt=new te},ie=function(){this.pidx=0,this.algo=V.salty,this.salt="",this.stem="",this.tier=""},oe=function(){this.pubs=new Array},se=function(){this.path="",this.code="",this.tier="high",this.temp=!1},ae=function(){function e(e,r){if(this._signers=e,null!=r&&e.length!=r.length)throw new Error("If paths are provided, they must be the same length as signers");this._paths=r}return a(e,[{key:"paths",get:function(){return this._paths}},{key:"signers",get:function(){return this._signers}}]),e}(),he=function(){function e(){}return e.prototype.create=function(e,r,t,n){void 0===e&&(e=void 0),void 0===r&&(r=1),void 0===t&&(t=P.Ed25519_Seed),void 0===n&&(n=!0);var i=new Array;return null==e&&(e=new Array(r).fill(t)),e.forEach((function(e){i.push(new Z({code:e,transferable:n}))})),new ae(i)},a(e,[{key:"salt",get:function(){return""}},{key:"stem",get:function(){return""}},{key:"tier",get:function(){return""}}]),e}(),de=function(){function e(e,r,t){void 0===e&&(e=void 0),void 0===r&&(r=void 0),void 0===t&&(t=void 0),this.salter=new Q({qb64:e,tier:r}),this._stem=null==t?"":t}return e.prototype.create=function(e,r,t,n,i,o,s,a){var h=this;void 0===e&&(e=void 0),void 0===r&&(r=1),void 0===t&&(t=P.Ed25519_Seed),void 0===n&&(n=!0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=!1);var d=new Array,u=new Array;return null==e&&(e=new Array(r).fill(t)),e.forEach((function(e,r){var t=h.stem+i.toString(16)+o.toString(16)+(s+r).toString(16);d.push(h.salter.signer(e,n,t,h.tier,a)),u.push(t)})),new ae(d,u)},a(e,[{key:"salt",get:function(){return this.salter.qb64}},{key:"stem",get:function(){return this._stem}},{key:"tier",get:function(){return this.salter.tier}}]),e}(),ue=function(){function e(e){switch(void 0===e&&(e=V.salty),e){case V.randy:this._make=this._makeRandy;break;case V.salty:this._make=this._makeSalty;break;default:throw new Error("unsupported algo="+e)}}var r=e.prototype;return r.make=function(){return this._make.apply(this,arguments)},r._makeRandy=function(){return new he},r._makeSalty=function(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];return c(de,r)},e}(),le=function(){function e(e){var r=e.ks,t=e.seed,n=e.aeid,i=e.pidx,o=e.algo,s=e.salt,a=e.tier;if(this._ks=null==r?new fe:r,this._seed=t,this._encrypter=void 0,this._decrypter=void 0,n=null==n?void 0:n,i=null==i?0:i,o=null==o?V.salty:o,null==s)s=new Q({}).qb64;else if(new Q({qb64:s}).qb64!=s)throw new Error("Invalid qb64 for salt="+s+".");a=null==a?"low":a,null==this.pidx&&(this.pidx=i),null==this.algo&&(this.algo=o),null==this.salt&&(this.salt=s),null==this.tier&&(this.tier=a),null==this.aeid&&this.updateAeid(n,this._seed)}var r=e.prototype;return r.updateAeid=function(e,r){if(null!=this.aeid){var t,n=M(this._seed);if(null==this._seed||null==(t=this._encrypter)||!t.verifySeed(n))throw new Error('Last seed missing or provided last seed "\n "not associated with last aeid='+this.aeid+".")}if(""!=e&&null!=e){if(e!=this.aeid&&(this._encrypter=new ee({},M(e)),null==r||!this._encrypter.verifySeed(M(r))))throw new Error('Seed missing or provided seed not associated"\n " with provided aeid='+e+".")}else{if(this.algo==V.randy)throw new Error("Invalid Manager configuration, encryption must be used with Randy key creation.");this._encrypter=void 0}var i=this.salt;if(null!=i&&(this.salt=i),null!=this._decrypter){for(var o,s=w(this.ks.prmsElements());!(o=s()).done;){var a=o.value,h=a[0],d=a[1];if(null!=d.salt){var u=this._decrypter.decrypt(M(d.salt));d.salt=null==this._encrypter?u.qb64:this._encrypter.encrypt(null,u),this.ks.pinPrms(h,d)}}for(var l,c=w(this.ks.prisElements(this._decrypter));!(l=c()).done;){var f=l.value;this.ks.pinPris(f[0],f[1],this._encrypter)}}this.ks.pinGbls("aeid",e),this._seed=r,this._decrypter=null!=r?new W({},M(r)):void 0},r.incept=function(e){var r=this,t=e.icodes,n=void 0===t?void 0:t,i=e.icount,o=void 0===i?1:i,s=e.icode,a=void 0===s?P.Ed25519_Seed:s,h=e.ncodes,d=void 0===h?void 0:h,u=e.ncount,l=void 0===u?1:u,c=e.ncode,f=void 0===c?P.Ed25519_Seed:c,p=e.dcode,w=void 0===p?P.Blake3_256:p,v=e.algo,_=void 0===v?void 0:v,g=e.salt,b=void 0===g?void 0:g,y=e.stem,E=void 0===y?void 0:y,m=e.tier,k=void 0===m?void 0:m,S=e.rooted,q=void 0===S||S,x=e.transferable,A=void 0===x||x,I=e.temp,B=void 0!==I&&I;q&&null==_&&(_=this.algo),q&&null==b&&(b=this.salt),q&&null==k&&(k=this.tier);var z=this.pidx,N=new ue(_).make(b,k,E);if(null==n){if(o<0)throw new Error("Invalid icount="+o+" must be >= 0.");n=new Array(o).fill(a)}var C=N.create(n,0,P.Ed25519_Seed,A,z,0,0,B),D=Array.from(C.signers,(function(e){return e.verfer}));if(null==d){if(l<0)throw new Error("Invalid ncount="+l+" must be >= 0.");d=new Array(l).fill(f)}var O=N.create(d,0,P.Ed25519_Seed,A,z,1,0+n.length,B),U=Array.from(O.signers,(function(e){return new re({code:w},e.verfer.qb64b)})),T=new ie;T.pidx=z,T.algo=_,T.salt=0==N.salt.length||null==this.encrypter?"":this.encrypter.encrypt(M(N.salt)).qb64,T.stem=N.stem,T.tier=N.tier;var j=(new Date).toString(),R=new te;R.pubs=Array.from(D,(function(e){return e.qb64})),R.ridx=0,R.kidx=0,R.dt=j;var H=new te;H.pubs=Array.from(O.signers,(function(e){return e.verfer.qb64})),H.ridx=1,H.kidx=0+n.length,H.dt=j;var X=new ne;X.new=R,X.nxt=H;var G=D[0].qb64;if(!this.ks.putPres(G,D[0].qb64b))throw new Error("Already incepted pre="+G+".");if(!this.ks.putPrms(G,T))throw new Error("Already incepted prm for pre="+G+".");if(this.pidx=z+1,!this.ks.putSits(G,X))throw new Error("Already incepted sit for pre="+G+".");if(null!=this.encrypter)C.signers.forEach((function(e){r.ks.putPris(e.verfer.qb64,e,r.encrypter)})),O.signers.forEach((function(e){r.ks.putPris(e.verfer.qb64,e,r.encrypter)}));else{if(null!=this._encrypter||null==C.paths||null==O.paths)throw new Error("invalid configuration, randy keys without encryption");C.paths.forEach((function(e,t){var i=C.signers[t],o=new se;o.path=e,o.code=n[t],o.tier=T.tier,o.temp=B,r.ks.putPths(i.verfer.qb64,o)})),O.paths.forEach((function(e,t){var n=O.signers[t],i=new se;i.path=e,i.code=d[t],i.tier=T.tier,i.temp=B,r.ks.putPths(n.verfer.qb64,i)}))}var L=new oe;L.pubs=X.new.pubs,this.ks.putPubs(ce(G,0),L);var J=new oe;return J.pubs=X.nxt.pubs,this.ks.putPubs(ce(G,1),J),[D,U]},r.move=function(e,r){if(e!=r){if(null==this.ks.getPres(e))throw new Error("Nonexistent old pre="+e+", nothing to assign.");if(null!=this.ks.getPres(r))throw new Error("Preexistent new pre="+r+" may not clobber.");var t=this.ks.getPrms(e);if(null==t)throw new Error("Nonexistent old prm for pre="+e+", nothing to move.");if(null!=this.ks.getPrms(r))throw new Error("Preexistent new prm for pre="+r+" may not clobber.");var n=this.ks.getSits(e);if(null==n)throw new Error("Nonexistent old sit for pre="+e+", nothing to move.");if(null!=this.ks.getSits(r))throw new Error("Preexistent new sit for pre="+r+" may not clobber.");if(!this.ks.putPrms(r,t))throw new Error("Failed moving prm from old pre="+e+" to new pre="+r+".");if(this.ks.remPrms(e),!this.ks.putSits(r,n))throw new Error("Failed moving sit from old pre="+e+" to new pre="+r+".");this.ks.remSits(e);for(var i=0;;){var o=this.ks.getPubs(ce(e,i));if(null==o)break;if(!this.ks.putPubs(ce(r,i),o))throw new Error("Failed moving pubs at pre="+e+" ri="+i+" to new pre="+r);i+=1}if(!this.ks.pinPres(e,M(r)))throw new Error("Failed assiging new pre="+r+" to old pre="+e+".");if(!this.ks.putPres(r,M(r)))throw new Error("Failed assiging new pre="+r+".")}},r.rotate=function(e){var r=this,t=e.pre,n=e.ncodes,i=void 0===n?void 0:n,o=e.ncount,s=void 0===o?1:o,a=e.ncode,h=void 0===a?P.Ed25519_Seed:a,d=e.dcode,u=void 0===d?P.Blake3_256:d,l=e.transferable,c=void 0===l||l,f=e.temp,p=void 0!==f&&f,w=e.erase,v=void 0===w||w,_=this.ks.getPrms(t);if(null==_)throw new Error("Attempt to rotate nonexistent pre="+t+".");var g=this.ks.getSits(t);if(null==g)throw new Error("Attempt to rotate nonexistent pre="+t+".");if(null==g.nxt.pubs||0==g.nxt.pubs.length)throw new Error("Attempt to rotate nontransferable pre="+t+".");var b=g.old;if(g.old=g.new,g.new=g.nxt,null!=this.aeid&&null==this.decrypter)throw new Error("Unauthorized decryption attempt. Aeid but no decrypter.");var y=new Array;g.new.pubs.forEach((function(e){if(null!=r.decrypter){var t=r.ks.getPris(e,r.decrypter);if(null==t)throw new Error("Missing prikey in db for pubkey="+e);y.push(t.verfer)}else y.push(new R({qb64:e}))}));var E=_.salt;if(null!=E&&""!=E){if(null==this.decrypter)throw new Error("Invalid configuration: AID salt with no encryption");E=this.decrypter.decrypt(M(E)).qb64}else E=this.salt;var m=new ue(_.algo).make(E,_.tier,_.stem);if(null==i){if(s<0)throw new Error("Invalid count="+s+" must be >= 0");i=new Array(s).fill(h)}var k=g.new.ridx+1,S=g.nxt.kidx+g.new.pubs.length,q=m.create(i,0,"",c,_.pidx,k,S,p),x=Array.from(q.signers,(function(e){return new re({code:u},e.verfer.qb64b)})),A=(new Date).toString();if(g.nxt=new te,g.nxt.pubs=Array.from(q.signers,(function(e){return e.verfer.qb64})),g.nxt.ridx=k,g.nxt.kidx=S,g.nxt.dt=A,!this.ks.pinSits(t,g))throw new Error("Problem updating pubsit db for pre="+t+".");if(null!=this.encrypter)q.signers.forEach((function(e){r.ks.putPris(e.verfer.qb64,e,r.encrypter)}));else{if(null!=this._encrypter||null==q.paths)throw new Error("invalid configuration, randy keys without encryption");q.paths.forEach((function(e,t){var n=q.signers[t],i=new se;i.path=e,i.tier=_.tier,i.temp=p,r.ks.putPths(n.verfer.qb64,i)}))}var I=new oe;return I.pubs=g.nxt.pubs,this.ks.putPubs(ce(t,g.nxt.ridx),I),v&&b.pubs.forEach((function(e){r.ks.remPris(e)})),[y,x]},r.sign=function(e){var r=this,t=e.ser,n=e.pubs,i=void 0===n?void 0:n,o=e.verfers,s=void 0===o?void 0:o,a=e.indexed,h=void 0===a||a,d=e.indices,u=void 0===d?void 0:d,l=e.ondices,c=void 0===l?void 0:l,f=new Array;if(null==i&&null==s)throw new Error("pubs or verfers required");if(null!=i){if(null!=this.aeid&&null==this.decrypter)throw new Error("Unauthorized decryption attempt. Aeid but no decrypter.");i.forEach((function(e){if(null!=r.decrypter){var t=r.ks.getPris(e,r.decrypter);if(null==t)throw new Error("Missing prikey in db for pubkey="+e);f.push(t)}else{var n=new R({qb64:e}),i=r.ks.getPths(e);if(null==i)throw new Error("Missing prikey in db for pubkey="+e);var o=new Q({qb64:r.salt});f.push(o.signer(i.code,n.transferable,i.path,i.tier,i.temp))}}))}else s.forEach((function(e){if(null!=r.decrypter){var t=r.ks.getPris(e.qb64,r.decrypter);if(null==t)throw new Error("Missing prikey in db for pubkey="+e.qb64);f.push(t)}else{var n=r.ks.getPths(e.qb64);if(null==n)throw new Error("Missing prikey in db for pubkey="+e.qb64);var i=new Q({qb64:r.salt});f.push(i.signer(n.code,e.transferable,n.path,n.tier,n.temp))}}));if(null!=u&&u.length!=f.length)throw new Error("Mismatch indices length="+u.length+" and resultant signers length="+f.length);if(null!=c&&c.length!=f.length)throw new Error("Mismatch ondices length="+c.length+" and resultant signers length="+f.length);if(h){var p=new Array;return f.forEach((function(e,r){var n,i;if(null!=u){if((n=u[r])<0)throw new Error("Invalid signing index = "+n+", not whole number.")}else n=r;if(null!=c){if((i=c[r])<=0)throw new Error("Invalid other signing index = {o}, not None or not whole number.")}else i=n;p.push(e.sign(t,n,null==i,i))})),p}var w=new Array;return f.forEach((function(e){w.push(e.sign(t))})),w},a(e,[{key:"ks",get:function(){return this._ks}},{key:"encrypter",get:function(){return this._encrypter}},{key:"decrypter",get:function(){return this._decrypter}},{key:"seed",get:function(){return this._seed}},{key:"aeid",get:function(){return this.ks.getGbls("aeid")}},{key:"pidx",get:function(){var e=this.ks.getGbls("pidx");if(null!=e)return parseInt(e,16)},set:function(e){this.ks.pinGbls("pidx",e.toString(16))}},{key:"salt",get:function(){if(null==this._decrypter)return this._salt;var e=this.ks.getGbls("salt");return this._decrypter.decrypt(M(e)).qb64},set:function(e){null==this._encrypter?this._salt=e:(e=this._encrypter.encrypt(M(e)).qb64,this.ks.pinGbls("salt",e))}},{key:"tier",get:function(){return this.ks.getGbls("tier")},set:function(e){this.ks.pinGbls("tier",e)}},{key:"algo",get:function(){var e=this.ks.getGbls("algo");return V[e]},set:function(e){this.ks.pinGbls("algo",e)}}]),e}();function ce(e,r){return e+"."+r.toString(16).padStart(32,"0")}var fe=function(){function e(){this._gbls=new Map,this._pris=new Map,this._pths=new Map,this._pres=new Map,this._prms=new Map,this._sits=new Map,this._pubs=new Map}var r=e.prototype;return r.getGbls=function(e){return this._gbls.get(e)},r.pinGbls=function(e,r){this._gbls.set(e,r)},r.prmsElements=function(){var e=new Array;return this._prms.forEach((function(r,t){e.push([t,r])})),e},r.getPrms=function(e){return this._prms.get(e)},r.pinPrms=function(e,r){this._prms.set(e,r)},r.putPrms=function(e,r){return!this._prms.has(e)&&(this._prms.set(e,r),!0)},r.remPrms=function(e){return this._prms.delete(e)},r.prisElements=function(e){var r=new Array;return this._pris.forEach((function(t,n){var i=new R({qb64:n}),o=e.decrypt(t,null,i.transferable);r.push([n,o])})),r},r.pinPris=function(e,r,t){var n=t.encrypt(null,r);this._pris.set(e,n.qb64b)},r.putPris=function(e,r,t){if(this._pris.has(e))return!1;var n=t.encrypt(null,r);return this._pris.set(e,n.qb64b),!0},r.getPris=function(e,r){var t=this._pris.get(e);if(null!=t){var n=new R({qb64:e});return r.decrypt(t,null,n.transferable)}},r.pinPths=function(e,r){return this._pths.set(e,r),!0},r.putPths=function(e,r){return!this._pths.has(e)&&(this._pths.set(e,r),!0)},r.getPths=function(e){return this._pths.get(e)},r.remPris=function(e){this._pris.delete(e)},r.getPres=function(e){return this._pres.get(e)},r.pinPres=function(e,r){return this._pres.set(e,r),!0},r.putPres=function(e,r){return!this._pres.has(e)&&(this._pres.set(e,r),!0)},r.getSits=function(e){return this._sits.get(e)},r.putSits=function(e,r){return!this._sits.has(e)&&(this._sits.set(e,r),!0)},r.pinSits=function(e,r){return this._sits.set(e,r),!0},r.remSits=function(e){return this._sits.delete(e)},r.getPubs=function(e){return this._pubs.get(e)},r.putPubs=function(e,r){return!this._pubs.has(e)&&(this._pubs.set(e,r),!0)},e}(),pe=function(){function e(e){this._weighted=!1,this._thold=0,this._size=0,this._sith="",this._limen=new Array,this.processSith(e)}return e.prototype.processSith=function(e){"string"==typeof e?(this._sith=e,this._thold=parseInt(e)):"number"==typeof e?(this._thold=e,this._size=this._thold):(this._limen=e,this._size=this._limen.length)},a(e,[{key:"num",get:function(){return this._weighted?void 0:this._thold}},{key:"size",get:function(){return this._size}},{key:"thold",get:function(){return this._thold}},{key:"weighted",get:function(){return this._weighted}},{key:"sith",get:function(){return this.weighted?""==this._sith?""+this._limen:this._sith:this.thold.toString(16)}}]),e}(),we=function(){function e(e,r){this._num=0,"number"==typeof e?this._num=e:null!=r&&(this._num=parseInt(r,16))}return a(e,[{key:"num",get:function(){return this._num}},{key:"numh",get:function(){return this._num.toString(16)}}]),e}(),ve=function(){function e(e,r,t){void 0===r&&(r=v.JSON),void 0===t&&(t=P.Blake3_256),this._raw="",this._ked={},this._ident=_.KERI,this._size=0,this._version=b,this._code=t,this._kind=r,this.ked=e}var r=e.prototype;return r._exhale=function(e,r){return ge(e,r)},r.pretty=function(){return JSON.stringify(this._ked,void 0,2)},a(e,[{key:"ked",get:function(){return this._ked},set:function(e){var r=this._exhale(e,this._kind),t=r[0],n=r[1],i=r[2],o=r[3],s=r[4],a=t.length;this._raw=t,this._ident=n,this._ked=o,this._kind=i,this._size=a,this._version=s}},{key:"code",get:function(){return this._code}},{key:"raw",get:function(){return this._raw}},{key:"kind",get:function(){return this._kind}},{key:"ident",get:function(){return this._ident}},{key:"size",get:function(){return this._size}},{key:"version",get:function(){return this._version}}]),e}();function _e(e,r){if(r==v.JSON)return JSON.stringify(e);throw new Error("unsupported event encoding")}function ge(e,r){if(!("v"in e))throw new Error("Missing or empty version string");var t=_.KERI,n=m(e.v),i=n[0],o=n[1];if(o!=b)throw new Error("unsupported version "+o.toString());null==r&&(r=i);var s=_e(e,r);return e.v=k(t,o,r,s.length),[s=_e(e,r),t,r,e,o]}var be,ye=function(e){function r(t,n){var i,o=t.raw,s=t.code,a=t.qb64b,h=t.qb64,d=t.qb2;try{i=e.call(this,{raw:o,code:s,qb64b:a,qb64:h,qb2:d})||this}catch(t){if(!(t instanceof g))throw t;if(null==n||null==s&&!("i"in n))throw t;var u;if(null==s&&(s=(i=e.call(this,{qb64:n.i,code:s})||this).code),s==P.Ed25519N)u=r._derive_ed25519N;else if(s==P.Ed25519)u=r._derive_ed25519;else{if(s!=P.Blake3_256)throw new Error("Unsupported code = "+s+" for prefixer.");u=r._derive_blake3_256}var l=u(n);(i=e.call(this,{raw:o=l[0],code:s=l[1]})||this)._derive=u}if(i.code==P.Ed25519N)i._verify=i._verify_ed25519N;else if(i.code==P.Ed25519)i._verify=i._verify_ed25519;else{if(i.code!=P.Blake3_256)throw new Error("Unsupported code = "+s+" for prefixer.");i._verify=i._verify_blake3_256}return f(i)}d(r,e);var t=r.prototype;return t.derive=function(e){if("icp"!=e.i)throw new Error("Non-incepting ilk "+e.i+" for prefix derivation");return this._derive(e)},t.verify=function(e,r){if(void 0===r&&(r=!1),"icp"!=e.i)throw new Error("Non-incepting ilk "+e.i+" for prefix derivation");return this._verify(e,this.qb64,r)},r._derive_ed25519N=function(e){var r,t=e.k;if(1!=t.length)throw new Error("Basic derivation needs at most 1 key got "+t.length+" keys instead");try{r=new R({qb64:t[0]})}catch(e){throw new Error("Error extracting public key = "+e)}if(!(r.code in[P.Ed25519N]))throw new Error("Mismatch derivation code = "+r.code);var n="n"in e?e.n:[];if(r.code==P.Ed25519N&&n.length>0)throw new Error("Non-empty nxt = "+n+" for non-transferable code = "+r.code);var i="b"in e?e.b:[];if(r.code==P.Ed25519N&&i.length>0)throw new Error("Non-empty b ="+i+" for non-transferable code = "+r.code);if(r.code==P.Ed25519N&&("a"in e?e.a:[]).length>0)throw new Error("Non-empty a = "+r.code+" for non-transferable code = "+r.code);return[r.raw,r.code]},r._derive_ed25519=function(e){var r,t=e.k;if(1!=t.length)throw new Error("Basic derivation needs at most 1 key got "+t.length+" keys instead");try{r=new R({qb64:t[0]})}catch(e){throw new Error("Error extracting public key = "+e)}if(r.code in[P.Ed25519])throw new Error("Mismatch derivation code = "+r.code);return[r.raw,r.code]},r._derive_blake3_256=function(e){var r=e,t=e.t;if("icp"!=t)throw new Error("Invalid ilk = "+t+" to derive pre.");r.i="".padStart(j.Sizes.get(P.Blake3_256).fs,"#"),r.d=e.i;var n=ge(e)[0];return[o.createHash().update(n).digest(""),P.Blake3_256]},t._verify_ed25519N=function(e,r,t){void 0===t&&(t=!1);try{var n=e.k;if(1!=n.length)return!1;if(n[0]!=r)return!1;if(t&&e.i!=r)return!1;if(("n"in e?e.n:[]).length>0)return!1}catch(e){return!1}return!0},t._verify_ed25519=function(e,r,t){void 0===t&&(t=!1);try{var n=e.k;if(1!=n.length)return!1;if(n[0]!=r)return!1;if(t&&e.i!=r)return!1}catch(e){return!1}return!0},t._verify_blake3_256=function(e,t,n){void 0===n&&(n=!1);try{var i=r._derive_blake3_256(e);if(new j({raw:i[0],code:P.Blake3_256}).qb64!=t)return!1;if(n&&e.i!=t)return!1}catch(e){return!1}return!0},r}(j);!function(e){e.d="d"}(be||(be={}));var Ee=function(e,r,t){this.klas=void 0,this.size=0,this.length=0,this.klas=e,this.size=r,this.length=t},me=function(e){function r(t,n,i,o){var s,a=t.raw,d=t.code,u=t.qb64b,l=t.qb64,c=t.qb2;void 0===o&&(o=be.d);try{s=e.call(this,{raw:a,code:d,qb64b:u,qb64:l,qb2:c})||this}catch(t){if(!(t instanceof g))throw t;if(null==n||!(o in n))throw t;if(null==d&&(d=""!=n[o]?(s=e.call(this,{qb64:n[o],code:d})||this).code:P.Blake3_256),!U.has(d))throw new Error("Unsupported digest code = "+d);var p=r._derive(h({},n),d,i,o);s=e.call(this,{raw:a=p[0],code:d})||this}if(!s.digestive)throw new Error("Unsupported digest code = "+s.code+".");return f(s)}d(r,e),r._derive_blake3_256=function(e,r,t){return o.createHash().update(e).digest("")},r._derive=function(e,t,n,i){if(!U.has(t)||!r.Digests.has(t))throw new Error("Unsupported digest code = "+t+".");if((e=h({},e))[i]="".padStart(j.Sizes.get(t).fs,"#"),"v"in e){var o=ge(e,n);n=o[2],e=o[3]}var s=h({},e),a=r.Digests.get(t),d=r._serialze(s,n),u=[];return null!=a.size&&u.push(a.size),null!=a.length&&u.push(a.length),[a.klas.apply(a,[d].concat(u)),e]};var t=r.prototype;return t.derive=function(e,t,n,i){return r._derive(e,t=null!=t?t:this.code,n,i)},t.verify=function(e,t,n,i,o){void 0===t&&(t=!1),void 0===n&&(n=!1),void 0===o&&(o=be.d);try{var s=r._derive(e,this.code,i,o),a=s[1],h=new r({raw:s[0],code:this.code});if(this.qb64!=h.qb64)return!1;if("v"in e&&n&&e.v!=a.v)return!1;if(t&&e[o]!=this.qb64)return!1}catch(e){return!1}return!0},r._serialze=function(e,r){var t=v.JSON;return"v"in e&&(t=m(e.v)[0]),null==r&&(r=t),_e(e,r)},r.saidify=function(e,t,n,i){if(void 0===t&&(t=P.Blake3_256),void 0===n&&(n=v.JSON),void 0===i&&(i=be.d),!(i in e))throw new Error("Missing id field labeled="+i+" in sad.");var o=r._derive(e,t,n,i);e=o[1];var s=new r({raw:o[0],code:t},void 0,n,i);return e[i]=s.qb64,[s,e]},r}(j);me.Digests=new Map([[P.Blake3_256,new Ee(me._derive_blake3_256,void 0,void 0)]]);var ke=function(){this.EstOnly="EO",this.DoNotDelegate="DND"},Se=new ke,qe=function(){function e(e,r){this.name=e,this.serder=r}return a(e,[{key:"pre",get:function(){return this.serder.ked.i}}]),e}(),xe=function(){function e(e){var r,t=e.name,n=e.passcode,i=e.seed,o=e.aeid,s=e.pidx,a=e.salt;if(this._habs=new Map,this._name=t,null!=n&&null==i){if(n.length<21)throw new Error("Bran (passcode seed material) too short.");var h=P.Salt_128+"A"+n.substring(0,21),d=new Q({qb64:h}).signer(P.Ed25519_Seed,!1);i=d.qb64,null==o&&(o=d.verfer.qb64)}null!=a?(r=V.salty,a=new Q({qb64:a}).qb64):r=V.randy,this._mgr=new le({seed:i,aeid:o,pidx:s,algo:r,salt:a})}var r=e.prototype;return r.habByName=function(e){return this._habs.get(e)},r.makeHab=function(e,r){var t=r.code,n=void 0===t?P.Blake3_256:t,i=r.transferable,o=void 0===i||i,s=r.isith,a=void 0===s?void 0:s,h=r.icount,d=void 0===h?1:h,u=r.nsith,l=void 0===u?void 0:u,c=r.ncount,f=void 0===c?void 0:c,p=r.toad,w=void 0===p?void 0:p,g=r.wits,y=void 0===g?void 0:g,E=r.delpre,m=void 0===E?void 0:E,S=r.estOnly,q=void 0!==S&&S,x=r.DnD,A=void 0!==x&&x,M=r.data,I=void 0===M?void 0:M;null==l&&(l=a),null==f&&(f=d),o||(f=0,l="0",n=P.Ed25519N);var B=this._mgr.incept({icount:d,ncount:f,stem:this.name,transferable:o,temp:!1}),z=B[0],N=B[1];d=z.length,f=null!=N?N.length:0,null==a&&(a=""+Math.max(1,Math.ceil(d/2)).toString(16)),null==l&&(l=""+Math.max(1,Math.ceil(f/2)).toString(16));var C=new Array;q&&C.push(Se.EstOnly),A&&C.push(Se.DoNotDelegate);var D=function(e){var r=e.keys,t=e.isith,n=e.ndigs,i=e.nsith,o=e.toad,s=e.wits,a=e.cnfg,h=e.data,d=e.version,u=e.kind,l=e.code,c=e.intive,f=void 0!==c&&c,p=e.delpre,w=k(_.KERI,void 0===d?b:d,void 0===u?v.JSON:u,0),g=null==p?"icp":"dip",y=new we(0);null==t&&(t=Math.max(1,Math.ceil(r.length/2)));var E=new pe(t);if(null!=E.num&&E.num<1)throw new Error("Invalid sith = "+E.num+" less than 1.");if(E.size>r.length)throw new Error("Invalid sith = "+E.num+" for keys "+r);null==n&&(n=new Array),null==i&&(i=Math.max(0,Math.ceil(n.length/2)));var m=new pe(i);if(null!=m.num&&m.num<0)throw new Error("Invalid nsith = "+m.num+" less than 0.");if(m.size>r.length)throw new Error("Invalid nsith = "+m.num+" for keys "+n);if(s=null==s?[]:s,new Set(s).size!=s.length)throw new Error("Invalid wits = "+s+", has duplicates.");null==o&&(o=0==s.length?0:function(e,r,t){var n;if(void 0===t&&(t=!0),e=Math.max(0,e),null==r){n=Math.max(1,Math.floor(Math.max(0,e-1)/3));var i=Math.max(1,Math.ceil(Math.max(0,e-1)/3));return t?Math.min(e,Math.ceil((e+n+1)/2),Math.ceil((e+i+1)/2)):Math.min(e,Math.max(0,e-n,Math.ceil((e+n+1)/2)))}r=Math.max(0,r);var o=Math.ceil((e+r+1)/2),s=Math.max(0,e-r);if(s<o&&e>0)throw new Error("Invalid f="+r+" is too big for n="+e+".");return t?Math.min(e,o,s):Math.min(e,Math.max(o,s))}(s.length));var S=new we(o);if(s.length>0){if(S.num<1||S.num>s.length)throw new Error("Invalid toad = "+S.num+" for wits = "+s)}else if(0!=S.num)throw new Error("Invalid toad = "+S.num+" for wits = "+s);a=null==a?new Array:a,h=null==h?new Array:h;var q,x={v:w,t:g,d:"",i:"",s:y.numh,kt:f&&null!=E.num?E.num:E.sith,k:r,nt:f&&null!=E.num?m.num:m.sith,n:n,bt:f?S.num:S.numh,b:s,c:a,a:h};if(null!=p&&(x.di=p,null==l&&(l=P.Blake3_256)),null==p&&null==l&&1==r.length){if((q=new ye({qb64:r[0]})).digestive)throw new Error("Invalid code, digestive="+q.code+", must be derived from ked.")}else if(q=new ye({code:l},x),null!=p&&!q.digestive)throw new Error("Invalid derivation code = "+q.code+" for delegation. Must be digestive");return x.i=q.qb64,q.digestive?x.d=q.qb64:x=me.saidify(x)[1],new ve(x)}({keys:Array.from(z,(function(e){return e.qb64})),isith:a,ndigs:Array.from(N,(function(e){return e.qb64})),nsith:l,toad:w,wits:y,cnfg:C,data:I,code:n,delpre:m}),O=new qe(e,D);return this._habs.set(e,O),O},a(e,[{key:"mgr",get:function(){return this._mgr}},{key:"habs",get:function(){return Array.from(this._habs.values())}},{key:"name",get:function(){return this._name}}]),e}();exports.Codex=z,exports.DigiCodex=O,exports.DigiDex=U,exports.Hab=qe,exports.Habery=xe,exports.Matter=j,exports.MatterCodex=N,exports.MtrDex=P,exports.NonTransCodex=C,exports.NonTransDex=D,exports.Salter=Q,exports.Sizage=T,exports.TraitCodex=ke,exports.TraitDex=Se;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function t(e){if(e&&e.__esModule)return e;var t={};return e&&Object.keys(e).forEach((function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})})),t.default=e,t}Object.defineProperty(exports,"__esModule",{value:!0});var r=e(require("libsodium-wrappers-sumo")),n=require("mathjs"),i=require("text-encoding"),s=e(require("urlsafe-base64")),o=require("buffer"),a=e(require("ecdsa-secp256r1")),u=require("blake3"),c=require("util"),h=require("structured-headers");function d(){d=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function h(e,t,r,n){var s=Object.create((t&&t.prototype instanceof g?t:g).prototype),o=new C(n||[]);return i(s,"_invoke",{value:A(e,r,o)}),s}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=h;var f="suspendedStart",p="executing",v="completed",w={};function g(){}function b(){}function y(){}var x={};c(x,o,(function(){return this}));var _=Object.getPrototypeOf,m=_&&_(_(M([])));m&&m!==r&&n.call(m,o)&&(x=m);var E=y.prototype=g.prototype=Object.create(x);function k(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function S(e,t){function r(i,s,o,a){var u=l(e[i],e,s);if("throw"!==u.type){var c=u.arg,h=c.value;return h&&"object"==typeof h&&n.call(h,"__await")?t.resolve(h.__await).then((function(e){r("next",e,o,a)}),(function(e){r("throw",e,o,a)})):t.resolve(h).then((function(e){c.value=e,o(c)}),(function(e){return r("throw",e,o,a)}))}a(u.arg)}var s;i(this,"_invoke",{value:function(e,n){function i(){return new t((function(t,i){r(e,n,t,i)}))}return s=s?s.then(i,i):i()}})}function A(t,r,n){var i=f;return function(s,o){if(i===p)throw new Error("Generator is already running");if(i===v){if("throw"===s)throw o;return{value:e,done:!0}}for(n.method=s,n.arg=o;;){var a=n.delegate;if(a){var u=q(a,n);if(u){if(u===w)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===f)throw i=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=p;var c=l(t,r,n);if("normal"===c.type){if(i=n.done?v:"suspendedYield",c.arg===w)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=v,n.method="throw",n.arg=c.arg)}}}function q(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,q(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),w;var s=l(i,t.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,w;var o=s.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,w):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function B(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function M(t){if(t||""===t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return s.next=s}}throw new TypeError(typeof t+" is not iterable")}return b.prototype=y,i(E,"constructor",{value:y,configurable:!0}),i(y,"constructor",{value:b,configurable:!0}),b.displayName=c(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===b||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,c(e,u,"GeneratorFunction")),e.prototype=Object.create(E),e},t.awrap=function(e){return{__await:e}},k(S.prototype),c(S.prototype,a,(function(){return this})),t.AsyncIterator=S,t.async=function(e,r,n,i,s){void 0===s&&(s=Promise);var o=new S(h(e,r,n,i),s);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},k(E),c(E,u,"Generator"),c(E,o,(function(){return this})),c(E,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=M,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(B),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return a.type="throw",a.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var s=this.tryEntries.length-1;s>=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===e||"continue"===e)&&s.tryLoc<=t&&t<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=e,o.arg=t,s?(this.method="next",this.next=s.finallyLoc,w):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),w},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),B(r),w}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;B(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:M(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),w}},t}function l(e,t,r,n,i,s,o){try{var a=e[s](o),u=a.value}catch(e){return void r(e)}a.done?t(u):Promise.resolve(u).then(n,i)}function f(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var s=e.apply(t,r);function o(e){l(s,n,i,o,a,"next",e)}function a(e){l(s,n,i,o,a,"throw",e)}o(void 0)}))}}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(n.key))?i:String(i),n)}var i}function v(e,t,r){return t&&p(e.prototype,t),r&&p(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function w(){return(w=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function g(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,b(e,t)}function b(e,t){return(b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function x(e,t,r){return(x=y()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&b(i,r.prototype),i}).apply(null,arguments)}function _(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return m(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k,S=function(){function e(e){this._err=new Error(e)}return v(e,[{key:"err",get:function(){return this._err}}]),e}();(exports.Serials||(exports.Serials={})).JSON="JSON",(k=exports.Ident||(exports.Ident={})).KERI="KERI",k.ACDC="ACDC";var A=function(e,t){void 0===e&&(e=1),void 0===t&&(t=0),this.major=e,this.minor=t},q=new A,I={icp:"icp",rot:"rot",ixn:"ixn",dip:"dip",drt:"drt",rct:"rct",vrc:"vrc",rpy:"rpy",exn:"exn",vcp:"vcp",iss:"iss",rev:"rev"},B=new i.TextEncoder,C=new i.TextDecoder,M="(KERI|ACDC)([0-9a-f])([0-9a-f])([A-Z]{4})([0-9a-f]{6})_";function N(e){var t,r,n,i=q,s=new RegExp(M).exec(e);if(s){var o=[s[1],+s[2],+s[3],s[4],s[5]];if(n=o[0],i.major=o[1],i.minor=o[2],t=o[3],r=o[4],!Object.values(exports.Serials).includes(t))throw new Error("Invalid serialization kind = "+t);if(!Object.values(exports.Ident).includes(n))throw new Error("Invalid serialization kind = "+t);return t=exports.Serials[t],[n=exports.Ident[n],t,i,r]}throw new Error("Invalid version string = "+e)}function O(e,t,r,n){return void 0===e&&(e=exports.Ident.KERI),void 0===r&&(r=exports.Serials.JSON),void 0===n&&(n=0),""+e+(t=null==t?q:t).major.toString(16)+t.minor.toString()+r+n.toString(16).padStart(6,"0")+"_"}var z=new Map([[0,"A"],[1,"B"],[2,"C"],[3,"D"],[4,"E"],[5,"F"],[6,"G"],[7,"H"],[8,"I"],[9,"J"],[10,"K"],[11,"L"],[12,"M"],[13,"N"],[14,"O"],[15,"P"],[16,"Q"],[17,"R"],[18,"S"],[19,"T"],[20,"U"],[21,"V"],[22,"W"],[23,"X"],[24,"Y"],[25,"Z"],[26,"a"],[27,"b"],[28,"c"],[29,"d"],[30,"e"],[31,"f"],[32,"g"],[33,"h"],[34,"i"],[35,"j"],[36,"k"],[37,"l"],[38,"m"],[39,"n"],[40,"o"],[41,"p"],[42,"q"],[43,"r"],[44,"s"],[45,"t"],[46,"u"],[47,"v"],[48,"w"],[49,"x"],[50,"y"],[51,"z"],[52,"0"],[53,"1"],[54,"2"],[55,"3"],[56,"4"],[57,"5"],[58,"6"],[59,"7"],[60,"8"],[61,"9"],[62,"-"],[63,"_"]]),j=new Map(Array.from(z,(function(e){return[e[1],e[0]]})));function D(e,t){void 0===t&&(t=1);for(var r="";0!=t&&(r=z.get(e%64)+r,0!=(e=Math.floor(e/64))););for(var n=t-r.length,i=0;i<n;i++)r="A"+r;return r}function T(e){if(0==e.length)throw new Error("Empty string, conversion undefined.");var t=0;return e.split("").reverse().forEach((function(e,r){t|=j.get(e)<<6*r})),t}function P(e){return B.encode(e)}function L(e){return C.decode(e)}function U(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function R(e){for(var t=0,r=0;r<e.length;r++)t=256*t+e[r];return t}var G=function(){function e(){}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}(),H=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).Ed25519_Seed="A",t.Ed25519N="B",t.X25519="C",t.Ed25519="D",t.Blake3_256="E",t.SHA3_256="H",t.SHA2_256="I",t.ECDSA_256k1_Seed="J",t.X25519_Private="O",t.X25519_Cipher_Seed="P",t.ECDSA_256r1_Seed="Q",t.Salt_128="0A",t.Ed25519_Sig="0B",t.ECDSA_256k1_Sig="0C",t.ECDSA_256r1_Sig="0I",t.StrB64_L0="4A",t.StrB64_L1="5A",t.StrB64_L2="6A",t.ECDSA_256k1N="1AAA",t.ECDSA_256k1="1AAB",t.X25519_Cipher_Salt="1AAH",t.ECDSA_256r1N="1AAI",t.ECDSA_256r1="1AAJ",t.StrB64_Big_L0="7AAA",t.StrB64_Big_L1="8AAA",t.StrB64_Big_L2="9AAA",t}return g(t,e),t}(G),F=new H,J=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).Ed25519N="B",t.ECDSA_256k1N="1AAA",t.Ed448N="1AAC",t.ECDSA_256r1N="1AAI",t}return g(t,e),t}(G),K=new J,X=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).Blake3_256="E",t.Blake2b_256="F",t.Blake2s_256="G",t.SHA3_256="H",t.SHA2_256="I",t.Blake3_512="0D",t.Blake2b_512="0E",t.SHA3_512="0F",t.SHA2_512="0G",t}return g(t,e),t}(G),V=new X,Z=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).Short="M",t.Long="0H",t.Big="N",t.Huge="0A",t}return g(t,e),t}(G),W=new Z,Y=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).StrB64_L0="4A",t.StrB64_L1="5A",t.StrB64_L2="6A",t.StrB64_Big_L0="7AAA",t.StrB64_Big_L1="8AAA",t.StrB64_Big_L2="9AAA",t}return g(t,e),t}(G),Q=new Y,$=new(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).Lead0="4",t.Lead1="5",t.Lead2="6",t}return g(t,e),t}(G)),ee=new(function(e){function t(){var t;return(t=e.apply(this,arguments)||this).Lead0_Big="7",t.Lead1_Big="8",t.Lead2_Big="9",t}return g(t,e),t}(G)),te=function(e,t,r,n){this.hs=e,this.ss=t,this.fs=r,this.ls=n},re=function(){function e(t){var r=t.raw,n=t.code,i=void 0===n?F.Ed25519N:n,s=t.qb64b,o=t.qb64,a=t.qb2,u=t.rize;this._code="",this._size=-1,this._raw=new Uint8Array(0);var c=-1;if(null!=r){if(0==i.length)throw new Error("Improper initialization need either (raw and code) or qb64b or qb64 or qb2.");if($.has(i[0])||ee.has(i[0])){if(void 0!==u){if(u<0)throw new Error("missing var raw size for code="+i)}else u=r.length;var h=(3-u%3)%3;if(c=Math.floor((u+h)/3),$.has(i[0]))if(c<=Math.pow(64,2)-1)i=""+Object.values($)[h]+i.substring(1,2);else{if(!(c<=Math.pow(64,4)-1))throw new Error("Unsupported raw size for code="+i);i=""+Object.values(ee)[h]+"AAAA".substring(0,2)+i[1]}else{if(!(c<=Math.pow(64,4)-1))throw new Error("Unsupported raw size for code="+i);i=""+Object.values(ee)[h]+i.substring(1,4)}}else{if(-1==e.Sizes.get(i).fs)throw new Error("Unsupported variable size code="+i);u=e._rawSize(i)}if((r=r.slice(0,u)).length!=u)throw new Error("Not enougth raw bytes for code="+i+" expected "+u+" got "+r.length+".");this._code=i,this._size=c,this._raw=r}else if(void 0!==o)this._exfil(o);else if(void 0!==s){var d=L(s);this._exfil(d)}else{if(void 0===a)throw new S("EmptyMaterialError");this._bexfil(a)}}e._rawSize=function(e){var t=this.Sizes.get(e),r=t.hs+t.ss;if(-1===t.fs)throw Error("Non-fixed raw size code "+e+".");return Math.floor(3*(t.fs-r)/4)-t.ls},e._leadSize=function(e){return this.Sizes.get(e).ls};var t=e.prototype;return t._infil=function(){var t=this.code,r=this.size,n=this.raw,i=(3-n.length%3)%3,a=e.Sizes.get(t);if(void 0===a.fs){var u=a.hs+a.ss;if(u%4)throw new Error("Whole code size not multiple of 4 for variable length material. cs="+u);if(r<0||r>Math.pow(64,a.ss)-1)throw new Error("Invalid size="+r+" for code="+t+".");var c=""+t+D(r,a.ss);if(c.length%4!=i-a.ls)throw new Error("Invalid code="+c+" for converted raw pad size="+i+".");for(var h=new Uint8Array(a.ls+n.length),d=0;d<a.ls;d++)h[d]=0;for(var l=0;l<n.length;l++)h[l+i]=n[l];return c+s.encode(o.Buffer.from(h))}var f=t,p=f.length;if(p%4!=i-a.ls)throw new Error("Invalid code="+f+" for converted raw pad size="+i+", "+n.length+".");for(var v=new Uint8Array(i+n.length),w=0;w<i;w++)v[w]=0;for(var g=0;g<n.length;g++)v[g+i]=n[g];return f+s.encode(o.Buffer.from(v)).slice(p%4)},t._exfil=function(t){if(0==t.length)throw new Error("Empty Material");var r=t[0];if(!Array.from(e.Hards.keys()).includes(r))throw new Error("Unexpected code "+r);var n=e.Hards.get(r);if(t.length<n)throw new Error("Shortage Error");var i=t.slice(0,n);if(!Array.from(e.Sizes.keys()).includes(i))throw new Error("Unsupported code "+i);var o,a=e.Sizes.get(i),u=a.hs+a.ss;if(-1==a.fs)throw new Error("Variable size codes not supported yet");if(o=a.fs,t.length<a.fs)throw new Error("Need "+(a.fs-t.length)+" more chars.");t=t.slice(0,a.fs);var c,h=u%4,d=2*(0==h?a.ls:h);if(0!=h){var l=new Array(h+1).join("A")+t.slice(u),f=s.decode(l);if(R(f.subarray(0,h))&Math.pow(2,d)-1)throw new Error("Non zeroed prepad bits = {pi & (2 ** pbs - 1 ):<06b} in {qb64b[cs:cs+1]}.");c=f.subarray(h)}else{var p=t.slice(u),v=s.decode(p),w=R(v.subarray(0,a.ls));if(0!=w)throw 1==w?new Error("Non zeroed lead byte = 0x{li:02x}."):new Error("Non zeroed lead bytes = 0x{li:04x}");c=v.subarray(a.ls)}this._code=i,this._size=o,this._raw=Uint8Array.from(c)},t._bexfil=function(e){throw new Error("qb2 not yet supported: "+e)},v(e,[{key:"code",get:function(){return this._code}},{key:"size",get:function(){return this._size}},{key:"raw",get:function(){return this._raw}},{key:"qb64",get:function(){return this._infil()}},{key:"qb64b",get:function(){return P(this.qb64)}},{key:"transferable",get:function(){return!K.has(this.code)}},{key:"digestive",get:function(){return V.has(this.code)}},{key:"both",get:function(){var t=e.Sizes.get(this.code);return""+this.code+D(this.size,t.ss)}}]),e}();re.Sizes=new Map(Object.entries({A:new te(1,0,44,0),B:new te(1,0,44,0),C:new te(1,0,44,0),D:new te(1,0,44,0),E:new te(1,0,44,0),F:new te(1,0,44,0),G:new te(1,0,44,0),H:new te(1,0,44,0),I:new te(1,0,44,0),J:new te(1,0,44,0),K:new te(1,0,76,0),L:new te(1,0,76,0),M:new te(1,0,4,0),N:new te(1,0,12,0),O:new te(1,0,44,0),P:new te(1,0,124,0),Q:new te(1,0,44,0),"0A":new te(2,0,24,0),"0B":new te(2,0,88,0),"0C":new te(2,0,88,0),"0D":new te(2,0,88,0),"0E":new te(2,0,88,0),"0F":new te(2,0,88,0),"0G":new te(2,0,88,0),"0H":new te(2,0,8,0),"0I":new te(2,0,88,0),"1AAA":new te(4,0,48,0),"1AAB":new te(4,0,48,0),"1AAC":new te(4,0,80,0),"1AAD":new te(4,0,80,0),"1AAE":new te(4,0,56,0),"1AAF":new te(4,0,8,0),"1AAG":new te(4,0,36,0),"1AAH":new te(4,0,100,0),"1AAI":new te(4,0,48,0),"1AAJ":new te(4,0,48,0),"2AAA":new te(4,0,8,1),"3AAA":new te(4,0,8,2),"4A":new te(2,2,void 0,0),"5A":new te(2,2,void 0,1),"6A":new te(2,2,void 0,2),"7AAA":new te(4,4,void 0,0),"8AAA":new te(4,4,void 0,1),"9AAA":new te(4,4,void 0,2),"4B":new te(2,2,void 0,0),"5B":new te(2,2,void 0,1),"6B":new te(2,2,void 0,2),"7AAB":new te(4,4,void 0,0),"8AAB":new te(4,4,void 0,1),"9AAB":new te(4,4,void 0,2)})),re.Hards=new Map([["A",1],["B",1],["C",1],["D",1],["E",1],["F",1],["G",1],["H",1],["I",1],["J",1],["K",1],["L",1],["M",1],["N",1],["O",1],["P",1],["Q",1],["R",1],["S",1],["T",1],["U",1],["V",1],["W",1],["X",1],["Y",1],["Z",1],["a",1],["b",1],["c",1],["d",1],["e",1],["f",1],["g",1],["h",1],["i",1],["j",1],["k",1],["l",1],["m",1],["n",1],["o",1],["p",1],["q",1],["r",1],["s",1],["t",1],["u",1],["v",1],["w",1],["x",1],["y",1],["z",1],["0",2],["1",4],["2",4],["3",4],["4",2],["5",2],["6",2],["7",4],["8",4],["9",4]]);var ne=function(e){function t(t){var r;if(r=e.call(this,{raw:t.raw,code:t.code,qb64:t.qb64,qb64b:t.qb64b,qb2:t.qb2})||this,Array.from([F.Ed25519N,F.Ed25519]).includes(r.code))r._verify=r._ed25519;else{if(!Array.from([F.ECDSA_256r1N,F.ECDSA_256r1]).includes(r.code))throw new Error("Unsupported code = "+r.code+" for verifier.");r._verify=r._secp256r1}return r}g(t,e);var n=t.prototype;return n.verify=function(e,t){return this._verify(e,t,this.raw)},n._ed25519=function(e,t,n){try{return r.crypto_sign_verify_detached(e,t,n)}catch(e){throw new Error(e)}},n._secp256r1=function(e,t,r){try{return a.fromCompressedPublicKey(r).verify(t,e)}catch(e){throw new Error(e)}},t}(re),ie=function(e){function t(t,r){var n;return(n=e.call(this,{raw:t.raw,code:t.code,qb64:t.qb64,qb64b:t.qb64b,qb2:t.qb2})||this)._verfer=r,n}return g(t,e),v(t,[{key:"verfer",get:function(){return this._verfer},set:function(e){this._verfer=e}}]),t}(re),se=function(){this.Ed25519_Sig="A",this.Ed25519_Crt_Sig="B",this.ECDSA_256k1_Sig="C",this.ECDSA_256k1_Crt_Sig="D",this.ECDSA_256r1_Sig="E",this.ECDSA_256r1_Crt_Sig="F",this.Ed448_Sig="0A",this.Ed448_Crt_Sig="0B",this.Ed25519_Big_Sig="2A",this.Ed25519_Big_Crt_Sig="2B",this.ECDSA_256k1_Big_Sig="2C",this.ECDSA_256k1_Big_Crt_Sig="2D",this.ECDSA_256r1_Big_Sig="2E",this.ECDSA_256r1_Big_Crt_Sig="2F",this.Ed448_Big_Sig="3A",this.Ed448_Big_Crt_Sig="3B"},oe=new se,ae=function(){function e(){this.Ed25519_Sig="A",this.Ed25519_Crt_Sig="B",this.ECDSA_256k1_Sig="C",this.ECDSA_256k1_Crt_Sig="D",this.ECDSA_256r1_Sig="E",this.ECDSA_256r1_Crt_Sig="F",this.Ed448_Sig="0A",this.Ed448_Crt_Sig="0B",this.Ed25519_Big_Sig="2A",this.Ed25519_Big_Crt_Sig="2B",this.ECDSA_256k1_Big_Sig="2C",this.ECDSA_256k1_Big_Crt_Sig="2D",this.ECDSA_256r1_Big_Sig="2E",this.ECDSA_256r1_Big_Crt_Sig="2F",this.Ed448_Big_Sig="3A",this.Ed448_Big_Crt_Sig="3B"}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}(),ue=new ae,ce=function(){function e(){this.Ed25519_Crt_Sig="B",this.ECDSA_256k1_Crt_Sig="D",this.ECDSA_256r1_Crt_Sig="F",this.Ed448_Crt_Sig="0B",this.Ed25519_Big_Crt_Sig="2B",this.ECDSA_256k1_Big_Crt_Sig="2D",this.ECDSA_256r1_Big_Crt_Sig="2F",this.Ed448_Big_Crt_Sig="3B"}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}(),he=new ce,de=function(){function e(){this.Ed25519_Sig="A",this.ECDSA_256k1_Sig="C",this.Ed448_Sig="0A",this.Ed25519_Big_Sig="2A",this.ECDSA_256k1_Big_Sig="2C",this.Ed448_Big_Sig="3A"}return e.prototype.has=function(e){return new Map(Array.from(Object.entries(this),(function(e){return[e[1],e[0]]}))).has(e)},e}(),le=new de,fe=function(e,t,r,n,i){this.hs=e,this.ss=t,this.os=r,this.fs=n,this.ls=i},pe=function(){function e(t){var r=t.raw,n=void 0===r?void 0:r,i=t.code,s=void 0===i?oe.Ed25519_Sig:i,o=t.index,a=void 0===o?0:o,u=t.ondex,c=void 0===u?void 0:u,h=t.qb64b,d=void 0===h?void 0:h,l=t.qb64,f=void 0===l?void 0:l,p=t.qb2,v=void 0===p?void 0:p;if(this.Codex=oe,this._code="",this._index=-1,this._raw=new Uint8Array(0),null!=n){if(null==s)throw new S("Improper initialization need either (raw and code) or qb64b or qb64 or qb2.");if(!e.Sizes.has(s))throw new Error("Unsupported code="+s+".");var w=e.Sizes.get(s),g=w.os,b=w.fs,y=w.hs+w.ss,x=w.ss-w.os;if(!Number.isInteger(a)||a<0||a>Math.pow(64,x)-1)throw new Error("Invalid index="+a+" for code="+s+".");if(null!=c&&0!=w.os&&!(c>=0&&c<=Math.pow(64,g)-1))throw new Error("Invalid ondex="+c+" for code="+s+".");if(he.has(s)&&null!=c)throw new Error("Non None ondex="+c+" for code="+s+".");if(le.has(s))if(null==c)c=a;else if(c!=a&&0==g)throw new Error("Non matching ondex="+c+" and index="+a+" for code="+s+".");if(null==b)throw new Error("variable length unsupported");var _=Math.floor(3*(b-y)/4);if((n=n.slice(0,_)).length!=_)throw new Error("Not enougth raw bytes for code="+s+" and index="+a+" ,expected "+_+" got "+n.length+".");this._code=s,this._index=a,this._ondex=c,this._raw=n}else if(null!=d){var m=L(d);this._exfil(m)}else if(null!=f)this._exfil(f);else{if(null==v)throw new S("Improper initialization need either (raw and code and index) or qb64b or qb64 or qb2.");this._bexfil(v)}}var t=e.prototype;return t._bexfil=function(e){throw new Error("qb2 not yet supported: "+e)},e._rawSize=function(t){var r=e.Sizes.get(t);return Math.floor(r.fs-3*(r.hs+r.ss)/4)},t._infil=function(){var t=this.code,r=this.index,n=this.ondex,i=this.raw,a=(3-i.length%3)%3,u=e.Sizes.get(t),c=u.hs+u.ss,h=u.ss-u.os;if(r<0||r>Math.pow(64,h)-1)throw new Error("Invalid index="+r+" for code="+t+".");if(null!=n&&0!=u.os&&!(n>=0&&n<=Math.pow(64,u.os)-1))throw new Error("Invalid ondex="+n+" for os="+u.os+" and code="+t+".");var d=""+t+D(r,h)+D(null==n?0:n,u.os);if(d.length!=c)throw new Error("Mismatch code size = "+c+" with table = "+d.length+".");if(c%4!=a-u.ls)throw new Error("Invalid code="+d+" for converted raw pad size="+a+".");for(var l=new Uint8Array(a+i.length),f=0;f<a;f++)l[f]=0;for(var p=0;p<i.length;p++)l[p+a]=i[p];var v=d+s.encode(o.Buffer.from(l)).slice(a-u.ls);if(v.length!=u.fs)throw new Error("Invalid code="+d+" for raw size="+i.length+".");return v},t._exfil=function(t){if(0==t.length)throw new Error("Empty Material");var r=t[0];if(!Array.from(e.Hards.keys()).includes(r))throw new Error("Unexpected code "+r);var n=e.Hards.get(r);if(t.length<n)throw new Error("Need "+(n-t.length)+" more characters.");var i=t.slice(0,n);if(!Array.from(e.Sizes.keys()).includes(i))throw new Error("Unsupported code "+i);var o=e.Sizes.get(i),a=o.hs+o.ss,u=o.ss-o.os;if(t.length<a)throw new Error("Need "+(a-t.length)+" more characters.");var c,h=T(t.slice(n,n+u)),d=t.slice(n+u,n+u+o.os);if(he.has(i)){if(0!=(c=0!=o.os?T(d):void 0)&&null!=c)throw new Error("Invalid ondex="+c+" for code="+i+".");c=void 0}else c=0!=o.os?T(d):h;if(null==o.fs)throw new Error("variable length not supported");if(t.length<o.fs)throw new Error("Need "+(o.fs-t.length)+" more chars.");t=t.slice(0,o.fs);var l,f=a%4,p=2*f!=0?f:o.ls;if(0!=f){var v=new Array(f+1).join("A")+t.slice(a),w=s.decode(v);if(R(w.slice(0,f))&Math.pow(2,p)-1)throw new Error("Non zeroed prepad bits = {pi & (2 ** pbs - 1 ):<06b} in {qb64b[cs:cs+1]}.");l=w.slice(f)}else{var g=t.slice(a),b=s.decode(g),y=R(b.slice(0,o.ls));if(0!=y)throw 1==y?new Error("Non zeroed lead byte = 0x{li:02x}."):new Error("Non zeroed lead bytes = 0x{li:04x}");l=b.slice(o.ls)}if(l.length!=Math.floor(3*(t.length-a)/4))throw new Error("Improperly qualified material = "+t);this._code=i,this._index=h,this._ondex=c,this._raw=new Uint8Array(l)},v(e,[{key:"code",get:function(){return this._code}},{key:"raw",get:function(){return this._raw}},{key:"index",get:function(){return this._index}},{key:"ondex",get:function(){return this._ondex}},{key:"qb64",get:function(){return this._infil()}},{key:"qb64b",get:function(){return P(this.qb64)}}]),e}();pe.Hards=new Map([["A",1],["B",1],["C",1],["D",1],["E",1],["F",1],["G",1],["H",1],["I",1],["J",1],["K",1],["L",1],["M",1],["N",1],["O",1],["P",1],["Q",1],["R",1],["S",1],["T",1],["U",1],["V",1],["W",1],["X",1],["Y",1],["Z",1],["a",1],["b",1],["c",1],["d",1],["e",1],["f",1],["g",1],["h",1],["i",1],["j",1],["k",1],["l",1],["m",1],["n",1],["o",1],["p",1],["q",1],["r",1],["s",1],["t",1],["u",1],["v",1],["w",1],["x",1],["y",1],["z",1],["0",2],["1",2],["2",2],["3",2],["4",2]]),pe.Sizes=new Map(Object.entries({A:new fe(1,1,0,88,0),B:new fe(1,1,0,88,0),C:new fe(1,1,0,88,0),D:new fe(1,1,0,88,0),E:new fe(1,1,0,88,0),F:new fe(1,1,0,88,0),"0A":new fe(2,2,1,156,0),"0B":new fe(2,2,1,156,0),"2A":new fe(2,4,2,92,0),"2B":new fe(2,4,2,92,0),"2C":new fe(2,4,2,92,0),"2D":new fe(2,4,2,92,0),"2E":new fe(2,4,2,92,0),"2F":new fe(2,4,2,92,0),"3A":new fe(2,6,3,160,0),"3B":new fe(2,6,3,160,0),"0z":new fe(2,2,0,void 0,0),"1z":new fe(2,2,1,76,1),"4z":new fe(2,6,3,80,1)}));var ve,we=function(e){function t(t,r){var n;if(n=e.call(this,{raw:t.raw,code:t.code,index:t.index,ondex:t.ondex,qb64:t.qb64,qb64b:t.qb64b,qb2:t.qb2})||this,!ue.has(n.code))throw new Error("Invalid code = "+n.code+" for Siger.");return n._verfer=r,n}return g(t,e),v(t,[{key:"verfer",get:function(){return this._verfer},set:function(e){this._verfer=e}}]),t}(pe),ge=function(e){function t(t){var n,i,s=t.raw,o=t.code,a=void 0===o?F.Ed25519_Seed:o,u=t.qb64,c=t.qb64b,h=t.qb2,d=t.transferable,l=void 0===d||d;try{n=e.call(this,{raw:s,code:a,qb64:u,qb64b:c,qb2:h})||this}catch(t){if(!(t instanceof S))throw t;if(a!=F.Ed25519_Seed)throw new Error("Unsupported signer code = "+a+".");var f=r.randombytes_buf(r.crypto_sign_SEEDBYTES);n=e.call(this,{raw:f,code:a,qb64:u,qb64b:c,qb2:h})||this}if(n.code!=F.Ed25519_Seed)throw new Error("Unsupported signer code = "+n.code+".");n._sign=n._ed25519;var p=r.crypto_sign_seed_keypair(n.raw);return i=new ne({raw:p.publicKey,code:l?F.Ed25519:F.Ed25519N}),n._verfer=i,_(n)}g(t,e);var n=t.prototype;return n.sign=function(e,t,r,n){return void 0===t&&(t=null),void 0===r&&(r=!1),void 0===n&&(n=void 0),this._sign(e,this.raw,this.verfer,t,r,n)},n._ed25519=function(e,t,n,i,s,a){void 0===s&&(s=!1);var u,c=r.crypto_sign_detached(e,o.Buffer.concat([t,n.raw]));return null==i?new ie({raw:c,code:F.Ed25519_Sig},n):(s?(a=void 0,u=i<=63?oe.Ed25519_Crt_Sig:oe.Ed25519_Big_Crt_Sig):(null==a&&(a=i),u=a==i&&i<=63?oe.Ed25519_Sig:oe.Ed25519_Big_Sig),new we({raw:c,code:u,index:i,ondex:a},n))},v(t,[{key:"verfer",get:function(){return this._verfer}}]),t}(re);(ve=exports.Tier||(exports.Tier={})).low="low",ve.med="med",ve.high="high";var be=function(e){function t(t){var n,i=t.raw,s=t.code,o=void 0===s?F.Salt_128:s,a=t.tier,u=void 0===a?exports.Tier.low:a,c=t.qb64,h=t.qb64b,d=t.qb2;try{n=e.call(this,{raw:i,code:o,qb64:c,qb64b:h,qb2:d})||this}catch(t){if(!(t instanceof S))throw t;if(o!=F.Salt_128)throw new Error("invalid code for Salter, only Salt_128 accepted");var l=r.randombytes_buf(r.crypto_pwhash_SALTBYTES);n=e.call(this,{raw:l,code:o})||this}if(n.code!=F.Salt_128)throw new Error("invalid code for Salter, only Salt_128 accepted");return n._tier=null!==u?u:exports.Tier.low,_(n)}g(t,e);var n=t.prototype;return n.stretch=function(e,t,n,i){var s,o;if(void 0===e&&(e=32),void 0===t&&(t=""),void 0===n&&(n=null),void 0===i&&(i=!1),n=null==n?this.tier:n,i)s=1,o=8192;else switch(n){case exports.Tier.low:s=2,o=67108864;break;case exports.Tier.med:s=3,o=268435456;break;case exports.Tier.high:s=4,o=1073741824;break;default:throw new Error("Unsupported security tier = "+n+".")}return r.crypto_pwhash(e,t,this.raw,s,o,r.crypto_pwhash_ALG_ARGON2ID13)},n.signer=function(e,t,r,n,i){void 0===e&&(e=F.Ed25519_Seed),void 0===t&&(t=!0),void 0===r&&(r=""),void 0===n&&(n=null),void 0===i&&(i=!1);var s=this.stretch(re._rawSize(e),r,n,i);return new ge({raw:s,code:e,transferable:t})},v(t,[{key:"tier",get:function(){return this._tier}}]),t}(re),ye=function(e){function t(t,n){var i,s=t.raw,o=t.code,a=void 0===o?F.X25519_Private:o,u=t.qb64,c=t.qb64b,h=t.qb2;void 0===n&&(n=void 0);try{i=e.call(this,{raw:s,code:a,qb64:u,qb64b:c,qb2:h})||this}catch(t){if(!(t instanceof S))throw t;if(null==n)throw t;var d=new ge({qb64b:n});if(d.code!=F.Ed25519_Seed)throw new Error("Unsupported signing seed derivation code "+d.code);var l=new Uint8Array(d.raw.length+d.verfer.raw.length);l.set(d.raw),l.set(d.verfer.raw,d.raw.length),s=r.crypto_sign_ed25519_sk_to_curve25519(l),i=e.call(this,{raw:s,code:a,qb64:u,qb64b:c,qb2:h})||this}if(i.code!=F.X25519_Private)throw new Error("Unsupported decrypter code = "+i.code+".");return i._decrypt=i._x25519,_(i)}g(t,e);var n=t.prototype;return n.decrypt=function(e,t,r){if(void 0===e&&(e=null),void 0===t&&(t=null),void 0===r&&(r=!1),null==e&&null==t)throw new S("Neither ser or cipher were provided");return null!=e&&(t=new xe({qb64b:e})),this._decrypt(t,this.raw,r)},n._x25519=function(e,t,n){void 0===n&&(n=!1);var i=r.crypto_scalarmult_base(t),s=r.crypto_box_seal_open(e.raw,i,t);if(e.code==F.X25519_Cipher_Salt)return new be({qb64b:s});if(e.code==F.X25519_Cipher_Seed)return new ge({qb64b:s,transferable:n});throw new Error("Unsupported cipher text code == "+e.code)},t}(re),xe=function(e){function t(t){var r,n=t.raw,i=t.code,s=t.qb64,o=t.qb64b,a=t.qb2;if(null!=n&&null==i&&(n.length==re._rawSize(F.X25519_Cipher_Salt)||n.length==re._rawSize(F.X25519_Cipher_Seed))&&(i=F.X25519_Cipher_Salt),r=e.call(this,{raw:n,code:i,qb64b:o,qb64:s,qb2:a})||this,!Array.from([F.X25519_Cipher_Salt,F.X25519_Cipher_Seed]).includes(r.code))throw new Error("Unsupported Cipher code == "+r.code);return r}return g(t,e),t.prototype.decrypt=function(e,t){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),new ye({qb64b:e},t).decrypt(this.qb64b)},t}(re);function _e(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function me(e,t){var r=[];try{if(e instanceof Array&&"string"!=typeof e)for(var n in e)me(e[n],t);else"string"==typeof e&&t.push(e);r=t}catch(e){throw new Error(e)}return r}function Ee(){return new Date}function ke(e,t){for(var r=new Uint8Array(t),n=0;n<r.length;n++){var i=255&e;r[n]=i,e=(e-i)/256}return r}function Se(e){for(var t=0,r=e.length-1;r>=0;r--)t=256*t+e[r];return t}var Ae,qe=function(e){function t(t,n){var i,s=t.raw,o=t.code,a=void 0===o?F.X25519:o,u=t.qb64,c=t.qb64b,h=t.qb2;if(void 0===n&&(n=null),null==s&&null!=n){var d=new ne({qb64b:n});if(!Array.from([F.Ed25519N,F.Ed25519]).includes(d.code))throw new Error("Unsupported verkey derivation code = "+d.code+".");s=r.crypto_sign_ed25519_pk_to_curve25519(d.raw)}if((i=e.call(this,{raw:s,code:a,qb64:u,qb64b:c,qb2:h})||this).code!=F.X25519)throw new Error("Unsupported encrypter code = "+i.code+".");return i._encrypt=i._x25519,i}g(t,e);var n=t.prototype;return n.verifySeed=function(e){var t=new ge({qb64b:e}),n=r.crypto_sign_seed_keypair(t.raw);return _e(r.crypto_sign_ed25519_pk_to_curve25519(n.publicKey),this.raw)},n.encrypt=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),null==e&&null==t)throw new Error("Neither ser nor matter are provided.");return null!=e&&(t=new re({qb64b:e})),this._encrypt(t.qb64,this.raw,t.code==F.Salt_128?F.X25519_Cipher_Salt:F.X25519_Cipher_Seed)},n._x25519=function(e,t,n){var i=r.crypto_box_seal(e,t);return new xe({raw:i,code:n})},t}(re),Ie=function(e){function t(t,r){var n,i=t.raw,s=t.code,o=void 0===s?F.Blake3_256:s,a=t.qb64,c=t.qb64b,h=t.qb2;void 0===r&&(r=null);try{n=e.call(this,{raw:i,code:o,qb64:a,qb64b:c,qb2:h})||this}catch(t){if(null==r)throw t;if(o!==F.Blake3_256)throw new Error("Unsupported code = "+o+" for digester.");var d=u.createHash().update(r).digest("");n=e.call(this,{raw:d,code:o})||this}if(o!==F.Blake3_256)throw new Error("Unsupported code = "+o+" for digester.");return n._verify=n.blake3_256,_(n)}g(t,e);var r=t.prototype;return r.verify=function(e){return this._verify(e,this.raw)},r.compare=function(e,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),null!=r){if(r.toString()==this.qb64)return!0;n=new t({qb64b:r})}else{if(null==n)throw new Error("Both dig and diger may not be None.");if(n.qb64b==this.qb64b)return!0}return n.code!=this.code&&n.verify(e)&&this.verify(e)},r.blake3_256=function(e,t){return u.createHash().update(e).digest("").toString()===t.toString()},t}(re);(Ae=exports.Algos||(exports.Algos={})).randy="randy",Ae.salty="salty",Ae.group="group",Ae.extern="extern";var Be=function(){this.pubs=new Array,this.ridx=0,this.kidx=0,this.dt=""},Ce=function(){this.old=new Be,this.new=new Be,this.nxt=new Be},Me=function(){this.pidx=0,this.algo=exports.Algos.salty,this.salt="",this.stem="",this.tier=""},Ne=function(){this.pubs=new Array},Oe=function(){this.path="",this.code="",this.tier=exports.Tier.high,this.temp=!1},ze=function(){function e(e,t){if(this._signers=e,null!=t&&e.length!=t.length)throw new Error("If paths are provided, they must be the same length as signers");this._paths=t}return v(e,[{key:"paths",get:function(){return this._paths}},{key:"signers",get:function(){return this._signers}}]),e}(),je=function(){function e(){}return e.prototype.create=function(e,t,r,n){void 0===e&&(e=void 0),void 0===t&&(t=1),void 0===r&&(r=F.Ed25519_Seed),void 0===n&&(n=!0);var i=new Array;return null==e&&(e=new Array(t).fill(r)),e.forEach((function(e){i.push(new ge({code:e,transferable:n}))})),new ze(i)},v(e,[{key:"salt",get:function(){return""}},{key:"stem",get:function(){return""}},{key:"tier",get:function(){return""}}]),e}(),De=function(){function e(e,t,r){void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===r&&(r=void 0),this.salter=new be({qb64:e,tier:t}),this._stem=null==r?"":r}return e.prototype.create=function(e,t,r,n,i,s,o,a){var u=this;void 0===e&&(e=void 0),void 0===t&&(t=1),void 0===r&&(r=F.Ed25519_Seed),void 0===n&&(n=!0),void 0===i&&(i=0),void 0===s&&(s=0),void 0===o&&(o=0),void 0===a&&(a=!1);var c=new Array,h=new Array;return null==e&&(e=new Array(t).fill(r)),e.forEach((function(e,t){var r=""==u.stem?i.toString(16):u.stem+s.toString(16)+(o+t).toString(16);c.push(u.salter.signer(e,n,r,u.tier,a)),h.push(r)})),new ze(c,h)},v(e,[{key:"salt",get:function(){return this.salter.qb64}},{key:"stem",get:function(){return this._stem}},{key:"tier",get:function(){return this.salter.tier}}]),e}(),Te=function(){function e(e){switch(void 0===e&&(e=exports.Algos.salty),e){case exports.Algos.randy:this._make=this._makeRandy;break;case exports.Algos.salty:this._make=this._makeSalty;break;default:throw new Error("unsupported algo="+e)}}var t=e.prototype;return t.make=function(){return this._make.apply(this,arguments)},t._makeRandy=function(){return new je},t._makeSalty=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return x(De,t)},e}(),Pe=function(){function e(e){var t=e.ks,r=e.seed,n=e.aeid,i=e.pidx,s=e.algo,o=e.salter,a=e.tier;this._ks=null==t?new Ue:t,this._seed=r,this._encrypter=void 0,this._decrypter=void 0,n=null==n?void 0:n,i=null==i?0:i,s=null==s?exports.Algos.salty:s;var u=null==o?void 0:o.qb64;a=null==a?exports.Tier.low:a,null==this.pidx&&(this.pidx=i),null==this.algo&&(this.algo=s),null==this.salt&&(this.salt=u),null==this.tier&&(this.tier=a),null==this.aeid&&this.updateAeid(n,this._seed)}var t=e.prototype;return t.updateAeid=function(e,t){if(null!=this.aeid){var r,n=P(this._seed);if(null==this._seed||null==(r=this._encrypter)||!r.verifySeed(n))throw new Error('Last seed missing or provided last seed "\n "not associated with last aeid='+this.aeid+".")}if(""!=e&&null!=e){if(e!=this.aeid&&(this._encrypter=new qe({},P(e)),null==t||!this._encrypter.verifySeed(P(t))))throw new Error('Seed missing or provided seed not associated"\n " with provided aeid='+e+".")}else{if(this.algo==exports.Algos.randy)throw new Error("Invalid Manager configuration, encryption must be used with Randy key creation.");this._encrypter=void 0}var i=this.salt;if(null!=i&&(this.salt=i),null!=this._decrypter){for(var s,o=E(this.ks.prmsElements());!(s=o()).done;){var a=s.value,u=a[0],c=a[1];if(null!=c.salt){var h=this._decrypter.decrypt(P(c.salt));c.salt=null==this._encrypter?h.qb64:this._encrypter.encrypt(null,h),this.ks.pinPrms(u,c)}}for(var d,l=E(this.ks.prisElements(this._decrypter));!(d=l()).done;){var f=d.value;this.ks.pinPris(f[0],f[1],this._encrypter)}}this.ks.pinGbls("aeid",e),this._seed=t,this._decrypter=null!=t?new ye({},P(t)):void 0},t.incept=function(e){var t=this,r=e.icodes,n=void 0===r?void 0:r,i=e.icount,s=void 0===i?1:i,o=e.icode,a=void 0===o?F.Ed25519_Seed:o,u=e.ncodes,c=void 0===u?void 0:u,h=e.ncount,d=void 0===h?1:h,l=e.ncode,f=void 0===l?F.Ed25519_Seed:l,p=e.dcode,v=void 0===p?F.Blake3_256:p,w=e.algo,g=void 0===w?void 0:w,b=e.salt,y=void 0===b?void 0:b,x=e.stem,_=void 0===x?void 0:x,m=e.tier,E=void 0===m?void 0:m,k=e.rooted,S=void 0===k||k,A=e.transferable,q=void 0===A||A,I=e.temp,B=void 0!==I&&I;S&&null==g&&(g=this.algo),S&&null==y&&(y=this.salt),S&&null==E&&(E=this.tier);var C=this.pidx,M=new Te(g).make(y,E,_);if(null==n){if(s<0)throw new Error("Invalid icount="+s+" must be >= 0.");n=new Array(s).fill(a)}var N=M.create(n,0,F.Ed25519_Seed,q,C,0,0,B),O=Array.from(N.signers,(function(e){return e.verfer}));if(null==c){if(d<0)throw new Error("Invalid ncount="+d+" must be >= 0.");c=new Array(d).fill(f)}var z=M.create(c,0,F.Ed25519_Seed,q,C,1,0+n.length,B),j=Array.from(z.signers,(function(e){return new Ie({code:v},e.verfer.qb64b)})),D=new Me;D.pidx=C,D.algo=g,D.salt=0==M.salt.length||null==this.encrypter?"":this.encrypter.encrypt(P(M.salt)).qb64,D.stem=M.stem,D.tier=M.tier;var T=(new Date).toString(),L=new Be;L.pubs=Array.from(O,(function(e){return e.qb64})),L.ridx=0,L.kidx=0,L.dt=T;var U=new Be;U.pubs=Array.from(z.signers,(function(e){return e.verfer.qb64})),U.ridx=1,U.kidx=0+n.length,U.dt=T;var R=new Ce;R.new=L,R.nxt=U;var G=O[0].qb64;if(!this.ks.putPres(G,O[0].qb64b))throw new Error("Already incepted pre="+G+".");if(!this.ks.putPrms(G,D))throw new Error("Already incepted prm for pre="+G+".");if(this.pidx=C+1,!this.ks.putSits(G,R))throw new Error("Already incepted sit for pre="+G+".");if(null!=this.encrypter)N.signers.forEach((function(e){t.ks.putPris(e.verfer.qb64,e,t.encrypter)})),z.signers.forEach((function(e){t.ks.putPris(e.verfer.qb64,e,t.encrypter)}));else{if(null!=this._encrypter||null==N.paths||null==z.paths)throw new Error("invalid configuration, randy keys without encryption");N.paths.forEach((function(e,r){var i=N.signers[r],s=new Oe;s.path=e,s.code=n[r],s.tier=D.tier,s.temp=B,t.ks.putPths(i.verfer.qb64,s)})),z.paths.forEach((function(e,r){var n=z.signers[r],i=new Oe;i.path=e,i.code=c[r],i.tier=D.tier,i.temp=B,t.ks.putPths(n.verfer.qb64,i)}))}var H=new Ne;H.pubs=R.new.pubs,this.ks.putPubs(Le(G,0),H);var J=new Ne;return J.pubs=R.nxt.pubs,this.ks.putPubs(Le(G,1),J),[O,j]},t.move=function(e,t){if(e!=t){if(null==this.ks.getPres(e))throw new Error("Nonexistent old pre="+e+", nothing to assign.");if(null!=this.ks.getPres(t))throw new Error("Preexistent new pre="+t+" may not clobber.");var r=this.ks.getPrms(e);if(null==r)throw new Error("Nonexistent old prm for pre="+e+", nothing to move.");if(null!=this.ks.getPrms(t))throw new Error("Preexistent new prm for pre="+t+" may not clobber.");var n=this.ks.getSits(e);if(null==n)throw new Error("Nonexistent old sit for pre="+e+", nothing to move.");if(null!=this.ks.getSits(t))throw new Error("Preexistent new sit for pre="+t+" may not clobber.");if(!this.ks.putPrms(t,r))throw new Error("Failed moving prm from old pre="+e+" to new pre="+t+".");if(this.ks.remPrms(e),!this.ks.putSits(t,n))throw new Error("Failed moving sit from old pre="+e+" to new pre="+t+".");this.ks.remSits(e);for(var i=0;;){var s=this.ks.getPubs(Le(e,i));if(null==s)break;if(!this.ks.putPubs(Le(t,i),s))throw new Error("Failed moving pubs at pre="+e+" ri="+i+" to new pre="+t);i+=1}if(!this.ks.pinPres(e,P(t)))throw new Error("Failed assiging new pre="+t+" to old pre="+e+".");if(!this.ks.putPres(t,P(t)))throw new Error("Failed assiging new pre="+t+".")}},t.rotate=function(e){var t=this,r=e.pre,n=e.ncodes,i=void 0===n?void 0:n,s=e.ncount,o=void 0===s?1:s,a=e.ncode,u=void 0===a?F.Ed25519_Seed:a,c=e.dcode,h=void 0===c?F.Blake3_256:c,d=e.transferable,l=void 0===d||d,f=e.temp,p=void 0!==f&&f,v=e.erase,w=void 0===v||v,g=this.ks.getPrms(r);if(null==g)throw new Error("Attempt to rotate nonexistent pre="+r+".");var b=this.ks.getSits(r);if(null==b)throw new Error("Attempt to rotate nonexistent pre="+r+".");if(null==b.nxt.pubs||0==b.nxt.pubs.length)throw new Error("Attempt to rotate nontransferable pre="+r+".");var y=b.old;if(b.old=b.new,b.new=b.nxt,null!=this.aeid&&null==this.decrypter)throw new Error("Unauthorized decryption attempt. Aeid but no decrypter.");var x=new Array;b.new.pubs.forEach((function(e){if(null!=t.decrypter){var r=t.ks.getPris(e,t.decrypter);if(null==r)throw new Error("Missing prikey in db for pubkey="+e);x.push(r.verfer)}else x.push(new ne({qb64:e}))}));var _=g.salt;if(null!=_&&""!=_){if(null==this.decrypter)throw new Error("Invalid configuration: AID salt with no encryption");_=this.decrypter.decrypt(P(_)).qb64}else _=this.salt;var m=new Te(g.algo).make(_,g.tier,g.stem);if(null==i){if(o<0)throw new Error("Invalid count="+o+" must be >= 0");i=new Array(o).fill(u)}var E=b.new.ridx+1,k=b.nxt.kidx+b.new.pubs.length,S=m.create(i,0,"",l,g.pidx,E,k,p),A=Array.from(S.signers,(function(e){return new Ie({code:h},e.verfer.qb64b)})),q=(new Date).toString();if(b.nxt=new Be,b.nxt.pubs=Array.from(S.signers,(function(e){return e.verfer.qb64})),b.nxt.ridx=E,b.nxt.kidx=k,b.nxt.dt=q,!this.ks.pinSits(r,b))throw new Error("Problem updating pubsit db for pre="+r+".");if(null!=this.encrypter)S.signers.forEach((function(e){t.ks.putPris(e.verfer.qb64,e,t.encrypter)}));else{if(null!=this._encrypter||null==S.paths)throw new Error("invalid configuration, randy keys without encryption");S.paths.forEach((function(e,r){var n=S.signers[r],i=new Oe;i.path=e,i.tier=g.tier,i.temp=p,t.ks.putPths(n.verfer.qb64,i)}))}var I=new Ne;return I.pubs=b.nxt.pubs,this.ks.putPubs(Le(r,b.nxt.ridx),I),w&&y.pubs.forEach((function(e){t.ks.remPris(e)})),[x,A]},t.sign=function(e){var t=this,r=e.ser,n=e.pubs,i=void 0===n?void 0:n,s=e.verfers,o=void 0===s?void 0:s,a=e.indexed,u=void 0===a||a,c=e.indices,h=void 0===c?void 0:c,d=e.ondices,l=void 0===d?void 0:d,f=new Array;if(null==i&&null==o)throw new Error("pubs or verfers required");if(null!=i){if(null!=this.aeid&&null==this.decrypter)throw new Error("Unauthorized decryption attempt. Aeid but no decrypter.");i.forEach((function(e){if(null!=t.decrypter){var r=t.ks.getPris(e,t.decrypter);if(null==r)throw new Error("Missing prikey in db for pubkey="+e);f.push(r)}else{var n=new ne({qb64:e}),i=t.ks.getPths(e);if(null==i)throw new Error("Missing prikey in db for pubkey="+e);var s=new be({qb64:t.salt});f.push(s.signer(i.code,n.transferable,i.path,i.tier,i.temp))}}))}else o.forEach((function(e){if(null!=t.decrypter){var r=t.ks.getPris(e.qb64,t.decrypter);if(null==r)throw new Error("Missing prikey in db for pubkey="+e.qb64);f.push(r)}else{var n=t.ks.getPths(e.qb64);if(null==n)throw new Error("Missing prikey in db for pubkey="+e.qb64);var i=new be({qb64:t.salt});f.push(i.signer(n.code,e.transferable,n.path,n.tier,n.temp))}}));if(null!=h&&h.length!=f.length)throw new Error("Mismatch indices length="+h.length+" and resultant signers length="+f.length);if(null!=l&&l.length!=f.length)throw new Error("Mismatch ondices length="+l.length+" and resultant signers length="+f.length);if(u){var p=new Array;return f.forEach((function(e,t){var n,i;if(null!=h){if((n=h[t])<0)throw new Error("Invalid signing index = "+n+", not whole number.")}else n=t;if(null!=l){if((i=l[t])<=0)throw new Error("Invalid other signing index = {o}, not None or not whole number.")}else i=n;p.push(e.sign(r,n,null==i,i))})),p}var v=new Array;return f.forEach((function(e){v.push(e.sign(r))})),v},v(e,[{key:"ks",get:function(){return this._ks}},{key:"encrypter",get:function(){return this._encrypter}},{key:"decrypter",get:function(){return this._decrypter}},{key:"seed",get:function(){return this._seed}},{key:"aeid",get:function(){return this.ks.getGbls("aeid")}},{key:"pidx",get:function(){var e=this.ks.getGbls("pidx");if(null!=e)return parseInt(e,16)},set:function(e){this.ks.pinGbls("pidx",e.toString(16))}},{key:"salt",get:function(){if(null==this._decrypter)return this._salt;var e=this.ks.getGbls("salt");return this._decrypter.decrypt(P(e)).qb64},set:function(e){null==this._encrypter?this._salt=e:(e=this._encrypter.encrypt(P(e)).qb64,this.ks.pinGbls("salt",e))}},{key:"tier",get:function(){return this.ks.getGbls("tier")},set:function(e){this.ks.pinGbls("tier",e)}},{key:"algo",get:function(){var e=this.ks.getGbls("algo");return exports.Algos[e]},set:function(e){this.ks.pinGbls("algo",e)}}]),e}();function Le(e,t){return e+"."+t.toString(16).padStart(32,"0")}var Ue=function(){function e(){this._gbls=new Map,this._pris=new Map,this._pths=new Map,this._pres=new Map,this._prms=new Map,this._sits=new Map,this._pubs=new Map}var t=e.prototype;return t.getGbls=function(e){return this._gbls.get(e)},t.pinGbls=function(e,t){this._gbls.set(e,t)},t.prmsElements=function(){var e=new Array;return this._prms.forEach((function(t,r){e.push([r,t])})),e},t.getPrms=function(e){return this._prms.get(e)},t.pinPrms=function(e,t){this._prms.set(e,t)},t.putPrms=function(e,t){return!this._prms.has(e)&&(this._prms.set(e,t),!0)},t.remPrms=function(e){return this._prms.delete(e)},t.prisElements=function(e){var t=new Array;return this._pris.forEach((function(r,n){var i=new ne({qb64:n}),s=e.decrypt(r,null,i.transferable);t.push([n,s])})),t},t.pinPris=function(e,t,r){var n=r.encrypt(null,t);this._pris.set(e,n.qb64b)},t.putPris=function(e,t,r){if(this._pris.has(e))return!1;var n=r.encrypt(null,t);return this._pris.set(e,n.qb64b),!0},t.getPris=function(e,t){var r=this._pris.get(e);if(null!=r){var n=new ne({qb64:e});return t.decrypt(r,null,n.transferable)}},t.pinPths=function(e,t){return this._pths.set(e,t),!0},t.putPths=function(e,t){return!this._pths.has(e)&&(this._pths.set(e,t),!0)},t.getPths=function(e){return this._pths.get(e)},t.remPris=function(e){this._pris.delete(e)},t.getPres=function(e){return this._pres.get(e)},t.pinPres=function(e,t){return this._pres.set(e,t),!0},t.putPres=function(e,t){return!this._pres.has(e)&&(this._pres.set(e,t),!0)},t.getSits=function(e){return this._sits.get(e)},t.putSits=function(e,t){return!this._sits.has(e)&&(this._sits.set(e,t),!0)},t.pinSits=function(e,t){return this._sits.set(e,t),!0},t.remSits=function(e){return this._sits.delete(e)},t.getPubs=function(e){return this._pubs.get(e)},t.putPubs=function(e,t){return!this._pubs.has(e)&&(this._pubs.set(e,t),!0)},e}(),Re=function(e){function t(t,r,n){var i,s,o=t.raw,a=t.code,u=t.qb64b,c=t.qb64,h=t.qb2;if(null==o&&null==c&&null==u&&null==h&&(s="number"==typeof r?r:null!=n?parseInt(n,16):0),null==s)throw new Error("Invalid whole number");if(s<=Math.pow(256,2)-1)a=W.Short;else if(s<=Math.pow(256,4)-1)a=a=W.Long;else if(s<=Math.pow(256,8)-1)a=a=W.Big;else{if(!(s<=Math.pow(256,16)-1))throw new Error("Invalid num = {num}, too large to encode.");a=a=W.Huge}if(o=ke(s,re._rawSize(a)),i=e.call(this,{raw:o,code:a,qb64b:u,qb64:c,qb2:h})||this,!W.has(i.code))throw new Error("Invalid code "+a+" for Number");return i}return g(t,e),v(t,[{key:"num",get:function(){return Se(this.raw)}},{key:"numh",get:function(){return this.num.toString(16)}},{key:"positive",get:function(){return this.num>0}}]),t}(re),Ge=function(){function e(e){if(this._weighted=!1,this._thold=void 0,this._size=0,this._number=void 0,this._satisfy=void 0,void 0!==e.thold)this._processThold(e.thold);else if(null!=e.limen)this._processLimen(e.limen);else{if(void 0===e.sith)throw new Error("Missing threshold expression");this._processSith(e.sith)}}var t=e.prototype;return t._processThold=function(e){"number"==typeof e?this._processUnweighted(e):this._processWeighted(e)},t._processLimen=function(e){var t=new re({qb64:e});if(W.has(t.code)){var r=new Re({raw:t.raw,code:t.code});this._processUnweighted(r.num)}else if(!Q.has(t.code))throw new Error("Invalid code for limen="+t.code)},t._processSith=function(e){if("number"==typeof e)this._processUnweighted(e);else if("string"==typeof e&&-1==e.indexOf("["))this._processUnweighted(parseInt(e,16));else{var t=e;if("string"==typeof e&&(t=JSON.parse(e)),0==t.length)throw new Error("Empty weight list");var r=t.map((function(e){return"string"!=typeof e}));r.length>0&&!r.every((function(e){return e}))&&(t=[t]);for(var n,i=E(t);!(n=i()).done;){var s=n.value.map((function(e){return"string"==typeof e}));if(s.length>0&&!s.every((function(e){return e})))throw new Error("Invalid sith, some weights in clause "+s+" are non string")}var o=this._processClauses(t);this._processWeighted(o)}},t._processClauses=function(e){var t=this,r=new Array;return e.forEach((function(e){r.push(e.map((function(e){return t.weight(e)})))})),r},t._processUnweighted=function(e){if(e<0)throw new Error("Non-positive int threshold = {thold}.");this._thold=e,this._weighted=!1,this._size=this._thold,this._satisfy=this._satisfy_numeric,this._number=new Re({},e)},t._processWeighted=function(e){for(var t,r=E(e);!(t=r()).done;)if(Number(tr.sum(t.value))<1)throw new Error("Invalid sith clause: "+e+"all clause weight sums must be >= 1");this._thold=e,this._weighted=!0,this._size=e.reduce((function(e,t){return e+t.length}),0),this._satisfy=this._satisfy_weighted},t.weight=function(e){return tr.fraction(e)},t._satisfy_numeric=function(e){return this.thold>0&&e.length>=this.thold},t._satisfy_weighted=function(e){if(0===e.length)return!1;for(var t,r=new Set(e.sort()),n=new Array(e.length).fill(!1),i=E(r);!(t=i()).done;)n[t.value]=!0;for(var s,o=0,a=E(this.thold);!(s=a()).done;){for(var u,c=0,h=E(s.value);!(u=h()).done;)n[o]&&(c+=Number(u.value)),o+=1;if(c<1)return!1}return!0},t.satisfy=function(e){return this._satisfy(e)},v(e,[{key:"weighted",get:function(){return this._weighted}},{key:"thold",get:function(){return this._thold}},{key:"size",get:function(){return this._size}},{key:"limen",get:function(){var e;return null==(e=this._number)?void 0:e.qb64b}},{key:"sith",get:function(){if(this.weighted){var e=this.thold.map((function(e){return e.map((function(e){return 0<Number(e)&&Number(e)<1?tr.format(e,{fraction:"ratio"}):tr.format(e,{fraction:"decimal"})}))}));return 1==e.length&&(e=e[0]),e}return this.thold.toString(16)}},{key:"json",get:function(){return JSON.stringify(this.sith)}},{key:"num",get:function(){return this._weighted?void 0:this._thold}}]),e}(),He=function(){function e(e,t,r){void 0===t&&(t=exports.Serials.JSON),void 0===r&&(r=F.Blake3_256),this._raw="",this._ked={},this._ident=exports.Ident.KERI,this._size=0,this._version=q,this._code=r,this._kind=t,this.ked=e}var t=e.prototype;return t._exhale=function(e,t){return Je(e,t)},t.pretty=function(){return JSON.stringify(this._ked,void 0,2)},v(e,[{key:"ked",get:function(){return this._ked},set:function(e){var t=this._exhale(e,this._kind),r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=r.length;this._raw=r,this._ident=n,this._ked=s,this._kind=i,this._size=a,this._version=o}},{key:"pre",get:function(){return this._ked.i}},{key:"code",get:function(){return this._code}},{key:"raw",get:function(){return this._raw}},{key:"kind",get:function(){return this._kind}},{key:"ident",get:function(){return this._ident}},{key:"size",get:function(){return this._size}},{key:"version",get:function(){return this._version}},{key:"verfers",get:function(){for(var e,t=[],r=(E("k"in this._ked?this._ked.k:[]));!(e=r()).done;)t.push(new ne({qb64:e.value}));return t}},{key:"digers",get:function(){for(var e,t=[],r=(E("n"in this._ked?this._ked.n:[]));!(e=r()).done;)t.push(new Ie({qb64:e.value}));return t}}]),e}();function Fe(e,t){if(t==exports.Serials.JSON)return JSON.stringify(e);throw new Error("unsupported event encoding")}function Je(e,t){if(!("v"in e))throw new Error("Missing or empty version string");var r=N(e.v),n=r[0],i=r[1],s=r[2];if(s!=q)throw new Error("unsupported version "+s.toString());null==t&&(t=i);var o=Fe(e,t);return e.v=O(n,s,t,o.length),[o=Fe(e,t),n,t,e,s]}var Ke=function(e){function t(r,n){var i,s=r.raw,o=r.code,a=r.qb64b,u=r.qb64,c=r.qb2;try{i=e.call(this,{raw:s,code:o,qb64b:a,qb64:u,qb2:c})||this}catch(r){if(!(r instanceof S))throw r;if(null==n||null==o&&!("i"in n))throw r;var h;if(null==o&&(o=(i=e.call(this,{qb64:n.i,code:o})||this).code),o==F.Ed25519N)h=t._derive_ed25519N;else if(o==F.Ed25519)h=t._derive_ed25519;else{if(o!=F.Blake3_256)throw new Error("Unsupported code = "+o+" for prefixer.");h=t._derive_blake3_256}var d=h(n);(i=e.call(this,{raw:s=d[0],code:o=d[1]})||this)._derive=h}if(i.code==F.Ed25519N)i._verify=i._verify_ed25519N;else if(i.code==F.Ed25519)i._verify=i._verify_ed25519;else{if(i.code!=F.Blake3_256)throw new Error("Unsupported code = "+o+" for prefixer.");i._verify=i._verify_blake3_256}return _(i)}g(t,e);var r=t.prototype;return r.derive=function(e){if(e.i!=I.icp)throw new Error("Non-incepting ilk "+e.i+" for prefix derivation");return this._derive(e)},r.verify=function(e,t){if(void 0===t&&(t=!1),e.i!=I.icp)throw new Error("Non-incepting ilk "+e.i+" for prefix derivation");return this._verify(e,this.qb64,t)},t._derive_ed25519N=function(e){var t,r=e.k;if(1!=r.length)throw new Error("Basic derivation needs at most 1 key got "+r.length+" keys instead");try{t=new ne({qb64:r[0]})}catch(e){throw new Error("Error extracting public key = "+e)}if(!(t.code in[F.Ed25519N]))throw new Error("Mismatch derivation code = "+t.code);var n="n"in e?e.n:[];if(t.code==F.Ed25519N&&n.length>0)throw new Error("Non-empty nxt = "+n+" for non-transferable code = "+t.code);var i="b"in e?e.b:[];if(t.code==F.Ed25519N&&i.length>0)throw new Error("Non-empty b ="+i+" for non-transferable code = "+t.code);if(t.code==F.Ed25519N&&("a"in e?e.a:[]).length>0)throw new Error("Non-empty a = "+t.code+" for non-transferable code = "+t.code);return[t.raw,t.code]},t._derive_ed25519=function(e){var t,r=e.k;if(1!=r.length)throw new Error("Basic derivation needs at most 1 key got "+r.length+" keys instead");try{t=new ne({qb64:r[0]})}catch(e){throw new Error("Error extracting public key = "+e)}if(t.code in[F.Ed25519])throw new Error("Mismatch derivation code = "+t.code);return[t.raw,t.code]},t._derive_blake3_256=function(e){var t=e,r=e.t;if(![I.icp,I.dip,I.vcp,I.dip].includes(r))throw new Error("Invalid ilk = "+r+" to derive pre.");t.i="".padStart(re.Sizes.get(F.Blake3_256).fs,"#"),t.d=e.i;var n=Je(e)[0];return[u.createHash().update(n).digest(""),F.Blake3_256]},r._verify_ed25519N=function(e,t,r){void 0===r&&(r=!1);try{var n=e.k;if(1!=n.length)return!1;if(n[0]!=t)return!1;if(r&&e.i!=t)return!1;if(("n"in e?e.n:[]).length>0)return!1}catch(e){return!1}return!0},r._verify_ed25519=function(e,t,r){void 0===r&&(r=!1);try{var n=e.k;if(1!=n.length)return!1;if(n[0]!=t)return!1;if(r&&e.i!=t)return!1}catch(e){return!1}return!0},r._verify_blake3_256=function(e,r,n){void 0===n&&(n=!1);try{var i=t._derive_blake3_256(e);if(new re({raw:i[0],code:F.Blake3_256}).qb64!=r)return!1;if(n&&e.i!=r)return!1}catch(e){return!1}return!0},t}(re);(exports.Ids||(exports.Ids={})).d="d";var Xe=function(e,t,r){this.klas=void 0,this.size=0,this.length=0,this.klas=e,this.size=t,this.length=r},Ve=function(e){function t(r,n,i,s){var o,a=r.raw,u=r.code,c=r.qb64b,h=r.qb64,d=r.qb2;void 0===s&&(s=exports.Ids.d);try{o=e.call(this,{raw:a,code:u,qb64b:c,qb64:h,qb2:d})||this}catch(r){if(!(r instanceof S))throw r;if(null==n||!(s in n))throw r;if(null==u&&(u=""!=n[s]?(o=e.call(this,{qb64:n[s],code:u})||this).code:F.Blake3_256),!V.has(u))throw new Error("Unsupported digest code = "+u);var l=t._derive(w({},n),u,i,s);o=e.call(this,{raw:a=l[0],code:u})||this}if(!o.digestive)throw new Error("Unsupported digest code = "+o.code+".");return _(o)}g(t,e),t._derive_blake3_256=function(e,t,r){return u.createHash().update(e).digest("")},t._derive=function(e,r,n,i){if(!V.has(r)||!t.Digests.has(r))throw new Error("Unsupported digest code = "+r+".");if((e=w({},e))[i]="".padStart(re.Sizes.get(r).fs,"#"),"v"in e){var s=Je(e,n);n=s[2],e=s[3]}var o=w({},e),a=t.Digests.get(r),u=t._serialze(o,n),c=[];return null!=a.size&&c.push(a.size),null!=a.length&&c.push(a.length),[a.klas.apply(a,[u].concat(c)),e]};var r=t.prototype;return r.derive=function(e,r,n,i){return t._derive(e,r=null!=r?r:this.code,n,i)},r.verify=function(e,r,n,i,s){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===s&&(s=exports.Ids.d);try{var o=t._derive(e,this.code,i,s),a=o[1],u=new t({raw:o[0],code:this.code});if(this.qb64!=u.qb64)return!1;if("v"in e&&n&&e.v!=a.v)return!1;if(r&&e[s]!=this.qb64)return!1}catch(e){return!1}return!0},t._serialze=function(e,t){var r=exports.Serials.JSON;return"v"in e&&(r=N(e.v)[1]),null==t&&(t=r),Fe(e,t)},t.saidify=function(e,r,n,i){if(void 0===r&&(r=F.Blake3_256),void 0===n&&(n=exports.Serials.JSON),void 0===i&&(i=exports.Ids.d),!(i in e))throw new Error("Missing id field labeled="+i+" in sad.");var s=t._derive(e,r,n,i);e=s[1];var o=new t({raw:s[0],code:r},void 0,n,i);return e[i]=o.qb64,[o,e]},t}(re);Ve.Digests=new Map([[F.Blake3_256,new Xe(Ve._derive_blake3_256,void 0,void 0)]]);var Ze=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).ControllerIdxSigs="-A",t.WitnessIdxSigs="-B",t.NonTransReceiptCouples="-C",t.TransReceiptQuadruples="-D",t.FirstSeenReplayCouples="-E",t.TransIdxSigGroups="-F",t.SealSourceCouples="-G",t.TransLastIdxSigGroups="-H",t.SealSourceTriples="-I",t.SadPathSig="-J",t.SadPathSigGroup="-K",t.PathedMaterialQuadlets="-L",t.AttachedMaterialQuadlets="-V",t.BigAttachedMaterialQuadlets="-0V",t.KERIProtocolStack="--AAA",t}return g(t,e),t}(G),We=new Ze,Ye=function(){function e(t){var r=t.code,n=t.count,i=t.countB64,s=t.qb64b,o=t.qb64,a=t.qb2;if(this._code="",this._count=-1,null!=r){if(!e.Sizes.has(r))throw new Error('"Unsupported code='+r+".");var u=e.Sizes.get(r),c=u.hs+u.ss;if(u.fs!=c||c%4!=0)throw new Error("Whole code size not full size or not multiple of 4. cs="+c+" fs="+u.fs+".");if(null==n&&(n=null==i?1:T(i)),n<0||n>Math.pow(64,u.ss)-1)throw new Error("Invalid count="+n+" for code="+r+".");this._code=r,this._count=n}else if(null!=s){var h=L(s);this._exfil(h)}else if(null!=o)this._exfil(o);else if(null==a)throw new Error("Improper initialization need either (code and count) or qb64b or qb64 or qb2.")}var t=e.prototype;return t.countToB64=function(t){return null==t&&(t=e.Sizes.get(this.code).ss),D(this.count,t)},e.semVerToB64=function(e,t,r,n){void 0===e&&(e=""),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0);var i=[t,r,n];if(""!=e){for(var s=e.split(".").map((function(e){return""==e?0:parseInt(e)})),o=s.length,a=3-o,u=0;u<a;u++)s.push(i[u+o]);i=s}return i.forEach((function(e){if(e<0||e>63)throw new Error("Out of bounds semantic version. Part="+e+" is < 0 or > 63.")})),i.map((function(e){return D(e,1)})).join("")},t._infil=function(){var t=this.code,r=this.count,n=e.Sizes.get(t),i=n.hs+n.ss;if(n.fs!=i||i%4!=0)throw new Error("Whole code size not full size or not multiple of 4. cs="+i+" fs="+n.fs+".");if(r<0||r>Math.pow(64,n.ss)-1)throw new Error("Invalid count="+r+" for code="+t+".");var s=""+t+D(r,n.ss);if(s.length%4)throw new Error("Invalid size = "+s.length+" of "+s+" not a multiple of 4.");return s},t._exfil=function(t){if(0==t.length)throw new Error("Empty Material");var r=t.slice(0,2);if(!e.Hards.has(r))throw new Error("Unexpected code "+r);var n=e.Hards.get(r);if(t.length<n)throw new Error("Need "+(n-t.length)+" more characters.");var i=t.slice(0,n);if(!e.Sizes.has(i))throw new Error("Unsupported code "+i);var s=e.Sizes.get(i),o=s.hs+s.ss;if(t.length<o)throw new Error("Need "+(o-t.length)+" more chars.");var a=T(t.slice(s.hs,s.hs+s.ss));this._code=i,this._count=a},v(e,[{key:"code",get:function(){return this._code}},{key:"count",get:function(){return this._count}},{key:"qb64",get:function(){return this._infil()}},{key:"qb64b",get:function(){return P(this.qb64)}}]),e}();Ye.Sizes=new Map(Object.entries({"-A":new te(2,2,4,0),"-B":new te(2,2,4,0),"-C":new te(2,2,4,0),"-D":new te(2,2,4,0),"-E":new te(2,2,4,0),"-F":new te(2,2,4,0),"-G":new te(2,2,4,0),"-H":new te(2,2,4,0),"-I":new te(2,2,4,0),"-J":new te(2,2,4,0),"-K":new te(2,2,4,0),"-L":new te(2,2,4,0),"-V":new te(2,2,4,0),"-0V":new te(3,5,8,0),"--AAA":new te(5,3,8,0)})),Ye.Hards=new Map([["-A",2],["-B",2],["-C",2],["-D",2],["-E",2],["-F",2],["-G",2],["-H",2],["-I",2],["-J",2],["-K",2],["-L",2],["-M",2],["-N",2],["-O",2],["-P",2],["-Q",2],["-R",2],["-S",2],["-T",2],["-U",2],["-V",2],["-W",2],["-X",2],["-Y",2],["-Z",2],["-a",2],["-b",2],["-c",2],["-d",2],["-e",2],["-f",2],["-g",2],["-h",2],["-i",2],["-j",2],["-k",2],["-l",2],["-m",2],["-n",2],["-o",2],["-p",2],["-q",2],["-r",2],["-s",2],["-t",2],["-u",2],["-v",2],["-w",2],["-x",2],["-y",2],["-z",2],["-0",3],["--",5]]);var Qe=["raw","code","qb64","qb64b","qb2","sn","snh"],$e=function(e){function t(t){var r,n=t.raw,i=t.code,s=void 0===i?F.Salt_128:i,o=t.qb64,a=t.qb64b,u=t.qb2,c=t.sn,h=t.snh,d=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)t.indexOf(r=s[n])>=0||(i[r]=e[r]);return i}(t,Qe);if(n||a||o||u||(void 0===c&&(c=void 0===h?0:parseInt(h,16)),n=ke(c,re._rawSize(F.Salt_128))),(r=e.call(this,w({raw:n,code:s,qb64:o,qb64b:a,qb2:u},d))||this).code!==F.Salt_128)throw new Error("Invalid code = "+r.code+" for Seqner.");return r}return g(t,e),v(t,[{key:"sn",get:function(){return Se(this.raw)}},{key:"snh",get:function(){return this.sn.toString(16)}}]),t}(re),et=Math.pow(2,32)-1;function tt(e){var t=e.pre,r=void 0===t?void 0:t,n=e.keys,i=e.dig,s=void 0===i?void 0:i,o=e.ilk,a=void 0===o?I.rot:o,u=e.sn,c=void 0===u?1:u,h=e.isith,l=void 0===h?void 0:h,f=e.ndigs,p=void 0===f?void 0:f,v=e.nsith,w=void 0===v?void 0:v,g=e.wits,b=void 0===g?void 0:g,y=e.cuts,x=void 0===y?void 0:y,_=e.adds,m=void 0===_?void 0:_,E=e.toad,k=void 0===E?void 0:E,S=e.data,A=void 0===S?void 0:S,q=e.version,B=e.kind,C=e.intive,M=void 0===C||C,N=O(exports.Ident.KERI,void 0===q?void 0:q,void 0===B?void 0:B,0),z=a;if(z!=I.rot&&z!=I.drt)throw new Error("Invalid ilk = "+a+" for rot or drt.");var j,D=Number(c);if(D<1)throw new Error("Invalid sn = 0x"+D.toString()+" for rot or drt.");j=null==l?Math.max(1,Math.ceil(n.length/2)):l;var T,P,L=new Ge({sith:j});if(null!=L.num&&L.num<1)throw new Error("Invalid sith = "+L.num+" less than 1.");if(L.size>n.length)throw new Error("Invalid sith = "+L.num+" for keys = "+n);T=void 0===p?[]:p,P=void 0===w?Math.max(1,Math.ceil(T.length/2)):w;var U,R=new Ge({sith:P});if(null!=R.num&&R.num<1)throw new Error("Invalid sith = "+R.num+" less than 1.");if(R.size>T.length)throw new Error("Invalid sith = "+R.num+" for ndigs = "+p);U=void 0===b?[]:b;var G,H=new Set(U);if(H.size!=U.length)throw new Error("Invalid wits = "+b+", has duplicates.");G=void 0===x?[]:x;var F=new Set(G);if(F.size!=G.length)throw new Error("Invalid cuts = "+x+", has duplicates.");var J=new Set(void 0===m?[]:m);if(new Set([].concat(H).filter((function(e){return J.has(e)}))).size>0)throw new Error("Invalid member combination among wits = "+b+", and adds = "+m+".");if(new Set([].concat(F).filter((function(e){return J.has(e)}))).size>0)throw new Error("Invalid member combination among cuts = "+x+", and adds = "+m+".");var K=new Set(U);G.forEach((function(e){K.delete(e)}));var X,V=new Set(d().mark((function e(){return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.delegateYield(K,"t0",1);case 1:return e.delegateYield(J,"t1",2);case 2:case"end":return e.stop()}}),e)}))());if(V.size!=H.size-F.size+J.size)throw new Error("Invalid member combination among wits = "+b+", cuts = "+x+", and adds = "+m+".");if(X=void 0===k?0==V.size?0:rt(V.size):k,V.size>0){if(X<1||X>V.size)throw new Error("Invalid toad = "+X+" for wit = "+b)}else if(0!=X)throw new Error("Invalid toad = "+X+" for wit = "+b);var Z={v:N,t:z,d:"",i:r,s:D.toString(16),p:s,kt:L.num&&M&&void 0!==L.num&&L.num<=et?L.num.toString(16):L.sith,k:n,nt:R.num&&M&&void 0!==R.num&&R.num<=et?R.num.toString(16):R.sith,n:T,bt:X&&M&&void 0!==X&&X<=et?X:X.toString(16),br:x,ba:m,a:null!=A?A:[]},W=Ve.saidify(Z);return new He(W[1])}function rt(e,t,r){var n;if(void 0===r&&(r=!0),e=Math.max(0,e),null==t){n=Math.max(1,Math.floor(Math.max(0,e-1)/3));var i=Math.max(1,Math.ceil(Math.max(0,e-1)/3));return r?Math.min(e,Math.ceil((e+n+1)/2),Math.ceil((e+i+1)/2)):Math.min(e,Math.max(0,e-n,Math.ceil((e+n+1)/2)))}t=Math.max(0,t);var s=Math.ceil((e+t+1)/2),o=Math.max(0,e-t);if(o<s&&e>0)throw new Error("Invalid f="+t+" is too big for n="+e+".");return r?Math.min(e,s,o):Math.min(e,Math.max(s,o))}function nt(e){var t=e.keys,r=e.isith,n=e.ndigs,i=e.nsith,s=e.toad,o=e.wits,a=e.cnfg,u=e.data,c=e.version,h=e.kind,d=void 0===h?exports.Serials.JSON:h,l=e.code,f=e.intive,p=void 0!==f&&f,v=e.delpre,w=O(exports.Ident.KERI,void 0===c?q:c,d,0),g=null==v?I.icp:I.dip,b=new Re({},0);null==r&&(r=Math.max(1,Math.ceil(t.length/2)));var y=new Ge({sith:r});if(null!=y.num&&y.num<1)throw new Error("Invalid sith = "+y.num+" less than 1.");if(y.size>t.length)throw new Error("Invalid sith = "+y.num+" for keys "+t);null==n&&(n=new Array),null==i&&(i=Math.max(0,Math.ceil(n.length/2)));var x=new Ge({sith:i});if(null!=x.num&&x.num<0)throw new Error("Invalid nsith = "+x.num+" less than 0.");if(x.size>t.length)throw new Error("Invalid nsith = "+x.num+" for keys "+n);if(o=null==o?[]:o,new Set(o).size!=o.length)throw new Error("Invalid wits = "+o+", has duplicates.");null==s&&(s=0==o.length?0:rt(o.length));var _=new Re({},s);if(o.length>0){if(_.num<1||_.num>o.length)throw new Error("Invalid toad = "+_.num+" for wits = "+o)}else if(0!=_.num)throw new Error("Invalid toad = "+_.num+" for wits = "+o);a=null==a?new Array:a,u=null==u?new Array:u;var m,E={v:w,t:g,d:"",i:"",s:b.numh,kt:p&&null!=y.num?y.num:y.sith,k:t,nt:p&&null!=y.num?x.num:x.sith,n:n,bt:p?_.num:_.numh,b:o,c:a,a:u};if(null!=v&&(E.di=v,null==l&&(l=F.Blake3_256)),null==v&&null==l&&1==t.length){if((m=new Ke({qb64:t[0]})).digestive)throw new Error("Invalid code, digestive="+m.code+", must be derived from ked.")}else if(m=new Ke({code:l},E),null!=v&&!m.digestive)throw new Error("Invalid derivation code = "+m.code+" for delegation. Must be digestive");return E.i=m.qb64,m.digestive?E.d=m.qb64:E=Ve.saidify(E)[1],new He(E)}function it(e,t,r,n,i,s){void 0===s&&(s=!1);var o=new Uint8Array(P(e.raw)),a=new Uint8Array;if(null==t&&null==n&&null==i)throw new Error("Missing attached signatures on message = "+e.ked+".");if(null!=t&&(null!=r&&("SealEvent"==r[0]?(a=U(a,new Ye({code:We.TransIdxSigGroups,count:1}).qb64b),a=U(a,(new c.TextEncoder).encode(r[1].i)),a=U(a,new $e(r[1].s).qb64b),a=U(a,(new c.TextEncoder).encode(r[1].d))):"SealLast"==r[0]&&(a=U(a,new Ye({code:We.TransLastIdxSigGroups,count:1}).qb64b),a=U(a,(new c.TextEncoder).encode(r[1].i)))),a=U(a,new Ye({code:We.ControllerIdxSigs,count:t.length}).qb64b),t.forEach((function(e){a=U(a,e.qb64b)}))),null!=n&&(a=U(a,new Ye({code:We.ControllerIdxSigs,count:n.length}).qb64b),n.forEach((function(e){if(e.verfer&&!(e.verfer.code in K))throw new Error("Attempt to use tranferable prefix="+e.verfer.qb64+" for receipt.");a=U(a,e.qb64b)}))),null!=i&&(a=U(a,new Ye({code:We.ControllerIdxSigs,count:i.length}).qb64b),i.forEach((function(e){if(e.verfer&&!(e.verfer.code in K))throw new Error("Attempt to use tranferable prefix="+e.verfer.qb64+" for receipt.");a=U(a,e.qb64b)}))),s){if(a.length%4!=0)throw new Error("Invalid attachments size="+a.length+", nonintegral quadlets.");o=U(o,new Ye({code:We.AttachedMaterialQuadlets,count:Math.floor(a.length/4)}).qb64b)}return U(o,a)}function st(e){var t=e.pre,r=e.dig,n=e.sn,i=e.data,s=O(exports.Ident.KERI,e.version,e.kind,0),o=I.ixn,a=new Re({},n);if(a.num<1)throw new Error("Invalid sn = 0x"+a.numh+" for ixn.");i=null==i?new Array:i;var u={v:s,t:o,d:"",i:t,s:a.numh,p:r,a:i},c=Ve.saidify(u);return new He(u=c[1])}function ot(e,t,r,n,i){void 0===e&&(e=""),void 0===i&&(i=exports.Serials.JSON),null==t&&(t={});var s={v:O(exports.Ident.KERI,n,i,0),t:I.rpy,d:"",dt:null!=r?r:(new Date).toISOString().replace("Z","000+00:00"),r:e,a:t},o=Ve.saidify(s)[1],a=new Ve({qb64:o.d});if(!a.verify(o,!0,!0,i,"d"))throw new Error("Invalid said = "+a.qb64+" for reply msg="+o+".");return new He(o)}var at=function(){this.EstOnly="EO",this.DoNotDelegate="DND",this.NoBackers="NB"},ut=new at,ct=function(){function e(e,t){this.name=e,this.serder=t}return v(e,[{key:"pre",get:function(){return this.serder.ked.i}}]),e}(),ht=function(){function e(e){var t,r=e.name,n=e.passcode,i=e.seed,s=e.aeid,o=e.pidx,a=e.salt;if(this._habs=new Map,this._name=r,null!=n&&null==i){if(n.length<21)throw new Error("Bran (passcode seed material) too short.");var u=F.Salt_128+"A"+n.substring(0,21),c=new be({qb64:u}).signer(F.Ed25519_Seed,!1);i=c.qb64,null==s&&(s=c.verfer.qb64)}var h=null!=a?new be({qb64:a}):void 0;t=null!=a?exports.Algos.salty:exports.Algos.randy,this._mgr=new Pe({seed:i,aeid:s,pidx:o,algo:t,salter:h})}var t=e.prototype;return t.habByName=function(e){return this._habs.get(e)},t.makeHab=function(e,t){var r=t.code,n=void 0===r?F.Blake3_256:r,i=t.transferable,s=void 0===i||i,o=t.isith,a=void 0===o?void 0:o,u=t.icount,c=void 0===u?1:u,h=t.nsith,d=void 0===h?void 0:h,l=t.ncount,f=void 0===l?void 0:l,p=t.toad,v=void 0===p?void 0:p,w=t.wits,g=void 0===w?void 0:w,b=t.delpre,y=void 0===b?void 0:b,x=t.estOnly,_=void 0!==x&&x,m=t.DnD,E=void 0!==m&&m,k=t.data,S=void 0===k?void 0:k;null==d&&(d=a),null==f&&(f=c),s||(f=0,d="0",n=F.Ed25519N);var A=this._mgr.incept({icount:c,ncount:f,stem:this.name,transferable:s,temp:!1}),q=A[0],I=A[1];c=q.length,f=null!=I?I.length:0,null==a&&(a=""+Math.max(1,Math.ceil(c/2)).toString(16)),null==d&&(d=""+Math.max(1,Math.ceil(f/2)).toString(16));var B=new Array;_&&B.push(ut.EstOnly),E&&B.push(ut.DoNotDelegate);var C=nt({keys:Array.from(q,(function(e){return e.qb64})),isith:a,ndigs:Array.from(I,(function(e){return e.qb64})),nsith:d,toad:v,wits:g,cnfg:B,data:S,code:n,delpre:y}),M=new ct(e,C);return this._habs.set(e,M),M},v(e,[{key:"mgr",get:function(){return this._mgr}},{key:"habs",get:function(){return Array.from(this._habs.values())}},{key:"name",get:function(){return this._name}}]),e}(),dt=function(){function e(e){this.pre="",this.anchor="",this.verfer=null,this.state=null,this.sn=0,this.said="",this.parse(e)}var t=e.prototype;return t.parse=function(e){var t=this.event(e),r=t[0],n=t[1];if(this.sn=new Re({},void 0,r.s).num,this.said=r.d,r.et!==I.dip)throw new Error("invalid inception event type "+r.et);if(this.pre=r.i,!r.di)throw new Error("no anchor to controller AID");this.anchor=r.di,this.verfer=n,this.state=r},t.event=function(e){if(1!==e.k.length)throw new Error("agent inception event can only have one key");var t=new ne({qb64:e.k[0]});if(1!==e.n.length)throw new Error("agent inception event can only have one next key");var r=new Ie({qb64:e.n[0]}),n=new Ge({sith:e.kt});if(1!==n.num)throw new Error("invalid threshold "+n.num+", must be 1");var i=new Ge({sith:e.nt});if(1!==i.num)throw new Error("invalid next threshold "+i.num+", must be 1");return[e,t,r]},e}(),lt=function(){function e(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=null),this.bran=F.Salt_128+"A"+e.substring(0,21),this.stem="signify:controller",this.tier=t,this.ridx=r,this.salter=new be({qb64:this.bran,tier:this.tier});var i=new De(this.salter.qb64,this.tier,this.stem);this.signer=i.create(void 0,1,F.Ed25519_Seed,!0,0,this.ridx,0,!1).signers.pop(),this.nsigner=i.create(void 0,1,F.Ed25519_Seed,!0,0,this.ridx+1,0,!1).signers.pop(),this.keys=[this.signer.verfer.qb64],this.ndigs=[new Ie({code:F.Blake3_256},this.nsigner.verfer.qb64b).qb64],this.serder=null==n||0==n.ee.s?nt({keys:this.keys,isith:"1",nsith:"1",ndigs:this.ndigs,code:F.Blake3_256,toad:"0",wits:[]}):new He(n.ee)}var t=e.prototype;return t.approveDelegation=function(e){var t=new $e({sn:e.sn}),r={i:e.pre,s:t.snh,d:e.said},n=new Re({},void 0,this.serder.ked.s).num+1;return this.serder=st({pre:this.serder.pre,dig:this.serder.ked.d,sn:n,data:[r],version:q,kind:exports.Serials.JSON}),[this.signer.sign(this.serder.raw,0).qb64]},t.derive=function(e){return null!=e&&"0"===e.ee.s?nt({keys:this.keys,isith:"1",nsith:"1",ndigs:this.ndigs,code:F.Blake3_256,toad:"0",wits:[]}):new He({ked:e.controller.ee})},t.rotate=function(e,t){var r=F.Salt_128+"A"+e.substring(0,21),n=new be({qb64:r,tier:this.tier}),i=this.salter.signer(void 0,!1),s=new De(this.salter.qb64,this.tier,this.stem).create(void 0,1,F.Ed25519_Seed,!0,0,this.ridx+1,0,!1).signers.pop(),o=new De(n.qb64,this.tier,this.stem);this.signer=o.create(void 0,1,F.Ed25519_Seed,!0,0,this.ridx,0,!1).signers.pop(),this.nsigner=o.create(void 0,1,F.Ed25519_Seed,!0,0,this.ridx+1,0,!1).signers.pop(),this.keys=[this.signer.verfer.qb64,null==s?void 0:s.verfer.qb64],this.ndigs=[new Ie({},this.nsigner.verfer.qb64b).qb64];for(var a,u=tt({pre:this.pre,keys:this.keys,dig:this.serder.ked.d,isith:["1","0"],nsith:"1",ndigs:this.ndigs}),c=[null==s?void 0:s.sign(P(u.raw),1,!1,0).qb64,this.signer.sign(u.raw,0).qb64],h=new qe({},P(i.verfer.qb64)),d=new ye({},i.qb64b),l=h.encrypt(P(this.bran)).qb64,f={},p=E(t);!(a=p()).done;){var v=a.value,w=v.prefix;if("salty"in v){console.log("salty aid to rotate"),console.log(v);for(var g,b=v.salty,y=new xe({qb64:b.sxlt}),x=d.decrypt(null,y).qb64,_=[],m=E(new De(x,b.tier,b.stem).create(b.icodes,void 0,F.Ed25519_Seed,b.transferable,b.pidx,0,b.kidx,!1).signers);!(g=m()).done;)_.push(g.value.verfer.qb64);if(v.state.k.join(",")!=_.join(","))throw new Error("Invalid Salty AID");var k=h.encrypt(P(x)).qb64;f[w]={sxlt:k}}else{if(!("randy"in v))throw new Error("invalid aid type ");for(var S,A=v.randy,q=A.nxts,I=[],B=[],C=E(A.prxs);!(S=C()).done;){var M=new xe({qb64:S.value}),N=d.decrypt(null,M,!0);B.push(N),I.push(h.encrypt(P(N.qb64)).qb64)}for(var O=v.state.k,z=[],j=0,D=B;j<D.length;j++)z.push(D[j].verfer.qb64);if(O.join(",")!=z.join(","))throw new Error("unable to rotate, validation of encrypted public keys "+O+" failed");for(var T,L=[],U=E(q);!(T=U()).done;)L.push(this.recrypt(T.value,d,h));f[w]={prxs:I,nxts:L}}}return{rot:u.ked,sigs:c,sxlt:l,keys:f}},t.recrypt=function(e,t,r){var n=new xe({qb64:e}),i=t.decrypt(null,n).qb64;return r.encrypt(P(i)).qb64},v(e,[{key:"pre",get:function(){return this.serder.pre}},{key:"event",get:function(){var e=this.signer.sign(this.serder.raw,0);return[this.serder,e]}},{key:"verfers",get:function(){return this.signer.verfer()}}]),e}();function ft(e){return e.trim()}function pt(e,t){var r=t.name,n=t.method,i=t.path,s=t.headers,o=t.fields,a=t.expires,u=t.nonce,c=t.alg,d=t.keyid,l=t.context,f=new Array,p=new Array;o.forEach((function(e){if(e.startsWith("@"))switch(e){case"@method":f.push('"'+e+'": '+n),p.push([e,new Map]);break;case"@path":f.push('"'+e+'": '+i),p.push([e,new Map])}else{if(!s.has(e))return;p.push([e,new Map]);var t=ft(s.get(e));f.push('"'+e+'": '+t)}}));var v=new Map,w=Math.floor(Ee().getTime()/1e3);v.set("created",w);var g=["("+p.map((function(e){return e[0]})).join(" ")+")","created="+w];null!=a&&(g.push("expires="+a),v.set("expires",a)),null!=u&&(g.push("nonce="+u),v.set("nonce",u)),null!=d&&(g.push("keyid="+d),v.set("keyid",d)),null!=l&&(g.push("context="+l),v.set("context",l)),null!=c&&(g.push("alg="+c),v.set("alg",c));var b=new Map([[r,[p,v]]]),y=g.join(";");f.push('"@signature-params: '+y+'"');var x=f.join("\n"),_=e.sign(P(x));return[new Map([["Signature-Input",""+h.serializeDictionary(b)]]),_]}var vt=function(){function e(e){this._raw=e}return v(e,[{key:"qb64",get:function(){return s.encode(o.Buffer.from(this._raw))}},{key:"qb64b",get:function(){return P(this.qb64)}}]),e}(),wt=function(){};function gt(e){var t=h.parseDictionary(e),r=new Array;return t.forEach((function(e,t){var n,i=new wt;if(i.name=t,n=e[1],i.fields=e[0].map((function(e){return e[0]})),!n.has("created"))throw new Error("missing required `created` field from signature input");i.created=n.get("created"),n.has("expires")&&(i.expires=n.get("expires")),n.has("nonce")&&(i.nonce=n.get("nonce")),n.has("alg")&&(i.alg=n.get("alg")),n.has("keyid")&&(i.keyid=n.get("keyid")),n.has("context")&&(i.context=n.get("context")),r.push(i)})),r}function bt(e,t){if(null!==e){var r=e.replace(t+" ","").split("/"),n=r[0].split("-");return{start:parseInt(n[0]),end:parseInt(n[1]),total:parseInt(r[1])}}return{start:0,end:0,total:0}}var yt=function(e,t,r,n,i,s,o){function a(e){this.client=e}var u=a.prototype;return u.list=function(t,r){return(e=e||f(d().mark((function e(t,r){var n,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=0),void 0===r&&(r=24),(n=new Headers).append("Range","aids="+t+"-"+r),e.next=9,this.client.fetch("/identifiers","GET",null,n);case 9:return s=(i=e.sent).headers.get("content-range"),o=bt(s,"aids"),e.next=14,i.json();case 14:return e.abrupt("return",{start:o.start,end:o.end,total:o.total,aids:e.sent});case 16:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},u.get=function(e){return(t=t||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/identifiers/"+t,e.next=5,this.client.fetch(r,"GET",null);case 5:return n=e.sent,e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},u.create=function(e,t){return(r=r||f(d().mark((function e(t,r){var n,i,s,o,a,u,c,h,l,f,p,v,w,g,b,y,x,_,m,E,k,S,A,I,B,C;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),c=null==r.algo?exports.Algos.salty:r.algo,h=null==(n=r.transferable)||n,l=null!=(i=r.isith)?i:"1",f=null!=(s=r.nsith)?s:"1",p=null!=(o=r.wits)?o:[],v=null!=(a=r.toad)?a:0,w=null!=(u=r.dcode)?u:F.Blake3_256,m=this.client.manager.new(c,this.client.pidx,{transferable:h,isith:l,nsith:f,wits:p,toad:v,proxy:g=r.proxy,delpre:b=r.delpre,dcode:w,data:y=null!=r.data?[r.data]:[],algo:c,pre:r.pre,prxs:r.prxs,nxts:r.nxts,mhab:r.mhab,states:x=r.states,rstates:_=r.rstates,keys:r.keys,ndigs:r.ndigs,bran:r.bran,count:r.count,ncount:r.ncount,tier:r.tier,extern_type:r.extern_type,extern:r.extern}),e.next=29,m.incept(h);case 29:return k=(E=e.sent)[0],S=E[1],p=void 0!==p?p:[],A=void 0,A=nt(null==b?{keys:k,isith:l,ndigs:S,nsith:f,toad:v,wits:p,cnfg:[],data:y,version:q,kind:exports.Serials.JSON,code:w,intive:!1}:{keys:k,isith:l,ndigs:S,nsith:f,toad:v,wits:p,cnfg:[],data:y,version:q,kind:exports.Serials.JSON,code:w,intive:!1,delpre:b}),e.next=37,m.sign(P(A.raw));case 37:return(B={name:t,icp:A.ked,sigs:I=e.sent,proxy:g,smids:null!=x?x.map((function(e){return e.i})):void 0,rmids:null!=_?_.map((function(e){return e.i})):void 0})[c]=m.params(),this.client.pidx=this.client.pidx+1,C=this.client.fetch("/identifiers","POST",B),e.abrupt("return",new xt(A,I,C));case 43:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},u.interact=function(e,t){return(n=n||f(d().mark((function e(t,r){var n,i,s,o,a,u,c,h,l,f;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return i=(n=e.sent).prefix,s=n.state,o=Number(s.s),a=s.d,r=Array.isArray(r)?r:[r],r=Array.isArray(r)?r:[r],u=st({pre:i,sn:o+1,data:r,dig:a,version:void 0,kind:void 0}),c=this.client.manager.get(n),e.next=13,c.sign(P(u.raw));case 13:return(l={ixn:u.ked,sigs:h=e.sent})[c.algo]=c.params(),f=this.client.fetch("/identifiers/"+t+"?type=ixn","PUT",l),e.abrupt("return",new xt(u,h,f));case 18:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},u.rotate=function(e,t){return(i=i||f(d().mark((function e(t,r){var n,i,s,o,a,u,c,h,l,f,p,v,w,g,b,y,x,_,m,E,k,S,A,q,I,B,C,M,N,O,z,j;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r={}),h=null==(n=r.transferable)||n,l=null!=(i=r.ncode)?i:F.Ed25519_Seed,f=null!=(s=r.ncount)?s:1,e.next=6,this.get(t);case 6:return v=(p=e.sent).prefix,g=(w=p.state).k.length,b=w.d,y=Number(w.s)+1,x=w.b,_=w.kt,m=null!=(o=r.nsith)?o:_,null==_&&(_=""+Math.max(1,Math.ceil(g/2)).toString(16)),null==m&&(m=""+Math.max(1,Math.ceil(f/2)).toString(16)),E=new Ge({sith:_}).sith,k=new Ge({sith:m}).sith,S=this.client.manager.get(p),A=null!=(a=r.ncodes)?a:new Array(f).fill(l),q=null==r.states?[]:r.states,I=null==r.rstates?[]:r.rstates,e.next=25,S.rotate(A,h,q,I);case 25:return C=null!=(u=r.cuts)?u:[],M=null!=(c=r.adds)?c:[],N=tt({pre:v,keys:(B=e.sent)[0],dig:b,sn:y,isith:E,nsith:k,ndigs:B[1],toad:r.toad,wits:x,cuts:C,adds:M,data:null!=r.data?[r.data]:[]}),e.next=35,S.sign(P(N.raw));case 35:return(z={rot:N.ked,sigs:O=e.sent,smids:null!=q?q.map((function(e){return e.i})):void 0,rmids:null!=I?I.map((function(e){return e.i})):void 0})[S.algo]=S.params(),j=this.client.fetch("/identifiers/"+t,"PUT",z),e.abrupt("return",new xt(N,O,j));case 40:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},u.addEndRole=function(e,t,r,n){return(s=s||f(d().mark((function e(t,r,n,i){var s,o,a,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.get(t);case 2:return o=this.makeEndRole((s=e.sent).prefix,r,n,i),a=this.client.manager.get(s),e.next=8,a.sign(P(o.raw));case 8:return c=this.client.fetch("/identifiers/"+t+"/endroles","POST",{rpy:o.ked,sigs:u=e.sent}),e.abrupt("return",new xt(o,u,c));case 12:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},u.makeEndRole=function(e,t,r,n){var i={cid:e,role:t};return null!=r&&(i.eid=r),ot("/end/role/add",i,n,void 0,exports.Serials.JSON)},u.members=function(e){return(o=o||f(d().mark((function e(t){var r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.fetch("/identifiers/"+t+"/members","GET",void 0);case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},a}(),xt=function(e){function t(e,t,r){this._serder=e,this._sigs=t,this.promise=r}return t.prototype.op=function(){return(e=e||f(d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return t=e.sent,e.next=5,t.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},v(t,[{key:"serder",get:function(){return this._serder}},{key:"sigs",get:function(){return this._sigs}}]),t}(),_t=[!1,0,"?0","no","false","False","off"],mt=function(e,t,r,n,i,s){this.indexed=!1,this.markers=e,this.indexed=t,this.signer=r,this.ordinal=n,this.digest=i,this.kind=s};function Et(e){for(var t,r=new Array,n=function(){var e,n,i=t.value,s=i.indexed,o=i.signer,a=i.ordinal,u=i.digest,c=i.kind;i.markers instanceof Map?(n=Array.from(i.markers.keys()),e=Array.from(i.markers.values())):(e=i.markers,n=new Array),null==s&&(s=e[0]instanceof we);var h=new Array,d=s?"?1":"?0";h.push('indexed="'+d+'"'),null!=o&&h.push('signer="'+o+'"'),null!=a&&h.push('ordinal="'+a+'"'),null!=u&&h.push('digest="'+u+'"'),null!=c&&h.push('kind="'+c+'"'),e.forEach((function(e,t){var r;if(null!=n&&n.length>t)r=n[t];else if(e instanceof we){if(!s)throw new Error("Indexed signature marker "+e+" when indexed False.");r=e.index.toString()}else{if(s)throw new Error("Unindexed signature marker "+e+" when indexed True.");r=e.verfer.qb64}h.push(r+'="'+(d=e.qb64)+'"')})),r.push(h.join(";"))},i=E(e);!(t=i()).done;)n();return new Headers([["Signature",r.join(",")]])}function kt(e){var t=e.replace(" ","").split(","),r=new Array;return t.forEach((function(e){var t=new Map;if(e.split(";").forEach((function(e){var r=e.split("=",2);t.set(r[0],r[1].replaceAll('"',""))})),!t.has("indexed"))throw new Error("Missing indexed field in Signature header signage.");var n,i,s,o,a,u=t.get("indexed"),c=!_t.includes(u);t.delete("indexed"),t.has("signer")&&(n=t.get("signer"),t.delete("signer")),t.has("ordinal")&&(i=t.get("ordinal"),t.delete("ordinal")),t.has("digest")&&(s=t.get("digest"),t.delete("digest")),t.has("kind")?(o=t.get("kind"),t.delete("kind")):o="CESR","CESR"==o?(a=new Map,t.forEach((function(e,t){a.set(t,c?new we({qb64:e}):new ie({qb64:e}))}))):a=t,r.push(new mt(a,c,n,i,s,o))})),r}var St=function(){function e(e,t){this._csig=e,this._verfer=t}var t=e.prototype;return t.verify=function(e,t,r){var n=this,i=e.get("Signature-Input");if(null==i)return!1;var s=e.get("Signature");if(null==s)return!1;var o=gt(i);return 0!=(o=o.filter((function(e){return"signify"==e.name}))).length&&(o.forEach((function(i){var o=new Array;i.fields.forEach((function(n){if(n.startsWith("@"))"@method"==n?o.push('"'+n+'": '+t):"@path"==n&&o.push('"'+n+'": '+r);else if(e.has(n)){var i=ft(e.get(n));o.push('"'+n+'": '+i)}}));var a=new Array;a.push("("+i.fields.join(" ")+")"),a.push("created="+i.created),null!=i.expires&&a.push("expires="+i.expires),null!=i.nonce&&a.push("nonce="+i.nonce),null!=i.keyid&&a.push("keyid="+i.keyid),null!=i.context&&a.push("context="+i.context),null!=i.alg&&a.push("alg="+i.alg);var u=a.join(";");o.push('"@signature-params: '+u+'"');var c=o.join("\n"),h=kt(s)[0].markers.get(i.name);if(!n._verfer.verify(h.raw,c))throw new Error("Signature for "+i.keyid+" invalid.")})),!0)},t.sign=function(t,r,n,i){null==i&&(i=e.DefaultFields);var s=pt(this._csig,{name:"signify",method:r,path:n,headers:t,fields:i,alg:"ed25519",keyid:this._csig.verfer.qb64}),o=s[1];s[0].forEach((function(e,r){t.append(r,e)}));var a=new Map;return a.set("signify",o),Et([new mt(a,!1)]).forEach((function(e,r){t.append(r,e)})),t},e}();St.DefaultFields=["@method","@path","signify-resource","signify-timestamp"];var At=function(){function e(e,t){var r=this;void 0===t&&(t=[]),this.salter=e,this.modules=[],t.forEach((function(e){r.modules[e.type]=e.module}))}var t=e.prototype;return t.new=function(e,t,r){switch(e){case exports.Algos.salty:return new qt(this.salter,t,r.kidx,r.tier,r.transferable,r.stem,r.code,r.count,r.icodes,r.ncode,r.ncount,r.ncodes,r.dcode,r.bran,r.sxlt);case exports.Algos.randy:return new It(this.salter,r.code,r.count,r.icodes,r.transferable,r.ncode,r.ncount,r.ncodes,r.dcode,r.prxs,r.nxts);case exports.Algos.group:return new Bt(this,r.mhab,r.states,r.rstates,r.keys,r.ndigs);case exports.Algos.extern:var n=r.extern_type;if(n in this.modules)return new this.modules[n](t,r);throw new Error("unsupported external module type "+n);default:throw new Error("Unknown algo")}},t.get=function(e){var t=new Ke({qb64:e.prefix});if(exports.Algos.salty in e){var r=e[exports.Algos.salty];return new qt(this.salter,r.pidx,r.kidx,r.tier,r.transferable,r.stem,r.code,r.count,r.icodes,r.ncode,r.ncount,r.ncodes,r.dcode,r.bran,r.sxlt)}if(exports.Algos.randy in e){var n=e[exports.Algos.randy];return new It(this.salter,n.code,n.count,n.icodes,t.transferable,n.ncode,n.ncount,n.ncodes,n.dcode,n.prxs,n.nxts)}if(exports.Algos.group in e){var i=e[exports.Algos.group];return new Bt(this,i.mhab,i.states,i.rstates,i.keys,i.ndigs)}if(exports.Algos.extern in e){var s=e[exports.Algos.randy],o=s.extern_type;if(o in this.modules)return new this.modules[o](s.pidx,s);throw new Error("unsupported external module type "+o)}throw new Error("Algo not allowed yet")},e}(),qt=function(){function e(e,t,r,n,i,s,o,a,u,c,h,d,l,f,p){void 0===r&&(r=0),void 0===n&&(n=exports.Tier.low),void 0===i&&(i=!1),void 0===s&&(s=void 0),void 0===o&&(o=F.Ed25519_Seed),void 0===a&&(a=1),void 0===u&&(u=void 0),void 0===c&&(c=F.Ed25519_Seed),void 0===h&&(h=1),void 0===d&&(d=void 0),void 0===l&&(l=F.Blake3_256),void 0===f&&(f=void 0),void 0===p&&(p=void 0),this.algo=exports.Algos.salty,this.salter=e;var v=this.salter.signer(void 0,i=!1);if(this.aeid=v.verfer.qb64,this.encrypter=new qe({},P(this.aeid)),this.decrypter=new ye({},v.qb64b),this.code=o,this.ncode=c,this.tier=n,this.icodes=null==u?new Array(a).fill(o):u,this.ncodes=null==d?new Array(h).fill(c):d,this.dcode=l,this.pidx=t,this.kidx=r,this.transferable=i,this.count=a,this.ncount=h,this.stem=null==s?"signify:aid":s,null!=f)this.bran=F.Salt_128+"A"+f.slice(0,21),this.creator=new De(this.bran,this.tier,this.stem),this.sxlt=this.encrypter.encrypt(P(this.creator.salt)).qb64;else if(null==p)this.creator=new De(void 0,this.tier,this.stem),this.sxlt=this.encrypter.encrypt(P(this.creator.salt)).qb64;else{this.sxlt=p;var w=new xe({qb64:this.sxlt});this.creator=new De(this.decrypter.decrypt(null,w).qb64,n=n,this.stem)}this.signers=this.creator.create(this.icodes,this.ncount,this.ncode,this.transferable,this.pidx,0,this.kidx,!1).signers}var t=e.prototype;return t.params=function(){return{sxlt:this.sxlt,pidx:this.pidx,kidx:this.kidx,stem:this.stem,tier:this.tier,icodes:this.icodes,ncodes:this.ncodes,dcode:this.dcode,transferable:this.transferable}},t.incept=function(e){var t,r=this;return this.transferable=e,this.kidx=0,[this.creator.create(this.icodes,this.count,this.code,this.transferable,this.pidx,0,this.kidx,!1).signers.map((function(e){return e.verfer.qb64})),this.creator.create(this.ncodes,this.ncount,this.ncode,this.transferable,this.pidx,0,null==(t=this.icodes)?void 0:t.length,!1).signers.map((function(e){return new Ie({code:r.dcode},e.verfer.qb64b).qb64}))]},t.rotate=function(e,t){var r=this;this.ncodes=e,this.transferable=t;var n=this.creator.create(this.ncodes,this.ncount,this.ncode,this.transferable,this.pidx,0,this.kidx+this.icodes.length,!1).signers.map((function(e){return e.verfer.qb64}));return this.kidx=this.kidx+this.icodes.length,[n,this.creator.create(this.ncodes,this.ncount,this.ncode,this.transferable,this.pidx,0,this.kidx+this.icodes.length,!1).signers.map((function(e){return new Ie({code:r.dcode},e.verfer.qb64b).qb64}))]},t.sign=function(e,t,r,n){void 0===t&&(t=!0),void 0===r&&(r=void 0),void 0===n&&(n=void 0);var i=this.creator.create(this.icodes,this.ncount,this.ncode,this.transferable,this.pidx,0,this.kidx,!1);if(t){for(var s,o=[],a=0,u=E(i.signers.entries());!(s=u()).done;){var c=s.value,h=c[0],d=c[1];if(null!=r){if("number"!=typeof(a=r[h])||a<0)throw new Error("Invalid signing index = "+a+", not whole number.")}else a=h;var l=0;if(null!=n){if(null==(l=n[h])||"number"==typeof l&&"number"!=typeof l&&l>=0)throw new Error("Invalid ondex = "+l+", not whole number.")}else l=a;o.push(d.sign(e,a,null==l,l))}return o.map((function(e){return e.qb64}))}for(var f,p=[],v=E(i.signers.entries());!(f=v()).done;)p.push(f.value[1].sign(e));return p.map((function(e){return e.qb64}))},e}(),It=function(){function e(e,t,r,n,i,s,o,a,u,c,h){var d,l,f=this;void 0===t&&(t=F.Ed25519_Seed),void 0===r&&(r=1),void 0===n&&(n=void 0),void 0===i&&(i=!1),void 0===s&&(s=F.Ed25519_Seed),void 0===o&&(o=1),void 0===u&&(u=F.Blake3_256),void 0===c&&(c=void 0),void 0===h&&(h=void 0),this.algo=exports.Algos.randy,this.salter=e,this.icodes=null==n?new Array(r).fill(t):n,this.ncodes=null==a?new Array(o).fill(s):a,this.code=t,this.ncode=s,this.count=r,this.ncount=o;var p=this.salter.signer(void 0,i=!1);this.aeid=p.verfer.qb64,this.encrypter=new qe({},P(this.aeid)),this.decrypter=new ye({},p.qb64b),this.nxts=null!=(d=h)?d:[],this.prxs=null!=(l=c)?l:[],this.transferable=i,this.icodes=n,this.ncodes=a,this.dcode=u,this.creator=new je,this.signers=this.prxs.map((function(e){return f.decrypter.decrypt(new xe({qb64:e}).qb64b,void 0,f.transferable)}))}var t=e.prototype;return t.params=function(){return{nxts:this.nxts,prxs:this.prxs,transferable:this.transferable}},t.incept=function(e){var t=this;this.transferable=e;var r=this.creator.create(this.icodes,this.count,this.code,this.transferable);this.prxs=r.signers.map((function(e){return t.encrypter.encrypt(void 0,e).qb64}));var n=r.signers.map((function(e){return e.verfer.qb64})),i=this.creator.create(this.ncodes,this.ncount,this.ncode,this.transferable);return this.nxts=i.signers.map((function(e){return t.encrypter.encrypt(void 0,e).qb64})),[n,i.signers.map((function(e){return new Ie({code:t.dcode},e.verfer.qb64b).qb64}))]},t.rotate=function(e,t){var r=this;this.ncodes=e,this.transferable=t,this.prxs=this.nxts;var n=this.nxts.map((function(e){return r.decrypter.decrypt(void 0,new xe({qb64:e}),r.transferable)})).map((function(e){return e.verfer.qb64})),i=this.creator.create(this.ncodes,this.ncount,this.ncode,this.transferable);return this.nxts=i.signers.map((function(e){return r.encrypter.encrypt(void 0,e).qb64})),[n,i.signers.map((function(e){return new Ie({code:r.dcode},e.verfer.qb64b).qb64}))]},t.sign=function(e,t,r,n){var i=this;void 0===t&&(t=!0),void 0===r&&(r=void 0),void 0===n&&(n=void 0);var s=this.prxs.map((function(e){return i.decrypter.decrypt(new xe({qb64:e}).qb64b,void 0,i.transferable)}));if(t){for(var o,a=[],u=0,c=E(s.entries());!(o=c()).done;){var h=o.value,d=h[0],l=h[1];if(null!=r){if("number"!=typeof(u=r[d])||u<0)throw new Error("Invalid signing index = "+u+", not whole number.")}else u=d;var f=0;if(null!=n){if(null==(f=n[d])||"number"==typeof f&&"number"!=typeof f&&f>=0)throw new Error("Invalid ondex = "+f+", not whole number.")}else f=u;a.push(l.sign(e,u,null==f,f))}return a.map((function(e){return e.qb64}))}for(var p,v=[],w=E(s.entries());!(p=w()).done;)v.push(p.value[1].sign(e));return v.map((function(e){return e.qb64}))},e}(),Bt=function(e){function t(e,t,r,n,i,s){void 0===t&&(t=void 0),void 0===r&&(r=void 0),void 0===n&&(n=void 0),void 0===i&&(i=void 0),void 0===s&&(s=void 0),this.algo=exports.Algos.group,this.manager=e,null!=r&&(i=r.map((function(e){return e.k[0]}))),null!=n&&(s=n.map((function(e){return e.n[0]}))),this.gkeys=i,this.gdigs=s,this.mhab=t,this.signers=[]}var r=t.prototype;return r.incept=function(){return[this.gkeys,this.gdigs]},r.rotate=function(e,t,r,n){return this.gkeys=r.map((function(e){return e.k[0]})),this.gdigs=n.map((function(e){return e.n[0]})),[this.gkeys,this.gdigs]},r.sign=function(t,r,n,i){return(e=e||f(d().mark((function e(t,r,n,i){var s,o,a,u;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=!0),s=this.mhab.state.n[0],o=this.gkeys.indexOf(this.mhab.state.k[0]),a=this.gdigs.indexOf(s),u=this.manager.get(this.mhab),e.next=10,u.sign(t,r,[o],[a]);case 10:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},r.params=function(){return{mhab:this.mhab,keys:this.gkeys,ndigs:this.gdigs}},t}(),Ct=function(e,t,r,n,i){function s(e){this.client=e}var o=s.prototype;return o.list=function(t,r,n){return(e=e||f(d().mark((function e(t,r,n){var i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new URLSearchParams,void 0!==t&&i.append("group",t),void 0!==r&&void 0!==n&&(i.append("filter_field",r),i.append("filter_value",n)),s="/contacts?"+i.toString(),e.next=7,this.client.fetch(s,"GET",null);case 7:return o=e.sent,e.next=10,o.json();case 10:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},o.get=function(e){return(t=t||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/contacts/"+t,e.next=4,this.client.fetch(r,"GET",null);case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},o.add=function(e,t){return(r=r||f(d().mark((function e(t,r){var n,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="/contacts/"+t,e.next=4,this.client.fetch(n,"POST",r);case 4:return i=e.sent,e.next=7,i.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},o.delete=function(e){return(n=n||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/contacts/"+t,e.next=4,this.client.fetch(r,"DELETE",null);case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},o.update=function(e,t){return(i=i||f(d().mark((function e(t,r){var n,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="/contacts/"+t,e.next=4,this.client.fetch(n,"PUT",r);case 4:return i=e.sent,e.next=7,i.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},s}(),Mt=function(e,t,r,n){function i(e){this.client=e}var s=i.prototype;return s.generate=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=128),r="/challenges?strength="+t.toString(),e.next=5,this.client.fetch(r,"GET",null);case 5:return n=e.sent,e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},s.respond=function(e,r,n){return(t=t||f(d().mark((function e(t,r,n){var i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.identifiers().get(t);case 2:return i=e.sent,s=this.client.exchanges(),e.next=6,s.send(t,"challenge",i,"/challenge/response",{words:n},{},[r]);case 6:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},s.verify=function(e,t,n){return(r=r||f(d().mark((function e(t,r,n){var i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="/challenges/"+t+"/verify/"+r,s={words:n},e.next=5,this.client.fetch(i,"POST",s);case 5:return o=e.sent,e.next=8,o.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},s.responded=function(e,t,r){return(n=n||f(d().mark((function e(t,r,n){var i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="/challenges/"+t+"/verify/"+r,s={said:n},e.next=5,this.client.fetch(i,"PUT",s);case 5:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i}();function Nt(){var e=r.randombytes_buf(r.crypto_sign_SEEDBYTES);return new re({raw:e,code:F.Ed25519_Seed}).qb64}var Ot,zt=function(e,t){function r(e){this.client=e}var n=r.prototype;return n.get=function(t,r){return(e=e||f(d().mark((function e(t,r){var n,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="agent"),n="/identifiers/"+t+"/oobis?role="+r,e.next=5,this.client.fetch(n,"GET",null);case 5:return i=e.sent,e.next=8,i.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n.resolve=function(e,r){return(t=t||f(d().mark((function e(t,r){var n,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={url:t},void 0!==r&&(n.oobialias=r),e.next=6,this.client.fetch("/oobis","POST",n);case 6:return i=e.sent,e.next=9,i.json();case 9:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},r}(),jt=function(e){function t(e){this.client=e}return t.prototype.get=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/operations/"+t,e.next=5,this.client.fetch(r,"GET",null);case 5:return n=e.sent,e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},t}(),Dt=function(e){function t(e){this.client=e}return t.prototype.get=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/events?pre="+t,e.next=5,this.client.fetch(r,"GET",null);case 5:return n=e.sent,e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},t}(),Tt=function(e,t,r){function n(e){this.client=e}var i=n.prototype;return i.get=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/states?pre="+t,e.next=5,this.client.fetch(r,"GET",null);case 5:return n=e.sent,e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i.list=function(e){return(t=t||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/states?"+t.map((function(e){return"pre="+e})).join("&"),e.next=5,this.client.fetch(r,"GET",null);case 5:return n=e.sent,e.next=8,n.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i.query=function(e,t,n){return(r=r||f(d().mark((function e(t,r,n){var i,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={pre:t},void 0!==r&&(i.sn=r),void 0!==n&&(i.anchor=n),e.next=7,this.client.fetch("/queries","POST",i);case 7:return s=e.sent,e.next=10,s.json();case 10:return e.abrupt("return",e.sent);case 11:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n}();!function(e){e.incept=function(e){var t,r=e.pre,n=e.toad,i=e.nonce,s=void 0===i?Nt():i,o=e.baks,a=void 0===o?[]:o,u=e.cnfg,c=void 0===u?[]:u,h=e.version,d=e.kind,l=void 0===d?exports.Serials.JSON:d,f=e.code,p=void 0===f?F.Blake3_256:f,v=O(exports.Ident.KERI,void 0===h?q:h,l,0),w=I.vcp;if(c.includes(ut.NoBackers)&&a.length>0)throw new Error(a.length+" backers specified for NB vcp, 0 allowed");if(new Set(a).size<a.length)throw new Error("Invalid baks "+a+" has duplicates");if(t=void 0===n?0===a.length?0:rt(a.length):+n,a.length>0){if(t<1||t>a.length)throw new Error("Invalid toad "+t+" for baks in "+a)}else if(0!=t)throw new Error("Invalid toad "+t+" for no baks");var g={v:v,t:w,d:"",i:"",ii:r,s:"0",c:c,bt:"0",b:a,n:s},b=new Ke({code:p},g);return g.i=b.qb64,g.d=b.qb64,new He(g)}}(Ot||(Ot={}));var Pt=function(){};Pt.issued="issued",Pt.received="received";var Lt=function(e){function t(e,t,r,n,i){this._acdc=e,this._iserder=t,this._anc=r,this._sigs=n,this.promise=i}return t.prototype.op=function(){return(e=e||f(d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return t=e.sent,e.next=5,t.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},v(t,[{key:"acdc",get:function(){return this._acdc}},{key:"iserder",get:function(){return this._iserder}},{key:"anc",get:function(){return this._anc}},{key:"sigs",get:function(){return this._sigs}}]),t}(),Ut=function(e,t,r,n,i,s){function o(e){this.client=e}var a=o.prototype;return a.list=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t={}),r={filter:void 0===t.filter?{}:t.filter,sort:void 0===t.sort?[]:t.sort,skip:void 0===t.skip?0:t.skip,limit:void 0===t.limit?25:t.limit},e.next=10,this.client.fetch("/credentials/query","POST",r,void 0);case 10:return n=e.sent,e.next=13,n.json();case 13:return e.abrupt("return",e.sent);case 14:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},a.get=function(e,r,n){return(t=t||f(d().mark((function e(t,r,n){var i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===n&&(n=!1),i="/identifiers/"+t+"/credentials/"+r,s=n?new Headers({Accept:"application/json+cesr"}):new Headers({Accept:"application/json"}),e.next=6,this.client.fetch(i,"GET",null,s);case 6:if(o=e.sent,!n){e.next=13;break}return e.next=10,o.text();case 10:e.t0=e.sent,e.next=16;break;case 13:return e.next=15,o.json();case 15:e.t0=e.sent;case 16:return e.abrupt("return",e.t0);case 17:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},a.issue=function(e,t,n,i,s,o,a,u,c){return(r=r||f(d().mark((function e(t,r,n,i,s,o,a,u,c){var h,l,f,p,v,g,b,y,x,_,m,E,k,S,A,q,B,C,M,N,z,j,D,T;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===c&&(c=!1),e.next=3,this.client.identifiers().get(t);case 3:if(l=(h=e.sent).prefix,f=void 0===u?(new Date).toISOString().replace("Z","000+00:00"):u,p=O(exports.Ident.ACDC,void 0,exports.Serials.JSON,0),v=O(exports.Ident.KERI,void 0,exports.Serials.JSON,0),g={v:p,d:""},b={d:""},c&&(g.u=new be({}),b.u=new be({})),null!=i&&(b.i=i),b.dt=f,b=w({},b,s),y=Ve.saidify(b,void 0,void 0,"d"),x=y[1],(g=w({},g,{i:l})).ri=r,g=w({},g,{s:n},{a:x}),void 0!==a&&(g.e=a),void 0!==o&&(g.r=o),_=Ve.saidify(g),E=Ve.saidify({v:v,t:I.iss,d:"",i:(m=_[1]).d,s:"0",ri:r,dt:f}),S=new He(k=E[1]),A=this.client.manager.get(h),B=!(void 0===(q=h.state).c||!q.c.includes("EO")),C=Number(q.s),M=q.d,N=[{i:k.i,s:k.s,d:k.d}],z={},D=[],!B){e.next=36;break}throw new Error("Establishment only not implemented");case 36:return j=st({pre:l,sn:C+1,data:N,dig:M,version:void 0,kind:void 0}),e.next=39,A.sign(P(j.raw));case 39:D=e.sent,z=j.ked;case 41:return T=this.issueFromEvents(h,t,m,k,z,D),e.abrupt("return",new Lt(m,S,j,D,T));case 43:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},a.issueFromEvents=function(e,t,r,n,i,s){var o="/identifiers/"+t+"/credentials",a={acdc:r,iss:n,ixn:i,sigs:s},u=this.client.manager.get(e);a[u.algo]=u.params();var c=new Headers({Accept:"application/json+cesr"});return this.client.fetch(o,"POST",a,c)},a.revoke=function(e,t){return(n=n||f(d().mark((function e(t,r){var n,i,s,o,a,u,c,h,l,f,p,v,w,g,b,y,x,_,m,E;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.identifiers().get(t);case 2:return i=(n=e.sent).prefix,s=O(exports.Ident.KERI,void 0,exports.Serials.JSON,0),o=(new Date).toISOString().replace("Z","000+00:00"),e.next=8,this.get(t,r);case 8:if(u=Ve.saidify({v:s,t:I.rev,d:"",i:r,s:"1",p:(a=e.sent).status.d,ri:a.sad.ri,dt:o}),c=u[1],h={},l=[],p=!(void 0===(f=n.state).c||!f.c.includes("EO")),v=Number(f.s),w=f.d,g=[{i:c.i,s:c.s,d:c.d}],!p){e.next=22;break}throw new Error("Establishment only not implemented");case 22:return b=st({pre:i,sn:v+1,data:g,dig:w,version:void 0,kind:void 0}),y=this.client.manager.get(n),e.next=26,y.sign(P(b.raw));case 26:l=e.sent,h=b.ked;case 28:return x={rev:c,ixn:h,sigs:l},_="/identifiers/"+t+"/credentials/"+r,m=new Headers({Accept:"application/json+cesr"}),e.next=34,this.client.fetch(_,"DELETE",x,m);case 34:return E=e.sent,e.next=37,E.json();case 37:return e.abrupt("return",e.sent);case 38:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},a.present=function(e,t,r,n){return(i=i||f(d().mark((function e(t,r,n,i){var s,o,a,u,h,l,f,p,v,w,g,b,y,x,_,m;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===i&&(i=!0),e.next=3,this.client.identifiers().get(t);case 3:return o=(s=e.sent).prefix,e.next=7,this.get(t,r);case 7:return u={i:(a=e.sent).sad.i,s:a.sad.s,n:r},h=O(exports.Ident.KERI,void 0,exports.Serials.JSON,0),l={v:h,t:I.exn,d:"",dt:(new Date).toISOString().replace("Z","000+00:00"),r:"/presentation",q:{},a:u},f=Ve.saidify(l),p=new He(f[1]),v=this.client.manager.get(s),w=v.sign(P(p.raw),!0),g=new we({qb64:w[0]}),b=(b=it(p,[g],["SealLast",{i:o}],void 0,void 0,!0)).slice(JSON.stringify(p.ked).length),y={exn:p.ked,sig:(new c.TextDecoder).decode(b),recipient:n,include:i},x="/identifiers/"+t+"/credentials/"+r+"/presentations",_=new Headers({Accept:"application/json+cesr"}),e.next=25,this.client.fetch(x,"POST",y,_);case 25:return m=e.sent,e.next=28,m.text();case 28:return e.abrupt("return",e.sent);case 29:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},a.request=function(e,t,r,n){return(s=s||f(d().mark((function e(t,r,n,i){var s,o,a,u,h,l,f,p,v,w,g,b,y,x;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.identifiers().get(t);case 2:return o=(s=e.sent).prefix,a={s:n},void 0!==i&&(a.i=i),u=O(exports.Ident.KERI,void 0,exports.Serials.JSON,0),h={v:u,t:I.exn,d:"",dt:(new Date).toISOString().replace("Z","000+00:00"),r:"/presentation/request",q:{},a:a},l=Ve.saidify(h),f=new He(l[1]),p=this.client.manager.get(s),e.next=13,p.sign(P(f.raw),!0);case 13:return v=new we({qb64:e.sent[0]}),w=(w=it(f,[v],["SealLast",{i:o}],void 0,void 0,!0)).slice(JSON.stringify(f.ked).length),g={exn:f.ked,sig:(new c.TextDecoder).decode(w),recipient:r},b="/identifiers/"+t+"/requests",y=new Headers({Accept:"application/json+cesr"}),e.next=24,this.client.fetch(b,"POST",g,y);case 24:return x=e.sent,e.next=27,x.text();case 27:return e.abrupt("return",e.sent);case 28:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},o}(),Rt=function(e){function t(e,t,r,n){this._regser=e,this._serder=t,this._sigs=r,this.promise=n}return t.prototype.op=function(){return(e=e||f(d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.promise;case 2:return t=e.sent,e.next=5,t.json();case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},v(t,[{key:"regser",get:function(){return this._regser}},{key:"serder",get:function(){return this._serder}},{key:"sigs",get:function(){return this._sigs}}]),t}(),Gt=function(e,t){function r(e){this.client=e}var n=r.prototype;return n.list=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/identifiers/"+t+"/registries",e.next=4,this.client.fetch(r,"GET",null);case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n.create=function(e){return(t=t||f(d().mark((function e(t){var r,n,i,s,o,a,u,c,h,l,f,p,v,w,g,b,y,x,_,m,E;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.name,n=t.registryName,s=void 0===(i=t.noBackers)||i,a=void 0===(o=t.toad)?0:o,c=void 0===(u=t.baks)?[]:u,h=t.nonce,e.next=3,this.client.identifiers().get(r);case 3:if(f=(l=e.sent).prefix,p=[],s&&p.push(ut.NoBackers),(w=void 0!==(v=l.state).c&&v.c.includes("EO"))&&p.push(ut.EstOnly),g=Ot.incept({pre:f,baks:c,toad:a,nonce:h,cnfg:p}),!w){e.next=15;break}throw new Error("establishment only not implemented");case 15:return b=l.state,y=Number(b.s),x=st({pre:f,sn:y+1,data:[{i:g.pre,s:"0",d:g.pre}],dig:b.d,version:q,kind:exports.Serials.JSON}),_=this.client.manager.get(l),e.next=23,_.sign(P(x.raw));case 23:return E=this.createFromEvents(l,r,n,g.ked,x.ked,m=e.sent),e.abrupt("return",new Rt(g,x,m,E));case 26:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n.createFromEvents=function(e,t,r,n,i,s){var o="/identifiers/"+t+"/registries",a={name:r,vcp:n,ixn:i,sigs:s},u=this.client.manager.get(e);return a[u.algo]=u.params(),this.client.fetch(o,"POST",a)},r}(),Ht=function(e,t){function r(e){this.client=e}var n=r.prototype;return n.get=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/schema/"+t,e.next=4,this.client.fetch(r,"GET",null);case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n.list=function(){return(t=t||f(d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=4,this.client.fetch("/schema","GET",null);case 4:return t=e.sent,e.next=7,t.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},r}(),Ft=function(e,t){function r(e){this.client=e}var n=r.prototype;return n.grant=function(t,r,n,i,s,o,a,u,c){return(e=e||f(d().mark((function e(t,r,n,i,s,o,a,u,c){var h,l,f;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.identifiers().get(t);case 2:return h=e.sent,l={m:n,i:r},f={acdc:[i,""],iss:[s,""],anc:[o,a]},e.abrupt("return",this.client.exchanges().createExchangeMessage(h,"/ipex/grant",l,f,void 0,c,u));case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n.admit=function(e,r,n,i){return(t=t||f(d().mark((function e(t,r,n,i){var s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.client.identifiers().get(t);case 2:return s=e.sent,o={m:r},e.abrupt("return",this.client.exchanges().createExchangeMessage(s,"/ipex/admit",o,{},void 0,i,n));case 5:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},r}(),Jt=function(e,t,r){function n(e){this.client=e}var i=n.prototype;return i.list=function(t,r){return(e=e||f(d().mark((function e(t,r){var n,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===t&&(t=0),void 0===r&&(r=24),(n=new Headers).append("Range","notes="+t+"-"+r),e.next=8,this.client.fetch("/notifications","GET",null,n);case 8:return s=(i=e.sent).headers.get("content-range"),o=bt(s,"notes"),e.next=13,i.json();case 13:return e.abrupt("return",{start:o.start,end:o.end,total:o.total,notes:e.sent});case 15:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i.mark=function(e){return(t=t||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/notifications/"+t,e.next=4,this.client.fetch(r,"PUT",null);case 4:return n=e.sent,e.next=7,n.text();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i.delete=function(e){return(r=r||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/notifications/"+t,e.next=4,this.client.fetch(r,"DELETE",null);case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n}(),Kt=function(e){function t(e){this.client=e}return t.prototype.listReply=function(t){return(e=e||f(d().mark((function e(t){var r,n,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new URLSearchParams,void 0!==t&&r.append("route",t),n="/escrows/rpy?"+r.toString(),e.next=6,this.client.fetch(n,"GET",null);case 6:return i=e.sent,e.next=9,i.json();case 9:return e.abrupt("return",e.sent);case 10:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},t}(),Xt=function(e,t){function r(e){this.client=e}var n=r.prototype;return n.getRequest=function(t){return(e=e||f(d().mark((function e(t){var r,n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r="/multisig/request/"+t,e.next=4,this.client.fetch(r,"GET",null);case 4:return n=e.sent,e.next=7,n.json();case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n.sendRequest=function(e,r,n,i){return(t=t||f(d().mark((function e(t,r,n,i){var s,o,a;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s="/identifiers/"+t+"/multisig/request",o={exn:r,sigs:n,atc:i},e.next=5,this.client.fetch(s,"POST",o);case 5:return a=e.sent,e.next=8,a.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},r}(),Vt=new RegExp("^[A-Za-z0-9\\-_]*$"),Zt=function(e){function t(r,n,i){var s=r.raw,o=r.code,a=void 0===o?F.StrB64_L0:o,u=r.qb64b,c=r.qb64,h=r.qb2;if(void 0===s&&void 0===n&&void 0===u&&void 0===c&&void 0===h){if(void 0===i)throw new S("Missing bext string.");n=t._bextify(i)}return e.call(this,{raw:s,code:a,qb64b:u,qb64:c,qb2:h},n)||this}return g(t,e),t._bextify=function(e){for(var t,r=[],n=E(e);!(t=n()).done;){var i,s=t.value;if(i="number"==typeof s?s.toString():s,!Vt.exec(i))throw new Error('"Non Base64 path component = '+s+".");r.push(i)}return"-"+r.join("-")},v(t,[{key:"path",get:function(){if(!this.bext.startsWith("-"))throw new Error("invalid SAD ptr");for(var e=this.bext;"-"===e.charAt(0);)e=e.substring(1);var t=e.split("-");return""!==t[0]?t:[]}}]),t}(function(e){function t(r,n){var i,s=r.raw,o=r.code,a=void 0===o?F.StrB64_L0:o,u=r.qb64b,c=r.qb64,h=r.qb2;if(void 0===s&&void 0===u&&void 0===c&&void 0===h){if(void 0===n)throw new S("Missing bext string.");if(!Vt.exec(n))throw new Error("Invalid Base64.");s=t._rawify(n)}if(i=e.call(this,{raw:s,code:a,qb64b:u,qb64:c,qb2:h})||this,!Q.has(i.code))throw new Error("Invalid code = "+i.code+" for Bexter.");return i}return g(t,e),t._rawify=function(e){var t=e.length%4,r=(3-t)%3,n=new Array((4-t)%4);n.fill("A");var i=n.join("")+e,o=s.decode(i);return Uint8Array.from(o).subarray(r)},v(t,[{key:"bext",get:function(){var e=re.Sizes.get(this.code),t=Uint8Array.from(new Array(null==e?void 0:e.ls).fill(0)),r=s.encode(Buffer.from([].concat(t,this.raw))),n=0;return 0===(null==e?void 0:e.ls)&&void 0!==r?"A"===r[0]&&(n=1):n=((null==e?void 0:e.ls)+1)%4,r.substring(n)}}]),t}(re)),Wt=function(e,t,r){function n(e){this.client=e}var i=n.prototype;return i.createExchangeMessage=function(t,r,n,i,s,o,a){return(e=e||f(d().mark((function e(t,r,n,i,s,o,a){var u,c,h,l;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=this.client.manager.get(t),c=Yt(r,n,t.prefix,s,o,a,void 0,i),h=c[0],l=c[1],e.next=4,u.sign(P(h.raw));case 4:return e.abrupt("return",[h,e.sent,L(l)]);case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i.send=function(e,r,n,i,s,o,a){return(t=t||f(d().mark((function e(t,r,n,i,s,o,a){var u,c,h,l;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.createExchangeMessage(n,i,s,o);case 2:return c=(u=e.sent)[0],h=u[1],l=u[2],e.next=8,this.sendFromEvents(t,r,c,h,l,a);case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},i.sendFromEvents=function(e,t,n,i,s,o){return(r=r||f(d().mark((function e(t,r,n,i,s,o){var a,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a="/identifiers/"+t+"/exchanges",u={tpc:r,exn:n.ked,sigs:i,atc:s,rec:o},e.next=5,this.client.fetch(a,"POST",u);case 5:return c=e.sent,e.next=8,c.json();case 8:return e.abrupt("return",e.sent);case 9:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},n}();function Yt(e,t,r,n,i,s,o,a){var u=O(exports.Ident.KERI,void 0,exports.Serials.JSON,0),c=I.exn,h=void 0!==i?i:Ee().toISOString().replace("Z","000+00:00"),d=void 0!==s?s:"",l=void 0!==o?o:{},f={},p="";if(Object.entries(null!=a?a:{}).forEach((function(e){var t=e[0],r=e[1],n=r[1];if(f[t]=r[0].ked,null!=n){var i="";i+=new Zt({},void 0,["e",t]).qb64,i+=n;var s=new Ye({code:We.PathedMaterialQuadlets,count:Math.floor(i.length/4)});p+=s.qb64,p+=i}})),Object.keys(f).length>0){f.d="";var v=Ve.saidify(f);f=v[1]}var g={};void 0!==n&&(g.i=n);var b=w({},g,t),y=Ve.saidify({v:u,t:c,d:"",i:r,p:d,dt:h,r:e,q:l,a:b,e:f});return[new He(y[1]),P(p)]}var Qt,$t=function(){this.agent=null,this.controller=null,this.pidx=0,this.ridx=0},er=function(e,t,r,n,i,s,o,a,u){function c(e,t,r,n,i){if(void 0===r&&(r=exports.Tier.low),void 0===n&&(n="http://localhost:3903"),void 0===i&&(i=[]),this.url=e,t.length<21)throw Error("bran must be 21 characters");this.bran=t,this.pidx=0,this.controller=new lt(t,r),this.authn=null,this.agent=null,this.manager=null,this.tier=r,this.bootUrl=n,this.exteralModules=i}var h=c.prototype;return h.boot=function(){return(e=e||f(d().mark((function e(){var t,r,n,i,s,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=null!=(t=null==(r=this.controller)?void 0:r.event)?t:[],o={icp:s[0].ked,sig:s[1].qb64,stem:null==(n=this.controller)?void 0:n.stem,pidx:1,tier:null==(i=this.controller)?void 0:i.tier},e.next=4,fetch(this.bootUrl+"/boot",{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.state=function(){return(t=t||f(d().mark((function e(){var t,r,n,i,s,o,a,u,c;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=null==(t=this.controller)?void 0:t.pre,e.next=3,fetch(this.url+"/agent/"+o);case 3:if(404!=(a=e.sent).status){e.next=6;break}throw new Error("agent does not exist for controller "+o);case 6:return e.next=8,a.json();case 8:return u=e.sent,(c=new $t).agent=null!=(r=u.agent)?r:{},c.controller=null!=(n=u.controller)?n:{},c.ridx=null!=(i=u.ridx)?i:0,c.pidx=null!=(s=u.pidx)?s:0,e.abrupt("return",c);case 15:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.connect=function(){return(r=r||f(d().mark((function e(){var t;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.state();case 2:if(this.pidx=(t=e.sent).pidx,this.controller=new lt(this.bran,this.tier,0,t.controller),this.controller.ridx=void 0!==t.ridx?t.ridx:0,this.agent=new dt(t.agent),this.agent.anchor==this.controller.pre){e.next=9;break}throw Error("commitment to controller AID missing in agent inception event");case 9:if(0!=this.controller.serder.ked.s){e.next=12;break}return e.next=12,this.approveDelegation();case 12:this.manager=new At(this.controller.salter,this.exteralModules),this.authn=new St(this.controller.signer,this.agent.verfer);case 14:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.fetch=function(e){function t(t,r,n,i){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t,r,i){return(n=n||f(d().mark((function e(t,r,n,i){var s,o,a,u,c,h;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=new Headers,a=new Headers,u=new Headers,o.set("Signify-Resource",this.controller.pre),o.set("Signify-Timestamp",(new Date).toISOString().replace("Z","000+00:00")),o.set("Content-Type","application/json"),null!==(c="GET"==r?null:JSON.stringify(n))&&o.set("Content-Length",String(c.length)),!this.authn){e.next=12;break}a=this.authn.sign(o,r,t.split("?")[0]),e.next=13;break;case 12:throw new Error("client need to call connect first");case 13:return a.forEach((function(e,t){u.set(t,e)})),void 0!==i&&i.forEach((function(e,t){u.append(t,e)})),e.next=17,fetch(this.url+t,{method:r,body:c,headers:u});case 17:if((h=e.sent).ok){e.next=23;break}return e.next=21,h.text();case 21:throw new Error(e.sent);case 23:if((null==(s=this.agent)?void 0:s.pre)===h.headers.get("signify-resource")){e.next=26;break}throw new Error("message from a different remote agent");case 26:if(!this.authn.verify(h.headers,r,t.split("?")[0])){e.next=31;break}return e.abrupt("return",h);case 31:throw new Error("response verification failed");case 32:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)})),h.signedFetch=function(e,t,r,n,s){return(i=i||f(d().mark((function e(t,r,n,i,s){var o,a,u,c,h,l;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.identifiers().get(s);case 2:return a=this.manager.get(o=e.sent),u=new St(a.signers[0],a.signers[0].verfer),(c=new Headers).set("Signify-Resource",o.prefix),c.set("Signify-Timestamp",(new Date).toISOString().replace("Z","000+00:00")),c.set("Content-Length",null!==i?i.length:"0"),h=u.sign(c,n,r.split("?")[0]),l=null,"GET"!=n?i instanceof FormData?l=i:(l=JSON.stringify(i),c.set("Content-Type","application/json")):c.set("Content-Type","application/json"),e.next=14,fetch(t+r,{method:n,body:l,headers:h});case 14:return e.abrupt("return",e.sent);case 15:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.approveDelegation=function(){return(s=s||f(d().mark((function e(){var t,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.controller.approveDelegation(this.agent),r={ixn:this.controller.serder.ked,sigs:t},e.next=4,fetch(this.url+"/agent/"+this.controller.pre+"?type=ixn",{method:"PUT",body:JSON.stringify(r),headers:{"Content-Type":"application/json"}});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.saveOldPasscode=function(e){return(o=o||f(d().mark((function e(t){var r,n,i;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null==(r=this.controller)?void 0:r.pre,i={salt:t},e.next=4,fetch(this.url+"/salt/"+n,{method:"PUT",body:JSON.stringify(i),headers:{"Content-Type":"application/json"}});case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.deletePasscode=function(){return(a=a||f(d().mark((function e(){var t,r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=null==(t=this.controller)?void 0:t.pre,e.next=3,fetch(this.url+"/salt/"+r,{method:"DELETE",headers:{"Content-Type":"application/json"}});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.rotate=function(e,t){return(u=u||f(d().mark((function e(t,r){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=this.controller.rotate(t,r),e.next=3,fetch(this.url+"/agent/"+this.controller.pre,{method:"PUT",body:JSON.stringify(n),headers:{"Content-Type":"application/json"}});case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)},h.identifiers=function(){return new yt(this)},h.oobis=function(){return new zt(this)},h.operations=function(){return new jt(this)},h.keyEvents=function(){return new Dt(this)},h.keyStates=function(){return new Tt(this)},h.credentials=function(){return new Ut(this)},h.ipex=function(){return new Ft(this)},h.registries=function(){return new Gt(this)},h.schemas=function(){return new Ht(this)},h.challenges=function(){return new Mt(this)},h.contacts=function(){return new Ct(this)},h.notifications=function(){return new Jt(this)},h.escrows=function(){return new Kt(this)},h.groups=function(){return new Xt(this)},h.exchanges=function(){return new Wt(this)},v(c,[{key:"data",get:function(){return[this.url,this.bran,this.pidx,this.authn]}}]),c}();try{window.Buffer=o.Buffer}catch(e){}var tr=n.create(n.all,{});exports.Agent=dt,exports.Authenticater=St,exports.B64ChrByIdx=z,exports.B64IdxByChr=j,exports.BexCodex=Y,exports.BexDex=Q,exports.CesrNumber=Re,exports.Challenges=Mt,exports.Cigar=ie,exports.Cipher=xe,exports.Codex=G,exports.Contacts=Ct,exports.Controller=lt,exports.Counter=Ye,exports.CounterCodex=Ze,exports.Creatory=Te,exports.CredentialResult=Lt,exports.CredentialTypes=Pt,exports.Credentials=Ut,exports.CtrDex=We,exports.Decrypter=ye,exports.Diger=Ie,exports.DigiCodex=X,exports.DigiDex=V,exports.DipLabels=["v","i","s","t","kt","k","n","bt","b","c","a","di"],exports.DrtLabels=["v","i","s","t","p","kt","k","n","bt","br","ba","a"],exports.EmptyMaterialError=S,exports.Encrypter=qe,exports.Escrows=Kt,exports.EventResult=xt,exports.Exchanges=Wt,exports.FALSY=_t,exports.GroupKeeper=Bt,exports.Groups=Xt,exports.Hab=ct,exports.Habery=ht,exports.IcpLabels=["v","i","s","t","kt","k","n","bt","b","c","a"],exports.Identifier=yt,exports.IdrDex=oe,exports.IdxBthSigDex=le,exports.IdxCrtSigDex=he,exports.IdxSigDex=ue,exports.Ilks=I,exports.IndexedBothSigCodex=de,exports.IndexedCurrentSigCodex=ce,exports.IndexedSigCodex=ae,exports.Indexer=pe,exports.IndexerCodex=se,exports.Inputage=wt,exports.Ipex=Ft,exports.IxnLabels=["v","i","s","t","p","a"],exports.KeyEvents=Dt,exports.KeyManager=At,exports.KeyStates=Tt,exports.KsnLabels=["v","i","s","t","p","d","f","dt","et","kt","k","n","bt","b","c","ee","di","r"],exports.LargeVrzDex=ee,exports.MINSIGSIZE=4,exports.MINSNIFFSIZE=29,exports.Manager=Pe,exports.Matter=re,exports.MatterCodex=H,exports.MtrDex=F,exports.NonTransCodex=J,exports.NonTransDex=K,exports.Notifications=Jt,exports.NumCodex=Z,exports.NumDex=W,exports.Oobis=zt,exports.Operations=jt,exports.Prefixer=Ke,exports.RandyCreator=je,exports.RandyKeeper=It,exports.Registries=Gt,exports.RegistryResult=Rt,exports.RotLabels=["v","i","s","t","p","kt","k","n","bt","br","ba","a"],exports.RpyLabels=["v","t","d","dt","r","a"],exports.Saider=Ve,exports.Salter=be,exports.SaltyCreator=De,exports.SaltyKeeper=qt,exports.Schemas=Ht,exports.Seqner=$e,exports.Serder=He,exports.Siger=we,exports.Signage=mt,exports.Signer=ge,exports.SignifyClient=er,exports.Sizage=te,exports.SmallVrzDex=$,exports.TRUTHY=[!0,1,"?1","yes","true","True","on"],exports.Tholder=Ge,exports.TraitCodex=at,exports.TraitDex=ut,exports.Unqualified=vt,exports.VEREX=M,exports.VERFULLSIZE=17,exports.Verfer=ne,exports.Version=A,exports.Versionage=q,exports.Xizage=fe,exports.ample=rt,exports.arrayEquals=_e,exports.b=P,exports.b64ToInt=T,exports.bytesToInt=Se,exports.concat=U,exports.d=L,exports.desiginput=gt,exports.designature=kt,exports.deversify=N,exports.dumps=Fe,exports.exchange=Yt,exports.extractValues=function(e,t){for(var r,n=[],i=E(t);!(r=i()).done;)n=me(e[r.value],n);return n},exports.incept=nt,exports.intToB64=D,exports.intToB64b=function(e,t){return void 0===t&&(t=1),P(D(e,t))},exports.intToBytes=ke,exports.interact=st,exports.math=tr,exports.messagize=it,exports.normalize=ft,exports.nowUTC=Ee,exports.openManager=function(e,t){if(e.length<21)throw new Error("Bran (passcode seed material) too short.");var r,n=F.Salt_128+"A"+e.substring(0,21),i=new be({qb64:n}).signer(F.Ed25519_Seed,!1),s=i.qb64,o=i.verfer.qb64,a=null!=t?new be({qb64:t}):void 0;return r=null!=t?exports.Algos.salty:exports.Algos.randy,new Pe({seed:s,aeid:o,algo:r,salter:a})},exports.pad=function(e,t,r){return void 0===t&&(t=3),void 0===r&&(r=0),(String(r).repeat(t)+String(e)).slice(String(e).length)},exports.parseRangeHeaders=bt,exports.randomNonce=Nt,exports.randomPasscode=function(){var e=r.randombytes_buf(16);return new be({raw:e}).qb64.substring(2)},exports.range=function(e,t,r){if(void 0===t&&(t=e,e=0),void 0===r&&(r=1),r>0&&e>=t||r<0&&e<=t)return[];for(var n=new Array,i=e;r>0?i<t:i>t;i+=r)n.push(i);return n},exports.readInt=R,exports.ready=function(){return(Qt=Qt||f(d().mark((function e(){var n;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,new Promise((function(e){e(t(require("blake3/browser-async")))}));case 3:return n=e.sent,e.next=6,n.default("https://cdn.jsdelivr.net/npm/blake3@2.1.7/dist/wasm/web/blake3_js_bg.wasm");case 6:return e.next=8,r.ready;case 8:e.next=14;break;case 10:return e.prev=10,e.t0=e.catch(0),e.next=14,r.ready;case 14:case"end":return e.stop()}}),e,null,[[0,10]])})))).apply(this,arguments)},exports.reply=ot,exports.riKey=Le,exports.rotate=tt,exports.siginput=pt,exports.signature=Et,exports.sizeify=Je,exports.versify=O;
2
2
  //# sourceMappingURL=signify-ts.cjs.production.min.js.map