Edit: /tmp/tsx-0/17887-a5a31f99a13f96120a726cb601a802a01595540f (7833B)
{"code":"__filename=\"/opt/canhelp/node_modules/jose/dist/webapi/jws/flattened/verify.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 verify_exports={};__export(verify_exports,{flattenedVerify:()=>flattenedVerify});module.exports=__toCommonJS(verify_exports);var import_base64url=require(\"../../util/base64url.js\");var import_signing=require(\"../../lib/signing.js\");var import_errors=require(\"../../util/errors.js\");var import_buffer_utils=require(\"../../lib/buffer_utils.js\");var import_helpers=require(\"../../lib/helpers.js\");var import_type_checks=require(\"../../lib/type_checks.js\");var import_type_checks2=require(\"../../lib/type_checks.js\");var import_check_key_type=require(\"../../lib/check_key_type.js\");var import_validate_crit=require(\"../../lib/validate_crit.js\");var import_validate_algorithms=require(\"../../lib/validate_algorithms.js\");var import_normalize_key=require(\"../../lib/normalize_key.js\");async function flattenedVerify(jws,key,options){if(!(0,import_type_checks2.isObject)(jws)){throw new import_errors.JWSInvalid(\"Flattened JWS must be an object\")}if(jws.protected===void 0&&jws.header===void 0){throw new import_errors.JWSInvalid('Flattened JWS must have either of the \"protected\" or \"header\" members')}if(jws.protected!==void 0&&typeof jws.protected!==\"string\"){throw new import_errors.JWSInvalid(\"JWS Protected Header incorrect type\")}if(jws.payload===void 0){throw new import_errors.JWSInvalid(\"JWS Payload missing\")}if(typeof jws.signature!==\"string\"){throw new import_errors.JWSInvalid(\"JWS Signature missing or incorrect type\")}if(jws.header!==void 0&&!(0,import_type_checks2.isObject)(jws.header)){throw new import_errors.JWSInvalid(\"JWS Unprotected Header incorrect type\")}let parsedProt={};if(jws.protected){try{const protectedHeader=(0,import_base64url.decode)(jws.protected);parsedProt=JSON.parse(import_buffer_utils.decoder.decode(protectedHeader))}catch{throw new import_errors.JWSInvalid(\"JWS Protected Header is invalid\")}}if(!(0,import_type_checks.isDisjoint)(parsedProt,jws.header)){throw new import_errors.JWSInvalid(\"JWS Protected and JWS Unprotected Header Parameter names must be disjoint\")}const joseHeader={...parsedProt,...jws.header};const extensions=(0,import_validate_crit.validateCrit)(import_errors.JWSInvalid,new Map([[\"b64\",true]]),options?.crit,parsedProt,joseHeader);let b64=true;if(extensions.has(\"b64\")){b64=parsedProt.b64;if(typeof b64!==\"boolean\"){throw new import_errors.JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean')}}const{alg}=joseHeader;if(typeof alg!==\"string\"||!alg){throw new import_errors.JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid')}const algorithms=options&&(0,import_validate_algorithms.validateAlgorithms)(\"algorithms\",options.algorithms);if(algorithms&&!algorithms.has(alg)){throw new import_errors.JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter value not allowed')}if(b64){if(typeof jws.payload!==\"string\"){throw new import_errors.JWSInvalid(\"JWS Payload must be a string\")}}else if(typeof jws.payload!==\"string\"&&!(jws.payload instanceof Uint8Array)){throw new import_errors.JWSInvalid(\"JWS Payload must be a string or an Uint8Array instance\")}let resolvedKey=false;if(typeof key===\"function\"){key=await key(parsedProt,jws);resolvedKey=true}(0,import_check_key_type.checkKeyType)(alg,key,\"verify\");const data=(0,import_buffer_utils.concat)(jws.protected!==void 0?(0,import_buffer_utils.encode)(jws.protected):new Uint8Array,(0,import_buffer_utils.encode)(\".\"),typeof jws.payload===\"string\"?b64?(0,import_buffer_utils.encode)(jws.payload):import_buffer_utils.encoder.encode(jws.payload):jws.payload);const signature=(0,import_helpers.decodeBase64url)(jws.signature,\"signature\",import_errors.JWSInvalid);const k=await(0,import_normalize_key.normalizeKey)(key,alg);const verified=await(0,import_signing.verify)(alg,k,signature,data);if(!verified){throw new import_errors.JWSSignatureVerificationFailed}let payload;if(b64){payload=(0,import_helpers.decodeBase64url)(jws.payload,\"payload\",import_errors.JWSInvalid)}else if(typeof jws.payload===\"string\"){payload=import_buffer_utils.encoder.encode(jws.payload)}else{payload=jws.payload}const result={payload};if(jws.protected!==void 0){result.protectedHeader=parsedProt}if(jws.header!==void 0){result.unprotectedHeader=jws.header}if(resolvedKey){return{...result,key:k}}return result}__name(flattenedVerify,\"flattenedVerify\");0&&(module.exports={flattenedVerify});\n})()\n","warnings":[],"map":{"version":3,"mappings":";suBAAA,sJAA+B,mCAC/B,mBAAuB,gCACvB,kBAA8E,gCAC9E,wBAAiD,qCACjD,mBAAgC,gCAChC,uBAA2B,oCAC3B,IAAAA,oBAAyB,oCACzB,0BAA6B,uCAC7B,yBAA6B,sCAC7B,+BAAmC,4CACnC,yBAA6B,sCAC7B,eAAsB,gBAAgB,IAAK,IAAK,QAAS,CACrD,GAAI,IAAC,8BAAS,GAAG,EAAG,CAChB,MAAM,IAAI,yBAAW,iCAAiC,CAC1D,CACA,GAAI,IAAI,YAAc,QAAa,IAAI,SAAW,OAAW,CACzD,MAAM,IAAI,yBAAW,uEAAuE,CAChG,CACA,GAAI,IAAI,YAAc,QAAa,OAAO,IAAI,YAAc,SAAU,CAClE,MAAM,IAAI,yBAAW,qCAAqC,CAC9D,CACA,GAAI,IAAI,UAAY,OAAW,CAC3B,MAAM,IAAI,yBAAW,qBAAqB,CAC9C,CACA,GAAI,OAAO,IAAI,YAAc,SAAU,CACnC,MAAM,IAAI,yBAAW,yCAAyC,CAClE,CACA,GAAI,IAAI,SAAW,QAAa,IAAC,8BAAS,IAAI,MAAM,EAAG,CAC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/B,MAAM,QAAO,4BAAO,IAAI,YAAc,UAAY,4BAAO,IAAI,SAAS,EAAI,IAAI,cAAc,4BAAO,GAAG,EAAG,OAAO,IAAI,UAAY,SAC1H,OACI,4BAAO,IAAI,OAAO,EAClB,4BAAQ,OAAO,IAAI,OAAO,EAC9B,IAAI,OAAO,EACjB,MAAM,aAAY,gCAAgB,IAAI,UAAW,YAAa,wBAAU,EACxE,MAAM,EAAI,QAAM,mCAAa,IAAK,GAAG,EACrC,MAAM,SAAW,QAAM,uBAAO,IAAK,EAAG,UAAW,IAAI,EACrD,GAAI,CAAC,SAAU,CACX,MAAM,IAAI,4CACd,CACA,IAAI,QACJ,GAAI,IAAK,CACL,WAAU,gCAAgB,IAAI,QAAS,UAAW,wBAAU,CAChE,SACS,OAAO,IAAI,UAAY,SAAU,CACtC,QAAU,4BAAQ,OAAO,IAAI,OAAO,CACxC,KACK,CACD,QAAU,IAAI,OAClB,CACA,MAAM,OAAS,CAAE,OAAQ,EACzB,GAAI,IAAI,YAAc,OAAW,CAC7B,OAAO,gBAAkB,UAC7B,CACA,GAAI,IAAI,SAAW,OAAW,CAC1B,OAAO,kBAAoB,IAAI,MACnC,CACA,GAAI,YAAa,CACb,MAAO,CAAE,GAAG,OAAQ,IAAK,CAAE,CAC/B,CACA,OAAO,MACX,CAlGsB","names":["import_type_checks","b64u"],"ignoreList":[],"sources":["/opt/canhelp/node_modules/jose/dist/webapi/jws/flattened/verify.js"],"sourcesContent":[null]}}