Edit: /tmp/tsx-0/17887-824bafcd4b799a6e69414c5486141f0f6e9282a1 (4537B)
{"code":"__filename=\"/opt/canhelp/node_modules/jose/dist/webapi/lib/ecdhes.js\";(()=>{\nvar __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,\"name\",{value,configurable:true});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from===\"object\"||typeof from===\"function\"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},\"__esModule\",{value:true}),mod);var ecdhes_exports={};__export(ecdhes_exports,{allowed:()=>allowed,deriveKey:()=>deriveKey});module.exports=__toCommonJS(ecdhes_exports);var import_buffer_utils=require(\"./buffer_utils.js\");var import_crypto_key=require(\"./crypto_key.js\");var import_helpers=require(\"./helpers.js\");function lengthAndInput(input){return(0,import_buffer_utils.concat)((0,import_buffer_utils.uint32be)(input.length),input)}__name(lengthAndInput,\"lengthAndInput\");async function concatKdf(Z,L,OtherInfo){const dkLen=L>>3;const hashLen=32;const reps=Math.ceil(dkLen/hashLen);const dk=new Uint8Array(reps*hashLen);for(let i=1;i<=reps;i++){const hashInput=new Uint8Array(4+Z.length+OtherInfo.length);hashInput.set((0,import_buffer_utils.uint32be)(i),0);hashInput.set(Z,4);hashInput.set(OtherInfo,4+Z.length);const hashResult=await(0,import_helpers.digest)(\"sha256\",hashInput);dk.set(hashResult,(i-1)*hashLen)}return dk.slice(0,dkLen)}__name(concatKdf,\"concatKdf\");async function deriveKey(publicKey,privateKey,algorithm,keyLength,apu=new Uint8Array,apv=new Uint8Array){(0,import_crypto_key.checkEncCryptoKey)(publicKey,\"ECDH\");(0,import_crypto_key.checkEncCryptoKey)(privateKey,\"ECDH\",\"deriveBits\");const algorithmID=lengthAndInput((0,import_buffer_utils.encode)(algorithm));const partyUInfo=lengthAndInput(apu);const partyVInfo=lengthAndInput(apv);const suppPubInfo=(0,import_buffer_utils.uint32be)(keyLength);const suppPrivInfo=new Uint8Array;const otherInfo=(0,import_buffer_utils.concat)(algorithmID,partyUInfo,partyVInfo,suppPubInfo,suppPrivInfo);const Z=new Uint8Array(await crypto.subtle.deriveBits({name:publicKey.algorithm.name,public:publicKey},privateKey,getEcdhBitLength(publicKey)));return concatKdf(Z,keyLength,otherInfo)}__name(deriveKey,\"deriveKey\");function getEcdhBitLength(publicKey){if(publicKey.algorithm.name===\"X25519\"){return 256}return Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3),10)/8)<<3}__name(getEcdhBitLength,\"getEcdhBitLength\");function allowed(key){switch(key.algorithm.namedCurve){case\"P-256\":case\"P-384\":case\"P-521\":return true;default:return key.algorithm.name===\"X25519\"}}__name(allowed,\"allowed\");0&&(module.exports={allowed,deriveKey});\n})()\n","warnings":[],"map":{"version":3,"mappings":";suBAAA,iKAAyC,6BACzC,sBAAkC,2BAClC,mBAAuB,wBACvB,SAAS,eAAe,MAAO,CAC3B,SAAO,+BAAO,8BAAS,MAAM,MAAM,EAAG,KAAK,CAC/C,CAFS,wCAGT,eAAe,UAAU,EAAG,EAAG,UAAW,CACtC,MAAM,MAAQ,GAAK,EACnB,MAAM,QAAU,GAChB,MAAM,KAAO,KAAK,KAAK,MAAQ,OAAO,EACtC,MAAM,GAAK,IAAI,WAAW,KAAO,OAAO,EACxC,QAAS,EAAI,EAAG,GAAK,KAAM,IAAK,CAC5B,MAAM,UAAY,IAAI,WAAW,EAAI,EAAE,OAAS,UAAU,MAAM,EAChE,UAAU,OAAI,8BAAS,CAAC,EAAG,CAAC,EAC5B,UAAU,IAAI,EAAG,CAAC,EAClB,UAAU,IAAI,UAAW,EAAI,EAAE,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