solid-logic 3.1.1-f0ed025 → 3.1.1-f7eee1f
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.
- package/README.md +108 -2
- package/dist/789.solid-logic.js +11 -0
- package/dist/789.solid-logic.js.map +1 -0
- package/dist/789.solid-logic.min.js +1 -0
- package/dist/841.solid-logic.js +12133 -0
- package/dist/841.solid-logic.js.map +1 -0
- package/dist/841.solid-logic.min.js +73 -0
- package/dist/841.solid-logic.min.js.map +1 -0
- package/dist/acl/aclLogic.d.ts +5 -0
- package/{lib → dist}/acl/aclLogic.d.ts.map +1 -1
- package/dist/acl/aclLogic.js +122 -0
- package/dist/acl/aclLogic.js.map +1 -0
- package/{lib → dist}/authSession/authSession.js +1 -1
- package/{lib → dist}/authSession/authSession.js.map +1 -1
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts +3 -3
- package/{lib → dist}/authn/SolidAuthnLogic.d.ts.map +1 -1
- package/dist/authn/SolidAuthnLogic.js +147 -0
- package/dist/authn/SolidAuthnLogic.js.map +1 -0
- package/{lib → dist}/authn/authUtil.d.ts +1 -1
- package/{lib → dist}/authn/authUtil.js +12 -12
- package/dist/authn/authUtil.js.map +1 -0
- package/{lib → dist}/chat/chatLogic.d.ts +1 -1
- package/dist/chat/chatLogic.js +160 -0
- package/dist/chat/chatLogic.js.map +1 -0
- package/{lib → dist}/inbox/inboxLogic.d.ts +1 -1
- package/{lib → dist}/inbox/inboxLogic.d.ts.map +1 -1
- package/dist/inbox/inboxLogic.js +55 -0
- package/dist/inbox/inboxLogic.js.map +1 -0
- package/{lib → dist}/index.d.ts +1 -1
- package/{lib → dist}/index.d.ts.map +1 -1
- package/{lib → dist}/index.js +4 -4
- package/{lib → dist}/index.js.map +1 -1
- package/dist/issuer/issuerLogic.js +40 -0
- package/dist/issuer/issuerLogic.js.map +1 -0
- package/{lib → dist}/logic/CustomError.d.ts.map +1 -1
- package/dist/logic/CustomError.js +38 -0
- package/dist/logic/CustomError.js.map +1 -0
- package/dist/logic/solidLogic.d.ts +6 -0
- package/{lib → dist}/logic/solidLogic.d.ts.map +1 -1
- package/{lib → dist}/logic/solidLogic.js +32 -33
- package/dist/logic/solidLogic.js.map +1 -0
- package/dist/logic/solidLogicSingleton.js +54 -0
- package/dist/logic/solidLogicSingleton.js.map +1 -0
- package/{lib → dist}/profile/profileLogic.d.ts +1 -1
- package/dist/profile/profileLogic.js +165 -0
- package/dist/profile/profileLogic.js.map +1 -0
- package/dist/solid-logic.esm.external.js +12725 -0
- package/dist/solid-logic.esm.external.js.map +1 -0
- package/dist/solid-logic.esm.external.min.js +32 -0
- package/dist/solid-logic.esm.external.min.js.map +1 -0
- package/dist/solid-logic.external.js +12802 -0
- package/dist/solid-logic.external.js.map +1 -0
- package/dist/solid-logic.external.min.js +32 -0
- package/dist/solid-logic.external.min.js.map +1 -0
- package/dist/solid-logic.js +40921 -0
- package/dist/solid-logic.js.map +1 -0
- package/dist/solid-logic.min.js +41 -0
- package/dist/solid-logic.min.js.map +1 -0
- package/dist/typeIndex/typeIndexLogic.js +222 -0
- package/dist/typeIndex/typeIndexLogic.js.map +1 -0
- package/{lib → dist}/types.d.ts +2 -2
- package/{lib → dist}/util/containerLogic.d.ts +1 -1
- package/{lib → dist}/util/containerLogic.d.ts.map +1 -1
- package/{src/util/containerLogic.ts → dist/util/containerLogic.js} +20 -25
- package/dist/util/containerLogic.js.map +1 -0
- package/dist/util/debug.d.ts.map +1 -0
- package/dist/util/debug.js +20 -0
- package/dist/util/debug.js.map +1 -0
- package/{lib → dist}/util/ns.js +2 -2
- package/{lib → dist}/util/ns.js.map +1 -1
- package/{lib → dist}/util/utilityLogic.d.ts +1 -1
- package/{lib → dist}/util/utilityLogic.d.ts.map +1 -1
- package/dist/util/utilityLogic.js +180 -0
- package/dist/util/utilityLogic.js.map +1 -0
- package/{lib → dist}/util/utils.d.ts +1 -1
- package/{lib → dist}/util/utils.d.ts.map +1 -1
- package/dist/util/utils.js +47 -0
- package/dist/util/utils.js.map +1 -0
- package/dist/versionInfo.js +33 -0
- package/dist/versionInfo.js.map +1 -0
- package/package.json +58 -20
- package/eslint.config.js +0 -29
- package/jest.config.js +0 -10
- package/lib/acl/aclLogic.d.ts +0 -5
- package/lib/acl/aclLogic.js +0 -168
- package/lib/acl/aclLogic.js.map +0 -1
- package/lib/authn/SolidAuthnLogic.js +0 -193
- package/lib/authn/SolidAuthnLogic.js.map +0 -1
- package/lib/authn/authUtil.js.map +0 -1
- package/lib/chat/chatLogic.js +0 -272
- package/lib/chat/chatLogic.js.map +0 -1
- package/lib/inbox/inboxLogic.js +0 -139
- package/lib/inbox/inboxLogic.js.map +0 -1
- package/lib/issuer/issuerLogic.js +0 -52
- package/lib/issuer/issuerLogic.js.map +0 -1
- package/lib/logic/CustomError.js +0 -89
- package/lib/logic/CustomError.js.map +0 -1
- package/lib/logic/solidLogic.d.ts +0 -6
- package/lib/logic/solidLogic.js.map +0 -1
- package/lib/logic/solidLogicSingleton.js +0 -94
- package/lib/logic/solidLogicSingleton.js.map +0 -1
- package/lib/profile/profileLogic.js +0 -259
- package/lib/profile/profileLogic.js.map +0 -1
- package/lib/typeIndex/typeIndexLogic.js +0 -399
- package/lib/typeIndex/typeIndexLogic.js.map +0 -1
- package/lib/util/containerLogic.js +0 -102
- package/lib/util/containerLogic.js.map +0 -1
- package/lib/util/debug.d.ts.map +0 -1
- package/lib/util/debug.js +0 -40
- package/lib/util/debug.js.map +0 -1
- package/lib/util/utilityLogic.js +0 -284
- package/lib/util/utilityLogic.js.map +0 -1
- package/lib/util/utils.js +0 -47
- package/lib/util/utils.js.map +0 -1
- package/src/acl/aclLogic.ts +0 -156
- package/src/authSession/authSession.ts +0 -7
- package/src/authn/SolidAuthnLogic.ts +0 -127
- package/src/authn/authUtil.ts +0 -70
- package/src/chat/chatLogic.ts +0 -226
- package/src/inbox/inboxLogic.ts +0 -59
- package/src/index.ts +0 -22
- package/src/issuer/issuerLogic.ts +0 -40
- package/src/logic/CustomError.ts +0 -29
- package/src/logic/solidLogic.ts +0 -76
- package/src/logic/solidLogicSingleton.ts +0 -20
- package/src/profile/profileLogic.ts +0 -125
- package/src/typeIndex/typeIndexLogic.ts +0 -198
- package/src/types.ts +0 -122
- package/src/util/debug.ts +0 -20
- package/src/util/ns.ts +0 -5
- package/src/util/utilityLogic.ts +0 -156
- package/src/util/utils.ts +0 -52
- package/test/aclLogic.test.ts +0 -24
- package/test/authUtil.test.ts +0 -23
- package/test/chatLogic.test.ts +0 -316
- package/test/container.test.ts +0 -58
- package/test/helpers/dataSetup.ts +0 -134
- package/test/helpers/setup.ts +0 -17
- package/test/inboxLogic.test.ts +0 -218
- package/test/logic.test.ts +0 -29
- package/test/profileLogic.test.ts +0 -246
- package/test/solidAuthLogic.test.ts +0 -49
- package/test/typeIndexLogic.test.ts +0 -255
- package/test/utilityLogic.test.ts +0 -179
- package/test/utils.test.ts +0 -32
- package/tsconfig.json +0 -75
- /package/{lib → dist}/authSession/authSession.d.ts +0 -0
- /package/{lib → dist}/authSession/authSession.d.ts.map +0 -0
- /package/{lib → dist}/authn/authUtil.d.ts.map +0 -0
- /package/{lib → dist}/chat/chatLogic.d.ts.map +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts +0 -0
- /package/{lib → dist}/issuer/issuerLogic.d.ts.map +0 -0
- /package/{lib → dist}/logic/CustomError.d.ts +0 -0
- /package/{lib → dist}/logic/solidLogicSingleton.d.ts +0 -0
- /package/{lib → dist}/logic/solidLogicSingleton.d.ts.map +0 -0
- /package/{lib → dist}/profile/profileLogic.d.ts.map +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts +0 -0
- /package/{lib → dist}/typeIndex/typeIndexLogic.d.ts.map +0 -0
- /package/{lib → dist}/types.d.ts.map +0 -0
- /package/{lib → dist}/types.js +0 -0
- /package/{lib → dist}/types.js.map +0 -0
- /package/{lib → dist}/util/debug.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts +0 -0
- /package/{lib → dist}/util/ns.d.ts.map +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import*as e from"$rdf";var t={149:(e,t,r)=>{function n(e){if("object"!=typeof(t=e)||null===t||"[object Object]"!==Object.prototype.toString.call(e))return!1;var t;if(null===Object.getPrototypeOf(e))return!0;let r=e;for(;null!==Object.getPrototypeOf(r);)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(e)===r}r.d(t,{A:()=>n})},182:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.validate=t.v7=t.v6ToV1=t.v6=t.v5=t.v4=t.v3=t.v1ToV6=t.v1=t.stringify=t.parse=t.NIL=t.MAX=void 0;var n=r(2196);Object.defineProperty(t,"MAX",{enumerable:!0,get:function(){return n.default}});var i=r(3465);Object.defineProperty(t,"NIL",{enumerable:!0,get:function(){return i.default}});var o=r(1797);Object.defineProperty(t,"parse",{enumerable:!0,get:function(){return o.default}});var s=r(6011);Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return s.default}});var a=r(1425);Object.defineProperty(t,"v1",{enumerable:!0,get:function(){return a.default}});var c=r(6568);Object.defineProperty(t,"v1ToV6",{enumerable:!0,get:function(){return c.default}});var u=r(591);Object.defineProperty(t,"v3",{enumerable:!0,get:function(){return u.default}});var l=r(8286);Object.defineProperty(t,"v4",{enumerable:!0,get:function(){return l.default}});var d=r(4557);Object.defineProperty(t,"v5",{enumerable:!0,get:function(){return d.default}});var h=r(6356);Object.defineProperty(t,"v6",{enumerable:!0,get:function(){return h.default}});var f=r(268);Object.defineProperty(t,"v6ToV1",{enumerable:!0,get:function(){return f.default}});var p=r(4299);Object.defineProperty(t,"v7",{enumerable:!0,get:function(){return p.default}});var g=r(9746);Object.defineProperty(t,"validate",{enumerable:!0,get:function(){return g.default}});var y=r(2770);Object.defineProperty(t,"version",{enumerable:!0,get:function(){return y.default}})},268:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(1797),i=r(6011);t.default=function(e){const t=function(e){return Uint8Array.of((15&e[3])<<4|e[4]>>4&15,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|15&e[6],e[7],(15&e[1])<<4|(240&e[2])>>4,(15&e[2])<<4|(240&e[3])>>4,16|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,n.default)(e):e);return"string"==typeof e?(0,i.unsafeStringify)(t):t}},338:(e,t)=>{function r(e){return 14+(e+64>>>9<<4)+1}function n(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}function i(e,t,r,i,o,s){return n((a=n(n(t,e),n(i,s)))<<(c=o)|a>>>32-c,r);var a,c}function o(e,t,r,n,o,s,a){return i(t&r|~t&n,e,t,o,s,a)}function s(e,t,r,n,o,s,a){return i(t&n|r&~n,e,t,o,s,a)}function a(e,t,r,n,o,s,a){return i(t^r^n,e,t,o,s,a)}function c(e,t,r,n,o,s,a){return i(r^(t|~n),e,t,o,s,a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(e){const t=new Uint8Array(4*e.length);for(let r=0;r<4*e.length;r++)t[r]=e[r>>2]>>>r%4*8&255;return t}(function(e,t){const i=new Uint32Array(r(t)).fill(0);i.set(e),i[t>>5]|=128<<t%32,i[i.length-1]=t,e=i;let u=1732584193,l=-271733879,d=-1732584194,h=271733878;for(let t=0;t<e.length;t+=16){const r=u,i=l,f=d,p=h;u=o(u,l,d,h,e[t],7,-680876936),h=o(h,u,l,d,e[t+1],12,-389564586),d=o(d,h,u,l,e[t+2],17,606105819),l=o(l,d,h,u,e[t+3],22,-1044525330),u=o(u,l,d,h,e[t+4],7,-176418897),h=o(h,u,l,d,e[t+5],12,1200080426),d=o(d,h,u,l,e[t+6],17,-1473231341),l=o(l,d,h,u,e[t+7],22,-45705983),u=o(u,l,d,h,e[t+8],7,1770035416),h=o(h,u,l,d,e[t+9],12,-1958414417),d=o(d,h,u,l,e[t+10],17,-42063),l=o(l,d,h,u,e[t+11],22,-1990404162),u=o(u,l,d,h,e[t+12],7,1804603682),h=o(h,u,l,d,e[t+13],12,-40341101),d=o(d,h,u,l,e[t+14],17,-1502002290),l=o(l,d,h,u,e[t+15],22,1236535329),u=s(u,l,d,h,e[t+1],5,-165796510),h=s(h,u,l,d,e[t+6],9,-1069501632),d=s(d,h,u,l,e[t+11],14,643717713),l=s(l,d,h,u,e[t],20,-373897302),u=s(u,l,d,h,e[t+5],5,-701558691),h=s(h,u,l,d,e[t+10],9,38016083),d=s(d,h,u,l,e[t+15],14,-660478335),l=s(l,d,h,u,e[t+4],20,-405537848),u=s(u,l,d,h,e[t+9],5,568446438),h=s(h,u,l,d,e[t+14],9,-1019803690),d=s(d,h,u,l,e[t+3],14,-187363961),l=s(l,d,h,u,e[t+8],20,1163531501),u=s(u,l,d,h,e[t+13],5,-1444681467),h=s(h,u,l,d,e[t+2],9,-51403784),d=s(d,h,u,l,e[t+7],14,1735328473),l=s(l,d,h,u,e[t+12],20,-1926607734),u=a(u,l,d,h,e[t+5],4,-378558),h=a(h,u,l,d,e[t+8],11,-2022574463),d=a(d,h,u,l,e[t+11],16,1839030562),l=a(l,d,h,u,e[t+14],23,-35309556),u=a(u,l,d,h,e[t+1],4,-1530992060),h=a(h,u,l,d,e[t+4],11,1272893353),d=a(d,h,u,l,e[t+7],16,-155497632),l=a(l,d,h,u,e[t+10],23,-1094730640),u=a(u,l,d,h,e[t+13],4,681279174),h=a(h,u,l,d,e[t],11,-358537222),d=a(d,h,u,l,e[t+3],16,-722521979),l=a(l,d,h,u,e[t+6],23,76029189),u=a(u,l,d,h,e[t+9],4,-640364487),h=a(h,u,l,d,e[t+12],11,-421815835),d=a(d,h,u,l,e[t+15],16,530742520),l=a(l,d,h,u,e[t+2],23,-995338651),u=c(u,l,d,h,e[t],6,-198630844),h=c(h,u,l,d,e[t+7],10,1126891415),d=c(d,h,u,l,e[t+14],15,-1416354905),l=c(l,d,h,u,e[t+5],21,-57434055),u=c(u,l,d,h,e[t+12],6,1700485571),h=c(h,u,l,d,e[t+3],10,-1894986606),d=c(d,h,u,l,e[t+10],15,-1051523),l=c(l,d,h,u,e[t+1],21,-2054922799),u=c(u,l,d,h,e[t+8],6,1873313359),h=c(h,u,l,d,e[t+15],10,-30611744),d=c(d,h,u,l,e[t+6],15,-1560198380),l=c(l,d,h,u,e[t+13],21,1309151649),u=c(u,l,d,h,e[t+4],6,-145523070),h=c(h,u,l,d,e[t+11],10,-1120210379),d=c(d,h,u,l,e[t+2],15,718787259),l=c(l,d,h,u,e[t+9],21,-343485551),u=n(u,r),l=n(l,i),d=n(d,f),h=n(h,p)}return Uint32Array.of(u,l,d,h)}(function(e){if(0===e.length)return new Uint32Array;const t=new Uint32Array(r(8*e.length)).fill(0);for(let r=0;r<e.length;r++)t[r>>2]|=(255&e[r])<<r%4*8;return t}(e),8*e.length))}},390:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FetchError=t.WebOperationError=t.NotEditableError=t.NotFoundError=t.SameOriginForbiddenError=t.CrossOriginForbiddenError=t.UnauthorizedError=void 0;class r extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=new.target.name}}t.UnauthorizedError=class extends r{};t.CrossOriginForbiddenError=class extends r{};t.SameOriginForbiddenError=class extends r{};t.NotFoundError=class extends r{};t.NotEditableError=class extends r{};t.WebOperationError=class extends r{};t.FetchError=class extends r{status;constructor(e,t){super(t),this.status=e}}},458:(e,t,r)=>{r.d(t,{w:()=>l});var n=r(8278),i=r(7493),o=r(149);function s(e){return(0,o.A)(e)}function a(e){return"function"==typeof structuredClone?structuredClone(e):JSON.parse(JSON.stringify(e))}class c{constructor(e){if(this._cached=new WeakMap,!function(e){return e&&"object"==typeof e&&Array.isArray(e.keys)&&e.keys.every(s)}(e))throw new i.JWKSInvalid("JSON Web Key Set malformed");this._jwks=a(e)}async getKey(e,t){const{alg:r,kid:n}={...e,...t?.header},o=function(e){switch("string"==typeof e&&e.slice(0,2)){case"RS":case"PS":return"RSA";case"ES":return"EC";case"Ed":return"OKP";default:throw new i.JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set')}}(r),s=this._jwks.keys.filter(e=>{let t=o===e.kty;if(t&&"string"==typeof n&&(t=n===e.kid),t&&"string"==typeof e.alg&&(t=r===e.alg),t&&"string"==typeof e.use&&(t="sig"===e.use),t&&Array.isArray(e.key_ops)&&(t=e.key_ops.includes("verify")),t)switch(r){case"ES256":t="P-256"===e.crv;break;case"ES256K":t="secp256k1"===e.crv;break;case"ES384":t="P-384"===e.crv;break;case"ES512":t="P-521"===e.crv;break;case"Ed25519":t="Ed25519"===e.crv;break;case"EdDSA":t="Ed25519"===e.crv||"Ed448"===e.crv}return t}),{0:a,length:c}=s;if(0===c)throw new i.JWKSNoMatchingKey;if(1!==c){const e=new i.JWKSMultipleMatchingKeys,{_cached:t}=this;throw e[Symbol.asyncIterator]=async function*(){for(const e of s)try{yield await u(t,e,r)}catch{}},e}return u(this._cached,a,r)}}async function u(e,t,r){const o=e.get(t)||e.set(t,{}).get(t);if(void 0===o[r]){const e=await(0,n.Og)({...t,ext:!0},r);if(e instanceof Uint8Array||"public"!==e.type)throw new i.JWKSInvalid("JSON Web Key Set members must be public keys");o[r]=e}return o[r]}function l(e){const t=new c(e),r=async(e,r)=>t.getKey(e,r);return Object.defineProperties(r,{jwks:{value:()=>a(t._jwks),enumerable:!0,configurable:!1,writable:!1}}),r}},591:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0;const n=r(338),i=r(2988);var o=r(2988);function s(e,t,r,o){return(0,i.default)(48,n.default,e,t,r,o)}Object.defineProperty(t,"DNS",{enumerable:!0,get:function(){return o.DNS}}),Object.defineProperty(t,"URL",{enumerable:!0,get:function(){return o.URL}}),s.DNS=i.DNS,s.URL=i.URL,t.default=s},610:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(7991);const i=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await n.A.subtle.digest(r,t))}},676:(e,t,r)=>{r.d(t,{A:()=>c});var n=r(7991),i=r(2698),o=r(1575),s=r(5994),a=r(3139);async function c(e,t,r){if("sign"===r&&(t=await a.A.normalizePrivateKey(t,e)),"verify"===r&&(t=await a.A.normalizePublicKey(t,e)),(0,n.R)(t))return(0,i.Y)(t,e,r),t;if(t instanceof Uint8Array){if(!e.startsWith("HS"))throw new TypeError((0,o.A)(t,...s.g));return n.A.subtle.importKey("raw",t,{hash:`SHA-${e.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError((0,o.A)(t,...s.g,"Uint8Array","JSON Web Key"))}},699:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createUtilityLogic=function(e,t,r){async function n(t){let r;try{r=await e.fetcher.load(t)}catch(r){if(404!==r.response.status){if(401===r.response.status)throw new c.UnauthorizedError;if(403===r.response.status){if((0,l.differentOrigin)(t))throw new c.CrossOriginForbiddenError;throw new c.SameOriginForbiddenError}const e="createIfNotExists doc load error NOT 404: "+t+": "+r;throw new c.FetchError(r.status,r.message+e)}try{await e.fetcher.webOperation("PUT",t,{data:"",contentType:"text/turtle"})}catch(e){const r="createIfNotExists: PUT FAILED: "+t+": "+e;throw new c.WebOperationError(r)}await e.fetcher.load(t)}return r}return{recursiveDelete:async function n(i){try{if(r.isContainer(i)){const o=await t.findAclDocUrl(i);await e.fetcher._fetch(o,{method:"DELETE"});const s=await r.getContainerMembers(i);await Promise.all(s.map(e=>n(e)))}const o=i.value;return e.fetcher._fetch(o,{method:"DELETE"})}catch(e){u.log(`Please manually remove ${i.value} from your system.`,e)}},setSinglePeerAccess:async function(r){let n=["@prefix acl: <http://www.w3.org/ns/auth/acl#>.","",`<#alice> a acl:Authorization;\n acl:agent <${r.ownerWebId}>;`,` acl:accessTo <${r.target}>;`,` acl:default <${r.target}>;`," acl:mode acl:Read, acl:Write, acl:Control.",""].join("\n");r.accessToModes&&(n+=["<#bobAccessTo> a acl:Authorization;",` acl:agent <${r.peerWebId}>;`,` acl:accessTo <${r.target}>;`,` acl:mode ${r.accessToModes}.`,""].join("\n")),r.defaultModes&&(n+=["<#bobDefault> a acl:Authorization;",` acl:agent <${r.peerWebId}>;`,` acl:default <${r.target}>;`,` acl:mode ${r.defaultModes}.`,""].join("\n"));const i=await t.findAclDocUrl((0,a.sym)(r.target));return e.fetcher._fetch(i,{method:"PUT",body:n,headers:[["Content-Type","text/turtle"]]})},createEmptyRdfDoc:async function(t,r){await e.fetcher.webOperation("PUT",t.uri,{data:`# ${new Date} ${r}\n `,contentType:"text/turtle"})},followOrCreateLink:async function(t,r,i,o){await e.fetcher.load(o);const s=e.any(t,r,null,o);if(s)return s;if(!e.updater.editable(o)){const e=`followOrCreateLink: cannot edit ${o.value}`;throw u.warn(e),new c.NotEditableError(e)}try{await e.updater.update([],[(0,a.st)(t,r,i,o)])}catch(e){const t=`followOrCreateLink: Error making link in ${o} to ${i}: ${e}`;throw u.warn(t),new c.WebOperationError(e)}try{await n(i)}catch(e){throw u.warn(`followOrCreateLink: Error loading or saving new linked document: ${i}: ${e}`),e}return i},loadOrCreateIfNotExists:n}};const a=r(4738),c=r(390),u=s(r(9378)),l=r(6848)},942:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createContainerLogic=function(e){function t(t){return e.statementsMatching(t,(0,n.sym)("http://www.w3.org/ns/ldp#contains"),void 0).map(e=>e.object)}function r(e){const t=e.value;return"/"===t.charAt(t.length-1)}return{isContainer:r,createContainer:async function(t){if(!r((0,n.sym)(t)))throw new Error(`Not a container URL ${t}`);const i=await e.fetcher._fetch(t,{method:"PUT",headers:{"Content-Type":"text/turtle","If-None-Match":"*",Link:'<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'},body:" "});if("2"!==i.status.toString()[0])throw new Error(`Not OK: got ${i.status} response while creating container at ${t}`)},getContainerElements:t,getContainerMembers:async function(r){return await e.fetcher.load(r),t(r)}}};const n=r(4738)},1020:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(7493);function i(e,t){const r=`SHA-${e.slice(-3)}`;switch(e){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:e.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:t.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:t.name};default:throw new n.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}},1177:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createTypeIndexLogic=function(e,t,r,n){const i=u.ns;async function o(t){if(!t)throw new Error("loadTypeIndexesFor: No user given");const o=await r.loadProfile(t),s=f(t);let a;try{a=await n.followOrCreateLink(t,i.solid("publicTypeIndex"),s,o)}catch(e){const r=`User ${t} has no pointer in profile to publicTypeIndex file.`;c.warn(r)}const u=a?[{label:"public",index:a,agent:t}]:[];let l,d;try{l=await r.silencedLoadPreferences(t)}catch(e){l=null}if(l){const r=p(l);let s;try{s=e.any(t,i.solid("privateTypeIndex"),void 0,o)||await n.followOrCreateLink(t,i.solid("privateTypeIndex"),r,l)}catch(e){const r=`User ${t} has no pointer in preference file to privateTypeIndex file.`;c.warn(r)}d=s?[{label:"private",index:s,agent:t}]:[]}else d=[];const h=u.concat(d);if(0===h.length)return h;const g=h.map(e=>e.index);try{await e.fetcher.load(g)}catch(e){c.warn("Problems loading type index: ",e)}return h}async function s(t){let n;try{n=await r.silencedLoadPreferences(t)}catch(e){const r=`User ${t} has no pointer in profile to preferences file.`;c.warn(r)}if(n){const r=e.each(t,i.solid("community"),void 0,n).concat(e.each(t,i.solid("community"),void 0,t.doc()));let s=[];for(const e of r)s=s.concat(await o(e));return s}return[]}async function d(e){return(await o(e)).concat((await s(e)).flat())}async function h(e,t){const r=await d(t);let n=[];for(const t of r){const r=await g(t,e);n=n.concat(r)}return n}function f(e){return(0,a.sym)(e.doc().dir()?.uri+"publicTypeIndex.ttl")}function p(e){return(0,a.sym)(e.doc().dir()?.uri+"privateTypeIndex.ttl")}async function g(t,r){const n=t.index,o=[],s=e.statementsMatching(null,i.solid("instance"),null,n).concat(e.statementsMatching(null,i.solid("instanceContainer"),null,n)).map(e=>e.subject);for(const c of s){const s=e.any(c,i.solid("forClass"),null,n);if(!r||s.sameTerm(r)){const r=e.each(c,i.solid("instance"),null,n);for(const e of r)o.push({instance:e,type:s,scope:t});const u=e.each(c,i.solid("instanceContainer"),null,n);for(const r of u)await e.fetcher.load(r),o.push({instance:(0,a.sym)(r.value),type:s,scope:t})}}return o}return{registerInTypeIndex:async function(t,r,n){const o=(0,l.newThing)(r),s=[(0,a.st)(o,i.rdf("type"),i.solid("TypeRegistration"),r),(0,a.st)(o,i.solid("forClass"),n,r),(0,a.st)(o,i.solid("instance"),t,r)];try{await e.updater.update([],s)}catch(e){const n=`Unable to register ${t} in index ${r}: ${e}`;return console.warn(n),null}return o},getRegistrations:function(t,r){return e.each(void 0,i.solid("instance"),t).filter(t=>e.holds(t,i.solid("forClass"),r))},loadTypeIndexesFor:o,loadCommunityTypeIndexes:s,loadAllTypeIndexes:d,getScopedAppInstances:h,getAppInstances:async function(e){const r=t.currentUser();if(!r)throw new Error("getAppInstances: Must be logged in to find apps.");return(await h(e,r)).map(e=>e.instance)},suggestPublicTypeIndex:f,suggestPrivateTypeIndex:p,deleteTypeIndexRegistration:async function(t){const r=e.the(null,i.solid("instance"),t.instance,t.scope.index);if(!r)throw new Error(`deleteTypeIndexRegistration: No registration found for ${t.instance}`);const n=e.statementsMatching(r,null,null,t.scope.index);await e.updater.update(n,[])},getScopedAppsFromIndex:g}};const a=r(4738),c=s(r(9378)),u=r(6118),l=r(6848)},1425:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateV1State=void 0;const n=r(2291),i=r(6011),o={};function s(e,t,r){return e.msecs??=-1/0,e.nsecs??=0,t===e.msecs?(e.nsecs++,e.nsecs>=1e4&&(e.node=void 0,e.nsecs=0)):t>e.msecs?e.nsecs=0:t<e.msecs&&(e.node=void 0),e.node||(e.node=r.slice(10,16),e.node[0]|=1,e.clockseq=16383&(r[8]<<8|r[9])),e.msecs=t,e}function a(e,t,r,n,i,o,s=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(o){if(s<0||s+16>o.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`)}else o=new Uint8Array(16),s=0;t??=Date.now(),r??=0,n??=16383&(e[8]<<8|e[9]),i??=e.slice(10,16);const a=(1e4*(268435455&(t+=122192928e5))+r)%4294967296;o[s++]=a>>>24&255,o[s++]=a>>>16&255,o[s++]=a>>>8&255,o[s++]=255&a;const c=t/4294967296*1e4&268435455;o[s++]=c>>>8&255,o[s++]=255&c,o[s++]=c>>>24&15|16,o[s++]=c>>>16&255,o[s++]=n>>>8|128,o[s++]=255&n;for(let e=0;e<6;++e)o[s++]=i[e];return o}t.updateV1State=s,t.default=function(e,t,r){let c;const u=e?._v6??!1;if(e){const t=Object.keys(e);1===t.length&&"_v6"===t[0]&&(e=void 0)}if(e)c=a(e.random??e.rng?.()??(0,n.default)(),e.msecs,e.nsecs,e.clockseq,e.node,t,r);else{const e=Date.now(),i=(0,n.default)();s(o,e,i),c=a(i,o.msecs,o.nsecs,u?void 0:o.clockseq,u?void 0:o.node,t,r)}return t??(0,i.unsafeStringify)(c)}},1436:(e,t,r)=>{r.d(t,{D4:()=>a,WG:()=>i,lF:()=>o,y4:()=>s});var n=r(1476);const i=e=>{let t=e;"string"==typeof t&&(t=n.Rd.encode(t));const r=[];for(let e=0;e<t.length;e+=32768)r.push(String.fromCharCode.apply(null,t.subarray(e,e+32768)));return btoa(r.join(""))},o=e=>i(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),s=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r},a=e=>{let t=e;t instanceof Uint8Array&&(t=n.D0.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return s(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}}},1476:(e,t,r)=>{r.d(t,{D0:()=>o,Kp:()=>h,MT:()=>c,Rd:()=>i,VS:()=>d,mx:()=>l,xW:()=>a,yI:()=>f});var n=r(610);const i=new TextEncoder,o=new TextDecoder,s=2**32;function a(...e){const t=e.reduce((e,{length:t})=>e+t,0),r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}function c(e,t){return a(i.encode(e),new Uint8Array([0]),t)}function u(e,t,r){if(t<0||t>=s)throw new RangeError(`value must be >= 0 and <= ${s-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,255&t],r)}function l(e){const t=Math.floor(e/s),r=e%s,n=new Uint8Array(8);return u(n,t,0),u(n,r,4),n}function d(e){const t=new Uint8Array(4);return u(t,e),t}function h(e){return a(d(e.length),e)}async function f(e,t,r){const i=Math.ceil((t>>3)/32),o=new Uint8Array(32*i);for(let t=0;t<i;t++){const i=new Uint8Array(4+e.length+r.length);i.set(d(t+1)),i.set(e,4),i.set(r,4+e.length),o.set(await(0,n.A)("sha256",i),32*t)}return o.slice(0,t>>3)}},1542:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(7991),i=r(7493);const o=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=function(e){let t,r;switch(e.kty){case"RSA":switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"EC":switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;case"OKP":switch(e.alg){case"Ed25519":t={name:"Ed25519"},r=e.d?["sign"]:["verify"];break;case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}(e),o=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,n.A.subtle.importKey("jwk",s,...o)}},1575:(e,t,r)=>{function n(e,t,...r){if((r=r.filter(Boolean)).length>2){const t=r.pop();e+=`one of type ${r.join(", ")}, or ${t}.`}else 2===r.length?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return null==t?e+=` Received ${t}`:"function"==typeof t&&t.name?e+=` Received function ${t.name}`:"object"==typeof t&&null!=t&&t.constructor?.name&&(e+=` Received an instance of ${t.constructor.name}`),e}r.d(t,{A:()=>i,t:()=>o});const i=(e,...t)=>n("Key must be ",e,...t);function o(e,t,...r){return n(`Key for the ${e} algorithm must be `,t,...r)}},1781:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.solidLogicSingleton=void 0;const a=s(r(9378)),c=r(9095),u=(0,r(2262).createSolidLogic)({fetch:async(e,t)=>{const r=t&&t.credentials&&"omit"==t.credentials;return c.authSession.info.webId&&!r?c.authSession.fetch(e,t):window.fetch(e,t)}},c.authSession);t.solidLogicSingleton=u,a.log("Unique quadstore initialized.")},1797:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(9746);t.default=function(e){if(!(0,n.default)(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,255&t,(t=parseInt(e.slice(9,13),16))>>>8,255&t,(t=parseInt(e.slice(14,18),16))>>>8,255&t,(t=parseInt(e.slice(19,23),16))>>>8,255&t,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,255&t)}},2168:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(7493);const i=function(e,t,r,i,o){if(void 0!==o.crit&&void 0===i?.crit)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!i||void 0===i.crit)return new Set;if(!Array.isArray(i.crit)||0===i.crit.length||i.crit.some(e=>"string"!=typeof e||0===e.length))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let s;s=void 0!==r?new Map([...Object.entries(r),...t.entries()]):t;for(const t of i.crit){if(!s.has(t))throw new n.JOSENotSupported(`Extension Header Parameter "${t}" is not recognized`);if(void 0===o[t])throw new e(`Extension Header Parameter "${t}" is missing`);if(s.get(t)&&void 0===i[t])throw new e(`Extension Header Parameter "${t}" MUST be integrity protected`)}return new Set(i.crit)}},2196:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default="ffffffff-ffff-ffff-ffff-ffffffffffff"},2222:(e,t,r)=>{r.d(t,{A:()=>n});const n=e=>Math.floor(e.getTime()/1e3)},2233:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.appContext=void 0,t.offlineTestID=function(){const{$SolidTestEnvironment:e}=window;if(void 0!==e&&e.username)return c.log("Assuming the user is "+e.username),(0,a.sym)(e.username);if("undefined"!=typeof document&&document.location&&"http://localhost"===(""+document.location).slice(0,16)){const e=document.getElementById("appTarget");if(!e)return null;const t=e.getAttribute("testID");return t?(c.log("Assuming user is "+t),(0,a.sym)(t)):null}return null};const a=r(4738),c=s(r(9378));t.appContext=()=>{let{SolidAppContext:e}=window;if(e||={},e.viewingNoAuthPage=!1,e.noAuth&&window.document){if(window.document.location.href.startsWith(e.noAuth)){e.viewingNoAuthPage=!0;const t=new URLSearchParams(window.document.location.search);if(t){let r=e.viewedPage=t.get("uri")||null;if(r&&(r=decodeURI(r),!r.startsWith(e.noAuth))){const t=r.split(/\//);e.idp=t[0]+"//"+t[2],e.viewingNoAuthPage=!1}}}}return e}},2262:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createSolidLogic=function(e,t){y.log("SolidLogic: Unique instance created. There should only be one of these.");const r=a.graph();a.fetcher(r,{fetch:e.fetch}),r.updater=new a.UpdateManager(r),r.features=[];const n=new u.SolidAuthnLogic(t),i=(0,c.createAclLogic)(r),o=(0,p.createContainerLogic)(r),s=(0,g.createUtilityLogic)(r,i,o),v=(0,h.createProfileLogic)(r,n,s),m=(0,l.createChatLogic)(r,v),w=(0,d.createInboxLogic)(r,v,s,o,i),S=(0,f.createTypeIndexLogic)(r,n,v,s);return y.log("SolidAuthnLogic initialized"),{store:r,authn:n,acl:i,inbox:w,chat:m,profile:v,typeIndex:S,load:function(e){return r.fetcher.load(e)},updatePromise:function(e,t=[]){return new Promise((n,i)=>{r.updater.update(e,t,function(e,t,r){t?n():i(new Error(r))})})},clearStore:function(){r.statements.slice().forEach(r.remove.bind(r))}}};const a=s(r(4738)),c=r(6769),u=r(4746),l=r(3091),d=r(7813),h=r(3029),f=r(1177),p=r(942),g=r(699),y=s(r(9378))},2291:(e,t)=>{let r;Object.defineProperty(t,"__esModule",{value:!0});const n=new Uint8Array(16);t.default=function(){if(!r){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(n)}},2452:(e,t,r)=>{var n=r(4667),i=r(182),o=r(7007),s=r(8134);class a extends n.StorageUtility{constructor(e,t){super(e,t)}}class c extends n.ClientAuthentication{login=async(e,t)=>{"none"!==e.prompt&&await this.sessionInfoManager.clear(e.sessionId);const r=e.redirectUrl??s.normalizeCallbackUrl(window.location.href);if(!n.isValidRedirectUrl(r))throw new Error(`${r} is not a valid redirect URL, it is either a malformed IRI, includes a hash fragment, or reserved query parameters ('code' or 'state').`);await this.loginHandler.handle({...e,redirectUrl:r,clientName:e.clientName??e.clientId,eventEmitter:t})};validateCurrentSession=async e=>{const t=await this.sessionInfoManager.get(e);return void 0===t||void 0===t.clientAppId||void 0===t.issuer?null:t};handleIncomingRedirect=async(e,t)=>{try{const r=await this.redirectHandler.handle(e,t,void 0);return this.fetch=r.fetch.bind(window),this.boundLogout=r.getLogoutUrl,await this.cleanUrlAfterRedirect(e),{isLoggedIn:r.isLoggedIn,webId:r.webId,sessionId:r.sessionId,expirationDate:r.expirationDate,clientAppId:r.clientAppId}}catch(r){return await this.cleanUrlAfterRedirect(e),void t.emit(n.EVENTS.ERROR,"redirect",r)}};async cleanUrlAfterRedirect(e){const t=n.removeOpenIdParams(e).href;for(window.history.replaceState(null,"",t);window.location.href!==t;)await new Promise(e=>{setTimeout(()=>e(),1)})}}function u(e){return"string"==typeof e.oidcIssuer}function l(e){return"string"==typeof e.redirectUrl}class d{storageUtility;oidcHandler;issuerConfigFetcher;clientRegistrar;constructor(e,t,r,n){this.storageUtility=e,this.oidcHandler=t,this.issuerConfigFetcher=r,this.clientRegistrar=n,this.storageUtility=e,this.oidcHandler=t,this.issuerConfigFetcher=r,this.clientRegistrar=n}async canHandle(e){return u(e)&&l(e)}async handle(e){if(!u(e))throw new n.ConfigurationError(`OidcLoginHandler requires an OIDC issuer: missing property 'oidcIssuer' in ${JSON.stringify(e)}`);if(!l(e))throw new n.ConfigurationError(`OidcLoginHandler requires a redirect URL: missing property 'redirectUrl' in ${JSON.stringify(e)}`);const t=await this.issuerConfigFetcher.fetchConfig(e.oidcIssuer),r=await n.handleRegistration(e,t,this.storageUtility,this.clientRegistrar),i={issuer:t.issuer,dpop:"dpop"===e.tokenType.toLowerCase(),...e,issuerConfiguration:t,client:r,scopes:n.normalizeScopes(e.customScopes)};return this.oidcHandler.handle(i)}}class h extends n.AuthorizationCodeWithPkceOidcHandlerBase{async handle(e){const t={authority:e.issuer.toString(),client_id:e.client.clientId,client_secret:e.client.clientSecret,redirect_uri:e.redirectUrl,response_type:"code",scope:e.scopes.join(" "),filterProtocolClaims:!0,loadUserInfo:!1,code_verifier:!0,prompt:e.prompt??"consent"},r=new s.OidcClient(t);try{const t=await r.createSigninRequest();return await this.setupRedirectHandler({oidcLoginOptions:e,state:t.state._id,codeVerifier:t.state._code_verifier,targetUrl:t.url.toString()})}catch(e){console.error(e)}}}const f={issuer:{toKey:"issuer",convertToUrl:!0},authorization_endpoint:{toKey:"authorizationEndpoint",convertToUrl:!0},token_endpoint:{toKey:"tokenEndpoint",convertToUrl:!0},userinfo_endpoint:{toKey:"userinfoEndpoint",convertToUrl:!0},jwks_uri:{toKey:"jwksUri",convertToUrl:!0},registration_endpoint:{toKey:"registrationEndpoint",convertToUrl:!0},end_session_endpoint:{toKey:"endSessionEndpoint",convertToUrl:!0},scopes_supported:{toKey:"scopesSupported"},response_types_supported:{toKey:"responseTypesSupported"},response_modes_supported:{toKey:"responseModesSupported"},grant_types_supported:{toKey:"grantTypesSupported"},acr_values_supported:{toKey:"acrValuesSupported"},subject_types_supported:{toKey:"subjectTypesSupported"},id_token_signing_alg_values_supported:{toKey:"idTokenSigningAlgValuesSupported"},id_token_encryption_alg_values_supported:{toKey:"idTokenEncryptionAlgValuesSupported"},id_token_encryption_enc_values_supported:{toKey:"idTokenEncryptionEncValuesSupported"},userinfo_signing_alg_values_supported:{toKey:"userinfoSigningAlgValuesSupported"},userinfo_encryption_alg_values_supported:{toKey:"userinfoEncryptionAlgValuesSupported"},userinfo_encryption_enc_values_supported:{toKey:"userinfoEncryptionEncValuesSupported"},request_object_signing_alg_values_supported:{toKey:"requestObjectSigningAlgValuesSupported"},request_object_encryption_alg_values_supported:{toKey:"requestObjectEncryptionAlgValuesSupported"},request_object_encryption_enc_values_supported:{toKey:"requestObjectEncryptionEncValuesSupported"},token_endpoint_auth_methods_supported:{toKey:"tokenEndpointAuthMethodsSupported"},token_endpoint_auth_signing_alg_values_supported:{toKey:"tokenEndpointAuthSigningAlgValuesSupported"},display_values_supported:{toKey:"displayValuesSupported"},claim_types_supported:{toKey:"claimTypesSupported"},claims_supported:{toKey:"claimsSupported"},service_documentation:{toKey:"serviceDocumentation"},claims_locales_supported:{toKey:"claimsLocalesSupported"},ui_locales_supported:{toKey:"uiLocalesSupported"},claims_parameter_supported:{toKey:"claimsParameterSupported"},request_parameter_supported:{toKey:"requestParameterSupported"},request_uri_parameter_supported:{toKey:"requestUriParameterSupported"},require_request_uri_registration:{toKey:"requireRequestUriRegistration"},op_policy_uri:{toKey:"opPolicyUri",convertToUrl:!0},op_tos_uri:{toKey:"opTosUri",convertToUrl:!0}};class p{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}static getLocalStorageKey(e){return`issuerConfig:${e}`}async fetchConfig(e){let t;const r=new URL(".well-known/openid-configuration",e.endsWith("/")?e:`${e}/`).href,i=await fetch(r);try{t=function(e){const t={};return Object.keys(e).forEach(r=>{f[r]&&(t[f[r].toKey]=e[r])}),Array.isArray(t.scopesSupported)||(t.scopesSupported=["openid"]),t}(await i.json())}catch(t){throw new n.ConfigurationError(`[${e.toString()}] has an invalid configuration: ${t.message}`)}return await this.storageUtility.set(p.getLocalStorageKey(e),JSON.stringify(t)),t}}class g extends n.SessionInfoManagerBase{async get(e){const[t,r,i,o,s,a,c,u]=await Promise.all([this.storageUtility.getForUser(e,"isLoggedIn",{secure:!0}),this.storageUtility.getForUser(e,"webId",{secure:!0}),this.storageUtility.getForUser(e,"clientId",{secure:!1}),this.storageUtility.getForUser(e,"clientSecret",{secure:!1}),this.storageUtility.getForUser(e,"redirectUrl",{secure:!1}),this.storageUtility.getForUser(e,"refreshToken",{secure:!0}),this.storageUtility.getForUser(e,"issuer",{secure:!1}),this.storageUtility.getForUser(e,"tokenType",{secure:!1})]);if("string"!=typeof s||n.isValidRedirectUrl(s)){if(void 0!==u&&!n.isSupportedTokenType(u))throw new Error(`Tokens of type [${u}] are not supported.`);if(void 0!==i||void 0!==t||void 0!==r||void 0!==a)return{sessionId:e,webId:r,isLoggedIn:"true"===t,redirectUrl:s,refreshToken:a,issuer:c,clientAppId:i,clientAppSecret:o,tokenType:u??"DPoP"}}else await Promise.all([this.storageUtility.deleteAllUserData(e,{secure:!1}),this.storageUtility.deleteAllUserData(e,{secure:!0})])}async clear(e){return async function(e,t){await n.clear(e,t),await s.clearOidcPersistentStorage()}(e,this.storageUtility)}}class y{async canHandle(e){try{return new URL(e),!0}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e){return n.getUnauthenticatedSession()}}class v{storageUtility;sessionInfoManager;issuerConfigFetcher;clientRegistrar;tokerRefresher;constructor(e,t,r,n,i){this.storageUtility=e,this.sessionInfoManager=t,this.issuerConfigFetcher=r,this.clientRegistrar=n,this.tokerRefresher=i,this.storageUtility=e,this.sessionInfoManager=t,this.issuerConfigFetcher=r,this.clientRegistrar=n,this.tokerRefresher=i}async canHandle(e){try{const t=new URL(e);return null!==t.searchParams.get("code")&&null!==t.searchParams.get("state")}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e,t){if(!await this.canHandle(e))throw new Error(`AuthCodeRedirectHandler cannot handle [${e}]: it is missing one of [code, state].`);const r=new URL(e),i=r.searchParams.get("state"),o=await this.storageUtility.getForUser(i,"sessionId",{errorIfNull:!0}),{issuerConfig:a,codeVerifier:c,redirectUrl:u,dpop:l}=await n.loadOidcContextFromStorage(o,this.storageUtility,this.issuerConfigFetcher),d=r.searchParams.get("iss");if("string"==typeof d&&d!==a.issuer)throw new Error(`The value of the iss parameter (${d}) does not match the issuer identifier of the authorization server (${a.issuer}). See [rfc9207](https://www.rfc-editor.org/rfc/rfc9207.html#section-2.3-3.1.1)`);if(void 0===c)throw new Error(`The code verifier for session ${o} is missing from storage.`);if(void 0===u)throw new Error(`The redirect URL for session ${o} is missing from storage.`);const h=await this.clientRegistrar.getClient({sessionId:o},a),f=Date.now(),p=await s.getTokens(a,h,{grantType:"authorization_code",code:r.searchParams.get("code"),codeVerifier:c,redirectUrl:u},l);let g;window.localStorage.removeItem(`oidc.${i}`),void 0!==p.refreshToken&&(g={sessionId:o,refreshToken:p.refreshToken,tokenRefresher:this.tokerRefresher});const y=n.buildAuthenticatedFetch(p.accessToken,{dpopKey:p.dpopKey,refreshOptions:g,eventEmitter:t,expiresIn:p.expiresIn});await n.saveSessionInfoToStorage(this.storageUtility,o,p.webId,p.clientId,"true",void 0,!0);const v=await this.sessionInfoManager.get(o);if(!v)throw new Error(`Could not retrieve session: [${o}].`);return Object.assign(v,{fetch:y,getLogoutUrl:n.maybeBuildRpInitiatedLogout({idTokenHint:p.idToken,endSessionEndpoint:a.endSessionEndpoint}),expirationDate:"number"==typeof p.expiresIn?f+1e3*p.expiresIn:void 0})}}class m extends n.AggregateHandler{constructor(e){super(e)}}class w{get storage(){return window.localStorage}async get(e){return this.storage.getItem(e)||void 0}async set(e,t){this.storage.setItem(e,t)}async delete(e){this.storage.removeItem(e)}}class S{redirect(e,t){t&&t.handleRedirect?t.handleRedirect(e):t&&t.redirectByReplacingState?window.history.replaceState({},"",e):window.location.href=e}}class _{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}async getClient(e,t){const[r,i,o,a,c]=await Promise.all([this.storageUtility.getForUser(e.sessionId,"clientId",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientSecret",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"expiresAt",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientName",{secure:!1}),this.storageUtility.getForUser(e.sessionId,"clientType",{secure:!1})]),u=void 0!==o?Number.parseInt(o,10):-1,l=void 0!==i&&0!==u&&Math.floor(Date.now()/1e3)>u;if(r&&n.isKnownClientType(c)&&!l)return void 0!==i?{clientId:r,clientSecret:i,clientName:a,clientType:"dynamic",expiresAt:u}:{clientId:r,clientName:a,clientType:c};try{const r=await s.registerClient(e,t),n={clientId:r.clientId,clientType:"dynamic"};return void 0!==r.clientSecret&&(n.clientSecret=r.clientSecret,n.expiresAt=String(r.expiresAt)),r.idTokenSignedResponseAlg&&(n.idTokenSignedResponseAlg=r.idTokenSignedResponseAlg),await this.storageUtility.setForUser(e.sessionId,n,{secure:!1}),r}catch(e){throw new Error("Client registration failed.",{cause:e})}}}class b{async canHandle(e){try{return new URL(e).searchParams.has("error")}catch(t){throw new Error(`[${e}] is not a valid URL, and cannot be used as a redirect URL: ${t}`)}}async handle(e,t){if(void 0!==t){const r=new URL(e),i=r.searchParams.get("error"),o=r.searchParams.get("error_description");t.emit(n.EVENTS.ERROR,i,o)}return n.getUnauthenticatedSession()}}class E{storageUtility;issuerConfigFetcher;clientRegistrar;constructor(e,t,r){this.storageUtility=e,this.issuerConfigFetcher=t,this.clientRegistrar=r,this.storageUtility=e,this.issuerConfigFetcher=t,this.clientRegistrar=r}async refresh(e,t,r,i){const o=await n.loadOidcContextFromStorage(e,this.storageUtility,this.issuerConfigFetcher),a=await this.clientRegistrar.getClient({sessionId:e},o.issuerConfig);if(void 0===t)throw new Error(`Session [${e}] has no refresh token to allow it to refresh its access token.`);if(o.dpop&&void 0===r)throw new Error(`For session [${e}], the key bound to the DPoP access token must be provided to refresh said access token.`);const c=await s.refresh(t,o.issuerConfig,a,r);return void 0!==c.refreshToken&&i?.emit(n.EVENTS.NEW_REFRESH_TOKEN,c.refreshToken),c}}function A(e){const t=new n.InMemoryStorage,r=e.secureStorage||t,i=e.insecureStorage||new w,o=new a(r,i),s=new p(o),u=new _(o),l=new g(o),f=new E(o,s,u),A=new S,F=new d(o,new h(o,A),s,u),P=new m([new b,new v(o,l,s,u,f),new y]);return new c(F,P,new n.IWaterfallLogoutHandler(l,A),l,s)}const F=`${n.SOLID_CLIENT_AUTHN_KEY_PREFIX}currentSession`,P=`${n.SOLID_CLIENT_AUTHN_KEY_PREFIX}currentUrl`;class k{info;events;clientAuthentication;tokenRequestInProgress=!1;constructor(e={},t=void 0){this.events=new o,e.clientAuthentication?this.clientAuthentication=e.clientAuthentication:e.secureStorage&&e.insecureStorage?this.clientAuthentication=A({secureStorage:e.secureStorage,insecureStorage:e.insecureStorage}):this.clientAuthentication=A({}),e.sessionInfo?this.info={sessionId:e.sessionInfo.sessionId,isLoggedIn:!1,webId:e.sessionInfo.webId,clientAppId:e.sessionInfo.clientAppId}:this.info={sessionId:t??i.v4(),isLoggedIn:!1},this.events.on(n.EVENTS.LOGIN,()=>window.localStorage.setItem(F,this.info.sessionId)),this.events.on(n.EVENTS.SESSION_EXPIRED,()=>this.internalLogout(!1)),this.events.on(n.EVENTS.ERROR,()=>this.internalLogout(!1))}login=async e=>(await this.clientAuthentication.login({sessionId:this.info.sessionId,...e,tokenType:e.tokenType??"DPoP"},this.events),new Promise(()=>{}));fetch=(e,t)=>this.clientAuthentication.fetch(e,t);internalLogout=async(e,t)=>{window.localStorage.removeItem(F),await this.clientAuthentication.logout(this.info.sessionId,t),this.info.isLoggedIn=!1,e&&this.events.emit(n.EVENTS.LOGOUT)};logout=async e=>this.internalLogout(!0,e);handleIncomingRedirect=async(e={})=>{if(this.info.isLoggedIn)return this.info;if(this.tokenRequestInProgress)return;const t="string"==typeof e?{url:e}:e,r=t.url??window.location.href;this.tokenRequestInProgress=!0;const i=await this.clientAuthentication.handleIncomingRedirect(r,this.events);if(function(e){return!!e?.isLoggedIn}(i)){this.setSessionInfo(i);const e=window.localStorage.getItem(P);null===e?this.events.emit(n.EVENTS.LOGIN):(window.localStorage.removeItem(P),this.events.emit(n.EVENTS.SESSION_RESTORED,e))}else if(!0===t.restorePreviousSession){const e=window.localStorage.getItem(F);if(null!==e){if(await async function(e,t,r){const n=await t.validateCurrentSession(e);return null!==n&&(window.localStorage.setItem(P,window.location.href),await t.login({sessionId:e,prompt:"none",oidcIssuer:n.issuer,redirectUrl:n.redirectUrl,clientId:n.clientAppId,clientSecret:n.clientAppSecret,tokenType:n.tokenType??"DPoP"},r.events),!0)}(e,this.clientAuthentication,this))return new Promise(()=>{})}}return this.tokenRequestInProgress=!1,i};setSessionInfo(e){this.info.isLoggedIn=e.isLoggedIn,this.info.webId=e.webId,this.info.sessionId=e.sessionId,this.info.clientAppId=e.clientAppId,this.info.expirationDate=e.expirationDate,this.events.on(n.EVENTS.SESSION_EXTENDED,e=>{this.info.expirationDate=Date.now()+1e3*e})}}let I;function x(){return void 0===I&&(I=new k),I}Object.defineProperty(t,"ConfigurationError",{enumerable:!0,get:function(){return n.ConfigurationError}}),Object.defineProperty(t,"EVENTS",{enumerable:!0,get:function(){return n.EVENTS}}),Object.defineProperty(t,"InMemoryStorage",{enumerable:!0,get:function(){return n.InMemoryStorage}}),Object.defineProperty(t,"NotImplementedError",{enumerable:!0,get:function(){return n.NotImplementedError}}),t.Session=k,t.events=()=>x().events,t.fetch=(...e)=>x().fetch(...e),t.getDefaultSession=x,t.handleIncomingRedirect=(...e)=>x().handleIncomingRedirect(...e),t.login=(...e)=>x().login(...e),t.logout=(...e)=>x().logout(...e)},2609:(e,t,r)=>{r.d(t,{T:()=>i});var n=r(5550);class i{constructor(e){this._flattened=new n.n(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,t){const r=await this._flattened.sign(e,t);if(void 0===r.payload)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${r.protected}.${r.payload}.${r.signature}`}}},2698:(e,t,r)=>{function n(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function i(e,t){return e.name===t}function o(e){return parseInt(e.name.slice(4),10)}function s(e,t){if(t.length&&!t.some(t=>e.usages.includes(t))){let e="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const r=t.pop();e+=`one of ${t.join(", ")}, or ${r}.`}else 2===t.length?e+=`one of ${t[0]} or ${t[1]}.`:e+=`${t[0]}.`;throw new TypeError(e)}}function a(e,t,...r){switch(t){case"HS256":case"HS384":case"HS512":{if(!i(e.algorithm,"HMAC"))throw n("HMAC");const r=parseInt(t.slice(2),10);if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!i(e.algorithm,"RSASSA-PKCS1-v1_5"))throw n("RSASSA-PKCS1-v1_5");const r=parseInt(t.slice(2),10);if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!i(e.algorithm,"RSA-PSS"))throw n("RSA-PSS");const r=parseInt(t.slice(2),10);if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}case"EdDSA":if("Ed25519"!==e.algorithm.name&&"Ed448"!==e.algorithm.name)throw n("Ed25519 or Ed448");break;case"Ed25519":if(!i(e.algorithm,"Ed25519"))throw n("Ed25519");break;case"ES256":case"ES384":case"ES512":{if(!i(e.algorithm,"ECDSA"))throw n("ECDSA");const r=function(e){switch(e){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}(t);if(e.algorithm.namedCurve!==r)throw n(r,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}s(e,r)}function c(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!i(e.algorithm,"AES-GCM"))throw n("AES-GCM");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw n(r,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!i(e.algorithm,"AES-KW"))throw n("AES-KW");const r=parseInt(t.slice(1,4),10);if(e.algorithm.length!==r)throw n(r,"algorithm.length");break}case"ECDH":switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw n("ECDH, X25519, or X448")}break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!i(e.algorithm,"PBKDF2"))throw n("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!i(e.algorithm,"RSA-OAEP"))throw n("RSA-OAEP");const r=parseInt(t.slice(9),10)||1;if(o(e.algorithm.hash)!==r)throw n(`SHA-${r}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}s(e,r)}r.d(t,{$:()=>c,Y:()=>a})},2770:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(9746);t.default=function(e){if(!(0,n.default)(e))throw TypeError("Invalid UUID");return parseInt(e.slice(14,15),16)}},2829:(e,t)=>{function r(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:case 3:return t^r^n;case 2:return t&r^t&n^r&n}}function n(e,t){return e<<t|e>>>32-t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){const t=[1518500249,1859775393,2400959708,3395469782],i=[1732584193,4023233417,2562383102,271733878,3285377520],o=new Uint8Array(e.length+1);o.set(e),o[e.length]=128;const s=(e=o).length/4+2,a=Math.ceil(s/16),c=new Array(a);for(let t=0;t<a;++t){const r=new Uint32Array(16);for(let n=0;n<16;++n)r[n]=e[64*t+4*n]<<24|e[64*t+4*n+1]<<16|e[64*t+4*n+2]<<8|e[64*t+4*n+3];c[t]=r}c[a-1][14]=8*(e.length-1)/Math.pow(2,32),c[a-1][14]=Math.floor(c[a-1][14]),c[a-1][15]=8*(e.length-1)&4294967295;for(let e=0;e<a;++e){const o=new Uint32Array(80);for(let t=0;t<16;++t)o[t]=c[e][t];for(let e=16;e<80;++e)o[e]=n(o[e-3]^o[e-8]^o[e-14]^o[e-16],1);let s=i[0],a=i[1],u=i[2],l=i[3],d=i[4];for(let e=0;e<80;++e){const i=Math.floor(e/20),c=n(s,5)+r(i,a,u,l)+d+t[i]+o[e]>>>0;d=l,l=u,u=n(a,30)>>>0,a=s,s=c}i[0]=i[0]+s>>>0,i[1]=i[1]+a>>>0,i[2]=i[2]+u>>>0,i[3]=i[3]+l>>>0,i[4]=i[4]+d>>>0}return Uint8Array.of(i[0]>>24,i[0]>>16,i[0]>>8,i[0],i[1]>>24,i[1]>>16,i[1]>>8,i[1],i[2]>>24,i[2]>>16,i[2]>>8,i[2],i[3]>>24,i[3]>>16,i[3]>>8,i[3],i[4]>>24,i[4]>>16,i[4]>>8,i[4])}},2988:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=t.stringToBytes=void 0;const n=r(1797),i=r(6011);function o(e){e=unescape(encodeURIComponent(e));const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}t.stringToBytes=o,t.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",t.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",t.default=function(e,t,r,s,a,c){const u="string"==typeof r?o(r):r,l="string"==typeof s?(0,n.default)(s):s;if("string"==typeof s&&(s=(0,n.default)(s)),16!==s?.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let d=new Uint8Array(16+u.length);if(d.set(l),d.set(u,l.length),d=t(d),d[6]=15&d[6]|e,d[8]=63&d[8]|128,a){c=c||0;for(let e=0;e<16;++e)a[c+e]=d[e];return a}return(0,i.unsafeStringify)(d)}},3029:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.createProfileLogic=function(e,t,r){const n=u.ns;async function i(t){await o(t);const i=(0,l.suggestPreferencesFile)(t);let s;try{s=await r.followOrCreateLink(t,n.space("preferencesFile"),i,t.doc())}catch(e){const r=`User ${t} has no pointer in profile to preferences file.`;if(c.warn(r),e instanceof a.NotEditableError)throw e;if(e instanceof a.WebOperationError)throw e;if(e instanceof a.UnauthorizedError)throw e;if(e instanceof a.CrossOriginForbiddenError)throw e;if(e instanceof a.SameOriginForbiddenError)throw e;if(e instanceof a.FetchError)throw e;throw e}try{await e.fetcher.load(s)}catch(e){const r=`Unable to load preference of user ${t}: ${e}`;if(c.warn(r),401===e.response.status)throw new a.UnauthorizedError;if(403===e.response.status){if((0,l.differentOrigin)(s))throw new a.CrossOriginForbiddenError;throw new a.SameOriginForbiddenError}throw new Error(r)}return s}async function o(t){if(!t)throw new Error("loadProfile: no user given.");try{await e.fetcher.load(t.doc())}catch(e){throw new Error(`Unable to load profile of user ${t}: ${e}`)}return t.doc()}function s(t){return e.any(t,n.space("storage"),void 0,t.doc())}return{loadMe:async function(){const r=t.currentUser();if(null===r)throw new Error("Current user not found! Not logged in?");return await e.fetcher.load(r.doc()),r},getPodRoot:function(e){const t=s(e);if(!t)throw new Error("User pod root not found!");return t},getMainInbox:async function(t){await e.fetcher.load(t);const r=e.any(t,n.ldp("inbox"),void 0,t.doc());if(!r)throw new Error("User main inbox not found!");return r},findStorage:s,loadPreferences:i,loadProfile:o,silencedLoadPreferences:async function(e){try{return await i(e)}catch(e){return}}}};const a=r(390),c=s(r(9378)),u=r(6118),l=r(6848)},3085:(e,t,r)=>{r.d(t,{G:()=>a});var n=r(2222),i=r(149),o=r(6957);function s(e,t){if(!Number.isFinite(t))throw new TypeError(`Invalid ${e} input`);return t}class a{constructor(e={}){if(!(0,i.A)(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return"number"==typeof e?this._payload={...this._payload,nbf:s("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:s("setNotBefore",(0,n.A)(e))}:this._payload={...this._payload,nbf:(0,n.A)(new Date)+(0,o.A)(e)},this}setExpirationTime(e){return"number"==typeof e?this._payload={...this._payload,exp:s("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:s("setExpirationTime",(0,n.A)(e))}:this._payload={...this._payload,exp:(0,n.A)(new Date)+(0,o.A)(e)},this}setIssuedAt(e){return void 0===e?this._payload={...this._payload,iat:(0,n.A)(new Date)}:e instanceof Date?this._payload={...this._payload,iat:s("setIssuedAt",(0,n.A)(e))}:this._payload="string"==typeof e?{...this._payload,iat:s("setIssuedAt",(0,n.A)(new Date)+(0,o.A)(e))}:{...this._payload,iat:s("setIssuedAt",e)},this}}},3091:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createChatLogic=function(e,t){const r=i.ns;async function a(t,r,i){await e.fetcher.load(t);const o=e.any(t,new n.NamedNode("http://www.iana.org/assignments/link-relations/acl"));if(!o)throw new Error("Chat ACL doc not found!");const s=`\n @prefix acl: <http://www.w3.org/ns/auth/acl#>.\n <#owner>\n a acl:Authorization;\n acl:agent <${r.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Write, acl:Control.\n <#invitee>\n a acl:Authorization;\n acl:agent <${i.value}>;\n acl:accessTo <.>;\n acl:default <.>;\n acl:mode\n acl:Read, acl:Append.\n `;await e.fetcher.webOperation("PUT",o.value,{data:s,contentType:"text/turtle"})}async function c(t,i){const s=e.any(i,r.solid("privateTypeIndex"));if(!s)throw new Error("Private type index not found!");await e.fetcher.load(s);const a=(0,o.newThing)(s),c=[(0,n.st)(a,r.rdf("type"),r.solid("TypeRegistration"),s.doc()),(0,n.st)(a,r.solid("forClass"),r.meeting("LongChat"),s.doc()),(0,n.st)(a,r.solid("instance"),t,s.doc())];await new Promise((t,r)=>{e.updater.update([],c,function(e,n,i){n?t(null):r(new Error(i))})})}async function u(r){const i=await t.loadMe(),s=await t.getPodRoot(i),a=(0,o.determineChatContainer)(r,s);let c=!0;try{await e.fetcher.load(new n.NamedNode(a.value+"index.ttl#this"))}catch(e){c=!1}return{me:i,chatContainer:a,exists:c}}async function l(e,t){return(await d({me:t,newBase:e.value})).newInstance}function d(t){const i=e,o=i.updater;if(t.me&&!t.me.uri)throw new Error("chat mintNew: Invalid userid "+t.me);const a=t.newInstance=t.newInstance||i.sym(t.newBase+s),c=a.doc();return i.add(a,r.rdf("type"),r.meeting("LongChat"),c),i.add(a,r.dc("title"),"Chat channel",c),i.add(a,r.dc("created"),(0,n.term)(new Date(Date.now())),c),t.me&&i.add(a,r.dc("author"),t.me,c),new Promise(function(e,r){o?.put(c,i.statementsMatching(void 0,void 0,void 0,c),"text/turtle",function(n,i,o){i?e({...t,newInstance:a}):r(new Error("FAILED to save new chat channel at: "+n+" : "+o))})})}async function h(t,n){await e.fetcher.load(t.doc());const i=e.any(t,r.ldp("inbox"),void 0,t.doc());if(!i)throw new Error(`Invitee inbox not found! ${t.value}`);const o=`\n <> a <http://www.w3.org/ns/pim/meeting#LongChatInvite> ;\n ${r.rdf("seeAlso")} <${n.value}> .\n `,s=await(e.fetcher?.webOperation("POST",i.value,{data:o,contentType:"text/turtle"})),a=s?.headers.get("location");if(!a)throw new Error(`Invite sending returned a ${s?.status}`)}return{setAcl:a,addToPrivateTypeIndex:c,findChat:u,createChatThing:l,getChat:async function(e,t=!0){const{me:r,chatContainer:i,exists:o}=await u(e);if(o)return new n.NamedNode(i.value+s);if(t){const t=await l(i,r);return await h(e,t),await a(i,r,e),await c(t,r),t}return null},sendInvite:h,mintNew:d}};const n=r(4738),i=r(6118),o=r(6848),s="index.ttl#this"},3121:(e,t,r)=>{r.d(t,{CompactEncrypt:()=>Q,CompactSign:()=>ee.T,EmbeddedJWK:()=>de,EncryptJWT:()=>se,FlattenedEncrypt:()=>J,FlattenedSign:()=>te.n,GeneralEncrypt:()=>q,GeneralSign:()=>ne,SignJWT:()=>ie.P,UnsecuredJWT:()=>pe,base64url:()=>n,calculateJwkThumbprint:()=>ue,calculateJwkThumbprintUri:()=>le,compactDecrypt:()=>j,compactVerify:()=>$.B,createLocalJWKSet:()=>he.w,createRemoteJWKSet:()=>fe.RD,cryptoRuntime:()=>be,decodeJwt:()=>me,decodeProtectedHeader:()=>ve,errors:()=>s,experimental_jwksCache:()=>fe.tK,exportJWK:()=>B.JU,exportPKCS8:()=>B.Yp,exportSPKI:()=>B.Y5,flattenedDecrypt:()=>H,flattenedVerify:()=>z.Z,generalDecrypt:()=>M,generalVerify:()=>G,generateKeyPair:()=>we.T,generateSecret:()=>_e,importJWK:()=>R.Og,importPKCS8:()=>R.Lf,importSPKI:()=>R.jU,importX509:()=>R.Mh,jwksCache:()=>fe.gE,jwtDecrypt:()=>Z,jwtVerify:()=>Y.V}),r.r(t);var n={};r.r(n),r.d(n,{decode:()=>ye,encode:()=>ge});var i=r(1436),o=r(1476),s=r(7493),a=r(8057);function c(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new s.JOSENotSupported(`Unsupported JWE Algorithm: ${e}`)}}const u=(e,t)=>{if(t.length<<3!==c(e))throw new s.JWEInvalid("Invalid Initialization Vector length")},l=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new s.JWEInvalid(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)},d=(e,t)=>{if(!(e instanceof Uint8Array))throw new TypeError("First argument must be a buffer");if(!(t instanceof Uint8Array))throw new TypeError("Second argument must be a buffer");if(e.length!==t.length)throw new TypeError("Input buffers must have the same length");const r=e.length;let n=0,i=-1;for(;++i<r;)n|=e[i]^t[i];return 0===n};var h=r(7991),f=r(2698),p=r(1575),g=r(5994);const y=async(e,t,r,n,i,a)=>{if(!((0,h.R)(t)||t instanceof Uint8Array))throw new TypeError((0,p.A)(t,...g.g,"Uint8Array"));if(!n)throw new s.JWEInvalid("JWE Initialization Vector missing");if(!i)throw new s.JWEInvalid("JWE Authentication Tag missing");switch(u(e,n),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return t instanceof Uint8Array&&l(t,parseInt(e.slice(-3),10)),async function(e,t,r,n,i,a){if(!(t instanceof Uint8Array))throw new TypeError((0,p.A)(t,"Uint8Array"));const c=parseInt(e.slice(1,4),10),u=await h.A.subtle.importKey("raw",t.subarray(c>>3),"AES-CBC",!1,["decrypt"]),l=await h.A.subtle.importKey("raw",t.subarray(0,c>>3),{hash:"SHA-"+(c<<1),name:"HMAC"},!1,["sign"]),f=(0,o.xW)(a,n,r,(0,o.mx)(a.length<<3)),g=new Uint8Array((await h.A.subtle.sign("HMAC",l,f)).slice(0,c>>3));let y,v;try{y=d(i,g)}catch{}if(!y)throw new s.JWEDecryptionFailed;try{v=new Uint8Array(await h.A.subtle.decrypt({iv:n,name:"AES-CBC"},u,r))}catch{}if(!v)throw new s.JWEDecryptionFailed;return v}(e,t,r,n,i,a);case"A128GCM":case"A192GCM":case"A256GCM":return t instanceof Uint8Array&&l(t,parseInt(e.slice(1,4),10)),async function(e,t,r,n,i,a){let c;t instanceof Uint8Array?c=await h.A.subtle.importKey("raw",t,"AES-GCM",!1,["decrypt"]):((0,f.$)(t,e,"decrypt"),c=t);try{return new Uint8Array(await h.A.subtle.decrypt({additionalData:a,iv:n,name:"AES-GCM",tagLength:128},c,(0,o.xW)(r,i)))}catch{throw new s.JWEDecryptionFailed}}(e,t,r,n,i,a);default:throw new s.JOSENotSupported("Unsupported JWE Content Encryption Algorithm")}};var v=r(9874),m=r(149);const w=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function S(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function _(e,t,r){if((0,h.R)(e))return(0,f.$)(e,t,r),e;if(e instanceof Uint8Array)return h.A.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError((0,p.A)(e,...g.g,"Uint8Array"))}const b=async(e,t,r)=>{const n=await _(t,e,"wrapKey");S(n,e);const i=await h.A.subtle.importKey("raw",r,...w);return new Uint8Array(await h.A.subtle.wrapKey("raw",i,n,"AES-KW"))},E=async(e,t,r)=>{const n=await _(t,e,"unwrapKey");S(n,e);const i=await h.A.subtle.unwrapKey("raw",r,n,"AES-KW",...w);return new Uint8Array(await h.A.subtle.exportKey("raw",i))};async function A(e,t,r,n,i=new Uint8Array(0),s=new Uint8Array(0)){if(!(0,h.R)(e))throw new TypeError((0,p.A)(e,...g.g));if((0,f.$)(e,"ECDH"),!(0,h.R)(t))throw new TypeError((0,p.A)(t,...g.g));(0,f.$)(t,"ECDH","deriveBits");const a=(0,o.xW)((0,o.Kp)(o.Rd.encode(r)),(0,o.Kp)(i),(0,o.Kp)(s),(0,o.VS)(n));let c;c="X25519"===e.algorithm.name?256:"X448"===e.algorithm.name?448:Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3;const u=new Uint8Array(await h.A.subtle.deriveBits({name:e.algorithm.name,public:e},t,c));return(0,o.yI)(u,n,a)}function F(e){if(!(0,h.R)(e))throw new TypeError((0,p.A)(e,...g.g));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||"X25519"===e.algorithm.name||"X448"===e.algorithm.name}async function P(e,t,r,n){!function(e){if(!(e instanceof Uint8Array)||e.length<8)throw new s.JWEInvalid("PBES2 Salt Input must be 8 or more octets")}(e);const i=(0,o.MT)(t,e),a=parseInt(t.slice(13,16),10),c={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:i},u={length:a,name:"AES-KW"},l=await function(e,t){if(e instanceof Uint8Array)return h.A.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if((0,h.R)(e))return(0,f.$)(e,t,"deriveBits","deriveKey"),e;throw new TypeError((0,p.A)(e,...g.g,"Uint8Array"))}(n,t);if(l.usages.includes("deriveBits"))return new Uint8Array(await h.A.subtle.deriveBits(c,l,a));if(l.usages.includes("deriveKey"))return h.A.subtle.deriveKey(c,l,u,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}function k(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new s.JOSENotSupported(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}var I=r(4495);var x=r(3139);function C(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new s.JOSENotSupported(`Unsupported JWE Algorithm: ${e}`)}}const T=e=>(0,a.A)(new Uint8Array(C(e)>>3));var R=r(8278),U=r(8858);const O=async(e,t,r,n,i)=>{if(!((0,h.R)(r)||r instanceof Uint8Array))throw new TypeError((0,p.A)(r,...g.g,"Uint8Array"));var d;switch(n?u(e,n):(d=e,n=(0,a.A)(new Uint8Array(c(d)>>3))),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&l(r,parseInt(e.slice(-3),10)),async function(e,t,r,n,i){if(!(r instanceof Uint8Array))throw new TypeError((0,p.A)(r,"Uint8Array"));const s=parseInt(e.slice(1,4),10),a=await h.A.subtle.importKey("raw",r.subarray(s>>3),"AES-CBC",!1,["encrypt"]),c=await h.A.subtle.importKey("raw",r.subarray(0,s>>3),{hash:"SHA-"+(s<<1),name:"HMAC"},!1,["sign"]),u=new Uint8Array(await h.A.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),l=(0,o.xW)(i,n,u,(0,o.mx)(i.length<<3));return{ciphertext:u,tag:new Uint8Array((await h.A.subtle.sign("HMAC",c,l)).slice(0,s>>3)),iv:n}}(e,t,r,n,i);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&l(r,parseInt(e.slice(1,4),10)),async function(e,t,r,n,i){let o;r instanceof Uint8Array?o=await h.A.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):((0,f.$)(r,e,"encrypt"),o=r);const s=new Uint8Array(await h.A.subtle.encrypt({additionalData:i,iv:n,name:"AES-GCM",tagLength:128},o,t)),a=s.slice(-16);return{ciphertext:s.slice(0,-16),tag:a,iv:n}}(e,t,r,n,i);default:throw new s.JOSENotSupported("Unsupported JWE Content Encryption Algorithm")}};const D=async function(e,t,r,n,o){switch((0,U.A)(e,t,"decrypt"),t=await(x.A.normalizePrivateKey?.(t,e))||t,e){case"dir":if(void 0!==r)throw new s.JWEInvalid("Encountered unexpected JWE Encrypted Key");return t;case"ECDH-ES":if(void 0!==r)throw new s.JWEInvalid("Encountered unexpected JWE Encrypted Key");case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!(0,m.A)(n.epk))throw new s.JWEInvalid('JOSE Header "epk" (Ephemeral Public Key) missing or invalid');if(!F(t))throw new s.JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");const o=await(0,R.Og)(n.epk,e);let a,c;if(void 0!==n.apu){if("string"!=typeof n.apu)throw new s.JWEInvalid('JOSE Header "apu" (Agreement PartyUInfo) invalid');try{a=(0,i.D4)(n.apu)}catch{throw new s.JWEInvalid("Failed to base64url decode the apu")}}if(void 0!==n.apv){if("string"!=typeof n.apv)throw new s.JWEInvalid('JOSE Header "apv" (Agreement PartyVInfo) invalid');try{c=(0,i.D4)(n.apv)}catch{throw new s.JWEInvalid("Failed to base64url decode the apv")}}const u=await A(o,t,"ECDH-ES"===e?n.enc:e,"ECDH-ES"===e?C(n.enc):parseInt(e.slice(-5,-2),10),a,c);if("ECDH-ES"===e)return u;if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");return E(e.slice(-6),u,r)}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");return(async(e,t,r)=>{if(!(0,h.R)(t))throw new TypeError((0,p.A)(t,...g.g));if((0,f.$)(t,e,"decrypt","unwrapKey"),(0,I.A)(e,t),t.usages.includes("decrypt"))return new Uint8Array(await h.A.subtle.decrypt(k(e),t,r));if(t.usages.includes("unwrapKey")){const n=await h.A.subtle.unwrapKey("raw",r,t,k(e),...w);return new Uint8Array(await h.A.subtle.exportKey("raw",n))}throw new TypeError('RSA-OAEP key "usages" must include "decrypt" or "unwrapKey" for this operation')})(e,t,r);case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");if("number"!=typeof n.p2c)throw new s.JWEInvalid('JOSE Header "p2c" (PBES2 Count) missing or invalid');const a=o?.maxPBES2Count||1e4;if(n.p2c>a)throw new s.JWEInvalid('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');if("string"!=typeof n.p2s)throw new s.JWEInvalid('JOSE Header "p2s" (PBES2 Salt) missing or invalid');let c;try{c=(0,i.D4)(n.p2s)}catch{throw new s.JWEInvalid("Failed to base64url decode the p2s")}return(async(e,t,r,n,i)=>{const o=await P(i,e,n,t);return E(e.slice(-6),o,r)})(e,t,r,n.p2c,c)}case"A128KW":case"A192KW":case"A256KW":if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");return E(e,t,r);case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{if(void 0===r)throw new s.JWEInvalid("JWE Encrypted Key missing");if("string"!=typeof n.iv)throw new s.JWEInvalid('JOSE Header "iv" (Initialization Vector) missing or invalid');if("string"!=typeof n.tag)throw new s.JWEInvalid('JOSE Header "tag" (Authentication Tag) missing or invalid');let o,a;try{o=(0,i.D4)(n.iv)}catch{throw new s.JWEInvalid("Failed to base64url decode the iv")}try{a=(0,i.D4)(n.tag)}catch{throw new s.JWEInvalid("Failed to base64url decode the tag")}return async function(e,t,r,n,i){const o=e.slice(0,7);return y(o,t,r,n,i,new Uint8Array(0))}(e,t,r,o,a)}default:throw new s.JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value')}};var N=r(2168),L=r(4618);async function H(e,t,r){if(!(0,m.A)(e))throw new s.JWEInvalid("Flattened JWE must be an object");if(void 0===e.protected&&void 0===e.header&&void 0===e.unprotected)throw new s.JWEInvalid("JOSE Header missing");if(void 0!==e.iv&&"string"!=typeof e.iv)throw new s.JWEInvalid("JWE Initialization Vector incorrect type");if("string"!=typeof e.ciphertext)throw new s.JWEInvalid("JWE Ciphertext missing or incorrect type");if(void 0!==e.tag&&"string"!=typeof e.tag)throw new s.JWEInvalid("JWE Authentication Tag incorrect type");if(void 0!==e.protected&&"string"!=typeof e.protected)throw new s.JWEInvalid("JWE Protected Header incorrect type");if(void 0!==e.encrypted_key&&"string"!=typeof e.encrypted_key)throw new s.JWEInvalid("JWE Encrypted Key incorrect type");if(void 0!==e.aad&&"string"!=typeof e.aad)throw new s.JWEInvalid("JWE AAD incorrect type");if(void 0!==e.header&&!(0,m.A)(e.header))throw new s.JWEInvalid("JWE Shared Unprotected Header incorrect type");if(void 0!==e.unprotected&&!(0,m.A)(e.unprotected))throw new s.JWEInvalid("JWE Per-Recipient Unprotected Header incorrect type");let n;if(e.protected)try{const t=(0,i.D4)(e.protected);n=JSON.parse(o.D0.decode(t))}catch{throw new s.JWEInvalid("JWE Protected Header is invalid")}if(!(0,v.A)(n,e.header,e.unprotected))throw new s.JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");const a={...n,...e.header,...e.unprotected};if((0,N.A)(s.JWEInvalid,new Map,r?.crit,n,a),void 0!==a.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:c,enc:u}=a;if("string"!=typeof c||!c)throw new s.JWEInvalid("missing JWE Algorithm (alg) in JWE Header");if("string"!=typeof u||!u)throw new s.JWEInvalid("missing JWE Encryption Algorithm (enc) in JWE Header");const l=r&&(0,L.A)("keyManagementAlgorithms",r.keyManagementAlgorithms),d=r&&(0,L.A)("contentEncryptionAlgorithms",r.contentEncryptionAlgorithms);if(l&&!l.has(c)||!l&&c.startsWith("PBES2"))throw new s.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(d&&!d.has(u))throw new s.JOSEAlgNotAllowed('"enc" (Encryption Algorithm) Header Parameter value not allowed');let h;if(void 0!==e.encrypted_key)try{h=(0,i.D4)(e.encrypted_key)}catch{throw new s.JWEInvalid("Failed to base64url decode the encrypted_key")}let f,p,g,w=!1;"function"==typeof t&&(t=await t(n,e),w=!0);try{f=await D(c,t,h,a,r)}catch(e){if(e instanceof TypeError||e instanceof s.JWEInvalid||e instanceof s.JOSENotSupported)throw e;f=T(u)}if(void 0!==e.iv)try{p=(0,i.D4)(e.iv)}catch{throw new s.JWEInvalid("Failed to base64url decode the iv")}if(void 0!==e.tag)try{g=(0,i.D4)(e.tag)}catch{throw new s.JWEInvalid("Failed to base64url decode the tag")}const S=o.Rd.encode(e.protected??"");let _,b;_=void 0!==e.aad?(0,o.xW)(S,o.Rd.encode("."),o.Rd.encode(e.aad)):S;try{b=(0,i.D4)(e.ciphertext)}catch{throw new s.JWEInvalid("Failed to base64url decode the ciphertext")}const E={plaintext:await y(u,f,b,p,g,_)};if(void 0!==e.protected&&(E.protectedHeader=n),void 0!==e.aad)try{E.additionalAuthenticatedData=(0,i.D4)(e.aad)}catch{throw new s.JWEInvalid("Failed to base64url decode the aad")}return void 0!==e.unprotected&&(E.sharedUnprotectedHeader=e.unprotected),void 0!==e.header&&(E.unprotectedHeader=e.header),w?{...E,key:t}:E}async function j(e,t,r){if(e instanceof Uint8Array&&(e=o.D0.decode(e)),"string"!=typeof e)throw new s.JWEInvalid("Compact JWE must be a string or Uint8Array");const{0:n,1:i,2:a,3:c,4:u,length:l}=e.split(".");if(5!==l)throw new s.JWEInvalid("Invalid Compact JWE");const d=await H({ciphertext:c,iv:a||void 0,protected:n,tag:u||void 0,encrypted_key:i||void 0},t,r),h={plaintext:d.plaintext,protectedHeader:d.protectedHeader};return"function"==typeof t?{...h,key:d.key}:h}async function M(e,t,r){if(!(0,m.A)(e))throw new s.JWEInvalid("General JWE must be an object");if(!Array.isArray(e.recipients)||!e.recipients.every(m.A))throw new s.JWEInvalid("JWE Recipients missing or incorrect type");if(!e.recipients.length)throw new s.JWEInvalid("JWE Recipients has no members");for(const n of e.recipients)try{return await H({aad:e.aad,ciphertext:e.ciphertext,encrypted_key:n.encrypted_key,header:n.header,iv:e.iv,protected:e.protected,tag:e.tag,unprotected:e.unprotected},t,r)}catch{}throw new s.JWEDecryptionFailed}const K=Symbol();var B=r(5130);const W=async function(e,t,r,n,o={}){let c,u,l;switch((0,U.A)(e,r,"encrypt"),r=await(x.A.normalizePublicKey?.(r,e))||r,e){case"dir":l=r;break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!F(r))throw new s.JOSENotSupported("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:a,apv:d}=o;let{epk:f}=o;f||(f=(await async function(e){if(!(0,h.R)(e))throw new TypeError((0,p.A)(e,...g.g));return h.A.subtle.generateKey(e.algorithm,!0,["deriveBits"])}(r)).privateKey);const{x:y,y:v,crv:m,kty:w}=await(0,B.JU)(f),S=await A(r,f,"ECDH-ES"===e?t:e,"ECDH-ES"===e?C(t):parseInt(e.slice(-5,-2),10),a,d);if(u={epk:{x:y,crv:m,kty:w}},"EC"===w&&(u.epk.y=v),a&&(u.apu=(0,i.lF)(a)),d&&(u.apv=(0,i.lF)(d)),"ECDH-ES"===e){l=S;break}l=n||T(t);const _=e.slice(-6);c=await b(_,S,l);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":l=n||T(t),c=await(async(e,t,r)=>{if(!(0,h.R)(t))throw new TypeError((0,p.A)(t,...g.g));if((0,f.$)(t,e,"encrypt","wrapKey"),(0,I.A)(e,t),t.usages.includes("encrypt"))return new Uint8Array(await h.A.subtle.encrypt(k(e),t,r));if(t.usages.includes("wrapKey")){const n=await h.A.subtle.importKey("raw",r,...w);return new Uint8Array(await h.A.subtle.wrapKey("raw",n,t,k(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')})(e,r,l);break;case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{l=n||T(t);const{p2c:s,p2s:d}=o;({encryptedKey:c,...u}=await(async(e,t,r,n=2048,o=(0,a.A)(new Uint8Array(16)))=>{const s=await P(o,e,n,t);return{encryptedKey:await b(e.slice(-6),s,r),p2c:n,p2s:(0,i.lF)(o)}})(e,r,l,s,d));break}case"A128KW":case"A192KW":case"A256KW":l=n||T(t),c=await b(e,r,l);break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{l=n||T(t);const{iv:s}=o;({encryptedKey:c,...u}=await async function(e,t,r,n){const o=e.slice(0,7),s=await O(o,r,t,n,new Uint8Array(0));return{encryptedKey:s.ciphertext,iv:(0,i.lF)(s.iv),tag:(0,i.lF)(s.tag)}}(e,r,l,s));break}default:throw new s.JOSENotSupported('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:l,encryptedKey:c,parameters:u}};class J{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=e}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}async encrypt(e,t){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new s.JWEInvalid("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!(0,v.A)(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new s.JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if((0,N.A)(s.JWEInvalid,new Map,t?.crit,this._protectedHeader,r),void 0!==r.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:n,enc:a}=r;if("string"!=typeof n||!n)throw new s.JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("string"!=typeof a||!a)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let c,u,l,d,h;if(this._cek&&("dir"===n||"ECDH-ES"===n))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${n}`);{let r;({cek:u,encryptedKey:c,parameters:r}=await W(n,a,e,this._cek,this._keyManagementParameters)),r&&(t&&K in t?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...r}:this.setUnprotectedHeader(r):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...r}:this.setProtectedHeader(r))}d=this._protectedHeader?o.Rd.encode((0,i.lF)(JSON.stringify(this._protectedHeader))):o.Rd.encode(""),this._aad?(h=(0,i.lF)(this._aad),l=(0,o.xW)(d,o.Rd.encode("."),o.Rd.encode(h))):l=d;const{ciphertext:f,tag:p,iv:g}=await O(a,this._plaintext,u,this._iv,l),y={ciphertext:(0,i.lF)(f)};return g&&(y.iv=(0,i.lF)(g)),p&&(y.tag=(0,i.lF)(p)),c&&(y.encrypted_key=(0,i.lF)(c)),h&&(y.aad=h),this._protectedHeader&&(y.protected=o.D0.decode(d)),this._sharedUnprotectedHeader&&(y.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(y.header=this._unprotectedHeader),y}}class V{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addRecipient(...e){return this.parent.addRecipient(...e)}encrypt(...e){return this.parent.encrypt(...e)}done(){return this.parent}}class q{constructor(e){this._recipients=[],this._plaintext=e}addRecipient(e,t){const r=new V(this,e,{crit:t?.crit});return this._recipients.push(r),r}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setSharedUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}setAdditionalAuthenticatedData(e){return this._aad=e,this}async encrypt(){if(!this._recipients.length)throw new s.JWEInvalid("at least one recipient must be added");if(1===this._recipients.length){const[e]=this._recipients,t=await new J(this._plaintext).setAdditionalAuthenticatedData(this._aad).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(e.unprotectedHeader).encrypt(e.key,{...e.options}),r={ciphertext:t.ciphertext,iv:t.iv,recipients:[{}],tag:t.tag};return t.aad&&(r.aad=t.aad),t.protected&&(r.protected=t.protected),t.unprotected&&(r.unprotected=t.unprotected),t.encrypted_key&&(r.recipients[0].encrypted_key=t.encrypted_key),t.header&&(r.recipients[0].header=t.header),r}let e;for(let t=0;t<this._recipients.length;t++){const r=this._recipients[t];if(!(0,v.A)(this._protectedHeader,this._unprotectedHeader,r.unprotectedHeader))throw new s.JWEInvalid("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...r.unprotectedHeader},{alg:i}=n;if("string"!=typeof i||!i)throw new s.JWEInvalid('JWE "alg" (Algorithm) Header Parameter missing or invalid');if("dir"===i||"ECDH-ES"===i)throw new s.JWEInvalid('"dir" and "ECDH-ES" alg may only be used with a single recipient');if("string"!=typeof n.enc||!n.enc)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');if(e){if(e!==n.enc)throw new s.JWEInvalid('JWE "enc" (Encryption Algorithm) Header Parameter must be the same for all recipients')}else e=n.enc;if((0,N.A)(s.JWEInvalid,new Map,r.options.crit,this._protectedHeader,n),void 0!==n.zip)throw new s.JOSENotSupported('JWE "zip" (Compression Algorithm) Header Parameter is not supported.')}const t=T(e),r={ciphertext:"",iv:"",recipients:[],tag:""};for(let n=0;n<this._recipients.length;n++){const o=this._recipients[n],s={};r.recipients.push(s);const a={...this._protectedHeader,...this._unprotectedHeader,...o.unprotectedHeader}.alg.startsWith("PBES2")?2048+n:void 0;if(0===n){const e=await new J(this._plaintext).setAdditionalAuthenticatedData(this._aad).setContentEncryptionKey(t).setProtectedHeader(this._protectedHeader).setSharedUnprotectedHeader(this._unprotectedHeader).setUnprotectedHeader(o.unprotectedHeader).setKeyManagementParameters({p2c:a}).encrypt(o.key,{...o.options,[K]:!0});r.ciphertext=e.ciphertext,r.iv=e.iv,r.tag=e.tag,e.aad&&(r.aad=e.aad),e.protected&&(r.protected=e.protected),e.unprotected&&(r.unprotected=e.unprotected),s.encrypted_key=e.encrypted_key,e.header&&(s.header=e.header);continue}const{encryptedKey:c,parameters:u}=await W(o.unprotectedHeader?.alg||this._protectedHeader?.alg||this._unprotectedHeader?.alg,e,o.key,t,{p2c:a});s.encrypted_key=(0,i.lF)(c),(o.unprotectedHeader||u)&&(s.header={...o.unprotectedHeader,...u})}return r}}var $=r(5609),z=r(6711);async function G(e,t,r){if(!(0,m.A)(e))throw new s.JWSInvalid("General JWS must be an object");if(!Array.isArray(e.signatures)||!e.signatures.every(m.A))throw new s.JWSInvalid("JWS Signatures missing or incorrect type");for(const n of e.signatures)try{return await(0,z.Z)({header:n.header,payload:e.payload,protected:n.protected,signature:n.signature},t,r)}catch{}throw new s.JWSSignatureVerificationFailed}var Y=r(9380),X=r(9803);async function Z(e,t,r){const n=await j(e,t,r),i=(0,X.A)(n.protectedHeader,n.plaintext,r),{protectedHeader:o}=n;if(void 0!==o.iss&&o.iss!==i.iss)throw new s.JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch',i,"iss","mismatch");if(void 0!==o.sub&&o.sub!==i.sub)throw new s.JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch',i,"sub","mismatch");if(void 0!==o.aud&&JSON.stringify(o.aud)!==JSON.stringify(i.aud))throw new s.JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch',i,"aud","mismatch");const a={payload:i,protectedHeader:o};return"function"==typeof t?{...a,key:n.key}:a}class Q{constructor(e){this._flattened=new J(e)}setContentEncryptionKey(e){return this._flattened.setContentEncryptionKey(e),this}setInitializationVector(e){return this._flattened.setInitializationVector(e),this}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}setKeyManagementParameters(e){return this._flattened.setKeyManagementParameters(e),this}async encrypt(e,t){const r=await this._flattened.encrypt(e,t);return[r.protected,r.encrypted_key,r.iv,r.ciphertext,r.tag].join(".")}}var ee=r(2609),te=r(5550);class re{constructor(e,t,r){this.parent=e,this.key=t,this.options=r}setProtectedHeader(e){if(this.protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this.protectedHeader=e,this}setUnprotectedHeader(e){if(this.unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this.unprotectedHeader=e,this}addSignature(...e){return this.parent.addSignature(...e)}sign(...e){return this.parent.sign(...e)}done(){return this.parent}}class ne{constructor(e){this._signatures=[],this._payload=e}addSignature(e,t){const r=new re(this,e,t);return this._signatures.push(r),r}async sign(){if(!this._signatures.length)throw new s.JWSInvalid("at least one signature must be added");const e={signatures:[],payload:""};for(let t=0;t<this._signatures.length;t++){const r=this._signatures[t],n=new te.n(this._payload);n.setProtectedHeader(r.protectedHeader),n.setUnprotectedHeader(r.unprotectedHeader);const{payload:i,...o}=await n.sign(r.key,r.options);if(0===t)e.payload=i;else if(e.payload!==i)throw new s.JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");e.signatures.push(o)}return e}}var ie=r(7248),oe=r(3085);class se extends oe.G{setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setKeyManagementParameters(e){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=e,this}setContentEncryptionKey(e){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=e,this}setInitializationVector(e){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=e,this}replicateIssuerAsHeader(){return this._replicateIssuerAsHeader=!0,this}replicateSubjectAsHeader(){return this._replicateSubjectAsHeader=!0,this}replicateAudienceAsHeader(){return this._replicateAudienceAsHeader=!0,this}async encrypt(e,t){const r=new Q(o.Rd.encode(JSON.stringify(this._payload)));return this._replicateIssuerAsHeader&&(this._protectedHeader={...this._protectedHeader,iss:this._payload.iss}),this._replicateSubjectAsHeader&&(this._protectedHeader={...this._protectedHeader,sub:this._payload.sub}),this._replicateAudienceAsHeader&&(this._protectedHeader={...this._protectedHeader,aud:this._payload.aud}),r.setProtectedHeader(this._protectedHeader),this._iv&&r.setInitializationVector(this._iv),this._cek&&r.setContentEncryptionKey(this._cek),this._keyManagementParameters&&r.setKeyManagementParameters(this._keyManagementParameters),r.encrypt(e,t)}}var ae=r(610);const ce=(e,t)=>{if("string"!=typeof e||!e)throw new s.JWKInvalid(`${t} missing or invalid`)};async function ue(e,t){if(!(0,m.A)(e))throw new TypeError("JWK must be an object");if(t??(t="sha256"),"sha256"!==t&&"sha384"!==t&&"sha512"!==t)throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');let r;switch(e.kty){case"EC":ce(e.crv,'"crv" (Curve) Parameter'),ce(e.x,'"x" (X Coordinate) Parameter'),ce(e.y,'"y" (Y Coordinate) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};break;case"OKP":ce(e.crv,'"crv" (Subtype of Key Pair) Parameter'),ce(e.x,'"x" (Public Key) Parameter'),r={crv:e.crv,kty:e.kty,x:e.x};break;case"RSA":ce(e.e,'"e" (Exponent) Parameter'),ce(e.n,'"n" (Modulus) Parameter'),r={e:e.e,kty:e.kty,n:e.n};break;case"oct":ce(e.k,'"k" (Key Value) Parameter'),r={k:e.k,kty:e.kty};break;default:throw new s.JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported')}const n=o.Rd.encode(JSON.stringify(r));return(0,i.lF)(await(0,ae.A)(t,n))}async function le(e,t){t??(t="sha256");const r=await ue(e,t);return`urn:ietf:params:oauth:jwk-thumbprint:sha-${t.slice(-3)}:${r}`}async function de(e,t){const r={...e,...t?.header};if(!(0,m.A)(r.jwk))throw new s.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');const n=await(0,R.Og)({...r.jwk,ext:!0},r.alg);if(n instanceof Uint8Array||"public"!==n.type)throw new s.JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');return n}var he=r(458),fe=r(3584);class pe extends oe.G{encode(){return`${i.lF(JSON.stringify({alg:"none"}))}.${i.lF(JSON.stringify(this._payload))}.`}static decode(e,t){if("string"!=typeof e)throw new s.JWTInvalid("Unsecured JWT must be a string");const{0:r,1:n,2:a,length:c}=e.split(".");if(3!==c||""!==a)throw new s.JWTInvalid("Invalid Unsecured JWT");let u;try{if(u=JSON.parse(o.D0.decode(i.D4(r))),"none"!==u.alg)throw new Error}catch{throw new s.JWTInvalid("Invalid Unsecured JWT")}return{payload:(0,X.A)(u,i.D4(n),t),header:u}}}const ge=i.lF,ye=i.D4;function ve(e){let t;if("string"==typeof e){const r=e.split(".");3!==r.length&&5!==r.length||([t]=r)}else if("object"==typeof e&&e){if(!("protected"in e))throw new TypeError("Token does not contain a Protected Header");t=e.protected}try{if("string"!=typeof t||!t)throw new Error;const e=JSON.parse(o.D0.decode(ye(t)));if(!(0,m.A)(e))throw new Error;return e}catch{throw new TypeError("Invalid Token or Protected Header formatting")}}function me(e){if("string"!=typeof e)throw new s.JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");const{1:t,length:r}=e.split(".");if(5===r)throw new s.JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");if(3!==r)throw new s.JWTInvalid("Invalid JWT");if(!t)throw new s.JWTInvalid("JWTs must contain a payload");let n,i;try{n=ye(t)}catch{throw new s.JWTInvalid("Failed to base64url decode the payload")}try{i=JSON.parse(o.D0.decode(n))}catch{throw new s.JWTInvalid("Failed to parse the decoded payload as JSON")}if(!(0,m.A)(i))throw new s.JWTInvalid("Invalid JWT Claims Set");return i}var we=r(7307),Se=r(8793);async function _e(e,t){return(0,Se.K)(e,t)}const be="WebCryptoAPI"},3139:(e,t,r)=>{r.d(t,{A:()=>d});var n=r(5500),i=r(1436),o=r(1542);const s=e=>(0,i.D4)(e);let a,c;const u=e=>"KeyObject"===e?.[Symbol.toStringTag],l=async(e,t,r,n,i=!1)=>{let s=e.get(t);if(s?.[n])return s[n];const a=await(0,o.A)({...r,alg:n});return i&&Object.freeze(t),s?s[n]=a:e.set(t,{[n]:a}),a},d={normalizePublicKey:(e,t)=>{if(u(e)){let r=e.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?s(r.k):(c||(c=new WeakMap),l(c,e,r,t))}if((0,n.ll)(e)){if(e.k)return(0,i.D4)(e.k);c||(c=new WeakMap);return l(c,e,e,t,!0)}return e},normalizePrivateKey:(e,t)=>{if(u(e)){let r=e.export({format:"jwk"});return r.k?s(r.k):(a||(a=new WeakMap),l(a,e,r,t))}if((0,n.ll)(e)){if(e.k)return(0,i.D4)(e.k);a||(a=new WeakMap);return l(a,e,e,t,!0)}return e}}},3465:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default="00000000-0000-0000-0000-000000000000"},3584:(e,t,r)=>{r.d(t,{RD:()=>l,tK:()=>d,gE:()=>c});var n=r(7493);const i=async(e,t,r)=>{let i,o,s=!1;"function"==typeof AbortController&&(i=new AbortController,o=setTimeout(()=>{s=!0,i.abort()},t));const a=await fetch(e.href,{signal:i?i.signal:void 0,redirect:"manual",headers:r.headers}).catch(e=>{if(s)throw new n.JWKSTimeout;throw e});if(void 0!==o&&clearTimeout(o),200!==a.status)throw new n.JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");try{return await a.json()}catch{throw new n.JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON")}};var o=r(458),s=r(149);let a;if("undefined"==typeof navigator||!navigator.userAgent?.startsWith?.("Mozilla/5.0 ")){a=`${"jose"}/${"v5.10.0"}`}const c=Symbol();class u{constructor(e,t){if(!(e instanceof URL))throw new TypeError("url must be an instance of URL");var r,n;this._url=new URL(e.href),this._options={agent:t?.agent,headers:t?.headers},this._timeoutDuration="number"==typeof t?.timeoutDuration?t?.timeoutDuration:5e3,this._cooldownDuration="number"==typeof t?.cooldownDuration?t?.cooldownDuration:3e4,this._cacheMaxAge="number"==typeof t?.cacheMaxAge?t?.cacheMaxAge:6e5,void 0!==t?.[c]&&(this._cache=t?.[c],r=t?.[c],n=this._cacheMaxAge,"object"==typeof r&&null!==r&&"uat"in r&&"number"==typeof r.uat&&!(Date.now()-r.uat>=n)&&"jwks"in r&&(0,s.A)(r.jwks)&&Array.isArray(r.jwks.keys)&&Array.prototype.every.call(r.jwks.keys,s.A)&&(this._jwksTimestamp=this._cache.uat,this._local=(0,o.w)(this._cache.jwks)))}coolingDown(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cooldownDuration}fresh(){return"number"==typeof this._jwksTimestamp&&Date.now()<this._jwksTimestamp+this._cacheMaxAge}async getKey(e,t){this._local&&this.fresh()||await this.reload();try{return await this._local(e,t)}catch(r){if(r instanceof n.JWKSNoMatchingKey&&!1===this.coolingDown())return await this.reload(),this._local(e,t);throw r}}async reload(){this._pendingFetch&&("undefined"!=typeof WebSocketPair||"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||"undefined"!=typeof EdgeRuntime&&"vercel"===EdgeRuntime)&&(this._pendingFetch=void 0);const e=new Headers(this._options.headers);a&&!e.has("User-Agent")&&(e.set("User-Agent",a),this._options.headers=Object.fromEntries(e.entries())),this._pendingFetch||(this._pendingFetch=i(this._url,this._timeoutDuration,this._options).then(e=>{this._local=(0,o.w)(e),this._cache&&(this._cache.uat=Date.now(),this._cache.jwks=e),this._jwksTimestamp=Date.now(),this._pendingFetch=void 0}).catch(e=>{throw this._pendingFetch=void 0,e})),await this._pendingFetch}}function l(e,t){const r=new u(e,t),n=async(e,t)=>r.getKey(e,t);return Object.defineProperties(n,{coolingDown:{get:()=>r.coolingDown(),enumerable:!0,configurable:!1},fresh:{get:()=>r.fresh(),enumerable:!0,configurable:!1},reload:{value:()=>r.reload(),enumerable:!0,configurable:!1,writable:!1},reloading:{get:()=>!!r._pendingFetch,enumerable:!0,configurable:!1},jwks:{value:()=>r._local?.jwks(),enumerable:!0,configurable:!1,writable:!1}}),n}const d=c},3779:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});const r="undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);t.default={randomUUID:r}},4299:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.updateV7State=void 0;const n=r(2291),i=r(6011),o={};function s(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,0===e.seq&&e.msecs++),e}function a(e,t,r,n,i=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(n){if(i<0||i+16>n.length)throw new RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`)}else n=new Uint8Array(16),i=0;return t??=Date.now(),r??=127*e[6]<<24|e[7]<<16|e[8]<<8|e[9],n[i++]=t/1099511627776&255,n[i++]=t/4294967296&255,n[i++]=t/16777216&255,n[i++]=t/65536&255,n[i++]=t/256&255,n[i++]=255&t,n[i++]=112|r>>>28&15,n[i++]=r>>>20&255,n[i++]=128|r>>>14&63,n[i++]=r>>>6&255,n[i++]=r<<2&255|3&e[10],n[i++]=e[11],n[i++]=e[12],n[i++]=e[13],n[i++]=e[14],n[i++]=e[15],n}t.updateV7State=s,t.default=function(e,t,r){let c;if(e)c=a(e.random??e.rng?.()??(0,n.default)(),e.msecs,e.seq,t,r);else{const e=Date.now(),i=(0,n.default)();s(o,e,i),c=a(i,o.msecs,o.seq,t,r)}return t??(0,i.unsafeStringify)(c)}},4353:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getSuggestedIssuers=function(){const e=[...r],{host:t,origin:n}=new URL(location.href),i=e.map(({uri:e})=>new URL(e).host);i.includes(t)||i.some(e=>function(e,t){const r=e.length-t.length-1;return r>0&&"."===e[r]&&e.endsWith(t)}(t,e))||e.unshift({name:t,uri:n});return e};const r=[{name:"Solid Community",uri:"https://solidcommunity.net"},{name:"Solid Web",uri:"https://solidweb.org"},{name:"Solid Web ME",uri:"https://solidweb.me"},{name:"Inrupt.com",uri:"https://login.inrupt.com"}]},4495:(e,t,r)=>{r.d(t,{A:()=>n});const n=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if("number"!=typeof r||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}}},4557:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.URL=t.DNS=void 0;const n=r(2829),i=r(2988);var o=r(2988);function s(e,t,r,o){return(0,i.default)(80,n.default,e,t,r,o)}Object.defineProperty(t,"DNS",{enumerable:!0,get:function(){return o.DNS}}),Object.defineProperty(t,"URL",{enumerable:!0,get:function(){return o.URL}}),s.DNS=i.DNS,s.URL=i.URL,t.default=s},4618:(e,t,r)=>{r.d(t,{A:()=>n});const n=(e,t)=>{if(void 0!==t&&(!Array.isArray(t)||t.some(e=>"string"!=typeof e)))throw new TypeError(`"${e}" option must be an array of strings`);if(t)return new Set(t)}},4667:(e,t,r)=>{var n=r(3121),i=r(182);const o=["ES256","RS256"],s={ERROR:"error",LOGIN:"login",LOGOUT:"logout",NEW_REFRESH_TOKEN:"newRefreshToken",NEW_TOKENS:"newTokens",AUTHORIZATION_REQUEST:"authorizationRequest",SESSION_EXPIRED:"sessionExpired",SESSION_EXTENDED:"sessionExtended",SESSION_RESTORED:"sessionRestore",TIMEOUT_SET:"timeoutSet"},a=["openid","offline_access","webid"];class c{sessionInfoManager;constructor(e){this.sessionInfoManager=e,this.sessionInfoManager=e}async canHandle(){return!0}async handle(e){await this.sessionInfoManager.clear(e)}}class u{redirector;constructor(e){this.redirector=e,this.redirector=e}async canHandle(e,t){return"idp"===t?.logoutType}async handle(e,t){if("idp"!==t?.logoutType)throw new Error("Attempting to call idp logout handler to perform app logout");if(void 0===t.toLogoutUrl)throw new Error("Cannot perform IDP logout. Did you log in using the OIDC authentication flow?");this.redirector.redirect(t.toLogoutUrl(t),{handleRedirect:t.handleRedirect})}}async function l(e,t){await Promise.all([t.deleteAllUserData(e,{secure:!1}),t.deleteAllUserData(e,{secure:!0})])}function d({endSessionEndpoint:e,idTokenHint:t,postLogoutRedirectUri:r,state:n}){const i=new URL(e);return void 0!==t&&i.searchParams.append("id_token_hint",t),void 0!==r&&(i.searchParams.append("post_logout_redirect_uri",r),void 0!==n&&i.searchParams.append("state",n)),i.toString()}function h(e){try{return new URL(e),!0}catch{return!1}}const f=(e,t)=>fetch(e,t);class p{secureStorage;insecureStorage;constructor(e,t){this.secureStorage=e,this.insecureStorage=t,this.secureStorage=e,this.insecureStorage=t}getKey(e){return`solidClientAuthenticationUser:${e}`}async getUserData(e,t){const r=await(t?this.secureStorage:this.insecureStorage).get(this.getKey(e));if(void 0===r)return{};try{return JSON.parse(r)}catch(n){throw new Error(`Data for user [${e}] in [${t?"secure":"unsecure"}] storage is corrupted - expected valid JSON, but got: ${r}`)}}async setUserData(e,t,r){await(r?this.secureStorage:this.insecureStorage).set(this.getKey(e),JSON.stringify(t))}async get(e,t){const r=await(t?.secure?this.secureStorage:this.insecureStorage).get(e);if(void 0===r&&t?.errorIfNull)throw new Error(`[${e}] is not stored`);return r}async set(e,t,r){return(r?.secure?this.secureStorage:this.insecureStorage).set(e,t)}async delete(e,t){return(t?.secure?this.secureStorage:this.insecureStorage).delete(e)}async getForUser(e,t,r){const n=await this.getUserData(e,r?.secure);let i;if(n&&n[t]||(i=void 0),i=n[t],void 0===i&&r?.errorIfNull)throw new Error(`Field [${t}] for user [${e}] is not stored`);return i||void 0}async setForUser(e,t,r){let n;try{n=await this.getUserData(e,r?.secure)}catch{n={}}await this.setUserData(e,{...n,...t},r?.secure)}async deleteForUser(e,t,r){const n=await this.getUserData(e,r?.secure);delete n[t],await this.setUserData(e,n,r?.secure)}async deleteAllUserData(e,t){await(t?.secure?this.secureStorage:this.insecureStorage).delete(this.getKey(e))}}class g extends Error{constructor(e){super(e)}}class y extends Error{constructor(e){super(`[${e}] is not implemented`)}}class v extends Error{missingFields;constructor(e){super(`Invalid response from OIDC provider: missing fields ${e}`),this.missingFields=e}}class m extends Error{error;errorDescription;constructor(e,t,r){super(e),this.error=t,this.errorDescription=r}}function w(e){const t=new URL(e);return new URL(t.pathname,t.origin).toString()}async function S(e,t,r){return new n.SignJWT({htu:w(e),htm:t.toUpperCase(),jti:i.v4()}).setProtectedHeader({alg:o[0],jwk:r.publicKey,typ:"dpop+jwt"}).setIssuedAt().sign(r.privateKey,{})}async function _(e,t,r,n){if(void 0!==r)return async function(e,t,r,n){const i=new Headers(n?.headers);return i.set("Authorization",`DPoP ${t}`),i.set("DPoP",await S(e,n?.method??"get",r)),{...n,headers:i}}(e,t,r,n);const i=new Headers(n?.headers);return i.set("Authorization",`Bearer ${t}`),{...n,headers:i}}async function b(e,t,r,n,i=fetch){return i(t,await _(t.toString(),e,n,r))}const E=e=>void 0!==e?e-5>0?e-5:e:600;const A="getResponse",F={get:async(e,t)=>A,set:async(e,t)=>{},delete:async e=>{},getForUser:async(e,t,r)=>A,setForUser:async(e,t,r)=>{},deleteForUser:async(e,t,r)=>{},deleteAllUserData:async(e,t)=>{}},P=e=>{const t=e;return{get:async e=>{if(void 0!==t[e])return"string"==typeof t[e]?t[e]:JSON.stringify(t[e])},set:async(e,r)=>{t[e]=r},delete:async e=>{delete t[e]}}};t.AggregateHandler=class{handleables;constructor(e){this.handleables=e,this.handleables=e}async getProperHandler(e){const t=await Promise.all(this.handleables.map(t=>t.canHandle(...e)));for(let e=0;e<t.length;e+=1)if(t[e])return this.handleables[e];return null}async canHandle(...e){return null!==await this.getProperHandler(e)}async handle(...e){const t=await this.getProperHandler(e);if(t)return t.handle(...e);throw new Error(`[${this.constructor.name}] cannot find a suitable handler for: ${e.map(e=>{try{return JSON.stringify(e)}catch(t){return e.toString()}}).join(", ")}`)}},t.AuthorizationCodeWithPkceOidcHandlerBase=class{storageUtility;redirector;constructor(e,t){this.storageUtility=e,this.redirector=t,this.storageUtility=e,this.redirector=t}parametersGuard=e=>void 0!==e.issuerConfiguration.grantTypesSupported&&e.issuerConfiguration.grantTypesSupported.indexOf("authorization_code")>-1&&void 0!==e.redirectUrl;async canHandle(e){return this.parametersGuard(e)}async setupRedirectHandler({oidcLoginOptions:e,state:t,codeVerifier:r,targetUrl:n}){if(!this.parametersGuard(e))throw new Error("The authorization code grant requires a redirectUrl.");var i,o;await Promise.all([this.storageUtility.setForUser(t,{sessionId:e.sessionId}),this.storageUtility.setForUser(e.sessionId,{codeVerifier:r,issuer:e.issuer.toString(),redirectUrl:e.redirectUrl,dpop:Boolean(e.dpop).toString(),keepAlive:(i=e.keepAlive,o=!0,"boolean"==typeof i?Boolean(i):Boolean(o)).toString()})]),this.redirector.redirect(n,{handleRedirect:e.handleRedirect})}},t.ClientAuthentication=class{loginHandler;redirectHandler;logoutHandler;sessionInfoManager;issuerConfigFetcher;boundLogout;constructor(e,t,r,n,i){this.loginHandler=e,this.redirectHandler=t,this.logoutHandler=r,this.sessionInfoManager=n,this.issuerConfigFetcher=i,this.loginHandler=e,this.redirectHandler=t,this.logoutHandler=r,this.sessionInfoManager=n,this.issuerConfigFetcher=i}fetch=f;logout=async(e,t)=>{await this.logoutHandler.handle(e,"idp"===t?.logoutType?{...t,toLogoutUrl:this.boundLogout}:t),this.fetch=f,delete this.boundLogout};getSessionInfo=async e=>this.sessionInfoManager.get(e);getAllSessionInfo=async()=>this.sessionInfoManager.getAll()},t.ConfigurationError=g,t.DEFAULT_SCOPES=a,t.EVENTS=s,t.GeneralLogoutHandler=c,t.IRpLogoutHandler=u,t.IWaterfallLogoutHandler=class{handlers;constructor(e,t){this.handlers=[new c(e),new u(t)]}async canHandle(){return!0}async handle(e,t){for(const r of this.handlers)await r.canHandle(e,t)&&await r.handle(e,t)}},t.InMemoryStorage=class{map={};async get(e){return this.map[e]||void 0}async set(e,t){this.map[e]=t}async delete(e){delete this.map[e]}},t.InvalidResponseError=v,t.NotImplementedError=y,t.OidcProviderError=m,t.PREFERRED_SIGNING_ALG=o,t.REFRESH_BEFORE_EXPIRATION_SECONDS=5,t.SOLID_CLIENT_AUTHN_KEY_PREFIX="solidClientAuthn:",t.SessionInfoManagerBase=class{storageUtility;constructor(e){this.storageUtility=e,this.storageUtility=e}update(e,t){throw new Error("Not Implemented")}set(e,t){throw new Error("Not Implemented")}get(e){throw new Error("Not implemented")}async getAll(){throw new Error("Not implemented")}async clear(e){return l(e,this.storageUtility)}async register(e){throw new Error("Not implemented")}async getRegisteredSessionIdAll(){throw new Error("Not implemented")}async clearAll(){throw new Error("Not implemented")}async setOidcContext(e,t){throw new Error("Not implemented")}},t.StorageUtility=p,t.StorageUtilityGetResponse=A,t.StorageUtilityMock=F,t.USER_SESSION_PREFIX="solidClientAuthenticationUser",t.buildAuthenticatedFetch=function(e,t){let r,n=e;const i=t?.refreshOptions;if(void 0!==i){const e=async()=>{try{const{accessToken:o,refreshToken:a,expiresIn:c}=await async function(e,t,r){const n=await e.tokenRefresher.refresh(e.sessionId,e.refreshToken,t);return r?.emit(s.SESSION_EXTENDED,n.expiresIn??600),{accessToken:n.accessToken,refreshToken:n.refreshToken,expiresIn:n.expiresIn}}(i,t.dpopKey,t.eventEmitter);n=o,void 0!==a&&(i.refreshToken=a),clearTimeout(r),r=setTimeout(e,1e3*E(c)),t.eventEmitter?.emit(s.TIMEOUT_SET,r)}catch(e){e instanceof m&&(t?.eventEmitter?.emit(s.ERROR,e.error,e.errorDescription),t?.eventEmitter?.emit(s.SESSION_EXPIRED)),e instanceof v&&e.missingFields.includes("access_token")&&t?.eventEmitter?.emit(s.SESSION_EXPIRED)}};r=setTimeout(e,1e3*E(t.expiresIn)),t.eventEmitter?.emit(s.TIMEOUT_SET,r)}else if(void 0!==t&&void 0!==t.eventEmitter){const e=setTimeout(()=>{t.eventEmitter.emit(s.SESSION_EXPIRED)},1e3*E(t.expiresIn));t.eventEmitter.emit(s.TIMEOUT_SET,e)}return async(e,r)=>{let i=await b(n,e,r,t?.dpopKey,t?.fetch);const o=!i.ok&&(s=i.status,![401,403].includes(s));var s;if(i.ok||o)return i;return i.url!==e&&void 0!==t?.dpopKey&&(i=await b(n,i.url,r,t.dpopKey,t.fetch)),i}},t.clear=l,t.createDpopHeader=S,t.determineSigningAlg=function(e,t){return t.find(t=>e.includes(t))??null},t.generateDpopKeyPair=async function(){const{privateKey:e,publicKey:t}=await n.generateKeyPair(o[0]),r={privateKey:e,publicKey:await n.exportJWK(t)};return[r.publicKey.alg]=o,r},t.getEndSessionUrl=d,t.getSessionIdFromOauthState=async function(e,t){return e.getForUser(t,"sessionId")},t.getUnauthenticatedSession=function(){return{isLoggedIn:!1,sessionId:i.v4(),fetch:(...e)=>fetch(...e)}},t.getWebidFromTokenPayload=async function(e,t,r,i){let o,s;try{const{payload:s}=await n.jwtVerify(e,n.createRemoteJWKSet(new URL(t)),{issuer:r,audience:i});o=s}catch(e){throw new Error(`Token verification failed: ${e.stack}`)}if("string"==typeof o.azp&&(s=o.azp),"string"==typeof o.webid)return{webId:o.webid,clientId:s};if("string"!=typeof o.sub)throw new Error(`The token ${JSON.stringify(o)} is invalid: it has no 'webid' claim and no 'sub' claim.`);try{return new URL(o.sub),{webId:o.sub,clientId:s}}catch(e){throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${o.sub}] is invalid as a URL - error [${e}].`)}},t.handleRegistration=async function(e,t,r,n){let i;if(function(e,t){return t.scopesSupported.includes("webid")&&void 0!==e.clientId&&h(e.clientId)}(e,t))i={clientId:e.clientId,clientName:e.clientName,clientType:"solid-oidc"};else{if(!function(e){return void 0!==e.clientId&&!h(e.clientId)}(e))return n.getClient({sessionId:e.sessionId,clientName:e.clientName,redirectUrl:e.redirectUrl},t);i={clientId:e.clientId,clientSecret:e.clientSecret,clientName:e.clientName,clientType:"static"}}const o={clientId:i.clientId,clientType:i.clientType};return"static"===i.clientType&&(o.clientSecret=i.clientSecret),i.clientName&&(o.clientName=i.clientName),await r.setForUser(e.sessionId,o),i},t.isKnownClientType=function(e){return"string"==typeof e&&["dynamic","static","solid-oidc"].includes(e)},t.isSupportedTokenType=function(e){return"string"==typeof e&&["DPoP","Bearer"].includes(e)},t.isValidRedirectUrl=function(e){try{const t=new URL(e),r=!t.searchParams.has("code")&&!t.searchParams.has("state"),n=""===t.hash;return r&&n}catch(e){return!1}},t.loadOidcContextFromStorage=async function(e,t,r){try{const[n,i,o,s,a]=await Promise.all([t.getForUser(e,"issuer",{errorIfNull:!0}),t.getForUser(e,"codeVerifier"),t.getForUser(e,"redirectUrl"),t.getForUser(e,"dpop",{errorIfNull:!0}),t.getForUser(e,"keepAlive")]);await t.deleteForUser(e,"codeVerifier");return{codeVerifier:i,redirectUrl:o,issuerConfig:await r.fetchConfig(n),dpop:"true"===s,keepAlive:"string"!=typeof a||"true"===a}}catch(t){throw new Error(`Failed to retrieve OIDC context from storage associated with session [${e}]: ${t}`)}},t.maybeBuildRpInitiatedLogout=function({endSessionEndpoint:e,idTokenHint:t}){if(void 0!==e)return function({state:r,postLogoutUrl:n}){return d({endSessionEndpoint:e,idTokenHint:t,state:r,postLogoutRedirectUri:n})}},t.mockStorage=P,t.mockStorageUtility=(e,t=!1)=>t?new p(P(e),P({})):new p(P({}),P(e)),t.normalizeScopes=function(e){return Array.isArray(e)?Array.from(new Set([...a,...e.filter(e=>"string"==typeof e&&!e.includes(" "))])):a},t.removeOpenIdParams=function(e){const t=new URL(e);return t.searchParams.delete("state"),t.searchParams.delete("code"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),t.searchParams.delete("iss"),t},t.saveSessionInfoToStorage=async function(e,t,r,i,o,s,a,c){void 0!==s&&await e.setForUser(t,{refreshToken:s},{secure:a}),void 0!==r&&await e.setForUser(t,{webId:r},{secure:a}),void 0!==i&&await e.setForUser(t,{clientId:i},{secure:a}),void 0!==o&&await e.setForUser(t,{isLoggedIn:o},{secure:a}),void 0!==c&&await e.setForUser(t,{publicKey:JSON.stringify(c.publicKey),privateKey:JSON.stringify(await n.exportJWK(c.privateKey))},{secure:a})}},4738:t=>{t.exports=e},4746:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.SolidAuthnLogic=void 0;const a=r(4738),c=r(2233),u=s(r(9378)),l=r(2452);t.SolidAuthnLogic=class{session;constructor(e){this.session=e}get authSession(){return this.session}currentUser(){const e=(0,c.appContext)();return e.viewingNoAuthPage?(0,a.sym)(e.webId):this&&this.session&&this.session.info&&this.session.info.webId&&this.session.info.isLoggedIn?(0,a.sym)(this.session.info.webId):(0,c.offlineTestID)()}async checkUser(e){const t=new URL(window.location.href).hash;t&&window.localStorage.setItem("preLoginRedirectHash",t),this.session.events.on(l.EVENTS.SESSION_RESTORED,e=>{u.log(`Session restored to ${e}`),document.location.toString()!==e&&history.replaceState(null,"",e)});const r=new URL(window.location.href);r.hash="",await this.session.handleIncomingRedirect({restorePreviousSession:!0,url:r.href});const n=window.localStorage.getItem("preLoginRedirectHash");if(n){const e=new URL(window.location.href);e.hash!==n&&(history.pushState?history.pushState(null,document.title,n):location.hash=n,e.hash=n),window.localStorage.setItem("preLoginRedirectHash","")}let i=(0,c.offlineTestID)();if(i)return Promise.resolve(e?e(i):i);const o=this.webIdFromSession(this.session.info);return o&&(i=this.saveUser(o)),i&&u.log(`(Logged in as ${i} by authentication)`),Promise.resolve(e?e(i):i)}saveUser(e,t){let r;if(e){r="string"==typeof e?e:e.uri;const n=(0,a.namedNode)(r);return t&&(t.me=n),n}return null}webIdFromSession(e){return e?.webId&&e.isLoggedIn?e.webId:null}}},5130:(e,t,r)=>{r.d(t,{JU:()=>d,Yp:()=>l,Y5:()=>u});var n=r(5141),i=r(7991),o=r(1575),s=r(1436),a=r(5994);const c=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:(0,s.lF)(e)};if(!(0,i.R)(e))throw new TypeError((0,o.A)(e,...a.g,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:c,...u}=await i.A.subtle.exportKey("jwk",e);return u};async function u(e){return(0,n.Nj)(e)}async function l(e){return(0,n.Jq)(e)}async function d(e){return c(e)}},5141:(e,t,r)=>{r.d(t,{IG:()=>g,sc:()=>y,zp:()=>S,Jq:()=>d,Nj:()=>l});var n=r(7991),i=r(1575),o=r(1436);const s=(e,t)=>`-----BEGIN ${t}-----\n${(e.match(/.{1,64}/g)||[]).join("\n")}\n-----END ${t}-----`;var a=r(7493),c=r(5994);const u=async(e,t,r)=>{if(!(0,n.R)(r))throw new TypeError((0,i.A)(r,...c.g));if(!r.extractable)throw new TypeError("CryptoKey is not extractable");if(r.type!==e)throw new TypeError(`key is not a ${e} key`);return s((0,o.WG)(new Uint8Array(await n.A.subtle.exportKey(t,r))),`${e.toUpperCase()} KEY`)},l=e=>u("public","spki",e),d=e=>u("private","pkcs8",e),h=(e,t,r=0)=>{0===r&&(t.unshift(t.length),t.unshift(6));const n=e.indexOf(t[0],r);if(-1===n)return!1;const i=e.subarray(n,n+t.length);return i.length===t.length&&(i.every((e,r)=>e===t[r])||h(e,t,n+1))},f=e=>{switch(!0){case h(e,[42,134,72,206,61,3,1,7]):return"P-256";case h(e,[43,129,4,0,34]):return"P-384";case h(e,[43,129,4,0,35]):return"P-521";case h(e,[43,101,110]):return"X25519";case h(e,[43,101,111]):return"X448";case h(e,[43,101,112]):return"Ed25519";case h(e,[43,101,113]):return"Ed448";default:throw new a.JOSENotSupported("Invalid or unsupported EC Key Curve or OKP Key Sub Type")}},p=async(e,t,r,i,o)=>{let s,c;const u=new Uint8Array(atob(r.replace(e,"")).split("").map(e=>e.charCodeAt(0))),l="spki"===t;switch(i){case"PS256":case"PS384":case"PS512":s={name:"RSA-PSS",hash:`SHA-${i.slice(-3)}`},c=l?["verify"]:["sign"];break;case"RS256":case"RS384":case"RS512":s={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${i.slice(-3)}`},c=l?["verify"]:["sign"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":s={name:"RSA-OAEP",hash:`SHA-${parseInt(i.slice(-3),10)||1}`},c=l?["encrypt","wrapKey"]:["decrypt","unwrapKey"];break;case"ES256":s={name:"ECDSA",namedCurve:"P-256"},c=l?["verify"]:["sign"];break;case"ES384":s={name:"ECDSA",namedCurve:"P-384"},c=l?["verify"]:["sign"];break;case"ES512":s={name:"ECDSA",namedCurve:"P-521"},c=l?["verify"]:["sign"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{const e=f(u);s=e.startsWith("P-")?{name:"ECDH",namedCurve:e}:{name:e},c=l?[]:["deriveBits"];break}case"Ed25519":s={name:"Ed25519"},c=l?["verify"]:["sign"];break;case"EdDSA":s={name:f(u)},c=l?["verify"]:["sign"];break;default:throw new a.JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value')}return n.A.subtle.importKey(t,u,s,o?.extractable??!1,c)},g=(e,t,r)=>p(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g,"pkcs8",e,t,r),y=(e,t,r)=>p(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\s)/g,"spki",e,t,r);function v(e){const t=[];let r=0;for(;r<e.length;){const n=m(e.subarray(r));t.push(n),r+=n.byteLength}return t}function m(e){let t=0,r=31&e[0];if(t++,31===r){for(r=0;e[t]>=128;)r=128*r+e[t]-128,t++;r=128*r+e[t]-128,t++}let n=0;if(e[t]<128)n=e[t],t++;else{if(128===n){for(n=0;0!==e[t+n]||0!==e[t+n+1];){if(n>e.byteLength)throw new TypeError("invalid indefinite form length");n++}const r=t+n+2;return{byteLength:r,contents:e.subarray(t,t+n),raw:e.subarray(0,r)}}{const r=127&e[t];t++,n=0;for(let i=0;i<r;i++)n=256*n+e[t],t++}}const i=t+n;return{byteLength:i,contents:e.subarray(t,i),raw:e.subarray(0,i)}}function w(e){const t=e.replace(/(?:-----(?:BEGIN|END) CERTIFICATE-----|\s)/g,""),r=(0,o.y4)(t);return s(function(e){const t=v(v(m(e).contents)[0].contents);return(0,o.WG)(t[160===t[0].raw[0]?6:5].raw)}(r),"PUBLIC KEY")}const S=(e,t,r)=>{let n;try{n=w(e)}catch(e){throw new TypeError("Failed to parse the X.509 certificate",{cause:e})}return y(n,t,r)}},5386:e=>{const t={acl:"http://www.w3.org/ns/auth/acl#",arg:"http://www.w3.org/ns/pim/arg#",as:"https://www.w3.org/ns/activitystreams#",bookmark:"http://www.w3.org/2002/01/bookmark#",cal:"http://www.w3.org/2002/12/cal/ical#",cco:"http://www.ontologyrepository.com/CommonCoreOntologies/",cert:"http://www.w3.org/ns/auth/cert#",contact:"http://www.w3.org/2000/10/swap/pim/contact#",dc:"http://purl.org/dc/elements/1.1/",dct:"http://purl.org/dc/terms/",doap:"http://usefulinc.com/ns/doap#",foaf:"http://xmlns.com/foaf/0.1/",geo:"http://www.w3.org/2003/01/geo/wgs84_pos#",gpx:"http://www.w3.org/ns/pim/gpx#",gr:"http://purl.org/goodrelations/v1#",http:"http://www.w3.org/2007/ont/http#",httph:"http://www.w3.org/2007/ont/httph#",icalTZ:"http://www.w3.org/2002/12/cal/icaltzd#",ldp:"http://www.w3.org/ns/ldp#",link:"http://www.w3.org/2007/ont/link#",log:"http://www.w3.org/2000/10/swap/log#",meeting:"http://www.w3.org/ns/pim/meeting#",mo:"http://purl.org/ontology/mo/",org:"http://www.w3.org/ns/org#",owl:"http://www.w3.org/2002/07/owl#",pad:"http://www.w3.org/ns/pim/pad#",patch:"http://www.w3.org/ns/pim/patch#",prov:"http://www.w3.org/ns/prov#",pto:"http://www.productontology.org/id/",qu:"http://www.w3.org/2000/10/swap/pim/qif#",trip:"http://www.w3.org/ns/pim/trip#",rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",rdfs:"http://www.w3.org/2000/01/rdf-schema#",rss:"http://purl.org/rss/1.0/",sched:"http://www.w3.org/ns/pim/schedule#",schema:"http://schema.org/",sioc:"http://rdfs.org/sioc/ns#",skos:"http://www.w3.org/2004/02/skos/core#",solid:"http://www.w3.org/ns/solid/terms#",space:"http://www.w3.org/ns/pim/space#",stat:"http://www.w3.org/ns/posix/stat#",tab:"http://www.w3.org/2007/ont/link#",tabont:"http://www.w3.org/2007/ont/link#",ui:"http://www.w3.org/ns/ui#",vann:"http://purl.org/vocab/vann/",vcard:"http://www.w3.org/2006/vcard/ns#",wf:"http://www.w3.org/2005/01/wf/flow#",xsd:"http://www.w3.org/2001/XMLSchema#"};e.exports=function(e={namedNode:e=>e}){const r={};for(const n in t){const i=t[n];r[n]=function(t=""){return e.namedNode(i+t)}}return r}},5500:(e,t,r)=>{r.d(t,{M3:()=>s,W2:()=>o,ll:()=>i,t9:()=>a});var n=r(149);function i(e){return(0,n.A)(e)&&"string"==typeof e.kty}function o(e){return"oct"!==e.kty&&"string"==typeof e.d}function s(e){return"oct"!==e.kty&&void 0===e.d}function a(e){return i(e)&&"oct"===e.kty&&"string"==typeof e.k}},5550:(e,t,r)=>{r.d(t,{n:()=>p});var n=r(1436),i=r(1020),o=r(7991),s=r(4495),a=r(676);const c=async(e,t,r)=>{const n=await(0,a.A)(e,t,"sign");(0,s.A)(e,n);const c=await o.A.subtle.sign((0,i.A)(e,n.algorithm),n,r);return new Uint8Array(c)};var u=r(9874),l=r(7493),d=r(1476),h=r(8858),f=r(2168);class p{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,t){if(!this._protectedHeader&&!this._unprotectedHeader)throw new l.JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!(0,u.A)(this._protectedHeader,this._unprotectedHeader))throw new l.JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const r={...this._protectedHeader,...this._unprotectedHeader};let i=!0;if((0,f.A)(l.JWSInvalid,new Map([["b64",!0]]),t?.crit,this._protectedHeader,r).has("b64")&&(i=this._protectedHeader.b64,"boolean"!=typeof i))throw new l.JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:o}=r;if("string"!=typeof o||!o)throw new l.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');(0,h.I)(o,e,"sign");let s,a=this._payload;i&&(a=d.Rd.encode((0,n.lF)(a))),s=this._protectedHeader?d.Rd.encode((0,n.lF)(JSON.stringify(this._protectedHeader))):d.Rd.encode("");const p=(0,d.xW)(s,d.Rd.encode("."),a),g=await c(o,e,p),y={signature:(0,n.lF)(g),payload:""};return i&&(y.payload=d.D0.decode(a)),this._unprotectedHeader&&(y.header=this._unprotectedHeader),this._protectedHeader&&(y.protected=d.D0.decode(s)),y}}},5609:(e,t,r)=>{r.d(t,{B:()=>s});var n=r(6711),i=r(7493),o=r(1476);async function s(e,t,r){if(e instanceof Uint8Array&&(e=o.D0.decode(e)),"string"!=typeof e)throw new i.JWSInvalid("Compact JWS must be a string or Uint8Array");const{0:s,1:a,2:c,length:u}=e.split(".");if(3!==u)throw new i.JWSInvalid("Invalid Compact JWS");const l=await(0,n.Z)({payload:a,protected:s,signature:c},t,r),d={payload:l.payload,protectedHeader:l.protectedHeader};return"function"==typeof t?{...d,key:l.key}:d}},5994:(e,t,r)=>{r.d(t,{A:()=>i,g:()=>o});var n=r(7991);const i=e=>!!(0,n.R)(e)||"KeyObject"===e?.[Symbol.toStringTag],o=["CryptoKey"]},6011:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.unsafeStringify=void 0;const n=r(9746),i=[];for(let e=0;e<256;++e)i.push((e+256).toString(16).slice(1));function o(e,t=0){return(i[e[t+0]]+i[e[t+1]]+i[e[t+2]]+i[e[t+3]]+"-"+i[e[t+4]]+i[e[t+5]]+"-"+i[e[t+6]]+i[e[t+7]]+"-"+i[e[t+8]]+i[e[t+9]]+"-"+i[e[t+10]]+i[e[t+11]]+i[e[t+12]]+i[e[t+13]]+i[e[t+14]]+i[e[t+15]]).toLowerCase()}t.unsafeStringify=o,t.default=function(e,t=0){const r=o(e,t);if(!(0,n.default)(r))throw TypeError("Stringified UUID is invalid");return r}},6118:function(e,t,r){var n,i=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||(n=function(e){return n=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},n(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r=n(e),s=0;s<r.length;s++)"default"!==r[s]&&i(t,e,r[s]);return o(t,e),t}),a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.ns=void 0;const c=a(r(5386)),u=s(r(4738));t.ns=(0,c.default)(u)},6356:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(6011),i=r(1425),o=r(6568);t.default=function(e,t,r){e??={},r??=0;let s=(0,i.default)({...e,_v6:!0},new Uint8Array(16));if(s=(0,o.default)(s),t){for(let e=0;e<16;e++)t[r+e]=s[e];return t}return(0,n.unsafeStringify)(s)}},6516:function(e){var t;t=function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=22)}([function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i={debug:function(){},info:function(){},warn:function(){},error:function(){}},o=void 0,s=void 0;(t.Log=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.reset=function(){s=3,o=i},e.debug=function(){if(s>=4){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.debug.apply(o,Array.from(t))}},e.info=function(){if(s>=3){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.info.apply(o,Array.from(t))}},e.warn=function(){if(s>=2){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.warn.apply(o,Array.from(t))}},e.error=function(){if(s>=1){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];o.error.apply(o,Array.from(t))}},n(e,null,[{key:"NONE",get:function(){return 0}},{key:"ERROR",get:function(){return 1}},{key:"WARN",get:function(){return 2}},{key:"INFO",get:function(){return 3}},{key:"DEBUG",get:function(){return 4}},{key:"level",get:function(){return s},set:function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");s=e}},{key:"logger",get:function(){return o},set:function(e){if(!e.debug&&e.info&&(e.debug=e.info),!(e.debug&&e.info&&e.warn&&e.error))throw new Error("Invalid logger");o=e}}]),e}()).reset()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i={setInterval:function(e){function t(t,r){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e,t){return setInterval(e,t)}),clearInterval:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return clearInterval(e)})},o=!1,s=null;t.Global=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e._testing=function(){o=!0},e.setXMLHttpRequest=function(e){s=e},n(e,null,[{key:"location",get:function(){if(!o)return location}},{key:"localStorage",get:function(){if(!o&&"undefined"!=typeof window)return localStorage}},{key:"sessionStorage",get:function(){if(!o&&"undefined"!=typeof window)return sessionStorage}},{key:"XMLHttpRequest",get:function(){if(!o&&"undefined"!=typeof window)return s||XMLHttpRequest}},{key:"timer",get:function(){if(!o)return i}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.MetadataService=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(7),s=".well-known/openid-configuration";t.MetadataService=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.JsonService;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("MetadataService: No settings passed to MetadataService"),new Error("settings");this._settings=t,this._jsonService=new r(["application/jwk-set+json"])}return e.prototype.resetSigningKeys=function(){this._settings=this._settings||{},this._settings.signingKeys=void 0},e.prototype.getMetadata=function(){var e=this;return this._settings.metadata?(i.Log.debug("MetadataService.getMetadata: Returning metadata from settings"),Promise.resolve(this._settings.metadata)):this.metadataUrl?(i.Log.debug("MetadataService.getMetadata: getting metadata from",this.metadataUrl),this._jsonService.getJson(this.metadataUrl).then(function(t){i.Log.debug("MetadataService.getMetadata: json received");var r=e._settings.metadataSeed||{};return e._settings.metadata=Object.assign({},r,t),e._settings.metadata})):(i.Log.error("MetadataService.getMetadata: No authority or metadataUrl configured on settings"),Promise.reject(new Error("No authority or metadataUrl configured on settings")))},e.prototype.getIssuer=function(){return this._getMetadataProperty("issuer")},e.prototype.getAuthorizationEndpoint=function(){return this._getMetadataProperty("authorization_endpoint")},e.prototype.getUserInfoEndpoint=function(){return this._getMetadataProperty("userinfo_endpoint")},e.prototype.getTokenEndpoint=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._getMetadataProperty("token_endpoint",e)},e.prototype.getCheckSessionIframe=function(){return this._getMetadataProperty("check_session_iframe",!0)},e.prototype.getEndSessionEndpoint=function(){return this._getMetadataProperty("end_session_endpoint",!0)},e.prototype.getRevocationEndpoint=function(){return this._getMetadataProperty("revocation_endpoint",!0)},e.prototype.getKeysEndpoint=function(){return this._getMetadataProperty("jwks_uri",!0)},e.prototype._getMetadataProperty=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i.Log.debug("MetadataService.getMetadataProperty for: "+e),this.getMetadata().then(function(r){if(i.Log.debug("MetadataService.getMetadataProperty: metadata recieved"),void 0===r[e]){if(!0===t)return void i.Log.warn("MetadataService.getMetadataProperty: Metadata does not contain optional property "+e);throw i.Log.error("MetadataService.getMetadataProperty: Metadata does not contain property "+e),new Error("Metadata does not contain property "+e)}return r[e]})},e.prototype.getSigningKeys=function(){var e=this;return this._settings.signingKeys?(i.Log.debug("MetadataService.getSigningKeys: Returning signingKeys from settings"),Promise.resolve(this._settings.signingKeys)):this._getMetadataProperty("jwks_uri").then(function(t){return i.Log.debug("MetadataService.getSigningKeys: jwks_uri received",t),e._jsonService.getJson(t).then(function(t){if(i.Log.debug("MetadataService.getSigningKeys: key set received",t),!t.keys)throw i.Log.error("MetadataService.getSigningKeys: Missing keys on keyset"),new Error("Missing keys on keyset");return e._settings.signingKeys=t.keys,e._settings.signingKeys})})},n(e,[{key:"metadataUrl",get:function(){return this._metadataUrl||(this._settings.metadataUrl?this._metadataUrl=this._settings.metadataUrl:(this._metadataUrl=this._settings.authority,this._metadataUrl&&this._metadataUrl.indexOf(s)<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=s))),this._metadataUrl}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.UrlUtility=void 0;var n=r(0),i=r(1);t.UrlUtility=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.addQueryParam=function(e,t,r){return e.indexOf("?")<0&&(e+="?"),"?"!==e[e.length-1]&&(e+="&"),e+=encodeURIComponent(t),(e+="=")+encodeURIComponent(r)},e.parseUrlFragment=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.Global;"string"!=typeof e&&(e=r.location.href);var o=e.lastIndexOf(t);o>=0&&(e=e.substr(o+1)),"?"===t&&(o=e.indexOf("#"))>=0&&(e=e.substr(0,o));for(var s,a={},c=/([^&=]+)=([^&]*)/g,u=0;s=c.exec(e);)if(a[decodeURIComponent(s[1])]=decodeURIComponent(s[2].replace(/\+/g," ")),u++>50)return n.Log.error("UrlUtility.parseUrlFragment: response exceeded expected number of parameters",e),{error:"Response exceeded expected number of parameters"};for(var l in a)return a;return{}},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.JoseUtil=void 0;var n=r(26),i=function(e){return e&&e.__esModule?e:{default:e}}(r(33));t.JoseUtil=(0,i.default)({jws:n.jws,KeyUtil:n.KeyUtil,X509:n.X509,crypto:n.crypto,hextob64u:n.hextob64u,b64tohex:n.b64tohex,AllowedSigningAlgs:n.AllowedSigningAlgs})},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.OidcClientSettings=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),o=r(0),s=r(23),a=r(6),c=r(24),u=r(2),l=".well-known/openid-configuration";t.OidcClientSettings=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.authority,i=t.metadataUrl,o=t.metadata,l=t.signingKeys,d=t.metadataSeed,h=t.client_id,f=t.client_secret,p=t.response_type,g=void 0===p?"id_token":p,y=t.scope,v=void 0===y?"openid":y,m=t.redirect_uri,w=t.post_logout_redirect_uri,S=t.client_authentication,_=void 0===S?"client_secret_post":S,b=t.prompt,E=t.display,A=t.max_age,F=t.ui_locales,P=t.acr_values,k=t.resource,I=t.response_mode,x=t.filterProtocolClaims,C=void 0===x||x,T=t.loadUserInfo,R=void 0===T||T,U=t.staleStateAge,O=void 0===U?900:U,D=t.clockSkew,N=void 0===D?300:D,L=t.clockService,H=void 0===L?new s.ClockService:L,j=t.userInfoJwtIssuer,M=void 0===j?"OP":j,K=t.mergeClaims,B=void 0!==K&&K,W=t.stateStore,J=void 0===W?new a.WebStorageStateStore:W,V=t.ResponseValidatorCtor,q=void 0===V?c.ResponseValidator:V,$=t.MetadataServiceCtor,z=void 0===$?u.MetadataService:$,G=t.extraQueryParams,Y=void 0===G?{}:G,X=t.extraTokenParams,Z=void 0===X?{}:X;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._authority=r,this._metadataUrl=i,this._metadata=o,this._metadataSeed=d,this._signingKeys=l,this._client_id=h,this._client_secret=f,this._response_type=g,this._scope=v,this._redirect_uri=m,this._post_logout_redirect_uri=w,this._client_authentication=_,this._prompt=b,this._display=E,this._max_age=A,this._ui_locales=F,this._acr_values=P,this._resource=k,this._response_mode=I,this._filterProtocolClaims=!!C,this._loadUserInfo=!!R,this._staleStateAge=O,this._clockSkew=N,this._clockService=H,this._userInfoJwtIssuer=M,this._mergeClaims=!!B,this._stateStore=J,this._validator=new q(this),this._metadataService=new z(this),this._extraQueryParams="object"===(void 0===Y?"undefined":n(Y))?Y:{},this._extraTokenParams="object"===(void 0===Z?"undefined":n(Z))?Z:{}}return e.prototype.getEpochTime=function(){return this._clockService.getEpochTime()},i(e,[{key:"client_id",get:function(){return this._client_id},set:function(e){if(this._client_id)throw o.Log.error("OidcClientSettings.set_client_id: client_id has already been assigned."),new Error("client_id has already been assigned.");this._client_id=e}},{key:"client_secret",get:function(){return this._client_secret}},{key:"response_type",get:function(){return this._response_type}},{key:"scope",get:function(){return this._scope}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"post_logout_redirect_uri",get:function(){return this._post_logout_redirect_uri}},{key:"client_authentication",get:function(){return this._client_authentication}},{key:"prompt",get:function(){return this._prompt}},{key:"display",get:function(){return this._display}},{key:"max_age",get:function(){return this._max_age}},{key:"ui_locales",get:function(){return this._ui_locales}},{key:"acr_values",get:function(){return this._acr_values}},{key:"resource",get:function(){return this._resource}},{key:"response_mode",get:function(){return this._response_mode}},{key:"authority",get:function(){return this._authority},set:function(e){if(this._authority)throw o.Log.error("OidcClientSettings.set_authority: authority has already been assigned."),new Error("authority has already been assigned.");this._authority=e}},{key:"metadataUrl",get:function(){return this._metadataUrl||(this._metadataUrl=this.authority,this._metadataUrl&&this._metadataUrl.indexOf(l)<0&&("/"!==this._metadataUrl[this._metadataUrl.length-1]&&(this._metadataUrl+="/"),this._metadataUrl+=l)),this._metadataUrl}},{key:"metadata",get:function(){return this._metadata},set:function(e){this._metadata=e}},{key:"metadataSeed",get:function(){return this._metadataSeed},set:function(e){this._metadataSeed=e}},{key:"signingKeys",get:function(){return this._signingKeys},set:function(e){this._signingKeys=e}},{key:"filterProtocolClaims",get:function(){return this._filterProtocolClaims}},{key:"loadUserInfo",get:function(){return this._loadUserInfo}},{key:"staleStateAge",get:function(){return this._staleStateAge}},{key:"clockSkew",get:function(){return this._clockSkew}},{key:"userInfoJwtIssuer",get:function(){return this._userInfoJwtIssuer}},{key:"mergeClaims",get:function(){return this._mergeClaims}},{key:"stateStore",get:function(){return this._stateStore}},{key:"validator",get:function(){return this._validator}},{key:"metadataService",get:function(){return this._metadataService}},{key:"extraQueryParams",get:function(){return this._extraQueryParams},set:function(e){"object"===(void 0===e?"undefined":n(e))?this._extraQueryParams=e:this._extraQueryParams={}}},{key:"extraTokenParams",get:function(){return this._extraTokenParams},set:function(e){"object"===(void 0===e?"undefined":n(e))?this._extraTokenParams=e:this._extraTokenParams={}}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.WebStorageStateStore=void 0;var n=r(0),i=r(1);t.WebStorageStateStore=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.prefix,n=void 0===r?"oidc.":r,o=t.store,s=void 0===o?i.Global.localStorage:o;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._store=s,this._prefix=n}return e.prototype.set=function(e,t){return n.Log.debug("WebStorageStateStore.set",e),e=this._prefix+e,this._store.setItem(e,t),Promise.resolve()},e.prototype.get=function(e){n.Log.debug("WebStorageStateStore.get",e),e=this._prefix+e;var t=this._store.getItem(e);return Promise.resolve(t)},e.prototype.remove=function(e){n.Log.debug("WebStorageStateStore.remove",e),e=this._prefix+e;var t=this._store.getItem(e);return this._store.removeItem(e),Promise.resolve(t)},e.prototype.getAllKeys=function(){n.Log.debug("WebStorageStateStore.getAllKeys");for(var e=[],t=0;t<this._store.length;t++){var r=this._store.key(t);0===r.indexOf(this._prefix)&&e.push(r.substr(this._prefix.length))}return Promise.resolve(e)},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.JsonService=void 0;var n=r(0),i=r(1);t.JsonService=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.Global.XMLHttpRequest,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),t&&Array.isArray(t)?this._contentTypes=t.slice():this._contentTypes=[],this._contentTypes.push("application/json"),n&&this._contentTypes.push("application/jwt"),this._XMLHttpRequest=r,this._jwtHandler=n}return e.prototype.getJson=function(e,t){var r=this;if(!e)throw n.Log.error("JsonService.getJson: No url passed"),new Error("url");return n.Log.debug("JsonService.getJson, url: ",e),new Promise(function(i,o){var s=new r._XMLHttpRequest;s.open("GET",e);var a=r._contentTypes,c=r._jwtHandler;s.onload=function(){if(n.Log.debug("JsonService.getJson: HTTP response received, status",s.status),200===s.status){var t=s.getResponseHeader("Content-Type");if(t){var r=a.find(function(e){if(t.startsWith(e))return!0});if("application/jwt"==r)return void c(s).then(i,o);if(r)try{return void i(JSON.parse(s.responseText))}catch(e){return n.Log.error("JsonService.getJson: Error parsing JSON response",e.message),void o(e)}}o(Error("Invalid response Content-Type: "+t+", from URL: "+e))}else o(Error(s.statusText+" ("+s.status+")"))},s.onerror=function(){n.Log.error("JsonService.getJson: network error"),o(Error("Network Error"))},t&&(n.Log.debug("JsonService.getJson: token passed, setting Authorization header"),s.setRequestHeader("Authorization","Bearer "+t)),s.send()})},e.prototype.postForm=function(e,t,r){var i=this;if(!e)throw n.Log.error("JsonService.postForm: No url passed"),new Error("url");return n.Log.debug("JsonService.postForm, url: ",e),new Promise(function(o,s){var a=new i._XMLHttpRequest;a.open("POST",e);var c=i._contentTypes;a.onload=function(){if(n.Log.debug("JsonService.postForm: HTTP response received, status",a.status),200!==a.status){if(400===a.status&&(r=a.getResponseHeader("Content-Type"))&&c.find(function(e){if(r.startsWith(e))return!0}))try{var t=JSON.parse(a.responseText);if(t&&t.error)return n.Log.error("JsonService.postForm: Error from server: ",t.error),void s(new Error(t.error))}catch(e){return n.Log.error("JsonService.postForm: Error parsing JSON response",e.message),void s(e)}s(Error(a.statusText+" ("+a.status+")"))}else{var r;if((r=a.getResponseHeader("Content-Type"))&&c.find(function(e){if(r.startsWith(e))return!0}))try{return void o(JSON.parse(a.responseText))}catch(e){return n.Log.error("JsonService.postForm: Error parsing JSON response",e.message),void s(e)}s(Error("Invalid response Content-Type: "+r+", from URL: "+e))}},a.onerror=function(){n.Log.error("JsonService.postForm: network error"),s(Error("Network Error"))};var u="";for(var l in t){var d=t[l];d&&(u.length>0&&(u+="&"),u+=encodeURIComponent(l),u+="=",u+=encodeURIComponent(d))}a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),void 0!==r&&a.setRequestHeader("Authorization","Basic "+btoa(r)),a.send(u)})},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SigninRequest=void 0;var n=r(0),i=r(3),o=r(13);t.SigninRequest=function(){function e(t){var r=t.url,s=t.client_id,a=t.redirect_uri,c=t.response_type,u=t.scope,l=t.authority,d=t.data,h=t.prompt,f=t.display,p=t.max_age,g=t.ui_locales,y=t.id_token_hint,v=t.login_hint,m=t.acr_values,w=t.resource,S=t.response_mode,_=t.request,b=t.request_uri,E=t.extraQueryParams,A=t.request_type,F=t.client_secret,P=t.extraTokenParams,k=t.skipUserInfo;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw n.Log.error("SigninRequest.ctor: No url passed"),new Error("url");if(!s)throw n.Log.error("SigninRequest.ctor: No client_id passed"),new Error("client_id");if(!a)throw n.Log.error("SigninRequest.ctor: No redirect_uri passed"),new Error("redirect_uri");if(!c)throw n.Log.error("SigninRequest.ctor: No response_type passed"),new Error("response_type");if(!u)throw n.Log.error("SigninRequest.ctor: No scope passed"),new Error("scope");if(!l)throw n.Log.error("SigninRequest.ctor: No authority passed"),new Error("authority");var I=e.isOidc(c),x=e.isCode(c);S||(S=e.isCode(c)?"query":null),this.state=new o.SigninState({nonce:I,data:d,client_id:s,authority:l,redirect_uri:a,code_verifier:x,request_type:A,response_mode:S,client_secret:F,scope:u,extraTokenParams:P,skipUserInfo:k}),r=i.UrlUtility.addQueryParam(r,"client_id",s),r=i.UrlUtility.addQueryParam(r,"redirect_uri",a),r=i.UrlUtility.addQueryParam(r,"response_type",c),r=i.UrlUtility.addQueryParam(r,"scope",u),r=i.UrlUtility.addQueryParam(r,"state",this.state.id),I&&(r=i.UrlUtility.addQueryParam(r,"nonce",this.state.nonce)),x&&(r=i.UrlUtility.addQueryParam(r,"code_challenge",this.state.code_challenge),r=i.UrlUtility.addQueryParam(r,"code_challenge_method","S256"));var C={prompt:h,display:f,max_age:p,ui_locales:g,id_token_hint:y,login_hint:v,acr_values:m,resource:w,request:_,request_uri:b,response_mode:S};for(var T in C)C[T]&&(r=i.UrlUtility.addQueryParam(r,T,C[T]));for(var R in E)r=i.UrlUtility.addQueryParam(r,R,E[R]);this.url=r}return e.isOidc=function(e){return!!e.split(/\s+/g).filter(function(e){return"id_token"===e})[0]},e.isOAuth=function(e){return!!e.split(/\s+/g).filter(function(e){return"token"===e})[0]},e.isCode=function(e){return!!e.split(/\s+/g).filter(function(e){return"code"===e})[0]},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.State=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=function(e){return e&&e.__esModule?e:{default:e}}(r(14));t.State=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.id,n=t.data,i=t.created,s=t.request_type;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._id=r||(0,o.default)(),this._data=n,this._created="number"==typeof i&&i>0?i:parseInt(Date.now()/1e3),this._request_type=s}return e.prototype.toStorageString=function(){return i.Log.debug("State.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type})},e.fromStorageString=function(t){return i.Log.debug("State.fromStorageString"),new e(JSON.parse(t))},e.clearStaleState=function(t,r){var n=Date.now()/1e3-r;return t.getAllKeys().then(function(r){i.Log.debug("State.clearStaleState: got keys",r);for(var o=[],s=function(s){var a=r[s];c=t.get(a).then(function(r){var o=!1;if(r)try{var s=e.fromStorageString(r);i.Log.debug("State.clearStaleState: got item from key: ",a,s.created),s.created<=n&&(o=!0)}catch(e){i.Log.error("State.clearStaleState: Error parsing state for key",a,e.message),o=!0}else i.Log.debug("State.clearStaleState: no item in storage for key: ",a),o=!0;if(o)return i.Log.debug("State.clearStaleState: removed item for key: ",a),t.remove(a)}),o.push(c)},a=0;a<r.length;a++){var c;s(a)}return i.Log.debug("State.clearStaleState: waiting on promise count:",o.length),Promise.all(o)})},n(e,[{key:"id",get:function(){return this._id}},{key:"data",get:function(){return this._data}},{key:"created",get:function(){return this._created}},{key:"request_type",get:function(){return this._request_type}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.OidcClient=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(5),s=r(12),a=r(8),c=r(34),u=r(35),l=r(36),d=r(13),h=r(9);t.OidcClient=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),t instanceof o.OidcClientSettings?this._settings=t:this._settings=new o.OidcClientSettings(t)}return e.prototype.createSigninRequest=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.response_type,n=t.scope,o=t.redirect_uri,s=t.data,c=t.state,u=t.prompt,l=t.display,d=t.max_age,h=t.ui_locales,f=t.id_token_hint,p=t.login_hint,g=t.acr_values,y=t.resource,v=t.request,m=t.request_uri,w=t.response_mode,S=t.extraQueryParams,_=t.extraTokenParams,b=t.request_type,E=t.skipUserInfo,A=arguments[1];i.Log.debug("OidcClient.createSigninRequest");var F=this._settings.client_id;r=r||this._settings.response_type,n=n||this._settings.scope,o=o||this._settings.redirect_uri,u=u||this._settings.prompt,l=l||this._settings.display,d=d||this._settings.max_age,h=h||this._settings.ui_locales,g=g||this._settings.acr_values,y=y||this._settings.resource,w=w||this._settings.response_mode,S=S||this._settings.extraQueryParams,_=_||this._settings.extraTokenParams;var P=this._settings.authority;return a.SigninRequest.isCode(r)&&"code"!==r?Promise.reject(new Error("OpenID Connect hybrid flow is not supported")):this._metadataService.getAuthorizationEndpoint().then(function(t){i.Log.debug("OidcClient.createSigninRequest: Received authorization endpoint",t);var k=new a.SigninRequest({url:t,client_id:F,redirect_uri:o,response_type:r,scope:n,data:s||c,authority:P,prompt:u,display:l,max_age:d,ui_locales:h,id_token_hint:f,login_hint:p,acr_values:g,resource:y,request:v,request_uri:m,extraQueryParams:S,extraTokenParams:_,request_type:b,response_mode:w,client_secret:e._settings.client_secret,skipUserInfo:E}),I=k.state;return(A=A||e._stateStore).set(I.id,I.toStorageString()).then(function(){return k})})},e.prototype.readSigninResponseState=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i.Log.debug("OidcClient.readSigninResponseState");var n="query"===this._settings.response_mode||!this._settings.response_mode&&a.SigninRequest.isCode(this._settings.response_type)?"?":"#",o=new c.SigninResponse(e,n);return o.state?(t=t||this._stateStore,(r?t.remove.bind(t):t.get.bind(t))(o.state).then(function(e){if(!e)throw i.Log.error("OidcClient.readSigninResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:d.SigninState.fromStorageString(e),response:o}})):(i.Log.error("OidcClient.readSigninResponseState: No state in response"),Promise.reject(new Error("No state in response")))},e.prototype.processSigninResponse=function(e,t){var r=this;return i.Log.debug("OidcClient.processSigninResponse"),this.readSigninResponseState(e,t,!0).then(function(e){var t=e.state,n=e.response;return i.Log.debug("OidcClient.processSigninResponse: Received state from storage; validating response"),r._validator.validateSigninResponse(t,n)})},e.prototype.createSignoutRequest=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.id_token_hint,n=t.data,o=t.state,s=t.post_logout_redirect_uri,a=t.extraQueryParams,c=t.request_type,l=arguments[1];return i.Log.debug("OidcClient.createSignoutRequest"),s=s||this._settings.post_logout_redirect_uri,a=a||this._settings.extraQueryParams,this._metadataService.getEndSessionEndpoint().then(function(t){if(!t)throw i.Log.error("OidcClient.createSignoutRequest: No end session endpoint url returned"),new Error("no end session endpoint");i.Log.debug("OidcClient.createSignoutRequest: Received end session endpoint",t);var d=new u.SignoutRequest({url:t,id_token_hint:r,post_logout_redirect_uri:s,data:n||o,extraQueryParams:a,request_type:c}),h=d.state;return h&&(i.Log.debug("OidcClient.createSignoutRequest: Signout request has state to persist"),(l=l||e._stateStore).set(h.id,h.toStorageString())),d})},e.prototype.readSignoutResponseState=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];i.Log.debug("OidcClient.readSignoutResponseState");var n=new l.SignoutResponse(e);if(!n.state)return i.Log.debug("OidcClient.readSignoutResponseState: No state in response"),n.error?(i.Log.warn("OidcClient.readSignoutResponseState: Response was error: ",n.error),Promise.reject(new s.ErrorResponse(n))):Promise.resolve({state:void 0,response:n});var o=n.state;return t=t||this._stateStore,(r?t.remove.bind(t):t.get.bind(t))(o).then(function(e){if(!e)throw i.Log.error("OidcClient.readSignoutResponseState: No matching state found in storage"),new Error("No matching state found in storage");return{state:h.State.fromStorageString(e),response:n}})},e.prototype.processSignoutResponse=function(e,t){var r=this;return i.Log.debug("OidcClient.processSignoutResponse"),this.readSignoutResponseState(e,t,!0).then(function(e){var t=e.state,n=e.response;return t?(i.Log.debug("OidcClient.processSignoutResponse: Received state from storage; validating response"),r._validator.validateSignoutResponse(t,n)):(i.Log.debug("OidcClient.processSignoutResponse: No state from storage; skipping validating response"),n)})},e.prototype.clearStaleState=function(e){return i.Log.debug("OidcClient.clearStaleState"),e=e||this._stateStore,h.State.clearStaleState(e,this.settings.staleStateAge)},n(e,[{key:"_stateStore",get:function(){return this.settings.stateStore}},{key:"_validator",get:function(){return this.settings.validator}},{key:"_metadataService",get:function(){return this.settings.metadataService}},{key:"settings",get:function(){return this._settings}},{key:"metadataService",get:function(){return this._metadataService}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.TokenClient=void 0;var n=r(7),i=r(2),o=r(0);t.TokenClient=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.JsonService,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.MetadataService;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw o.Log.error("TokenClient.ctor: No settings passed"),new Error("settings");this._settings=t,this._jsonService=new r,this._metadataService=new s(this._settings)}return e.prototype.exchangeCode=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(t=Object.assign({},t)).grant_type=t.grant_type||"authorization_code",t.client_id=t.client_id||this._settings.client_id,t.client_secret=t.client_secret||this._settings.client_secret,t.redirect_uri=t.redirect_uri||this._settings.redirect_uri;var r=void 0,n=t._client_authentication||this._settings._client_authentication;return delete t._client_authentication,t.code?t.redirect_uri?t.code_verifier?t.client_id?t.client_secret||"client_secret_basic"!=n?("client_secret_basic"==n&&(r=t.client_id+":"+t.client_secret,delete t.client_id,delete t.client_secret),this._metadataService.getTokenEndpoint(!1).then(function(n){return o.Log.debug("TokenClient.exchangeCode: Received token endpoint"),e._jsonService.postForm(n,t,r).then(function(e){return o.Log.debug("TokenClient.exchangeCode: response received"),e})})):(o.Log.error("TokenClient.exchangeCode: No client_secret passed"),Promise.reject(new Error("A client_secret is required"))):(o.Log.error("TokenClient.exchangeCode: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(o.Log.error("TokenClient.exchangeCode: No code_verifier passed"),Promise.reject(new Error("A code_verifier is required"))):(o.Log.error("TokenClient.exchangeCode: No redirect_uri passed"),Promise.reject(new Error("A redirect_uri is required"))):(o.Log.error("TokenClient.exchangeCode: No code passed"),Promise.reject(new Error("A code is required")))},e.prototype.exchangeRefreshToken=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(t=Object.assign({},t)).grant_type=t.grant_type||"refresh_token",t.client_id=t.client_id||this._settings.client_id,t.client_secret=t.client_secret||this._settings.client_secret;var r=void 0,n=t._client_authentication||this._settings._client_authentication;return delete t._client_authentication,t.refresh_token?t.client_id?("client_secret_basic"==n&&(r=t.client_id+":"+t.client_secret,delete t.client_id,delete t.client_secret),this._metadataService.getTokenEndpoint(!1).then(function(n){return o.Log.debug("TokenClient.exchangeRefreshToken: Received token endpoint"),e._jsonService.postForm(n,t,r).then(function(e){return o.Log.debug("TokenClient.exchangeRefreshToken: response received"),e})})):(o.Log.error("TokenClient.exchangeRefreshToken: No client_id passed"),Promise.reject(new Error("A client_id is required"))):(o.Log.error("TokenClient.exchangeRefreshToken: No refresh_token passed"),Promise.reject(new Error("A refresh_token is required")))},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorResponse=void 0;var n=r(0);t.ErrorResponse=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=r.error,o=r.error_description,s=r.error_uri,a=r.state,c=r.session_state;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),!i)throw n.Log.error("No error passed to ErrorResponse"),new Error("error");var u=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,o||i));return u.name="ErrorResponse",u.error=i,u.error_description=o,u.error_uri=s,u.state=a,u.session_state=c,u}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t}(Error)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SigninState=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(9),s=r(4),a=function(e){return e&&e.__esModule?e:{default:e}}(r(14));t.SigninState=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.nonce,i=r.authority,o=r.client_id,c=r.redirect_uri,u=r.code_verifier,l=r.response_mode,d=r.client_secret,h=r.scope,f=r.extraTokenParams,p=r.skipUserInfo;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var g=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,arguments[0]));if(!0===n?g._nonce=(0,a.default)():n&&(g._nonce=n),!0===u?g._code_verifier=(0,a.default)()+(0,a.default)()+(0,a.default)():u&&(g._code_verifier=u),g.code_verifier){var y=s.JoseUtil.hashString(g.code_verifier,"SHA256");g._code_challenge=s.JoseUtil.hexToBase64Url(y)}return g._redirect_uri=c,g._authority=i,g._client_id=o,g._response_mode=l,g._client_secret=d,g._scope=h,g._extraTokenParams=f,g._skipUserInfo=p,g}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.toStorageString=function(){return i.Log.debug("SigninState.toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,nonce:this.nonce,code_verifier:this.code_verifier,redirect_uri:this.redirect_uri,authority:this.authority,client_id:this.client_id,response_mode:this.response_mode,client_secret:this.client_secret,scope:this.scope,extraTokenParams:this.extraTokenParams,skipUserInfo:this.skipUserInfo})},t.fromStorageString=function(e){return i.Log.debug("SigninState.fromStorageString"),new t(JSON.parse(e))},n(t,[{key:"nonce",get:function(){return this._nonce}},{key:"authority",get:function(){return this._authority}},{key:"client_id",get:function(){return this._client_id}},{key:"redirect_uri",get:function(){return this._redirect_uri}},{key:"code_verifier",get:function(){return this._code_verifier}},{key:"code_challenge",get:function(){return this._code_challenge}},{key:"response_mode",get:function(){return this._response_mode}},{key:"client_secret",get:function(){return this._client_secret}},{key:"scope",get:function(){return this._scope}},{key:"extraTokenParams",get:function(){return this._extraTokenParams}},{key:"skipUserInfo",get:function(){return this._skipUserInfo}}]),t}(o.State)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){return("undefined"!=n&&null!==n&&void 0!==n.getRandomValues?i:o)().replace(/-/g,"")};var n="undefined"!=typeof window?window.crypto||window.msCrypto:null;function i(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(e){return(e^n.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)})}function o(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(e){return(e^16*Math.random()>>e/4).toString(16)})}e.exports=t.default},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.User=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.User=function(){function e(t){var r=t.id_token,n=t.session_state,i=t.access_token,o=t.refresh_token,s=t.token_type,a=t.scope,c=t.profile,u=t.expires_at,l=t.state;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.id_token=r,this.session_state=n,this.access_token=i,this.refresh_token=o,this.token_type=s,this.scope=a,this.profile=c,this.expires_at=u,this.state=l}return e.prototype.toStorageString=function(){return i.Log.debug("User.toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})},e.fromStorageString=function(t){return i.Log.debug("User.fromStorageString"),new e(JSON.parse(t))},n(e,[{key:"expires_in",get:function(){if(this.expires_at){var e=parseInt(Date.now()/1e3);return this.expires_at-e}},set:function(e){var t=parseInt(e);if("number"==typeof t&&t>0){var r=parseInt(Date.now()/1e3);this.expires_at=r+t}}},{key:"expired",get:function(){var e=this.expires_in;if(void 0!==e)return e<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.AccessTokenEvents=void 0;var n=r(0),i=r(46);t.AccessTokenEvents=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.accessTokenExpiringNotificationTime,n=void 0===r?60:r,o=t.accessTokenExpiringTimer,s=void 0===o?new i.Timer("Access token expiring"):o,a=t.accessTokenExpiredTimer,c=void 0===a?new i.Timer("Access token expired"):a;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._accessTokenExpiringNotificationTime=n,this._accessTokenExpiring=s,this._accessTokenExpired=c}return e.prototype.load=function(e){if(e.access_token&&void 0!==e.expires_in){var t=e.expires_in;if(n.Log.debug("AccessTokenEvents.load: access token present, remaining duration:",t),t>0){var r=t-this._accessTokenExpiringNotificationTime;r<=0&&(r=1),n.Log.debug("AccessTokenEvents.load: registering expiring timer in:",r),this._accessTokenExpiring.init(r)}else n.Log.debug("AccessTokenEvents.load: canceling existing expiring timer becase we're past expiration."),this._accessTokenExpiring.cancel();var i=t+1;n.Log.debug("AccessTokenEvents.load: registering expired timer in:",i),this._accessTokenExpired.init(i)}else this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},e.prototype.unload=function(){n.Log.debug("AccessTokenEvents.unload: canceling existing access token timers"),this._accessTokenExpiring.cancel(),this._accessTokenExpired.cancel()},e.prototype.addAccessTokenExpiring=function(e){this._accessTokenExpiring.addHandler(e)},e.prototype.removeAccessTokenExpiring=function(e){this._accessTokenExpiring.removeHandler(e)},e.prototype.addAccessTokenExpired=function(e){this._accessTokenExpired.addHandler(e)},e.prototype.removeAccessTokenExpired=function(e){this._accessTokenExpired.removeHandler(e)},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;var n=r(0);t.Event=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._name=t,this._callbacks=[]}return e.prototype.addHandler=function(e){this._callbacks.push(e)},e.prototype.removeHandler=function(e){var t=this._callbacks.findIndex(function(t){return t===e});t>=0&&this._callbacks.splice(t,1)},e.prototype.raise=function(){n.Log.debug("Event: Raising event: "+this._name);for(var e=0;e<this._callbacks.length;e++){var t;(t=this._callbacks)[e].apply(t,arguments)}},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SessionMonitor=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(19),s=r(1);t.SessionMonitor=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.CheckSessionIFrame,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.Global.timer;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("SessionMonitor.ctor: No user manager passed to SessionMonitor"),new Error("userManager");this._userManager=t,this._CheckSessionIFrameCtor=n,this._timer=a,this._userManager.events.addUserLoaded(this._start.bind(this)),this._userManager.events.addUserUnloaded(this._stop.bind(this)),Promise.resolve(this._userManager.getUser().then(function(e){e?r._start(e):r._settings.monitorAnonymousSession&&r._userManager.querySessionStatus().then(function(e){var t={session_state:e.session_state};e.sub&&e.sid&&(t.profile={sub:e.sub,sid:e.sid}),r._start(t)}).catch(function(e){i.Log.error("SessionMonitor ctor: error from querySessionStatus:",e.message)})}).catch(function(e){i.Log.error("SessionMonitor ctor: error from getUser:",e.message)}))}return e.prototype._start=function(e){var t=this,r=e.session_state;r&&(e.profile?(this._sub=e.profile.sub,this._sid=e.profile.sid,i.Log.debug("SessionMonitor._start: session_state:",r,", sub:",this._sub)):(this._sub=void 0,this._sid=void 0,i.Log.debug("SessionMonitor._start: session_state:",r,", anonymous user")),this._checkSessionIFrame?this._checkSessionIFrame.start(r):this._metadataService.getCheckSessionIframe().then(function(e){if(e){i.Log.debug("SessionMonitor._start: Initializing check session iframe");var n=t._client_id,o=t._checkSessionInterval,s=t._stopCheckSessionOnError;t._checkSessionIFrame=new t._CheckSessionIFrameCtor(t._callback.bind(t),n,e,o,s),t._checkSessionIFrame.load().then(function(){t._checkSessionIFrame.start(r)})}else i.Log.warn("SessionMonitor._start: No check session iframe found in the metadata")}).catch(function(e){i.Log.error("SessionMonitor._start: Error from getCheckSessionIframe:",e.message)}))},e.prototype._stop=function(){var e=this;if(this._sub=void 0,this._sid=void 0,this._checkSessionIFrame&&(i.Log.debug("SessionMonitor._stop"),this._checkSessionIFrame.stop()),this._settings.monitorAnonymousSession)var t=this._timer.setInterval(function(){e._timer.clearInterval(t),e._userManager.querySessionStatus().then(function(t){var r={session_state:t.session_state};t.sub&&t.sid&&(r.profile={sub:t.sub,sid:t.sid}),e._start(r)}).catch(function(e){i.Log.error("SessionMonitor: error from querySessionStatus:",e.message)})},1e3)},e.prototype._callback=function(){var e=this;this._userManager.querySessionStatus().then(function(t){var r=!0;t?t.sub===e._sub?(r=!1,e._checkSessionIFrame.start(t.session_state),t.sid===e._sid?i.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",t.session_state):(i.Log.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",t.session_state),e._userManager.events._raiseUserSessionChanged())):i.Log.debug("SessionMonitor._callback: Different subject signed into OP:",t.sub):i.Log.debug("SessionMonitor._callback: Subject no longer signed into OP"),r&&(e._sub?(i.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed out event"),e._userManager.events._raiseUserSignedOut()):(i.Log.debug("SessionMonitor._callback: SessionMonitor._callback; raising signed in event"),e._userManager.events._raiseUserSignedIn()))}).catch(function(t){e._sub&&(i.Log.debug("SessionMonitor._callback: Error calling queryCurrentSigninSession; raising signed out event",t.message),e._userManager.events._raiseUserSignedOut())})},n(e,[{key:"_settings",get:function(){return this._userManager.settings}},{key:"_metadataService",get:function(){return this._userManager.metadataService}},{key:"_client_id",get:function(){return this._settings.client_id}},{key:"_checkSessionInterval",get:function(){return this._settings.checkSessionInterval}},{key:"_stopCheckSessionOnError",get:function(){return this._settings.stopCheckSessionOnError}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CheckSessionIFrame=void 0;var n=r(0);t.CheckSessionIFrame=function(){function e(t,r,n,i){var o=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),this._callback=t,this._client_id=r,this._url=n,this._interval=i||2e3,this._stopOnError=o;var s=n.indexOf("/",n.indexOf("//")+2);this._frame_origin=n.substr(0,s),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=n}return e.prototype.load=function(){var e=this;return new Promise(function(t){e._frame.onload=function(){t()},window.document.body.appendChild(e._frame),e._boundMessageEvent=e._message.bind(e),window.addEventListener("message",e._boundMessageEvent,!1)})},e.prototype._message=function(e){e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(n.Log.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(n.Log.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):n.Log.debug("CheckSessionIFrame: "+e.data+" message from check session op iframe"))},e.prototype.start=function(e){var t=this;if(this._session_state!==e){n.Log.debug("CheckSessionIFrame.start"),this.stop(),this._session_state=e;var r=function(){t._frame.contentWindow.postMessage(t._client_id+" "+t._session_state,t._frame_origin)};r(),this._timer=window.setInterval(r,this._interval)}},e.prototype.stop=function(){this._session_state=null,this._timer&&(n.Log.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.TokenRevocationClient=void 0;var n=r(0),i=r(2),o=r(1);t.TokenRevocationClient=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.XMLHttpRequest,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.MetadataService;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw n.Log.error("TokenRevocationClient.ctor: No settings provided"),new Error("No settings provided.");this._settings=t,this._XMLHttpRequestCtor=r,this._metadataService=new s(this._settings)}return e.prototype.revoke=function(e,t){var r=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"access_token";if(!e)throw n.Log.error("TokenRevocationClient.revoke: No token provided"),new Error("No token provided.");if("access_token"!==i&&"refresh_token"!=i)throw n.Log.error("TokenRevocationClient.revoke: Invalid token type"),new Error("Invalid token type.");return this._metadataService.getRevocationEndpoint().then(function(o){if(o){n.Log.debug("TokenRevocationClient.revoke: Revoking "+i);var s=r._settings.client_id,a=r._settings.client_secret;return r._revoke(o,s,a,e,i)}if(t)throw n.Log.error("TokenRevocationClient.revoke: Revocation not supported"),new Error("Revocation not supported")})},e.prototype._revoke=function(e,t,r,i,o){var s=this;return new Promise(function(a,c){var u=new s._XMLHttpRequestCtor;u.open("POST",e),u.onload=function(){n.Log.debug("TokenRevocationClient.revoke: HTTP response received, status",u.status),200===u.status?a():c(Error(u.statusText+" ("+u.status+")"))},u.onerror=function(){n.Log.debug("TokenRevocationClient.revoke: Network Error."),c("Network Error")};var l="client_id="+encodeURIComponent(t);r&&(l+="&client_secret="+encodeURIComponent(r)),l+="&token_type_hint="+encodeURIComponent(o),l+="&token="+encodeURIComponent(i),u.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),u.send(l)})},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaPopupWindow=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.CordovaPopupWindow=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t}),this.features=t.popupWindowFeatures||"location=no,toolbar=no,zoom=no",this.target=t.popupWindowTarget||"_blank",this.redirect_uri=t.startUrl,i.Log.debug("CordovaPopupWindow.ctor: redirect_uri: "+this.redirect_uri)}return e.prototype._isInAppBrowserInstalled=function(e){return["cordova-plugin-inappbrowser","cordova-plugin-inappbrowser.inappbrowser","org.apache.cordova.inappbrowser"].some(function(t){return e.hasOwnProperty(t)})},e.prototype.navigate=function(e){if(e&&e.url){if(!window.cordova)return this._error("cordova is undefined");var t=window.cordova.require("cordova/plugin_list").metadata;if(!1===this._isInAppBrowserInstalled(t))return this._error("InAppBrowser plugin not found");this._popup=cordova.InAppBrowser.open(e.url,this.target,this.features),this._popup?(i.Log.debug("CordovaPopupWindow.navigate: popup successfully created"),this._exitCallbackEvent=this._exitCallback.bind(this),this._loadStartCallbackEvent=this._loadStartCallback.bind(this),this._popup.addEventListener("exit",this._exitCallbackEvent,!1),this._popup.addEventListener("loadstart",this._loadStartCallbackEvent,!1)):this._error("Error opening popup window")}else this._error("No url provided");return this.promise},e.prototype._loadStartCallback=function(e){0===e.url.indexOf(this.redirect_uri)&&this._success({url:e.url})},e.prototype._exitCallback=function(e){this._error(e)},e.prototype._success=function(e){this._cleanup(),i.Log.debug("CordovaPopupWindow: Successful response from cordova popup window"),this._resolve(e)},e.prototype._error=function(e){this._cleanup(),i.Log.error(e),this._reject(new Error(e))},e.prototype.close=function(){this._cleanup()},e.prototype._cleanup=function(){this._popup&&(i.Log.debug("CordovaPopupWindow: cleaning up popup"),this._popup.removeEventListener("exit",this._exitCallbackEvent,!1),this._popup.removeEventListener("loadstart",this._loadStartCallbackEvent,!1),this._popup.close()),this._popup=null},n(e,[{key:"promise",get:function(){return this._promise}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(10),o=r(5),s=r(6),a=r(37),c=r(38),u=r(16),l=r(2),d=r(48),h=r(49),f=r(19),p=r(20),g=r(18),y=r(1),v=r(15),m=r(50);t.default={Version:m.Version,Log:n.Log,OidcClient:i.OidcClient,OidcClientSettings:o.OidcClientSettings,WebStorageStateStore:s.WebStorageStateStore,InMemoryWebStorage:a.InMemoryWebStorage,UserManager:c.UserManager,AccessTokenEvents:u.AccessTokenEvents,MetadataService:l.MetadataService,CordovaPopupNavigator:d.CordovaPopupNavigator,CordovaIFrameNavigator:h.CordovaIFrameNavigator,CheckSessionIFrame:f.CheckSessionIFrame,TokenRevocationClient:p.TokenRevocationClient,SessionMonitor:g.SessionMonitor,Global:y.Global,User:v.User},e.exports=t.default},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ClockService=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.getEpochTime=function(){return Promise.resolve(Date.now()/1e3|0)},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ResponseValidator=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=r(0),o=r(2),s=r(25),a=r(11),c=r(12),u=r(4),l=["nonce","at_hash","iat","nbf","exp","aud","iss","c_hash"];t.ResponseValidator=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.MetadataService,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:s.UserInfoService,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:u.JoseUtil,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:a.TokenClient;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw i.Log.error("ResponseValidator.ctor: No settings passed to ResponseValidator"),new Error("settings");this._settings=t,this._metadataService=new r(this._settings),this._userInfoService=new n(this._settings),this._joseUtil=c,this._tokenClient=new l(this._settings)}return e.prototype.validateSigninResponse=function(e,t){var r=this;return i.Log.debug("ResponseValidator.validateSigninResponse"),this._processSigninParams(e,t).then(function(t){return i.Log.debug("ResponseValidator.validateSigninResponse: state processed"),r._validateTokens(e,t).then(function(t){return i.Log.debug("ResponseValidator.validateSigninResponse: tokens validated"),r._processClaims(e,t).then(function(e){return i.Log.debug("ResponseValidator.validateSigninResponse: claims processed"),e})})})},e.prototype.validateSignoutResponse=function(e,t){return e.id!==t.state?(i.Log.error("ResponseValidator.validateSignoutResponse: State does not match"),Promise.reject(new Error("State does not match"))):(i.Log.debug("ResponseValidator.validateSignoutResponse: state validated"),t.state=e.data,t.error?(i.Log.warn("ResponseValidator.validateSignoutResponse: Response was error",t.error),Promise.reject(new c.ErrorResponse(t))):Promise.resolve(t))},e.prototype._processSigninParams=function(e,t){if(e.id!==t.state)return i.Log.error("ResponseValidator._processSigninParams: State does not match"),Promise.reject(new Error("State does not match"));if(!e.client_id)return i.Log.error("ResponseValidator._processSigninParams: No client_id on state"),Promise.reject(new Error("No client_id on state"));if(!e.authority)return i.Log.error("ResponseValidator._processSigninParams: No authority on state"),Promise.reject(new Error("No authority on state"));if(this._settings.authority){if(this._settings.authority&&this._settings.authority!==e.authority)return i.Log.error("ResponseValidator._processSigninParams: authority mismatch on settings vs. signin state"),Promise.reject(new Error("authority mismatch on settings vs. signin state"))}else this._settings.authority=e.authority;if(this._settings.client_id){if(this._settings.client_id&&this._settings.client_id!==e.client_id)return i.Log.error("ResponseValidator._processSigninParams: client_id mismatch on settings vs. signin state"),Promise.reject(new Error("client_id mismatch on settings vs. signin state"))}else this._settings.client_id=e.client_id;return i.Log.debug("ResponseValidator._processSigninParams: state validated"),t.state=e.data,t.error?(i.Log.warn("ResponseValidator._processSigninParams: Response was error",t.error),Promise.reject(new c.ErrorResponse(t))):e.nonce&&!t.id_token?(i.Log.error("ResponseValidator._processSigninParams: Expecting id_token in response"),Promise.reject(new Error("No id_token in response"))):!e.nonce&&t.id_token?(i.Log.error("ResponseValidator._processSigninParams: Not expecting id_token in response"),Promise.reject(new Error("Unexpected id_token in response"))):e.code_verifier&&!t.code?(i.Log.error("ResponseValidator._processSigninParams: Expecting code in response"),Promise.reject(new Error("No code in response"))):!e.code_verifier&&t.code?(i.Log.error("ResponseValidator._processSigninParams: Not expecting code in response"),Promise.reject(new Error("Unexpected code in response"))):(t.scope||(t.scope=e.scope),Promise.resolve(t))},e.prototype._processClaims=function(e,t){var r=this;if(t.isOpenIdConnect){if(i.Log.debug("ResponseValidator._processClaims: response is OIDC, processing claims"),t.profile=this._filterProtocolClaims(t.profile),!0!==e.skipUserInfo&&this._settings.loadUserInfo&&t.access_token)return i.Log.debug("ResponseValidator._processClaims: loading user info"),this._userInfoService.getClaims(t.access_token).then(function(e){return i.Log.debug("ResponseValidator._processClaims: user info claims received from user info endpoint"),e.sub!==t.profile.sub?(i.Log.error("ResponseValidator._processClaims: sub from user info endpoint does not match sub in id_token"),Promise.reject(new Error("sub from user info endpoint does not match sub in id_token"))):(t.profile=r._mergeClaims(t.profile,e),i.Log.debug("ResponseValidator._processClaims: user info claims received, updated profile:",t.profile),t)});i.Log.debug("ResponseValidator._processClaims: not loading user info")}else i.Log.debug("ResponseValidator._processClaims: response is not OIDC, not processing claims");return Promise.resolve(t)},e.prototype._mergeClaims=function(e,t){var r=Object.assign({},e);for(var i in t){var o=t[i];Array.isArray(o)||(o=[o]);for(var s=0;s<o.length;s++){var a=o[s];r[i]?Array.isArray(r[i])?r[i].indexOf(a)<0&&r[i].push(a):r[i]!==a&&("object"===(void 0===a?"undefined":n(a))&&this._settings.mergeClaims?r[i]=this._mergeClaims(r[i],a):r[i]=[r[i],a]):r[i]=a}}return r},e.prototype._filterProtocolClaims=function(e){i.Log.debug("ResponseValidator._filterProtocolClaims, incoming claims:",e);var t=Object.assign({},e);return this._settings._filterProtocolClaims?(l.forEach(function(e){delete t[e]}),i.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims filtered",t)):i.Log.debug("ResponseValidator._filterProtocolClaims: protocol claims not filtered"),t},e.prototype._validateTokens=function(e,t){return t.code?(i.Log.debug("ResponseValidator._validateTokens: Validating code"),this._processCode(e,t)):t.id_token?t.access_token?(i.Log.debug("ResponseValidator._validateTokens: Validating id_token and access_token"),this._validateIdTokenAndAccessToken(e,t)):(i.Log.debug("ResponseValidator._validateTokens: Validating id_token"),this._validateIdToken(e,t)):(i.Log.debug("ResponseValidator._validateTokens: No code to process or id_token to validate"),Promise.resolve(t))},e.prototype._processCode=function(e,t){var r=this,o={client_id:e.client_id,client_secret:e.client_secret,code:t.code,redirect_uri:e.redirect_uri,code_verifier:e.code_verifier};return e.extraTokenParams&&"object"===n(e.extraTokenParams)&&Object.assign(o,e.extraTokenParams),this._tokenClient.exchangeCode(o).then(function(n){for(var o in n)t[o]=n[o];return t.id_token?(i.Log.debug("ResponseValidator._processCode: token response successful, processing id_token"),r._validateIdTokenAttributes(e,t)):(i.Log.debug("ResponseValidator._processCode: token response successful, returning response"),t)})},e.prototype._validateIdTokenAttributes=function(e,t){var r=this;return this._metadataService.getIssuer().then(function(n){var o=e.client_id,s=r._settings.clockSkew;return i.Log.debug("ResponseValidator._validateIdTokenAttributes: Validaing JWT attributes; using clock skew (in seconds) of: ",s),r._settings.getEpochTime().then(function(a){return r._joseUtil.validateJwtAttributes(t.id_token,n,o,s,a).then(function(r){return e.nonce&&e.nonce!==r.nonce?(i.Log.error("ResponseValidator._validateIdTokenAttributes: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):r.sub?(t.profile=r,t):(i.Log.error("ResponseValidator._validateIdTokenAttributes: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))})})})},e.prototype._validateIdTokenAndAccessToken=function(e,t){var r=this;return this._validateIdToken(e,t).then(function(e){return r._validateAccessToken(e)})},e.prototype._getSigningKeyForJwt=function(e){var t=this;return this._metadataService.getSigningKeys().then(function(r){var n=e.header.kid;if(!r)return i.Log.error("ResponseValidator._validateIdToken: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));i.Log.debug("ResponseValidator._validateIdToken: Received signing keys");var o=void 0;if(n)o=r.filter(function(e){return e.kid===n})[0];else{if((r=t._filterByAlg(r,e.header.alg)).length>1)return i.Log.error("ResponseValidator._validateIdToken: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));o=r[0]}return Promise.resolve(o)})},e.prototype._getSigningKeyForJwtWithSingleRetry=function(e){var t=this;return this._getSigningKeyForJwt(e).then(function(r){return r?Promise.resolve(r):(t._metadataService.resetSigningKeys(),t._getSigningKeyForJwt(e))})},e.prototype._validateIdToken=function(e,t){var r=this;if(!e.nonce)return i.Log.error("ResponseValidator._validateIdToken: No nonce on state"),Promise.reject(new Error("No nonce on state"));var n=this._joseUtil.parseJwt(t.id_token);return n&&n.header&&n.payload?e.nonce!==n.payload.nonce?(i.Log.error("ResponseValidator._validateIdToken: Invalid nonce in id_token"),Promise.reject(new Error("Invalid nonce in id_token"))):this._metadataService.getIssuer().then(function(o){return i.Log.debug("ResponseValidator._validateIdToken: Received issuer"),r._getSigningKeyForJwtWithSingleRetry(n).then(function(s){if(!s)return i.Log.error("ResponseValidator._validateIdToken: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var a=e.client_id,c=r._settings.clockSkew;return i.Log.debug("ResponseValidator._validateIdToken: Validaing JWT; using clock skew (in seconds) of: ",c),r._joseUtil.validateJwt(t.id_token,s,o,a,c).then(function(){return i.Log.debug("ResponseValidator._validateIdToken: JWT validation successful"),n.payload.sub?(t.profile=n.payload,t):(i.Log.error("ResponseValidator._validateIdToken: No sub present in id_token"),Promise.reject(new Error("No sub present in id_token")))})})}):(i.Log.error("ResponseValidator._validateIdToken: Failed to parse id_token",n),Promise.reject(new Error("Failed to parse id_token")))},e.prototype._filterByAlg=function(e,t){var r=null;if(t.startsWith("RS"))r="RSA";else if(t.startsWith("PS"))r="PS";else{if(!t.startsWith("ES"))return i.Log.debug("ResponseValidator._filterByAlg: alg not supported: ",t),[];r="EC"}return i.Log.debug("ResponseValidator._filterByAlg: Looking for keys that match kty: ",r),e=e.filter(function(e){return e.kty===r}),i.Log.debug("ResponseValidator._filterByAlg: Number of keys that match kty: ",r,e.length),e},e.prototype._validateAccessToken=function(e){if(!e.profile)return i.Log.error("ResponseValidator._validateAccessToken: No profile loaded from id_token"),Promise.reject(new Error("No profile loaded from id_token"));if(!e.profile.at_hash)return i.Log.error("ResponseValidator._validateAccessToken: No at_hash in id_token"),Promise.reject(new Error("No at_hash in id_token"));if(!e.id_token)return i.Log.error("ResponseValidator._validateAccessToken: No id_token"),Promise.reject(new Error("No id_token"));var t=this._joseUtil.parseJwt(e.id_token);if(!t||!t.header)return i.Log.error("ResponseValidator._validateAccessToken: Failed to parse id_token",t),Promise.reject(new Error("Failed to parse id_token"));var r=t.header.alg;if(!r||5!==r.length)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r),Promise.reject(new Error("Unsupported alg: "+r));var n=r.substr(2,3);if(!n)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r,n),Promise.reject(new Error("Unsupported alg: "+r));if(256!==(n=parseInt(n))&&384!==n&&512!==n)return i.Log.error("ResponseValidator._validateAccessToken: Unsupported alg:",r,n),Promise.reject(new Error("Unsupported alg: "+r));var o="sha"+n,s=this._joseUtil.hashString(e.access_token,o);if(!s)return i.Log.error("ResponseValidator._validateAccessToken: access_token hash failed:",o),Promise.reject(new Error("Failed to validate at_hash"));var a=s.substr(0,s.length/2),c=this._joseUtil.hexToBase64Url(a);return c!==e.profile.at_hash?(i.Log.error("ResponseValidator._validateAccessToken: Failed to validate at_hash",c,e.profile.at_hash),Promise.reject(new Error("Failed to validate at_hash"))):(i.Log.debug("ResponseValidator._validateAccessToken: success"),Promise.resolve(e))},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.UserInfoService=void 0;var n=r(7),i=r(2),o=r(0),s=r(4);t.UserInfoService=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.JsonService,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.MetadataService,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s.JoseUtil;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!t)throw o.Log.error("UserInfoService.ctor: No settings passed"),new Error("settings");this._settings=t,this._jsonService=new r(void 0,void 0,this._getClaimsFromJwt.bind(this)),this._metadataService=new a(this._settings),this._joseUtil=c}return e.prototype.getClaims=function(e){var t=this;return e?this._metadataService.getUserInfoEndpoint().then(function(r){return o.Log.debug("UserInfoService.getClaims: received userinfo url",r),t._jsonService.getJson(r,e).then(function(e){return o.Log.debug("UserInfoService.getClaims: claims received",e),e})}):(o.Log.error("UserInfoService.getClaims: No token passed"),Promise.reject(new Error("A token is required")))},e.prototype._getClaimsFromJwt=function e(t){var r=this;try{var n=this._joseUtil.parseJwt(t.responseText);if(!n||!n.header||!n.payload)return o.Log.error("UserInfoService._getClaimsFromJwt: Failed to parse JWT",n),Promise.reject(new Error("Failed to parse id_token"));var i=n.header.kid,s=void 0;switch(this._settings.userInfoJwtIssuer){case"OP":s=this._metadataService.getIssuer();break;case"ANY":s=Promise.resolve(n.payload.iss);break;default:s=Promise.resolve(this._settings.userInfoJwtIssuer)}return s.then(function(e){return o.Log.debug("UserInfoService._getClaimsFromJwt: Received issuer:"+e),r._metadataService.getSigningKeys().then(function(s){if(!s)return o.Log.error("UserInfoService._getClaimsFromJwt: No signing keys from metadata"),Promise.reject(new Error("No signing keys from metadata"));o.Log.debug("UserInfoService._getClaimsFromJwt: Received signing keys");var a=void 0;if(i)a=s.filter(function(e){return e.kid===i})[0];else{if((s=r._filterByAlg(s,n.header.alg)).length>1)return o.Log.error("UserInfoService._getClaimsFromJwt: No kid found in id_token and more than one key found in metadata"),Promise.reject(new Error("No kid found in id_token and more than one key found in metadata"));a=s[0]}if(!a)return o.Log.error("UserInfoService._getClaimsFromJwt: No key matching kid or alg found in signing keys"),Promise.reject(new Error("No key matching kid or alg found in signing keys"));var c=r._settings.client_id,u=r._settings.clockSkew;return o.Log.debug("UserInfoService._getClaimsFromJwt: Validaing JWT; using clock skew (in seconds) of: ",u),r._joseUtil.validateJwt(t.responseText,a,e,c,u,void 0,!0).then(function(){return o.Log.debug("UserInfoService._getClaimsFromJwt: JWT validation successful"),n.payload})})})}catch(e){return o.Log.error("UserInfoService._getClaimsFromJwt: Error parsing JWT response",e.message),void reject(e)}},e.prototype._filterByAlg=function(e,t){var r=null;if(t.startsWith("RS"))r="RSA";else if(t.startsWith("PS"))r="PS";else{if(!t.startsWith("ES"))return o.Log.debug("UserInfoService._filterByAlg: alg not supported: ",t),[];r="EC"}return o.Log.debug("UserInfoService._filterByAlg: Looking for keys that match kty: ",r),e=e.filter(function(e){return e.kty===r}),o.Log.debug("UserInfoService._filterByAlg: Number of keys that match kty: ",r,e.length),e},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.AllowedSigningAlgs=t.b64tohex=t.hextob64u=t.crypto=t.X509=t.KeyUtil=t.jws=void 0;var n=r(27);t.jws=n.jws,t.KeyUtil=n.KEYUTIL,t.X509=n.X509,t.crypto=n.crypto,t.hextob64u=n.hextob64u,t.b64tohex=n.b64tohex,t.AllowedSigningAlgs=["RS256","RS384","RS512","PS256","PS384","PS512","ES256","ES384","ES512"]},function(e,t,r){(function(e){Object.defineProperty(t,"__esModule",{value:!0});var r,n,i,o,s,a,c,u,l,d,h,f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p={userAgent:!1},g={},y=y||(r=Math,i=(n={}).lib={},o=i.Base=function(){function e(){}return{extend:function(t){e.prototype=this;var r=new e;return t&&r.mixIn(t),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),s=i.WordArray=o.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var s=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=s<<24-(n+o)%4*8}else for(o=0;o<i;o+=4)t[n+o>>>2]=r[o>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=r.ceil(t/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(4294967296*r.random()|0);return new s.init(t,e)}}),a=n.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new s.init(r,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new s.init(r,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},d=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(e){var t=this._data,n=t.words,i=t.sigBytes,o=this.blockSize,a=i/(4*o),c=(a=e?r.ceil(a):r.max((0|a)-this._minBufferSize,0))*o,u=r.min(4*c,i);if(c){for(var l=0;l<c;l+=o)this._doProcessBlock(n,l);var d=n.splice(0,c);t.sigBytes-=u}return new s.init(d,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),i.Hasher=d.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new h.HMAC.init(e,r).finalize(t)}}}),h=n.algo={},n);!function(){var e,t=(e=y).lib,r=t.Base,n=t.WordArray;(e=e.x64={}).Word=r.extend({init:function(e,t){this.high=e,this.low=t}}),e.WordArray=r.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:8*e.length},toX32:function(){for(var e=this.words,t=e.length,r=[],i=0;i<t;i++){var o=e[i];r.push(o.high),r.push(o.low)}return n.create(r,this.sigBytes)},clone:function(){for(var e=r.clone.call(this),t=e.words=this.words.slice(0),n=t.length,i=0;i<n;i++)t[i]=t[i].clone();return e}})}(),function(){var e=y,t=e.lib.WordArray;e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp(),e=[];for(var i=0;i<r;i+=3)for(var o=(t[i>>>2]>>>24-i%4*8&255)<<16|(t[i+1>>>2]>>>24-(i+1)%4*8&255)<<8|t[i+2>>>2]>>>24-(i+2)%4*8&255,s=0;4>s&&i+.75*s<r;s++)e.push(n.charAt(o>>>6*(3-s)&63));if(t=n.charAt(64))for(;e.length%4;)e.push(t);return e.join("")},parse:function(e){var r=e.length,n=this._map;(i=n.charAt(64))&&-1!=(i=e.indexOf(i))&&(r=i);for(var i=[],o=0,s=0;s<r;s++)if(s%4){var a=n.indexOf(e.charAt(s-1))<<s%4*2,c=n.indexOf(e.charAt(s))>>>6-s%4*2;i[o>>>2]|=(a|c)<<24-o%4*8,o++}return t.create(i,o)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(e){for(var t=y,r=(i=t.lib).WordArray,n=i.Hasher,i=t.algo,o=[],s=[],a=function(e){return 4294967296*(e-(0|e))|0},c=2,u=0;64>u;){var l;e:{l=c;for(var d=e.sqrt(l),h=2;h<=d;h++)if(!(l%h)){l=!1;break e}l=!0}l&&(8>u&&(o[u]=a(e.pow(c,.5))),s[u]=a(e.pow(c,1/3)),u++),c++}var f=[];i=i.SHA256=n.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=r[5],l=r[6],d=r[7],h=0;64>h;h++){if(16>h)f[h]=0|e[t+h];else{var p=f[h-15],g=f[h-2];f[h]=((p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3)+f[h-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+f[h-16]}p=d+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&u^~c&l)+s[h]+f[h],g=((n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22))+(n&i^n&o^i&o),d=l,l=u,u=c,c=a+p|0,a=o,o=i,i=n,n=p+g|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0,r[5]=r[5]+u|0,r[6]=r[6]+l|0,r[7]=r[7]+d|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=n.clone.call(this);return e._hash=this._hash.clone(),e}}),t.SHA256=n._createHelper(i),t.HmacSHA256=n._createHmacHelper(i)}(Math),function(){function e(){return n.create.apply(n,arguments)}for(var t=y,r=t.lib.Hasher,n=(o=t.x64).Word,i=o.WordArray,o=t.algo,s=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],a=[],c=0;80>c;c++)a[c]=e();o=o.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(e,t){for(var r=(d=this._hash.words)[0],n=d[1],i=d[2],o=d[3],c=d[4],u=d[5],l=d[6],d=d[7],h=r.high,f=r.low,p=n.high,g=n.low,y=i.high,v=i.low,m=o.high,w=o.low,S=c.high,_=c.low,b=u.high,E=u.low,A=l.high,F=l.low,P=d.high,k=d.low,I=h,x=f,C=p,T=g,R=y,U=v,O=m,D=w,N=S,L=_,H=b,j=E,M=A,K=F,B=P,W=k,J=0;80>J;J++){var V=a[J];if(16>J)var q=V.high=0|e[t+2*J],$=V.low=0|e[t+2*J+1];else{q=(($=(q=a[J-15]).high)>>>1|(z=q.low)<<31)^($>>>8|z<<24)^$>>>7;var z=(z>>>1|$<<31)^(z>>>8|$<<24)^(z>>>7|$<<25),G=(($=(G=a[J-2]).high)>>>19|(Y=G.low)<<13)^($<<3|Y>>>29)^$>>>6,Y=(Y>>>19|$<<13)^(Y<<3|$>>>29)^(Y>>>6|$<<26),X=($=a[J-7]).high,Z=(Q=a[J-16]).high,Q=Q.low;q=(q=(q=q+X+(($=z+$.low)>>>0<z>>>0?1:0))+G+(($+=Y)>>>0<Y>>>0?1:0))+Z+(($+=Q)>>>0<Q>>>0?1:0),V.high=q,V.low=$}X=N&H^~N&M,Q=L&j^~L&K,V=I&C^I&R^C&R;var ee=x&T^x&U^T&U,te=(z=(I>>>28|x<<4)^(I<<30|x>>>2)^(I<<25|x>>>7),G=(x>>>28|I<<4)^(x<<30|I>>>2)^(x<<25|I>>>7),(Y=s[J]).high),re=Y.low;Z=B+((N>>>14|L<<18)^(N>>>18|L<<14)^(N<<23|L>>>9))+((Y=W+((L>>>14|N<<18)^(L>>>18|N<<14)^(L<<23|N>>>9)))>>>0<W>>>0?1:0),B=M,W=K,M=H,K=j,H=N,j=L,N=O+(Z=(Z=(Z=Z+X+((Y+=Q)>>>0<Q>>>0?1:0))+te+((Y+=re)>>>0<re>>>0?1:0))+q+((Y+=$)>>>0<$>>>0?1:0))+((L=D+Y|0)>>>0<D>>>0?1:0)|0,O=R,D=U,R=C,U=T,C=I,T=x,I=Z+(V=z+V+(($=G+ee)>>>0<G>>>0?1:0))+((x=Y+$|0)>>>0<Y>>>0?1:0)|0}f=r.low=f+x,r.high=h+I+(f>>>0<x>>>0?1:0),g=n.low=g+T,n.high=p+C+(g>>>0<T>>>0?1:0),v=i.low=v+U,i.high=y+R+(v>>>0<U>>>0?1:0),w=o.low=w+D,o.high=m+O+(w>>>0<D>>>0?1:0),_=c.low=_+L,c.high=S+N+(_>>>0<L>>>0?1:0),E=u.low=E+j,u.high=b+H+(E>>>0<j>>>0?1:0),F=l.low=F+K,l.high=A+M+(F>>>0<K>>>0?1:0),k=d.low=k+W,d.high=P+B+(k>>>0<W>>>0?1:0)},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[30+(n+128>>>10<<5)]=Math.floor(r/4294967296),t[31+(n+128>>>10<<5)]=r,e.sigBytes=4*t.length,this._process(),this._hash.toX32()},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e},blockSize:32}),t.SHA512=r._createHelper(o),t.HmacSHA512=r._createHmacHelper(o)}(),function(){var e=y,t=(i=e.x64).Word,r=i.WordArray,n=(i=e.algo).SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var e=n._doFinalize.call(this);return e.sigBytes-=16,e}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)}();
|
|
2
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
3
|
+
*/
|
|
4
|
+
var v,m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function w(e){var t,r,n="";for(t=0;t+3<=e.length;t+=3)r=parseInt(e.substring(t,t+3),16),n+=m.charAt(r>>6)+m.charAt(63&r);for(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=m.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=m.charAt(r>>2)+m.charAt((3&r)<<4));(3&n.length)>0;)n+="=";return n}function S(e){var t,r,n,i="",o=0;for(t=0;t<e.length&&"="!=e.charAt(t);++t)(n=m.indexOf(e.charAt(t)))<0||(0==o?(i+=k(n>>2),r=3&n,o=1):1==o?(i+=k(r<<2|n>>4),r=15&n,o=2):2==o?(i+=k(r),i+=k(n>>2),r=3&n,o=3):(i+=k(r<<2|n>>4),i+=k(15&n),o=0));return 1==o&&(i+=k(r<<2)),i}function _(e){var t,r=S(e),n=new Array;for(t=0;2*t<r.length;++t)n[t]=parseInt(r.substring(2*t,2*t+2),16);return n}function b(e,t,r){null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function E(){return new b(null)}"Microsoft Internet Explorer"==p.appName?(b.prototype.am=function(e,t,r,n,i,o){for(var s=32767&t,a=t>>15;--o>=0;){var c=32767&this[e],u=this[e++]>>15,l=a*c+u*s;i=((c=s*c+((32767&l)<<15)+r[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r[n++]=1073741823&c}return i},v=30):"Netscape"!=p.appName?(b.prototype.am=function(e,t,r,n,i,o){for(;--o>=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=67108863&s}return i},v=26):(b.prototype.am=function(e,t,r,n,i,o){for(var s=16383&t,a=t>>14;--o>=0;){var c=16383&this[e],u=this[e++]>>14,l=a*c+u*s;i=((c=s*c+((16383&l)<<14)+r[n]+i)>>28)+(l>>14)+a*u,r[n++]=268435455&c}return i},v=28),b.prototype.DB=v,b.prototype.DM=(1<<v)-1,b.prototype.DV=1<<v,b.prototype.FV=Math.pow(2,52),b.prototype.F1=52-v,b.prototype.F2=2*v-52;var A,F,P=new Array;for(A="0".charCodeAt(0),F=0;F<=9;++F)P[A++]=F;for(A="a".charCodeAt(0),F=10;F<36;++F)P[A++]=F;for(A="A".charCodeAt(0),F=10;F<36;++F)P[A++]=F;function k(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function I(e,t){var r=P[e.charCodeAt(t)];return null==r?-1:r}function x(e){var t=E();return t.fromInt(e),t}function C(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function T(e){this.m=e}function R(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function U(e,t){return e&t}function O(e,t){return e|t}function D(e,t){return e^t}function N(e,t){return e&~t}function L(e){if(0==e)return-1;var t=0;return!(65535&e)&&(e>>=16,t+=16),!(255&e)&&(e>>=8,t+=8),!(15&e)&&(e>>=4,t+=4),!(3&e)&&(e>>=2,t+=2),!(1&e)&&++t,t}function H(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function j(){}function M(e){return e}function K(e){this.r2=E(),this.q3=E(),b.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}T.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},T.prototype.revert=function(e){return e},T.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},T.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},T.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},R.prototype.convert=function(e){var t=E();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(b.ZERO)>0&&this.m.subTo(t,t),t},R.prototype.revert=function(e){var t=E();return e.copyTo(t),this.reduce(t),t},R.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},R.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},R.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},b.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},b.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},b.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var s=8==r?255&e[n]:I(e,n);s<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<<this.DB-o)-1)<<o,this[this.t++]=s>>this.DB-o):this[this.t-1]|=s<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&!!(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&b.ZERO.subTo(this,this)},b.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},b.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},b.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s},b.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,o=(1<<i)-1,s=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t[r+s+1]=this[r]>>i|a,a=(this[r]&o)<<n;for(r=s-1;r>=0;--r)t[r]=0;t[s]=a,t.t=this.t+s+1,t.s=this.s,t.clamp()},b.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<<n)-1;t[0]=this[r]>>n;for(var s=r+1;s<this.t;++s)t[s-r-1]|=(this[s]&o)<<i,t[s-r]=this[s]>>n;n>0&&(t[this.t-r-1]|=(this.s&o)<<i),t.t=this.t-r,t.clamp()}},b.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},b.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&b.ZERO.subTo(t,t)},b.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},b.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=E());var o=E(),s=this.s,a=e.s,c=this.DB-C(n[n.t-1]);c>0?(n.lShiftTo(c,o),i.lShiftTo(c,r)):(n.copyTo(o),i.copyTo(r));var u=o.t,l=o[u-1];if(0!=l){var d=l*(1<<this.F1)+(u>1?o[u-2]>>this.F2:0),h=this.FV/d,f=(1<<this.F1)/d,p=1<<this.F2,g=r.t,y=g-u,v=null==t?E():t;for(o.dlShiftTo(y,v),r.compareTo(v)>=0&&(r[r.t++]=1,r.subTo(v,r)),b.ONE.dlShiftTo(u,v),v.subTo(o,o);o.t<u;)o[o.t++]=0;for(;--y>=0;){var m=r[--g]==l?this.DM:Math.floor(r[g]*h+(r[g-1]+p)*f);if((r[g]+=o.am(0,m,r,y,0,u))<m)for(o.dlShiftTo(y,v),r.subTo(v,r);r[g]<--m;)r.subTo(v,r)}null!=t&&(r.drShiftTo(u,t),s!=a&&b.ZERO.subTo(t,t)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),s<0&&b.ZERO.subTo(r,r)}}},b.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},b.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},b.prototype.exp=function(e,t){if(e>4294967295||e<1)return b.ONE;var r=E(),n=E(),i=t.convert(this),o=C(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<<o)>0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)},b.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,o="",s=this.t,a=this.DB-s*this.DB%t;if(s-- >0)for(a<this.DB&&(r=this[s]>>a)>0&&(i=!0,o=k(r));s>=0;)a<t?(r=(this[s]&(1<<a)-1)<<t-a,r|=this[--s]>>(a+=this.DB-t)):(r=this[s]>>(a-=t)&n,a<=0&&(a+=this.DB,--s)),r>0&&(i=!0),i&&(o+=k(r));return i?o:"0"},b.prototype.negate=function(){var e=E();return b.ZERO.subTo(this,e),e},b.prototype.abs=function(){return this.s<0?this.negate():this},b.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},b.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+C(this[this.t-1]^this.s&this.DM)},b.prototype.mod=function(e){var t=E();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(b.ZERO)>0&&e.subTo(t,t),t},b.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new T(t):new R(t),this.exp(e,r)},b.ZERO=x(0),b.ONE=x(1),j.prototype.convert=M,j.prototype.revert=M,j.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},j.prototype.sqrTo=function(e,t){e.squareTo(t)},K.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=E();return e.copyTo(t),this.reduce(t),t},K.prototype.revert=function(e){return e},K.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},K.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},K.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var B,W,J,V=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/V[V.length-1];
|
|
5
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
6
|
+
*/function $(){this.i=0,this.j=0,this.S=new Array}
|
|
7
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
8
|
+
*/
|
|
9
|
+
function z(){!function(e){W[J++]^=255&e,W[J++]^=e>>8&255,W[J++]^=e>>16&255,W[J++]^=e>>24&255,J>=256&&(J-=256)}((new Date).getTime())}if(b.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},b.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=x(r),i=E(),o=E(),s="";for(this.divRemTo(n,i,o);i.signum()>0;)s=(r+o.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,o);return o.intValue().toString(e)+s},b.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,s=0,a=0;a<e.length;++a){var c=I(e,a);c<0?"-"==e.charAt(a)&&0==this.signum()&&(i=!0):(s=t*s+c,++o>=r&&(this.dMultiply(n),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(s,0)),i&&b.ZERO.subTo(this,this)},b.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(b.ONE.shiftLeft(e-1),O,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(b.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},b.prototype.bitwiseTo=function(e,t,r){var n,i,o=Math.min(e.t,this.t);for(n=0;n<o;++n)r[n]=t(this[n],e[n]);if(e.t<this.t){for(i=e.s&this.DM,n=o;n<this.t;++n)r[n]=t(this[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=o;n<e.t;++n)r[n]=t(i,e[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},b.prototype.changeBit=function(e,t){var r=b.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},b.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},b.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},b.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},b.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,e[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e[i],r,i,0,t-i);r.clamp()},b.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r[this.t+n-t]=this.am(t-n,e[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},b.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},b.prototype.millerRabin=function(e){var t=this.subtract(b.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>V.length&&(e=V.length);for(var i=E(),o=0;o<e;++o){i.fromInt(V[Math.floor(Math.random()*V.length)]);var s=i.modPow(n,this);if(0!=s.compareTo(b.ONE)&&0!=s.compareTo(t)){for(var a=1;a++<r&&0!=s.compareTo(t);)if(0==(s=s.modPowInt(2,this)).compareTo(b.ONE))return!1;if(0!=s.compareTo(t))return!1}}return!0},b.prototype.clone=
|
|
10
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
11
|
+
*/
|
|
12
|
+
function(){var e=E();return this.copyTo(e),e},b.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},b.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},b.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},b.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},b.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this[e]&(1<<n)-1)<<8-n,r|=this[--e]>>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),!!(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},b.prototype.equals=function(e){return 0==this.compareTo(e)},b.prototype.min=function(e){return this.compareTo(e)<0?this:e},b.prototype.max=function(e){return this.compareTo(e)>0?this:e},b.prototype.and=function(e){var t=E();return this.bitwiseTo(e,U,t),t},b.prototype.or=function(e){var t=E();return this.bitwiseTo(e,O,t),t},b.prototype.xor=function(e){var t=E();return this.bitwiseTo(e,D,t),t},b.prototype.andNot=function(e){var t=E();return this.bitwiseTo(e,N,t),t},b.prototype.not=function(){for(var e=E(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},b.prototype.shiftLeft=function(e){var t=E();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},b.prototype.shiftRight=function(e){var t=E();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},b.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+L(this[e]);return this.s<0?this.t*this.DB:-1},b.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=H(this[r]^t);return e},b.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)},b.prototype.setBit=function(e){return this.changeBit(e,O)},b.prototype.clearBit=function(e){return this.changeBit(e,N)},b.prototype.flipBit=function(e){return this.changeBit(e,D)},b.prototype.add=function(e){var t=E();return this.addTo(e,t),t},b.prototype.subtract=function(e){var t=E();return this.subTo(e,t),t},b.prototype.multiply=function(e){var t=E();return this.multiplyTo(e,t),t},b.prototype.divide=function(e){var t=E();return this.divRemTo(e,t,null),t},b.prototype.remainder=function(e){var t=E();return this.divRemTo(e,null,t),t},b.prototype.divideAndRemainder=function(e){var t=E(),r=E();return this.divRemTo(e,t,r),new Array(t,r)},b.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),o=x(1);if(i<=0)return o;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new T(t):t.isEven()?new K(t):new R(t);var s=new Array,a=3,c=r-1,u=(1<<r)-1;if(s[1]=n.convert(this),r>1){var l=E();for(n.sqrTo(s[1],l);a<=u;)s[a]=E(),n.mulTo(l,s[a-2],s[a]),a+=2}var d,h,f=e.t-1,p=!0,g=E();for(i=C(e[f])-1;f>=0;){for(i>=c?d=e[f]>>i-c&u:(d=(e[f]&(1<<i+1)-1)<<c-i,f>0&&(d|=e[f-1]>>this.DB+i-c)),a=r;!(1&d);)d>>=1,--a;if((i-=a)<0&&(i+=this.DB,--f),p)s[d].copyTo(o),p=!1;else{for(;a>1;)n.sqrTo(o,g),n.sqrTo(g,o),a-=2;a>0?n.sqrTo(o,g):(h=o,o=g,g=h),n.mulTo(g,s[d],o)}for(;f>=0&&!(e[f]&1<<i);)n.sqrTo(o,g),h=o,o=g,g=h,--i<0&&(i=this.DB-1,--f)}return n.revert(o)},b.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return b.ZERO;for(var r=e.clone(),n=this.clone(),i=x(1),o=x(0),s=x(0),a=x(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),o.subTo(a,o)):(n.subTo(r,n),t&&s.subTo(i,s),a.subTo(o,a))}return 0!=n.compareTo(b.ONE)?b.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a},b.prototype.pow=function(e){return this.exp(e,new j)},b.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i<o&&(o=i),o>0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},b.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=V[V.length-1]){for(t=0;t<V.length;++t)if(r[0]==V[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<V.length;){for(var n=V[t],i=t+1;i<V.length&&n<q;)n*=V[i++];for(n=r.modInt(n);t<i;)if(n%V[t++]==0)return!1}return r.millerRabin(e)},b.prototype.square=function(){var e=E();return this.squareTo(e),e},$.prototype.init=function(e){var t,r,n;for(t=0;t<256;++t)this.S[t]=t;for(r=0,t=0;t<256;++t)r=r+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[r],this.S[r]=n;this.i=0,this.j=0},$.prototype.next=function(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]},null==W){var G;if(W=new Array,J=0,void 0!==g&&(void 0!==g.crypto||void 0!==g.msCrypto)){var Y=g.crypto||g.msCrypto;if(Y.getRandomValues){var X=new Uint8Array(32);for(Y.getRandomValues(X),G=0;G<32;++G)W[J++]=X[G]}else if("Netscape"==p.appName&&p.appVersion<"5"){var Z=g.crypto.random(32);for(G=0;G<Z.length;++G)W[J++]=255&Z.charCodeAt(G)}}for(;J<256;)G=Math.floor(65536*Math.random()),W[J++]=G>>>8,W[J++]=255&G;J=0,z()}function Q(){if(null==B){for(z(),(B=new $).init(W),J=0;J<W.length;++J)W[J]=0;J=0}return B.next()}function ee(){}
|
|
13
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
14
|
+
*/function te(e,t){return new b(e,t)}function re(e,t,r){for(var n="",i=0;n.length<t;)n+=r(String.fromCharCode.apply(String,e.concat([(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i]))),i+=1;return n}function ne(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}
|
|
15
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
16
|
+
*/function ie(e,t){this.x=t,this.q=e}function oe(e,t,r,n){this.curve=e,this.x=t,this.y=r,this.z=null==n?b.ONE:n,this.zinv=null}function se(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new oe(this,null,null)}ee.prototype.nextBytes=function(e){var t;for(t=0;t<e.length;++t)e[t]=Q()},ne.prototype.doPublic=function(e){return e.modPowInt(this.e,this.n)},ne.prototype.setPublic=function(e,t){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof e)this.n=e,this.e=t;else{if(!(null!=e&&null!=t&&e.length>0&&t.length>0))throw"Invalid RSA public key";this.n=te(e,16),this.e=parseInt(t,16)}},ne.prototype.encrypt=function(e){var t=function(e,t){if(t<e.length+11)throw"Message too long for RSA";for(var r=new Array,n=e.length-1;n>=0&&t>0;){var i=e.charCodeAt(n--);i<128?r[--t]=i:i>127&&i<2048?(r[--t]=63&i|128,r[--t]=i>>6|192):(r[--t]=63&i|128,r[--t]=i>>6&63|128,r[--t]=i>>12|224)}r[--t]=0;for(var o=new ee,s=new Array;t>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);r[--t]=s[0]}return r[--t]=2,r[--t]=0,new b(r)}(e,this.n.bitLength()+7>>3);if(null==t)return null;var r=this.doPublic(t);if(null==r)return null;var n=r.toString(16);return 1&n.length?"0"+n:n},ne.prototype.encryptOAEP=function(e,t,r){var n=function(e,t,r,n){var i=ce.crypto.MessageDigest,o=ce.crypto.Util,s=null;if(r||(r="sha1"),"string"==typeof r&&(s=i.getCanonicalAlgName(r),n=i.getHashLength(s),r=function(e){return be(o.hashHex(Ee(e),s))}),e.length+2*n+2>t)throw"Message too long for RSA";var a,c="";for(a=0;a<t-e.length-2*n-2;a+=1)c+="\0";var u=r("")+c+""+e,l=new Array(n);(new ee).nextBytes(l);var d=re(l,u.length,r),h=[];for(a=0;a<u.length;a+=1)h[a]=u.charCodeAt(a)^d.charCodeAt(a);var f=re(h,l.length,r),p=[0];for(a=0;a<l.length;a+=1)p[a+1]=l[a]^f.charCodeAt(a);return new b(p.concat(h))}(e,this.n.bitLength()+7>>3,t,r);if(null==n)return null;var i=this.doPublic(n);if(null==i)return null;var o=i.toString(16);return 1&o.length?"0"+o:o},ne.prototype.type="RSA",ie.prototype.equals=function(e){return e==this||this.q.equals(e.q)&&this.x.equals(e.x)},ie.prototype.toBigInteger=function(){return this.x},ie.prototype.negate=function(){return new ie(this.q,this.x.negate().mod(this.q))},ie.prototype.add=function(e){return new ie(this.q,this.x.add(e.toBigInteger()).mod(this.q))},ie.prototype.subtract=function(e){return new ie(this.q,this.x.subtract(e.toBigInteger()).mod(this.q))},ie.prototype.multiply=function(e){return new ie(this.q,this.x.multiply(e.toBigInteger()).mod(this.q))},ie.prototype.square=function(){return new ie(this.q,this.x.square().mod(this.q))},ie.prototype.divide=function(e){return new ie(this.q,this.x.multiply(e.toBigInteger().modInverse(this.q)).mod(this.q))},oe.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},oe.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},oe.prototype.equals=function(e){return e==this||(this.isInfinity()?e.isInfinity():e.isInfinity()?this.isInfinity():!!e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(b.ZERO)&&e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(b.ZERO))},oe.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(b.ZERO)&&!this.y.toBigInteger().equals(b.ZERO)},oe.prototype.negate=function(){return new oe(this.curve,this.x,this.y.negate(),this.z)},oe.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q),r=e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q);if(b.ZERO.equals(r))return b.ZERO.equals(t)?this.twice():this.curve.getInfinity();var n=new b("3"),i=this.x.toBigInteger(),o=this.y.toBigInteger(),s=(e.x.toBigInteger(),e.y.toBigInteger(),r.square()),a=s.multiply(r),c=i.multiply(s),u=t.square().multiply(this.z),l=u.subtract(c.shiftLeft(1)).multiply(e.z).subtract(a).multiply(r).mod(this.curve.q),d=c.multiply(n).multiply(t).subtract(o.multiply(a)).subtract(u.multiply(t)).multiply(e.z).add(t.multiply(a)).mod(this.curve.q),h=a.multiply(this.z).multiply(e.z).mod(this.curve.q);return new oe(this.curve,this.curve.fromBigInteger(l),this.curve.fromBigInteger(d),h)},oe.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var e=new b("3"),t=this.x.toBigInteger(),r=this.y.toBigInteger(),n=r.multiply(this.z),i=n.multiply(r).mod(this.curve.q),o=this.curve.a.toBigInteger(),s=t.square().multiply(e);b.ZERO.equals(o)||(s=s.add(this.z.square().multiply(o)));var a=(s=s.mod(this.curve.q)).square().subtract(t.shiftLeft(3).multiply(i)).shiftLeft(1).multiply(n).mod(this.curve.q),c=s.multiply(e).multiply(t).subtract(i.shiftLeft(1)).shiftLeft(2).multiply(i).subtract(s.square().multiply(s)).mod(this.curve.q),u=n.square().multiply(n).shiftLeft(3).mod(this.curve.q);return new oe(this.curve,this.curve.fromBigInteger(a),this.curve.fromBigInteger(c),u)},oe.prototype.multiply=function(e){if(this.isInfinity())return this;if(0==e.signum())return this.curve.getInfinity();var t,r=e,n=r.multiply(new b("3")),i=this.negate(),o=this,s=this.curve.q.subtract(e),a=s.multiply(new b("3")),c=new oe(this.curve,this.x,this.y),u=c.negate();for(t=n.bitLength()-2;t>0;--t){o=o.twice();var l=n.testBit(t);l!=r.testBit(t)&&(o=o.add(l?this:i))}for(t=a.bitLength()-2;t>0;--t){c=c.twice();var d=a.testBit(t);d!=s.testBit(t)&&(c=c.add(d?c:u))}return o},oe.prototype.multiplyTwo=function(e,t,r){var n;n=e.bitLength()>r.bitLength()?e.bitLength()-1:r.bitLength()-1;for(var i=this.curve.getInfinity(),o=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?i=r.testBit(n)?i.add(o):i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i},se.prototype.getQ=function(){return this.q},se.prototype.getA=function(){return this.a},se.prototype.getB=function(){return this.b},se.prototype.equals=function(e){return e==this||this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)},se.prototype.getInfinity=function(){return this.infinity},se.prototype.fromBigInteger=function(e){return new ie(this.q,e)},se.prototype.decodePointHex=function(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:default:return null;case 4:case 6:case 7:var t=(e.length-2)/2,r=e.substr(2,t),n=e.substr(t+2,t);return new oe(this,this.fromBigInteger(new b(r,16)),this.fromBigInteger(new b(n,16)))}},
|
|
17
|
+
/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib
|
|
18
|
+
*/
|
|
19
|
+
ie.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},oe.prototype.getEncoded=function(e){var t=function(e,t){var r=e.toByteArrayUnsigned();if(t<r.length)r=r.slice(r.length-t);else for(;t>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=t(r,32);return e?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(t(n,32))),i},oe.decodeFrom=function(e,t){t[0];var r=t.length-1,n=t.slice(1,1+r/2),i=t.slice(1+r/2,1+r);n.unshift(0),i.unshift(0);var o=new b(n),s=new b(i);return new oe(e,e.fromBigInteger(o),e.fromBigInteger(s))},oe.decodeFromHex=function(e,t){t.substr(0,2);var r=t.length-2,n=t.substr(2,r/2),i=t.substr(2+r/2,r/2),o=new b(n,16),s=new b(i,16);return new oe(e,e.fromBigInteger(o),e.fromBigInteger(s))},oe.prototype.add2D=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;if(this.x.equals(e.x))return this.y.equals(e.y)?this.twice():this.curve.getInfinity();var t=e.x.subtract(this.x),r=e.y.subtract(this.y).divide(t),n=r.square().subtract(this.x).subtract(e.x),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new oe(this.curve,n,i)},oe.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var e=this.curve.fromBigInteger(b.valueOf(2)),t=this.curve.fromBigInteger(b.valueOf(3)),r=this.x.square().multiply(t).add(this.curve.a).divide(this.y.multiply(e)),n=r.square().subtract(this.x.multiply(e)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new oe(this.curve,n,i)},oe.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(0==e.signum())return this.curve.getInfinity();var t,r=e,n=r.multiply(new b("3")),i=this.negate(),o=this;for(t=n.bitLength()-2;t>0;--t){o=o.twice();var s=n.testBit(t);s!=r.testBit(t)&&(o=o.add2D(s?this:i))}return o},oe.prototype.isOnCurve=function(){var e=this.getX().toBigInteger(),t=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),o=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return o.equals(s)},oe.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},oe.prototype.validate=function(){var e=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var t=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(t.compareTo(b.ONE)<0||t.compareTo(e.subtract(b.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(b.ONE)<0||r.compareTo(e.subtract(b.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(e).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};
|
|
20
|
+
/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval
|
|
21
|
+
*/
|
|
22
|
+
var ae=function(){var e=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),t=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function n(e,t,n){return t?r[t]:String.fromCharCode(parseInt(n,16))}var i=new String(""),o=Object.hasOwnProperty;return function(r,s){var a,c,u=r.match(e),l=u[0],d=!1;"{"===l?a={}:"["===l?a=[]:(a=[],d=!0);for(var h=[a],p=1-d,g=u.length;p<g;++p){var y;switch((l=u[p]).charCodeAt(0)){default:(y=h[0])[c||y.length]=+l,c=void 0;break;case 34:if(-1!==(l=l.substring(1,l.length-1)).indexOf("\\")&&(l=l.replace(t,n)),y=h[0],!c){if(!(y instanceof Array)){c=l||i;break}c=y.length}y[c]=l,c=void 0;break;case 91:y=h[0],h.unshift(y[c||y.length]=[]),c=void 0;break;case 93:case 125:h.shift();break;case 102:(y=h[0])[c||y.length]=!1,c=void 0;break;case 110:(y=h[0])[c||y.length]=null,c=void 0;break;case 116:(y=h[0])[c||y.length]=!0,c=void 0;break;case 123:y=h[0],h.unshift(y[c||y.length]={}),c=void 0}}if(d){if(1!==h.length)throw new Error;a=a[0]}else if(h.length)throw new Error;return s&&(a=function e(t,r){var n=t[r];if(n&&"object"===(void 0===n?"undefined":f(n))){var i=null;for(var a in n)if(o.call(n,a)&&n!==t){var c=e(n,a);void 0!==c?n[a]=c:(i||(i=[]),i.push(a))}if(i)for(var u=i.length;--u>=0;)delete n[i[u]]}return s.call(t,r,n)}({"":a},"")),a}}();void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.asn1&&ce.asn1||(ce.asn1={}),ce.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){var t=e.toString(16);if("-"!=t.substr(0,1))t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var r=t.substr(1).length;r%2==1?r+=1:t.match(/^[0-7]/)||(r+=2);for(var n="",i=0;i<r;i++)n+="f";t=new b(n,16).xor(e).add(b.ONE).toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(e,t){return ke(e,t)},this.newObject=function(e){var t=ce.asn1,r=t.ASN1Object,n=t.DERBoolean,i=t.DERInteger,o=t.DERBitString,s=t.DEROctetString,a=t.DERNull,c=t.DERObjectIdentifier,u=t.DEREnumerated,l=t.DERUTF8String,d=t.DERNumericString,h=t.DERPrintableString,f=t.DERTeletexString,p=t.DERIA5String,g=t.DERUTCTime,y=t.DERGeneralizedTime,v=t.DERVisibleString,m=t.DERBMPString,w=t.DERSequence,S=t.DERSet,_=t.DERTaggedObject,b=t.ASN1Util.newObject;if(e instanceof t.ASN1Object)return e;var E=Object.keys(e);if(1!=E.length)throw new Error("key of param shall be only one.");var A=E[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+A+":"))throw new Error("undefined key: "+A);if("bool"==A)return new n(e[A]);if("int"==A)return new i(e[A]);if("bitstr"==A)return new o(e[A]);if("octstr"==A)return new s(e[A]);if("null"==A)return new a(e[A]);if("oid"==A)return new c(e[A]);if("enum"==A)return new u(e[A]);if("utf8str"==A)return new l(e[A]);if("numstr"==A)return new d(e[A]);if("prnstr"==A)return new h(e[A]);if("telstr"==A)return new f(e[A]);if("ia5str"==A)return new p(e[A]);if("utctime"==A)return new g(e[A]);if("gentime"==A)return new y(e[A]);if("visstr"==A)return new v(e[A]);if("bmpstr"==A)return new m(e[A]);if("asn1"==A)return new r(e[A]);if("seq"==A){for(var F=e[A],P=[],k=0;k<F.length;k++){var I=b(F[k]);P.push(I)}return new w({array:P})}if("set"==A){for(F=e[A],P=[],k=0;k<F.length;k++)I=b(F[k]),P.push(I);return new S({array:P})}if("tag"==A){var x=e[A];if("[object Array]"===Object.prototype.toString.call(x)&&3==x.length){var C=b(x[2]);return new _({tag:x[0],explicit:x[1],obj:C})}return new _(x)}},this.jsonToASN1HEX=function(e){return this.newObject(e).getEncodedHex()}},ce.asn1.ASN1Util.oidHexToInt=function(e){for(var t="",r=parseInt(e.substr(0,2),16),n=(t=Math.floor(r/40)+"."+r%40,""),i=2;i<e.length;i+=2){var o=("00000000"+parseInt(e.substr(i,2),16).toString(2)).slice(-8);n+=o.substr(1,7),"0"==o.substr(0,1)&&(t=t+"."+new b(n,2).toString(10),n="")}return t},ce.asn1.ASN1Util.oidIntToHex=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},r=function(e){var r="",n=new b(e,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",s=0;s<i;s++)o+="0";for(n=o+n,s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),r+=t(parseInt(a,2))}return r};if(!e.match(/^[0-9.]+$/))throw"malformed oid string: "+e;var n="",i=e.split("."),o=40*parseInt(i[0])+parseInt(i[1]);n+=t(o),i.splice(0,2);for(var s=0;s<i.length;s++)n+=r(i[s]);return n},ce.asn1.ASN1Object=function(e){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var e=this.hV.length/2,t=e.toString(16);if(t.length%2==1&&(t="0"+t),e<128)return t;var r=t.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+e.toString(16);return(128+r).toString(16)+t},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(e){this.params=e},null!=e&&null!=e.tlv&&(this.hTLV=e.tlv,this.isModified=!1)},ce.asn1.DERAbstractString=function(e){ce.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=Se(this.s).toLowerCase()},this.setStringHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e?this.setString(e):void 0!==e.str?this.setString(e.str):void 0!==e.hex&&this.setStringHex(e.hex))},Ke(ce.asn1.DERAbstractString,ce.asn1.ASN1Object),ce.asn1.DERAbstractTime=function(e){ce.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(e){var t=e.getTime()+6e4*e.getTimezoneOffset();return new Date(t)},this.formatDate=function(e,t,r){var n=this.zeroPadding,i=this.localDateToUTC(e),o=String(i.getFullYear());"utc"==t&&(o=o.substr(2,2));var s=o+n(String(i.getMonth()+1),2)+n(String(i.getDate()),2)+n(String(i.getHours()),2)+n(String(i.getMinutes()),2)+n(String(i.getSeconds()),2);if(!0===r){var a=i.getMilliseconds();if(0!=a){var c=n(String(a),3);s=s+"."+(c=c.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},this.getString=function(){return this.s},this.setString=function(e){this.hTLV=null,this.isModified=!0,this.s=e,this.hV=ge(e)},this.setByDateValue=function(e,t,r,n,i,o){var s=new Date(Date.UTC(e,t-1,r,n,i,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},Ke(ce.asn1.DERAbstractTime,ce.asn1.ASN1Object),ce.asn1.DERAbstractStructured=function(e){ce.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array=e},this.appendASN1Object=function(e){this.hTLV=null,this.isModified=!0,this.asn1Array.push(e)},this.asn1Array=new Array,void 0!==e&&void 0!==e.array&&(this.asn1Array=e.array)},Ke(ce.asn1.DERAbstractStructured,ce.asn1.ASN1Object),ce.asn1.DERBoolean=function(e){ce.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==e?"010100":"0101ff"},Ke(ce.asn1.DERBoolean,ce.asn1.ASN1Object),ce.asn1.DERInteger=function(e){ce.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=ce.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new b(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.bigint?this.setByBigInteger(e.bigint):void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},Ke(ce.asn1.DERInteger,ce.asn1.ASN1Object),ce.asn1.DERBitString=function(e){if(void 0!==e&&void 0!==e.obj){var t=ce.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.getEncodedHex()}ce.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,t){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var r="0"+e;this.hTLV=null,this.isModified=!0,this.hV=r+t},this.setByBinaryString=function(e){var t=8-(e=e.replace(/0+$/,"")).length%8;8==t&&(t=0);for(var r=0;r<=t;r++)e+="0";var n="";for(r=0;r<e.length-1;r+=8){var i=e.substr(r,8),o=parseInt(i,2).toString(16);1==o.length&&(o="0"+o),n+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+t+n},this.setByBooleanArray=function(e){for(var t="",r=0;r<e.length;r++)1==e[r]?t+="1":t+="0";this.setByBinaryString(t)},this.newFalseArray=function(e){for(var t=new Array(e),r=0;r<e;r++)t[r]=!1;return t},this.getFreshValueHex=function(){return this.hV},void 0!==e&&("string"==typeof e&&e.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(e):void 0!==e.hex?this.setHexValueIncludingUnusedBits(e.hex):void 0!==e.bin?this.setByBinaryString(e.bin):void 0!==e.array&&this.setByBooleanArray(e.array))},Ke(ce.asn1.DERBitString,ce.asn1.ASN1Object),ce.asn1.DEROctetString=function(e){if(void 0!==e&&void 0!==e.obj){var t=ce.asn1.ASN1Util.newObject(e.obj);e.hex=t.getEncodedHex()}ce.asn1.DEROctetString.superclass.constructor.call(this,e),this.hT="04"},Ke(ce.asn1.DEROctetString,ce.asn1.DERAbstractString),ce.asn1.DERNull=function(){ce.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Ke(ce.asn1.DERNull,ce.asn1.ASN1Object),ce.asn1.DERObjectIdentifier=function(e){ce.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(e){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueOidString=function(e){var t=function(e){var t=function(e){var t=e.toString(16);return 1==t.length&&(t="0"+t),t},r=function(e){var r="",n=parseInt(e,10).toString(2),i=7-n.length%7;7==i&&(i=0);for(var o="",s=0;s<i;s++)o+="0";for(n=o+n,s=0;s<n.length-1;s+=7){var a=n.substr(s,7);s!=n.length-7&&(a="1"+a),r+=t(parseInt(a,2))}return r};try{if(!e.match(/^[0-9.]+$/))return null;var n="",i=e.split("."),o=40*parseInt(i[0],10)+parseInt(i[1],10);n+=t(o),i.splice(0,2);for(var s=0;s<i.length;s++)n+=r(i[s]);return n}catch(e){return null}}(e);if(null==t)throw new Error("malformed oid string: "+e);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueName=function(e){var t=ce.asn1.x509.OID.name2oid(e);if(""===t)throw new Error("DERObjectIdentifier oidName undefined: "+e);this.setValueOidString(t)},this.setValueNameOrOid=function(e){e.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(e):this.setValueName(e)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){"string"==typeof e?this.setValueNameOrOid(e):void 0!==e.oid?this.setValueNameOrOid(e.oid):void 0!==e.name?this.setValueNameOrOid(e.name):void 0!==e.hex&&this.setValueHex(e.hex)},void 0!==e&&this.setByParam(e)},Ke(ce.asn1.DERObjectIdentifier,ce.asn1.ASN1Object),ce.asn1.DEREnumerated=function(e){ce.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(e){this.hTLV=null,this.isModified=!0,this.hV=ce.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e)},this.setByInteger=function(e){var t=new b(String(e),10);this.setByBigInteger(t)},this.setValueHex=function(e){this.hV=e},this.getFreshValueHex=function(){return this.hV},void 0!==e&&(void 0!==e.int?this.setByInteger(e.int):"number"==typeof e?this.setByInteger(e):void 0!==e.hex&&this.setValueHex(e.hex))},Ke(ce.asn1.DEREnumerated,ce.asn1.ASN1Object),ce.asn1.DERUTF8String=function(e){ce.asn1.DERUTF8String.superclass.constructor.call(this,e),this.hT="0c"},Ke(ce.asn1.DERUTF8String,ce.asn1.DERAbstractString),ce.asn1.DERNumericString=function(e){ce.asn1.DERNumericString.superclass.constructor.call(this,e),this.hT="12"},Ke(ce.asn1.DERNumericString,ce.asn1.DERAbstractString),ce.asn1.DERPrintableString=function(e){ce.asn1.DERPrintableString.superclass.constructor.call(this,e),this.hT="13"},Ke(ce.asn1.DERPrintableString,ce.asn1.DERAbstractString),ce.asn1.DERTeletexString=function(e){ce.asn1.DERTeletexString.superclass.constructor.call(this,e),this.hT="14"},Ke(ce.asn1.DERTeletexString,ce.asn1.DERAbstractString),ce.asn1.DERIA5String=function(e){ce.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="16"},Ke(ce.asn1.DERIA5String,ce.asn1.DERAbstractString),ce.asn1.DERVisibleString=function(e){ce.asn1.DERIA5String.superclass.constructor.call(this,e),this.hT="1a"},Ke(ce.asn1.DERVisibleString,ce.asn1.DERAbstractString),ce.asn1.DERBMPString=function(e){ce.asn1.DERBMPString.superclass.constructor.call(this,e),this.hT="1e"},Ke(ce.asn1.DERBMPString,ce.asn1.DERAbstractString),ce.asn1.DERUTCTime=function(e){ce.asn1.DERUTCTime.superclass.constructor.call(this,e),this.hT="17",this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"utc"),this.hV=ge(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=ge(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{12}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date))},Ke(ce.asn1.DERUTCTime,ce.asn1.DERAbstractTime),ce.asn1.DERGeneralizedTime=function(e){ce.asn1.DERGeneralizedTime.superclass.constructor.call(this,e),this.hT="18",this.withMillis=!1,this.setByDate=function(e){this.hTLV=null,this.isModified=!0,this.date=e,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=ge(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=ge(this.s)),this.hV},void 0!==e&&(void 0!==e.str?this.setString(e.str):"string"==typeof e&&e.match(/^[0-9]{14}Z$/)?this.setString(e):void 0!==e.hex?this.setStringHex(e.hex):void 0!==e.date&&this.setByDate(e.date),!0===e.millis&&(this.withMillis=!0))},Ke(ce.asn1.DERGeneralizedTime,ce.asn1.DERAbstractTime),ce.asn1.DERSequence=function(e){ce.asn1.DERSequence.superclass.constructor.call(this,e),this.hT="30",this.getFreshValueHex=function(){for(var e="",t=0;t<this.asn1Array.length;t++)e+=this.asn1Array[t].getEncodedHex();return this.hV=e,this.hV}},Ke(ce.asn1.DERSequence,ce.asn1.DERAbstractStructured),ce.asn1.DERSet=function(e){ce.asn1.DERSet.superclass.constructor.call(this,e),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var e=new Array,t=0;t<this.asn1Array.length;t++){var r=this.asn1Array[t];e.push(r.getEncodedHex())}return 1==this.sortFlag&&e.sort(),this.hV=e.join(""),this.hV},void 0!==e&&void 0!==e.sortflag&&0==e.sortflag&&(this.sortFlag=!1)},Ke(ce.asn1.DERSet,ce.asn1.DERAbstractStructured),ce.asn1.DERTaggedObject=function(e){ce.asn1.DERTaggedObject.superclass.constructor.call(this);var t=ce.asn1;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(e,t,r){this.hT=t,this.isExplicit=e,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,t),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(e){null!=e.tag&&(this.hT=e.tag),null!=e.explicit&&(this.isExplicit=e.explicit),null!=e.tage&&(this.hT=e.tage,this.isExplicit=!0),null!=e.tagi&&(this.hT=e.tagi,this.isExplicit=!1),null!=e.obj&&(e.obj instanceof t.ASN1Object?(this.asn1Object=e.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)):"object"==f(e.obj)&&(this.asn1Object=t.ASN1Util.newObject(e.obj),this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},null!=e&&this.setByParam(e)},Ke(ce.asn1.DERTaggedObject,ce.asn1.ASN1Object);var ce,ue,le,de=new function(){};function he(e){for(var t=new Array,r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function fe(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}function pe(e){for(var t="",r=0;r<e.length;r++){var n=e[r].toString(16);1==n.length&&(n="0"+n),t+=n}return t}function ge(e){return pe(he(e))}function ye(e){return(e=(e=e.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function ve(e){return e.length%4==2?e+="==":e.length%4==3&&(e+="="),(e=e.replace(/-/g,"+")).replace(/_/g,"/")}function me(e){return e.length%2==1&&(e="0"+e),ye(w(e))}function we(e){return S(ve(e))}function Se(e){return Te(Le(e))}function _e(e){return decodeURIComponent(Re(e))}function be(e){for(var t="",r=0;r<e.length-1;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t}function Ee(e){for(var t="",r=0;r<e.length;r++)t+=("0"+e.charCodeAt(r).toString(16)).slice(-2);return t}function Ae(e){return w(e)}function Fe(e){var t=Ae(e).replace(/(.{64})/g,"$1\r\n");return t.replace(/\r\n$/,"")}function Pe(e){return S(e.replace(/[^0-9A-Za-z\/+=]*/g,""))}function ke(e,t){return"-----BEGIN "+t+"-----\r\n"+Fe(e)+"\r\n-----END "+t+"-----\r\n"}function Ie(e,t){if(-1==e.indexOf("-----BEGIN "))throw"can't find PEM header: "+t;return Pe(e=void 0!==t?(e=e.replace(new RegExp("^[^]*-----BEGIN "+t+"-----"),"")).replace(new RegExp("-----END "+t+"-----[^]*$"),""):(e=e.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function xe(e){var t,r,n,i,o,s,a,c,u,l,d;if(d=e.match(/^(\d{2}|\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return c=d[1],t=parseInt(c),2===c.length&&(50<=t&&t<100?t=1900+t:0<=t&&t<50&&(t=2e3+t)),r=parseInt(d[2])-1,n=parseInt(d[3]),i=parseInt(d[4]),o=parseInt(d[5]),s=parseInt(d[6]),a=0,""!==(u=d[7])&&(l=(u.substr(1)+"00").substr(0,3),a=parseInt(l)),Date.UTC(t,r,n,i,o,s,a);throw"unsupported zulu format: "+e}function Ce(e){return~~(xe(e)/1e3)}function Te(e){return e.replace(/%/g,"")}function Re(e){return e.replace(/(..)/g,"%$1")}function Ue(e){var t="malformed IPv6 address";if(!e.match(/^[0-9A-Fa-f:]+$/))throw t;var r=(e=e.toLowerCase()).split(":").length-1;if(r<2)throw t;var n=":".repeat(7-r+2),i=(e=e.replace("::",n)).split(":");if(8!=i.length)throw t;for(var o=0;o<8;o++)i[o]=("0000"+i[o]).slice(-4);return i.join("")}function Oe(e){if(!e.match(/^[0-9A-Fa-f]{32}$/))throw"malformed IPv6 address octet";for(var t=(e=e.toLowerCase()).match(/.{1,4}/g),r=0;r<8;r++)t[r]=t[r].replace(/^0+/,""),""==t[r]&&(t[r]="0");var n=(e=":"+t.join(":")+":").match(/:(0:){2,}/g);if(null===n)return e.slice(1,-1);var i="";for(r=0;r<n.length;r++)n[r].length>i.length&&(i=n[r]);return(e=e.replace(i,"::")).slice(1,-1)}function De(e){var t="malformed hex value";if(!e.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw t;if(8!=e.length)return 32==e.length?Oe(e):e;try{return parseInt(e.substr(0,2),16)+"."+parseInt(e.substr(2,2),16)+"."+parseInt(e.substr(4,2),16)+"."+parseInt(e.substr(6,2),16)}catch(e){throw t}}function Ne(e){return e.match(/.{4}/g).map(function(e){var t=parseInt(e.substr(0,2),16),r=parseInt(e.substr(2),16);if(0==t&r<128)return String.fromCharCode(r);if(t<8){var n=128|63&r;return _e((192|(7&t)<<3|(192&r)>>6).toString(16)+n.toString(16))}n=128|(15&t)<<2|(192&r)>>6;var i=128|63&r;return _e((224|(240&t)>>4).toString(16)+n.toString(16)+i.toString(16))}).join("")}function Le(e){for(var t=encodeURIComponent(e),r="",n=0;n<t.length;n++)"%"==t[n]?(r+=t.substr(n,3),n+=2):r=r+"%"+ge(t[n]);return r}function He(e){return!(e.length%2!=0||!e.match(/^[0-9a-f]+$/)&&!e.match(/^[0-9A-F]+$/))}function je(e){return e.length%2==1?"0"+e:e.substr(0,1)>"7"?"00"+e:e}de.getLblen=function(e,t){if("8"!=e.substr(t+2,1))return 1;var r=parseInt(e.substr(t+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},de.getL=function(e,t){var r=de.getLblen(e,t);return r<1?"":e.substr(t+2,2*r)},de.getVblen=function(e,t){var r;return""==(r=de.getL(e,t))?-1:("8"===r.substr(0,1)?new b(r.substr(2),16):new b(r,16)).intValue()},de.getVidx=function(e,t){var r=de.getLblen(e,t);return r<0?r:t+2*(r+1)},de.getV=function(e,t){var r=de.getVidx(e,t),n=de.getVblen(e,t);return e.substr(r,2*n)},de.getTLV=function(e,t){return e.substr(t,2)+de.getL(e,t)+de.getV(e,t)},de.getTLVblen=function(e,t){return 2+2*de.getLblen(e,t)+2*de.getVblen(e,t)},de.getNextSiblingIdx=function(e,t){return de.getVidx(e,t)+2*de.getVblen(e,t)},de.getChildIdx=function(e,t){var r,n,i,o=de,s=[];r=o.getVidx(e,t),n=2*o.getVblen(e,t),"03"==e.substr(t,2)&&(r+=2,n-=2),i=0;for(var a=r;i<=n;){var c=o.getTLVblen(e,a);if((i+=c)<=n&&s.push(a),a+=c,i>=n)break}return s},de.getNthChildIdx=function(e,t,r){return de.getChildIdx(e,t)[r]},de.getIdxbyList=function(e,t,r,n){var i,o,s=de;return 0==r.length?void 0!==n&&e.substr(t,2)!==n?-1:t:(i=r.shift())>=(o=s.getChildIdx(e,t)).length?-1:s.getIdxbyList(e,o[i],r,n)},de.getIdxbyListEx=function(e,t,r,n){var i,o,s=de;if(0==r.length)return void 0!==n&&e.substr(t,2)!==n?-1:t;i=r.shift(),o=s.getChildIdx(e,t);for(var a=0,c=0;c<o.length;c++){var u=e.substr(o[c],2);if("number"==typeof i&&!s.isContextTag(u)&&a==i||"string"==typeof i&&s.isContextTag(u,i))return s.getIdxbyListEx(e,o[c],r,n);s.isContextTag(u)||a++}return-1},de.getTLVbyList=function(e,t,r,n){var i=de,o=i.getIdxbyList(e,t,r,n);return-1==o||o>=e.length?null:i.getTLV(e,o)},de.getTLVbyListEx=function(e,t,r,n){var i=de,o=i.getIdxbyListEx(e,t,r,n);return-1==o?null:i.getTLV(e,o)},de.getVbyList=function(e,t,r,n,i){var o,s,a=de;return-1==(o=a.getIdxbyList(e,t,r,n))||o>=e.length?null:(s=a.getV(e,o),!0===i&&(s=s.substr(2)),s)},de.getVbyListEx=function(e,t,r,n,i){var o,s,a=de;return-1==(o=a.getIdxbyListEx(e,t,r,n))?null:(s=a.getV(e,o),"03"==e.substr(o,2)&&!1!==i&&(s=s.substr(2)),s)},de.getInt=function(e,t,r){null==r&&(r=-1);try{var n=e.substr(t,2);if("02"!=n&&"03"!=n)return r;var i=de.getV(e,t);return"02"==n?parseInt(i,16):function(e){try{var t=e.substr(0,2);if("00"==t)return parseInt(e.substr(2),16);var r=parseInt(t,16),n=e.substr(2),i=parseInt(n,16).toString(2);return"0"==i&&(i="00000000"),i=i.slice(0,0-r),parseInt(i,2)}catch(e){return-1}}(i)}catch(e){return r}},de.getOID=function(e,t,r){null==r&&(r=null);try{return"06"!=e.substr(t,2)?r:function(e){if(!He(e))return null;try{var t=[],r=e.substr(0,2),n=parseInt(r,16);t[0]=new String(Math.floor(n/40)),t[1]=new String(n%40);for(var i=e.substr(2),o=[],s=0;s<i.length/2;s++)o.push(parseInt(i.substr(2*s,2),16));var a=[],c="";for(s=0;s<o.length;s++)128&o[s]?c+=Me((127&o[s]).toString(2),7):(c+=Me((127&o[s]).toString(2),7),a.push(new String(parseInt(c,2))),c="");var u=t.join(".");return a.length>0&&(u=u+"."+a.join(".")),u}catch(e){return null}}(de.getV(e,t))}catch(e){return r}},de.getOIDName=function(e,t,r){null==r&&(r=null);try{var n=de.getOID(e,t,r);if(n==r)return r;var i=ce.asn1.x509.OID.oid2name(n);return""==i?n:i}catch(e){return r}},de.getString=function(e,t,r){null==r&&(r=null);try{return be(de.getV(e,t))}catch(e){return r}},de.hextooidstr=function(e){var t=function(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e},r=[],n=e.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var o=e.substr(2),s=[],a=0;a<o.length/2;a++)s.push(parseInt(o.substr(2*a,2),16));var c=[],u="";for(a=0;a<s.length;a++)128&s[a]?u+=t((127&s[a]).toString(2),7):(u+=t((127&s[a]).toString(2),7),c.push(new String(parseInt(u,2))),u="");var l=r.join(".");return c.length>0&&(l=l+"."+c.join(".")),l},de.dump=function(e,t,r,n){var i=de,o=i.getV,s=i.dump,a=i.getChildIdx,c=e;e instanceof ce.asn1.ASN1Object&&(c=e.getEncodedHex());var u=function(e,t){return e.length<=2*t?e:e.substr(0,t)+"..(total "+e.length/2+"bytes).."+e.substr(e.length-t,t)};void 0===t&&(t={ommit_long_octet:32}),void 0===r&&(r=0),void 0===n&&(n="");var l,d=t.ommit_long_octet;if("01"==(l=c.substr(r,2)))return"00"==(h=o(c,r))?n+"BOOLEAN FALSE\n":n+"BOOLEAN TRUE\n";if("02"==l)return n+"INTEGER "+u(h=o(c,r),d)+"\n";if("03"==l){var h=o(c,r);return i.isASN1HEX(h.substr(2))?(_=n+"BITSTRING, encapsulates\n")+s(h.substr(2),t,0,n+" "):n+"BITSTRING "+u(h,d)+"\n"}if("04"==l)return h=o(c,r),i.isASN1HEX(h)?(_=n+"OCTETSTRING, encapsulates\n")+s(h,t,0,n+" "):n+"OCTETSTRING "+u(h,d)+"\n";if("05"==l)return n+"NULL\n";if("06"==l){var f=o(c,r),p=ce.asn1.ASN1Util.oidHexToInt(f),g=ce.asn1.x509.OID.oid2name(p),y=p.replace(/\./g," ");return""!=g?n+"ObjectIdentifier "+g+" ("+y+")\n":n+"ObjectIdentifier ("+y+")\n"}if("0a"==l)return n+"ENUMERATED "+parseInt(o(c,r))+"\n";if("0c"==l)return n+"UTF8String '"+_e(o(c,r))+"'\n";if("13"==l)return n+"PrintableString '"+_e(o(c,r))+"'\n";if("14"==l)return n+"TeletexString '"+_e(o(c,r))+"'\n";if("16"==l)return n+"IA5String '"+_e(o(c,r))+"'\n";if("17"==l)return n+"UTCTime "+_e(o(c,r))+"\n";if("18"==l)return n+"GeneralizedTime "+_e(o(c,r))+"\n";if("1a"==l)return n+"VisualString '"+_e(o(c,r))+"'\n";if("1e"==l)return n+"BMPString '"+Ne(o(c,r))+"'\n";if("30"==l){if("3000"==c.substr(r,4))return n+"SEQUENCE {}\n";_=n+"SEQUENCE\n";var v=t;if((2==(S=a(c,r)).length||3==S.length)&&"06"==c.substr(S[0],2)&&"04"==c.substr(S[S.length-1],2)){g=i.oidname(o(c,S[0]));var m=JSON.parse(JSON.stringify(t));m.x509ExtName=g,v=m}for(var w=0;w<S.length;w++)_+=s(c,v,S[w],n+" ");return _}if("31"==l){_=n+"SET\n";var S=a(c,r);for(w=0;w<S.length;w++)_+=s(c,t,S[w],n+" ");return _}if(128&(l=parseInt(l,16))){var _,b=31&l;if(32&l){for(_=n+"["+b+"]\n",S=a(c,r),w=0;w<S.length;w++)_+=s(c,t,S[w],n+" ");return _}return h=o(c,r),de.isASN1HEX(h)?(_=n+"["+b+"]\n")+s(h,t,0,n+" "):(("68747470"==h.substr(0,8)||"subjectAltName"===t.x509ExtName&&2==b)&&(h=_e(h)),n+"["+b+"] "+h+"\n")}return n+"UNKNOWN("+l+") "+o(c,r)+"\n"},de.isContextTag=function(e,t){var r,n;e=e.toLowerCase();try{r=parseInt(e,16)}catch(e){return-1}if(void 0===t)return 128==(192&r);try{return null!=t.match(/^\[[0-9]+\]$/)&&!((n=parseInt(t.substr(1,t.length-1),10))>31)&&128==(192&r)&&(31&r)==n}catch(e){return!1}},de.isASN1HEX=function(e){var t=de;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0);return e.length-n.length-i.length==2*r},de.checkStrictDER=function(e,t,r,n,i){var o=de;if(void 0===r){if("string"!=typeof e)throw new Error("not hex string");if(e=e.toLowerCase(),!ce.lang.String.isHex(e))throw new Error("not hex string");r=e.length,i=(n=e.length/2)<128?1:Math.ceil(n.toString(16))+1}if(o.getL(e,t).length>2*i)throw new Error("L of TLV too long: idx="+t);var s=o.getVblen(e,t);if(s>n)throw new Error("value of L too long than hex: idx="+t);var a=o.getTLV(e,t),c=a.length-2-o.getL(e,t).length;if(c!==2*s)throw new Error("V string length and L's value not the same:"+c+"/"+2*s);if(0===t&&e.length!=a.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+a.length);var u=e.substr(t,2);if("02"===u){var l=o.getVidx(e,t);if("00"==e.substr(l,2)&&e.charCodeAt(l+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var d=o.getVblen(e,t),h=0,f=o.getChildIdx(e,t),p=0;p<f.length;p++)h+=o.getTLV(e,f[p]).length,o.checkStrictDER(e,f[p],r,n,i);if(2*d!=h)throw new Error("sum of children's TLV length and L unmatch: "+2*d+"!="+h)}},de.oidname=function(e){var t=ce.asn1;ce.lang.String.isHex(e)&&(e=t.ASN1Util.oidHexToInt(e));var r=t.x509.OID.oid2name(e);return""===r&&(r=e),r},void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.lang&&ce.lang||(ce.lang={}),ce.lang.String=function(){},"function"==typeof e?(t.utf8tob64u=ue=function(t){return ye(e.from(t,"utf8").toString("base64"))},t.b64utoutf8=le=function(t){return e.from(ve(t),"base64").toString("utf8")}):(t.utf8tob64u=ue=function(e){return me(Te(Le(e)))},t.b64utoutf8=le=function(e){return decodeURIComponent(Re(we(e)))}),ce.lang.String.isInteger=function(e){return!!e.match(/^[0-9]+$/)||!!e.match(/^-[0-9]+$/)},ce.lang.String.isHex=function(e){return He(e)},ce.lang.String.isBase64=function(e){return!(!(e=e.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||e.length%4!=0)},ce.lang.String.isBase64URL=function(e){return!e.match(/[+/=]/)&&(e=ve(e),ce.lang.String.isBase64(e))},ce.lang.String.isIntegerArray=function(e){return!!(e=e.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},ce.lang.String.isPrintable=function(e){return null!==e.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},ce.lang.String.isIA5=function(e){return null!==e.match(/^[\x20-\x21\x23-\x7f]*$/)},ce.lang.String.isMail=function(e){return null!==e.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var Me=function(e,t,r){return null==r&&(r="0"),e.length>=t?e:new Array(t-e.length+1).join(r)+e};function Ke(e,t){var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e,e.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.crypto&&ce.crypto||(ce.crypto={}),ce.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:y.algo.MD5,sha1:y.algo.SHA1,sha224:y.algo.SHA224,sha256:y.algo.SHA256,sha384:y.algo.SHA384,sha512:y.algo.SHA512,ripemd160:y.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(void 0===this.DIGESTINFOHEAD[t])throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,r){var n=this.getDigestInfoHex(e,t),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+t;for(var o="0001",s="00"+n,a="",c=i-4-s.length,u=0;u<c;u+=2)a+="ff";return o+a+s},this.hashString=function(e,t){return new ce.crypto.MessageDigest({alg:t}).digestString(e)},this.hashHex=function(e,t){return new ce.crypto.MessageDigest({alg:t}).digestHex(e)},this.sha1=function(e){return this.hashString(e,"sha1")},this.sha256=function(e){return this.hashString(e,"sha256")},this.sha256Hex=function(e){return this.hashHex(e,"sha256")},this.sha512=function(e){return this.hashString(e,"sha512")},this.sha512Hex=function(e){return this.hashHex(e,"sha512")},this.isKey=function(e){return e instanceof ne||e instanceof ce.crypto.DSA||e instanceof ce.crypto.ECDSA}},ce.crypto.Util.md5=function(e){return new ce.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(e)},ce.crypto.Util.ripemd160=function(e){return new ce.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(e)},ce.crypto.Util.SECURERANDOMGEN=new ee,ce.crypto.Util.getRandomHexOfNbytes=function(e){var t=new Array(e);return ce.crypto.Util.SECURERANDOMGEN.nextBytes(t),pe(t)},ce.crypto.Util.getRandomBigIntegerOfNbytes=function(e){return new b(ce.crypto.Util.getRandomHexOfNbytes(e),16)},ce.crypto.Util.getRandomHexOfNbits=function(e){var t=e%8,r=new Array((e-t)/8+1);return ce.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<t&255^255)&r[0],pe(r)},ce.crypto.Util.getRandomBigIntegerOfNbits=function(e){return new b(ce.crypto.Util.getRandomHexOfNbits(e),16)},ce.crypto.Util.getRandomBigIntegerZeroToMax=function(e){for(var t=e.bitLength();;){var r=ce.crypto.Util.getRandomBigIntegerOfNbits(t);if(-1!=e.compareTo(r))return r}},ce.crypto.Util.getRandomBigIntegerMinToMax=function(e,t){var r=e.compareTo(t);if(1==r)throw"biMin is greater than biMax";if(0==r)return e;var n=t.subtract(e);return ce.crypto.Util.getRandomBigIntegerZeroToMax(n).add(e)},ce.crypto.MessageDigest=function(e){this.setAlgAndProvider=function(e,t){if(null!==(e=ce.crypto.MessageDigest.getCanonicalAlgName(e))&&void 0===t&&(t=ce.crypto.Util.DEFAULTPROVIDER[e]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(e)&&"cryptojs"==t){try{this.md=ce.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[e].create()}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=y.enc.Hex.parse(e);this.md.update(t)},this.digest=function(){return this.md.finalize().toString(y.enc.Hex)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}if(-1!=":sha256:".indexOf(e)&&"sjcl"==t){try{this.md=new sjcl.hash.sha256}catch(t){throw"setAlgAndProvider hash alg set fail alg="+e+"/"+t}this.updateString=function(e){this.md.update(e)},this.updateHex=function(e){var t=sjcl.codec.hex.toBits(e);this.md.update(t)},this.digest=function(){var e=this.md.finalize();return sjcl.codec.hex.fromBits(e)},this.digestString=function(e){return this.updateString(e),this.digest()},this.digestHex=function(e){return this.updateHex(e),this.digest()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==e&&void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=ce.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},ce.crypto.MessageDigest.getCanonicalAlgName=function(e){return"string"==typeof e&&(e=(e=e.toLowerCase()).replace(/-/,"")),e},ce.crypto.MessageDigest.getHashLength=function(e){var t=ce.crypto.MessageDigest,r=t.getCanonicalAlgName(e);if(void 0===t.HASHLENGTH[r])throw"not supported algorithm: "+e;return t.HASHLENGTH[r]},ce.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},ce.crypto.Mac=function(e){this.setAlgAndProvider=function(e,t){if(null==(e=e.toLowerCase())&&(e="hmacsha1"),"hmac"!=(e=e.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+e;void 0===t&&(t=ce.crypto.Util.DEFAULTPROVIDER[e]),this.algProv=e+"/"+t;var r=e.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==t){try{var n=ce.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=y.algo.HMAC.create(n,this.pass)}catch(e){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+e}this.updateString=function(e){this.mac.update(e)},this.updateHex=function(e){var t=y.enc.Hex.parse(e);this.mac.update(t)},this.doFinal=function(){return this.mac.finalize().toString(y.enc.Hex)},this.doFinalString=function(e){return this.updateString(e),this.doFinal()},this.doFinalHex=function(e){return this.updateHex(e),this.doFinal()}}},this.updateString=function(e){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(e){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(e){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(e){if("string"==typeof e){var t=e;return e.length%2!=1&&e.match(/^[0-9A-Fa-f]+$/)||(t=Ee(e)),void(this.pass=y.enc.Hex.parse(t))}if("object"!=(void 0===e?"undefined":f(e)))throw"KJUR.crypto.Mac unsupported password type: "+e;if(t=null,void 0!==e.hex){if(e.hex.length%2!=0||!e.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+e.hex;t=e.hex}if(void 0!==e.utf8&&(t=Se(e.utf8)),void 0!==e.rstr&&(t=Ee(e.rstr)),void 0!==e.b64&&(t=S(e.b64)),void 0!==e.b64u&&(t=we(e.b64u)),null==t)throw"KJUR.crypto.Mac unsupported password type: "+e;this.pass=y.enc.Hex.parse(t)},void 0!==e&&(void 0!==e.pass&&this.setPassword(e.pass),void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov&&(this.provName=ce.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},ce.crypto.Signature=function(e){var t=null;if(this._setAlgNames=function(){var e=this.algName.match(/^(.+)with(.+)$/);e&&(this.mdAlgName=e[1].toLowerCase(),this.pubkeyAlgName=e[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(e,t){for(var r="",n=t/4-e.length,i=0;i<n;i++)r+="0";return r+e},this.setAlgAndProvider=function(e,t){if(this._setAlgNames(),"cryptojs/jsrsa"!=t)throw new Error("provider not supported: "+t);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new ce.crypto.MessageDigest({alg:this.mdAlgName})}catch(e){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+e)}this.init=function(e,t){var r=null;try{r=void 0===t?Be.getKey(e):Be.getKey(e,t)}catch(e){throw"init failed:"+e}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(e){this.md.updateString(e)},this.updateHex=function(e){this.md.updateHex(e)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==ce.crypto.ECDSA&&(this.prvKey=new ce.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof ne&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof ne&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof ce.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof ce.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(e){return this.updateString(e),this.sign()},this.signHex=function(e){return this.updateHex(e),this.sign()},this.verify=function(e){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==ce.crypto.ECDSA&&(this.pubKey=new ce.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof ne&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,e,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof ne&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==ce.crypto.ECDSA&&this.pubKey instanceof ce.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);if(void 0!==ce.crypto.DSA&&this.pubKey instanceof ce.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,e);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(e,t){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(e){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(e){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(e){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(e){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(e){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=e,void 0!==e&&(void 0!==e.alg&&(this.algName=e.alg,void 0===e.prov?this.provName=ce.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=e.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==e.psssaltlen&&(this.pssSaltLen=e.psssaltlen),void 0!==e.prvkeypem)){if(void 0!==e.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{t=Be.getKey(e.prvkeypem),this.init(t)}catch(e){throw"fatal error to load pem private key: "+e}}},ce.crypto.Cipher=function(e){},ce.crypto.Cipher.encrypt=function(e,t,r){if(t instanceof ne&&t.isPublic){var n=ce.crypto.Cipher.getAlgByKeyAndName(t,r);if("RSA"===n)return t.encrypt(e);if("RSAOAEP"===n)return t.encryptOAEP(e,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return t.encryptOAEP(e,"sha"+i[1]);throw"Cipher.encrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.encrypt: unsupported key or algorithm"},ce.crypto.Cipher.decrypt=function(e,t,r){if(t instanceof ne&&t.isPrivate){var n=ce.crypto.Cipher.getAlgByKeyAndName(t,r);if("RSA"===n)return t.decrypt(e);if("RSAOAEP"===n)return t.decryptOAEP(e,"sha1");var i=n.match(/^RSAOAEP(\d+)$/);if(null!==i)return t.decryptOAEP(e,"sha"+i[1]);throw"Cipher.decrypt: unsupported algorithm for RSAKey: "+r}throw"Cipher.decrypt: unsupported key or algorithm"},ce.crypto.Cipher.getAlgByKeyAndName=function(e,t){if(e instanceof ne){if(-1!=":RSA:RSAOAEP:RSAOAEP224:RSAOAEP256:RSAOAEP384:RSAOAEP512:".indexOf(t))return t;if(null==t)return"RSA";throw"getAlgByKeyAndName: not supported algorithm name for RSAKey: "+t}throw"getAlgByKeyAndName: not supported algorithm name: "+t},ce.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040023":"secp521r1","2b81040022":"secp384r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.crypto&&ce.crypto||(ce.crypto={}),ce.crypto.ECDSA=function(e){var t=Error,r=b,n=oe,i=ce.crypto.ECDSA,o=ce.crypto.ECParameterDB,s=i.getName,a=de,c=a.getVbyListEx,u=a.isASN1HEX,l=new ee;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(e){return new r(e.bitLength(),l).mod(e.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(e){this.ecparams=o.getByName(e),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=e},this.setPrivateKeyHex=function(e){this.isPrivate=!0,this.prvKeyHex=e},this.setPublicKeyHex=function(e){this.isPublic=!0,this.pubKeyHex=e},this.getPublicKeyXYHex=function(){var e=this.pubKeyHex;if("04"!==e.substr(0,2))throw"this method supports uncompressed format(04) only";var t=this.ecparams.keylen/4;if(e.length!==2+2*t)throw"malformed public key hex length";var r={};return r.x=e.substr(2,t),r.y=e.substr(2+t),r},this.getShortNISTPCurveName=function(){var e=this.curveName;return"secp256r1"===e||"NIST P-256"===e||"P-256"===e||"prime256v1"===e?"P-256":"secp384r1"===e||"NIST P-384"===e||"P-384"===e?"P-384":null},this.generateKeyPairHex=function(){var e=this.ecparams.n,t=this.getBigRandom(e),r=this.ecparams.G.multiply(t),n=r.getX().toBigInteger(),i=r.getY().toBigInteger(),o=this.ecparams.keylen/4,s=("0000000000"+t.toString(16)).slice(-o),a="04"+("0000000000"+n.toString(16)).slice(-o)+("0000000000"+i.toString(16)).slice(-o);return this.setPrivateKeyHex(s),this.setPublicKeyHex(a),{ecprvhex:s,ecpubhex:a}},this.signWithMessageHash=function(e){return this.signHex(e,this.prvKeyHex)},this.signHex=function(e,t){var n=new r(t,16),o=this.ecparams.n,s=new r(e.substring(0,this.ecparams.keylen/4),16);do{var a=this.getBigRandom(o),c=this.ecparams.G.multiply(a).getX().toBigInteger().mod(o)}while(c.compareTo(r.ZERO)<=0);var u=a.modInverse(o).multiply(s.add(n.multiply(c))).mod(o);return i.biRSSigToASN1Sig(c,u)},this.sign=function(e,t){var n=t,i=this.ecparams.n,o=r.fromByteArrayUnsigned(e);do{var s=this.getBigRandom(i),a=this.ecparams.G.multiply(s).getX().toBigInteger().mod(i)}while(a.compareTo(b.ZERO)<=0);var c=s.modInverse(i).multiply(o.add(n.multiply(a))).mod(i);return this.serializeSig(a,c)},this.verifyWithMessageHash=function(e,t){return this.verifyHex(e,t,this.pubKeyHex)},this.verifyHex=function(e,t,o){try{var s,a,c=i.parseSigHex(t);s=c.r,a=c.s;var u=n.decodeFromHex(this.ecparams.curve,o),l=new r(e.substring(0,this.ecparams.keylen/4),16);return this.verifyRaw(l,s,a,u)}catch(e){return!1}},this.verify=function(e,t,i){var o,s,a;if(Bitcoin.Util.isArray(t)){var c=this.parseSig(t);o=c.r,s=c.s}else{if("object"!==(void 0===t?"undefined":f(t))||!t.r||!t.s)throw"Invalid value for signature";o=t.r,s=t.s}if(i instanceof oe)a=i;else{if(!Bitcoin.Util.isArray(i))throw"Invalid format for pubkey value, must be byte array or ECPointFp";a=n.decodeFrom(this.ecparams.curve,i)}var u=r.fromByteArrayUnsigned(e);return this.verifyRaw(u,o,s,a)},this.verifyRaw=function(e,t,n,i){var o=this.ecparams.n,s=this.ecparams.G;if(t.compareTo(r.ONE)<0||t.compareTo(o)>=0)return!1;if(n.compareTo(r.ONE)<0||n.compareTo(o)>=0)return!1;var a=n.modInverse(o),c=e.multiply(a).mod(o),u=t.multiply(a).mod(o);return s.multiply(c).add(i.multiply(u)).getX().toBigInteger().mod(o).equals(t)},this.serializeSig=function(e,t){var r=e.toByteArraySigned(),n=t.toByteArraySigned(),i=[];return i.push(2),i.push(r.length),(i=i.concat(r)).push(2),i.push(n.length),(i=i.concat(n)).unshift(i.length),i.unshift(48),i},this.parseSig=function(e){var t;if(48!=e[0])throw new Error("Signature not a valid DERSequence");if(2!=e[t=2])throw new Error("First element in signature must be a DERInteger");var n=e.slice(t+2,t+2+e[t+1]);if(2!=e[t+=2+e[t+1]])throw new Error("Second element in signature must be a DERInteger");var i=e.slice(t+2,t+2+e[t+1]);return t+=2+e[t+1],{r:r.fromByteArrayUnsigned(n),s:r.fromByteArrayUnsigned(i)}},this.parseSigCompact=function(e){if(65!==e.length)throw"Signature has the wrong length";var t=e[0]-27;if(t<0||t>7)throw"Invalid signature type";var n=this.ecparams.n;return{r:r.fromByteArrayUnsigned(e.slice(1,33)).mod(n),s:r.fromByteArrayUnsigned(e.slice(33,65)).mod(n),i:t}},this.readPKCS5PrvKeyHex=function(e){if(!1===u(e))throw new Error("not ASN.1 hex string");var t,r,n;try{t=c(e,0,["[0]",0],"06"),r=c(e,0,[1],"04");try{n=c(e,0,["[1]",0],"03")}catch(e){}}catch(e){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=s(t),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(e){if(!1===u(e))throw new t("not ASN.1 hex string");var r,n,i;try{c(e,0,[1,0],"06"),r=c(e,0,[1,1],"06"),n=c(e,0,[2,0,1],"04");try{i=c(e,0,[2,0,"[1]",0],"03")}catch(e){}}catch(e){throw new t("malformed PKCS#8 plain ECC private key")}if(this.curveName=s(r),void 0===this.curveName)throw new t("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(n),this.isPublic=!1},this.readPKCS8PubKeyHex=function(e){if(!1===u(e))throw new t("not ASN.1 hex string");var r,n;try{c(e,0,[0,0],"06"),r=c(e,0,[0,1],"06"),n=c(e,0,[1],"03")}catch(e){throw new t("malformed PKCS#8 ECC public key")}if(this.curveName=s(r),null===this.curveName)throw new t("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},this.readCertPubKeyHex=function(e,r){if(!1===u(e))throw new t("not ASN.1 hex string");var n,i;try{n=c(e,0,[0,5,0,1],"06"),i=c(e,0,[0,5,1],"03")}catch(e){throw new t("malformed X.509 certificate ECC public key")}if(this.curveName=s(n),null===this.curveName)throw new t("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},void 0!==e&&void 0!==e.curve&&(this.curveName=e.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==e&&(void 0!==e.prv&&this.setPrivateKeyHex(e.prv),void 0!==e.pub&&this.setPublicKeyHex(e.pub))},ce.crypto.ECDSA.parseSigHex=function(e){var t=ce.crypto.ECDSA.parseSigHexInHexRS(e);return{r:new b(t.r,16),s:new b(t.s,16)}},ce.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=de,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),"30"!=e.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(2!=i.length)throw new Error("signature shall have two elements");var o=i[0],s=i[1];if("02"!=e.substr(o,2))throw new Error("1st item not ASN.1 integer");if("02"!=e.substr(s,2))throw new Error("2nd item not ASN.1 integer");return{r:n(e,o),s:n(e,s)}},ce.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=ce.crypto.ECDSA.parseSigHexInHexRS(e),r=t.r,n=t.s;if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==n.substr(0,2)&&n.length%32==2&&(n=n.substr(2)),r.length%32==30&&(r="00"+r),n.length%32==30&&(n="00"+n),r.length%32!=0)throw"unknown ECDSA sig r length error";if(n.length%32!=0)throw"unknown ECDSA sig s length error";return r+n},ce.crypto.ECDSA.concatSigToASN1Sig=function(e){if(e.length/2*8%128!=0)throw"unknown ECDSA concatinated r-s sig length error";var t=e.substr(0,e.length/2),r=e.substr(e.length/2);return ce.crypto.ECDSA.hexRSSigToASN1Sig(t,r)},ce.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new b(e,16),n=new b(t,16);return ce.crypto.ECDSA.biRSSigToASN1Sig(r,n)},ce.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=ce.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t});return new r.DERSequence({array:[n,i]}).getEncodedHex()},ce.crypto.ECDSA.getName=function(e){return"2b8104001f"===e?"secp192k1":"2a8648ce3d030107"===e?"secp256r1":"2b8104000a"===e?"secp256k1":"2b81040021"===e?"secp224r1":"2b81040022"===e?"secp384r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(e)?"secp256r1":-1!=="|secp256k1|".indexOf(e)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(e)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(e)?"secp384r1":null},void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.crypto&&ce.crypto||(ce.crypto={}),ce.crypto.ECParameterDB=new function(){var e={},t={};function r(e){return new b(e,16)}this.getByName=function(r){var n=r;if(void 0!==t[n]&&(n=t[r]),void 0!==e[n])return e[n];throw"unregistered EC curve name: "+n},this.regist=function(n,i,o,s,a,c,u,l,d,h,f,p){e[n]={};var g=r(o),y=r(s),v=r(a),m=r(c),w=r(u),S=new se(g,y,v),_=S.decodePointHex("04"+l+d);e[n].name=n,e[n].keylen=i,e[n].curve=S,e[n].G=_,e[n].n=m,e[n].h=w,e[n].oid=f,e[n].info=p;for(var b=0;b<h.length;b++)t[h[b]]=n}},ce.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),ce.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),ce.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),ce.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),ce.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),ce.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),ce.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),ce.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),ce.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),ce.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]);var Be=function(){var e=function(e,r,n){return t(y.AES,e,r,n)},t=function(e,t,r,n){var i=y.enc.Hex.parse(t),o=y.enc.Hex.parse(r),s=y.enc.Hex.parse(n),a={};a.key=o,a.iv=s,a.ciphertext=i;var c=e.decrypt(a,o,{iv:s});return y.enc.Hex.stringify(c)},r=function(e,t,r){return n(y.AES,e,t,r)},n=function(e,t,r,n){var i=y.enc.Hex.parse(t),o=y.enc.Hex.parse(r),s=y.enc.Hex.parse(n),a=e.encrypt(i,o,{iv:s}),c=y.enc.Hex.parse(a.toString());return y.enc.Base64.stringify(c)},i={"AES-256-CBC":{proc:e,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(e,r,n){return t(y.TripleDES,e,r,n)},eproc:function(e,t,r){return n(y.TripleDES,e,t,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(e,r,n){return t(y.DES,e,r,n)},eproc:function(e,t,r){return n(y.DES,e,t,r)},keylen:8,ivlen:8}},o=function(e){var t={},r=e.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(t.cipher=r[1],t.ivsalt=r[2]);var n=e.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));n&&(t.type=n[1]);var i=-1,o=0;-1!=e.indexOf("\r\n\r\n")&&(i=e.indexOf("\r\n\r\n"),o=2),-1!=e.indexOf("\n\n")&&(i=e.indexOf("\n\n"),o=1);var s=e.indexOf("-----END");if(-1!=i&&-1!=s){var a=e.substring(i+2*o,s-o);a=a.replace(/\s+/g,""),t.data=a}return t},s=function(e,t,r){for(var n=r.substring(0,16),o=y.enc.Hex.parse(n),s=y.enc.Utf8.parse(t),a=i[e].keylen+i[e].ivlen,c="",u=null;;){var l=y.algo.MD5.create();if(null!=u&&l.update(u),l.update(s),l.update(o),u=l.finalize(),(c+=y.enc.Hex.stringify(u)).length>=2*a)break}var d={};return d.keyhex=c.substr(0,2*i[e].keylen),d.ivhex=c.substr(2*i[e].keylen,2*i[e].ivlen),d},a=function(e,t,r,n){var o=y.enc.Base64.parse(e),s=y.enc.Hex.stringify(o);return(0,i[t].proc)(s,r,n)};return{version:"1.0.0",parsePKCS5PEM:function(e){return o(e)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(e,t,r){return s(e,t,r)},decryptKeyB64:function(e,t,r,n){return a(e,t,r,n)},getDecryptedKeyHex:function(e,t){var r=o(e),n=(r.type,r.cipher),i=r.ivsalt,c=r.data,u=s(n,t,i).keyhex;return a(c,n,u,i)},getEncryptedPKCS5PEMFromPrvKeyHex:function(e,t,r,n,o){var a="";if(void 0!==n&&null!=n||(n="AES-256-CBC"),void 0===i[n])throw new Error("KEYUTIL unsupported algorithm: "+n);void 0!==o&&null!=o||(o=function(e){var t=y.lib.WordArray.random(e);return y.enc.Hex.stringify(t)}(i[n].ivlen).toUpperCase());var c=function(e,t,r,n){return(0,i[t].eproc)(e,r,n)}(t,n,s(n,r,o).keyhex,o);return a="-----BEGIN "+e+" PRIVATE KEY-----\r\n",a+="Proc-Type: 4,ENCRYPTED\r\n",a+="DEK-Info: "+n+","+o+"\r\n",a+="\r\n",(a+=c.replace(/(.{64})/g,"$1\r\n"))+"\r\n-----END "+e+" PRIVATE KEY-----\r\n"},parseHexOfEncryptedPKCS8:function(e){var t=de,r=t.getChildIdx,n=t.getV,i={},o=r(e,0);if(2!=o.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+o.length);i.ciphertext=n(e,o[1]);var s=r(e,o[0]);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+s.length);if("2a864886f70d01050d"!=n(e,s[0]))throw new Error("this only supports pkcs5PBES2");var a=r(e,s[1]);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+a.length);var c=r(e,a[1]);if(2!=c.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+c.length);if("2a864886f70d0307"!=n(e,c[0]))throw"this only supports TripleDES";i.encryptionSchemeAlg="TripleDES",i.encryptionSchemeIV=n(e,c[1]);var u=r(e,a[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=n(e,u[0]))throw new Error("this only supports pkcs5PBKDF2");var l=r(e,u[1]);if(l.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+l.length);i.pbkdf2Salt=n(e,l[0]);var d=n(e,l[1]);try{i.pbkdf2Iter=parseInt(d,16)}catch(e){throw new Error("malformed format pbkdf2Iter: "+d)}return i},getPBKDF2KeyHexFromParam:function(e,t){var r=y.enc.Hex.parse(e.pbkdf2Salt),n=e.pbkdf2Iter,i=y.PBKDF2(t,r,{keySize:6,iterations:n});return y.enc.Hex.stringify(i)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(e,t){var r=Ie(e,"ENCRYPTED PRIVATE KEY"),n=this.parseHexOfEncryptedPKCS8(r),i=Be.getPBKDF2KeyHexFromParam(n,t),o={};o.ciphertext=y.enc.Hex.parse(n.ciphertext);var s=y.enc.Hex.parse(i),a=y.enc.Hex.parse(n.encryptionSchemeIV),c=y.TripleDES.decrypt(o,s,{iv:a});return y.enc.Hex.stringify(c)},getKeyFromEncryptedPKCS8PEM:function(e,t){var r=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(e,t);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(e){var t=de,r=t.getChildIdx,n=t.getV,i={algparam:null};if("30"!=e.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var o=r(e,0);if(o.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=e.substr(o[1],2))throw new Error("malformed PKCS8 private key(code:003)");var s=r(e,o[1]);if(2!=s.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=e.substr(s[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(i.algoid=n(e,s[0]),"06"==e.substr(s[1],2)&&(i.algparam=n(e,s[1])),"04"!=e.substr(o[2],2))throw new Error("malformed PKCS8 private key(code:006)");return i.keyidx=t.getVidx(e,o[2]),i},getKeyFromPlainPrivatePKCS8PEM:function(e){var t=Ie(e,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(t)},getKeyFromPlainPrivatePKCS8Hex:function(e){var t,r=this.parsePlainPrivatePKCS8Hex(e);if("2a864886f70d010101"==r.algoid)t=new ne;else if("2a8648ce380401"==r.algoid)t=new ce.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");t=new ce.crypto.ECDSA}return t.readPKCS8PrvKeyHex(e),t},_getKeyFromPublicPKCS8Hex:function(e){var t,r=de.getVbyList(e,0,[0,0],"06");if("2a864886f70d010101"===r)t=new ne;else if("2a8648ce380401"===r)t=new ce.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");t=new ce.crypto.ECDSA}return t.readPKCS8PubKeyHex(e),t},parsePublicRawRSAKeyHex:function(e){var t=de,r=t.getChildIdx,n=t.getV,i={};if("30"!=e.substr(0,2))throw new Error("malformed RSA key(code:001)");var o=r(e,0);if(2!=o.length)throw new Error("malformed RSA key(code:002)");if("02"!=e.substr(o[0],2))throw new Error("malformed RSA key(code:003)");if(i.n=n(e,o[0]),"02"!=e.substr(o[1],2))throw new Error("malformed RSA key(code:004)");return i.e=n(e,o[1]),i},parsePublicPKCS8Hex:function(e){var t=de,r=t.getChildIdx,n=t.getV,i={algparam:null},o=r(e,0);if(2!=o.length)throw new Error("outer DERSequence shall have 2 elements: "+o.length);var s=o[0];if("30"!=e.substr(s,2))throw new Error("malformed PKCS8 public key(code:001)");var a=r(e,s);if(2!=a.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=e.substr(a[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(i.algoid=n(e,a[0]),"06"==e.substr(a[1],2)?i.algparam=n(e,a[1]):"30"==e.substr(a[1],2)&&(i.algparam={},i.algparam.p=t.getVbyList(e,a[1],[0],"02"),i.algparam.q=t.getVbyList(e,a[1],[1],"02"),i.algparam.g=t.getVbyList(e,a[1],[2],"02")),"03"!=e.substr(o[1],2))throw new Error("malformed PKCS8 public key(code:004)");return i.key=n(e,o[1]).substr(2),i}}}();function We(e,t){for(var r="",n=t/4-e.length,i=0;i<n;i++)r+="0";return r+e}function Je(e,t,r){for(var n="",i=0;n.length<t;)n+=be(r(Ee(e+String.fromCharCode.apply(String,[(4278190080&i)>>24,(16711680&i)>>16,(65280&i)>>8,255&i])))),i+=1;return n}function Ve(e){for(var t in ce.crypto.Util.DIGESTINFOHEAD){var r=ce.crypto.Util.DIGESTINFOHEAD[t],n=r.length;if(e.substring(0,n)==r)return[t,e.substring(n)]}return[]}function qe(e){var t,r=de,n=r.getChildIdx,i=r.getV,o=r.getTLV,s=r.getVbyList,a=r.getVbyListEx,c=r.getTLVbyList,u=r.getTLVbyListEx,l=r.getIdxbyList,d=r.getIdxbyListEx,h=r.getVidx,f=r.getInt,p=r.oidname,g=r.hextooidstr,y=Ie;try{t=ce.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(e){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var e=c(this.hex,0,[0,0]);if("a0"==e.substr(0,2)){var t=c(e,0,[0]),r=f(t,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return a(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var e=u(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(e)},this.getAlgorithmIdentifierName=function(e){for(var r in t)if(e===t[r])return r;return p(a(e,0,[0],"06"))},this.getIssuer=function(){return this.getX500Name(this.getIssuerHex())},this.getIssuerHex=function(){return c(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(){return this.getX500Name(this.getSubjectHex())},this.getSubjectHex=function(){return c(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var e=s(this.hex,0,[0,4+this.foffset,0]);return e=e.replace(/(..)/g,"%$1"),decodeURIComponent(e)},this.getNotAfter=function(){var e=s(this.hex,0,[0,4+this.foffset,1]);return e=e.replace(/(..)/g,"%$1"),decodeURIComponent(e)},this.getPublicKeyHex=function(){return r.getTLVbyList(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var e=this.getPublicKeyIdx();return l(this.hex,e,[1,0],"30")},this.getPublicKey=function(){return Be.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var e=c(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(e)},this.getSignatureValueHex=function(){return s(this.hex,0,[2],"03",!0)},this.verifySignature=function(e){var t=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),n=c(this.hex,0,[0],"30"),i=new ce.crypto.Signature({alg:t});return i.init(e),i.updateHex(n),i.verify(r)},this.parseExt=function(e){var t,o,a;if(void 0===e){if(a=this.hex,3!==this.version)return-1;t=l(a,0,[0,7,0],"30"),o=n(a,t)}else{a=Ie(e);var c=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=i(a,c))return void(this.aExtInfo=new Array);t=l(a,0,[0,3,0,1,0],"30"),o=n(a,t),this.hex=a}this.aExtInfo=new Array;for(var u=0;u<o.length;u++){var d={critical:!1},f=0;3===n(a,o[u]).length&&(d.critical=!0,f=1),d.oid=r.hextooidstr(s(a,o[u],[0],"06"));var p=l(a,o[u],[1+f]);d.vidx=h(a,p),this.aExtInfo.push(d)}},this.getExtInfo=function(e){var t=this.aExtInfo,r=e;if(e.match(/^[0-9.]+$/)||(r=ce.asn1.x509.OID.name2oid(e)),""!==r)for(var n=0;n<t.length;n++)if(t[n].oid===r)return t[n]},this.getExtBasicConstraints=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"basicConstraints"};if(t&&(n.critical=!0),"3000"===e)return n;if("30030101ff"===e)return n.cA=!0,n;if("30060101ff02"===e.substr(0,12)){var s=i(e,10),a=parseInt(s,16);return n.cA=!0,n.pathLen=a,n}throw new Error("hExtV parse error: "+e)},this.getExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("keyUsage");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"keyUsage"};return t&&(n.critical=!0),n.names=this.getExtKeyUsageString(e).split(","),n},this.getExtKeyUsageBin=function(e){if(void 0===e){var t=this.getExtInfo("keyUsage");if(void 0===t)return"";e=o(this.hex,t.vidx)}if(8!=e.length&&10!=e.length)throw new Error("malformed key usage value: "+e);var r="000000000000000"+parseInt(e.substr(6),16).toString(2);return 8==e.length&&(r=r.slice(-8)),10==e.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(e){for(var t=this.getExtKeyUsageBin(e),r=new Array,n=0;n<t.length;n++)"1"==t.substr(n,1)&&r.push(qe.KEYUSAGE_NAME[n]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"subjectKeyIdentifier"};t&&(n.critical=!0);var s=i(e,0);return n.kid={hex:s},n},this.getExtAuthorityKeyIdentifier=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var s={extname:"authorityKeyIdentifier"};t&&(s.critical=!0);for(var a=n(e,0),c=0;c<a.length;c++){var u=e.substr(a[c],2);if("80"===u&&(s.kid={hex:i(e,a[c])}),"a1"===u){var l=o(e,a[c]),d=this.getGeneralNames(l);s.issuer=d[0].dn}"82"===u&&(s.sn={hex:i(e,a[c])})}return s},this.getExtExtKeyUsage=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var s={extname:"extKeyUsage",array:[]};t&&(s.critical=!0);for(var a=n(e,0),c=0;c<a.length;c++)s.array.push(p(i(e,a[c])));return s},this.getExtExtKeyUsageName=function(){var e=this.getExtInfo("extKeyUsage");if(void 0===e)return e;var t=new Array,r=o(this.hex,e.vidx);if(""===r)return t;for(var s=n(r,0),a=0;a<s.length;a++)t.push(p(i(r,s[a])));return t},this.getExtSubjectAltName=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"subjectAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getExtIssuerAltName=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var n={extname:"issuerAltName",array:[]};return t&&(n.critical=!0),n.array=this.getGeneralNames(e),n},this.getGeneralNames=function(e){for(var t=n(e,0),r=[],i=0;i<t.length;i++){var s=this.getGeneralName(o(e,t[i]));void 0!==s&&r.push(s)}return r},this.getGeneralName=function(e){var t=e.substr(0,2),r=i(e,0),n=be(r);return"81"==t?{rfc822:n}:"82"==t?{dns:n}:"86"==t?{uri:n}:"87"==t?{ip:De(r)}:"a4"==t?{dn:this.getX500Name(r)}:void 0},this.getExtSubjectAltName2=function(){var e,t,r,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var a=new Array,c=o(this.hex,s.vidx),u=n(c,0),l=0;l<u.length;l++)r=c.substr(u[l],2),e=i(c,u[l]),"81"===r&&(t=_e(e),a.push(["MAIL",t])),"82"===r&&(t=_e(e),a.push(["DNS",t])),"84"===r&&(t=qe.hex2dn(e,0),a.push(["DN",t])),"86"===r&&(t=_e(e),a.push(["URI",t])),"87"===r&&(t=De(e),a.push(["IP",t]));return a},this.getExtCRLDistributionPoints=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"cRLDistributionPoints",array:[]};t&&(i.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var c=o(e,s[a]);i.array.push(this.getDistributionPoint(c))}return i},this.getDistributionPoint=function(e){for(var t={},r=n(e,0),i=0;i<r.length;i++){var s=e.substr(r[i],2),a=o(e,r[i]);"a0"==s&&(t.dpname=this.getDistributionPointName(a))}return t},this.getDistributionPointName=function(e){for(var t={},r=n(e,0),i=0;i<r.length;i++){var s=e.substr(r[i],2),a=o(e,r[i]);"a0"==s&&(t.full=this.getGeneralNames(a))}return t},this.getExtCRLDistributionPointsURI=function(){var e=this.getExtInfo("cRLDistributionPoints");if(void 0===e)return e;for(var t=new Array,r=n(this.hex,e.vidx),i=0;i<r.length;i++)try{var o=_e(s(this.hex,r[i],[0,0,0],"86"));t.push(o)}catch(e){}return t},this.getExtAIAInfo=function(){var e=this.getExtInfo("authorityInfoAccess");if(void 0===e)return e;for(var t={ocsp:[],caissuer:[]},r=n(this.hex,e.vidx),i=0;i<r.length;i++){var o=s(this.hex,r[i],[0],"06"),a=s(this.hex,r[i],[1],"86");"2b06010505073001"===o&&t.ocsp.push(_e(a)),"2b06010505073002"===o&&t.caissuer.push(_e(a))}return t},this.getExtAuthorityInfoAccess=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"authorityInfoAccess",array:[]};t&&(i.critical=!0);for(var c=n(e,0),u=0;u<c.length;u++){var l=a(e,c[u],[0],"06"),d=_e(s(e,c[u],[1],"86"));if("2b06010505073001"==l)i.array.push({ocsp:d});else{if("2b06010505073002"!=l)throw new Error("unknown method: "+l);i.array.push({caissuer:d})}}return i},this.getExtCertificatePolicies=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"certificatePolicies",array:[]};t&&(i.critical=!0);for(var s=n(e,0),a=0;a<s.length;a++){var c=o(e,s[a]),u=this.getPolicyInformation(c);i.array.push(u)}return i},this.getPolicyInformation=function(e){var t={},r=s(e,0,[0],"06");t.policyoid=p(r);var i=d(e,0,[1],"30");if(-1!=i){t.array=[];for(var a=n(e,i),c=0;c<a.length;c++){var u=o(e,a[c]),l=this.getPolicyQualifierInfo(u);t.array.push(l)}}return t},this.getPolicyQualifierInfo=function(e){var t={},r=s(e,0,[0],"06");if("2b06010505070201"===r){var n=a(e,0,[1],"16");t.cps=be(n)}else if("2b06010505070202"===r){var i=c(e,0,[1],"30");t.unotice=this.getUserNotice(i)}return t},this.getUserNotice=function(e){for(var t={},r=n(e,0),i=0;i<r.length;i++){var s=o(e,r[i]);"30"!=s.substr(0,2)&&(t.exptext=this.getDisplayText(s))}return t},this.getDisplayText=function(e){var t={};return t.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[e.substr(0,2)],t.str=be(i(e,0)),t},this.getExtCRLNumber=function(e,t){var r={extname:"cRLNumber"};if(t&&(r.critical=!0),"02"==e.substr(0,2))return r.num={hex:i(e,0)},r;throw new Error("hExtV parse error: "+e)},this.getExtCRLReason=function(e,t){var r={extname:"cRLReason"};if(t&&(r.critical=!0),"0a"==e.substr(0,2))return r.code=parseInt(i(e,0),16),r;throw new Error("hExtV parse error: "+e)},this.getExtOcspNonce=function(e,t){var r={extname:"ocspNonce"};t&&(r.critical=!0);var n=i(e,0);return r.hex=n,r},this.getExtOcspNoCheck=function(e,t){var r={extname:"ocspNoCheck"};return t&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(e,t){if(void 0===e&&void 0===t){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;e=o(this.hex,r.vidx),t=r.critical}var i={extname:"adobeTimeStamp"};t&&(i.critical=!0);var s=n(e,0);if(s.length>1){var a=o(e,s[1]),c=this.getGeneralName(a);null!=c.uri&&(i.uri=c.uri)}if(s.length>2){var u=o(e,s[2]);"0101ff"==u&&(i.reqauth=!0),"010100"==u&&(i.reqauth=!1)}return i},this.getX500NameRule=function(e){for(var t=null,r=[],n=0;n<e.length;n++)for(var i=e[n],o=0;o<i.length;o++)r.push(i[o]);for(n=0;n<r.length;n++){var s=r[n],a=s.ds,c=s.value,u=s.type;if("prn"!=a&&"utf8"!=a&&"ia5"!=a)return"mixed";if("ia5"==a){if("CN"!=u)return"mixed";if(ce.lang.String.isMail(c))continue;return"mixed"}if("C"==u){if("prn"==a)continue;return"mixed"}if(null==t)t=a;else if(t!==a)return"mixed"}return null==t?"prn":t},this.getX500Name=function(e){var t=this.getX500NameArray(e);return{array:t,str:this.dnarraytostr(t)}},this.getX500NameArray=function(e){for(var t=[],r=n(e,0),i=0;i<r.length;i++)t.push(this.getRDN(o(e,r[i])));return t},this.getRDN=function(e){for(var t=[],r=n(e,0),i=0;i<r.length;i++)t.push(this.getAttrTypeAndValue(o(e,r[i])));return t},this.getAttrTypeAndValue=function(e){var t={type:null,value:null,ds:null},r=n(e,0),i=s(e,r[0],[],"06"),o=s(e,r[1],[]),a=ce.asn1.ASN1Util.oidHexToInt(i);return t.type=ce.asn1.x509.OID.oid2atype(a),t.ds=this.HEX2STAG[e.substr(r[1],2)],"bmp"!=t.ds?t.value=_e(o):t.value=Ne(o),t},this.readCertPEM=function(e){this.readCertHex(y(e))},this.readCertHex=function(e){this.hex=e,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(e){}},this.getParam=function(){var e={};return e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(),e.sbjpubkey=ke(this.getPublicKeyHex(),"PUBLIC KEY"),this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),e},this.getExtParamArray=function(e){null==e&&-1!=d(this.hex,0,[0,"[3]"])&&(e=u(this.hex,0,[0,"[3]",0],"30"));for(var t=[],r=n(e,0),i=0;i<r.length;i++){var s=o(e,r[i]),a=this.getExtParam(s);null!=a&&t.push(a)}return t},this.getExtParam=function(e){var t=n(e,0).length;if(2!=t&&3!=t)throw new Error("wrong number elements in Extension: "+t+" "+e);var r=g(s(e,0,[0],"06")),i=!1;3==t&&"0101ff"==c(e,0,[1])&&(i=!0);var o=c(e,0,[t-1,0]),a=void 0;if("2.5.29.14"==r?a=this.getExtSubjectKeyIdentifier(o,i):"2.5.29.15"==r?a=this.getExtKeyUsage(o,i):"2.5.29.17"==r?a=this.getExtSubjectAltName(o,i):"2.5.29.18"==r?a=this.getExtIssuerAltName(o,i):"2.5.29.19"==r?a=this.getExtBasicConstraints(o,i):"2.5.29.31"==r?a=this.getExtCRLDistributionPoints(o,i):"2.5.29.32"==r?a=this.getExtCertificatePolicies(o,i):"2.5.29.35"==r?a=this.getExtAuthorityKeyIdentifier(o,i):"2.5.29.37"==r?a=this.getExtExtKeyUsage(o,i):"1.3.6.1.5.5.7.1.1"==r?a=this.getExtAuthorityInfoAccess(o,i):"2.5.29.20"==r?a=this.getExtCRLNumber(o,i):"2.5.29.21"==r?a=this.getExtCRLReason(o,i):"1.3.6.1.5.5.7.48.1.2"==r?a=this.getExtOcspNonce(o,i):"1.3.6.1.5.5.7.48.1.5"==r?a=this.getExtOcspNoCheck(o,i):"1.2.840.113583.1.1.9.1"==r&&(a=this.getExtAdobeTimeStamp(o,i)),null!=a)return a;var u={extname:r,extn:o};return i&&(u.critical=!0),u},this.findExt=function(e,t){for(var r=0;r<e.length;r++)if(e[r].extname==t)return e[r];return null},this.updateExtCDPFullURI=function(e,t){var r=this.findExt(e,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)if(null!=n[i].dpname&&null!=n[i].dpname.full)for(var o=n[i].dpname.full,s=0;s<o.length;s++){var a=o[i];null!=a.uri&&(a.uri=t)}},this.updateExtAIAOCSP=function(e,t){var r=this.findExt(e,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].ocsp&&(n[i].ocsp=t)},this.updateExtAIACAIssuer=function(e,t){var r=this.findExt(e,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var n=r.array,i=0;i<n.length;i++)null!=n[i].caissuer&&(n[i].caissuer=t)},this.dnarraytostr=function(e){return"/"+e.map(function(e){return function(e){return e.map(function(e){return function(e){return e.type+"="+e.value}(e).replace(/\+/,"\\+")}).join("+")}(e).replace(/\//,"\\/")}).join("/")},this.getInfo=function(){var e,t,r,n=function(e){return JSON.stringify(e.array).replace(/[\[\]\{\}\"]/g,"")},i=function(e){for(var t="",r=e.array,n=0;n<r.length;n++){var i=r[n];if(t+=" policy oid: "+i.policyoid+"\n",void 0!==i.array)for(var o=0;o<i.array.length;o++){var s=i.array[o];void 0!==s.cps&&(t+=" cps: "+s.cps+"\n")}}return t},o=function(e){for(var t="",r=e.array,n=0;n<r.length;n++){var i=r[n];try{void 0!==i.dpname.full[0].uri&&(t+=" "+i.dpname.full[0].uri+"\n")}catch(e){}try{void 0!==i.dname.full[0].dn.hex&&(t+=" "+qe.hex2dn(i.dpname.full[0].dn.hex)+"\n")}catch(e){}}return t},s=function(e){for(var t="",r=e.array,n=0;n<r.length;n++){var i=r[n];void 0!==i.caissuer&&(t+=" caissuer: "+i.caissuer+"\n"),void 0!==i.ocsp&&(t+=" ocsp: "+i.ocsp+"\n")}return t};if(e="Basic Fields\n",e+=" serial number: "+this.getSerialNumberHex()+"\n",e+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",e+=" issuer: "+this.getIssuerString()+"\n",e+=" notBefore: "+this.getNotBefore()+"\n",e+=" notAfter: "+this.getNotAfter()+"\n",e+=" subject: "+this.getSubjectString()+"\n",e+=" subject public key info: \n",e+=" key algorithm: "+(t=this.getPublicKey()).type+"\n","RSA"===t.type&&(e+=" n="+je(t.n.toString(16)).substr(0,16)+"...\n",e+=" e="+je(t.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){e+="X509v3 Extensions:\n";for(var a=0;a<r.length;a++){var c=r[a],u=ce.asn1.x509.OID.oid2name(c.oid);""===u&&(u=c.oid);var l="";if(!0===c.critical&&(l="CRITICAL"),e+=" "+u+" "+l+":\n","basicConstraints"===u){var d=this.getExtBasicConstraints();void 0===d.cA?e+=" {}\n":(e+=" cA=true",void 0!==d.pathLen&&(e+=", pathLen="+d.pathLen),e+="\n")}else if("keyUsage"===u)e+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"===u)e+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"===u){var h=this.getExtAuthorityKeyIdentifier();void 0!==h.kid&&(e+=" kid="+h.kid.hex+"\n")}else"extKeyUsage"===u?e+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n":"subjectAltName"===u?e+=" "+n(this.getExtSubjectAltName())+"\n":"cRLDistributionPoints"===u?e+=o(this.getExtCRLDistributionPoints()):"authorityInfoAccess"===u?e+=s(this.getExtAuthorityInfoAccess()):"certificatePolicies"===u&&(e+=i(this.getExtCertificatePolicies()))}}return(e+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n")+"signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof e&&(-1!=e.indexOf("-----BEGIN")?this.readCertPEM(e):ce.lang.String.isHex(e)&&this.readCertHex(e))}Be.getKey=function(e,t,r){var n,i=(v=de).getChildIdx,o=(v.getV,v.getVbyList),s=ce.crypto,a=s.ECDSA,c=s.DSA,u=ne,l=Ie,d=Be;if(void 0!==u&&e instanceof u)return e;if(void 0!==a&&e instanceof a)return e;if(void 0!==c&&e instanceof c)return e;if(void 0!==e.curve&&void 0!==e.xy&&void 0===e.d)return new a({pub:e.xy,curve:e.curve});if(void 0!==e.curve&&void 0!==e.d)return new a({prv:e.d,curve:e.curve});if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(x=new u).setPublic(e.n,e.e),x;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.co&&void 0===e.qi)return(x=new u).setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),x;if(void 0===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0===e.p)return(x=new u).setPrivate(e.n,e.e,e.d),x;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0===e.x)return(x=new c).setPublic(e.p,e.q,e.g,e.y),x;if(void 0!==e.p&&void 0!==e.q&&void 0!==e.g&&void 0!==e.y&&void 0!==e.x)return(x=new c).setPrivate(e.p,e.q,e.g,e.y,e.x),x;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0===e.d)return(x=new u).setPublic(we(e.n),we(e.e)),x;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d&&void 0!==e.p&&void 0!==e.q&&void 0!==e.dp&&void 0!==e.dq&&void 0!==e.qi)return(x=new u).setPrivateEx(we(e.n),we(e.e),we(e.d),we(e.p),we(e.q),we(e.dp),we(e.dq),we(e.qi)),x;if("RSA"===e.kty&&void 0!==e.n&&void 0!==e.e&&void 0!==e.d)return(x=new u).setPrivate(we(e.n),we(e.e),we(e.d)),x;if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0===e.d){var h=(I=new a({curve:e.crv})).ecparams.keylen/4,f="04"+("0000000000"+we(e.x)).slice(-h)+("0000000000"+we(e.y)).slice(-h);return I.setPublicKeyHex(f),I}if("EC"===e.kty&&void 0!==e.crv&&void 0!==e.x&&void 0!==e.y&&void 0!==e.d){h=(I=new a({curve:e.crv})).ecparams.keylen/4,f="04"+("0000000000"+we(e.x)).slice(-h)+("0000000000"+we(e.y)).slice(-h);var p=("0000000000"+we(e.d)).slice(-h);return I.setPublicKeyHex(f),I.setPrivateKeyHex(p),I}if("pkcs5prv"===r){var g,y=e,v=de;if(9===(g=i(y,0)).length)(x=new u).readPKCS5PrvKeyHex(y);else if(6===g.length)(x=new c).readPKCS5PrvKeyHex(y);else{if(!(g.length>2&&"04"===y.substr(g[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(x=new a).readPKCS5PrvKeyHex(y)}return x}if("pkcs8prv"===r)return d.getKeyFromPlainPrivatePKCS8Hex(e);if("pkcs8pub"===r)return d._getKeyFromPublicPKCS8Hex(e);if("x509pub"===r)return qe.getPublicKeyFromCertHex(e);if(-1!=e.indexOf("-END CERTIFICATE-",0)||-1!=e.indexOf("-END X509 CERTIFICATE-",0)||-1!=e.indexOf("-END TRUSTED CERTIFICATE-",0))return qe.getPublicKeyFromCertPEM(e);if(-1!=e.indexOf("-END PUBLIC KEY-")){var m=Ie(e,"PUBLIC KEY");return d._getKeyFromPublicPKCS8Hex(m)}if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var w=l(e,"RSA PRIVATE KEY");return d.getKey(w,null,"pkcs5prv")}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED")){var S=o(n=l(e,"DSA PRIVATE KEY"),0,[1],"02"),_=o(n,0,[2],"02"),E=o(n,0,[3],"02"),A=o(n,0,[4],"02"),F=o(n,0,[5],"02");return(x=new c).setPrivate(new b(S,16),new b(_,16),new b(E,16),new b(A,16),new b(F,16)),x}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1==e.indexOf("4,ENCRYPTED"))return w=l(e,"EC PRIVATE KEY"),d.getKey(w,null,"pkcs5prv");if(-1!=e.indexOf("-END PRIVATE KEY-"))return d.getKeyFromPlainPrivatePKCS8PEM(e);if(-1!=e.indexOf("-END RSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var P=d.getDecryptedKeyHex(e,t),k=new ne;return k.readPKCS5PrvKeyHex(P),k}if(-1!=e.indexOf("-END EC PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED")){var I,x=o(n=d.getDecryptedKeyHex(e,t),0,[1],"04"),C=o(n,0,[2,0],"06"),T=o(n,0,[3,0],"03").substr(2);if(void 0===ce.crypto.OID.oidhex2name[C])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+C);return(I=new a({curve:ce.crypto.OID.oidhex2name[C]})).setPublicKeyHex(T),I.setPrivateKeyHex(x),I.isPublic=!1,I}if(-1!=e.indexOf("-END DSA PRIVATE KEY-")&&-1!=e.indexOf("4,ENCRYPTED"))return S=o(n=d.getDecryptedKeyHex(e,t),0,[1],"02"),_=o(n,0,[2],"02"),E=o(n,0,[3],"02"),A=o(n,0,[4],"02"),F=o(n,0,[5],"02"),(x=new c).setPrivate(new b(S,16),new b(_,16),new b(E,16),new b(A,16),new b(F,16)),x;if(-1!=e.indexOf("-END ENCRYPTED PRIVATE KEY-"))return d.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")},Be.generateKeypair=function(e,t){if("RSA"==e){var r=t;(s=new ne).generate(r,"10001"),s.isPrivate=!0,s.isPublic=!0;var n=new ne,i=s.n.toString(16),o=s.e.toString(16);return n.setPublic(i,o),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}if("EC"==e){var s,a,c=t,u=new ce.crypto.ECDSA({curve:c}).generateKeyPairHex();return(s=new ce.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),s.setPrivateKeyHex(u.ecprvhex),s.isPrivate=!0,s.isPublic=!1,(n=new ce.crypto.ECDSA({curve:c})).setPublicKeyHex(u.ecpubhex),n.isPrivate=!1,n.isPublic=!0,(a={}).prvKeyObj=s,a.pubKeyObj=n,a}throw new Error("unknown algorithm: "+e)},Be.getPEM=function(e,t,r,n,i,o){var s=ce,a=s.asn1,c=a.DERObjectIdentifier,u=a.DERInteger,l=a.ASN1Util.newObject,d=a.x509.SubjectPublicKeyInfo,h=s.crypto,f=h.DSA,p=h.ECDSA,g=ne;function v(e){return l({seq:[{int:0},{int:{bigint:e.n}},{int:e.e},{int:{bigint:e.d}},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.dmp1}},{int:{bigint:e.dmq1}},{int:{bigint:e.coeff}}]})}function m(e){return l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a0",!0,{oid:{name:e.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]})}function w(e){return l({seq:[{int:0},{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}},{int:{bigint:e.y}},{int:{bigint:e.x}}]})}if((void 0!==g&&e instanceof g||void 0!==f&&e instanceof f||void 0!==p&&e instanceof p)&&1==e.isPublic&&(void 0===t||"PKCS8PUB"==t))return ke(E=new d(e).getEncodedHex(),"PUBLIC KEY");if("PKCS1PRV"==t&&void 0!==g&&e instanceof g&&(void 0===r||null==r)&&1==e.isPrivate)return ke(E=v(e).getEncodedHex(),"RSA PRIVATE KEY");if("PKCS1PRV"==t&&void 0!==p&&e instanceof p&&(void 0===r||null==r)&&1==e.isPrivate){var S=new c({name:e.curveName}).getEncodedHex(),_=m(e).getEncodedHex(),b="";return(b+=ke(S,"EC PARAMETERS"))+ke(_,"EC PRIVATE KEY")}if("PKCS1PRV"==t&&void 0!==f&&e instanceof f&&(void 0===r||null==r)&&1==e.isPrivate)return ke(E=w(e).getEncodedHex(),"DSA PRIVATE KEY");if("PKCS5PRV"==t&&void 0!==g&&e instanceof g&&void 0!==r&&null!=r&&1==e.isPrivate){var E=v(e).getEncodedHex();return void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",E,r,n,o)}if("PKCS5PRV"==t&&void 0!==p&&e instanceof p&&void 0!==r&&null!=r&&1==e.isPrivate)return E=m(e).getEncodedHex(),void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",E,r,n,o);if("PKCS5PRV"==t&&void 0!==f&&e instanceof f&&void 0!==r&&null!=r&&1==e.isPrivate)return E=w(e).getEncodedHex(),void 0===n&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",E,r,n,o);var A=function(e,t){var r=F(e,t);return new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:r.pbkdf2Salt}},{int:r.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:r.encryptionSchemeIV}}]}]}]},{octstr:{hex:r.ciphertext}}]}).getEncodedHex()},F=function(e,t){var r=y.lib.WordArray.random(8),n=y.lib.WordArray.random(8),i=y.PBKDF2(t,r,{keySize:6,iterations:100}),o=y.enc.Hex.parse(e),s=y.TripleDES.encrypt(o,i,{iv:n})+"",a={};return a.ciphertext=s,a.pbkdf2Salt=y.enc.Hex.stringify(r),a.pbkdf2Iter=100,a.encryptionSchemeAlg="DES-EDE3-CBC",a.encryptionSchemeIV=y.enc.Hex.stringify(n),a};if("PKCS8PRV"==t&&null!=g&&e instanceof g&&1==e.isPrivate){var P=v(e).getEncodedHex();return E=l({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:P}}]}).getEncodedHex(),void 0===r||null==r?ke(E,"PRIVATE KEY"):ke(_=A(E,r),"ENCRYPTED PRIVATE KEY")}if("PKCS8PRV"==t&&void 0!==p&&e instanceof p&&1==e.isPrivate)return P=new l({seq:[{int:1},{octstr:{hex:e.prvKeyHex}},{tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]}]}).getEncodedHex(),E=l({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:P}}]}).getEncodedHex(),void 0===r||null==r?ke(E,"PRIVATE KEY"):ke(_=A(E,r),"ENCRYPTED PRIVATE KEY");if("PKCS8PRV"==t&&void 0!==f&&e instanceof f&&1==e.isPrivate)return P=new u({bigint:e.x}).getEncodedHex(),E=l({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:P}}]}).getEncodedHex(),void 0===r||null==r?ke(E,"PRIVATE KEY"):ke(_=A(E,r),"ENCRYPTED PRIVATE KEY");throw new Error("unsupported object nor format")},Be.getKeyFromCSRPEM=function(e){var t=Ie(e,"CERTIFICATE REQUEST");return Be.getKeyFromCSRHex(t)},Be.getKeyFromCSRHex=function(e){var t=Be.parseCSRHex(e);return Be.getKey(t.p8pubkeyhex,null,"pkcs8pub")},Be.parseCSRHex=function(e){var t=de,r=t.getChildIdx,n=t.getTLV,i={},o=e;if("30"!=o.substr(0,2))throw new Error("malformed CSR(code:001)");var s=r(o,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if("30"!=o.substr(s[0],2))throw new Error("malformed CSR(code:003)");var a=r(o,s[0]);if(a.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(o,a[2]),i},Be.getKeyID=function(e){var t=Be,r=de;"string"==typeof e&&-1!=e.indexOf("BEGIN ")&&(e=t.getKey(e));var n=Ie(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),o=r.getV(n,i).substring(2);return ce.crypto.Util.hashHex(o,"sha1")},Be.getJWKFromKey=function(e){var t={};if(e instanceof ne&&e.isPrivate)return t.kty="RSA",t.n=me(e.n.toString(16)),t.e=me(e.e.toString(16)),t.d=me(e.d.toString(16)),t.p=me(e.p.toString(16)),t.q=me(e.q.toString(16)),t.dp=me(e.dmp1.toString(16)),t.dq=me(e.dmq1.toString(16)),t.qi=me(e.coeff.toString(16)),t;if(e instanceof ne&&e.isPublic)return t.kty="RSA",t.n=me(e.n.toString(16)),t.e=me(e.e.toString(16)),t;if(e instanceof ce.crypto.ECDSA&&e.isPrivate){if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw new Error("unsupported curve name for JWT: "+n);var r=e.getPublicKeyXYHex();return t.kty="EC",t.crv=n,t.x=me(r.x),t.y=me(r.y),t.d=me(e.prvKeyHex),t}if(e instanceof ce.crypto.ECDSA&&e.isPublic){var n;if("P-256"!==(n=e.getShortNISTPCurveName())&&"P-384"!==n)throw new Error("unsupported curve name for JWT: "+n);return r=e.getPublicKeyXYHex(),t.kty="EC",t.crv=n,t.x=me(r.x),t.y=me(r.y),t}throw new Error("not supported key object")},ne.getPosArrayOfChildrenFromHex=function(e){return de.getChildIdx(e,0)},ne.getHexValueArrayOfChildrenFromHex=function(e){var t,r=de.getV,n=r(e,(t=ne.getPosArrayOfChildrenFromHex(e))[0]),i=r(e,t[1]),o=r(e,t[2]),s=r(e,t[3]),a=r(e,t[4]),c=r(e,t[5]),u=r(e,t[6]),l=r(e,t[7]),d=r(e,t[8]);return(t=new Array).push(n,i,o,s,a,c,u,l,d),t},ne.prototype.readPrivateKeyFromPEMString=function(e){var t=Ie(e),r=ne.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},ne.prototype.readPKCS5PrvKeyHex=function(e){var t=ne.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},ne.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,o,s,a,c,u=de,l=u.getVbyListEx;if(!1===u.isASN1HEX(e))throw new Error("not ASN.1 hex string");try{t=l(e,0,[2,0,1],"02"),r=l(e,0,[2,0,2],"02"),n=l(e,0,[2,0,3],"02"),i=l(e,0,[2,0,4],"02"),o=l(e,0,[2,0,5],"02"),s=l(e,0,[2,0,6],"02"),a=l(e,0,[2,0,7],"02"),c=l(e,0,[2,0,8],"02")}catch(e){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,o,s,a,c)},ne.prototype.readPKCS5PubKeyHex=function(e){var t=de,r=t.getV;if(!1===t.isASN1HEX(e))throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(2!==n.length||"02"!==e.substr(n[0],2)||"02"!==e.substr(n[1],2))throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),o=r(e,n[1]);this.setPublic(i,o)},ne.prototype.readPKCS8PubKeyHex=function(e){var t=de;if(!1===t.isASN1HEX(e))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==t.getTLVbyListEx(e,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)},ne.prototype.readCertPubKeyHex=function(e,t){var r,n;(r=new qe).readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)},new RegExp("[^0-9a-f]","gi"),ne.prototype.sign=function(e,t){var r=function(e){return ce.crypto.Util.hashString(e,t)}(e);return this.signWithMessageHash(r,t)},ne.prototype.signWithMessageHash=function(e,t){var r=te(ce.crypto.Util.getPaddedDigestInfoHex(e,t,this.n.bitLength()),16);return We(this.doPrivate(r).toString(16),this.n.bitLength())},ne.prototype.signPSS=function(e,t,r){var n=function(e){return ce.crypto.Util.hashHex(e,t)}(Ee(e));return void 0===r&&(r=-1),this.signWithMessageHashPSS(n,t,r)},ne.prototype.signWithMessageHashPSS=function(e,t,r){var n,i=be(e),o=i.length,s=this.n.bitLength()-1,a=Math.ceil(s/8),c=function(e){return ce.crypto.Util.hashHex(e,t)};if(-1===r||void 0===r)r=o;else if(-2===r)r=a-o-2;else if(r<-2)throw new Error("invalid salt length");if(a<o+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new ee).nextBytes(u),u=String.fromCharCode.apply(String,u));var l=be(c(Ee("\0\0\0\0\0\0\0\0"+i+u))),d=[];for(n=0;n<a-r-o-2;n+=1)d[n]=0;var h=String.fromCharCode.apply(String,d)+""+u,f=Je(l,h.length,c),p=[];for(n=0;n<h.length;n+=1)p[n]=h.charCodeAt(n)^f.charCodeAt(n);var g=65280>>8*a-s&255;for(p[0]&=~g,n=0;n<o;n++)p.push(l.charCodeAt(n));return p.push(188),We(this.doPrivate(new b(p)).toString(16),this.n.bitLength())},ne.prototype.verify=function(e,t){if(null==(t=t.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=te(t,16),n=this.n.bitLength();if(r.bitLength()>n)return!1;var i=this.doPublic(r).toString(16);if(i.length+3!=n/4)return!1;var o=Ve(i.replace(/^1f+00/,""));if(0==o.length)return!1;var s=o[0];return o[1]==function(e){return ce.crypto.Util.hashString(e,s)}(e)},ne.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=te(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=Ve(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=n.length&&(n[0],n[1]==e)},ne.prototype.verifyPSS=function(e,t,r,n){var i=function(e){return ce.crypto.Util.hashHex(e,r)}(Ee(e));return void 0===n&&(n=-1),this.verifyWithMessageHashPSS(i,t,r,n)},ne.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i,o=new b(t,16),s=function(e){return ce.crypto.Util.hashHex(e,r)},a=be(e),c=a.length,u=this.n.bitLength()-1,l=Math.ceil(u/8);if(-1===n||void 0===n)n=c;else if(-2===n)n=l-c-2;else if(n<-2)throw new Error("invalid salt length");if(l<c+n+2)throw new Error("data too long");var d=this.doPublic(o).toByteArray();for(i=0;i<d.length;i+=1)d[i]&=255;for(;d.length<l;)d.unshift(0);if(188!==d[l-1])throw new Error("encoded message does not end in 0xbc");var h=(d=String.fromCharCode.apply(String,d)).substr(0,l-c-1),f=d.substr(h.length,c),p=65280>>8*l-u&255;if(0!=(h.charCodeAt(0)&p))throw new Error("bits beyond keysize not zero");var g=Je(f,h.length,s),y=[];for(i=0;i<h.length;i+=1)y[i]=h.charCodeAt(i)^g.charCodeAt(i);y[0]&=~p;var v=l-c-n-2;for(i=0;i<v;i+=1)if(0!==y[i])throw new Error("leftmost octets not zero");if(1!==y[v])throw new Error("0x01 marker not found");return f===be(s(Ee("\0\0\0\0\0\0\0\0"+a+String.fromCharCode.apply(String,y.slice(-n)))))},ne.SALT_LEN_HLEN=-1,ne.SALT_LEN_MAX=-2,ne.SALT_LEN_RECOVER=-2,qe.hex2dn=function(e,t){void 0===t&&(t=0);var r=new qe;return de.getTLV(e,t),r.getX500Name(e).str},qe.hex2rdn=function(e,t){if(void 0===t&&(t=0),"31"!==e.substr(t,2))throw new Error("malformed RDN");for(var r=new Array,n=de.getChildIdx(e,t),i=0;i<n.length;i++)r.push(qe.hex2attrTypeValue(e,n[i]));return(r=r.map(function(e){return e.replace("+","\\+")})).join("+")},qe.hex2attrTypeValue=function(e,t){var r=de,n=r.getV;if(void 0===t&&(t=0),"30"!==e.substr(t,2))throw new Error("malformed attribute type and value");var i=r.getChildIdx(e,t);2!==i.length||e.substr(i[0],2);var o=n(e,i[0]),s=ce.asn1.ASN1Util.oidHexToInt(o);return ce.asn1.x509.OID.oid2atype(s)+"="+be(n(e,i[1]))},qe.getPublicKeyFromCertHex=function(e){var t=new qe;return t.readCertHex(e),t.getPublicKey()},qe.getPublicKeyFromCertPEM=function(e){var t=new qe;return t.readCertPEM(e),t.getPublicKey()},qe.getPublicKeyInfoPropOfCertPEM=function(e){var t,r,n=de.getVbyList,i={algparam:null};return(t=new qe).readCertPEM(e),r=t.getPublicKeyHex(),i.keyhex=n(r,0,[1],"03").substr(2),i.algoid=n(r,0,[0,0],"06"),"2a8648ce3d0201"===i.algoid&&(i.algparam=n(r,0,[0,1],"06")),i},qe.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==ce&&ce||(t.KJUR=ce={}),void 0!==ce.jws&&ce.jws||(ce.jws={}),ce.jws.JWS=function(){var e=ce.jws.JWS.isSafeJSONString;this.parseJWS=function(t,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var n=t.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==n)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var i=n[1],o=n[2],s=n[3],a=i+"."+o;if(this.parsedJWS={},this.parsedJWS.headB64U=i,this.parsedJWS.payloadB64U=o,this.parsedJWS.sigvalB64U=s,this.parsedJWS.si=a,!r){var c=we(s),u=te(c,16);this.parsedJWS.sigvalH=c,this.parsedJWS.sigvalBI=u}var l=le(i),d=le(o);if(this.parsedJWS.headS=l,this.parsedJWS.payloadS=d,!e(l,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+l}}},ce.jws.JWS.sign=function(e,t,r,n,i){var o,s,a,c=ce,u=c.jws.JWS,l=u.readSafeJSONString,d=u.isSafeJSONString,h=c.crypto,p=(h.ECDSA,h.Mac),g=h.Signature,y=JSON;if("string"!=typeof t&&"object"!=(void 0===t?"undefined":f(t)))throw"spHeader must be JSON string or object: "+t;if("object"==(void 0===t?"undefined":f(t))&&(s=t,o=y.stringify(s)),"string"==typeof t){if(!d(o=t))throw"JWS Head is not safe JSON string: "+o;s=l(o)}if(a=r,"object"==(void 0===r?"undefined":f(r))&&(a=y.stringify(r)),""!=e&&null!=e||void 0===s.alg||(e=s.alg),""!=e&&null!=e&&void 0===s.alg&&(s.alg=e,o=y.stringify(s)),e!==s.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+s.alg;var v=null;if(void 0===u.jwsalg2sigalg[e])throw"unsupported alg name: "+e;v=u.jwsalg2sigalg[e];var m=ue(o)+"."+ue(a),w="";if("Hmac"==v.substr(0,4)){if(void 0===n)throw"mac key shall be specified for HS* alg";var S=new p({alg:v,prov:"cryptojs",pass:n});S.updateString(m),w=S.doFinal()}else if(-1!=v.indexOf("withECDSA")){(b=new g({alg:v})).init(n,i),b.updateString(m);var _=b.sign();w=ce.crypto.ECDSA.asn1SigToConcatSig(_)}else{var b;"none"!=v&&((b=new g({alg:v})).init(n,i),b.updateString(m),w=b.sign())}return m+"."+me(w)},ce.jws.JWS.verify=function(e,t,r){var n,i=ce,o=i.jws.JWS,s=o.readSafeJSONString,a=i.crypto,c=a.ECDSA,u=a.Mac,l=a.Signature;void 0!==f(ne)&&(n=ne);var d=e.split(".");if(3!==d.length)return!1;var h,p=d[0]+"."+d[1],g=we(d[2]),y=s(le(d[0])),v=null;if(void 0===y.alg)throw"algorithm not specified in header";if(h=(v=y.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0&&-1==(":"+r.join(":")+":").indexOf(":"+v+":"))throw"algorithm '"+v+"' not accepted in the list";if("none"!=v&&null===t)throw"key shall be specified to verify.";if("string"==typeof t&&-1!=t.indexOf("-----BEGIN ")&&(t=Be.getKey(t)),!("RS"!=h&&"PS"!=h||t instanceof n))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==h&&!(t instanceof c))throw"key shall be a ECDSA obj for ES* algs";var m=null;if(void 0===o.jwsalg2sigalg[y.alg])throw"unsupported alg name: "+v;if("none"==(m=o.jwsalg2sigalg[v]))throw"not supported";if("Hmac"==m.substr(0,4)){if(void 0===t)throw"hexadecimal key shall be specified for HMAC";var w=new u({alg:m,pass:t});return w.updateString(p),g==w.doFinal()}if(-1!=m.indexOf("withECDSA")){var S,_=null;try{_=c.concatSigToASN1Sig(g)}catch(e){return!1}return(S=new l({alg:m})).init(t),S.updateString(p),S.verify(_)}return(S=new l({alg:m})).init(t),S.updateString(p),S.verify(g)},ce.jws.JWS.parse=function(e){var t,r,n,i=e.split("."),o={};if(2!=i.length&&3!=i.length)throw"malformed sJWS: wrong number of '.' splitted elements";return t=i[0],r=i[1],3==i.length&&(n=i[2]),o.headerObj=ce.jws.JWS.readSafeJSONString(le(t)),o.payloadObj=ce.jws.JWS.readSafeJSONString(le(r)),o.headerPP=JSON.stringify(o.headerObj,null," "),null==o.payloadObj?o.payloadPP=le(r):o.payloadPP=JSON.stringify(o.payloadObj,null," "),void 0!==n&&(o.sigHex=we(n)),o},ce.jws.JWS.verifyJWT=function(e,t,r){var n=ce.jws,i=n.JWS,o=i.readSafeJSONString,s=i.inArray,a=i.includedArray,c=e.split("."),u=c[0],l=c[1],d=(we(c[2]),o(le(u))),h=o(le(l));if(void 0===d.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!s(d.alg,r.alg))return!1;if(void 0!==h.iss&&"object"===f(r.iss)&&!s(h.iss,r.iss))return!1;if(void 0!==h.sub&&"object"===f(r.sub)&&!s(h.sub,r.sub))return!1;if(void 0!==h.aud&&"object"===f(r.aud))if("string"==typeof h.aud){if(!s(h.aud,r.aud))return!1}else if("object"==f(h.aud)&&!a(h.aud,r.aud))return!1;var p=n.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==h.exp&&"number"==typeof h.exp&&h.exp+r.gracePeriod<p||void 0!==h.nbf&&"number"==typeof h.nbf&&p<h.nbf-r.gracePeriod||void 0!==h.iat&&"number"==typeof h.iat&&p<h.iat-r.gracePeriod||void 0!==h.jti&&void 0!==r.jti&&h.jti!==r.jti||!i.verify(e,t,r.alg))},ce.jws.JWS.includedArray=function(e,t){var r=ce.jws.JWS.inArray;if(null===e)return!1;if("object"!==(void 0===e?"undefined":f(e)))return!1;if("number"!=typeof e.length)return!1;for(var n=0;n<e.length;n++)if(!r(e[n],t))return!1;return!0},ce.jws.JWS.inArray=function(e,t){if(null===t)return!1;if("object"!==(void 0===t?"undefined":f(t)))return!1;if("number"!=typeof t.length)return!1;for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1},ce.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},ce.jws.JWS.isSafeJSONString=function(e,t,r){var n=null;try{return"object"!=(void 0===(n=ae(e))?"undefined":f(n))||n.constructor===Array?0:(t&&(t[r]=n),1)}catch(e){return 0}},ce.jws.JWS.readSafeJSONString=function(e){var t=null;try{return"object"!=(void 0===(t=ae(e))?"undefined":f(t))||t.constructor===Array?null:t}catch(e){return null}},ce.jws.JWS.getEncodedSignatureValueFromJWS=function(e){var t=e.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==t)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return t[1]},ce.jws.JWS.getJWKthumbprint=function(e){if("RSA"!==e.kty&&"EC"!==e.kty&&"oct"!==e.kty)throw"unsupported algorithm for JWK Thumprint";var t="{";if("RSA"===e.kty){if("string"!=typeof e.n||"string"!=typeof e.e)throw"wrong n and e value for RSA key";t+='"e":"'+e.e+'",',t+='"kty":"'+e.kty+'",',t+='"n":"'+e.n+'"}'}else if("EC"===e.kty){if("string"!=typeof e.crv||"string"!=typeof e.x||"string"!=typeof e.y)throw"wrong crv, x and y value for EC key";t+='"crv":"'+e.crv+'",',t+='"kty":"'+e.kty+'",',t+='"x":"'+e.x+'",',t+='"y":"'+e.y+'"}'}else if("oct"===e.kty){if("string"!=typeof e.k)throw"wrong k value for oct(symmetric) key";t+='"kty":"'+e.kty+'",',t+='"k":"'+e.k+'"}'}var r=Ee(t);return me(ce.crypto.Util.hashHex(r,"sha256"))},ce.jws.IntDate={},ce.jws.IntDate.get=function(e){var t=ce.jws.IntDate,r=t.getNow,n=t.getZulu;if("now"==e)return r();if("now + 1hour"==e)return r()+3600;if("now + 1day"==e)return r()+86400;if("now + 1month"==e)return r()+2592e3;if("now + 1year"==e)return r()+31536e3;if(e.match(/Z$/))return n(e);if(e.match(/^[0-9]+$/))return parseInt(e);throw"unsupported format: "+e},ce.jws.IntDate.getZulu=function(e){return Ce(e)},ce.jws.IntDate.getNow=function(){return~~(new Date/1e3)},ce.jws.IntDate.intDate2UTCString=function(e){return new Date(1e3*e).toUTCString()},ce.jws.IntDate.intDate2Zulu=function(e){var t=new Date(1e3*e);return("0000"+t.getUTCFullYear()).slice(-4)+("00"+(t.getUTCMonth()+1)).slice(-2)+("00"+t.getUTCDate()).slice(-2)+("00"+t.getUTCHours()).slice(-2)+("00"+t.getUTCMinutes()).slice(-2)+("00"+t.getUTCSeconds()).slice(-2)+"Z"},t.SecureRandom=ee,t.rng_seed_time=z,t.BigInteger=b,t.RSAKey=ne;var $e=ce.crypto.EDSA;t.EDSA=$e;var ze=ce.crypto.DSA;t.DSA=ze;var Ge=ce.crypto.Signature;t.Signature=Ge;var Ye=ce.crypto.MessageDigest;t.MessageDigest=Ye;var Xe=ce.crypto.Mac;t.Mac=Xe;var Ze=ce.crypto.Cipher;t.Cipher=Ze,t.KEYUTIL=Be,t.ASN1HEX=de,t.X509=qe,t.CryptoJS=y,t.b64tohex=S,t.b64toBA=_,t.stoBA=he,t.BAtos=fe,t.BAtohex=pe,t.stohex=ge,t.stob64=function(e){return w(ge(e))},t.stob64u=function(e){return ye(w(ge(e)))},t.b64utos=function(e){return fe(_(ve(e)))},t.b64tob64u=ye,t.b64utob64=ve,t.hex2b64=w,t.hextob64u=me,t.b64utohex=we,t.utf8tob64u=ue,t.b64utoutf8=le,t.utf8tob64=function(e){return w(Te(Le(e)))},t.b64toutf8=function(e){return decodeURIComponent(Re(S(e)))},t.utf8tohex=Se,t.hextoutf8=_e,t.hextorstr=be,t.rstrtohex=Ee,t.hextob64=Ae,t.hextob64nl=Fe,t.b64nltohex=Pe,t.hextopem=ke,t.pemtohex=Ie,t.hextoArrayBuffer=function(e){if(e.length%2!=0)throw"input is not even length";if(null==e.match(/^[0-9A-Fa-f]+$/))throw"input is not hexadecimal";for(var t=new ArrayBuffer(e.length/2),r=new DataView(t),n=0;n<e.length/2;n++)r.setUint8(n,parseInt(e.substr(2*n,2),16));return t},t.ArrayBuffertohex=function(e){for(var t="",r=new DataView(e),n=0;n<e.byteLength;n++)t+=("00"+r.getUint8(n).toString(16)).slice(-2);return t},t.zulutomsec=xe,t.zulutosec=Ce,t.zulutodate=function(e){return new Date(xe(e))},t.datetozulu=function(e,t,r){var n,i=e.getUTCFullYear();if(t){if(i<1950||2049<i)throw"not proper year for UTCTime: "+i;n=(""+i).slice(-2)}else n=("000"+i).slice(-4);if(n+=("0"+(e.getUTCMonth()+1)).slice(-2),n+=("0"+e.getUTCDate()).slice(-2),n+=("0"+e.getUTCHours()).slice(-2),n+=("0"+e.getUTCMinutes()).slice(-2),n+=("0"+e.getUTCSeconds()).slice(-2),r){var o=e.getUTCMilliseconds();0!==o&&(n+="."+(o=(o=("00"+o).slice(-3)).replace(/0+$/g,"")))}return n+"Z"},t.uricmptohex=Te,t.hextouricmp=Re,t.ipv6tohex=Ue,t.hextoipv6=Oe,t.hextoip=De,t.iptohex=function(e){var t="malformed IP address";if(!(e=e.toLowerCase(e)).match(/^[0-9.]+$/)){if(e.match(/^[0-9a-f:]+$/)&&-1!==e.indexOf(":"))return Ue(e);throw t}var r=e.split(".");if(4!==r.length)throw t;var n="";try{for(var i=0;i<4;i++)n+=("0"+parseInt(r[i]).toString(16)).slice(-2);return n}catch(e){throw t}},t.encodeURIComponentAll=Le,t.newline_toUnix=function(e){return e.replace(/\r\n/gm,"\n")},t.newline_toDos=function(e){return(e=e.replace(/\r\n/gm,"\n")).replace(/\n/gm,"\r\n")},t.hextoposhex=je,t.intarystrtohex=function(e){e=(e=(e=e.replace(/^\s*\[\s*/,"")).replace(/\s*\]\s*$/,"")).replace(/\s*/g,"");try{return e.split(/,/).map(function(e,t,r){var n=parseInt(e);if(n<0||255<n)throw"integer not in range 0-255";return("00"+n.toString(16)).slice(-2)}).join("")}catch(e){throw"malformed integer array string: "+e}},t.strdiffidx=function(e,t){var r=e.length;e.length>t.length&&(r=t.length);for(var n=0;n<r;n++)if(e.charCodeAt(n)!=t.charCodeAt(n))return n;return e.length!=t.length?r:-1},t.KJUR=ce;var Qe=ce.crypto;t.crypto=Qe;var et=ce.asn1;t.asn1=et;var tt=ce.jws;t.jws=tt;var rt=ce.lang;t.lang=rt}).call(this,r(28).Buffer)},function(e,t,r){(function(e){
|
|
23
|
+
/*!
|
|
24
|
+
* The buffer module from node.js, for the browser.
|
|
25
|
+
*
|
|
26
|
+
* @author Feross Aboukhadijeh <http://feross.org>
|
|
27
|
+
* @license MIT
|
|
28
|
+
*/
|
|
29
|
+
var n=r(30),i=r(31),o=r(32);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(s()<t)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=c.prototype:(null===e&&(e=new c(t)),e.length=t),e}function c(e,t,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return d(this,e)}return u(this,e,t,r)}function u(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),c.TYPED_ARRAY_SUPPORT?(e=t).__proto__=c.prototype:e=h(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(c.isBuffer(t)){var r=0|f(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||function(e){return e!=e}(t.length)?a(e,0):h(e,t);if("Buffer"===t.type&&o(t.data))return h(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function d(e,t){if(l(t),e=a(e,t<0?0:0|f(t)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function h(e,t){var r=t.length<0?0:0|f(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function f(e){if(e>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function p(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return B(e).length;default:if(n)return K(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return P(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return x(this,t,r);case"base64":return F(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function v(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var o,s=1,a=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;o<a;o++)if(u(e,o)===u(t,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===c)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var d=!0,h=0;h<c;h++)if(u(e,o+h)!==u(t,h)){d=!1;break}if(d)return o}return-1}function w(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[r+s]=a}return s}function S(e,t,r,n){return W(K(t,e.length-r),e,r,n)}function _(e,t,r,n){return W(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function b(e,t,r,n){return _(e,t,r,n)}function E(e,t,r,n){return W(B(t),e,r,n)}function A(e,t,r,n){return W(function(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function F(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function P(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o,s,a,c,u=e[i],l=null,d=u>239?4:u>223?3:u>191?2:1;if(i+d<=r)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&u)<<6|63&o)>127&&(l=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&u)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&u)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=d}return function(e){var t=e.length;if(t<=k)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=k));return r}(n)}t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=s(),c.poolSize=8192,c._augment=function(e){return e.__proto__=c.prototype,e},c.from=function(e,t,r){return u(null,e,t,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(e,t,r){return function(e,t,r,n){return l(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},c.allocUnsafe=function(e){return d(null,e)},c.allocUnsafeSlow=function(e){return d(null,e)},c.isBuffer=function(e){return!(null==e||!e._isBuffer)},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i<o;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(e,t){if(!o(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=c.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},c.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},c.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},c.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?P(this,0,e):g.apply(this,arguments)},c.prototype.equals=function(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),l=e.slice(t,r),d=0;d<a;++d)if(u[d]!==l[d]){o=u[d],s=l[d];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return v(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return v(this,e,t,r,!1)},c.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":return _(this,e,t,r);case"latin1":case"binary":return b(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function I(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function x(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=M(e[o]);return i}function T(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function R(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function U(e,t,r,n,i,o){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function D(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function N(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(e,t,r,n,o){return o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function H(e,t,r,n,o){return o||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=c.prototype;else{var i=t-e;r=new c(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+e]}return r},c.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n},c.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=this[e],i=1,o=0;++o<t&&(i*=256);)n+=this[e+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||R(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},c.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o<r&&(i*=256);)this[t+o]=e/i&255;return t+r},c.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||U(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);U(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<r&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);U(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s|0)-a&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||U(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return H(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return H(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,o=n-r;if(this===e&&r<t&&t<n)for(i=o-1;i>=0;--i)e[i+t]=this[i+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+o),t);return o},c.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var o;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o<r;++o)this[o]=e;else{var s=c.isBuffer(e)?e:K(new c(e,n).toString()),a=s.length;for(o=0;o<r-t;++o)this[o+t]=s[o%a]}return this};var j=/[^+\/0-9A-Za-z-_]/g;function M(e){return e<16?"0"+e.toString(16):e.toString(16)}function K(e,t){var r;t=t||1/0;for(var n=e.length,i=null,o=[],s=0;s<n;++s){if((r=e.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function B(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(j,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function W(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(29))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){t.byteLength=function(e){var t=c(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=c(e),s=n[0],a=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,s,a)),l=0,d=a>0?s-4:s;for(r=0;r<d;r+=4)t=i[e.charCodeAt(r)]<<18|i[e.charCodeAt(r+1)]<<12|i[e.charCodeAt(r+2)]<<6|i[e.charCodeAt(r+3)],u[l++]=t>>16&255,u[l++]=t>>8&255,u[l++]=255&t;return 2===a&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[l++]=255&t),1===a&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t),u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],s=16383,a=0,c=r-i;a<c;a+=s)o.push(u(e,a,a+s>c?c:a+s));return 1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0;a<64;++a)n[a]=s[a],i[s.charCodeAt(a)]=a;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function u(e,t,r){for(var i,o,s=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){
|
|
30
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
31
|
+
t.read=function(e,t,r,n,i){var o,s,a=8*i-n-1,c=(1<<a)-1,u=c>>1,l=-7,d=r?i-1:0,h=r?-1:1,f=e[t+d];for(d+=h,o=f&(1<<-l)-1,f>>=-l,l+=a;l>0;o=256*o+e[t+d],d+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+d],d+=h,l-=8);if(0===o)o=1-u;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),o-=u}return(f?-1:1)*s*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var s,a,c,u=8*o-i-1,l=(1<<u)-1,d=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?h/c:h*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=l?(a=0,s=l):s+d>=1?(a=(t*c-1)*Math.pow(2,i),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;e[r+f]=255&s,f+=p,s/=256,u-=8);e[r+f-p]|=128*g}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=e.jws,r=e.KeyUtil,i=e.X509,o=e.crypto,s=e.hextob64u,a=e.b64tohex,c=e.AllowedSigningAlgs;return function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.parseJwt=function e(r){n.Log.debug("JoseUtil.parseJwt");try{var i=t.JWS.parse(r);return{header:i.headerObj,payload:i.payloadObj}}catch(e){n.Log.error(e)}},e.validateJwt=function(t,o,s,c,u,l,d){n.Log.debug("JoseUtil.validateJwt");try{if("RSA"===o.kty)if(o.e&&o.n)o=r.getKey(o);else{if(!o.x5c||!o.x5c.length)return n.Log.error("JoseUtil.validateJwt: RSA key missing key material",o),Promise.reject(new Error("RSA key missing key material"));var h=a(o.x5c[0]);o=i.getPublicKeyFromCertHex(h)}else{if("EC"!==o.kty)return n.Log.error("JoseUtil.validateJwt: Unsupported key type",o&&o.kty),Promise.reject(new Error(o.kty));if(!(o.crv&&o.x&&o.y))return n.Log.error("JoseUtil.validateJwt: EC key missing key material",o),Promise.reject(new Error("EC key missing key material"));o=r.getKey(o)}return e._validateJwt(t,o,s,c,u,l,d)}catch(e){return n.Log.error(e&&e.message||e),Promise.reject("JWT validation failed")}},e.validateJwtAttributes=function(t,r,i,o,s,a){o||(o=0),s||(s=parseInt(Date.now()/1e3));var c=e.parseJwt(t).payload;if(!c.iss)return n.Log.error("JoseUtil._validateJwt: issuer was not provided"),Promise.reject(new Error("issuer was not provided"));if(c.iss!==r)return n.Log.error("JoseUtil._validateJwt: Invalid issuer in token",c.iss),Promise.reject(new Error("Invalid issuer in token: "+c.iss));if(!c.aud)return n.Log.error("JoseUtil._validateJwt: aud was not provided"),Promise.reject(new Error("aud was not provided"));if(!(c.aud===i||Array.isArray(c.aud)&&c.aud.indexOf(i)>=0))return n.Log.error("JoseUtil._validateJwt: Invalid audience in token",c.aud),Promise.reject(new Error("Invalid audience in token: "+c.aud));if(c.azp&&c.azp!==i)return n.Log.error("JoseUtil._validateJwt: Invalid azp in token",c.azp),Promise.reject(new Error("Invalid azp in token: "+c.azp));if(!a){var u=s+o,l=s-o;if(!c.iat)return n.Log.error("JoseUtil._validateJwt: iat was not provided"),Promise.reject(new Error("iat was not provided"));if(u<c.iat)return n.Log.error("JoseUtil._validateJwt: iat is in the future",c.iat),Promise.reject(new Error("iat is in the future: "+c.iat));if(c.nbf&&u<c.nbf)return n.Log.error("JoseUtil._validateJwt: nbf is in the future",c.nbf),Promise.reject(new Error("nbf is in the future: "+c.nbf));if(!c.exp)return n.Log.error("JoseUtil._validateJwt: exp was not provided"),Promise.reject(new Error("exp was not provided"));if(c.exp<l)return n.Log.error("JoseUtil._validateJwt: exp is in the past",c.exp),Promise.reject(new Error("exp is in the past:"+c.exp))}return Promise.resolve(c)},e._validateJwt=function(r,i,o,s,a,u,l){return e.validateJwtAttributes(r,o,s,a,u,l).then(function(e){try{return t.JWS.verify(r,i,c)?e:(n.Log.error("JoseUtil._validateJwt: signature validation failed"),Promise.reject(new Error("signature validation failed")))}catch(e){return n.Log.error(e&&e.message||e),Promise.reject(new Error("signature validation failed"))}})},e.hashString=function e(t,r){try{return o.Util.hashString(t,r)}catch(e){n.Log.error(e)}},e.hexToBase64Url=function e(t){try{return s(t)}catch(e){n.Log.error(e)}},e}()};var n=r(0);e.exports=t.default},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SigninResponse=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(3);t.SigninResponse=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var n=i.UrlUtility.parseUrlFragment(t,r);this.error=n.error,this.error_description=n.error_description,this.error_uri=n.error_uri,this.code=n.code,this.state=n.state,this.id_token=n.id_token,this.session_state=n.session_state,this.access_token=n.access_token,this.token_type=n.token_type,this.scope=n.scope,this.profile=void 0,this.expires_in=n.expires_in}return n(e,[{key:"expires_in",get:function(){if(this.expires_at){var e=parseInt(Date.now()/1e3);return this.expires_at-e}},set:function(e){var t=parseInt(e);if("number"==typeof t&&t>0){var r=parseInt(Date.now()/1e3);this.expires_at=r+t}}},{key:"expired",get:function(){var e=this.expires_in;if(void 0!==e)return e<=0}},{key:"scopes",get:function(){return(this.scope||"").split(" ")}},{key:"isOpenIdConnect",get:function(){return this.scopes.indexOf("openid")>=0||!!this.id_token}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SignoutRequest=void 0;var n=r(0),i=r(3),o=r(9);t.SignoutRequest=function e(t){var r=t.url,s=t.id_token_hint,a=t.post_logout_redirect_uri,c=t.data,u=t.extraQueryParams,l=t.request_type;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),!r)throw n.Log.error("SignoutRequest.ctor: No url passed"),new Error("url");for(var d in s&&(r=i.UrlUtility.addQueryParam(r,"id_token_hint",s)),a&&(r=i.UrlUtility.addQueryParam(r,"post_logout_redirect_uri",a),c&&(this.state=new o.State({data:c,request_type:l}),r=i.UrlUtility.addQueryParam(r,"state",this.state.id))),u)r=i.UrlUtility.addQueryParam(r,d,u[d]);this.url=r}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SignoutResponse=void 0;var n=r(3);t.SignoutResponse=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var r=n.UrlUtility.parseUrlFragment(t,"?");this.error=r.error,this.error_description=r.error_description,this.error_uri=r.error_uri,this.state=r.state}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.InMemoryWebStorage=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.InMemoryWebStorage=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._data={}}return e.prototype.getItem=function(e){return i.Log.debug("InMemoryWebStorage.getItem",e),this._data[e]},e.prototype.setItem=function(e,t){i.Log.debug("InMemoryWebStorage.setItem",e),this._data[e]=t},e.prototype.removeItem=function(e){i.Log.debug("InMemoryWebStorage.removeItem",e),delete this._data[e]},e.prototype.key=function(e){return Object.getOwnPropertyNames(this._data)[e]},n(e,[{key:"length",get:function(){return Object.getOwnPropertyNames(this._data).length}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.UserManager=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(10),s=r(39),a=r(15),c=r(45),u=r(47),l=r(18),d=r(8),h=r(20),f=r(11),p=r(4);t.UserManager=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.SilentRenewService,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l.SessionMonitor,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:h.TokenRevocationClient,d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:f.TokenClient,g=arguments.length>5&&void 0!==arguments[5]?arguments[5]:p.JoseUtil;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,t),r instanceof s.UserManagerSettings||(r=new s.UserManagerSettings(r));var y=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,r));return y._events=new c.UserManagerEvents(r),y._silentRenewService=new n(y),y.settings.automaticSilentRenew&&(i.Log.debug("UserManager.ctor: automaticSilentRenew is configured, setting up silent renew"),y.startSilentRenew()),y.settings.monitorSession&&(i.Log.debug("UserManager.ctor: monitorSession is configured, setting up session monitor"),y._sessionMonitor=new o(y)),y._tokenRevocationClient=new a(y._settings),y._tokenClient=new d(y._settings),y._joseUtil=g,y}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.getUser=function(){var e=this;return this._loadUser().then(function(t){return t?(i.Log.info("UserManager.getUser: user loaded"),e._events.load(t,!1),t):(i.Log.info("UserManager.getUser: user not found in storage"),null)})},t.prototype.removeUser=function(){var e=this;return this.storeUser(null).then(function(){i.Log.info("UserManager.removeUser: user removed from storage"),e._events.unload()})},t.prototype.signinRedirect=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="si:r";var t={useReplaceToNavigate:e.useReplaceToNavigate};return this._signinStart(e,this._redirectNavigator,t).then(function(){i.Log.info("UserManager.signinRedirect: successful")})},t.prototype.signinRedirectCallback=function(e){return this._signinEnd(e||this._redirectNavigator.url).then(function(e){return e.profile&&e.profile.sub?i.Log.info("UserManager.signinRedirectCallback: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinRedirectCallback: no sub"),e})},t.prototype.signinPopup=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="si:p";var t=e.redirect_uri||this.settings.popup_redirect_uri||this.settings.redirect_uri;return t?(e.redirect_uri=t,e.display="popup",this._signin(e,this._popupNavigator,{startUrl:t,popupWindowFeatures:e.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:e.popupWindowTarget||this.settings.popupWindowTarget}).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinPopup: signinPopup successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinPopup: no sub")),e})):(i.Log.error("UserManager.signinPopup: No popup_redirect_uri or redirect_uri configured"),Promise.reject(new Error("No popup_redirect_uri or redirect_uri configured")))},t.prototype.signinPopupCallback=function(e){return this._signinCallback(e,this._popupNavigator).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinPopupCallback: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinPopupCallback: no sub")),e}).catch(function(e){i.Log.error(e.message)})},t.prototype.signinSilent=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=Object.assign({},t),this._loadUser().then(function(r){return r&&r.refresh_token?(t.refresh_token=r.refresh_token,e._useRefreshToken(t)):(t.request_type="si:s",t.id_token_hint=t.id_token_hint||e.settings.includeIdTokenInSilentRenew&&r&&r.id_token,r&&e._settings.validateSubOnSilentRenew&&(i.Log.debug("UserManager.signinSilent, subject prior to silent renew: ",r.profile.sub),t.current_sub=r.profile.sub),e._signinSilentIframe(t))})},t.prototype._useRefreshToken=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._tokenClient.exchangeRefreshToken(t).then(function(t){return t?t.access_token?e._loadUser().then(function(r){if(r){var n=Promise.resolve();return t.id_token&&(n=e._validateIdTokenFromTokenRefreshToken(r.profile,t.id_token)),n.then(function(){return i.Log.debug("UserManager._useRefreshToken: refresh token response success"),r.id_token=t.id_token||r.id_token,r.access_token=t.access_token,r.refresh_token=t.refresh_token||r.refresh_token,r.expires_in=t.expires_in,e.storeUser(r).then(function(){return e._events.load(r),r})})}return null}):(i.Log.error("UserManager._useRefreshToken: No access token returned from token endpoint"),Promise.reject("No access token returned from token endpoint")):(i.Log.error("UserManager._useRefreshToken: No response returned from token endpoint"),Promise.reject("No response returned from token endpoint"))})},t.prototype._validateIdTokenFromTokenRefreshToken=function(e,t){var r=this;return this._metadataService.getIssuer().then(function(n){return r.settings.getEpochTime().then(function(o){return r._joseUtil.validateJwtAttributes(t,n,r._settings.client_id,r._settings.clockSkew,o).then(function(t){return t?t.sub!==e.sub?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: sub in id_token does not match current sub"),Promise.reject(new Error("sub in id_token does not match current sub"))):t.auth_time&&t.auth_time!==e.auth_time?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: auth_time in id_token does not match original auth_time"),Promise.reject(new Error("auth_time in id_token does not match original auth_time"))):t.azp&&t.azp!==e.azp?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: azp in id_token does not match original azp"),Promise.reject(new Error("azp in id_token does not match original azp"))):!t.azp&&e.azp?(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: azp not in id_token, but present in original id_token"),Promise.reject(new Error("azp not in id_token, but present in original id_token"))):void 0:(i.Log.error("UserManager._validateIdTokenFromTokenRefreshToken: Failed to validate id_token"),Promise.reject(new Error("Failed to validate id_token")))})})})},t.prototype._signinSilentIframe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;return t?(e.redirect_uri=t,e.prompt=e.prompt||"none",this._signin(e,this._iframeNavigator,{startUrl:t,silentRequestTimeout:e.silentRequestTimeout||this.settings.silentRequestTimeout}).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinSilent: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinSilent: no sub")),e})):(i.Log.error("UserManager.signinSilent: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},t.prototype.signinSilentCallback=function(e){return this._signinCallback(e,this._iframeNavigator).then(function(e){return e&&(e.profile&&e.profile.sub?i.Log.info("UserManager.signinSilentCallback: successful, signed in sub: ",e.profile.sub):i.Log.info("UserManager.signinSilentCallback: no sub")),e})},t.prototype.signinCallback=function(e){var t=this;return this.readSigninResponseState(e).then(function(r){var n=r.state;return r.response,"si:r"===n.request_type?t.signinRedirectCallback(e):"si:p"===n.request_type?t.signinPopupCallback(e):"si:s"===n.request_type?t.signinSilentCallback(e):Promise.reject(new Error("invalid response_type in state"))})},t.prototype.signoutCallback=function(e,t){var r=this;return this.readSignoutResponseState(e).then(function(n){var i=n.state,o=n.response;return i?"so:r"===i.request_type?r.signoutRedirectCallback(e):"so:p"===i.request_type?r.signoutPopupCallback(e,t):Promise.reject(new Error("invalid response_type in state")):o})},t.prototype.querySessionStatus=function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(t=Object.assign({},t)).request_type="si:s";var r=t.redirect_uri||this.settings.silent_redirect_uri||this.settings.redirect_uri;return r?(t.redirect_uri=r,t.prompt="none",t.response_type=t.response_type||this.settings.query_status_response_type,t.scope=t.scope||"openid",t.skipUserInfo=!0,this._signinStart(t,this._iframeNavigator,{startUrl:r,silentRequestTimeout:t.silentRequestTimeout||this.settings.silentRequestTimeout}).then(function(t){return e.processSigninResponse(t.url).then(function(e){if(i.Log.debug("UserManager.querySessionStatus: got signin response"),e.session_state&&e.profile.sub)return i.Log.info("UserManager.querySessionStatus: querySessionStatus success for sub: ",e.profile.sub),{session_state:e.session_state,sub:e.profile.sub,sid:e.profile.sid};i.Log.info("querySessionStatus successful, user not authenticated")}).catch(function(t){if(t.session_state&&e.settings.monitorAnonymousSession&&("login_required"==t.message||"consent_required"==t.message||"interaction_required"==t.message||"account_selection_required"==t.message))return i.Log.info("UserManager.querySessionStatus: querySessionStatus success for anonymous user"),{session_state:t.session_state};throw t})})):(i.Log.error("UserManager.querySessionStatus: No silent_redirect_uri configured"),Promise.reject(new Error("No silent_redirect_uri configured")))},t.prototype._signin=function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._signinStart(e,t,n).then(function(t){return r._signinEnd(t.url,e)})},t.prototype._signinStart=function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.prepare(n).then(function(t){return i.Log.debug("UserManager._signinStart: got navigator window handle"),r.createSigninRequest(e).then(function(e){return i.Log.debug("UserManager._signinStart: got signin request"),n.url=e.url,n.id=e.state.id,t.navigate(n)}).catch(function(e){throw t.close&&(i.Log.debug("UserManager._signinStart: Error after preparing navigator, closing navigator window"),t.close()),e})})},t.prototype._signinEnd=function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.processSigninResponse(e).then(function(e){i.Log.debug("UserManager._signinEnd: got signin response");var n=new a.User(e);if(r.current_sub){if(r.current_sub!==n.profile.sub)return i.Log.debug("UserManager._signinEnd: current user does not match user returned from signin. sub from signin: ",n.profile.sub),Promise.reject(new Error("login_required"));i.Log.debug("UserManager._signinEnd: current user matches user returned from signin")}return t.storeUser(n).then(function(){return i.Log.debug("UserManager._signinEnd: user stored"),t._events.load(n),n})})},t.prototype._signinCallback=function(e,t){i.Log.debug("UserManager._signinCallback");var r="query"===this._settings.response_mode||!this._settings.response_mode&&d.SigninRequest.isCode(this._settings.response_type)?"?":"#";return t.callback(e,void 0,r)},t.prototype.signoutRedirect=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="so:r";var t=e.post_logout_redirect_uri||this.settings.post_logout_redirect_uri;t&&(e.post_logout_redirect_uri=t);var r={useReplaceToNavigate:e.useReplaceToNavigate};return this._signoutStart(e,this._redirectNavigator,r).then(function(){i.Log.info("UserManager.signoutRedirect: successful")})},t.prototype.signoutRedirectCallback=function(e){return this._signoutEnd(e||this._redirectNavigator.url).then(function(e){return i.Log.info("UserManager.signoutRedirectCallback: successful"),e})},t.prototype.signoutPopup=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(e=Object.assign({},e)).request_type="so:p";var t=e.post_logout_redirect_uri||this.settings.popup_post_logout_redirect_uri||this.settings.post_logout_redirect_uri;return e.post_logout_redirect_uri=t,e.display="popup",e.post_logout_redirect_uri&&(e.state=e.state||{}),this._signout(e,this._popupNavigator,{startUrl:t,popupWindowFeatures:e.popupWindowFeatures||this.settings.popupWindowFeatures,popupWindowTarget:e.popupWindowTarget||this.settings.popupWindowTarget}).then(function(){i.Log.info("UserManager.signoutPopup: successful")})},t.prototype.signoutPopupCallback=function(e,t){return void 0===t&&"boolean"==typeof e&&(t=e,e=null),this._popupNavigator.callback(e,t,"?").then(function(){i.Log.info("UserManager.signoutPopupCallback: successful")})},t.prototype._signout=function(e,t){var r=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._signoutStart(e,t,n).then(function(e){return r._signoutEnd(e.url)})},t.prototype._signoutStart=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return arguments[1].prepare(r).then(function(n){return i.Log.debug("UserManager._signoutStart: got navigator window handle"),t._loadUser().then(function(o){return i.Log.debug("UserManager._signoutStart: loaded current user from storage"),(t._settings.revokeAccessTokenOnSignout?t._revokeInternal(o):Promise.resolve()).then(function(){var s=e.id_token_hint||o&&o.id_token;return s&&(i.Log.debug("UserManager._signoutStart: Setting id_token into signout request"),e.id_token_hint=s),t.removeUser().then(function(){return i.Log.debug("UserManager._signoutStart: user removed, creating signout request"),t.createSignoutRequest(e).then(function(e){return i.Log.debug("UserManager._signoutStart: got signout request"),r.url=e.url,e.state&&(r.id=e.state.id),n.navigate(r)})})})}).catch(function(e){throw n.close&&(i.Log.debug("UserManager._signoutStart: Error after preparing navigator, closing navigator window"),n.close()),e})})},t.prototype._signoutEnd=function(e){return this.processSignoutResponse(e).then(function(e){return i.Log.debug("UserManager._signoutEnd: got signout response"),e})},t.prototype.revokeAccessToken=function(){var e=this;return this._loadUser().then(function(t){return e._revokeInternal(t,!0).then(function(r){if(r)return i.Log.debug("UserManager.revokeAccessToken: removing token properties from user and re-storing"),t.access_token=null,t.refresh_token=null,t.expires_at=null,t.token_type=null,e.storeUser(t).then(function(){i.Log.debug("UserManager.revokeAccessToken: user stored"),e._events.load(t)})})}).then(function(){i.Log.info("UserManager.revokeAccessToken: access token revoked successfully")})},t.prototype._revokeInternal=function(e,t){var r=this;if(e){var n=e.access_token,o=e.refresh_token;return this._revokeAccessTokenInternal(n,t).then(function(e){return r._revokeRefreshTokenInternal(o,t).then(function(t){return e||t||i.Log.debug("UserManager.revokeAccessToken: no need to revoke due to no token(s), or JWT format"),e||t})})}return Promise.resolve(!1)},t.prototype._revokeAccessTokenInternal=function(e,t){return!e||e.indexOf(".")>=0?Promise.resolve(!1):this._tokenRevocationClient.revoke(e,t).then(function(){return!0})},t.prototype._revokeRefreshTokenInternal=function(e,t){return e?this._tokenRevocationClient.revoke(e,t,"refresh_token").then(function(){return!0}):Promise.resolve(!1)},t.prototype.startSilentRenew=function(){this._silentRenewService.start()},t.prototype.stopSilentRenew=function(){this._silentRenewService.stop()},t.prototype._loadUser=function(){return this._userStore.get(this._userStoreKey).then(function(e){return e?(i.Log.debug("UserManager._loadUser: user storageString loaded"),a.User.fromStorageString(e)):(i.Log.debug("UserManager._loadUser: no user storageString"),null)})},t.prototype.storeUser=function(e){if(e){i.Log.debug("UserManager.storeUser: storing user");var t=e.toStorageString();return this._userStore.set(this._userStoreKey,t)}return i.Log.debug("storeUser.storeUser: removing user"),this._userStore.remove(this._userStoreKey)},n(t,[{key:"_redirectNavigator",get:function(){return this.settings.redirectNavigator}},{key:"_popupNavigator",get:function(){return this.settings.popupNavigator}},{key:"_iframeNavigator",get:function(){return this.settings.iframeNavigator}},{key:"_userStore",get:function(){return this.settings.userStore}},{key:"events",get:function(){return this._events}},{key:"_userStoreKey",get:function(){return"user:"+this.settings.authority+":"+this.settings.client_id}}]),t}(o.OidcClient)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.UserManagerSettings=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=(r(0),r(5)),o=r(40),s=r(41),a=r(43),c=r(6),u=r(1),l=r(8);t.UserManagerSettings=function(e){function t(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=r.popup_redirect_uri,i=r.popup_post_logout_redirect_uri,d=r.popupWindowFeatures,h=r.popupWindowTarget,f=r.silent_redirect_uri,p=r.silentRequestTimeout,g=r.automaticSilentRenew,y=void 0!==g&&g,v=r.validateSubOnSilentRenew,m=void 0!==v&&v,w=r.includeIdTokenInSilentRenew,S=void 0===w||w,_=r.monitorSession,b=void 0===_||_,E=r.monitorAnonymousSession,A=void 0!==E&&E,F=r.checkSessionInterval,P=void 0===F?2e3:F,k=r.stopCheckSessionOnError,I=void 0===k||k,x=r.query_status_response_type,C=r.revokeAccessTokenOnSignout,T=void 0!==C&&C,R=r.accessTokenExpiringNotificationTime,U=void 0===R?60:R,O=r.redirectNavigator,D=void 0===O?new o.RedirectNavigator:O,N=r.popupNavigator,L=void 0===N?new s.PopupNavigator:N,H=r.iframeNavigator,j=void 0===H?new a.IFrameNavigator:H,M=r.userStore,K=void 0===M?new c.WebStorageStateStore({store:u.Global.sessionStorage}):M;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var B=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,arguments[0]));return B._popup_redirect_uri=n,B._popup_post_logout_redirect_uri=i,B._popupWindowFeatures=d,B._popupWindowTarget=h,B._silent_redirect_uri=f,B._silentRequestTimeout=p,B._automaticSilentRenew=y,B._validateSubOnSilentRenew=m,B._includeIdTokenInSilentRenew=S,B._accessTokenExpiringNotificationTime=U,B._monitorSession=b,B._monitorAnonymousSession=A,B._checkSessionInterval=P,B._stopCheckSessionOnError=I,x?B._query_status_response_type=x:arguments[0]&&arguments[0].response_type?B._query_status_response_type=l.SigninRequest.isOidc(arguments[0].response_type)?"id_token":"code":B._query_status_response_type="id_token",B._revokeAccessTokenOnSignout=T,B._redirectNavigator=D,B._popupNavigator=L,B._iframeNavigator=j,B._userStore=K,B}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),n(t,[{key:"popup_redirect_uri",get:function(){return this._popup_redirect_uri}},{key:"popup_post_logout_redirect_uri",get:function(){return this._popup_post_logout_redirect_uri}},{key:"popupWindowFeatures",get:function(){return this._popupWindowFeatures}},{key:"popupWindowTarget",get:function(){return this._popupWindowTarget}},{key:"silent_redirect_uri",get:function(){return this._silent_redirect_uri}},{key:"silentRequestTimeout",get:function(){return this._silentRequestTimeout}},{key:"automaticSilentRenew",get:function(){return this._automaticSilentRenew}},{key:"validateSubOnSilentRenew",get:function(){return this._validateSubOnSilentRenew}},{key:"includeIdTokenInSilentRenew",get:function(){return this._includeIdTokenInSilentRenew}},{key:"accessTokenExpiringNotificationTime",get:function(){return this._accessTokenExpiringNotificationTime}},{key:"monitorSession",get:function(){return this._monitorSession}},{key:"monitorAnonymousSession",get:function(){return this._monitorAnonymousSession}},{key:"checkSessionInterval",get:function(){return this._checkSessionInterval}},{key:"stopCheckSessionOnError",get:function(){return this._stopCheckSessionOnError}},{key:"query_status_response_type",get:function(){return this._query_status_response_type}},{key:"revokeAccessTokenOnSignout",get:function(){return this._revokeAccessTokenOnSignout}},{key:"redirectNavigator",get:function(){return this._redirectNavigator}},{key:"popupNavigator",get:function(){return this._popupNavigator}},{key:"iframeNavigator",get:function(){return this._iframeNavigator}},{key:"userStore",get:function(){return this._userStore}}]),t}(i.OidcClientSettings)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.RedirectNavigator=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.RedirectNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(){return Promise.resolve(this)},e.prototype.navigate=function(e){return e&&e.url?(e.useReplaceToNavigate?window.location.replace(e.url):window.location=e.url,Promise.resolve()):(i.Log.error("RedirectNavigator.navigate: No url provided"),Promise.reject(new Error("No url provided")))},n(e,[{key:"url",get:function(){return window.location.href}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PopupNavigator=void 0;var n=r(0),i=r(42);t.PopupNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){var t=new i.PopupWindow(e);return Promise.resolve(t)},e.prototype.callback=function e(t,r,o){n.Log.debug("PopupNavigator.callback");try{return i.PopupWindow.notifyOpener(t,r,o),Promise.resolve()}catch(e){return Promise.reject(e)}},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.PopupWindow=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(3);t.PopupWindow=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t});var n=t.popupWindowTarget||"_blank",o=t.popupWindowFeatures||"location=no,toolbar=no,width=500,height=500,left=100,top=100;";this._popup=window.open("",n,o),this._popup&&(i.Log.debug("PopupWindow.ctor: popup successfully created"),this._checkForPopupClosedTimer=window.setInterval(this._checkForPopupClosed.bind(this),500))}return e.prototype.navigate=function(e){return this._popup?e&&e.url?(i.Log.debug("PopupWindow.navigate: Setting URL in popup"),this._id=e.id,this._id&&(window["popupCallback_"+e.id]=this._callback.bind(this)),this._popup.focus(),this._popup.window.location=e.url):(this._error("PopupWindow.navigate: no url provided"),this._error("No url provided")):this._error("PopupWindow.navigate: Error opening popup window"),this.promise},e.prototype._success=function(e){i.Log.debug("PopupWindow.callback: Successful response from popup window"),this._cleanup(),this._resolve(e)},e.prototype._error=function(e){i.Log.error("PopupWindow.error: ",e),this._cleanup(),this._reject(new Error(e))},e.prototype.close=function(){this._cleanup(!1)},e.prototype._cleanup=function(e){i.Log.debug("PopupWindow.cleanup"),window.clearInterval(this._checkForPopupClosedTimer),this._checkForPopupClosedTimer=null,delete window["popupCallback_"+this._id],this._popup&&!e&&this._popup.close(),this._popup=null},e.prototype._checkForPopupClosed=function(){this._popup&&!this._popup.closed||this._error("Popup window closed")},e.prototype._callback=function(e,t){this._cleanup(t),e?(i.Log.debug("PopupWindow.callback success"),this._success({url:e})):(i.Log.debug("PopupWindow.callback: Invalid response from popup"),this._error("Invalid response from popup"))},e.notifyOpener=function(e,t,r){if(window.opener){if(e=e||window.location.href){var n=o.UrlUtility.parseUrlFragment(e,r);if(n.state){var s="popupCallback_"+n.state,a=window.opener[s];a?(i.Log.debug("PopupWindow.notifyOpener: passing url message to opener"),a(e,t)):i.Log.warn("PopupWindow.notifyOpener: no matching callback found on opener")}else i.Log.warn("PopupWindow.notifyOpener: no state found in response url")}}else i.Log.warn("PopupWindow.notifyOpener: no window.opener. Can't complete notification.")},n(e,[{key:"promise",get:function(){return this._promise}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.IFrameNavigator=void 0;var n=r(0),i=r(44);t.IFrameNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){var t=new i.IFrameWindow(e);return Promise.resolve(t)},e.prototype.callback=function e(t){n.Log.debug("IFrameNavigator.callback");try{return i.IFrameWindow.notifyParent(t),Promise.resolve()}catch(e){return Promise.reject(e)}},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.IFrameWindow=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0);t.IFrameWindow=function(){function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._promise=new Promise(function(e,t){r._resolve=e,r._reject=t}),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.width=0,this._frame.height=0,window.document.body.appendChild(this._frame)}return e.prototype.navigate=function(e){if(e&&e.url){var t=e.silentRequestTimeout||1e4;i.Log.debug("IFrameWindow.navigate: Using timeout of:",t),this._timer=window.setTimeout(this._timeout.bind(this),t),this._frame.src=e.url}else this._error("No url provided");return this.promise},e.prototype._success=function(e){this._cleanup(),i.Log.debug("IFrameWindow: Successful response from frame window"),this._resolve(e)},e.prototype._error=function(e){this._cleanup(),i.Log.error(e),this._reject(new Error(e))},e.prototype.close=function(){this._cleanup()},e.prototype._cleanup=function(){this._frame&&(i.Log.debug("IFrameWindow: cleanup"),window.removeEventListener("message",this._boundMessageEvent,!1),window.clearTimeout(this._timer),window.document.body.removeChild(this._frame),this._timer=null,this._frame=null,this._boundMessageEvent=null)},e.prototype._timeout=function(){i.Log.debug("IFrameWindow.timeout"),this._error("Frame window timed out")},e.prototype._message=function(e){if(i.Log.debug("IFrameWindow.message"),this._timer&&e.origin===this._origin&&e.source===this._frame.contentWindow&&"string"==typeof e.data&&(e.data.startsWith("http://")||e.data.startsWith("https://"))){var t=e.data;t?this._success({url:t}):this._error("Invalid response from frame")}},e.notifyParent=function(e){i.Log.debug("IFrameWindow.notifyParent"),(e=e||window.location.href)&&(i.Log.debug("IFrameWindow.notifyParent: posting url message to parent"),window.parent.postMessage(e,location.protocol+"//"+location.host))},n(e,[{key:"promise",get:function(){return this._promise}},{key:"_origin",get:function(){return location.protocol+"//"+location.host}}]),e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.UserManagerEvents=void 0;var n=r(0),i=r(16),o=r(17);t.UserManagerEvents=function(e){function t(r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,r));return n._userLoaded=new o.Event("User loaded"),n._userUnloaded=new o.Event("User unloaded"),n._silentRenewError=new o.Event("Silent renew error"),n._userSignedIn=new o.Event("User signed in"),n._userSignedOut=new o.Event("User signed out"),n._userSessionChanged=new o.Event("User session changed"),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.load=function(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];n.Log.debug("UserManagerEvents.load"),e.prototype.load.call(this,t),r&&this._userLoaded.raise(t)},t.prototype.unload=function(){n.Log.debug("UserManagerEvents.unload"),e.prototype.unload.call(this),this._userUnloaded.raise()},t.prototype.addUserLoaded=function(e){this._userLoaded.addHandler(e)},t.prototype.removeUserLoaded=function(e){this._userLoaded.removeHandler(e)},t.prototype.addUserUnloaded=function(e){this._userUnloaded.addHandler(e)},t.prototype.removeUserUnloaded=function(e){this._userUnloaded.removeHandler(e)},t.prototype.addSilentRenewError=function(e){this._silentRenewError.addHandler(e)},t.prototype.removeSilentRenewError=function(e){this._silentRenewError.removeHandler(e)},t.prototype._raiseSilentRenewError=function(e){n.Log.debug("UserManagerEvents._raiseSilentRenewError",e.message),this._silentRenewError.raise(e)},t.prototype.addUserSignedIn=function(e){this._userSignedIn.addHandler(e)},t.prototype.removeUserSignedIn=function(e){this._userSignedIn.removeHandler(e)},t.prototype._raiseUserSignedIn=function(){n.Log.debug("UserManagerEvents._raiseUserSignedIn"),this._userSignedIn.raise()},t.prototype.addUserSignedOut=function(e){this._userSignedOut.addHandler(e)},t.prototype.removeUserSignedOut=function(e){this._userSignedOut.removeHandler(e)},t.prototype._raiseUserSignedOut=function(){n.Log.debug("UserManagerEvents._raiseUserSignedOut"),this._userSignedOut.raise()},t.prototype.addUserSessionChanged=function(e){this._userSessionChanged.addHandler(e)},t.prototype.removeUserSessionChanged=function(e){this._userSessionChanged.removeHandler(e)},t.prototype._raiseUserSessionChanged=function(){n.Log.debug("UserManagerEvents._raiseUserSessionChanged"),this._userSessionChanged.raise()},t}(i.AccessTokenEvents)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Timer=void 0;var n=function(){function e(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,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),i=r(0),o=r(1),s=r(17);t.Timer=function(e){function t(r){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:o.Global.timer,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var s=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,r));return s._timer=n,s._nowFunc=i||function(){return Date.now()/1e3},s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.init=function(e){e<=0&&(e=1),e=parseInt(e);var t=this.now+e;if(this.expiration===t&&this._timerHandle)i.Log.debug("Timer.init timer "+this._name+" skipping initialization since already initialized for expiration:",this.expiration);else{this.cancel(),i.Log.debug("Timer.init timer "+this._name+" for duration:",e),this._expiration=t;var r=5;e<r&&(r=e),this._timerHandle=this._timer.setInterval(this._callback.bind(this),1e3*r)}},t.prototype.cancel=function(){this._timerHandle&&(i.Log.debug("Timer.cancel: ",this._name),this._timer.clearInterval(this._timerHandle),this._timerHandle=null)},t.prototype._callback=function(){var t=this._expiration-this.now;i.Log.debug("Timer.callback; "+this._name+" timer expires in:",t),this._expiration<=this.now&&(this.cancel(),e.prototype.raise.call(this))},n(t,[{key:"now",get:function(){return parseInt(this._nowFunc())}},{key:"expiration",get:function(){return this._expiration}}]),t}(s.Event)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.SilentRenewService=void 0;var n=r(0);t.SilentRenewService=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._userManager=t}return e.prototype.start=function(){this._callback||(this._callback=this._tokenExpiring.bind(this),this._userManager.events.addAccessTokenExpiring(this._callback),this._userManager.getUser().then(function(e){}).catch(function(e){n.Log.error("SilentRenewService.start: Error from getUser:",e.message)}))},e.prototype.stop=function(){this._callback&&(this._userManager.events.removeAccessTokenExpiring(this._callback),delete this._callback)},e.prototype._tokenExpiring=function(){var e=this;this._userManager.signinSilent().then(function(e){n.Log.debug("SilentRenewService._tokenExpiring: Silent token renewal successful")},function(t){n.Log.error("SilentRenewService._tokenExpiring: Error from signinSilent:",t.message),e._userManager.events._raiseSilentRenewError(t)})},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaPopupNavigator=void 0;var n=r(21);t.CordovaPopupNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){var t=new n.CordovaPopupWindow(e);return Promise.resolve(t)},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.CordovaIFrameNavigator=void 0;var n=r(21);t.CordovaIFrameNavigator=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return e.prototype.prepare=function(e){e.popupWindowFeatures="hidden=yes";var t=new n.CordovaPopupWindow(e);return Promise.resolve(t)},e}()},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.Version="1.11.6"}])},e.exports=t()},6568:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(1797),i=r(6011);t.default=function(e){const t=function(e){return Uint8Array.of((15&e[6])<<4|e[7]>>4&15,(15&e[7])<<4|(240&e[4])>>4,(15&e[4])<<4|(240&e[5])>>4,(15&e[5])<<4|(240&e[0])>>4,(15&e[0])<<4|(240&e[1])>>4,(15&e[1])<<4|(240&e[2])>>4,96|15&e[2],e[3],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])}("string"==typeof e?(0,n.default)(e):e);return"string"==typeof e?(0,i.unsafeStringify)(t):t}},6697:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i},6711:(e,t,r)=>{r.d(t,{Z:()=>m});var n=r(1436),i=r(1020),o=r(7991),s=r(4495),a=r(676);const c=async(e,t,r,n)=>{const c=await(0,a.A)(e,t,"verify");(0,s.A)(e,c);const u=(0,i.A)(e,c.algorithm);try{return await o.A.subtle.verify(u,c,r,n)}catch{return!1}};var u=r(7493),l=r(1476),d=r(9874),h=r(149),f=r(8858),p=r(2168),g=r(4618),y=r(5500),v=r(8278);async function m(e,t,r){if(!(0,h.A)(e))throw new u.JWSInvalid("Flattened JWS must be an object");if(void 0===e.protected&&void 0===e.header)throw new u.JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');if(void 0!==e.protected&&"string"!=typeof e.protected)throw new u.JWSInvalid("JWS Protected Header incorrect type");if(void 0===e.payload)throw new u.JWSInvalid("JWS Payload missing");if("string"!=typeof e.signature)throw new u.JWSInvalid("JWS Signature missing or incorrect type");if(void 0!==e.header&&!(0,h.A)(e.header))throw new u.JWSInvalid("JWS Unprotected Header incorrect type");let i={};if(e.protected)try{const t=(0,n.D4)(e.protected);i=JSON.parse(l.D0.decode(t))}catch{throw new u.JWSInvalid("JWS Protected Header is invalid")}if(!(0,d.A)(i,e.header))throw new u.JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const o={...i,...e.header};let s=!0;if((0,p.A)(u.JWSInvalid,new Map([["b64",!0]]),r?.crit,i,o).has("b64")&&(s=i.b64,"boolean"!=typeof s))throw new u.JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:a}=o;if("string"!=typeof a||!a)throw new u.JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');const m=r&&(0,g.A)("algorithms",r.algorithms);if(m&&!m.has(a))throw new u.JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');if(s){if("string"!=typeof e.payload)throw new u.JWSInvalid("JWS Payload must be a string")}else if("string"!=typeof e.payload&&!(e.payload instanceof Uint8Array))throw new u.JWSInvalid("JWS Payload must be a string or an Uint8Array instance");let w=!1;"function"==typeof t?(t=await t(i,e),w=!0,(0,f.I)(a,t,"verify"),(0,y.ll)(t)&&(t=await(0,v.Og)(t,a))):(0,f.I)(a,t,"verify");const S=(0,l.xW)(l.Rd.encode(e.protected??""),l.Rd.encode("."),"string"==typeof e.payload?l.Rd.encode(e.payload):e.payload);let _;try{_=(0,n.D4)(e.signature)}catch{throw new u.JWSInvalid("Failed to base64url decode the signature")}if(!await c(a,t,_,S))throw new u.JWSSignatureVerificationFailed;let b;if(s)try{b=(0,n.D4)(e.payload)}catch{throw new u.JWSInvalid("Failed to base64url decode the payload")}else b="string"==typeof e.payload?l.Rd.encode(e.payload):e.payload;const E={payload:b};return void 0!==e.protected&&(E.protectedHeader=i),void 0!==e.header&&(E.unprotectedHeader=e.header),w?{...E,key:t}:E}},6769:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ACL_LINK=void 0,t.createAclLogic=function(e){const r=i.ns;function o(e,t,i,o={}){const s=o.public||[],a=(0,n.graph)(),c=(0,n.Namespace)("http://www.w3.org/ns/auth/acl#");let u=a.sym(`${i}#a1`);const l=a.sym(i),d=a.sym(e);if(a.add(u,r.rdf("type"),c("Authorization"),l),a.add(u,c("accessTo"),d,l),o.defaultForNew&&a.add(u,c("default"),d,l),a.add(u,c("agent"),t,l),a.add(u,c("mode"),c("Read"),l),a.add(u,c("mode"),c("Write"),l),a.add(u,c("mode"),c("Control"),l),s.length){u=a.sym(`${i}#a2`),a.add(u,r.rdf("type"),c("Authorization"),l),a.add(u,c("accessTo"),d,l),a.add(u,c("agentClass"),r.foaf("Agent"),l);for(let e=0;e<s.length;e++)a.add(u,c("mode"),c(s[e]),l)}return(0,n.serialize)(l,a,i)}return{findAclDocUrl:async function(r){await e.fetcher.load(r);const n=e.any(r,t.ACL_LINK);if(!n)throw new Error(`No ACL link discovered for ${r}`);return n.value},setACLUserPublic:function(r,n,i){const s=e.any(e.sym(r),t.ACL_LINK);return Promise.resolve().then(()=>s||function(r){const n=e.fetcher;if(!n)throw new Error("Cannot fetch ACL rel, store has no fetcher");return n.load(r).then(n=>{if(!n.ok)throw new Error("fetchACLRel: While loading:"+n.error);const i=e.any(e.sym(r),t.ACL_LINK);if(!i)throw new Error("fetchACLRel: No Link rel=ACL header for "+r);return i})}(r).catch(e=>{throw new Error(`Error fetching rel=ACL header for ${r}: ${e}`)})).then(t=>{const s=o(r,n,t.uri,i);if(!e.fetcher)throw new Error("Cannot PUT this, store has no fetcher");return e.fetcher.webOperation("PUT",t.uri,{data:s,contentType:"text/turtle"}).then(e=>{if(!e.ok)throw new Error("Error writing ACL text: "+e.error);return t})})},genACLText:o}};const n=r(4738),i=r(6118);t.ACL_LINK=(0,n.sym)("http://www.iana.org/assignments/link-relations/acl")},6848:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.newThing=function(e){return(0,n.sym)(e.uri+"#id"+Date.now())},t.uniqueNodes=function(e){const t=e.map(e=>e.uri),r=new Set(t),i=Array.from(r);return i.map(e=>new n.NamedNode(e))},t.getArchiveUrl=function(e,t){const r=t.getUTCFullYear(),n=("0"+(t.getUTCMonth()+1)).slice(-2),i=("0"+t.getUTCDate()).slice(-2),o=e.split("/"),s=o[o.length-1];return new URL(`./archive/${r}/${n}/${i}/${s}`,e).toString()},t.differentOrigin=function(e){if(!e)return!0;return`${window.location.origin}/`!==new URL(e.value).origin},t.suggestPreferencesFile=function(e){const t=e.uri.replace("/profile/","/").replace("/public/","/"),r=t.split("/").slice(0,-1).join("/")+"/Settings/Preferences.ttl";return(0,n.sym)(r)},t.determineChatContainer=function(e,t){const r=new URL(`IndividualChats/${new URL(e.value).host}/`,t.value).toString();return new n.NamedNode(r)};const n=r(4738)},6957:(e,t,r)=>{r.d(t,{A:()=>o});const n=86400,i=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,o=e=>{const t=i.exec(e);if(!t||t[4]&&t[1])throw new TypeError("Invalid time period format");const r=parseFloat(t[2]);let o;switch(t[3].toLowerCase()){case"sec":case"secs":case"second":case"seconds":case"s":o=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":o=Math.round(60*r);break;case"hour":case"hours":case"hr":case"hrs":case"h":o=Math.round(3600*r);break;case"day":case"days":case"d":o=Math.round(r*n);break;case"week":case"weeks":case"w":o=Math.round(604800*r);break;default:o=Math.round(31557600*r)}return"-"===t[1]||"ago"===t[4]?-o:o}},7007:e=>{var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}g(e,t,o,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&g(e,"error",t,r)}(e,i,{once:!0})})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function h(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function g(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var u=c.length,l=p(c,u);for(r=0;r<u;++r)n(l[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,d(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,d(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return h(this,e,!0)},o.prototype.rawListeners=function(e){return h(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},7248:(e,t,r)=>{r.d(t,{P:()=>a});var n=r(2609),i=r(7493),o=r(1476),s=r(3085);class a extends s.G{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,t){const r=new n.T(o.Rd.encode(JSON.stringify(this._payload)));if(r.setProtectedHeader(this._protectedHeader),Array.isArray(this._protectedHeader?.crit)&&this._protectedHeader.crit.includes("b64")&&!1===this._protectedHeader.b64)throw new i.JWTInvalid("JWTs MUST NOT use unencoded payload");return r.sign(e,t)}}},7307:(e,t,r)=>{r.d(t,{T:()=>i});var n=r(8793);async function i(e,t){return(0,n.T)(e,t)}},7493:(e,t,r)=>{r.r(t),r.d(t,{JOSEAlgNotAllowed:()=>s,JOSEError:()=>n,JOSENotSupported:()=>a,JWEDecryptionFailed:()=>c,JWEInvalid:()=>u,JWKInvalid:()=>h,JWKSInvalid:()=>f,JWKSMultipleMatchingKeys:()=>g,JWKSNoMatchingKey:()=>p,JWKSTimeout:()=>y,JWSInvalid:()=>l,JWSSignatureVerificationFailed:()=>v,JWTClaimValidationFailed:()=>i,JWTExpired:()=>o,JWTInvalid:()=>d});class n extends Error{constructor(e,t){super(e,t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}n.code="ERR_JOSE_GENERIC";class i extends n{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=n,this.payload=t}}i.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class o extends n{constructor(e,t,r="unspecified",n="unspecified"){super(e,{cause:{claim:r,reason:n,payload:t}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=n,this.payload=t}}o.code="ERR_JWT_EXPIRED";class s extends n{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}s.code="ERR_JOSE_ALG_NOT_ALLOWED";class a extends n{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}a.code="ERR_JOSE_NOT_SUPPORTED";class c extends n{constructor(e="decryption operation failed",t){super(e,t),this.code="ERR_JWE_DECRYPTION_FAILED"}}c.code="ERR_JWE_DECRYPTION_FAILED";class u extends n{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}u.code="ERR_JWE_INVALID";class l extends n{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}l.code="ERR_JWS_INVALID";class d extends n{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}d.code="ERR_JWT_INVALID";class h extends n{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}h.code="ERR_JWK_INVALID";class f extends n{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}f.code="ERR_JWKS_INVALID";class p extends n{constructor(e="no applicable key found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_NO_MATCHING_KEY"}}p.code="ERR_JWKS_NO_MATCHING_KEY";class g extends n{constructor(e="multiple matching keys found in the JSON Web Key Set",t){super(e,t),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Symbol.asyncIterator,g.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class y extends n{constructor(e="request timed out",t){super(e,t),this.code="ERR_JWKS_TIMEOUT"}}y.code="ERR_JWKS_TIMEOUT";class v extends n{constructor(e="signature verification failed",t){super(e,t),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}v.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"},7813:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createInboxLogic=function(e,t,r,i,o){return{createInboxFor:async function(e,n){const o=await t.loadMe(),s=`${(await t.getPodRoot(o)).value}p2p-inboxes/${encodeURIComponent(n)}/`;return await i.createContainer(s),await r.setSinglePeerAccess({ownerWebId:o.value,peerWebId:e,accessToModes:"acl:Append",target:s}),s},getNewMessages:async function(e){e||(e=await t.loadMe());const r=await t.getMainInbox(e);return(await i.getContainerMembers(r)).filter(e=>!i.isContainer(e))},markAsRead:async function(t,r){const i=await e.fetcher._fetch(t);if(200!==i.status)throw new Error(`Not OK! ${t}`);const o=(0,n.getArchiveUrl)(t,r),s={method:"PUT",body:await i.text(),headers:[["Content-Type",i.headers.get("Content-Type")||"application/octet-stream"]]};"2"===(await e.fetcher._fetch(o,s)).status.toString()[0]&&await e.fetcher._fetch(t,{method:"DELETE"})}}};const n=r(6848)},7991:(e,t,r)=>{r.d(t,{A:()=>n,R:()=>i});const n=crypto,i=e=>e instanceof CryptoKey},8057:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(7991);const i=n.A.getRandomValues.bind(n.A)},8134:(e,t,r)=>{r.d(t,{CordovaIFrameNavigator:()=>n.CordovaIFrameNavigator,CordovaPopupNavigator:()=>n.CordovaPopupNavigator,InMemoryWebStorage:()=>n.InMemoryWebStorage,Log:()=>n.Log,OidcClient:()=>n.OidcClient,SessionMonitor:()=>n.SessionMonitor,User:()=>n.User,UserManager:()=>n.UserManager,Version:()=>n.Version,WebStorageStateStore:()=>n.WebStorageStateStore,clearOidcPersistentStorage:()=>x,getTokens:()=>F,normalizeCallbackUrl:()=>I,refresh:()=>k,registerClient:()=>b}),r.r(t);var n=r(6516),i=r(9380),o=r(3584),s=r(7248),a=r(7307),c=r(5130);const u={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let l;const d=new Uint8Array(16);const h=[];for(let e=0;e<256;++e)h.push((e+256).toString(16).slice(1));function f(e,t=0){return(h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]).toLowerCase()}const p=function(e,t,r){if(u.randomUUID&&!t&&!e)return u.randomUUID();const n=(e=e||{}).random??e.rng?.()??function(){if(!l){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");l=crypto.getRandomValues.bind(crypto)}return l(d)}();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=n[e];return t}return f(n)},g=["ES256","RS256"];async function y(e,t,r,n){let s,a;try{const{payload:a}=await(0,i.V)(e,(0,o.RD)(new URL(t)),{issuer:r,audience:n});s=a}catch(e){throw new Error(`Token verification failed: ${e.stack}`)}if("string"==typeof s.azp&&(a=s.azp),"string"==typeof s.webid)return{webId:s.webid,clientId:a};if("string"!=typeof s.sub)throw new Error(`The token ${JSON.stringify(s)} is invalid: it has no 'webid' claim and no 'sub' claim.`);try{return new URL(s.sub),{webId:s.sub,clientId:a}}catch(e){throw new Error(`The token has no 'webid' claim, and its 'sub' claim of [${s.sub}] is invalid as a URL - error [${e}].`)}}Error;Error;class v extends Error{missingFields;constructor(e){super(`Invalid response from OIDC provider: missing fields ${e}`),this.missingFields=e}}class m extends Error{error;errorDescription;constructor(e,t,r){super(e),this.error=t,this.errorDescription=r}}function w(e){const t=new URL(e);return new URL(t.pathname,t.origin).toString()}async function S(e,t,r){return new s.P({htu:w(e),htm:t.toUpperCase(),jti:p()}).setProtectedHeader({alg:g[0],jwk:r.publicKey,typ:"dpop+jwt"}).setIssuedAt().sign(r.privateKey,{})}function _(e,t){if("string"!=typeof e.client_id)throw new Error(`Dynamic client registration failed: no client_id has been found on ${JSON.stringify(e)}`);if(t.redirectUrl&&function(e){return Array.isArray(e.redirect_uris)&&e.redirect_uris.every(e=>"string"==typeof e)}(e)&&e.redirect_uris[0]!==t.redirectUrl.toString())throw new Error(`Dynamic client registration failed: the returned redirect URIs ${JSON.stringify(e.redirect_uris)} don't match the provided ${JSON.stringify([t.redirectUrl.toString()])}`);return!0}async function b(e,t){if(!t.registrationEndpoint)throw new Error("Dynamic Registration could not be completed because the issuer has no registration endpoint.");if(!Array.isArray(t.idTokenSigningAlgValuesSupported))throw new Error("The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory.");const r=(n=t.idTokenSigningAlgValuesSupported,g.find(e=>n.includes(e))??null);var n;const i={client_name:e.clientName,application_type:"web",redirect_uris:[e.redirectUrl?.toString()],subject_type:"public",token_endpoint_auth_method:"client_secret_basic",id_token_signed_response_alg:r,grant_types:["authorization_code","refresh_token"]},o=await fetch(t.registrationEndpoint.toString(),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(o.ok){const t=await o.json();return _(t,e),{clientId:t.client_id,clientSecret:t.client_secret,expiresAt:t.client_secret_expires_at,idTokenSignedResponseAlg:t.id_token_signed_response_alg,clientType:"dynamic"}}throw 400===o.status&&function(e,t){if("invalid_redirect_uri"===e.error)throw new Error(`Dynamic client registration failed: the provided redirect uri [${t.redirectUrl?.toString()}] is invalid - ${e.error_description??""}`);if("invalid_client_metadata"===e.error)throw new Error(`Dynamic client registration failed: the provided client metadata ${JSON.stringify(t)} is invalid - ${e.error_description??""}`);throw new Error(`Dynamic client registration failed: ${e.error} - ${e.error_description??""}`)}(await o.json(),e),new Error(`Dynamic client registration failed: the server returned ${o.status} ${o.statusText} - ${await o.text()}`)}function E(e){return void 0!==e.error_description&&"string"==typeof e.error_description}function A(e,t){if(void 0!==(r=e).error&&"string"==typeof r.error)throw new m(`Token endpoint returned error [${e.error}]${E(e)?`: ${e.error_description}`:""}${function(e){return void 0!==e.error_uri&&"string"==typeof e.error_uri}(e)?` (see ${e.error_uri})`:""}`,e.error,E(e)?e.error_description:void 0);var r;if(!function(e){return void 0!==e.access_token&&"string"==typeof e.access_token}(e))throw new v(["access_token"]);if(!function(e){return void 0!==e.id_token&&"string"==typeof e.id_token}(e))throw new v(["id_token"]);if(!function(e){return void 0!==e.token_type&&"string"==typeof e.token_type}(e))throw new v(["token_type"]);if(!function(e){return void 0===e.expires_in||"number"==typeof e.expires_in}(e))throw new v(["expires_in"]);if(!t&&"bearer"!==e.token_type.toLowerCase())throw new Error(`Invalid token endpoint response: requested a [Bearer] token, but got a 'token_type' value of [${e.token_type}].`);return e}async function F(e,t,r,n){!function(e,t){if(t.grantType&&(!e.grantTypesSupported||!e.grantTypesSupported.includes(t.grantType)))throw new Error(`The issuer [${e.issuer}] does not support the [${t.grantType}] grant`);if(!e.tokenEndpoint)throw new Error(`This issuer [${e.issuer}] does not have a token endpoint`)}(e,r);const i={"content-type":"application/x-www-form-urlencoded"};let o;n&&(o=await async function(){const{privateKey:e,publicKey:t}=await(0,a.T)(g[0]),r={privateKey:e,publicKey:await(0,c.JU)(t)};return[r.publicKey.alg]=g,r}(),i.DPoP=await S(e.tokenEndpoint,"POST",o)),t.clientSecret&&(i.Authorization=`Basic ${btoa(`${t.clientId}:${t.clientSecret}`)}`);const s={grant_type:r.grantType,redirect_uri:r.redirectUrl,code:r.code,code_verifier:r.codeVerifier,client_id:t.clientId},u={method:"POST",headers:i,body:new URLSearchParams(s).toString()},l=await fetch(e.tokenEndpoint,u),d=A(await l.json(),n),{webId:h,clientId:f}=await y(d.id_token,e.jwksUri,e.issuer,t.clientId);return{accessToken:d.access_token,idToken:d.id_token,refreshToken:(p=d,void 0!==p.refresh_token&&"string"==typeof p.refresh_token?d.refresh_token:void 0),webId:h,clientId:f,dpopKey:o,expiresIn:d.expires_in};var p}const P=e=>{try{return new URL(e),!0}catch{return!1}};async function k(e,t,r,n){if(void 0===r.clientId)throw new Error("No client ID available when trying to refresh the access token.");const i={grant_type:"refresh_token",refresh_token:e};let o={};void 0!==n&&(o={DPoP:await S(t.tokenEndpoint,"POST",n)});let s={};void 0!==r.clientSecret?s={Authorization:`Basic ${btoa(`${r.clientId}:${r.clientSecret}`)}`}:P(r.clientId)&&(i.client_id=r.clientId);const a=await fetch(t.tokenEndpoint,{method:"POST",body:new URLSearchParams(i).toString(),headers:{...o,...s,"Content-Type":"application/x-www-form-urlencoded"}});let c;try{c=await a.json()}catch(e){throw new Error(`The token endpoint of issuer ${t.issuer} returned a malformed response.`)}const u=A(c,void 0!==n),{webId:l}=await y(u.id_token,t.jwksUri,t.issuer,r.clientId);return{accessToken:u.access_token,idToken:u.id_token,refreshToken:"string"==typeof u.refresh_token?u.refresh_token:void 0,webId:l,dpopKey:n,expiresIn:u.expires_in}}function I(e){const t=function(e){const t=new URL(e);return t.searchParams.delete("state"),t.searchParams.delete("code"),t.searchParams.delete("error"),t.searchParams.delete("error_description"),t.searchParams.delete("iss"),t}(e);return t.hash="",e.includes(`${t.origin}/`)?t.href:`${t.origin}${t.href.substring(t.origin.length+1)}`}async function x(){const e=new n.OidcClient({response_mode:"query"});await e.clearStaleState(new n.WebStorageStateStore({}));const t=window.localStorage,r=[];for(let e=0;e<=t.length;e+=1){const n=t.key(e);n&&(n.match(/^oidc\..+$/)||n.match(/^solidClientAuthenticationUser:.+$/))&&r.push(n)}r.forEach(e=>t.removeItem(e))}},8278:(e,t,r)=>{r.d(t,{Lf:()=>l,Mh:()=>u,Og:()=>d,jU:()=>c});var n=r(1436),i=r(5141),o=r(1542),s=r(7493),a=r(149);async function c(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PUBLIC KEY-----"))throw new TypeError('"spki" must be SPKI formatted string');return(0,i.sc)(e,t,r)}async function u(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN CERTIFICATE-----"))throw new TypeError('"x509" must be X.509 formatted string');return(0,i.zp)(e,t,r)}async function l(e,t,r){if("string"!=typeof e||0!==e.indexOf("-----BEGIN PRIVATE KEY-----"))throw new TypeError('"pkcs8" must be PKCS#8 formatted string');return(0,i.IG)(e,t,r)}async function d(e,t){if(!(0,a.A)(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if("string"!=typeof e.k||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return(0,n.D4)(e.k);case"RSA":if("oth"in e&&void 0!==e.oth)throw new s.JOSENotSupported('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return(0,o.A)({...e,alg:t});default:throw new s.JOSENotSupported('Unsupported "kty" (Key Type) Parameter value')}}},8286:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(3779),i=r(2291),o=r(6011);t.default=function(e,t,r){if(n.default.randomUUID&&!t&&!e)return n.default.randomUUID();const s=(e=e||{}).random??e.rng?.()??(0,i.default)();if(s.length<16)throw new Error("Random bytes length must be >= 16");if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){if((r=r||0)<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[r+e]=s[e];return t}return(0,o.unsafeStringify)(s)}},8793:(e,t,r)=>{r.d(t,{K:()=>s,T:()=>c});var n=r(7991),i=r(7493),o=r(8057);async function s(e,t){let r,s,a;switch(e){case"HS256":case"HS384":case"HS512":r=parseInt(e.slice(-3),10),s={name:"HMAC",hash:`SHA-${r}`,length:r},a=["sign","verify"];break;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r=parseInt(e.slice(-3),10),(0,o.A)(new Uint8Array(r>>3));case"A128KW":case"A192KW":case"A256KW":r=parseInt(e.slice(1,4),10),s={name:"AES-KW",length:r},a=["wrapKey","unwrapKey"];break;case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":case"A128GCM":case"A192GCM":case"A256GCM":r=parseInt(e.slice(1,4),10),s={name:"AES-GCM",length:r},a=["encrypt","decrypt"];break;default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return n.A.subtle.generateKey(s,t?.extractable??!1,a)}function a(e){const t=e?.modulusLength??2048;if("number"!=typeof t||t<2048)throw new i.JOSENotSupported("Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used");return t}async function c(e,t){let r,o;switch(e){case"PS256":case"PS384":case"PS512":r={name:"RSA-PSS",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:a(t)},o=["sign","verify"];break;case"RS256":case"RS384":case"RS512":r={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.slice(-3)}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:a(t)},o=["sign","verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":r={name:"RSA-OAEP",hash:`SHA-${parseInt(e.slice(-3),10)||1}`,publicExponent:new Uint8Array([1,0,1]),modulusLength:a(t)},o=["decrypt","unwrapKey","encrypt","wrapKey"];break;case"ES256":r={name:"ECDSA",namedCurve:"P-256"},o=["sign","verify"];break;case"ES384":r={name:"ECDSA",namedCurve:"P-384"},o=["sign","verify"];break;case"ES512":r={name:"ECDSA",namedCurve:"P-521"},o=["sign","verify"];break;case"Ed25519":r={name:"Ed25519"},o=["sign","verify"];break;case"EdDSA":{o=["sign","verify"];const e=t?.crv??"Ed25519";switch(e){case"Ed25519":case"Ed448":r={name:e};break;default:throw new i.JOSENotSupported("Invalid or unsupported crv option provided")}break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{o=["deriveKey","deriveBits"];const e=t?.crv??"P-256";switch(e){case"P-256":case"P-384":case"P-521":r={name:"ECDH",namedCurve:e};break;case"X25519":case"X448":r={name:e};break;default:throw new i.JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448")}break}default:throw new i.JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}return n.A.subtle.generateKey(r,t?.extractable??!1,o)}},8858:(e,t,r)=>{r.d(t,{A:()=>u,I:()=>l});var n=r(1575),i=r(5994),o=r(5500);const s=e=>e?.[Symbol.toStringTag],a=(e,t,r)=>{if(void 0!==t.use&&"sig"!==t.use)throw new TypeError("Invalid key for this operation, when present its use must be sig");if(void 0!==t.key_ops&&!0!==t.key_ops.includes?.(r))throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(void 0!==t.alg&&t.alg!==e)throw new TypeError(`Invalid key for this operation, when present its alg must be ${e}`);return!0};function c(e,t,r,c){t.startsWith("HS")||"dir"===t||t.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(t)?((e,t,r,c)=>{if(!(t instanceof Uint8Array)){if(c&&o.ll(t)){if(o.t9(t)&&a(e,t,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!(0,i.A)(t))throw new TypeError((0,n.t)(e,t,...i.g,"Uint8Array",c?"JSON Web Key":null));if("secret"!==t.type)throw new TypeError(`${s(t)} instances for symmetric algorithms must be of type "secret"`)}})(t,r,c,e):((e,t,r,c)=>{if(c&&o.ll(t))switch(r){case"sign":if(o.W2(t)&&a(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(o.M3(t)&&a(e,t,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!(0,i.A)(t))throw new TypeError((0,n.t)(e,t,...i.g,c?"JSON Web Key":null));if("secret"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithms must not be of type "secret"`);if("sign"===r&&"public"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm signing must be of type "private"`);if("decrypt"===r&&"public"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&"verify"===r&&"private"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&"encrypt"===r&&"private"===t.type)throw new TypeError(`${s(t)} instances for asymmetric algorithm encryption must be of type "public"`)})(t,r,c,e)}const u=c.bind(void 0,!1),l=c.bind(void 0,!0)},9095:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.authSession=void 0;const n=r(2452);t.authSession=new n.Session},9378:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.log=function(...e){console.log(...e)},t.warn=function(...e){console.warn(...e)},t.error=function(...e){console.error(...e)},t.trace=function(...e){console.trace(...e)}},9380:(e,t,r)=>{r.d(t,{V:()=>s});var n=r(5609),i=r(9803),o=r(7493);async function s(e,t,r){const s=await(0,n.B)(e,t,r);if(s.protectedHeader.crit?.includes("b64")&&!1===s.protectedHeader.b64)throw new o.JWTInvalid("JWTs MUST NOT use unencoded payload");const a={payload:(0,i.A)(s.protectedHeader,s.payload,r),protectedHeader:s.protectedHeader};return"function"==typeof t?{...a,key:s.key}:a}},9746:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});const n=r(6697);t.default=function(e){return"string"==typeof e&&n.default.test(e)}},9803:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(7493),i=r(1476),o=r(2222),s=r(6957),a=r(149);const c=e=>e.toLowerCase().replace(/^application\//,""),u=(e,t,r={})=>{let u;try{u=JSON.parse(i.D0.decode(t))}catch{}if(!(0,a.A)(u))throw new n.JWTInvalid("JWT Claims Set must be a top-level JSON object");const{typ:l}=r;if(l&&("string"!=typeof e.typ||c(e.typ)!==c(l)))throw new n.JWTClaimValidationFailed('unexpected "typ" JWT header value',u,"typ","check_failed");const{requiredClaims:d=[],issuer:h,subject:f,audience:p,maxTokenAge:g}=r,y=[...d];void 0!==g&&y.push("iat"),void 0!==p&&y.push("aud"),void 0!==f&&y.push("sub"),void 0!==h&&y.push("iss");for(const e of new Set(y.reverse()))if(!(e in u))throw new n.JWTClaimValidationFailed(`missing required "${e}" claim`,u,e,"missing");if(h&&!(Array.isArray(h)?h:[h]).includes(u.iss))throw new n.JWTClaimValidationFailed('unexpected "iss" claim value',u,"iss","check_failed");if(f&&u.sub!==f)throw new n.JWTClaimValidationFailed('unexpected "sub" claim value',u,"sub","check_failed");if(p&&(v=u.aud,m="string"==typeof p?[p]:p,!("string"==typeof v?m.includes(v):Array.isArray(v)&&m.some(Set.prototype.has.bind(new Set(v))))))throw new n.JWTClaimValidationFailed('unexpected "aud" claim value',u,"aud","check_failed");var v,m;let w;switch(typeof r.clockTolerance){case"string":w=(0,s.A)(r.clockTolerance);break;case"number":w=r.clockTolerance;break;case"undefined":w=0;break;default:throw new TypeError("Invalid clockTolerance option type")}const{currentDate:S}=r,_=(0,o.A)(S||new Date);if((void 0!==u.iat||g)&&"number"!=typeof u.iat)throw new n.JWTClaimValidationFailed('"iat" claim must be a number',u,"iat","invalid");if(void 0!==u.nbf){if("number"!=typeof u.nbf)throw new n.JWTClaimValidationFailed('"nbf" claim must be a number',u,"nbf","invalid");if(u.nbf>_+w)throw new n.JWTClaimValidationFailed('"nbf" claim timestamp check failed',u,"nbf","check_failed")}if(void 0!==u.exp){if("number"!=typeof u.exp)throw new n.JWTClaimValidationFailed('"exp" claim must be a number',u,"exp","invalid");if(u.exp<=_-w)throw new n.JWTExpired('"exp" claim timestamp check failed',u,"exp","check_failed")}if(g){const e=_-u.iat;if(e-w>("number"==typeof g?g:(0,s.A)(g)))throw new n.JWTExpired('"iat" claim timestamp check failed (too far in the past)',u,"iat","check_failed");if(e<0-w)throw new n.JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)',u,"iat","check_failed")}return u}},9874:(e,t,r)=>{r.d(t,{A:()=>n});const n=(...e)=>{const t=e.filter(Boolean);if(0===t.length||1===t.length)return!0;let r;for(const e of t){const t=Object.keys(e);if(r&&0!==r.size)for(const e of t){if(r.has(e))return!1;r.add(e)}else r=new Set(t)}return!0}}},r={};function n(e){var i=r[e];if(void 0!==i)return i.exports;var o=r[e]={exports:{}};return t[e].call(o.exports,o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};(()=>{var e=i;Object.defineProperty(e,"BJ",{value:!0}),e.lG=e.jO=e.M_=e.hV=e.ac=e.ML=e.fk=e.m_=e.sN=e.Un=e.D_=e.T4=e.I0=e.vu=e.TX=e.Oo=void 0;const t=n(1781);Object.defineProperty(e,"hV",{enumerable:!0,get:function(){return t.solidLogicSingleton}});const r=t.solidLogicSingleton.authn;e.jO=r;const o=t.solidLogicSingleton.authn.authSession;e.lG=o;const s=t.solidLogicSingleton.store;e.M_=s;var a=n(6769);Object.defineProperty(e,"Oo",{enumerable:!0,get:function(){return a.ACL_LINK}});var c=n(2233);Object.defineProperty(e,"TX",{enumerable:!0,get:function(){return c.offlineTestID}}),Object.defineProperty(e,"vu",{enumerable:!0,get:function(){return c.appContext}});var u=n(4353);Object.defineProperty(e,"I0",{enumerable:!0,get:function(){return u.getSuggestedIssuers}});var l=n(1177);Object.defineProperty(e,"T4",{enumerable:!0,get:function(){return l.createTypeIndexLogic}});var d=n(390);Object.defineProperty(e,"D_",{enumerable:!0,get:function(){return d.UnauthorizedError}}),Object.defineProperty(e,"Un",{enumerable:!0,get:function(){return d.CrossOriginForbiddenError}}),Object.defineProperty(e,"sN",{enumerable:!0,get:function(){return d.SameOriginForbiddenError}}),Object.defineProperty(e,"m_",{enumerable:!0,get:function(){return d.NotFoundError}}),Object.defineProperty(e,"fk",{enumerable:!0,get:function(){return d.FetchError}}),Object.defineProperty(e,"ML",{enumerable:!0,get:function(){return d.NotEditableError}}),Object.defineProperty(e,"ac",{enumerable:!0,get:function(){return d.WebOperationError}})})();const o=i.Oo,s=i.Un,a=i.fk,c=i.ML,u=i.m_,l=i.sN,d=i.D_,h=i.ac,f=i.BJ,p=i.vu,g=i.lG,y=i.jO,v=i.T4,m=i.I0,w=i.TX,S=i.hV,_=i.M_;export{o as ACL_LINK,s as CrossOriginForbiddenError,a as FetchError,c as NotEditableError,u as NotFoundError,l as SameOriginForbiddenError,d as UnauthorizedError,h as WebOperationError,f as __esModule,p as appContext,g as authSession,y as authn,v as createTypeIndexLogic,m as getSuggestedIssuers,w as offlineTestID,S as solidLogicSingleton,_ as store};
|
|
32
|
+
//# sourceMappingURL=solid-logic.esm.external.min.js.map
|