resend-cli 2.8.0 → 2.8.1
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/dist/cli.cjs +3 -3
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -24,7 +24,7 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[t]?this._life
|
|
|
24
24
|
`),this.outputHelp({error:!0}));let i=o||{},r=i.exitCode||1,n=i.code||"commander.error";this._exit(r,n,t)}_parseOptionsEnv(){this.options.forEach(t=>{if(t.envVar&&t.envVar in L.env){let o=t.attributeName();(this.getOptionValue(o)===void 0||["default","config","env"].includes(this.getOptionValueSource(o)))&&(t.required||t.optional?this.emit(`optionEnv:${t.name()}`,L.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new Xu(this.options),o=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&o(i.attributeName())&&t.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(r=>!o(r)).forEach(r=>{this.setOptionValueWithSource(r,i.implied[r],"implied")})})}missingArgument(t){let o=`error: missing required argument '${t}'`;this.error(o,{code:"commander.missingArgument"})}optionMissingArgument(t){let o=`error: option '${t.flags}' argument missing`;this.error(o,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(t){let o=`error: required option '${t.flags}' not specified`;this.error(o,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(t,o){let i=s=>{let a=s.attributeName(),l=this.getOptionValue(a),d=this.options.find(u=>u.negate&&a===u.attributeName()),c=this.options.find(u=>!u.negate&&a===u.attributeName());return d&&(d.presetArg===void 0&&l===!1||d.presetArg!==void 0&&l===d.presetArg)?d:c||s},r=s=>{let a=i(s),l=a.attributeName();return this.getOptionValueSource(l)==="env"?`environment variable '${a.envVar}'`:`option '${a.flags}'`},n=`error: ${r(t)} cannot be used with ${r(o)}`;this.error(n,{code:"commander.conflictingOption"})}unknownOption(t){if(this._allowUnknownOption)return;let o="";if(t.startsWith("--")&&this._showSuggestionAfterError){let r=[],n=this;do{let s=n.createHelp().visibleOptions(n).filter(a=>a.long).map(a=>a.long);r=r.concat(s),n=n.parent}while(n&&!n._enablePositionalOptions);o=$r(t,r)}let i=`error: unknown option '${t}'${o}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(t){if(this._allowExcessArguments)return;let o=this.registeredArguments.length,i=o===1?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${o} argument${i} but got ${t.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){let t=this.args[0],o="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach(n=>{r.push(n.name()),n.alias()&&r.push(n.alias())}),o=$r(t,r)}let i=`error: unknown command '${t}'${o}`;this.error(i,{code:"commander.unknownCommand"})}version(t,o,i){if(t===void 0)return this._version;this._version=t,o=o||"-V, --version",i=i||"output the version number";let r=this.createOption(o,i);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${t}
|
|
25
25
|
`),this._exit(0,"commander.version",t)}),this}description(t,o){return t===void 0&&o===void 0?this._description:(this._description=t,o&&(this._argsDescription=o),this)}summary(t){return t===void 0?this._summary:(this._summary=t,this)}alias(t){if(t===void 0)return this._aliases[0];let o=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(o=this.commands[this.commands.length-1]),t===o._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(t);if(i){let r=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${t}' to command '${this.name()}' as already have command '${r}'`)}return o._aliases.push(t),this}aliases(t){return t===void 0?this._aliases:(t.forEach(o=>this.alias(o)),this)}usage(t){if(t===void 0){if(this._usage)return this._usage;let o=this.registeredArguments.map(i=>Vu(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?o:[]).join(" ")}return this._usage=t,this}name(t){return t===void 0?this._name:(this._name=t,this)}helpGroup(t){return t===void 0?this._helpGroupHeading??"":(this._helpGroupHeading=t,this)}commandsGroup(t){return t===void 0?this._defaultCommandGroup??"":(this._defaultCommandGroup=t,this)}optionsGroup(t){return t===void 0?this._defaultOptionGroup??"":(this._defaultOptionGroup=t,this)}_initOptionGroup(t){this._defaultOptionGroup&&!t.helpGroupHeading&&t.helpGroup(this._defaultOptionGroup)}_initCommandGroup(t){this._defaultCommandGroup&&!t.helpGroup()&&t.helpGroup(this._defaultCommandGroup)}nameFromFilename(t){return this._name=ze.basename(t,ze.extname(t)),this}executableDir(t){return t===void 0?this._executableDir:(this._executableDir=t,this)}helpInformation(t){let o=this.createHelp(),i=this._getOutputContext(t);o.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});let r=o.formatHelp(this,o);return i.hasColors?r:this._outputConfiguration.stripColor(r)}_getOutputContext(t){t=t||{};let o=!!t.error,i,r,n;return o?(i=a=>this._outputConfiguration.writeErr(a),r=this._outputConfiguration.getErrHasColors(),n=this._outputConfiguration.getErrHelpWidth()):(i=a=>this._outputConfiguration.writeOut(a),r=this._outputConfiguration.getOutHasColors(),n=this._outputConfiguration.getOutHelpWidth()),{error:o,write:a=>(r||(a=this._outputConfiguration.stripColor(a)),i(a)),hasColors:r,helpWidth:n}}outputHelp(t){let o;typeof t=="function"&&(o=t,t=void 0);let i=this._getOutputContext(t),r={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach(s=>s.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let n=this.helpInformation({error:i.error});if(o&&(n=o(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",r),this._getCommandAndAncestors().forEach(s=>s.emit("afterAllHelp",r))}helpOption(t,o){return typeof t=="boolean"?(t?(this._helpOption===null&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(t??"-h, --help",o??"display help for command"),(t||o)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(t){return this._helpOption=t,this._initOptionGroup(t),this}help(t){this.outputHelp(t);let o=Number(L.exitCode??0);o===0&&t&&typeof t!="function"&&t.error&&(o=1),this._exit(o,"commander.help","(outputHelp)")}addHelpText(t,o){let i=["beforeAll","before","after","afterAll"];if(!i.includes(t))throw new Error(`Unexpected value for position to addHelpText.
|
|
26
26
|
Expecting one of '${i.join("', '")}'`);let r=`${t}Help`;return this.on(r,n=>{let s;typeof o=="function"?s=o({error:n.error,command:n.command}):s=o,s&&n.write(`${s}
|
|
27
|
-
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(r=>o.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Hr(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let o,i="127.0.0.1",r="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?o=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(o=n[1],/^\d+$/.test(n[3])?r=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(o=n[1],i=n[3],r=n[4]),o&&r!=="0"?`${o}=${i}:${parseInt(r)+1}`:t})}function Ri(){if(L.env.NO_COLOR||L.env.FORCE_COLOR==="0"||L.env.FORCE_COLOR==="false")return!1;if(L.env.FORCE_COLOR||L.env.CLICOLOR_FORCE!==void 0)return!0}Di.Command=ki;Di.useColor=Ri});var Mr=we(Te=>{var{Argument:Gr}=ho(),{Command:_i}=Qr(),{CommanderError:Zu,InvalidArgumentError:Nr}=Wt(),{Help:ed}=Ui(),{Option:qr}=wi();Te.program=new _i;Te.createCommand=e=>new _i(e);Te.createOption=(e,t)=>new qr(e,t);Te.createArgument=(e,t)=>new Gr(e,t);Te.Command=_i;Te.Option=qr;Te.Argument=Gr;Te.Help=ed;Te.CommanderError=Zu;Te.InvalidArgumentError=Nr;Te.InvalidOptionArgumentError=Nr});var Wr=we((De,Lr)=>{var He=Mr();De=Lr.exports={};De.program=new He.Command;De.Argument=He.Argument;De.Command=He.Command;De.CommanderError=He.CommanderError;De.Help=He.Help;De.InvalidArgumentError=He.InvalidArgumentError;De.InvalidOptionArgumentError=He.InvalidArgumentError;De.Option=He.Option;De.createCommand=e=>new He.Command(e);De.createOption=(e,t)=>new He.Option(e,t);De.createArgument=(e,t)=>new He.Argument(e,t)});var ot=we((Rf,Bi)=>{var Co=process||{},zr=Co.argv||[],bo=Co.env||{},td=!(bo.NO_COLOR||zr.includes("--no-color"))&&(!!bo.FORCE_COLOR||zr.includes("--color")||Co.platform==="win32"||(Co.stdout||{}).isTTY&&bo.TERM!=="dumb"||!!bo.CI),od=(e,t,o=e)=>i=>{let r=""+i,n=r.indexOf(t,e.length);return~n?e+id(r,t,o,n)+t:e+r+t},id=(e,t,o,i)=>{let r="",n=0;do r+=e.substring(n,i)+o,n=i+t.length,i=e.indexOf(t,n);while(~i);return r+e.substring(n)},Yr=(e=td)=>{let t=e?od:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};Bi.exports=Yr();Bi.exports.createColors=Yr});var Ii=we((Pf,mn)=>{"use strict";var ji={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let o="";return e<0?o+=`\x1B[${-e}D`:e>0&&(o+=`\x1B[${e}C`),t<0?o+=`\x1B[${-t}A`:t>0&&(o+=`\x1B[${t}B`),o},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},yd={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Ud={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let o=0;o<e;o++)t+=this.line+(o<e-1?ji.up():"");return e&&(t+=ji.left),t}};mn.exports={cursor:ji,scroll:yd,erase:Ud,beep:"\x07"}});var Ni,kn=me(()=>{Ni={name:"resend-cli",version:"2.8.0",description:"The official CLI for Resend",license:"MIT",repository:{type:"git",url:"https://github.com/resend/resend-cli"},homepage:"https://github.com/resend/resend-cli#readme",keywords:["cli","resend","email","api","tanstack-intent"],engines:{node:">=22"},packageManager:"pnpm@11.8.0",files:["dist/cli.cjs","skills/"],type:"module",bin:{resend:"./dist/cli.cjs"},scripts:{dev:"tsx src/cli.ts","dev:watch":"tsx --watch src/cli.ts",build:"node scripts/build.mjs","build:bin":"pnpm build && pkg dist/cli.cjs --config package.json --compress Brotli --target node24 --output dist/resend",lint:"biome check .","lint:fix":"biome check --write .",typecheck:"tsc --noEmit",test:"vitest run","test:e2e":"vitest run --config vitest.config.e2e.ts",prepack:"pnpm install && pnpm build && node scripts/verify-bundle.mjs"},dependencies:{"@clack/prompts":"1.4.0","@commander-js/extra-typings":"14.0.0",commander:"14.0.3",esbuild:"0.28.1","esbuild-wasm":"0.28.0",picocolors:"1.1.1",resend:"6.17.0"},pkg:{scripts:["node_modules/esbuild-wasm/bin/esbuild","node_modules/esbuild-wasm/wasm_exec.js","node_modules/esbuild-wasm/wasm_exec_node.js"],assets:["node_modules/esbuild-wasm/esbuild.wasm"]},devDependencies:{"@biomejs/biome":"2.4.11","@types/node":"24.12.4","@yao-pkg/pkg":"6.20.0",tsx:"4.22.4",typescript:"5.9.3",vitest:"4.1.9"}}});var te,Rn,bt=me(()=>{"use strict";kn();te=Ni.version,Rn=Ni.name});var Hn=we(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.timingSafeEqual=void 0;function $n(e,t=""){if(!e)throw new Error(t)}function Yd(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),$n(e instanceof DataView),$n(t instanceof DataView);let o=e.byteLength,i=0,r=-1;for(;++r<o;)i|=e.getUint8(r)^t.getUint8(r);return i===0}Bo.timingSafeEqual=Yd});var Nn=we(Be=>{"use strict";var Xd=Be&&Be.__extends||(function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var n in r)r.hasOwnProperty(n)&&(i[n]=r[n])},e(t,o)};return function(t,o){e(t,o);function i(){this.constructor=t}t.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)}})();Object.defineProperty(Be,"__esModule",{value:!0});var ne=256,Xi=(function(){function e(t){t===void 0&&(t="="),this._paddingCharacter=t}return e.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(t*8+5)/6|0},e.prototype.encode=function(t){for(var o="",i=0;i<t.length-2;i+=3){var r=t[i]<<16|t[i+1]<<8|t[i+2];o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),o+=this._encodeByte(r>>>6&63),o+=this._encodeByte(r>>>0&63)}var n=t.length-i;if(n>0){var r=t[i]<<16|(n===2?t[i+1]<<8:0);o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),n===2?o+=this._encodeByte(r>>>6&63):o+=this._paddingCharacter||"",o+=this._paddingCharacter||""}return o},e.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(t*6+7)/8|0},e.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},e.prototype.decode=function(t){if(t.length===0)return new Uint8Array(0);for(var o=this._getPaddingLength(t),i=t.length-o,r=new Uint8Array(this.maxDecodedLength(i)),n=0,s=0,a=0,l=0,d=0,c=0,u=0;s<i-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),d=this._decodeChar(t.charCodeAt(s+1)),c=this._decodeChar(t.charCodeAt(s+2)),u=this._decodeChar(t.charCodeAt(s+3)),r[n++]=l<<2|d>>>4,r[n++]=d<<4|c>>>2,r[n++]=c<<6|u,a|=l&ne,a|=d&ne,a|=c&ne,a|=u≠if(s<i-1&&(l=this._decodeChar(t.charCodeAt(s)),d=this._decodeChar(t.charCodeAt(s+1)),r[n++]=l<<2|d>>>4,a|=l&ne,a|=d&ne),s<i-2&&(c=this._decodeChar(t.charCodeAt(s+2)),r[n++]=d<<4|c>>>2,a|=c&ne),s<i-3&&(u=this._decodeChar(t.charCodeAt(s+3)),r[n++]=c<<6|u,a|=u&ne),a!==0)throw new Error("Base64Coder: incorrect characters for decoding");return r},e.prototype._encodeByte=function(t){var o=t;return o+=65,o+=25-t>>>8&6,o+=51-t>>>8&-75,o+=61-t>>>8&-15,o+=62-t>>>8&3,String.fromCharCode(o)},e.prototype._decodeChar=function(t){var o=ne;return o+=(42-t&t-44)>>>8&-ne+t-43+62,o+=(46-t&t-48)>>>8&-ne+t-47+63,o+=(47-t&t-58)>>>8&-ne+t-48+52,o+=(64-t&t-91)>>>8&-ne+t-65+0,o+=(96-t&t-123)>>>8&-ne+t-97+26,o},e.prototype._getPaddingLength=function(t){var o=0;if(this._paddingCharacter){for(var i=t.length-1;i>=0&&t[i]===this._paddingCharacter;i--)o++;if(t.length<4||o>2)throw new Error("Base64Coder: incorrect padding")}return o},e})();Be.Coder=Xi;var io=new Xi;function Zd(e){return io.encode(e)}Be.encode=Zd;function ep(e){return io.decode(e)}Be.decode=ep;var Qn=(function(e){Xd(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype._encodeByte=function(o){var i=o;return i+=65,i+=25-o>>>8&6,i+=51-o>>>8&-75,i+=61-o>>>8&-13,i+=62-o>>>8&49,String.fromCharCode(i)},t.prototype._decodeChar=function(o){var i=ne;return i+=(44-o&o-46)>>>8&-ne+o-45+62,i+=(94-o&o-96)>>>8&-ne+o-95+63,i+=(47-o&o-58)>>>8&-ne+o-48+52,i+=(64-o&o-91)>>>8&-ne+o-65+0,i+=(96-o&o-123)>>>8&-ne+o-97+26,i},t})(Xi);Be.URLSafeCoder=Qn;var Gn=new Qn;function tp(e){return Gn.encode(e)}Be.encodeURLSafe=tp;function op(e){return Gn.decode(e)}Be.decodeURLSafe=op;Be.encodedLength=function(e){return io.encodedLength(e)};Be.maxDecodedLength=function(e){return io.maxDecodedLength(e)};Be.decodedLength=function(e){return io.decodedLength(e)}});var Mn=we((qn,Eo)=>{(function(e,t){var o={};t(o);var i=o.default;for(var r in o)i[r]=o[r];typeof Eo=="object"&&typeof Eo.exports=="object"?Eo.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):e.sha256=i})(qn,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function o(u,f,b,h,A){for(var K,v,S,w,Q,k,B,_,F,E,be,ee,ht;A>=64;){for(K=f[0],v=f[1],S=f[2],w=f[3],Q=f[4],k=f[5],B=f[6],_=f[7],E=0;E<16;E++)be=h+E*4,u[E]=(b[be]&255)<<24|(b[be+1]&255)<<16|(b[be+2]&255)<<8|b[be+3]&255;for(E=16;E<64;E++)F=u[E-2],ee=(F>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,F=u[E-15],ht=(F>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,u[E]=(ee+u[E-7]|0)+(ht+u[E-16]|0);for(E=0;E<64;E++)ee=(((Q>>>6|Q<<26)^(Q>>>11|Q<<21)^(Q>>>25|Q<<7))+(Q&k^~Q&B)|0)+(_+(t[E]+u[E]|0)|0)|0,ht=((K>>>2|K<<30)^(K>>>13|K<<19)^(K>>>22|K<<10))+(K&v^K&S^v&S)|0,_=B,B=k,k=Q,Q=w+ee|0,w=S,S=v,v=K,K=ee+ht|0;f[0]+=K,f[1]+=v,f[2]+=S,f[3]+=w,f[4]+=Q,f[5]+=k,f[6]+=B,f[7]+=_,h+=64,A-=64}return h}var i=(function(){function u(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return u.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},u.prototype.clean=function(){for(var f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},u.prototype.update=function(f,b){if(b===void 0&&(b=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var h=0;if(this.bytesHashed+=b,this.bufferLength>0){for(;this.bufferLength<64&&b>0;)this.buffer[this.bufferLength++]=f[h++],b--;this.bufferLength===64&&(o(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(b>=64&&(h=o(this.temp,this.state,f,h,b),b%=64);b>0;)this.buffer[this.bufferLength++]=f[h++],b--;return this},u.prototype.finish=function(f){if(!this.finished){var b=this.bytesHashed,h=this.bufferLength,A=b/536870912|0,K=b<<3,v=b%64<56?64:128;this.buffer[h]=128;for(var S=h+1;S<v-8;S++)this.buffer[S]=0;this.buffer[v-8]=A>>>24&255,this.buffer[v-7]=A>>>16&255,this.buffer[v-6]=A>>>8&255,this.buffer[v-5]=A>>>0&255,this.buffer[v-4]=K>>>24&255,this.buffer[v-3]=K>>>16&255,this.buffer[v-2]=K>>>8&255,this.buffer[v-1]=K>>>0&255,o(this.temp,this.state,this.buffer,0,v),this.finished=!0}for(var S=0;S<8;S++)f[S*4+0]=this.state[S]>>>24&255,f[S*4+1]=this.state[S]>>>16&255,f[S*4+2]=this.state[S]>>>8&255,f[S*4+3]=this.state[S]>>>0&255;return this},u.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},u.prototype._saveState=function(f){for(var b=0;b<this.state.length;b++)f[b]=this.state[b]},u.prototype._restoreState=function(f,b){for(var h=0;h<this.state.length;h++)this.state[h]=f[h];this.bytesHashed=b,this.finished=!1,this.bufferLength=0},u})();e.Hash=i;var r=(function(){function u(f){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var b=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(b).clean();else for(var h=0;h<f.length;h++)b[h]=f[h];for(var h=0;h<b.length;h++)b[h]^=54;this.inner.update(b);for(var h=0;h<b.length;h++)b[h]^=106;this.outer.update(b),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var h=0;h<b.length;h++)b[h]=0}return u.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},u.prototype.clean=function(){for(var f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},u.prototype.update=function(f){return this.inner.update(f),this},u.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},u.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},u})();e.HMAC=r;function n(u){var f=new i().update(u),b=f.digest();return f.clean(),b}e.hash=n,e.default=n;function s(u,f){var b=new r(u).update(f),h=b.digest();return b.clean(),h}e.hmac=s;function a(u,f,b,h){var A=h[0];if(A===0)throw new Error("hkdf: cannot expand more");f.reset(),A>1&&f.update(u),b&&f.update(b),f.update(h),f.finish(u),h[0]++}var l=new Uint8Array(e.digestLength);function d(u,f,b,h){f===void 0&&(f=l),h===void 0&&(h=32);for(var A=new Uint8Array([1]),K=s(f,u),v=new r(K),S=new Uint8Array(v.digestLength),w=S.length,Q=new Uint8Array(h),k=0;k<h;k++)w===S.length&&(a(S,v,b,A),w=0),Q[k]=S[w++];return v.clean(),S.fill(0),A.fill(0),Q}e.hkdf=d;function c(u,f,b,h){for(var A=new r(u),K=A.digestLength,v=new Uint8Array(4),S=new Uint8Array(K),w=new Uint8Array(K),Q=new Uint8Array(h),k=0;k*K<h;k++){var B=k+1;v[0]=B>>>24&255,v[1]=B>>>16&255,v[2]=B>>>8&255,v[3]=B>>>0&255,A.reset(),A.update(f),A.update(v),A.finish(w);for(var _=0;_<K;_++)S[_]=w[_];for(var _=2;_<=b;_++){A.reset(),A.update(w).finish(w);for(var F=0;F<K;F++)S[F]^=w[F]}for(var _=0;_<K&&k*K+_<h;_++)Q[k*K+_]=S[_]}for(var k=0;k<K;k++)S[k]=w[k]=0;for(var k=0;k<4;k++)v[k]=0;return A.clean(),Q}e.pbkdf2=c})});var Jn=we(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.Webhook=Ft.WebhookVerificationError=void 0;var ip=Hn(),Ln=Nn(),rp=Mn(),Wn=300,Zi=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},at=class e extends Zi{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};Ft.WebhookVerificationError=at;var Oo=class e{constructor(t,o){if(!t)throw new Error("Secret can't be empty.");if(o?.format==="raw")t instanceof Uint8Array?this.key=t:this.key=Uint8Array.from(t,i=>i.charCodeAt(0));else{if(typeof t!="string")throw new Error("Expected secret to be of type string");t.startsWith(e.prefix)&&(t=t.substring(e.prefix.length)),this.key=Ln.decode(t)}}verify(t,o){let i={};for(let f of Object.keys(o))i[f.toLowerCase()]=o[f];let r=i["webhook-id"],n=i["webhook-signature"],s=i["webhook-timestamp"];if(!n||!r||!s)throw new at("Missing required headers");let a=this.verifyTimestamp(s),d=this.sign(r,a,t).split(",")[1],c=n.split(" "),u=new globalThis.TextEncoder;for(let f of c){let[b,h]=f.split(",");if(b==="v1"&&(0,ip.timingSafeEqual)(u.encode(h),u.encode(d)))return JSON.parse(t.toString())}throw new at("No matching signature found")}sign(t,o,i){if(typeof i!="string")if(i.constructor.name==="Buffer")i=i.toString();else throw new Error("Expected payload to be of type string or Buffer.");let r=new TextEncoder,n=Math.floor(o.getTime()/1e3),s=r.encode(`${t}.${n}.${i}`);return`v1,${Ln.encode(rp.hmac(this.key,s))}`}verifyTimestamp(t){let o=Math.floor(Date.now()/1e3),i=parseInt(t,10);if(isNaN(i))throw new at("Invalid Signature Headers");if(o-i>Wn)throw new at("Message timestamp too old");if(i>o+Wn)throw new at("Message timestamp too new");return new Date(i*1e3)}};Ft.Webhook=Oo;Oo.prefix="whsec_"});var To,ns=me(()=>{"use strict";To=class extends Error{constructor(t){super(`Credentials file is corrupted or contains invalid JSON: ${t}
|
|
27
|
+
`)}),this}_outputHelpIfRequested(t){let o=this._getHelpOption();o&&t.find(r=>o.is(r))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function Hr(e){return e.map(t=>{if(!t.startsWith("--inspect"))return t;let o,i="127.0.0.1",r="9229",n;return(n=t.match(/^(--inspect(-brk)?)$/))!==null?o=n[1]:(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(o=n[1],/^\d+$/.test(n[3])?r=n[3]:i=n[3]):(n=t.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(o=n[1],i=n[3],r=n[4]),o&&r!=="0"?`${o}=${i}:${parseInt(r)+1}`:t})}function Ri(){if(L.env.NO_COLOR||L.env.FORCE_COLOR==="0"||L.env.FORCE_COLOR==="false")return!1;if(L.env.FORCE_COLOR||L.env.CLICOLOR_FORCE!==void 0)return!0}Di.Command=ki;Di.useColor=Ri});var Mr=we(Te=>{var{Argument:Gr}=ho(),{Command:_i}=Qr(),{CommanderError:Zu,InvalidArgumentError:Nr}=Wt(),{Help:ed}=Ui(),{Option:qr}=wi();Te.program=new _i;Te.createCommand=e=>new _i(e);Te.createOption=(e,t)=>new qr(e,t);Te.createArgument=(e,t)=>new Gr(e,t);Te.Command=_i;Te.Option=qr;Te.Argument=Gr;Te.Help=ed;Te.CommanderError=Zu;Te.InvalidArgumentError=Nr;Te.InvalidOptionArgumentError=Nr});var Wr=we((De,Lr)=>{var He=Mr();De=Lr.exports={};De.program=new He.Command;De.Argument=He.Argument;De.Command=He.Command;De.CommanderError=He.CommanderError;De.Help=He.Help;De.InvalidArgumentError=He.InvalidArgumentError;De.InvalidOptionArgumentError=He.InvalidArgumentError;De.Option=He.Option;De.createCommand=e=>new He.Command(e);De.createOption=(e,t)=>new He.Option(e,t);De.createArgument=(e,t)=>new He.Argument(e,t)});var ot=we((Rf,Bi)=>{var Co=process||{},zr=Co.argv||[],bo=Co.env||{},td=!(bo.NO_COLOR||zr.includes("--no-color"))&&(!!bo.FORCE_COLOR||zr.includes("--color")||Co.platform==="win32"||(Co.stdout||{}).isTTY&&bo.TERM!=="dumb"||!!bo.CI),od=(e,t,o=e)=>i=>{let r=""+i,n=r.indexOf(t,e.length);return~n?e+id(r,t,o,n)+t:e+r+t},id=(e,t,o,i)=>{let r="",n=0;do r+=e.substring(n,i)+o,n=i+t.length,i=e.indexOf(t,n);while(~i);return r+e.substring(n)},Yr=(e=td)=>{let t=e?od:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};Bi.exports=Yr();Bi.exports.createColors=Yr});var Ii=we((Pf,mn)=>{"use strict";var ji={to(e,t){return t?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`},move(e,t){let o="";return e<0?o+=`\x1B[${-e}D`:e>0&&(o+=`\x1B[${e}C`),t<0?o+=`\x1B[${-t}A`:t>0&&(o+=`\x1B[${t}B`),o},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},yd={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Ud={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let t="";for(let o=0;o<e;o++)t+=this.line+(o<e-1?ji.up():"");return e&&(t+=ji.left),t}};mn.exports={cursor:ji,scroll:yd,erase:Ud,beep:"\x07"}});var Ni,kn=me(()=>{Ni={name:"resend-cli",version:"2.8.1",description:"The official CLI for Resend",license:"MIT",repository:{type:"git",url:"https://github.com/resend/resend-cli"},homepage:"https://github.com/resend/resend-cli#readme",keywords:["cli","resend","email","api","tanstack-intent"],engines:{node:">=22"},packageManager:"pnpm@11.8.0",files:["dist/cli.cjs","skills/"],type:"module",bin:{resend:"./dist/cli.cjs"},scripts:{dev:"tsx src/cli.ts","dev:watch":"tsx --watch src/cli.ts",build:"node scripts/build.mjs","build:bin":"pnpm build && pkg dist/cli.cjs --config package.json --compress Brotli --target node24 --output dist/resend",lint:"biome check .","lint:fix":"biome check --write .",typecheck:"tsc --noEmit",test:"vitest run","test:e2e":"vitest run --config vitest.config.e2e.ts",prepack:"pnpm install && pnpm build && node scripts/verify-bundle.mjs"},dependencies:{"@clack/prompts":"1.4.0","@commander-js/extra-typings":"14.0.0",commander:"14.0.3",esbuild:"0.28.1","esbuild-wasm":"0.28.0",picocolors:"1.1.1",resend:"6.17.1"},pkg:{scripts:["node_modules/esbuild-wasm/bin/esbuild","node_modules/esbuild-wasm/wasm_exec.js","node_modules/esbuild-wasm/wasm_exec_node.js"],assets:["node_modules/esbuild-wasm/esbuild.wasm"]},devDependencies:{"@biomejs/biome":"2.4.11","@types/node":"24.12.4","@yao-pkg/pkg":"6.20.0",tsx:"4.22.4",typescript:"5.9.3",vitest:"4.1.9"}}});var te,Rn,bt=me(()=>{"use strict";kn();te=Ni.version,Rn=Ni.name});var Hn=we(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.timingSafeEqual=void 0;function $n(e,t=""){if(!e)throw new Error(t)}function Yd(e,t){if(e.byteLength!==t.byteLength)return!1;e instanceof DataView||(e=new DataView(ArrayBuffer.isView(e)?e.buffer:e)),t instanceof DataView||(t=new DataView(ArrayBuffer.isView(t)?t.buffer:t)),$n(e instanceof DataView),$n(t instanceof DataView);let o=e.byteLength,i=0,r=-1;for(;++r<o;)i|=e.getUint8(r)^t.getUint8(r);return i===0}Bo.timingSafeEqual=Yd});var Nn=we(Be=>{"use strict";var Xd=Be&&Be.__extends||(function(){var e=function(t,o){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var n in r)r.hasOwnProperty(n)&&(i[n]=r[n])},e(t,o)};return function(t,o){e(t,o);function i(){this.constructor=t}t.prototype=o===null?Object.create(o):(i.prototype=o.prototype,new i)}})();Object.defineProperty(Be,"__esModule",{value:!0});var ne=256,Xi=(function(){function e(t){t===void 0&&(t="="),this._paddingCharacter=t}return e.prototype.encodedLength=function(t){return this._paddingCharacter?(t+2)/3*4|0:(t*8+5)/6|0},e.prototype.encode=function(t){for(var o="",i=0;i<t.length-2;i+=3){var r=t[i]<<16|t[i+1]<<8|t[i+2];o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),o+=this._encodeByte(r>>>6&63),o+=this._encodeByte(r>>>0&63)}var n=t.length-i;if(n>0){var r=t[i]<<16|(n===2?t[i+1]<<8:0);o+=this._encodeByte(r>>>18&63),o+=this._encodeByte(r>>>12&63),n===2?o+=this._encodeByte(r>>>6&63):o+=this._paddingCharacter||"",o+=this._paddingCharacter||""}return o},e.prototype.maxDecodedLength=function(t){return this._paddingCharacter?t/4*3|0:(t*6+7)/8|0},e.prototype.decodedLength=function(t){return this.maxDecodedLength(t.length-this._getPaddingLength(t))},e.prototype.decode=function(t){if(t.length===0)return new Uint8Array(0);for(var o=this._getPaddingLength(t),i=t.length-o,r=new Uint8Array(this.maxDecodedLength(i)),n=0,s=0,a=0,l=0,d=0,c=0,u=0;s<i-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),d=this._decodeChar(t.charCodeAt(s+1)),c=this._decodeChar(t.charCodeAt(s+2)),u=this._decodeChar(t.charCodeAt(s+3)),r[n++]=l<<2|d>>>4,r[n++]=d<<4|c>>>2,r[n++]=c<<6|u,a|=l&ne,a|=d&ne,a|=c&ne,a|=u≠if(s<i-1&&(l=this._decodeChar(t.charCodeAt(s)),d=this._decodeChar(t.charCodeAt(s+1)),r[n++]=l<<2|d>>>4,a|=l&ne,a|=d&ne),s<i-2&&(c=this._decodeChar(t.charCodeAt(s+2)),r[n++]=d<<4|c>>>2,a|=c&ne),s<i-3&&(u=this._decodeChar(t.charCodeAt(s+3)),r[n++]=c<<6|u,a|=u&ne),a!==0)throw new Error("Base64Coder: incorrect characters for decoding");return r},e.prototype._encodeByte=function(t){var o=t;return o+=65,o+=25-t>>>8&6,o+=51-t>>>8&-75,o+=61-t>>>8&-15,o+=62-t>>>8&3,String.fromCharCode(o)},e.prototype._decodeChar=function(t){var o=ne;return o+=(42-t&t-44)>>>8&-ne+t-43+62,o+=(46-t&t-48)>>>8&-ne+t-47+63,o+=(47-t&t-58)>>>8&-ne+t-48+52,o+=(64-t&t-91)>>>8&-ne+t-65+0,o+=(96-t&t-123)>>>8&-ne+t-97+26,o},e.prototype._getPaddingLength=function(t){var o=0;if(this._paddingCharacter){for(var i=t.length-1;i>=0&&t[i]===this._paddingCharacter;i--)o++;if(t.length<4||o>2)throw new Error("Base64Coder: incorrect padding")}return o},e})();Be.Coder=Xi;var io=new Xi;function Zd(e){return io.encode(e)}Be.encode=Zd;function ep(e){return io.decode(e)}Be.decode=ep;var Qn=(function(e){Xd(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype._encodeByte=function(o){var i=o;return i+=65,i+=25-o>>>8&6,i+=51-o>>>8&-75,i+=61-o>>>8&-13,i+=62-o>>>8&49,String.fromCharCode(i)},t.prototype._decodeChar=function(o){var i=ne;return i+=(44-o&o-46)>>>8&-ne+o-45+62,i+=(94-o&o-96)>>>8&-ne+o-95+63,i+=(47-o&o-58)>>>8&-ne+o-48+52,i+=(64-o&o-91)>>>8&-ne+o-65+0,i+=(96-o&o-123)>>>8&-ne+o-97+26,i},t})(Xi);Be.URLSafeCoder=Qn;var Gn=new Qn;function tp(e){return Gn.encode(e)}Be.encodeURLSafe=tp;function op(e){return Gn.decode(e)}Be.decodeURLSafe=op;Be.encodedLength=function(e){return io.encodedLength(e)};Be.maxDecodedLength=function(e){return io.maxDecodedLength(e)};Be.decodedLength=function(e){return io.decodedLength(e)}});var Mn=we((qn,Eo)=>{(function(e,t){var o={};t(o);var i=o.default;for(var r in o)i[r]=o[r];typeof Eo=="object"&&typeof Eo.exports=="object"?Eo.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):e.sha256=i})(qn,function(e){"use strict";e.__esModule=!0,e.digestLength=32,e.blockSize=64;var t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function o(u,f,b,h,A){for(var K,v,S,w,Q,k,B,_,F,E,be,ee,ht;A>=64;){for(K=f[0],v=f[1],S=f[2],w=f[3],Q=f[4],k=f[5],B=f[6],_=f[7],E=0;E<16;E++)be=h+E*4,u[E]=(b[be]&255)<<24|(b[be+1]&255)<<16|(b[be+2]&255)<<8|b[be+3]&255;for(E=16;E<64;E++)F=u[E-2],ee=(F>>>17|F<<15)^(F>>>19|F<<13)^F>>>10,F=u[E-15],ht=(F>>>7|F<<25)^(F>>>18|F<<14)^F>>>3,u[E]=(ee+u[E-7]|0)+(ht+u[E-16]|0);for(E=0;E<64;E++)ee=(((Q>>>6|Q<<26)^(Q>>>11|Q<<21)^(Q>>>25|Q<<7))+(Q&k^~Q&B)|0)+(_+(t[E]+u[E]|0)|0)|0,ht=((K>>>2|K<<30)^(K>>>13|K<<19)^(K>>>22|K<<10))+(K&v^K&S^v&S)|0,_=B,B=k,k=Q,Q=w+ee|0,w=S,S=v,v=K,K=ee+ht|0;f[0]+=K,f[1]+=v,f[2]+=S,f[3]+=w,f[4]+=Q,f[5]+=k,f[6]+=B,f[7]+=_,h+=64,A-=64}return h}var i=(function(){function u(){this.digestLength=e.digestLength,this.blockSize=e.blockSize,this.state=new Int32Array(8),this.temp=new Int32Array(64),this.buffer=new Uint8Array(128),this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this.reset()}return u.prototype.reset=function(){return this.state[0]=1779033703,this.state[1]=3144134277,this.state[2]=1013904242,this.state[3]=2773480762,this.state[4]=1359893119,this.state[5]=2600822924,this.state[6]=528734635,this.state[7]=1541459225,this.bufferLength=0,this.bytesHashed=0,this.finished=!1,this},u.prototype.clean=function(){for(var f=0;f<this.buffer.length;f++)this.buffer[f]=0;for(var f=0;f<this.temp.length;f++)this.temp[f]=0;this.reset()},u.prototype.update=function(f,b){if(b===void 0&&(b=f.length),this.finished)throw new Error("SHA256: can't update because hash was finished.");var h=0;if(this.bytesHashed+=b,this.bufferLength>0){for(;this.bufferLength<64&&b>0;)this.buffer[this.bufferLength++]=f[h++],b--;this.bufferLength===64&&(o(this.temp,this.state,this.buffer,0,64),this.bufferLength=0)}for(b>=64&&(h=o(this.temp,this.state,f,h,b),b%=64);b>0;)this.buffer[this.bufferLength++]=f[h++],b--;return this},u.prototype.finish=function(f){if(!this.finished){var b=this.bytesHashed,h=this.bufferLength,A=b/536870912|0,K=b<<3,v=b%64<56?64:128;this.buffer[h]=128;for(var S=h+1;S<v-8;S++)this.buffer[S]=0;this.buffer[v-8]=A>>>24&255,this.buffer[v-7]=A>>>16&255,this.buffer[v-6]=A>>>8&255,this.buffer[v-5]=A>>>0&255,this.buffer[v-4]=K>>>24&255,this.buffer[v-3]=K>>>16&255,this.buffer[v-2]=K>>>8&255,this.buffer[v-1]=K>>>0&255,o(this.temp,this.state,this.buffer,0,v),this.finished=!0}for(var S=0;S<8;S++)f[S*4+0]=this.state[S]>>>24&255,f[S*4+1]=this.state[S]>>>16&255,f[S*4+2]=this.state[S]>>>8&255,f[S*4+3]=this.state[S]>>>0&255;return this},u.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},u.prototype._saveState=function(f){for(var b=0;b<this.state.length;b++)f[b]=this.state[b]},u.prototype._restoreState=function(f,b){for(var h=0;h<this.state.length;h++)this.state[h]=f[h];this.bytesHashed=b,this.finished=!1,this.bufferLength=0},u})();e.Hash=i;var r=(function(){function u(f){this.inner=new i,this.outer=new i,this.blockSize=this.inner.blockSize,this.digestLength=this.inner.digestLength;var b=new Uint8Array(this.blockSize);if(f.length>this.blockSize)new i().update(f).finish(b).clean();else for(var h=0;h<f.length;h++)b[h]=f[h];for(var h=0;h<b.length;h++)b[h]^=54;this.inner.update(b);for(var h=0;h<b.length;h++)b[h]^=106;this.outer.update(b),this.istate=new Uint32Array(8),this.ostate=new Uint32Array(8),this.inner._saveState(this.istate),this.outer._saveState(this.ostate);for(var h=0;h<b.length;h++)b[h]=0}return u.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},u.prototype.clean=function(){for(var f=0;f<this.istate.length;f++)this.ostate[f]=this.istate[f]=0;this.inner.clean(),this.outer.clean()},u.prototype.update=function(f){return this.inner.update(f),this},u.prototype.finish=function(f){return this.outer.finished?this.outer.finish(f):(this.inner.finish(f),this.outer.update(f,this.digestLength).finish(f)),this},u.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},u})();e.HMAC=r;function n(u){var f=new i().update(u),b=f.digest();return f.clean(),b}e.hash=n,e.default=n;function s(u,f){var b=new r(u).update(f),h=b.digest();return b.clean(),h}e.hmac=s;function a(u,f,b,h){var A=h[0];if(A===0)throw new Error("hkdf: cannot expand more");f.reset(),A>1&&f.update(u),b&&f.update(b),f.update(h),f.finish(u),h[0]++}var l=new Uint8Array(e.digestLength);function d(u,f,b,h){f===void 0&&(f=l),h===void 0&&(h=32);for(var A=new Uint8Array([1]),K=s(f,u),v=new r(K),S=new Uint8Array(v.digestLength),w=S.length,Q=new Uint8Array(h),k=0;k<h;k++)w===S.length&&(a(S,v,b,A),w=0),Q[k]=S[w++];return v.clean(),S.fill(0),A.fill(0),Q}e.hkdf=d;function c(u,f,b,h){for(var A=new r(u),K=A.digestLength,v=new Uint8Array(4),S=new Uint8Array(K),w=new Uint8Array(K),Q=new Uint8Array(h),k=0;k*K<h;k++){var B=k+1;v[0]=B>>>24&255,v[1]=B>>>16&255,v[2]=B>>>8&255,v[3]=B>>>0&255,A.reset(),A.update(f),A.update(v),A.finish(w);for(var _=0;_<K;_++)S[_]=w[_];for(var _=2;_<=b;_++){A.reset(),A.update(w).finish(w);for(var F=0;F<K;F++)S[F]^=w[F]}for(var _=0;_<K&&k*K+_<h;_++)Q[k*K+_]=S[_]}for(var k=0;k<K;k++)S[k]=w[k]=0;for(var k=0;k<4;k++)v[k]=0;return A.clean(),Q}e.pbkdf2=c})});var Jn=we(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.Webhook=Ft.WebhookVerificationError=void 0;var ip=Hn(),Ln=Nn(),rp=Mn(),Wn=300,Zi=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},at=class e extends Zi{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};Ft.WebhookVerificationError=at;var Oo=class e{constructor(t,o){if(!t)throw new Error("Secret can't be empty.");if(o?.format==="raw")t instanceof Uint8Array?this.key=t:this.key=Uint8Array.from(t,i=>i.charCodeAt(0));else{if(typeof t!="string")throw new Error("Expected secret to be of type string");t.startsWith(e.prefix)&&(t=t.substring(e.prefix.length)),this.key=Ln.decode(t)}}verify(t,o){let i={};for(let f of Object.keys(o))i[f.toLowerCase()]=o[f];let r=i["webhook-id"],n=i["webhook-signature"],s=i["webhook-timestamp"];if(!n||!r||!s)throw new at("Missing required headers");let a=this.verifyTimestamp(s),d=this.sign(r,a,t).split(",")[1],c=n.split(" "),u=new globalThis.TextEncoder;for(let f of c){let[b,h]=f.split(",");if(b==="v1"&&(0,ip.timingSafeEqual)(u.encode(h),u.encode(d)))return JSON.parse(t.toString())}throw new at("No matching signature found")}sign(t,o,i){if(typeof i!="string")if(i.constructor.name==="Buffer")i=i.toString();else throw new Error("Expected payload to be of type string or Buffer.");let r=new TextEncoder,n=Math.floor(o.getTime()/1e3),s=r.encode(`${t}.${n}.${i}`);return`v1,${Ln.encode(rp.hmac(this.key,s))}`}verifyTimestamp(t){let o=Math.floor(Date.now()/1e3),i=parseInt(t,10);if(isNaN(i))throw new at("Invalid Signature Headers");if(o-i>Wn)throw new at("Message timestamp too old");if(i>o+Wn)throw new at("Message timestamp too new");return new Date(i*1e3)}};Ft.Webhook=Oo;Oo.prefix="whsec_"});var To,ns=me(()=>{"use strict";To=class extends Error{constructor(t){super(`Credentials file is corrupted or contains invalid JSON: ${t}
|
|
28
28
|
The file has been preserved for manual inspection.
|
|
29
29
|
To fix: either repair the JSON manually, or delete the file and run: resend login`),this.name="CorruptedCredentialsError"}}});var tr={};Lt(tr,{FileBackend:()=>er});var er,or=me(()=>{"use strict";ge();er=class{name="plaintext file";isSecure=!1;async get(t,o){let i=ye();if(!i)return null;let r=i.profiles[o];return(r?.type==="api_key"?r.api_key:null)??null}async set(t,o,i){ir(i,o)}async delete(t,o){try{return ss(o),!0}catch{return!1}}async isAvailable(){return!0}}});var ls={};Lt(ls,{MacOSBackend:()=>nr});function rr(e,t){return new Promise(o=>{(0,as.execFile)(e,t,{timeout:5e3},(i,r,n)=>{let s=i&&"code"in i?i.code:0;o({stdout:r??"",stderr:n??"",code:s})})})}var as,nr,cs=me(()=>{"use strict";as=require("node:child_process");nr=class{name="macOS Keychain";isSecure=!0;async get(t,o){let{stdout:i,stderr:r,code:n}=await rr("/usr/bin/security",["find-generic-password","-s",t,"-a",o,"-w"]);if(n===44)return null;if(n!==0)throw new Error(`Failed to read from macOS Keychain (exit code ${n}): ${r.trim()}`);return i.trim()||null}async set(t,o,i){let{code:r,stderr:n}=await rr("/usr/bin/security",["add-generic-password","-s",t,"-a",o,"-w",i,"-U"]);if(r!==0)throw new Error(`Failed to store credential in macOS Keychain: ${n.trim()}`)}async delete(t,o){let{code:i}=await rr("/usr/bin/security",["delete-generic-password","-s",t,"-a",o]);return i===0}async isAvailable(){return process.platform==="darwin"}}});var us={};Lt(us,{LinuxBackend:()=>sr});function jo(e,t,o){return new Promise(i=>{(0,Io.execFile)(e,t,{timeout:o?.timeout??5e3},(r,n,s)=>{let a=r&&"code"in r?r.code:0;i({stdout:n??"",stderr:s??"",code:a})})})}function Ip(e,t,o){return new Promise(i=>{let r=(0,Io.spawn)(e,t,{stdio:["pipe","ignore","pipe"],timeout:5e3}),n="";r.stderr?.on("data",s=>{n+=s.toString()}),r.on("close",s=>{i({code:s,stderr:n})}),r.on("error",()=>{i({code:1,stderr:"Failed to spawn process"})}),r.stdin?.on("error",()=>{}),r.stdin?.write(o),r.stdin?.end()})}var Io,sr,ds=me(()=>{"use strict";Io=require("node:child_process");sr=class{name="Secret Service (libsecret)";isSecure=!0;async get(t,o){let{stdout:i,code:r}=await jo("secret-tool",["lookup","service",t,"account",o]);return r!==0||!i.trim()?null:i.trim()}async set(t,o,i){let{code:r,stderr:n}=await Ip("secret-tool",["store",`--label=Resend CLI (${o})`,"service",t,"account",o],i);if(r!==0)throw new Error(`Failed to store credential in Secret Service: ${n.trim()}`)}async delete(t,o){let{code:i}=await jo("secret-tool",["clear","service",t,"account",o]);return i===0}async isAvailable(){if(process.platform!=="linux"||(await jo("which",["secret-tool"])).code!==0)return!1;let o=await jo("secret-tool",["lookup","service","__resend_cli_probe__"],{timeout:3e3});return o.code===0||o.code===1}}});var ps={};Lt(ps,{WindowsBackend:()=>ar});function Po(e){return new Promise(t=>{(0,$o.execFile)("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{timeout:1e4},(o,i,r)=>{let n=o&&"code"in o?o.code:0;t({stdout:i??"",stderr:r??"",code:n})})})}function Pp(e,t){return new Promise(o=>{let i=(0,$o.spawn)("powershell.exe",["-NoProfile","-NonInteractive","-Command",e],{stdio:["pipe","pipe","pipe"],timeout:1e4}),r="",n="";i.stdout?.on("data",s=>{r+=s.toString()}),i.stderr?.on("data",s=>{n+=s.toString()}),i.on("close",s=>{o({stdout:r,stderr:n,code:s})}),i.on("error",()=>{o({stdout:"",stderr:"Failed to spawn process",code:1})}),i.stdin?.on("error",()=>{}),i.stdin?.write(t),i.stdin?.end()})}function lt(e){return e.replace(/'/g,"''")}var $o,no,ar,ms=me(()=>{"use strict";$o=require("node:child_process");no=`
|
|
30
30
|
try { $null = [Windows.Security.Credentials.PasswordVault] } catch {
|
|
@@ -265,7 +265,7 @@ ${r}
|
|
|
265
265
|
`&&(t=" "),(t.charCodeAt(0)>=33||[" "," "].includes(t))&&(this.node.value+=t),this.escaped=!1}},Jd=50;function zi(e,t){t=t||{};let o=t._depth||0;if(o>Jd)return[];let r=new Vi(e).tokenize(),n=[],s=[],a=[];if(r.forEach(l=>{l.type==="operator"&&(l.value===","||l.value===";")?(s.length&&n.push(s),s=[]):s.push(l)}),s.length&&n.push(s),n.forEach(l=>{l=Wd(l,o),l.length&&(a=a.concat(l))}),t.flatten){let l=[],d=c=>{c.forEach(u=>{if(u.group)return d(u.group);l.push(u)})};return d(a),l}return a}var _o=zi;function Pn(e){for(var t="",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(e),r=i.byteLength,n=r%3,s=r-n,a,l,d,c,u,f=0;f<s;f=f+3)u=i[f]<<16|i[f+1]<<8|i[f+2],a=(u&16515072)>>18,l=(u&258048)>>12,d=(u&4032)>>6,c=u&63,t+=o[a]+o[l]+o[d]+o[c];return n==1?(u=i[s],a=(u&252)>>2,l=(u&3)<<4,t+=o[a]+o[l]+"=="):n==2&&(u=i[s]<<8|i[s+1],a=(u&64512)>>10,l=(u&1008)>>4,d=(u&15)<<2,t+=o[a]+o[l]+o[d]+"="),t}var Vd=256,zd=2*1024*1024;function Yi(e){return e.replace(/-(.)/g,(t,o)=>o.toUpperCase())}var oo=class e{static parse(t,o){return new e(o).parse(t)}constructor(t){this.options=t||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||Vd,maxHeadersSize:this.options.maxHeadersSize||zd},this.root=this.currentNode=new xt({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(t,o){let i=this.boundaries;if(i.length&&t.length>2&&t[0]===45&&t[1]===45)for(let r=i.length-1;r>=0;r--){let n=i[r];if(t.length<n.value.length+2)continue;let s=!0;for(let c=0;c<n.value.length;c++)if(t[c+2]!==n.value[c]){s=!1;break}if(!s)continue;let a=n.value.length+2,l=!1;t.length>=n.value.length+4&&t[n.value.length+2]===45&&t[n.value.length+3]===45&&(l=!0,a=n.value.length+4);let d=!0;for(let c=a;c<t.length;c++)if(t[c]!==32&&t[c]!==9){d=!1;break}if(d)return l?(await n.node.finalize(),this.currentNode=n.node.parentNode||this.root):(await n.node.finalizeChildNodes(),this.currentNode=new xt({postalMime:this,parentNode:n.node,parentMultipartType:n.node.contentType.multipart,...this.mimeOptions})),o?this.finalize():void 0}if(this.currentNode.feed(t),o)return this.finalize()}readLine(){let t=this.readPos,o=this.readPos;for(;this.readPos<this.av.length;){let i=this.av[this.readPos++];if(i!==13&&i!==10&&(o=this.readPos),i===10)return{bytes:new Uint8Array(this.buf,t,o-t),done:this.readPos>=this.av.length}}return{bytes:new Uint8Array(this.buf,t,o-t),done:this.readPos>=this.av.length}}async processNodeTree(){let t={},o=new Set,i=this.textMap=new Map,r=this.forceRfc822Attachments(),n=async(s,a,l)=>{if(a=a||!1,l=l||!1,s.contentType.multipart)s.contentType.multipart==="alternative"?a=s:s.contentType.multipart==="related"&&(l=s);else if(this.isInlineMessageRfc822(s)&&!r){let d=new e;s.subMessage=await d.parse(s.content),i.has(s)||i.set(s,{});let c=i.get(s);(s.subMessage.text||!s.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:s.subMessage}),o.add("plain")),s.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:s.subMessage}),o.add("html")),d.textMap&&d.textMap.forEach((u,f)=>{i.set(f,u)});for(let u of s.subMessage.attachments||[])this.attachments.push(u)}else if(this.isInlineTextNode(s)){let d=s.contentType.parsed.value.substr(s.contentType.parsed.value.indexOf("/")+1),c=a||s;i.has(c)||i.set(c,{});let u=i.get(c);u[d]=u[d]||[],u[d].push({type:"text",value:s.getTextContent()}),o.add(d)}else if(s.content){let d=s.contentDisposition?.parsed?.params?.filename||s.contentType.parsed.params.name||null,c={filename:d?Ct(d):null,mimeType:s.contentType.parsed.value,disposition:s.contentDisposition?.parsed?.value||null};switch(l&&s.contentId&&(c.related=!0),s.contentDescription&&(c.description=s.contentDescription),s.contentId&&(c.contentId=s.contentId),s.contentType.parsed.value){case"text/calendar":case"application/ics":{s.contentType.parsed.params.method&&(c.method=s.contentType.parsed.params.method.toString().toUpperCase().trim());let u=s.getTextContent().replace(/\r?\n/g,`
|
|
266
266
|
`).replace(/\n*$/,`
|
|
267
267
|
`);c.content=nt.encode(u);break}default:c.content=s.content}this.attachments.push(c)}for(let d of s.childNodes)await n(d,a,l)};await n(this.root,!1,!1),i.forEach(s=>{o.forEach(a=>{if(t[a]||(t[a]=[]),s[a])s[a].forEach(l=>{switch(l.type){case"text":t[a].push(l.value);break;case"subMessage":switch(a){case"html":t[a].push(Ji(l.value));break;case"plain":t[a].push(Wi(l.value));break}break}});else{let l;switch(a){case"html":l="plain";break;case"plain":l="html";break}(s[l]||[]).forEach(d=>{switch(d.type){case"text":switch(a){case"html":t[a].push(On(d.value));break;case"plain":t[a].push(Tn(d.value));break}break;case"subMessage":switch(a){case"html":t[a].push(Ji(d.value));break;case"plain":t[a].push(Wi(d.value));break}break}})}})}),Object.keys(t).forEach(s=>{t[s]=t[s].join(`
|
|
268
|
-
`)}),this.textContent=t}isInlineTextNode(t){if(t.contentDisposition?.parsed?.value==="attachment")return!1;switch(t.contentType.parsed?.value){case"text/html":case"text/plain":return!0;default:return!1}}isInlineMessageRfc822(t){return t.contentType.parsed?.value!=="message/rfc822"?!1:(t.contentDisposition?.parsed?.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let t=!1,o=i=>{i.contentType.multipart||i.contentType.parsed&&["message/delivery-status","message/feedback-report"].includes(i.contentType.parsed.value)&&(t=!0);for(let r of i.childNodes)o(r)};return o(this.root),t}async resolveStream(t){let o=0,i=[],r=t.getReader();for(;;){let{done:a,value:l}=await r.read();if(a)break;i.push(l),o+=l.length}let n=new Uint8Array(o),s=0;for(let a of i)n.set(a,s),s+=a.length;return n}async parse(t){if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,t&&typeof t.getReader=="function"&&(t=await this.resolveStream(t)),t=t||new ArrayBuffer(0),typeof t=="string"&&(t=nt.encode(t)),(t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]")&&(t=await st(t)),t.buffer instanceof ArrayBuffer&&(t=new Uint8Array(t).buffer),this.buf=t,this.av=new Uint8Array(t),this.readPos=0;this.readPos<this.av.length;){let r=this.readLine();await this.processLine(r.bytes,r.done)}await this.processNodeTree();let o={headers:this.root.headers.map(r=>({key:r.key,originalKey:r.originalKey,value:r.value})).reverse()};for(let r of["from","sender"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=_o(n.value);s&&s.length&&(o[r]=s[0])}}for(let r of["delivered-to","return-path"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=_o(n.value);if(s&&s.length&&s[0].address){let a=Yi(r);o[a]=s[0].address}}}for(let r of["to","cc","bcc","reply-to"]){let n=this.root.headers.filter(a=>a.key===r),s=[];if(n.filter(a=>a&&a.value).map(a=>_o(a.value)).forEach(a=>s=s.concat(a||[])),s&&s.length){let a=Yi(r);o[a]=s}}for(let r of["subject","message-id","in-reply-to","references"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=Yi(r);o[s]=Ct(n.value)}}let i=this.root.headers.find(r=>r.key==="date");if(i){let r=new Date(i.value);r.toString()==="Invalid Date"?r=i.value:r=r.toISOString(),o.date=r}switch(this.textContent?.html&&(o.html=this.textContent.html),this.textContent?.plain&&(o.text=this.textContent.plain),o.attachments=this.attachments,o.headerLines=(this.root.rawHeaderLines||[]).slice().reverse(),this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let n of o.attachments||[])n?.content&&(n.content=Pn(n.content),n.encoding="base64");break;case"utf8":let r=new TextDecoder("utf8");for(let n of o.attachments||[])n?.content&&(n.content=r.decode(n.content),n.encoding="utf8");break;default:throw new Error("Unknown attachment encoding")}return o}};var ts=fe(Jn(),1),np="6.17.0";function se(e){let t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",e.limit.toString()),"after"in e&&e.after!==void 0&&t.set("after",e.after),"before"in e&&e.before!==void 0&&t.set("before",e.before),t.toString()}var sp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/api-keys",e,t)}async list(e={}){let t=se(e),o=t?`/api-keys?${t}`:"/api-keys";return await this.resend.get(o)}async remove(e){return await this.resend.delete(`/api-keys/${e}`)}},ap=class{constructor(e){this.resend=e}async get(e){return await this.resend.get(`/automations/${e.automationId}/runs/${e.runId}`)}async list(e){let t=se(e),o=new URLSearchParams(t);if(e.status){let n=Array.isArray(e.status)?e.status.join(","):e.status;o.set("status",n)}let i=o.toString(),r=i?`/automations/${e.automationId}/runs?${i}`:`/automations/${e.automationId}/runs`;return await this.resend.get(r)}};function os(e){switch(e.type){case"trigger":return{key:e.key,type:e.type,config:{event_name:e.config.eventName}};case"delay":return{key:e.key,type:e.type,config:e.config};case"send_email":return{key:e.key,type:e.type,config:{template:e.config.template,subject:e.config.subject,from:e.config.from,reply_to:e.config.replyTo}};case"wait_for_event":return{key:e.key,type:e.type,config:{event_name:e.config.eventName,timeout:e.config.timeout,filter_rule:e.config.filterRule}};case"condition":return{key:e.key,type:e.type,config:e.config};case"contact_update":return{key:e.key,type:e.type,config:{first_name:e.config.firstName,last_name:e.config.lastName,unsubscribed:e.config.unsubscribed,properties:e.config.properties}};case"contact_delete":return{key:e.key,type:e.type,config:e.config};case"add_to_segment":return{key:e.key,type:e.type,config:{segment_id:e.config.segmentId}}}}function is(e){return{from:e.from,to:e.to,type:e.type}}function lp(e){return{name:e.name,status:e.status,steps:e.steps.map(os),connections:e.connections.map(is)}}function cp(e){return{event:e.event,contact_id:e.contactId,email:e.email,payload:e.payload}}var up=class{constructor(e){this.resend=e,this.runs=new ap(this.resend)}async create(e){return await this.resend.post("/automations",lp(e))}async list(e={}){let t=[se(e)];e.status&&t.push(`status=${encodeURIComponent(e.status)}`);let o=t.filter(Boolean).join("&"),i=o?`/automations?${o}`:"/automations";return await this.resend.get(i)}async get(e){return await this.resend.get(`/automations/${e}`)}async remove(e){return await this.resend.delete(`/automations/${e}`)}async update(e,t){let o={};return t.name!==void 0&&(o.name=t.name),t.status!==void 0&&(o.status=t.status),t.steps!==void 0&&(o.steps=t.steps.map(os)),t.connections!==void 0&&(o.connections=t.connections.map(is)),await this.resend.patch(`/automations/${e}`,o)}async stop(e){return await this.resend.post(`/automations/${e}/stop`)}};function dp(e){return e?.map(t=>({content:t.content,filename:t.filename,path:t.path,content_type:t.contentType,content_id:t.contentId}))}function rs(e){return{attachments:dp(e.attachments),bcc:e.bcc,cc:e.cc,from:e.from,headers:e.headers,html:e.html,reply_to:e.replyTo,scheduled_at:e.scheduledAt,subject:e.subject,tags:e.tags,text:e.text,to:e.to,template:e.template?{id:e.template.id,variables:e.template.variables}:void 0,topic_id:e.topicId}}async function ro(e){let t;try{({render:t}=await import("@react-email/render"))}catch{throw new Error("Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`.")}return t(e)}var pp=class{constructor(e){this.resend=e}async send(e,t){return this.create(e,t)}async create(e,t){let o=[];for(let i of e)i.react&&(i.html=await ro(i.react),i.react=void 0),o.push(rs(i));return await this.resend.post("/emails/batch",o,{...t,headers:{"x-batch-validation":t?.batchValidation??"strict",...t?.headers}})}},mp=class{constructor(e){this.resend=e}async create(e,t={}){let o=e.react?await ro(e.react):e.html;return await this.resend.post("/broadcasts",{name:e.name,segment_id:e.segmentId,audience_id:e.audienceId,preview_text:e.previewText,from:e.from,html:o,reply_to:e.replyTo,subject:e.subject,text:e.text,topic_id:e.topicId,send:e.send,scheduled_at:e.scheduledAt},t)}async send(e,t){return await this.resend.post(`/broadcasts/${e}/send`,{scheduled_at:t?.scheduledAt})}async list(e={}){let t=se(e),o=t?`/broadcasts?${t}`:"/broadcasts";return await this.resend.get(o)}async get(e){return await this.resend.get(`/broadcasts/${e}`)}async remove(e){return await this.resend.delete(`/broadcasts/${e}`)}async update(e,t){let o=t.react?await ro(t.react):t.html;return await this.resend.patch(`/broadcasts/${e}`,{name:t.name,segment_id:t.segmentId,audience_id:t.audienceId,from:t.from,html:o,text:t.text,subject:t.subject,reply_to:t.replyTo,preview_text:t.previewText,topic_id:t.topicId})}};function Vn(e){return{id:e.id,key:e.key,createdAt:e.created_at,type:e.type,fallbackValue:e.fallback_value}}function zn(e){return"key"in e?{key:e.key,type:e.type,fallback_value:e.fallbackValue}:{fallback_value:e.fallbackValue}}var fp=class{constructor(e){this.resend=e}async create(e){let t=zn(e);return await this.resend.post("/contact-properties",t)}async list(e={}){let t=se(e),o=t?`/contact-properties?${t}`:"/contact-properties",i=await this.resend.get(o);return i.data?{data:{...i.data,data:i.data.data.map(r=>Vn(r))},headers:i.headers,error:null}:i}async get(e){if(!e)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let t=await this.resend.get(`/contact-properties/${e}`);return t.data?{data:{object:"contact_property",...Vn(t.data)},headers:t.headers,error:null}:t}async update(e){if(!e.id)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let t=zn(e);return await this.resend.patch(`/contact-properties/${e.id}`,t)}async remove(e){return e?await this.resend.delete(`/contact-properties/${e}`):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},gp=class{constructor(e){this.resend=e}async create(e,t={}){let o=this.buildCreateFormData(e);return this.resend.post("/contacts/imports",o,t)}async list(e={}){let t=new URLSearchParams(se(e));e.status!==void 0&&t.set("status",e.status);let o=t.toString(),i=o?`/contacts/imports?${o}`:"/contacts/imports";return this.resend.get(i)}async get(e){return this.resend.get(`/contacts/imports/${e}`)}buildCreateFormData(e){let t=new FormData;return t.append("file",e.file),this.appendField(t,"column_map",this.buildColumnMap(e.columnMap??null)),this.appendField(t,"on_conflict",e.onConflict??null),this.appendField(t,"segments",e.segments??null),this.appendField(t,"topics",e.topics??null),t}buildColumnMap(e){return e===null?null:{email:e.email,first_name:e.firstName,last_name:e.lastName,unsubscribed:e.unsubscribed,properties:e.properties}}appendField(e,t,o){o!==null&&e.append(t,typeof o=="string"?o:JSON.stringify(o))}},hp=class{constructor(e){this.resend=e}async list(e){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.contactId,o=se(e),i=o?`/contacts/${t}/segments?${o}`:`/contacts/${t}/segments`;return await this.resend.get(i)}async add(e){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.contactId;return this.resend.post(`/contacts/${t}/segments/${e.segmentId}`)}async remove(e){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.contactId;return this.resend.delete(`/contacts/${t}/segments/${e.segmentId}`)}},Ap=class{constructor(e){this.resend=e}async update(e){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.id;return this.resend.patch(`/contacts/${t}/topics`,e.topics)}async list(e){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.id,o=se(e),i=o?`/contacts/${t}/topics?${o}`:`/contacts/${t}/topics`;return this.resend.get(i)}},bp=class{constructor(e){this.resend=e,this.imports=new gp(this.resend),this.topics=new Ap(this.resend),this.segments=new hp(this.resend)}async create(e,t={}){return"audienceId"in e?"segments"in e||"topics"in e?{data:null,headers:null,error:{message:"`audienceId` is deprecated, and cannot be used together with `segments` or `topics`. Use `segments` instead to add one or more segments to the new contact.",statusCode:null,name:"invalid_parameter"}}:await this.resend.post(`/audiences/${e.audienceId}/contacts`,{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t):await this.resend.post("/contacts",{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties,segments:e.segments,topics:e.topics},t)}async list(e={}){let t=e.segmentId??e.audienceId;if(!t){let r=se(e),n=r?`/contacts?${r}`:"/contacts";return await this.resend.get(n)}let o=se(e),i=o?`/segments/${t}/contacts?${o}`:`/segments/${t}/contacts`;return await this.resend.get(i)}async get(e){return typeof e=="string"?this.resend.get(`/contacts/${e}`):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.get(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`):this.resend.get(`/contacts/${e?.email?e?.email:e?.id}`)}async update(e){return!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?await this.resend.patch(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties}):await this.resend.patch(`/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties})}async remove(e){return typeof e=="string"?this.resend.delete(`/contacts/${e}`):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.delete(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`):this.resend.delete(`/contacts/${e?.email?e?.email:e?.id}`)}};function Cp(e){return{name:e.name,region:e.region,custom_return_path:e.customReturnPath,capabilities:e.capabilities,open_tracking:e.openTracking,click_tracking:e.clickTracking,tls:e.tls,tracking_subdomain:e.trackingSubdomain}}var yp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/domains/claim",{name:e.name,region:e.region,custom_return_path:e.customReturnPath,open_tracking:e.openTracking,click_tracking:e.clickTracking,tracking_subdomain:e.trackingSubdomain},t)}async get(e){return await this.resend.get(`/domains/${e}/claim`)}async verify(e){return await this.resend.post(`/domains/${e}/claim/verify`)}},Up=class{constructor(e){this.resend=e,this.claims=new yp(this.resend)}async create(e,t={}){return await this.resend.post("/domains",Cp(e),t)}async list(e={}){let t=se(e),o=t?`/domains?${t}`:"/domains";return await this.resend.get(o)}async get(e){return await this.resend.get(`/domains/${e}`)}async update(e){return await this.resend.patch(`/domains/${e.id}`,{click_tracking:e.clickTracking,open_tracking:e.openTracking,tls:e.tls,capabilities:e.capabilities,tracking_subdomain:e.trackingSubdomain})}async remove(e){return await this.resend.delete(`/domains/${e}`)}async verify(e){return await this.resend.post(`/domains/${e}/verify`)}},Kp=class{constructor(e){this.resend=e}async get(e){let{emailId:t,id:o}=e;return await this.resend.get(`/emails/${t}/attachments/${o}`)}async list(e){let{emailId:t}=e,o=se(e),i=o?`/emails/${t}/attachments?${o}`:`/emails/${t}/attachments`;return await this.resend.get(i)}},Sp=class{constructor(e){this.resend=e}async get(e){let{emailId:t,id:o}=e;return await this.resend.get(`/emails/receiving/${t}/attachments/${o}`)}async list(e){let{emailId:t}=e,o=se(e),i=o?`/emails/receiving/${t}/attachments?${o}`:`/emails/receiving/${t}/attachments`;return await this.resend.get(i)}},vp=class{constructor(e){this.resend=e,this.attachments=new Sp(e)}async get(e,t={}){let o=new URLSearchParams;t.html_format!==void 0&&o.set("html_format",t.html_format);let i=o.toString(),r=i?`/emails/receiving/${e}?${i}`:`/emails/receiving/${e}`;return await this.resend.get(r)}async list(e={}){let t=se(e),o=t?`/emails/receiving?${t}`:"/emails/receiving";return await this.resend.get(o)}async forward(e,t={}){let{emailId:o,to:i,from:r}=e,n=e.passthrough!==!1,s=await this.get(o);if(s.error)return{data:null,error:s.error,headers:s.headers};let a=s.data,l=a.subject||"(no subject)";if(n)return this.forwardPassthrough(a,{to:i,from:r,subject:l},t);let d=l.startsWith("Fwd:")?l:`Fwd: ${l}`;return this.forwardWrapped(a,{to:i,from:r,subject:d,text:"text"in e?e.text:void 0,html:"html"in e?e.html:void 0},t)}async forwardPassthrough(e,t,o){let{to:i,from:r,subject:n}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let s=await fetch(e.raw.download_url);if(!s.ok)return{data:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:s.status},headers:null};let a=await s.text(),l=await oo.parse(a,{attachmentEncoding:"base64"}),d=l.attachments.map(c=>{let u=c.contentId?c.contentId.replace(/^<|>$/g,""):void 0;return{filename:c.filename,content:c.content.toString(),content_type:c.mimeType,content_id:u||void 0}});return await this.resend.post("/emails",{from:r,to:i,subject:n,text:l.text||void 0,html:l.html||void 0,attachments:d.length>0?d:void 0},o)}async forwardWrapped(e,t,o){let{to:i,from:r,subject:n,text:s,html:a}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let l=await fetch(e.raw.download_url);if(!l.ok)return{data:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:l.status},headers:null};let d=await l.text();return await this.resend.post("/emails",{from:r,to:i,subject:n,text:s,html:a,attachments:[{filename:"forwarded_message.eml",content:Buffer.from(d).toString("base64"),content_type:"message/rfc822"}]},o)}},wp=class{constructor(e){this.resend=e,this.attachments=new Kp(e),this.receiving=new vp(e)}async send(e,t={}){return this.create(e,t)}async create(e,t={}){let o={...e};return e.react&&(o.html=await ro(e.react)),await this.resend.post("/emails",rs(o),t)}async get(e){return await this.resend.get(`/emails/${e}`)}async list(e={}){let t=se(e),o=t?`/emails?${t}`:"/emails";return await this.resend.get(o)}async update(e){return await this.resend.patch(`/emails/${e.id}`,{scheduled_at:e.scheduledAt})}async cancel(e){return await this.resend.post(`/emails/${e}/cancel`)}},xp=class{constructor(e){this.resend=e}async send(e){return await this.resend.post("/events/send",cp(e))}async create(e){return await this.resend.post("/events",e)}async get(e){return await this.resend.get(`/events/${encodeURIComponent(e)}`)}async list(e={}){let t=se(e),o=t?`/events?${t}`:"/events";return await this.resend.get(o)}async update(e,t){return await this.resend.patch(`/events/${encodeURIComponent(e)}`,t)}async remove(e){return await this.resend.delete(`/events/${encodeURIComponent(e)}`)}},Fp=class{constructor(e){this.resend=e}async list(e={}){let t=se(e),o=t?`/logs?${t}`:"/logs";return await this.resend.get(o)}async get(e){return await this.resend.get(`/logs/${e}`)}},kp=class{constructor(e){this.resend=e}async list(e={}){let t=se(e),o=t?`/oauth/grants?${t}`:"/oauth/grants";return await this.resend.get(o)}async revoke(e){return await this.resend.delete(`/oauth/grants/${e}`)}},Rp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/segments",e,t)}async list(e={}){let t=se(e),o=t?`/segments?${t}`:"/segments";return await this.resend.get(o)}async get(e){return await this.resend.get(`/segments/${e}`)}async remove(e){return await this.resend.delete(`/segments/${e}`)}};function Dp(e={}){let t=new URLSearchParams;return e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.limit&&t.set("limit",e.limit.toString()),t.size>0?`?${t.toString()}`:""}function _p(e){return e?.map(t=>({key:t.key,type:t.type,fallback_value:t.fallbackValue}))}function Yn(e){return{name:"name"in e?e.name:void 0,subject:e.subject,html:e.html,text:e.text,alias:e.alias,from:e.from,reply_to:e.replyTo,variables:_p(e.variables)}}var Xn=class{constructor(e,t){this.promise=e,this.publishFn=t}then(e,t){return this.promise.then(e,t)}async publish(){let{data:e,error:t}=await this.promise;return t?{data:null,headers:null,error:t}:this.publishFn(e.id)}},Bp=class{constructor(e){this.resend=e}create(e){return new Xn(this.performCreate(e),this.publish.bind(this))}async performCreate(e){let t={...e};return e.react&&(t.html=await ro(e.react)),this.resend.post("/templates",Yn(t))}async remove(e){return await this.resend.delete(`/templates/${e}`)}async get(e){return await this.resend.get(`/templates/${e}`)}async list(e={}){return this.resend.get(`/templates${Dp(e)}`)}duplicate(e){return new Xn(this.resend.post(`/templates/${e}/duplicate`),this.publish.bind(this))}async publish(e){return await this.resend.post(`/templates/${e}/publish`)}async update(e,t){return await this.resend.patch(`/templates/${e}`,Yn(t))}},Ep=class{constructor(e){this.resend=e}async create(e){let{defaultSubscription:t,...o}=e;return await this.resend.post("/topics",{...o,default_subscription:t})}async list(){return await this.resend.get("/topics")}async get(e){return e?await this.resend.get(`/topics/${e}`):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async update(e){return e.id?await this.resend.patch(`/topics/${e.id}`,e):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async remove(e){return e?await this.resend.delete(`/topics/${e}`):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},Op=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/webhooks",e,t)}async get(e){return await this.resend.get(`/webhooks/${e}`)}async list(e={}){let t=se(e),o=t?`/webhooks?${t}`:"/webhooks";return await this.resend.get(o)}async update(e,t){return await this.resend.patch(`/webhooks/${e}`,t)}async remove(e){return await this.resend.delete(`/webhooks/${e}`)}verify(e){return new ts.Webhook(e.webhookSecret).verify(e.payload,{"webhook-id":e.headers.id,"webhook-timestamp":e.headers.timestamp,"webhook-signature":e.headers.signature})}},Zn="https://api.resend.com",es=`resend-node:${np}`;function Tp(){return typeof process<"u"&&process.env&&process.env.RESEND_BASE_URL||Zn}function jp(){return typeof process<"u"&&process.env&&process.env.RESEND_USER_AGENT||es}var kt=class{constructor(e,t){if(this.key=e,this.segments=new Rp(this),this.apiKeys=new sp(this),this.audiences=this.segments,this.automations=new up(this),this.batch=new pp(this),this.broadcasts=new mp(this),this.contactProperties=new fp(this),this.contacts=new bp(this),this.domains=new Up(this),this.emails=new wp(this),this.events=new xp(this),this.logs=new Fp(this),this.oauthGrants=new kp(this),this.templates=new Bp(this),this.topics=new Ep(this),this.webhooks=new Op(this),!e&&(typeof process<"u"&&process.env&&(this.key=process.env.RESEND_API_KEY),!this.key))throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');this.baseUrl=t?.baseUrl??Tp(),this.userAgent=t?.userAgent??jp(),this.headers=new Headers({Authorization:`Bearer ${this.key}`,"User-Agent":this.userAgent,"Content-Type":"application/json"})}async fetchRequest(e,t={}){try{let o=await fetch(`${this.baseUrl}${e}`,t);if(!o.ok)try{let i=await o.text();return{data:null,error:JSON.parse(i),headers:Object.fromEntries(o.headers.entries())}}catch(i){if(i instanceof SyntaxError)return{data:null,error:{name:"application_error",statusCode:o.status,message:"Internal server error. We are unable to process your request right now, please try again later."},headers:Object.fromEntries(o.headers.entries())};let r={message:o.statusText,statusCode:o.status,name:"application_error"};return i instanceof Error?{data:null,error:{...r,message:i.message},headers:Object.fromEntries(o.headers.entries())}:{data:null,error:r,headers:Object.fromEntries(o.headers.entries())}}return{data:await o.json(),error:null,headers:Object.fromEntries(o.headers.entries())}}catch{return{data:null,error:{name:"application_error",statusCode:null,message:"Unable to fetch data. The request could not be resolved."},headers:null}}}async post(e,t,o={}){let i=new Headers(this.headers),r=typeof FormData<"u"&&t instanceof FormData;if(r&&i.delete("Content-Type"),o.headers)for(let[s,a]of new Headers(o.headers).entries())i.set(s,a);o.idempotencyKey&&i.set("Idempotency-Key",o.idempotencyKey);let n={method:"POST",body:r?t:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,n)}async get(e,t={}){let o=new Headers(this.headers);if(t.headers)for(let[r,n]of new Headers(t.headers).entries())o.set(r,n);let i={method:"GET",...t,headers:o};return this.fetchRequest(e,i)}async put(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PUT",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async patch(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PATCH",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async delete(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"DELETE",body:t===void 0?void 0:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}};ge();var hr=fe(ot(),1);function N(e,t){return e instanceof Error?e.message:t}function Ps(e){return!!(e||!process.stdout.isTTY)}function H(e,t={}){Ps(t.json)?console.log(JSON.stringify(e,null,2)):console.log(typeof e=="string"?e:JSON.stringify(e,null,2)),t.exitCode!==void 0&&process.exit(t.exitCode)}var zp=new Set(["content-type","retry-after"]);function Yp(e){let t={};for(let[o,i]of Object.entries(e)){let r=o.toLowerCase();(zp.has(r)||r.startsWith("x-"))&&(t[r]=i)}return t}function g(e,t={}){let o=t.exitCode??1,i=e.headers&&Object.keys(e.headers).length>0?Yp(e.headers):void 0,r=i!==void 0&&Object.keys(i).length>0;if(Ps(t.json)){let n={message:e.message,code:e.code??"unknown"};typeof e.statusCode=="number"&&(n.statusCode=e.statusCode),r&&(n.headers=i),typeof e.body=="string"&&e.body.length>0&&(n.body=e.body),console.error(JSON.stringify({error:n},null,2))}else{console.error(`${hr.default.red("Error:")} ${e.message}`);let n=[];if(typeof e.statusCode=="number"&&n.push(`HTTP ${e.statusCode}`),r)for(let[s,a]of Object.entries(i))n.push(`${s}: ${a}`);n.length>0&&console.error(hr.default.dim(`[${n.join("; ")}]`))}process.exit(o)}var $s={sending_access:0,full_access:1};function Xp(e,t){return $s[e]>=$s[t]}async function Z(e,t){let o=e.profile;try{let i=await Kt(e.apiKey,o);if(!i){if(o){let s=Se();if(!s.some(l=>l.name===o))throw new Error(`Profile "${o}" not found. Available profiles: ${s.map(l=>l.name).join(", ")||"(none)"}`)}throw new Error("No API key found. Set RESEND_API_KEY, use --api-key, or run: resend login")}let r;if(i.type==="api_key")r=i.permission;else{let s=i.scope.split(" ").filter(Boolean);s.includes("full_access")?r="full_access":s.includes("emails:send")?r="sending_access":g({message:`Unrecognized credential scope${i.scope?` "${i.scope}"`:""}. Run \`resend login\` to re-authenticate.`,code:"unrecognized_scope"},{json:e.json})}if(r){let s=t?.permission??"full_access";Xp(r,s)||g({message:`This command requires full access. Your current credential has sending access only.
|
|
268
|
+
`)}),this.textContent=t}isInlineTextNode(t){if(t.contentDisposition?.parsed?.value==="attachment")return!1;switch(t.contentType.parsed?.value){case"text/html":case"text/plain":return!0;default:return!1}}isInlineMessageRfc822(t){return t.contentType.parsed?.value!=="message/rfc822"?!1:(t.contentDisposition?.parsed?.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let t=!1,o=i=>{i.contentType.multipart||i.contentType.parsed&&["message/delivery-status","message/feedback-report"].includes(i.contentType.parsed.value)&&(t=!0);for(let r of i.childNodes)o(r)};return o(this.root),t}async resolveStream(t){let o=0,i=[],r=t.getReader();for(;;){let{done:a,value:l}=await r.read();if(a)break;i.push(l),o+=l.length}let n=new Uint8Array(o),s=0;for(let a of i)n.set(a,s),s+=a.length;return n}async parse(t){if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,t&&typeof t.getReader=="function"&&(t=await this.resolveStream(t)),t=t||new ArrayBuffer(0),typeof t=="string"&&(t=nt.encode(t)),(t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]")&&(t=await st(t)),t.buffer instanceof ArrayBuffer&&(t=new Uint8Array(t).buffer),this.buf=t,this.av=new Uint8Array(t),this.readPos=0;this.readPos<this.av.length;){let r=this.readLine();await this.processLine(r.bytes,r.done)}await this.processNodeTree();let o={headers:this.root.headers.map(r=>({key:r.key,originalKey:r.originalKey,value:r.value})).reverse()};for(let r of["from","sender"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=_o(n.value);s&&s.length&&(o[r]=s[0])}}for(let r of["delivered-to","return-path"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=_o(n.value);if(s&&s.length&&s[0].address){let a=Yi(r);o[a]=s[0].address}}}for(let r of["to","cc","bcc","reply-to"]){let n=this.root.headers.filter(a=>a.key===r),s=[];if(n.filter(a=>a&&a.value).map(a=>_o(a.value)).forEach(a=>s=s.concat(a||[])),s&&s.length){let a=Yi(r);o[a]=s}}for(let r of["subject","message-id","in-reply-to","references"]){let n=this.root.headers.find(s=>s.key===r);if(n&&n.value){let s=Yi(r);o[s]=Ct(n.value)}}let i=this.root.headers.find(r=>r.key==="date");if(i){let r=new Date(i.value);r.toString()==="Invalid Date"?r=i.value:r=r.toISOString(),o.date=r}switch(this.textContent?.html&&(o.html=this.textContent.html),this.textContent?.plain&&(o.text=this.textContent.plain),o.attachments=this.attachments,o.headerLines=(this.root.rawHeaderLines||[]).slice().reverse(),this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let n of o.attachments||[])n?.content&&(n.content=Pn(n.content),n.encoding="base64");break;case"utf8":let r=new TextDecoder("utf8");for(let n of o.attachments||[])n?.content&&(n.content=r.decode(n.content),n.encoding="utf8");break;default:throw new Error("Unknown attachment encoding")}return o}};var ts=fe(Jn(),1),np="6.17.1";function se(e){let t=new URLSearchParams;return e.limit!==void 0&&t.set("limit",e.limit.toString()),"after"in e&&e.after!==void 0&&t.set("after",e.after),"before"in e&&e.before!==void 0&&t.set("before",e.before),t.toString()}var sp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/api-keys",e,t)}async list(e={}){let t=se(e),o=t?`/api-keys?${t}`:"/api-keys";return await this.resend.get(o)}async remove(e){return await this.resend.delete(`/api-keys/${e}`)}},ap=class{constructor(e){this.resend=e}async get(e){return await this.resend.get(`/automations/${e.automationId}/runs/${e.runId}`)}async list(e){let t=se(e),o=new URLSearchParams(t);if(e.status){let n=Array.isArray(e.status)?e.status.join(","):e.status;o.set("status",n)}let i=o.toString(),r=i?`/automations/${e.automationId}/runs?${i}`:`/automations/${e.automationId}/runs`;return await this.resend.get(r)}};function os(e){switch(e.type){case"trigger":return{key:e.key,type:e.type,config:{event_name:e.config.eventName}};case"delay":return{key:e.key,type:e.type,config:e.config};case"send_email":return{key:e.key,type:e.type,config:{template:e.config.template,subject:e.config.subject,from:e.config.from,reply_to:e.config.replyTo}};case"wait_for_event":return{key:e.key,type:e.type,config:{event_name:e.config.eventName,timeout:e.config.timeout,filter_rule:e.config.filterRule}};case"condition":return{key:e.key,type:e.type,config:e.config};case"contact_update":return{key:e.key,type:e.type,config:{first_name:e.config.firstName,last_name:e.config.lastName,unsubscribed:e.config.unsubscribed,properties:e.config.properties}};case"contact_delete":return{key:e.key,type:e.type,config:e.config};case"add_to_segment":return{key:e.key,type:e.type,config:{segment_id:e.config.segmentId}}}}function is(e){return{from:e.from,to:e.to,type:e.type}}function lp(e){return{name:e.name,status:e.status,steps:e.steps.map(os),connections:e.connections.map(is)}}function cp(e){return{event:e.event,contact_id:e.contactId,email:e.email,payload:e.payload}}var up=class{constructor(e){this.resend=e,this.runs=new ap(this.resend)}async create(e){return await this.resend.post("/automations",lp(e))}async list(e={}){let t=[se(e)];e.status&&t.push(`status=${encodeURIComponent(e.status)}`);let o=t.filter(Boolean).join("&"),i=o?`/automations?${o}`:"/automations";return await this.resend.get(i)}async get(e){return await this.resend.get(`/automations/${e}`)}async remove(e){return await this.resend.delete(`/automations/${e}`)}async update(e,t){let o={};return t.name!==void 0&&(o.name=t.name),t.status!==void 0&&(o.status=t.status),t.steps!==void 0&&(o.steps=t.steps.map(os)),t.connections!==void 0&&(o.connections=t.connections.map(is)),await this.resend.patch(`/automations/${e}`,o)}async stop(e){return await this.resend.post(`/automations/${e}/stop`)}};function dp(e){return e?.map(t=>({content:t.content,filename:t.filename,path:t.path,content_type:t.contentType,content_id:t.contentId}))}function rs(e){return{attachments:dp(e.attachments),bcc:e.bcc,cc:e.cc,from:e.from,headers:e.headers,html:e.html,reply_to:e.replyTo,scheduled_at:e.scheduledAt,subject:e.subject,tags:e.tags,text:e.text,to:e.to,template:e.template?{id:e.template.id,variables:e.template.variables}:void 0,topic_id:e.topicId}}async function ro(e){let t;try{({render:t}=await import("@react-email/render"))}catch{throw new Error("Failed to render React component. Make sure to install `@react-email/render` or `@react-email/components`.")}return t(e)}var pp=class{constructor(e){this.resend=e}async send(e,t){return this.create(e,t)}async create(e,t){let o=[];for(let i of e)i.react&&(i.html=await ro(i.react),i.react=void 0),o.push(rs(i));return await this.resend.post("/emails/batch",o,{...t,headers:{"x-batch-validation":t?.batchValidation??"strict",...t?.headers}})}},mp=class{constructor(e){this.resend=e}async create(e,t={}){let o=e.react?await ro(e.react):e.html;return await this.resend.post("/broadcasts",{name:e.name,segment_id:e.segmentId,audience_id:e.audienceId,preview_text:e.previewText,from:e.from,html:o,reply_to:e.replyTo,subject:e.subject,text:e.text,topic_id:e.topicId,send:e.send,scheduled_at:e.scheduledAt},t)}async send(e,t){return await this.resend.post(`/broadcasts/${e}/send`,{scheduled_at:t?.scheduledAt})}async list(e={}){let t=se(e),o=t?`/broadcasts?${t}`:"/broadcasts";return await this.resend.get(o)}async get(e){return await this.resend.get(`/broadcasts/${e}`)}async remove(e){return await this.resend.delete(`/broadcasts/${e}`)}async update(e,t){let o=t.react?await ro(t.react):t.html;return await this.resend.patch(`/broadcasts/${e}`,{name:t.name,segment_id:t.segmentId,audience_id:t.audienceId,from:t.from,html:o,text:t.text,subject:t.subject,reply_to:t.replyTo,preview_text:t.previewText,topic_id:t.topicId})}};function Vn(e){return{id:e.id,key:e.key,createdAt:e.created_at,type:e.type,fallbackValue:e.fallback_value}}function zn(e){return"key"in e?{key:e.key,type:e.type,fallback_value:e.fallbackValue}:{fallback_value:e.fallbackValue}}var fp=class{constructor(e){this.resend=e}async create(e){let t=zn(e);return await this.resend.post("/contact-properties",t)}async list(e={}){let t=se(e),o=t?`/contact-properties?${t}`:"/contact-properties",i=await this.resend.get(o);return i.data?{data:{...i.data,data:i.data.data.map(r=>Vn(r))},headers:i.headers,error:null}:i}async get(e){if(!e)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let t=await this.resend.get(`/contact-properties/${e}`);return t.data?{data:{object:"contact_property",...Vn(t.data)},headers:t.headers,error:null}:t}async update(e){if(!e.id)return{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}};let t=zn(e);return await this.resend.patch(`/contact-properties/${e.id}`,t)}async remove(e){return e?await this.resend.delete(`/contact-properties/${e}`):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},gp=class{constructor(e){this.resend=e}async create(e,t={}){let o=this.buildCreateFormData(e);return this.resend.post("/contacts/imports",o,t)}async list(e={}){let t=new URLSearchParams(se(e));e.status!==void 0&&t.set("status",e.status);let o=t.toString(),i=o?`/contacts/imports?${o}`:"/contacts/imports";return this.resend.get(i)}async get(e){return this.resend.get(`/contacts/imports/${e}`)}buildCreateFormData(e){let t=new FormData;return t.append("file",e.file),this.appendField(t,"column_map",this.buildColumnMap(e.columnMap??null)),this.appendField(t,"on_conflict",e.onConflict??null),this.appendField(t,"segments",e.segments??null),this.appendField(t,"topics",e.topics??null),t}buildColumnMap(e){return e===null?null:{email:e.email,first_name:e.firstName,last_name:e.lastName,unsubscribed:e.unsubscribed,properties:e.properties}}appendField(e,t,o){o!==null&&e.append(t,typeof o=="string"?o:JSON.stringify(o))}},hp=class{constructor(e){this.resend=e}async list(e){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.contactId,o=se(e),i=o?`/contacts/${t}/segments?${o}`:`/contacts/${t}/segments`;return await this.resend.get(i)}async add(e){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.contactId;return this.resend.post(`/contacts/${t}/segments/${e.segmentId}`)}async remove(e){if(!e.contactId&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.contactId;return this.resend.delete(`/contacts/${t}/segments/${e.segmentId}`)}},Ap=class{constructor(e){this.resend=e}async update(e){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.id;return this.resend.patch(`/contacts/${t}/topics`,e.topics)}async list(e){if(!e.id&&!e.email)return{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}};let t=e.email?e.email:e.id,o=se(e),i=o?`/contacts/${t}/topics?${o}`:`/contacts/${t}/topics`;return this.resend.get(i)}},bp=class{constructor(e){this.resend=e,this.imports=new gp(this.resend),this.topics=new Ap(this.resend),this.segments=new hp(this.resend)}async create(e,t={}){return"audienceId"in e?"segments"in e||"topics"in e?{data:null,headers:null,error:{message:"`audienceId` is deprecated, and cannot be used together with `segments` or `topics`. Use `segments` instead to add one or more segments to the new contact.",statusCode:null,name:"invalid_parameter"}}:await this.resend.post(`/audiences/${e.audienceId}/contacts`,{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties},t):await this.resend.post("/contacts",{unsubscribed:e.unsubscribed,email:e.email,first_name:e.firstName,last_name:e.lastName,properties:e.properties,segments:e.segments,topics:e.topics},t)}async list(e={}){let t=e.segmentId??e.audienceId;if(!t){let r=se(e),n=r?`/contacts?${r}`:"/contacts";return await this.resend.get(n)}let o=se(e),i=o?`/segments/${t}/contacts?${o}`:`/segments/${t}/contacts`;return await this.resend.get(i)}async get(e){return typeof e=="string"?this.resend.get(`/contacts/${e}`):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.get(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`):this.resend.get(`/contacts/${e?.email?e?.email:e?.id}`)}async update(e){return!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?await this.resend.patch(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties}):await this.resend.patch(`/contacts/${e?.email?e?.email:e?.id}`,{unsubscribed:e.unsubscribed,first_name:e.firstName,last_name:e.lastName,properties:e.properties})}async remove(e){return typeof e=="string"?this.resend.delete(`/contacts/${e}`):!e.id&&!e.email?{data:null,headers:null,error:{message:"Missing `id` or `email` field.",statusCode:null,name:"missing_required_field"}}:e.audienceId?this.resend.delete(`/audiences/${e.audienceId}/contacts/${e?.email?e?.email:e?.id}`):this.resend.delete(`/contacts/${e?.email?e?.email:e?.id}`)}};function Cp(e){return{name:e.name,region:e.region,custom_return_path:e.customReturnPath,capabilities:e.capabilities,open_tracking:e.openTracking,click_tracking:e.clickTracking,tls:e.tls,tracking_subdomain:e.trackingSubdomain}}var yp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/domains/claim",{name:e.name,region:e.region,custom_return_path:e.customReturnPath,open_tracking:e.openTracking,click_tracking:e.clickTracking,tracking_subdomain:e.trackingSubdomain},t)}async get(e){return await this.resend.get(`/domains/${e}/claim`)}async verify(e){return await this.resend.post(`/domains/${e}/claim/verify`)}},Up=class{constructor(e){this.resend=e,this.claims=new yp(this.resend)}async create(e,t={}){return await this.resend.post("/domains",Cp(e),t)}async list(e={}){let t=se(e),o=t?`/domains?${t}`:"/domains";return await this.resend.get(o)}async get(e){return await this.resend.get(`/domains/${e}`)}async update(e){return await this.resend.patch(`/domains/${e.id}`,{click_tracking:e.clickTracking,open_tracking:e.openTracking,tls:e.tls,capabilities:e.capabilities,tracking_subdomain:e.trackingSubdomain})}async remove(e){return await this.resend.delete(`/domains/${e}`)}async verify(e){return await this.resend.post(`/domains/${e}/verify`)}},Kp=class{constructor(e){this.resend=e}async get(e){let{emailId:t,id:o}=e;return await this.resend.get(`/emails/${t}/attachments/${o}`)}async list(e){let{emailId:t}=e,o=se(e),i=o?`/emails/${t}/attachments?${o}`:`/emails/${t}/attachments`;return await this.resend.get(i)}},Sp=class{constructor(e){this.resend=e}async get(e){let{emailId:t,id:o}=e;return await this.resend.get(`/emails/receiving/${t}/attachments/${o}`)}async list(e){let{emailId:t}=e,o=se(e),i=o?`/emails/receiving/${t}/attachments?${o}`:`/emails/receiving/${t}/attachments`;return await this.resend.get(i)}},vp=class{constructor(e){this.resend=e,this.attachments=new Sp(e)}async get(e,t={}){let o=new URLSearchParams;t.html_format!==void 0&&o.set("html_format",t.html_format);let i=o.toString(),r=i?`/emails/receiving/${e}?${i}`:`/emails/receiving/${e}`;return await this.resend.get(r)}async list(e={}){let t=se(e),o=t?`/emails/receiving?${t}`:"/emails/receiving";return await this.resend.get(o)}async forward(e,t={}){let{emailId:o,to:i,from:r}=e,n=e.passthrough!==!1,s=await this.get(o);if(s.error)return{data:null,error:s.error,headers:s.headers};let a=s.data,l=a.subject||"(no subject)";if(n)return this.forwardPassthrough(a,{to:i,from:r,subject:l},t);let d=l.startsWith("Fwd:")?l:`Fwd: ${l}`;return this.forwardWrapped(a,{to:i,from:r,subject:d,text:"text"in e?e.text:void 0,html:"html"in e?e.html:void 0},t)}async forwardPassthrough(e,t,o){let{to:i,from:r,subject:n}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let s=await fetch(e.raw.download_url);if(!s.ok)return{data:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:s.status},headers:null};let a=await s.text(),l=await oo.parse(a,{attachmentEncoding:"base64"}),d=l.attachments.map(c=>{let u=c.contentId?c.contentId.replace(/^<|>$/g,""):void 0;return{filename:c.filename,content:c.content.toString(),content_type:c.mimeType,content_id:u||void 0}});return await this.resend.post("/emails",{from:r,to:i,subject:n,text:l.text||void 0,html:l.html||void 0,attachments:d.length>0?d:void 0},o)}async forwardWrapped(e,t,o){let{to:i,from:r,subject:n,text:s,html:a}=t;if(!e.raw?.download_url)return{data:null,error:{name:"validation_error",message:"Raw email content is not available for this email",statusCode:400},headers:null};let l=await fetch(e.raw.download_url);if(!l.ok)return{data:null,error:{name:"application_error",message:"Failed to download raw email content",statusCode:l.status},headers:null};let d=await l.text();return await this.resend.post("/emails",{from:r,to:i,subject:n,text:s,html:a,attachments:[{filename:"forwarded_message.eml",content:Buffer.from(d).toString("base64"),content_type:"message/rfc822"}]},o)}},wp=class{constructor(e){this.resend=e,this.attachments=new Kp(e),this.receiving=new vp(e)}async send(e,t={}){return this.create(e,t)}async create(e,t={}){let o={...e};return e.react&&(o.html=await ro(e.react)),await this.resend.post("/emails",rs(o),t)}async get(e){return await this.resend.get(`/emails/${e}`)}async list(e={}){let t=se(e),o=t?`/emails?${t}`:"/emails";return await this.resend.get(o)}async update(e){return await this.resend.patch(`/emails/${e.id}`,{scheduled_at:e.scheduledAt})}async cancel(e){return await this.resend.post(`/emails/${e}/cancel`)}},xp=class{constructor(e){this.resend=e}async send(e){return await this.resend.post("/events/send",cp(e))}async create(e){return await this.resend.post("/events",e)}async get(e){return await this.resend.get(`/events/${encodeURIComponent(e)}`)}async list(e={}){let t=se(e),o=t?`/events?${t}`:"/events";return await this.resend.get(o)}async update(e,t){return await this.resend.patch(`/events/${encodeURIComponent(e)}`,t)}async remove(e){return await this.resend.delete(`/events/${encodeURIComponent(e)}`)}},Fp=class{constructor(e){this.resend=e}async list(e={}){let t=se(e),o=t?`/logs?${t}`:"/logs";return await this.resend.get(o)}async get(e){return await this.resend.get(`/logs/${e}`)}},kp=class{constructor(e){this.resend=e}async list(e={}){let t=se(e),o=t?`/oauth/grants?${t}`:"/oauth/grants";return await this.resend.get(o)}async revoke(e){return await this.resend.delete(`/oauth/grants/${e}`)}},Rp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/segments",e,t)}async list(e={}){let t=se(e),o=t?`/segments?${t}`:"/segments";return await this.resend.get(o)}async get(e){return await this.resend.get(`/segments/${e}`)}async remove(e){return await this.resend.delete(`/segments/${e}`)}};function Dp(e={}){let t=new URLSearchParams;return e.before&&t.set("before",e.before),e.after&&t.set("after",e.after),e.limit&&t.set("limit",e.limit.toString()),t.size>0?`?${t.toString()}`:""}function _p(e){return e?.map(t=>({key:t.key,type:t.type,fallback_value:t.fallbackValue}))}function Yn(e){return{name:"name"in e?e.name:void 0,subject:e.subject,html:e.html,text:e.text,alias:e.alias,from:e.from,reply_to:e.replyTo,variables:_p(e.variables)}}var Xn=class{constructor(e,t){this.promise=e,this.publishFn=t}then(e,t){return this.promise.then(e,t)}async publish(){let{data:e,error:t}=await this.promise;return t?{data:null,headers:null,error:t}:this.publishFn(e.id)}},Bp=class{constructor(e){this.resend=e}create(e){return new Xn(this.performCreate(e),this.publish.bind(this))}async performCreate(e){let t={...e};return e.react&&(t.html=await ro(e.react)),this.resend.post("/templates",Yn(t))}async remove(e){return await this.resend.delete(`/templates/${e}`)}async get(e){return await this.resend.get(`/templates/${e}`)}async list(e={}){return this.resend.get(`/templates${Dp(e)}`)}duplicate(e){return new Xn(this.resend.post(`/templates/${e}/duplicate`),this.publish.bind(this))}async publish(e){return await this.resend.post(`/templates/${e}/publish`)}async update(e,t){return await this.resend.patch(`/templates/${e}`,Yn(t))}},Ep=class{constructor(e){this.resend=e}async create(e){let{defaultSubscription:t,...o}=e;return await this.resend.post("/topics",{...o,default_subscription:t})}async list(){return await this.resend.get("/topics")}async get(e){return e?await this.resend.get(`/topics/${e}`):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async update(e){return e.id?await this.resend.patch(`/topics/${e.id}`,e):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}async remove(e){return e?await this.resend.delete(`/topics/${e}`):{data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}}},Op=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/webhooks",e,t)}async get(e){return await this.resend.get(`/webhooks/${e}`)}async list(e={}){let t=se(e),o=t?`/webhooks?${t}`:"/webhooks";return await this.resend.get(o)}async update(e,t){return await this.resend.patch(`/webhooks/${e}`,t)}async remove(e){return await this.resend.delete(`/webhooks/${e}`)}verify(e){return new ts.Webhook(e.webhookSecret).verify(e.payload,{"webhook-id":e.headers.id,"webhook-timestamp":e.headers.timestamp,"webhook-signature":e.headers.signature})}},Zn="https://api.resend.com",es=`resend-node:${np}`;function Tp(){return typeof process<"u"&&process.env&&process.env.RESEND_BASE_URL||Zn}function jp(){return typeof process<"u"&&process.env&&process.env.RESEND_USER_AGENT||es}var kt=class{constructor(e,t){if(this.key=e,this.segments=new Rp(this),this.apiKeys=new sp(this),this.audiences=this.segments,this.automations=new up(this),this.batch=new pp(this),this.broadcasts=new mp(this),this.contactProperties=new fp(this),this.contacts=new bp(this),this.domains=new Up(this),this.emails=new wp(this),this.events=new xp(this),this.logs=new Fp(this),this.oauthGrants=new kp(this),this.templates=new Bp(this),this.topics=new Ep(this),this.webhooks=new Op(this),!e&&(typeof process<"u"&&process.env&&(this.key=process.env.RESEND_API_KEY),!this.key))throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');this.baseUrl=t?.baseUrl??Tp(),this.userAgent=t?.userAgent??jp(),this.headers=new Headers({Authorization:`Bearer ${this.key}`,"User-Agent":this.userAgent,"Content-Type":"application/json"})}async fetchRequest(e,t={}){try{let o=await fetch(`${this.baseUrl}${e}`,t);if(!o.ok)try{let i=await o.text();return{data:null,error:JSON.parse(i),headers:Object.fromEntries(o.headers.entries())}}catch(i){if(i instanceof SyntaxError)return{data:null,error:{name:"application_error",statusCode:o.status,message:"Internal server error. We are unable to process your request right now, please try again later."},headers:Object.fromEntries(o.headers.entries())};let r={message:o.statusText,statusCode:o.status,name:"application_error"};return i instanceof Error?{data:null,error:{...r,message:i.message},headers:Object.fromEntries(o.headers.entries())}:{data:null,error:r,headers:Object.fromEntries(o.headers.entries())}}return{data:await o.json(),error:null,headers:Object.fromEntries(o.headers.entries())}}catch{return{data:null,error:{name:"application_error",statusCode:null,message:"Unable to fetch data. The request could not be resolved."},headers:null}}}async post(e,t,o={}){let i=new Headers(this.headers),r=typeof FormData<"u"&&t instanceof FormData;if(r&&i.delete("Content-Type"),o.headers)for(let[s,a]of new Headers(o.headers).entries())i.set(s,a);o.idempotencyKey&&i.set("Idempotency-Key",o.idempotencyKey);let n={method:"POST",body:r?t:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,n)}async get(e,t={}){let o=new Headers(this.headers);if(t.headers)for(let[r,n]of new Headers(t.headers).entries())o.set(r,n);let i={method:"GET",...t,headers:o};return this.fetchRequest(e,i)}async put(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PUT",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async patch(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"PATCH",body:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}async delete(e,t,o={}){let i=new Headers(this.headers);if(o.headers)for(let[n,s]of new Headers(o.headers).entries())i.set(n,s);let r={method:"DELETE",body:t===void 0?void 0:JSON.stringify(t),...o,headers:i};return this.fetchRequest(e,r)}};ge();var hr=fe(ot(),1);function N(e,t){return e instanceof Error?e.message:t}function Ps(e){return!!(e||!process.stdout.isTTY)}function H(e,t={}){Ps(t.json)?console.log(JSON.stringify(e,null,2)):console.log(typeof e=="string"?e:JSON.stringify(e,null,2)),t.exitCode!==void 0&&process.exit(t.exitCode)}var zp=new Set(["content-type","retry-after"]);function Yp(e){let t={};for(let[o,i]of Object.entries(e)){let r=o.toLowerCase();(zp.has(r)||r.startsWith("x-"))&&(t[r]=i)}return t}function g(e,t={}){let o=t.exitCode??1,i=e.headers&&Object.keys(e.headers).length>0?Yp(e.headers):void 0,r=i!==void 0&&Object.keys(i).length>0;if(Ps(t.json)){let n={message:e.message,code:e.code??"unknown"};typeof e.statusCode=="number"&&(n.statusCode=e.statusCode),r&&(n.headers=i),typeof e.body=="string"&&e.body.length>0&&(n.body=e.body),console.error(JSON.stringify({error:n},null,2))}else{console.error(`${hr.default.red("Error:")} ${e.message}`);let n=[];if(typeof e.statusCode=="number"&&n.push(`HTTP ${e.statusCode}`),r)for(let[s,a]of Object.entries(i))n.push(`${s}: ${a}`);n.length>0&&console.error(hr.default.dim(`[${n.join("; ")}]`))}process.exit(o)}var $s={sending_access:0,full_access:1};function Xp(e,t){return $s[e]>=$s[t]}async function Z(e,t){let o=e.profile;try{let i=await Kt(e.apiKey,o);if(!i){if(o){let s=Se();if(!s.some(l=>l.name===o))throw new Error(`Profile "${o}" not found. Available profiles: ${s.map(l=>l.name).join(", ")||"(none)"}`)}throw new Error("No API key found. Set RESEND_API_KEY, use --api-key, or run: resend login")}let r;if(i.type==="api_key")r=i.permission;else{let s=i.scope.split(" ").filter(Boolean);s.includes("full_access")?r="full_access":s.includes("emails:send")?r="sending_access":g({message:`Unrecognized credential scope${i.scope?` "${i.scope}"`:""}. Run \`resend login\` to re-authenticate.`,code:"unrecognized_scope"},{json:e.json})}if(r){let s=t?.permission??"full_access";Xp(r,s)||g({message:`This command requires full access. Your current credential has sending access only.
|
|
269
269
|
${Dt}`,code:"insufficient_permissions"},{json:e.json})}let n=i.type==="api_key"?i.key:i.access_token;return new kt(n)}catch(i){g({message:N(i,"Failed to create client"),code:"auth_error"},{json:e.json})}}var Hs=130;function Zp(){process.stderr.isTTY&&process.stderr.write("\r\x1B[2K"),console.error("Cancelled."),process.exit(Hs)}var _t;function Qs(){_t=Zp,process.on("SIGINT",_t),process.on("uncaughtException",e=>{g({message:N(e,"An unexpected error occurred"),code:"unexpected_error"},{}),process.exit(1)})}function Lo(e){_t&&process.removeListener("SIGINT",_t),_t=e,process.on("SIGINT",_t)}function Bt(){return Hs}ge();var Wo=fe(ot(),1);V();var Gs=[1,2,4],em=Gs.length,tm=new Set(["internal_server_error","service_unavailable","gateway_timeout"]),om=(e,t)=>!!(e==="rate_limit_exceeded"||t&&e!==void 0&&tm.has(e)),im=e=>{let t=e?.["retry-after"];if(!t)return;let o=Number(t);if(Number.isFinite(o)&&o>=0)return o;let i=Date.parse(t);if(!Number.isNaN(i)){let r=(i-Date.now())/1e3;return r>0?r:0}},rm=e=>new Promise(t=>setTimeout(t,e)),lo=async(e,t,o=0)=>{let i=await e(),r=t?.retryTransient??!1;if(i.error&&o<em&&om(i.error.name,r)){let n=im(i.headers)??Gs[o];return t?.onRetry?.(o,n,i.error.name??""),await rm(n*1e3),lo(e,t,o+1)}return i};var Ns=(e,t)=>new Promise((o,i)=>{let r=setTimeout(()=>{i(new Error(`Request timed out after ${t/1e3}s`))},t);r.unref(),e.then(n=>{clearTimeout(r),o(n)},n=>{clearTimeout(r),i(n)})});var sm=Ze?String.fromCodePoint(10004):"v",am=Ze?String.fromCodePoint(9888):"!",lm=Ze?String.fromCodePoint(10007):"x",cm=["\u2839","\u2838","\u2834","\u2826","\u2807","\u280F","\u2819","\u2839"],um=80;async function Fe(e,t,o,i,r={}){let n=oe(e,i.quiet);try{let{data:s,error:a,headers:l}=await lo(()=>Ns(t(),3e4),{retryTransient:r.retryTransient,onRetry:(d,c,u)=>{n.update(u==="rate_limit_exceeded"?`Rate limited, retrying in ${c}s...`:`Server error, retrying in ${c}s...`)}});return a&&(n.stop(),g({message:a.message,code:o,statusCode:a.statusCode,headers:l},{json:i.json})),s===null&&(n.stop(),g({message:"Unexpected empty response",code:o,headers:l},{json:i.json})),n.stop(),s}catch(s){return n.stop(),g({message:N(s,"Unknown error"),code:o},{json:i.json})}}function oe(e,t){if(t||!U())return{update(a){},stop(a){},clear(){},warn(a){},fail(a){}};let o=Ze?cm:["-","\\","|","/"],i=um,r=0,n=e,s=setInterval(()=>{process.stderr.write(`\r\x1B[2K ${o[r++%o.length]} ${n}`)},i);return{update(a){n=a},stop(a){clearInterval(s),a?process.stderr.write(`\r\x1B[2K ${Wo.default.green(sm)} ${a}
|
|
270
270
|
`):process.stderr.write("\r\x1B[2K")},clear(){clearInterval(s),process.stderr.write("\r\x1B[2K")},warn(a){clearInterval(s),process.stderr.write(`\r\x1B[2K ${Wo.default.yellow(am)} ${a}
|
|
271
271
|
`)},fail(a){clearInterval(s),process.stderr.write(`\r\x1B[2K ${Wo.default.red(lm)} ${a}
|
|
@@ -694,7 +694,7 @@ Response Body:
|
|
|
694
694
|
${JSON.stringify(n.response_body,null,2)}`)}},i)});var kc=new p("list").alias("ls").description("List API request logs").option("--limit <n>","Maximum number of logs to return (1-100)","10").option("--after <cursor>","Return logs after this cursor (next page)").option("--before <cursor>","Return logs before this cursor (previous page)").addHelpText("after",m({output:` {"object":"list","data":[...],"has_more":true}
|
|
695
695
|
The list response does not include request/response bodies \u2014 use "resend logs get <id>" for that.`,errorCodes:["auth_error","invalid_limit","list_error"],examples:["resend logs list","resend logs list --limit 25 --json","resend logs list --after <cursor> --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=I(e.limit,o),r=P(i,e.after,e.before,o);await D({loading:"Fetching logs...",sdkCall:n=>n.logs.list(r),onInteractive:n=>{console.log(wc(n.data)),$(n,"logs list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile})}},o)});var Rc=new p("open").description("Open a log or the logs list in the Resend dashboard").argument("[id]","Log ID \u2014 omit to open the logs list").addHelpText("after",m({context:`Opens the Resend dashboard in your default browser.
|
|
696
696
|
With an ID: opens that log's detail page.
|
|
697
|
-
Without an ID: opens the logs list.`,examples:["resend logs open","resend logs open 3d4a472d-bc6d-4dd2-aa9d-d3d11b549e55"]})).action(async(e,t,o)=>{let i=e?de.log(e):de.logs,r=o.optsWithGlobals();await Re(i,r)});var Dc=new p("logs").description("View API request logs").addHelpText("after",m({examples:["resend logs list","resend logs list --limit 25 --json","resend logs get 3d4a472d-bc6d-4dd2-aa9d-d3d11b549e55","resend logs open","resend logs open 3d4a472d-bc6d-4dd2-aa9d-d3d11b549e55"]})).addCommand(Fc).addCommand(kc,{isDefault:!0}).addCommand(Rc);var _c={resource:"OAuth grant",resourcePlural:"OAuth grants",fetchItems:(e,{limit:t,after:o})=>e.oauthGrants.list({limit:t,...o&&{after:o}}),display:e=>({label:e.client.name,hint:e.id})};function Bc(e){let t=e.map(o=>[o.client.name,o.id,o.scopes.join(", "),o.created_at,o.revoked_at??""]);return T(["Client","ID","Scopes","Created","Revoked"],t,"(no OAuth grants)")}var Ec=new p("list").alias("ls").description("List OAuth grants for the team (both active and revoked), including each grant's client, scopes, and revocation status").option("--limit <n>","Maximum number of OAuth grants to return (1-100)","10").option("--after <cursor>","Cursor for forward pagination \u2014 list items after this ID").option("--before <cursor>","Cursor for backward pagination \u2014 list items before this ID").addHelpText("after",m({output:` {"object":"list","has_more":false,"data":[{"id":"<id>","client_id":"<id>","scopes":["<scope>"],"
|
|
697
|
+
Without an ID: opens the logs list.`,examples:["resend logs open","resend logs open 3d4a472d-bc6d-4dd2-aa9d-d3d11b549e55"]})).action(async(e,t,o)=>{let i=e?de.log(e):de.logs,r=o.optsWithGlobals();await Re(i,r)});var Dc=new p("logs").description("View API request logs").addHelpText("after",m({examples:["resend logs list","resend logs list --limit 25 --json","resend logs get 3d4a472d-bc6d-4dd2-aa9d-d3d11b549e55","resend logs open","resend logs open 3d4a472d-bc6d-4dd2-aa9d-d3d11b549e55"]})).addCommand(Fc).addCommand(kc,{isDefault:!0}).addCommand(Rc);var _c={resource:"OAuth grant",resourcePlural:"OAuth grants",fetchItems:(e,{limit:t,after:o})=>e.oauthGrants.list({limit:t,...o&&{after:o}}),display:e=>({label:e.client.name,hint:e.id})};function Bc(e){let t=e.map(o=>[o.client.name,o.id,o.scopes.join(", "),o.created_at,o.revoked_at??""]);return T(["Client","ID","Scopes","Created","Revoked"],t,"(no OAuth grants)")}var Ec=new p("list").alias("ls").description("List OAuth grants for the team (both active and revoked), including each grant's client, scopes, and revocation status").option("--limit <n>","Maximum number of OAuth grants to return (1-100)","10").option("--after <cursor>","Cursor for forward pagination \u2014 list items after this ID").option("--before <cursor>","Cursor for backward pagination \u2014 list items before this ID").addHelpText("after",m({output:` {"object":"list","has_more":false,"data":[{"id":"<id>","client_id":"<id>","scopes":["<scope>"],"created_at":"<date>","revoked_at":"<date>|null","revoked_reason":"<reason>|null","client":{"name":"<name>","logo_uri":"<url>|null"}}]}
|
|
698
698
|
Revoked grants have non-null revoked_at and revoked_reason.`,errorCodes:["auth_error","invalid_limit","list_error"],examples:["resend oauth-grants list","resend oauth-grants list --limit 25 --json","resend oauth-grants list --after <cursor> --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=I(e.limit,o),r=P(i,e.after,e.before,o);await D({loading:"Fetching OAuth grants...",sdkCall:n=>n.oauthGrants.list(r),onInteractive:n=>{console.log(Bc(n.data)),$(n,"oauth-grants list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile})}},o)});var Oc=new p("revoke").description("Revoke an OAuth grant \u2014 every access and refresh token issued under it stops working immediately").argument("[id]","OAuth grant ID").option("--yes","Skip confirmation prompt").addHelpText("after",m({context:`Non-interactive: --yes is required to confirm revocation when stdin/stdout is not a TTY.
|
|
699
699
|
|
|
700
700
|
Any team API key can revoke any of the team's grants. Revocation is immediate and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend-cli",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
4
4
|
"description": "The official CLI for Resend",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"esbuild": "0.28.1",
|
|
47
47
|
"esbuild-wasm": "0.28.0",
|
|
48
48
|
"picocolors": "1.1.1",
|
|
49
|
-
"resend": "6.17.
|
|
49
|
+
"resend": "6.17.1"
|
|
50
50
|
},
|
|
51
51
|
"pkg": {
|
|
52
52
|
"scripts": [
|