Edit: /tmp/tsx-0/17887-caea52efc4f548bb3ab7529e1d5024acc54cad50 (10932B)
{"code":"__filename=\"/opt/canhelp/node_modules/jose/dist/webapi/jwe/general/encrypt.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 encrypt_exports={};__export(encrypt_exports,{GeneralEncrypt:()=>GeneralEncrypt});module.exports=__toCommonJS(encrypt_exports);var import_encrypt=require(\"../flattened/encrypt.js\");var import_helpers=require(\"../../lib/helpers.js\");var import_errors=require(\"../../util/errors.js\");var import_content_encryption=require(\"../../lib/content_encryption.js\");var import_type_checks=require(\"../../lib/type_checks.js\");var import_key_management=require(\"../../lib/key_management.js\");var import_base64url=require(\"../../util/base64url.js\");var import_validate_crit=require(\"../../lib/validate_crit.js\");var import_normalize_key=require(\"../../lib/normalize_key.js\");var import_check_key_type=require(\"../../lib/check_key_type.js\");class IndividualRecipient{static{__name(this,\"IndividualRecipient\")}#parent;unprotectedHeader;keyManagementParameters;key;options;constructor(enc,key,options){this.#parent=enc;this.key=key;this.options=options}setUnprotectedHeader(unprotectedHeader){(0,import_helpers.assertNotSet)(this.unprotectedHeader,\"setUnprotectedHeader\");this.unprotectedHeader=unprotectedHeader;return this}setKeyManagementParameters(parameters){(0,import_helpers.assertNotSet)(this.keyManagementParameters,\"setKeyManagementParameters\");this.keyManagementParameters=parameters;return this}addRecipient(...args){return this.#parent.addRecipient(...args)}encrypt(...args){return this.#parent.encrypt(...args)}done(){return this.#parent}}class GeneralEncrypt{static{__name(this,\"GeneralEncrypt\")}#plaintext;#recipients=[];#protectedHeader;#unprotectedHeader;#aad;constructor(plaintext){this.#plaintext=plaintext}addRecipient(key,options){const recipient=new IndividualRecipient(this,key,{crit:options?.crit});this.#recipients.push(recipient);return recipient}setProtectedHeader(protectedHeader){(0,import_helpers.assertNotSet)(this.#protectedHeader,\"setProtectedHeader\");this.#protectedHeader=protectedHeader;return this}setSharedUnprotectedHeader(sharedUnprotectedHeader){(0,import_helpers.assertNotSet)(this.#unprotectedHeader,\"setSharedUnprotectedHeader\");this.#unprotectedHeader=sharedUnprotectedHeader;return this}setAdditionalAuthenticatedData(aad){this.#aad=aad;return this}async encrypt(){if(!this.#recipients.length){throw new import_errors.JWEInvalid(\"at least one recipient must be added\")}if(this.#recipients.length===1){const[recipient]=this.#recipients;const flattened=await new import_encrypt.FlattenedEncrypt(this.#plaintext).setAdditionalAuthenticatedData(this.#aad).setProtectedHeader(this.#protectedHeader).setSharedUnprotectedHeader(this.#unprotectedHeader).setUnprotectedHeader(recipient.unprotectedHeader).encrypt(recipient.key,{...recipient.options});const jwe2={ciphertext:flattened.ciphertext,iv:flattened.iv,recipients:[{}],tag:flattened.tag};if(flattened.aad)jwe2.aad=flattened.aad;if(flattened.protected)jwe2.protected=flattened.protected;if(flattened.unprotected)jwe2.unprotected=flattened.unprotected;if(flattened.encrypted_key)jwe2.recipients[0].encrypted_key=flattened.encrypted_key;if(flattened.header)jwe2.recipients[0].header=flattened.header;return jwe2}let enc;for(let i=0;i