resend-cli 2.22.0 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cli.cjs +14 -10
- package/package.json +2 -2
- package/skills/resend-cli/SKILL.md +1 -1
- package/skills/resend-cli/references/webhooks.md +3 -2
package/README.md
CHANGED
|
@@ -425,8 +425,9 @@ For example, you can:
|
|
|
425
425
|
| Category | Events |
|
|
426
426
|
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
427
427
|
| Email | `email.sent`, `email.delivered`, `email.delivery_delayed`, `email.bounced`, `email.complained`, `email.opened`, `email.clicked`, `email.failed`, `email.scheduled`, `email.suppressed`, `email.received` |
|
|
428
|
-
| Contact | `contact.created`, `contact.updated`, `contact.deleted`
|
|
428
|
+
| Contact | `contact.created`, `contact.updated`, `contact.deleted`, `contact.topics.updated` |
|
|
429
429
|
| Domain | `domain.created`, `domain.updated`, `domain.deleted` |
|
|
430
|
+
| Topic | `topic.created`, `topic.updated`, `topic.deleted` |
|
|
430
431
|
|
|
431
432
|
Use `all` with `--events` to subscribe to every event.
|
|
432
433
|
|
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 J.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()}`,J.env[t.envVar]):this.emit(`optionEnv:${t.name()}`))}})}_parseOptionsImplied(){let t=new sm(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),c=this.options.find(p=>p.negate&&a===p.attributeName()),u=this.options.find(p=>!p.negate&&a===p.attributeName());return c&&(c.presetArg===void 0&&l===!1||c.presetArg!==void 0&&l===c.presetArg)?c:u||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=en(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=en(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=>im(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=tt.basename(t,tt.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(J.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 tn(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 Qi(){if(J.env.NO_COLOR||J.env.FORCE_COLOR==="0"||J.env.FORCE_COLOR==="false")return!1;if(J.env.FORCE_COLOR||J.env.CLICOLOR_FORCE!==void 0)return!0}Ni.Command=Hi;Ni.useColor=Qi});var an=Re(Ge=>{var{Argument:rn}=xo(),{Command:Mi}=on(),{CommanderError:am,InvalidArgumentError:nn}=io(),{Help:lm}=Oi(),{Option:sn}=Pi();Ge.program=new Mi;Ge.createCommand=e=>new Mi(e);Ge.createOption=(e,t)=>new sn(e,t);Ge.createArgument=(e,t)=>new rn(e,t);Ge.Command=Mi;Ge.Option=sn;Ge.Argument=rn;Ge.Help=lm;Ge.CommanderError=am;Ge.InvalidArgumentError=nn;Ge.InvalidOptionArgumentError=nn});var cn=Re((Oe,ln)=>{var Le=an();Oe=ln.exports={};Oe.program=new Le.Command;Oe.Argument=Le.Argument;Oe.Command=Le.Command;Oe.CommanderError=Le.CommanderError;Oe.Help=Le.Help;Oe.InvalidArgumentError=Le.InvalidArgumentError;Oe.InvalidOptionArgumentError=Le.InvalidArgumentError;Oe.Option=Le.Option;Oe.createCommand=e=>new Le.Command(e);Oe.createOption=(e,t)=>new Le.Option(e,t);Oe.createArgument=(e,t)=>new Le.Argument(e,t)});var Ye=Re((bh,qi)=>{var Ro=process||{},mn=Ro.argv||[],Fo=Ro.env||{},cm=!(Fo.NO_COLOR||mn.includes("--no-color"))&&(!!Fo.FORCE_COLOR||mn.includes("--color")||Ro.platform==="win32"||(Ro.stdout||{}).isTTY&&Fo.TERM!=="dumb"||!!Fo.CI),dm=(e,t,o=e)=>i=>{let r=""+i,n=r.indexOf(t,e.length);return~n?e+um(r,t,o,n)+t:e+r+t},um=(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)},pn=(e=cm)=>{let t=e?dm:()=>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")}};qi.exports=pn();qi.exports.createColors=pn});var zi=Re((kh,Fn)=>{"use strict";var Vi={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"},Fm={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Rm={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?Vi.up():"");return e&&(t+=Vi.left),t}};Fn.exports={cursor:Vi,scroll:Fm,erase:Rm,beep:"\x07"}});var er,Ln=he(()=>{er={name:"resend-cli",version:"2.22.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.30.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 ne,Wn,Kt=he(()=>{"use strict";Ln();ne=er.version,Wn=er.name});var ns=Re(je=>{"use strict";var bp=je&&je.__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(je,"__esModule",{value:!0});var le=256,dr=(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,c=0,u=0,p=0;s<i-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),c=this._decodeChar(t.charCodeAt(s+1)),u=this._decodeChar(t.charCodeAt(s+2)),p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=l<<2|c>>>4,r[n++]=c<<4|u>>>2,r[n++]=u<<6|p,a|=l&le,a|=c&le,a|=u&le,a|=p≤if(s<i-1&&(l=this._decodeChar(t.charCodeAt(s)),c=this._decodeChar(t.charCodeAt(s+1)),r[n++]=l<<2|c>>>4,a|=l&le,a|=c&le),s<i-2&&(u=this._decodeChar(t.charCodeAt(s+2)),r[n++]=c<<4|u>>>2,a|=u&le),s<i-3&&(p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=u<<6|p,a|=p&le),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=le;return o+=(42-t&t-44)>>>8&-le+t-43+62,o+=(46-t&t-48)>>>8&-le+t-47+63,o+=(47-t&t-58)>>>8&-le+t-48+52,o+=(64-t&t-91)>>>8&-le+t-65+0,o+=(96-t&t-123)>>>8&-le+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})();je.Coder=dr;var mo=new dr;function yp(e){return mo.encode(e)}je.encode=yp;function Cp(e){return mo.decode(e)}je.decode=Cp;var is=(function(e){bp(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=le;return i+=(44-o&o-46)>>>8&-le+o-45+62,i+=(94-o&o-96)>>>8&-le+o-95+63,i+=(47-o&o-58)>>>8&-le+o-48+52,i+=(64-o&o-91)>>>8&-le+o-65+0,i+=(96-o&o-123)>>>8&-le+o-97+26,i},t})(dr);je.URLSafeCoder=is;var rs=new is;function wp(e){return rs.encode(e)}je.encodeURLSafe=wp;function Up(e){return rs.decode(e)}je.decodeURLSafe=Up;je.encodedLength=function(e){return mo.encodedLength(e)};je.maxDecodedLength=function(e){return mo.maxDecodedLength(e)};je.decodedLength=function(e){return mo.decodedLength(e)}});var as=Re((ss,No)=>{(function(e,t){var o={};t(o);var i=o.default;for(var r in o)i[r]=o[r];typeof No=="object"&&typeof No.exports=="object"?No.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):e.sha256=i})(ss,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(p,f,b,h,A){for(var w,S,v,K,x,D,I,H,E,N,we,ie,St;A>=64;){for(w=f[0],S=f[1],v=f[2],K=f[3],x=f[4],D=f[5],I=f[6],H=f[7],N=0;N<16;N++)we=h+N*4,p[N]=(b[we]&255)<<24|(b[we+1]&255)<<16|(b[we+2]&255)<<8|b[we+3]&255;for(N=16;N<64;N++)E=p[N-2],ie=(E>>>17|E<<15)^(E>>>19|E<<13)^E>>>10,E=p[N-15],St=(E>>>7|E<<25)^(E>>>18|E<<14)^E>>>3,p[N]=(ie+p[N-7]|0)+(St+p[N-16]|0);for(N=0;N<64;N++)ie=(((x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7))+(x&D^~x&I)|0)+(H+(t[N]+p[N]|0)|0)|0,St=((w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10))+(w&S^w&v^S&v)|0,H=I,I=D,D=x,x=K+ie|0,K=v,v=S,S=w,w=ie+St|0;f[0]+=w,f[1]+=S,f[2]+=v,f[3]+=K,f[4]+=x,f[5]+=D,f[6]+=I,f[7]+=H,h+=64,A-=64}return h}var i=(function(){function p(){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 p.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},p.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()},p.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},p.prototype.finish=function(f){if(!this.finished){var b=this.bytesHashed,h=this.bufferLength,A=b/536870912|0,w=b<<3,S=b%64<56?64:128;this.buffer[h]=128;for(var v=h+1;v<S-8;v++)this.buffer[v]=0;this.buffer[S-8]=A>>>24&255,this.buffer[S-7]=A>>>16&255,this.buffer[S-6]=A>>>8&255,this.buffer[S-5]=A>>>0&255,this.buffer[S-4]=w>>>24&255,this.buffer[S-3]=w>>>16&255,this.buffer[S-2]=w>>>8&255,this.buffer[S-1]=w>>>0&255,o(this.temp,this.state,this.buffer,0,S),this.finished=!0}for(var v=0;v<8;v++)f[v*4+0]=this.state[v]>>>24&255,f[v*4+1]=this.state[v]>>>16&255,f[v*4+2]=this.state[v]>>>8&255,f[v*4+3]=this.state[v]>>>0&255;return this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p.prototype._saveState=function(f){for(var b=0;b<this.state.length;b++)f[b]=this.state[b]},p.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},p})();e.Hash=i;var r=(function(){function p(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 p.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},p.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()},p.prototype.update=function(f){return this.inner.update(f),this},p.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},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p})();e.HMAC=r;function n(p){var f=new i().update(p),b=f.digest();return f.clean(),b}e.hash=n,e.default=n;function s(p,f){var b=new r(p).update(f),h=b.digest();return b.clean(),h}e.hmac=s;function a(p,f,b,h){var A=h[0];if(A===0)throw new Error("hkdf: cannot expand more");f.reset(),A>1&&f.update(p),b&&f.update(b),f.update(h),f.finish(p),h[0]++}var l=new Uint8Array(e.digestLength);function c(p,f,b,h){f===void 0&&(f=l),h===void 0&&(h=32);for(var A=new Uint8Array([1]),w=s(f,p),S=new r(w),v=new Uint8Array(S.digestLength),K=v.length,x=new Uint8Array(h),D=0;D<h;D++)K===v.length&&(a(v,S,b,A),K=0),x[D]=v[K++];return S.clean(),v.fill(0),A.fill(0),x}e.hkdf=c;function u(p,f,b,h){for(var A=new r(p),w=A.digestLength,S=new Uint8Array(4),v=new Uint8Array(w),K=new Uint8Array(w),x=new Uint8Array(h),D=0;D*w<h;D++){var I=D+1;S[0]=I>>>24&255,S[1]=I>>>16&255,S[2]=I>>>8&255,S[3]=I>>>0&255,A.reset(),A.update(f),A.update(S),A.finish(K);for(var H=0;H<w;H++)v[H]=K[H];for(var H=2;H<=b;H++){A.reset(),A.update(K).finish(K);for(var E=0;E<w;E++)v[E]^=K[E]}for(var H=0;H<w&&D*w+H<h;H++)x[D*w+H]=v[H]}for(var D=0;D<w;D++)v[D]=K[D]=0;for(var D=0;D<4;D++)S[D]=0;return A.clean(),x}e.pbkdf2=u})});var cs=Re(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.timingSafeEqual=Sp;function ls(e,t=""){if(!e)throw new Error(t)}function Sp(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)),ls(e instanceof DataView),ls(t instanceof DataView);let o=e.byteLength,i=0,r=-1;for(;++r<o;)i|=e.getUint8(r)^t.getUint8(r);return i===0}});var ms=Re(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.Webhook=jt.WebhookVerificationError=void 0;var ds=ns(),vp=as(),Kp=cs(),us=300,mr=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},mt=class e extends mr{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};jt.WebhookVerificationError=mt;var Mo=class e{constructor(t,o){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=ds.decode(t)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(t,o,i){var r;let n=(r=i?.jsonParse)!==null&&r!==void 0?r:!0,s={};for(let A of Object.keys(o))s[A.toLowerCase()]=o[A];let a=s["webhook-id"],l=s["webhook-signature"],c=s["webhook-timestamp"];if(!l||!a||!c)throw new mt("Missing required headers");let u=this.verifyTimestamp(c),f=this.sign(a,u,t).split(",")[1],b=l.split(" "),h=new globalThis.TextEncoder;for(let A of b){let[w,S]=A.split(",");if(w==="v1"&&(0,Kp.timingSafeEqual)(h.encode(S),h.encode(f))){let v=t.toString();return v===""?void 0:n?JSON.parse(v):void 0}}throw new mt("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,${ds.encode(vp.hmac(this.key,s))}`}verifyTimestamp(t){let o=Math.floor(Date.now()/1e3),i=parseInt(t,10);if(Number.isNaN(i))throw new mt("Invalid Signature Headers");if(o-i>us)throw new mt("Message timestamp too old");if(i>o+us)throw new mt("Message timestamp too new");return new Date(i*1e3)}};jt.Webhook=Mo;Mo.prefix="whsec_"});var qo,vs=he(()=>{"use strict";qo=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 tn(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 Qi(){if(J.env.NO_COLOR||J.env.FORCE_COLOR==="0"||J.env.FORCE_COLOR==="false")return!1;if(J.env.FORCE_COLOR||J.env.CLICOLOR_FORCE!==void 0)return!0}Ni.Command=Hi;Ni.useColor=Qi});var an=Re(Ge=>{var{Argument:rn}=xo(),{Command:Mi}=on(),{CommanderError:am,InvalidArgumentError:nn}=io(),{Help:lm}=Oi(),{Option:sn}=Pi();Ge.program=new Mi;Ge.createCommand=e=>new Mi(e);Ge.createOption=(e,t)=>new sn(e,t);Ge.createArgument=(e,t)=>new rn(e,t);Ge.Command=Mi;Ge.Option=sn;Ge.Argument=rn;Ge.Help=lm;Ge.CommanderError=am;Ge.InvalidArgumentError=nn;Ge.InvalidOptionArgumentError=nn});var cn=Re((Oe,ln)=>{var Le=an();Oe=ln.exports={};Oe.program=new Le.Command;Oe.Argument=Le.Argument;Oe.Command=Le.Command;Oe.CommanderError=Le.CommanderError;Oe.Help=Le.Help;Oe.InvalidArgumentError=Le.InvalidArgumentError;Oe.InvalidOptionArgumentError=Le.InvalidArgumentError;Oe.Option=Le.Option;Oe.createCommand=e=>new Le.Command(e);Oe.createOption=(e,t)=>new Le.Option(e,t);Oe.createArgument=(e,t)=>new Le.Argument(e,t)});var Ye=Re((bh,qi)=>{var Ro=process||{},mn=Ro.argv||[],Fo=Ro.env||{},cm=!(Fo.NO_COLOR||mn.includes("--no-color"))&&(!!Fo.FORCE_COLOR||mn.includes("--color")||Ro.platform==="win32"||(Ro.stdout||{}).isTTY&&Fo.TERM!=="dumb"||!!Fo.CI),dm=(e,t,o=e)=>i=>{let r=""+i,n=r.indexOf(t,e.length);return~n?e+um(r,t,o,n)+t:e+r+t},um=(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)},pn=(e=cm)=>{let t=e?dm:()=>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")}};qi.exports=pn();qi.exports.createColors=pn});var zi=Re((kh,Fn)=>{"use strict";var Vi={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"},Fm={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Rm={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?Vi.up():"");return e&&(t+=Vi.left),t}};Fn.exports={cursor:Vi,scroll:Fm,erase:Rm,beep:"\x07"}});var er,Ln=he(()=>{er={name:"resend-cli",version:"2.23.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.31.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 ne,Wn,Kt=he(()=>{"use strict";Ln();ne=er.version,Wn=er.name});var ns=Re(je=>{"use strict";var bp=je&&je.__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(je,"__esModule",{value:!0});var le=256,dr=(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,c=0,u=0,p=0;s<i-4;s+=4)l=this._decodeChar(t.charCodeAt(s+0)),c=this._decodeChar(t.charCodeAt(s+1)),u=this._decodeChar(t.charCodeAt(s+2)),p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=l<<2|c>>>4,r[n++]=c<<4|u>>>2,r[n++]=u<<6|p,a|=l&le,a|=c&le,a|=u&le,a|=p≤if(s<i-1&&(l=this._decodeChar(t.charCodeAt(s)),c=this._decodeChar(t.charCodeAt(s+1)),r[n++]=l<<2|c>>>4,a|=l&le,a|=c&le),s<i-2&&(u=this._decodeChar(t.charCodeAt(s+2)),r[n++]=c<<4|u>>>2,a|=u&le),s<i-3&&(p=this._decodeChar(t.charCodeAt(s+3)),r[n++]=u<<6|p,a|=p&le),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=le;return o+=(42-t&t-44)>>>8&-le+t-43+62,o+=(46-t&t-48)>>>8&-le+t-47+63,o+=(47-t&t-58)>>>8&-le+t-48+52,o+=(64-t&t-91)>>>8&-le+t-65+0,o+=(96-t&t-123)>>>8&-le+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})();je.Coder=dr;var mo=new dr;function yp(e){return mo.encode(e)}je.encode=yp;function Cp(e){return mo.decode(e)}je.decode=Cp;var is=(function(e){bp(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=le;return i+=(44-o&o-46)>>>8&-le+o-45+62,i+=(94-o&o-96)>>>8&-le+o-95+63,i+=(47-o&o-58)>>>8&-le+o-48+52,i+=(64-o&o-91)>>>8&-le+o-65+0,i+=(96-o&o-123)>>>8&-le+o-97+26,i},t})(dr);je.URLSafeCoder=is;var rs=new is;function wp(e){return rs.encode(e)}je.encodeURLSafe=wp;function Up(e){return rs.decode(e)}je.decodeURLSafe=Up;je.encodedLength=function(e){return mo.encodedLength(e)};je.maxDecodedLength=function(e){return mo.maxDecodedLength(e)};je.decodedLength=function(e){return mo.decodedLength(e)}});var as=Re((ss,No)=>{(function(e,t){var o={};t(o);var i=o.default;for(var r in o)i[r]=o[r];typeof No=="object"&&typeof No.exports=="object"?No.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):e.sha256=i})(ss,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(p,f,b,h,A){for(var w,S,v,K,x,D,I,H,E,N,we,ie,St;A>=64;){for(w=f[0],S=f[1],v=f[2],K=f[3],x=f[4],D=f[5],I=f[6],H=f[7],N=0;N<16;N++)we=h+N*4,p[N]=(b[we]&255)<<24|(b[we+1]&255)<<16|(b[we+2]&255)<<8|b[we+3]&255;for(N=16;N<64;N++)E=p[N-2],ie=(E>>>17|E<<15)^(E>>>19|E<<13)^E>>>10,E=p[N-15],St=(E>>>7|E<<25)^(E>>>18|E<<14)^E>>>3,p[N]=(ie+p[N-7]|0)+(St+p[N-16]|0);for(N=0;N<64;N++)ie=(((x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7))+(x&D^~x&I)|0)+(H+(t[N]+p[N]|0)|0)|0,St=((w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10))+(w&S^w&v^S&v)|0,H=I,I=D,D=x,x=K+ie|0,K=v,v=S,S=w,w=ie+St|0;f[0]+=w,f[1]+=S,f[2]+=v,f[3]+=K,f[4]+=x,f[5]+=D,f[6]+=I,f[7]+=H,h+=64,A-=64}return h}var i=(function(){function p(){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 p.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},p.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()},p.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},p.prototype.finish=function(f){if(!this.finished){var b=this.bytesHashed,h=this.bufferLength,A=b/536870912|0,w=b<<3,S=b%64<56?64:128;this.buffer[h]=128;for(var v=h+1;v<S-8;v++)this.buffer[v]=0;this.buffer[S-8]=A>>>24&255,this.buffer[S-7]=A>>>16&255,this.buffer[S-6]=A>>>8&255,this.buffer[S-5]=A>>>0&255,this.buffer[S-4]=w>>>24&255,this.buffer[S-3]=w>>>16&255,this.buffer[S-2]=w>>>8&255,this.buffer[S-1]=w>>>0&255,o(this.temp,this.state,this.buffer,0,S),this.finished=!0}for(var v=0;v<8;v++)f[v*4+0]=this.state[v]>>>24&255,f[v*4+1]=this.state[v]>>>16&255,f[v*4+2]=this.state[v]>>>8&255,f[v*4+3]=this.state[v]>>>0&255;return this},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p.prototype._saveState=function(f){for(var b=0;b<this.state.length;b++)f[b]=this.state[b]},p.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},p})();e.Hash=i;var r=(function(){function p(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 p.prototype.reset=function(){return this.inner._restoreState(this.istate,this.inner.blockSize),this.outer._restoreState(this.ostate,this.outer.blockSize),this},p.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()},p.prototype.update=function(f){return this.inner.update(f),this},p.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},p.prototype.digest=function(){var f=new Uint8Array(this.digestLength);return this.finish(f),f},p})();e.HMAC=r;function n(p){var f=new i().update(p),b=f.digest();return f.clean(),b}e.hash=n,e.default=n;function s(p,f){var b=new r(p).update(f),h=b.digest();return b.clean(),h}e.hmac=s;function a(p,f,b,h){var A=h[0];if(A===0)throw new Error("hkdf: cannot expand more");f.reset(),A>1&&f.update(p),b&&f.update(b),f.update(h),f.finish(p),h[0]++}var l=new Uint8Array(e.digestLength);function c(p,f,b,h){f===void 0&&(f=l),h===void 0&&(h=32);for(var A=new Uint8Array([1]),w=s(f,p),S=new r(w),v=new Uint8Array(S.digestLength),K=v.length,x=new Uint8Array(h),D=0;D<h;D++)K===v.length&&(a(v,S,b,A),K=0),x[D]=v[K++];return S.clean(),v.fill(0),A.fill(0),x}e.hkdf=c;function u(p,f,b,h){for(var A=new r(p),w=A.digestLength,S=new Uint8Array(4),v=new Uint8Array(w),K=new Uint8Array(w),x=new Uint8Array(h),D=0;D*w<h;D++){var I=D+1;S[0]=I>>>24&255,S[1]=I>>>16&255,S[2]=I>>>8&255,S[3]=I>>>0&255,A.reset(),A.update(f),A.update(S),A.finish(K);for(var H=0;H<w;H++)v[H]=K[H];for(var H=2;H<=b;H++){A.reset(),A.update(K).finish(K);for(var E=0;E<w;E++)v[E]^=K[E]}for(var H=0;H<w&&D*w+H<h;H++)x[D*w+H]=v[H]}for(var D=0;D<w;D++)v[D]=K[D]=0;for(var D=0;D<4;D++)S[D]=0;return A.clean(),x}e.pbkdf2=u})});var cs=Re(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.timingSafeEqual=Sp;function ls(e,t=""){if(!e)throw new Error(t)}function Sp(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)),ls(e instanceof DataView),ls(t instanceof DataView);let o=e.byteLength,i=0,r=-1;for(;++r<o;)i|=e.getUint8(r)^t.getUint8(r);return i===0}});var ms=Re(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.Webhook=jt.WebhookVerificationError=void 0;var ds=ns(),vp=as(),Kp=cs(),us=300,mr=class e extends Error{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="ExtendableError",this.stack=new Error(t).stack}},mt=class e extends mr{constructor(t){super(t),Object.setPrototypeOf(this,e.prototype),this.name="WebhookVerificationError"}};jt.WebhookVerificationError=mt;var Mo=class e{constructor(t,o){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=ds.decode(t)}if(this.key.length===0)throw new Error("Secret can't be empty.")}verify(t,o,i){var r;let n=(r=i?.jsonParse)!==null&&r!==void 0?r:!0,s={};for(let A of Object.keys(o))s[A.toLowerCase()]=o[A];let a=s["webhook-id"],l=s["webhook-signature"],c=s["webhook-timestamp"];if(!l||!a||!c)throw new mt("Missing required headers");let u=this.verifyTimestamp(c),f=this.sign(a,u,t).split(",")[1],b=l.split(" "),h=new globalThis.TextEncoder;for(let A of b){let[w,S]=A.split(",");if(w==="v1"&&(0,Kp.timingSafeEqual)(h.encode(S),h.encode(f))){let v=t.toString();return v===""?void 0:n?JSON.parse(v):void 0}}throw new mt("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,${ds.encode(vp.hmac(this.key,s))}`}verifyTimestamp(t){let o=Math.floor(Date.now()/1e3),i=parseInt(t,10);if(Number.isNaN(i))throw new mt("Invalid Signature Headers");if(o-i>us)throw new mt("Message timestamp too old");if(i>o+us)throw new mt("Message timestamp too new");return new Date(i*1e3)}};jt.Webhook=Mo;Mo.prefix="whsec_"});var qo,vs=he(()=>{"use strict";qo=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 fr={};oo(fr,{FileBackend:()=>pr});var pr,gr=he(()=>{"use strict";Ae();pr=class{name="plaintext file";isSecure=!1;async get(t,o){let i=ve();if(!i)return null;let r=i.profiles[o];return(r?.type==="api_key"?r.api_key:null)??null}async set(t,o,i){hr(i,o)}async delete(t,o){try{return Ks(o),!0}catch{return!1}}async isAvailable(){return!0}}});var ks={};oo(ks,{MacOSBackend:()=>br});function Ar(e,t){return new Promise(o=>{(0,xs.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 xs,br,Fs=he(()=>{"use strict";xs=require("node:child_process");br=class{name="macOS Keychain";isSecure=!0;async get(t,o){let{stdout:i,stderr:r,code:n}=await Ar("/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 Ar("/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 Ar("/usr/bin/security",["delete-generic-password","-s",t,"-a",o]);return i===0}async isAvailable(){return process.platform==="darwin"}}});var Rs={};oo(Rs,{LinuxBackend:()=>yr});function Lo(e,t,o){return new Promise(i=>{(0,Wo.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 pf(e,t,o){return new Promise(i=>{let r=(0,Wo.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 Wo,yr,_s=he(()=>{"use strict";Wo=require("node:child_process");yr=class{name="Secret Service (libsecret)";isSecure=!0;async get(t,o){let{stdout:i,code:r}=await Lo("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 pf("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 Lo("secret-tool",["clear","service",t,"account",o]);return i===0}async isAvailable(){if(process.platform!=="linux"||(await Lo("which",["secret-tool"])).code!==0)return!1;let o=await Lo("secret-tool",["lookup","service","__resend_cli_probe__"],{timeout:3e3});return o.code===0||o.code===1}}});var Ds={};oo(Ds,{WindowsBackend:()=>Cr});function Jo(e){return new Promise(t=>{(0,Vo.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 ff(e,t){return new Promise(o=>{let i=(0,Vo.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 pt(e){return e.replace(/'/g,"''")}var Vo,fo,Cr,Es=he(()=>{"use strict";Vo=require("node:child_process");fo=`
|
|
30
30
|
try { $null = [Windows.Security.Credentials.PasswordVault] } catch {
|
|
@@ -277,7 +277,7 @@ ${r}
|
|
|
277
277
|
`&&(t=" "),(t.charCodeAt(0)>=33||[" "," "].includes(t))&&(this.node.value+=t),this.escaped=!1}},fp=50;function ar(e,t){t=t||{};let o=t._depth||0;if(o>fp)return[];let r=new sr(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=pp(l,o),l.length&&(a=a.concat(l))}),t.flatten){let l=[],c=u=>{u.forEach(p=>{if(p.group)return c(p.group);l.push(p)})};return c(a),l}return a}var Qo=ar;function os(e){for(var t="",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(e),r=i.byteLength,n=r%3,s=r-n,a,l,c,u,p,f=0;f<s;f=f+3)p=i[f]<<16|i[f+1]<<8|i[f+2],a=(p&16515072)>>18,l=(p&258048)>>12,c=(p&4032)>>6,u=p&63,t+=o[a]+o[l]+o[c]+o[u];return n==1?(p=i[s],a=(p&252)>>2,l=(p&3)<<4,t+=o[a]+o[l]+"=="):n==2&&(p=i[s]<<8|i[s+1],a=(p&64512)>>10,l=(p&1008)>>4,c=(p&15)<<2,t+=o[a]+o[l]+o[c]+"="),t}var gp=256,hp=2*1024*1024,Ap=10;function lr(e){return e.replace(/-(.)/g,(t,o)=>o.toUpperCase())}function cr(e,t,o){if(e==null)return t;if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new TypeError(`${o} must be a non-negative integer`);return e}var uo=class e{static async parse(t,o){return new e(o).parse(t)}constructor(t,o=0){this.options=t||{},this.mimeOptions={maxNestingDepth:cr(this.options.maxNestingDepth,gp,"maxNestingDepth"),maxHeadersSize:cr(this.options.maxHeadersSize,hp,"maxHeadersSize")},this.maxRfc822NestingDepth=cr(this.options.maxRfc822NestingDepth,Ap,"maxRfc822NestingDepth"),this.rfc822NestingDepth=o,this.root=this.currentNode=new It({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 u=0;u<n.value.length;u++)if(t[u+2]!==n.value[u]){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 c=!0;for(let u=a;u<t.length;u++)if(t[u]!==32&&t[u]!==9){c=!1;break}if(c)return l?(await n.node.finalize(),this.currentNode=n.node.parentNode||this.root):(await n.node.finalizeChildNodes(),this.currentNode=new It({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{let c=this.isInlineMessageRfc822(s)&&!r,u=c&&this.rfc822NestingDepth>=this.maxRfc822NestingDepth;if(c&&!u){let p=new e({...this.mimeOptions,maxRfc822NestingDepth:this.maxRfc822NestingDepth,attachmentEncoding:"arraybuffer"},this.rfc822NestingDepth+1);s.subMessage=await p.parse(s.content),i.has(s)||i.set(s,{});let f=i.get(s);(s.subMessage.text||!s.subMessage.html)&&(f.plain=f.plain||[],f.plain.push({type:"subMessage",value:s.subMessage}),o.add("plain")),s.subMessage.html&&(f.html=f.html||[],f.html.push({type:"subMessage",value:s.subMessage}),o.add("html")),p.textMap&&p.textMap.forEach((b,h)=>{i.set(h,b)});for(let b of s.subMessage.attachments||[])this.attachments.push(b)}else if(this.isInlineTextNode(s)){let p=s.contentType.parsed.value.substr(s.contentType.parsed.value.indexOf("/")+1),f=a||s;i.has(f)||i.set(f,{});let b=i.get(f);b[p]=b[p]||[],b[p].push({type:"text",value:s.getTextContent()}),o.add(p)}else if(s.content){let p=s.contentDisposition?.parsed?.params?.filename||s.contentType.parsed.params.name||null,f={filename:p?xt(p):null,mimeType:s.contentType.parsed.value,disposition:s.contentDisposition?.parsed?.value||null};switch(l&&s.contentId&&!u&&(f.related=!0),u&&(f.rfc822DepthExceeded=!0),s.contentDescription&&(f.description=s.contentDescription),s.contentId&&(f.contentId=s.contentId),s.contentType.parsed.value){case"text/calendar":case"application/ics":{s.contentType.parsed.params.method&&(f.method=s.contentType.parsed.params.method.toString().toUpperCase().trim());let b=s.getTextContent().replace(/\r?\n/g,`
|
|
278
278
|
`).replace(/\n*$/,`
|
|
279
279
|
`);f.content=dt.encode(b);break}default:f.content=s.content}this.attachments.push(f)}}for(let c of s.childNodes)await n(c,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(nr(l.value));break;case"plain":t[a].push(rr(l.value));break}break}});else{let l;switch(a){case"html":l="plain";break;case"plain":l="html";break}(s[l]||[]).forEach(c=>{switch(c.type){case"text":switch(a){case"html":t[a].push(Xn(c.value));break;case"plain":t[a].push(Zn(c.value));break}break;case"subMessage":switch(a){case"html":t[a].push(nr(c.value));break;case"plain":t[a].push(rr(c.value));break}break}})}})}),Object.keys(t).forEach(s=>{t[s]=t[s].join(`
|
|
280
|
-
`)}),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=dt.encode(t)),(t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]")&&(t=await ut(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=Qo(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=Qo(n.value);if(s&&s.length&&s[0].address){let a=lr(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=>Qo(a.value)).forEach(a=>s=s.concat(a||[])),s&&s.length){let a=lr(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=lr(r);o[s]=xt(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=os(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 Cs=ue(ms(),1),xp="6.30.0";function ce(e,t){let o=Pt(t);return o?`${e}?${o}`:e}function Pt(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 kp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/api-keys",e,t)}async list(e={}){let t=ce("/api-keys",e);return await this.resend.get(t)}async update(e,t){return await this.resend.patch(`/api-keys/${e}`,t)}async remove(e){return await this.resend.delete(`/api-keys/${e}`)}},Fp=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=Pt(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 ws(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 Us(e){return{from:e.from,to:e.to,type:e.type}}function Rp(e){return{name:e.name,status:e.status,steps:e.steps.map(ws),connections:e.connections.map(Us)}}function _p(e){return{event:e.event,contact_id:e.contactId,email:e.email,payload:e.payload}}var Dp=class{constructor(e){this.resend=e,this.runs=new Fp(this.resend)}async create(e){return await this.resend.post("/automations",Rp(e))}async list(e={}){let t=[Pt(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(ws)),t.connections!==void 0&&(o.connections=t.connections.map(Us)),await this.resend.patch(`/automations/${e}`,o)}async duplicate(e){return await this.resend.post(`/automations/${e}/duplicate`)}async stop(e){return await this.resend.post(`/automations/${e}/stop`)}};function Ep(e){return e?.map(t=>({content:t.content,filename:t.filename,path:t.path,content_type:t.contentType,content_id:t.contentId}))}function Ss(e){return{attachments:Ep(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 po(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 Bp=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 po(i.react),i.react=void 0),o.push(Ss(i));return await this.resend.post("/emails/batch",o,{...t,headers:{"x-batch-validation":t?.batchValidation??"strict",...t?.headers}})}},Op=class{constructor(e){this.resend=e}async create(e,t={}){let o=e.react?await po(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=ce("/broadcasts",e);return await this.resend.get(t)}async get(e){return await this.resend.get(`/broadcasts/${e}`)}async recipients(e,t){let o=`/broadcasts/${e}/recipients?${Tp(t)}`;return await this.resend.get(o)}async clickedLinks(e,t={}){let o=ce(`/broadcasts/${e}/clicked-links`,t);return await this.resend.get(o)}async remove(e){return await this.resend.delete(`/broadcasts/${e}`)}async cancel(e){return await this.resend.post(`/broadcasts/${e}/cancel`)}async duplicate(e){return await this.resend.post(`/broadcasts/${e}/duplicate`)}async update(e,t){let o=t.react?await po(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 Tp(e){let{type:t,email:o,bounceType:i,...r}=e,n=new URLSearchParams(Pt(r));return n.set("type",t),o!==void 0&&n.set("email",o),i!==void 0&&n.set("bounce_type",i),n.toString()}function ps(e){return{id:e.id,key:e.key,createdAt:e.created_at,type:e.type,fallbackValue:e.fallback_value}}function fs(e){return"key"in e?{key:e.key,type:e.type,fallback_value:e.fallbackValue}:{fallback_value:e.fallbackValue}}var Ip=class{constructor(e){this.resend=e}async create(e){let t=fs(e);return await this.resend.post("/contact-properties",t)}async list(e={}){let t=ce("/contact-properties",e),o=await this.resend.get(t);return o.data?{data:{...o.data,data:o.data.data.map(i=>ps(i))},headers:o.headers,error:null}:o}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",...ps(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=fs(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"}}}},jp=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(Pt(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))}},Pp=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=ce(`/contacts/${e.email?e.email:e.contactId}/segments`,e);return await this.resend.get(t)}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}`)}},$p=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=ce(`/contacts/${e.email?e.email:e.id}/topics`,e);return this.resend.get(t)}},Gp=class{constructor(e){this.resend=e,this.imports=new jp(this.resend),this.topics=new $p(this.resend),this.segments=new Pp(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 i=ce("/contacts",e);return await this.resend.get(i)}let o=ce(`/segments/${t}/contacts`,e);return await this.resend.get(o)}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 Hp(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 Qp=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`)}},Np=class{constructor(e){this.resend=e,this.claims=new Qp(this.resend)}async create(e,t={}){return await this.resend.post("/domains",Hp(e),t)}async list(e={}){let t=ce("/domains",e);return await this.resend.get(t)}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`)}},Mp=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=ce(`/emails/${t}/attachments`,e);return await this.resend.get(o)}},qp=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=ce(`/emails/receiving/${t}/attachments`,e);return await this.resend.get(o)}},Lp=class{constructor(e){this.resend=e,this.attachments=new qp(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=ce("/emails/receiving",e);return await this.resend.get(t)}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 c=l.startsWith("Fwd:")?l:`Fwd: ${l}`;return this.forwardWrapped(a,{to:i,from:r,subject:c,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 uo.parse(a,{attachmentEncoding:"base64"}),c=l.attachments.map(u=>{let p=u.contentId?u.contentId.replace(/^<|>$/g,""):void 0;return{filename:u.filename,content:u.content.toString(),content_type:u.mimeType,content_id:p||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:c.length>0?c: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 c=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(c).toString("base64"),content_type:"message/rfc822"}]},o)}},Wp=class{constructor(e){this.resend=e,this.attachments=new Mp(e),this.receiving=new Lp(e)}async send(e,t={}){return this.create(e,t)}async create(e,t={}){let o={...e};return e.react&&(o.html=await po(e.react)),await this.resend.post("/emails",Ss(o),t)}async get(e){return await this.resend.get(`/emails/${e}`)}async list(e={}){let t=ce("/emails",e);return await this.resend.get(t)}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`)}async share(e,t){return await this.resend.post(`/emails/${e}/share`,{expires_in:t?.expiresIn})}async metrics(e={}){let t=Jp(e),o=t?`/emails/metrics?${t}`:"/emails/metrics";return await this.resend.get(o)}};function Jp(e){let t={start_date:e.startDate,end_date:e.endDate,timezone:e.timezone,granularity:e.granularity,metrics:e.metrics?.join(","),dimensions:e.dimensions?.join(","),domain_id:e.domainId?.join(","),email_id:e.emailId?.join(","),broadcast_id:e.broadcastId?.join(",")},o=new URLSearchParams;for(let[i,r]of Object.entries(t))r!==void 0&&r!==""&&o.set(i,r);return o.toString()}var Vp=class{constructor(e){this.resend=e}async send(e){return await this.resend.post("/events/send",_p(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=ce("/events",e);return await this.resend.get(t)}async update(e,t){return await this.resend.patch(`/events/${encodeURIComponent(e)}`,t)}async remove(e){return await this.resend.delete(`/events/${encodeURIComponent(e)}`)}},zp=class{constructor(e){this.resend=e}async list(e={}){let t=ce("/logs",e);return await this.resend.get(t)}async get(e){return await this.resend.get(`/logs/${e}`)}},Yp=class{constructor(e){this.resend=e}async list(e={}){let t=ce("/oauth/grants",e);return await this.resend.get(t)}async revoke(e){return await this.resend.delete(`/oauth/grants/${e}`)}},Xp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/segments",e,t)}async list(e={}){let t=ce("/segments",e);return await this.resend.get(t)}async get(e){return await this.resend.get(`/segments/${e}`)}async update(e,t){return await this.resend.patch(`/segments/${e}`,t)}async remove(e){return await this.resend.delete(`/segments/${e}`)}},Zp=class{constructor(e){this.resend=e}async add(e){return this.resend.post("/suppressions/batch/add",e)}async remove(e){return this.resend.post("/suppressions/batch/remove",e)}},gs=()=>({data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}),ef=class{constructor(e){this.resend=e,this.batch=new Zp(e)}async add(e){return this.resend.post("/suppressions",e)}async list(e={}){let t=tf(e),o=t?`/suppressions?${t}`:"/suppressions";return this.resend.get(o)}async get(e){return e?this.resend.get(`/suppressions/${encodeURIComponent(e)}`):gs()}async remove(e){return e?this.resend.delete(`/suppressions/${encodeURIComponent(e)}`):gs()}};function tf(e){let{origin:t,...o}=e,i=new URLSearchParams(Pt(o));return t&&i.set("origin",t),i.toString()}function of(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 rf(e){return e?.map(t=>({key:t.key,type:t.type,fallback_value:t.fallbackValue}))}function hs(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:rf(e.variables)}}var As=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)}},nf=class{constructor(e){this.resend=e}create(e){return new As(this.performCreate(e),this.publish.bind(this))}async performCreate(e){let t={...e};return e.react&&(t.html=await po(e.react)),this.resend.post("/templates",hs(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${of(e)}`)}duplicate(e){return new As(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}`,hs(t))}},sf=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"}}}},af=class{constructor(e){this.resend=e}async get(){return await this.resend.get("/usage")}},lf=class{constructor(e){this.resend=e}async list(e){let{webhookId:t,eventId:o}=e,i=ce(`/webhooks/${t}/events/${o}/attempts`,e);return await this.resend.get(i)}},cf=class{constructor(e){this.resend=e,this.attempts=new lf(e)}async list(e){let{webhookId:t}=e,o=ce(`/webhooks/${t}/events`,e);return await this.resend.get(o)}async get(e){let{webhookId:t,eventId:o}=e;return await this.resend.get(`/webhooks/${t}/events/${o}`)}async replay(e){let{webhookId:t,eventId:o}=e;return await this.resend.post(`/webhooks/${t}/events/${o}/replay`)}},df=class{constructor(e){this.resend=e,this.events=new cf(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=ce("/webhooks",e);return await this.resend.get(t)}async update(e,t){return await this.resend.patch(`/webhooks/${e}`,t)}async remove(e){return await this.resend.delete(`/webhooks/${e}`)}async rotateSigningSecret(e){return await this.resend.post(`/webhooks/${e}/signing-secret/rotate`)}verify(e){return new Cs.Webhook(e.webhookSecret).verify(e.payload,{"webhook-id":e.headers.id,"webhook-timestamp":e.headers.timestamp,"webhook-signature":e.headers.signature})}},bs="https://api.resend.com",ys=`resend-node:${xp}`;function uf(){return typeof process<"u"&&process.env&&process.env.RESEND_BASE_URL||bs}function mf(){return typeof process<"u"&&process.env&&process.env.RESEND_USER_AGENT||ys}var $t=class{constructor(e,t){if(this.key=e,this.segments=new Xp(this),this.apiKeys=new kp(this),this.audiences=this.segments,this.automations=new Dp(this),this.batch=new Bp(this),this.broadcasts=new Op(this),this.contactProperties=new Ip(this),this.contacts=new Gp(this),this.domains=new Np(this),this.emails=new Wp(this),this.events=new Vp(this),this.logs=new zp(this),this.oauthGrants=new Yp(this),this.suppressions=new ef(this),this.templates=new nf(this),this.topics=new sf(this),this.usage=new af(this),this.webhooks=new df(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??uf(),this.userAgent=t?.userAgent??mf(),this.headers=new Headers({Authorization:`Bearer ${this.key}`,"User-Agent":this.userAgent,"Content-Type":"application/json"})}logError(e,t,o){typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&console.error("[Resend API Error]:",{...o!==void 0&&{status:o},error:e,path:t})}async fetchRequest(e,t={}){try{let o=await fetch(`${this.baseUrl}${e}`,t);if(!o.ok)try{let i=await o.text(),r=JSON.parse(i);return this.logError(r,e,o.status),{data:null,error:r,headers:Object.fromEntries(o.headers.entries())}}catch(i){if(i instanceof SyntaxError){let n={name:"application_error",statusCode:o.status,message:"Internal server error. We are unable to process your request right now, please try again later."};return this.logError(n,e,o.status),{data:null,error:n,headers:Object.fromEntries(o.headers.entries())}}let r={message:o.statusText,statusCode:o.status,name:"application_error"};if(i instanceof Error){let n={...r,message:i.message};return this.logError(n,e,o.status),{data:null,error:n,headers:Object.fromEntries(o.headers.entries())}}return this.logError(r,e,o.status),{data:null,error:r,headers:Object.fromEntries(o.headers.entries())}}return{data:await o.json(),error:null,headers:Object.fromEntries(o.headers.entries())}}catch{let o={name:"application_error",statusCode:null,message:"Unable to fetch data. The request could not be resolved."};return this.logError(o,e),{data:null,error:o,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)}};Ae();var Rr=ue(Ye(),1);function q(e,t){return e instanceof Error?e.message:t}function ia(e){return!!(e||!process.stdout.isTTY)}function Q(e,t={}){ia(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 xf=new Set(["content-type","retry-after"]);function kf(e){let t={};for(let[o,i]of Object.entries(e)){let r=o.toLowerCase();(xf.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?kf(e.headers):void 0,r=i!==void 0&&Object.keys(i).length>0;if(ia(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(`${Rr.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(Rr.default.dim(`[${n.join("; ")}]`))}process.exit(o)}var ra={sending_access:0,full_access:1};function Ff(e,t){return ra[e]>=ra[t]}async function Y(e,t){let o=e.profile;try{let i=await Rt(e.apiKey,o);if(!i){if(o){let s=ke();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";Ff(r,s)||g({message:`This command requires full access. Your current credential has sending access only.
|
|
280
|
+
`)}),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=dt.encode(t)),(t instanceof Blob||Object.prototype.toString.call(t)==="[object Blob]")&&(t=await ut(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=Qo(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=Qo(n.value);if(s&&s.length&&s[0].address){let a=lr(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=>Qo(a.value)).forEach(a=>s=s.concat(a||[])),s&&s.length){let a=lr(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=lr(r);o[s]=xt(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=os(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 Cs=ue(ms(),1),xp="6.31.0";function ce(e,t){let o=Pt(t);return o?`${e}?${o}`:e}function Pt(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 kp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/api-keys",e,t)}async list(e={}){let t=ce("/api-keys",e);return await this.resend.get(t)}async update(e,t){return await this.resend.patch(`/api-keys/${e}`,t)}async remove(e){return await this.resend.delete(`/api-keys/${e}`)}},Fp=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=Pt(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 ws(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 Us(e){return{from:e.from,to:e.to,type:e.type}}function Rp(e){return{name:e.name,status:e.status,steps:e.steps.map(ws),connections:e.connections.map(Us)}}function _p(e){return{event:e.event,contact_id:e.contactId,email:e.email,payload:e.payload}}var Dp=class{constructor(e){this.resend=e,this.runs=new Fp(this.resend)}async create(e){return await this.resend.post("/automations",Rp(e))}async list(e={}){let t=[Pt(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(ws)),t.connections!==void 0&&(o.connections=t.connections.map(Us)),await this.resend.patch(`/automations/${e}`,o)}async duplicate(e){return await this.resend.post(`/automations/${e}/duplicate`)}async stop(e){return await this.resend.post(`/automations/${e}/stop`)}};function Ep(e){return e?.map(t=>({content:t.content,filename:t.filename,path:t.path,content_type:t.contentType,content_id:t.contentId}))}function Ss(e){return{attachments:Ep(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 po(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 Bp=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 po(i.react),i.react=void 0),o.push(Ss(i));return await this.resend.post("/emails/batch",o,{...t,headers:{"x-batch-validation":t?.batchValidation??"strict",...t?.headers}})}},Op=class{constructor(e){this.resend=e}async create(e,t={}){let o=e.react?await po(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=ce("/broadcasts",e);return await this.resend.get(t)}async get(e){return await this.resend.get(`/broadcasts/${e}`)}async recipients(e,t){let o=`/broadcasts/${e}/recipients?${Tp(t)}`;return await this.resend.get(o)}async clickedLinks(e,t={}){let o=ce(`/broadcasts/${e}/clicked-links`,t);return await this.resend.get(o)}async remove(e){return await this.resend.delete(`/broadcasts/${e}`)}async cancel(e){return await this.resend.post(`/broadcasts/${e}/cancel`)}async duplicate(e){return await this.resend.post(`/broadcasts/${e}/duplicate`)}async update(e,t){let o=t.react?await po(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 Tp(e){let{type:t,email:o,bounceType:i,...r}=e,n=new URLSearchParams(Pt(r));return n.set("type",t),o!==void 0&&n.set("email",o),i!==void 0&&n.set("bounce_type",i),n.toString()}function ps(e){return{id:e.id,key:e.key,createdAt:e.created_at,type:e.type,fallbackValue:e.fallback_value}}function fs(e){return"key"in e?{key:e.key,type:e.type,fallback_value:e.fallbackValue}:{fallback_value:e.fallbackValue}}var Ip=class{constructor(e){this.resend=e}async create(e){let t=fs(e);return await this.resend.post("/contact-properties",t)}async list(e={}){let t=ce("/contact-properties",e),o=await this.resend.get(t);return o.data?{data:{...o.data,data:o.data.data.map(i=>ps(i))},headers:o.headers,error:null}:o}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",...ps(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=fs(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"}}}},jp=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(Pt(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))}},Pp=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=ce(`/contacts/${e.email?e.email:e.contactId}/segments`,e);return await this.resend.get(t)}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}`)}},$p=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=ce(`/contacts/${e.email?e.email:e.id}/topics`,e);return this.resend.get(t)}},Gp=class{constructor(e){this.resend=e,this.imports=new jp(this.resend),this.topics=new $p(this.resend),this.segments=new Pp(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 i=ce("/contacts",e);return await this.resend.get(i)}let o=ce(`/segments/${t}/contacts`,e);return await this.resend.get(o)}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 Hp(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 Qp=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`)}},Np=class{constructor(e){this.resend=e,this.claims=new Qp(this.resend)}async create(e,t={}){return await this.resend.post("/domains",Hp(e),t)}async list(e={}){let t=ce("/domains",e);return await this.resend.get(t)}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`)}},Mp=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=ce(`/emails/${t}/attachments`,e);return await this.resend.get(o)}},qp=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=ce(`/emails/receiving/${t}/attachments`,e);return await this.resend.get(o)}},Lp=class{constructor(e){this.resend=e,this.attachments=new qp(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=ce("/emails/receiving",e);return await this.resend.get(t)}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 c=l.startsWith("Fwd:")?l:`Fwd: ${l}`;return this.forwardWrapped(a,{to:i,from:r,subject:c,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 uo.parse(a,{attachmentEncoding:"base64"}),c=l.attachments.map(u=>{let p=u.contentId?u.contentId.replace(/^<|>$/g,""):void 0;return{filename:u.filename,content:u.content.toString(),content_type:u.mimeType,content_id:p||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:c.length>0?c: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 c=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(c).toString("base64"),content_type:"message/rfc822"}]},o)}},Wp=class{constructor(e){this.resend=e,this.attachments=new Mp(e),this.receiving=new Lp(e)}async send(e,t={}){return this.create(e,t)}async create(e,t={}){let o={...e};return e.react&&(o.html=await po(e.react)),await this.resend.post("/emails",Ss(o),t)}async get(e){return await this.resend.get(`/emails/${e}`)}async list(e={}){let t=ce("/emails",e);return await this.resend.get(t)}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`)}async share(e,t){return await this.resend.post(`/emails/${e}/share`,{expires_in:t?.expiresIn})}async metrics(e={}){let t=Jp(e),o=t?`/emails/metrics?${t}`:"/emails/metrics";return await this.resend.get(o)}};function Jp(e){let t={start_date:e.startDate,end_date:e.endDate,timezone:e.timezone,granularity:e.granularity,metrics:e.metrics?.join(","),dimensions:e.dimensions?.join(","),domain_id:e.domainId?.join(","),email_id:e.emailId?.join(","),broadcast_id:e.broadcastId?.join(",")},o=new URLSearchParams;for(let[i,r]of Object.entries(t))r!==void 0&&r!==""&&o.set(i,r);return o.toString()}var Vp=class{constructor(e){this.resend=e}async send(e){return await this.resend.post("/events/send",_p(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=ce("/events",e);return await this.resend.get(t)}async update(e,t){return await this.resend.patch(`/events/${encodeURIComponent(e)}`,t)}async remove(e){return await this.resend.delete(`/events/${encodeURIComponent(e)}`)}},zp=class{constructor(e){this.resend=e}async list(e={}){let t=ce("/logs",e);return await this.resend.get(t)}async get(e){return await this.resend.get(`/logs/${e}`)}},Yp=class{constructor(e){this.resend=e}async list(e={}){let t=ce("/oauth/grants",e);return await this.resend.get(t)}async revoke(e){return await this.resend.delete(`/oauth/grants/${e}`)}},Xp=class{constructor(e){this.resend=e}async create(e,t={}){return await this.resend.post("/segments",e,t)}async list(e={}){let t=ce("/segments",e);return await this.resend.get(t)}async get(e){return await this.resend.get(`/segments/${e}`)}async update(e,t){return await this.resend.patch(`/segments/${e}`,t)}async remove(e){return await this.resend.delete(`/segments/${e}`)}},Zp=class{constructor(e){this.resend=e}async add(e){return this.resend.post("/suppressions/batch/add",e)}async remove(e){return this.resend.post("/suppressions/batch/remove",e)}},gs=()=>({data:null,headers:null,error:{message:"Missing `id` field.",statusCode:null,name:"missing_required_field"}}),ef=class{constructor(e){this.resend=e,this.batch=new Zp(e)}async add(e){return this.resend.post("/suppressions",e)}async list(e={}){let t=tf(e),o=t?`/suppressions?${t}`:"/suppressions";return this.resend.get(o)}async get(e){return e?this.resend.get(`/suppressions/${encodeURIComponent(e)}`):gs()}async remove(e){return e?this.resend.delete(`/suppressions/${encodeURIComponent(e)}`):gs()}};function tf(e){let{origin:t,...o}=e,i=new URLSearchParams(Pt(o));return t&&i.set("origin",t),i.toString()}function of(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 rf(e){return e?.map(t=>({key:t.key,type:t.type,fallback_value:t.fallbackValue}))}function hs(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:rf(e.variables)}}var As=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)}},nf=class{constructor(e){this.resend=e}create(e){return new As(this.performCreate(e),this.publish.bind(this))}async performCreate(e){let t={...e};return e.react&&(t.html=await po(e.react)),this.resend.post("/templates",hs(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${of(e)}`)}duplicate(e){return new As(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}`,hs(t))}},sf=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"}}}},af=class{constructor(e){this.resend=e}async get(){return await this.resend.get("/usage")}},lf=class{constructor(e){this.resend=e}async list(e){let{webhookId:t,eventId:o}=e,i=ce(`/webhooks/${t}/events/${o}/attempts`,e);return await this.resend.get(i)}},cf=class{constructor(e){this.resend=e,this.attempts=new lf(e)}async list(e){let{webhookId:t}=e,o=ce(`/webhooks/${t}/events`,e);return await this.resend.get(o)}async get(e){let{webhookId:t,eventId:o}=e;return await this.resend.get(`/webhooks/${t}/events/${o}`)}async replay(e){let{webhookId:t,eventId:o}=e;return await this.resend.post(`/webhooks/${t}/events/${o}/replay`)}},df=class{constructor(e){this.resend=e,this.events=new cf(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=ce("/webhooks",e);return await this.resend.get(t)}async update(e,t){return await this.resend.patch(`/webhooks/${e}`,t)}async remove(e){return await this.resend.delete(`/webhooks/${e}`)}async rotateSigningSecret(e){return await this.resend.post(`/webhooks/${e}/signing-secret/rotate`)}verify(e){return new Cs.Webhook(e.webhookSecret).verify(e.payload,{"webhook-id":e.headers.id,"webhook-timestamp":e.headers.timestamp,"webhook-signature":e.headers.signature})}},bs="https://api.resend.com",ys=`resend-node:${xp}`;function uf(){return typeof process<"u"&&process.env&&process.env.RESEND_BASE_URL||bs}function mf(){return typeof process<"u"&&process.env&&process.env.RESEND_USER_AGENT||ys}var $t=class{constructor(e,t){if(this.key=e,this.segments=new Xp(this),this.apiKeys=new kp(this),this.audiences=this.segments,this.automations=new Dp(this),this.batch=new Bp(this),this.broadcasts=new Op(this),this.contactProperties=new Ip(this),this.contacts=new Gp(this),this.domains=new Np(this),this.emails=new Wp(this),this.events=new Vp(this),this.logs=new zp(this),this.oauthGrants=new Yp(this),this.suppressions=new ef(this),this.templates=new nf(this),this.topics=new sf(this),this.usage=new af(this),this.webhooks=new df(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??uf(),this.userAgent=t?.userAgent??mf(),this.headers=new Headers({Authorization:`Bearer ${this.key}`,"User-Agent":this.userAgent,"Content-Type":"application/json"})}logError(e,t,o){typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&console.error("[Resend API Error]:",{...o!==void 0&&{status:o},error:e,path:t})}async fetchRequest(e,t={}){try{let o=await fetch(`${this.baseUrl}${e}`,t);if(!o.ok)try{let i=await o.text(),r=JSON.parse(i);return this.logError(r,e,o.status),{data:null,error:r,headers:Object.fromEntries(o.headers.entries())}}catch(i){if(i instanceof SyntaxError){let n={name:"application_error",statusCode:o.status,message:"Internal server error. We are unable to process your request right now, please try again later."};return this.logError(n,e,o.status),{data:null,error:n,headers:Object.fromEntries(o.headers.entries())}}let r={message:o.statusText,statusCode:o.status,name:"application_error"};if(i instanceof Error){let n={...r,message:i.message};return this.logError(n,e,o.status),{data:null,error:n,headers:Object.fromEntries(o.headers.entries())}}return this.logError(r,e,o.status),{data:null,error:r,headers:Object.fromEntries(o.headers.entries())}}return{data:await o.json(),error:null,headers:Object.fromEntries(o.headers.entries())}}catch{let o={name:"application_error",statusCode:null,message:"Unable to fetch data. The request could not be resolved."};return this.logError(o,e),{data:null,error:o,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)}};Ae();var Rr=ue(Ye(),1);function q(e,t){return e instanceof Error?e.message:t}function ia(e){return!!(e||!process.stdout.isTTY)}function Q(e,t={}){ia(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 xf=new Set(["content-type","retry-after"]);function kf(e){let t={};for(let[o,i]of Object.entries(e)){let r=o.toLowerCase();(xf.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?kf(e.headers):void 0,r=i!==void 0&&Object.keys(i).length>0;if(ia(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(`${Rr.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(Rr.default.dim(`[${n.join("; ")}]`))}process.exit(o)}var ra={sending_access:0,full_access:1};function Ff(e,t){return ra[e]>=ra[t]}async function Y(e,t){let o=e.profile;try{let i=await Rt(e.apiKey,o);if(!i){if(o){let s=ke();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";Ff(r,s)||g({message:`This command requires full access. Your current credential has sending access only.
|
|
281
281
|
${Ht}`,code:"insufficient_permissions"},{json:e.json})}let n=i.type==="api_key"?i.key:i.access_token;return new $t(n)}catch(i){g({message:q(i,"Failed to create client"),code:"auth_error"},{json:e.json})}}var na=130;function Rf(){process.stderr.isTTY&&process.stderr.write("\r\x1B[2K"),console.error("Cancelled."),process.exit(na)}var Qt;function sa(){Qt=Rf,process.on("SIGINT",Qt),process.on("uncaughtException",e=>{g({message:q(e,"An unexpected error occurred"),code:"unexpected_error"},{}),process.exit(1)})}function oi(e){Qt&&process.removeListener("SIGINT",Qt),Qt=e,process.on("SIGINT",Qt)}function Nt(){return na}Ae();var ii=ue(Ye(),1);V();var aa=[1,2,4],_f=aa.length,Df=new Set(["internal_server_error","service_unavailable","gateway_timeout"]),Ef=(e,t)=>!!(e==="rate_limit_exceeded"||t&&e!==void 0&&Df.has(e)),Bf=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}},Of=e=>new Promise(t=>setTimeout(t,e)),Ao=async(e,t,o=0)=>{let i=await e(),r=t?.retryTransient??!1;if(i.error&&o<_f&&Ef(i.error.name,r)){let n=Bf(i.headers)??aa[o];return t?.onRetry?.(o,n,i.error.name??""),await Of(n*1e3),Ao(e,t,o+1)}return i};var la=(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 If=nt?String.fromCodePoint(10004):"v",jf=nt?String.fromCodePoint(9888):"!",Pf=nt?String.fromCodePoint(10007):"x",$f=["\u2839","\u2838","\u2834","\u2826","\u2807","\u280F","\u2819","\u2839"],Gf=80;async function ae(e,t,o,i,r={}){let n=se(e,i.quiet);try{let{data:s,error:a,headers:l}=await Ao(()=>la(t(),3e4),{retryTransient:r.retryTransient,onRetry:(c,u,p)=>{n.update(p==="rate_limit_exceeded"?`Rate limited, retrying in ${u}s...`:`Server error, retrying in ${u}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:q(s,"Unknown error"),code:o},{json:i.json})}}function se(e,t){if(t||!U())return{update(a){},stop(a){},clear(){},warn(a){},fail(a){}};let o=nt?$f:["-","\\","|","/"],i=Gf,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 ${ii.default.green(If)} ${a}
|
|
282
282
|
`):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 ${ii.default.yellow(jf)} ${a}
|
|
283
283
|
`)},fail(a){clearInterval(s),process.stderr.write(`\r\x1B[2K ${ii.default.red(Pf)} ${a}
|
|
@@ -862,7 +862,7 @@ Contact topic subscriptions are managed via the contacts namespace:
|
|
|
862
862
|
Shows the current version, latest version, and how to upgrade.`,output:` {"current":"1.4.0","latest":"1.5.0","update_available":true,"upgrade_command":"npm install -g resend-cli"}
|
|
863
863
|
{"current":"1.5.0","latest":"1.5.0","update_available":false}`,examples:["resend update","resend update --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),r=U()&&!o.json?se("Checking for updates..."):null,n=await Pr();if(!n){r?.fail("Could not check for updates"),g({message:"Could not reach GitHub releases",code:"fetch_failed"},{json:o.json});return}let s=Ci(ne,n),a=wi();if(o.json||!U()){Q({current:ne,latest:n,update_available:s,...s?{upgrade_command:a}:{}},{json:o.json});return}if(s){let l=a.startsWith("http");r?.warn(`Update available: v${ne} \u2192 v${n}`),console.log(`
|
|
864
864
|
${l?"Visit":"Run"}: \x1B[36m${a}\x1B[0m
|
|
865
|
-
`)}else r?.stop(`Already up to date (v${ne})`)});var Be=new Intl.NumberFormat("en-US");function wt(e){return e===null?"\u2014":Be.format(e)}function Fg(e){let t=["Resource","Used","Limit","Sent","Received","Resets At"],o=[["emails_daily",Be.format(e.emails.daily.used),wt(e.emails.daily.limit),Be.format(e.emails.daily.sent),Be.format(e.emails.daily.received),e.emails.daily.resets_at],["emails_monthly",Be.format(e.emails.monthly.used),wt(e.emails.monthly.limit),Be.format(e.emails.monthly.sent),Be.format(e.emails.monthly.received),e.emails.monthly.resets_at],["contacts",Be.format(e.contacts.used),wt(e.contacts.limit),"","",""],["segments",Be.format(e.segments.used),wt(e.segments.limit),"","",""],["broadcasts",Be.format(e.broadcasts.used),wt(e.broadcasts.limit),"","",""],["ai_credits",Be.format(e.ai_credits.used),wt(e.ai_credits.limit),"","",e.ai_credits.next_increase_at??""],["automation_runs",Be.format(e.automation_runs.used),wt(e.automation_runs.limit),"","",e.automation_runs.resets_at],["domains",Be.format(e.domains.used),wt(e.domains.limit),"","",""],["rate_limit","\u2014",`${Be.format(e.rate_limit.limit)} requests / ${e.rate_limit.duration}`,"","",""]];return _(t,o)}var nu=new d("usage").description("Show account-level usage and quota limits").addHelpText("after",m({output:' {"object":"usage","emails":{"daily":{"used":258,"limit":null,"sent":57,"received":201,"resets_at":"..."},"monthly":{"used":5442,"limit":10000,"sent":1000,"received":4442,"resets_at":"..."}},"contacts":{"used":85000,"limit":150000},"segments":{"used":2,"limit":3},"broadcasts":{"used":100,"limit":null},"ai_credits":{"used":0,"limit":500,"next_increase_at":"..."},"automation_runs":{"used":0,"limit":1000,"resets_at":"..."},"domains":{"used":1,"limit":1000},"rate_limit":{"limit":10,"duration":"1000ms"}}',errorCodes:["auth_error","fetch_error"],examples:["resend usage","resend usage --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals();await $({loading:"Fetching usage...",sdkCall:i=>i.usage.get(),onInteractive:i=>{console.log(Fg(i))}},o)});V();var at=["email.sent","email.delivered","email.delivery_delayed","email.bounced","email.complained","email.opened","email.clicked","email.failed","email.scheduled","email.suppressed","email.received","contact.created","contact.updated","contact.deleted","domain.created","domain.updated","domain.deleted","suppression.added","suppression.removed"];function Zt(e){return e.flatMap(t=>t.split(",")).map(t=>t.trim()).filter(Boolean)}var ye={resource:"webhook",resourcePlural:"webhooks",fetchItems:(e,{limit:t,after:o})=>e.webhooks.list({limit:t,...o&&{after:o}}),display:e=>({label:e.endpoint,hint:e.id})};function su(e){let t=e.map(o=>{let i=(o.events??[]).join(", "),r=i.length>60?`${i.slice(0,57)}...`:i;return[o.endpoint,r,o.status,o.id]});return _(["Endpoint","Events","Status","ID"],t,"(no webhooks)")}var au=new d("create").description("Register a new webhook endpoint to receive real-time event notifications").option("--endpoint <endpoint>","HTTPS URL to receive webhook events (required)").option("--events <events...>",'Event types to subscribe to (comma or space-separated). Use "all" for all
|
|
865
|
+
`)}else r?.stop(`Already up to date (v${ne})`)});var Be=new Intl.NumberFormat("en-US");function wt(e){return e===null?"\u2014":Be.format(e)}function Fg(e){let t=["Resource","Used","Limit","Sent","Received","Resets At"],o=[["emails_daily",Be.format(e.emails.daily.used),wt(e.emails.daily.limit),Be.format(e.emails.daily.sent),Be.format(e.emails.daily.received),e.emails.daily.resets_at],["emails_monthly",Be.format(e.emails.monthly.used),wt(e.emails.monthly.limit),Be.format(e.emails.monthly.sent),Be.format(e.emails.monthly.received),e.emails.monthly.resets_at],["contacts",Be.format(e.contacts.used),wt(e.contacts.limit),"","",""],["segments",Be.format(e.segments.used),wt(e.segments.limit),"","",""],["broadcasts",Be.format(e.broadcasts.used),wt(e.broadcasts.limit),"","",""],["ai_credits",Be.format(e.ai_credits.used),wt(e.ai_credits.limit),"","",e.ai_credits.next_increase_at??""],["automation_runs",Be.format(e.automation_runs.used),wt(e.automation_runs.limit),"","",e.automation_runs.resets_at],["domains",Be.format(e.domains.used),wt(e.domains.limit),"","",""],["rate_limit","\u2014",`${Be.format(e.rate_limit.limit)} requests / ${e.rate_limit.duration}`,"","",""]];return _(t,o)}var nu=new d("usage").description("Show account-level usage and quota limits").addHelpText("after",m({output:' {"object":"usage","emails":{"daily":{"used":258,"limit":null,"sent":57,"received":201,"resets_at":"..."},"monthly":{"used":5442,"limit":10000,"sent":1000,"received":4442,"resets_at":"..."}},"contacts":{"used":85000,"limit":150000},"segments":{"used":2,"limit":3},"broadcasts":{"used":100,"limit":null},"ai_credits":{"used":0,"limit":500,"next_increase_at":"..."},"automation_runs":{"used":0,"limit":1000,"resets_at":"..."},"domains":{"used":1,"limit":1000},"rate_limit":{"limit":10,"duration":"1000ms"}}',errorCodes:["auth_error","fetch_error"],examples:["resend usage","resend usage --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals();await $({loading:"Fetching usage...",sdkCall:i=>i.usage.get(),onInteractive:i=>{console.log(Fg(i))}},o)});V();var at=["email.sent","email.delivered","email.delivery_delayed","email.bounced","email.complained","email.opened","email.clicked","email.failed","email.scheduled","email.suppressed","email.received","contact.created","contact.updated","contact.deleted","contact.topics.updated","domain.created","domain.updated","domain.deleted","suppression.added","suppression.removed","topic.created","topic.updated","topic.deleted"];function Zt(e){return e.flatMap(t=>t.split(",")).map(t=>t.trim()).filter(Boolean)}var ye={resource:"webhook",resourcePlural:"webhooks",fetchItems:(e,{limit:t,after:o})=>e.webhooks.list({limit:t,...o&&{after:o}}),display:e=>({label:e.endpoint,hint:e.id})};function su(e){let t=e.map(o=>{let i=(o.events??[]).join(", "),r=i.length>60?`${i.slice(0,57)}...`:i;return[o.endpoint,r,o.status,o.id]});return _(["Endpoint","Events","Status","ID"],t,"(no webhooks)")}var au=new d("create").description("Register a new webhook endpoint to receive real-time event notifications").option("--endpoint <endpoint>","HTTPS URL to receive webhook events (required)").option("--events <events...>",'Event types to subscribe to (comma or space-separated). Use "all" for all 23 events.').addHelpText("after",m({context:`Webhooks deliver real-time event notifications to your HTTPS endpoint.
|
|
866
866
|
Events fire per-recipient: a batch email to 3 recipients generates 3 email.sent events.
|
|
867
867
|
|
|
868
868
|
--endpoint must use HTTPS.
|
|
@@ -872,13 +872,15 @@ Events fire per-recipient: a batch email to 3 recipients generates 3 email.sent
|
|
|
872
872
|
resend webhooks create --endpoint https://... --events email.sent,email.delivered
|
|
873
873
|
resend webhooks create --endpoint https://... --events all
|
|
874
874
|
|
|
875
|
-
Available event types (
|
|
875
|
+
Available event types (23 total):
|
|
876
876
|
Email: email.sent, email.delivered, email.delivery_delayed, email.bounced,
|
|
877
877
|
email.complained, email.opened, email.clicked, email.failed,
|
|
878
878
|
email.scheduled, email.suppressed, email.received
|
|
879
|
-
Contact: contact.created, contact.updated, contact.deleted
|
|
879
|
+
Contact: contact.created, contact.updated, contact.deleted,
|
|
880
|
+
contact.topics.updated
|
|
880
881
|
Domain: domain.created, domain.updated, domain.deleted
|
|
881
882
|
Suppression: suppression.added, suppression.removed
|
|
883
|
+
Topic: topic.created, topic.updated, topic.deleted
|
|
882
884
|
|
|
883
885
|
Use the signing_secret in the response to verify webhook payloads using Svix
|
|
884
886
|
signature headers (svix-id, svix-timestamp, svix-signature). "resend webhooks get" returns it again.
|
|
@@ -912,7 +914,7 @@ The webhook must be enabled \u2014 re-enable it first with: resend webhooks upda
|
|
|
912
914
|
Events are listed most recent first. Both list commands paginate forward only,
|
|
913
915
|
with --after.`,examples:["resend webhooks events list 4dd369bc-aa82-4ff3-97de-514ae3000ee0","resend webhooks events get 4dd369bc-aa82-4ff3-97de-514ae3000ee0 msg_1srOrx2ZWZBpBUvZwXKQmoEYga2","resend webhooks events attempts 4dd369bc-aa82-4ff3-97de-514ae3000ee0 msg_1srOrx2ZWZBpBUvZwXKQmoEYga2","resend webhooks events replay 4dd369bc-aa82-4ff3-97de-514ae3000ee0 msg_1srOrx2ZWZBpBUvZwXKQmoEYga2"]})).addCommand(pu,{isDefault:!0}).addCommand(mu).addCommand(uu).addCommand(fu);var hu=new d("get").description("Retrieve a webhook endpoint configuration by ID").argument("[id]","Webhook UUID").addHelpText("after",m({context:'The response includes the signing_secret. Rotate it with "resend webhooks rotate-signing-secret <id>".',output:' {"object":"webhook","id":"<uuid>","endpoint":"<url>","events":["<event>"],"status":"enabled|disabled","created_at":"<date>","signing_secret":"<whsec_...>"}',errorCodes:["auth_error","fetch_error"],examples:["resend webhooks get wh_abc123","resend webhooks get wh_abc123 --json"]})).action(async(e,t,o)=>{let i=o.optsWithGlobals(),r=await C(e,ye,i);await $({loading:"Fetching webhook...",sdkCall:n=>n.webhooks.get(r),onInteractive:n=>{console.log(`${n.endpoint}`),console.log(`ID: ${n.id}`),console.log(`Status: ${n.status}`),console.log(`Events: ${(n.events??[]).join(", ")||"(none)"}`),console.log(`Created: ${n.created_at}`),console.log(`Signing Secret: ${n.signing_secret}`)}},i)});var Au=new d("list").alias("ls").description("List all registered webhook endpoints").option("--limit <n>","Maximum number of webhooks to return (1-100)","10").option("--after <cursor>","Return webhooks after this cursor (next page)").option("--before <cursor>","Return webhooks before this cursor (previous page)").addHelpText("after",m({context:`Pagination: use --after or --before with a webhook ID as the cursor.
|
|
914
916
|
Only one of --after or --before may be used at a time.
|
|
915
|
-
The response includes has_more: true when additional pages exist.`,output:' {"object":"list","data":[{"id":"<uuid>","endpoint":"<url>","events":["<event>"],"status":"enabled","created_at":"<date>"}],"has_more":false}',errorCodes:["auth_error","invalid_limit","list_error"],examples:["resend webhooks list","resend webhooks list --limit 25 --json","resend webhooks list --after wh_abc123 --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=O(e.limit,o),r=G(i,e.after,e.before,o);await F({loading:"Fetching webhooks...",sdkCall:n=>n.webhooks.list(r),onInteractive:n=>{console.log(su(n.data)),T(n,"webhooks list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile})}},o)});var yu=require("node:http");var Ce=ue(Ye(),1);V();function bu(e){return e?"error"in e?e.timeout?{status:504,body:"Forward target timed out"}:{status:502,body:"Forward target unreachable"}:e.status>=200&&e.status<300?{status:200,body:"OK"}:{status:e.status,body:"Forward target failed"}:{status:200,body:"OK"}}var Cu=["svix-id","svix-timestamp","svix-signature"],Rg=3e4;function _g(){return new Date().toLocaleTimeString("en-GB",{hour12:!1})}function Dg(e){let t=Fe(e.type??"unknown"),o=e.data??{},i=Fe(o.id??""),r="";if(t.startsWith("email.")){let n=Fe(o.from??""),s=Fe(Array.isArray(o.to)?o.to[0]:"");(n||s)&&(r=`${n} -> ${s}`)}else t.startsWith("domain.")?r=Fe(o.name??""):(t.startsWith("contact.")||t.startsWith("suppression."))&&(r=Fe(o.email??""));return{type:t,resourceId:i,detail:r}}function Eg(e){let t=`${e} ${Bg(e)}`;return e>=200&&e<300?Ce.default.green(t):e>=400&&e<500?Ce.default.yellow(t):Ce.default.red(t)}function Bg(e){return{200:"OK",201:"Created",204:"No Content",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"}[e]??""}async function Og(e,t,o){let i={"content-type":"application/json"};for(let s of Cu){let a=o[s];a&&(i[s]=a)}let r=e.startsWith("http")?e:`http://${e}`;return{status:(await fetch(r,{method:"POST",headers:i,body:t,signal:AbortSignal.timeout(Rg)})).status}}function Tg(e){return new Promise((t,o)=>{let i=[];e.on("data",r=>i.push(r)),e.on("end",()=>t(Buffer.concat(i).toString())),e.on("error",o)})}async function Ig(e,t,o){process.stderr.write(`
|
|
917
|
+
The response includes has_more: true when additional pages exist.`,output:' {"object":"list","data":[{"id":"<uuid>","endpoint":"<url>","events":["<event>"],"status":"enabled","created_at":"<date>"}],"has_more":false}',errorCodes:["auth_error","invalid_limit","list_error"],examples:["resend webhooks list","resend webhooks list --limit 25 --json","resend webhooks list --after wh_abc123 --json"]})).action(async(e,t)=>{let o=t.optsWithGlobals(),i=O(e.limit,o),r=G(i,e.after,e.before,o);await F({loading:"Fetching webhooks...",sdkCall:n=>n.webhooks.list(r),onInteractive:n=>{console.log(su(n.data)),T(n,"webhooks list",{limit:i,before:e.before,apiKey:o.apiKey,profile:o.profile})}},o)});var yu=require("node:http");var Ce=ue(Ye(),1);V();function bu(e){return e?"error"in e?e.timeout?{status:504,body:"Forward target timed out"}:{status:502,body:"Forward target unreachable"}:e.status>=200&&e.status<300?{status:200,body:"OK"}:{status:e.status,body:"Forward target failed"}:{status:200,body:"OK"}}var Cu=["svix-id","svix-timestamp","svix-signature"],Rg=3e4;function _g(){return new Date().toLocaleTimeString("en-GB",{hour12:!1})}function Dg(e){let t=Fe(e.type??"unknown"),o=e.data??{},i=Fe(o.id??""),r="";if(t.startsWith("email.")){let n=Fe(o.from??""),s=Fe(Array.isArray(o.to)?o.to[0]:"");(n||s)&&(r=`${n} -> ${s}`)}else t.startsWith("domain.")||t.startsWith("topic.")?r=Fe(o.name??""):(t.startsWith("contact.")||t.startsWith("suppression."))&&(r=Fe(o.email??""));return{type:t,resourceId:i,detail:r}}function Eg(e){let t=`${e} ${Bg(e)}`;return e>=200&&e<300?Ce.default.green(t):e>=400&&e<500?Ce.default.yellow(t):Ce.default.red(t)}function Bg(e){return{200:"OK",201:"Created",204:"No Content",400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"}[e]??""}async function Og(e,t,o){let i={"content-type":"application/json"};for(let s of Cu){let a=o[s];a&&(i[s]=a)}let r=e.startsWith("http")?e:`http://${e}`;return{status:(await fetch(r,{method:"POST",headers:i,body:t,signal:AbortSignal.timeout(Rg)})).status}}function Tg(e){return new Promise((t,o)=>{let i=[];e.on("data",r=>i.push(r)),e.on("end",()=>t(Buffer.concat(i).toString())),e.on("error",o)})}async function Ig(e,t,o){process.stderr.write(`
|
|
916
918
|
Cleaning up...`);try{await e.webhooks.remove(t),process.stderr.write(` Webhook ${t} deleted.
|
|
917
919
|
`)}catch{process.stderr.write(` Failed to delete webhook ${t}.
|
|
918
920
|
`)}o.close()}var wu=new d("listen").description("Listen for webhook events locally during development").option("--url <url>","Public URL for receiving webhooks (your tunnel URL)").option("--forward-to <url>","Forward payloads to this local URL").option("--events <events...>","Event types to listen for (default: all)").option("--port <port>","Local server port","4318").addHelpText("after",m({context:`Start a local server that receives Resend webhook events in real time.
|
|
@@ -940,23 +942,25 @@ Ready! Listening for webhook events. Press Ctrl+C to stop.
|
|
|
940
942
|
|
|
941
943
|
`)}let f=!1,b=async()=>{f||(f=!0,await Ig(a,p,c),process.exit(Nt()))};oi(b),process.on("SIGTERM",b),await new Promise(()=>{})});var Uu=new d("rotate-signing-secret").description("Generate a new signing secret for a webhook").argument("[id]","Webhook UUID").addHelpText("after",m({context:`Generates a new signing secret and returns it. For 24 hours, payloads are
|
|
942
944
|
signed with both the new and the previous secret, so either one verifies them.
|
|
943
|
-
After that, only the new secret does. Update your verification code within that window.`,output:' {"object":"webhook","id":"<uuid>","signing_secret":"<whsec_...>"}',errorCodes:["auth_error","create_error"],examples:["resend webhooks rotate-signing-secret 4dd369bc-aa82-4ff3-97de-514ae3000ee0","resend webhooks rotate-signing-secret 4dd369bc-aa82-4ff3-97de-514ae3000ee0 --json"]})).action(async(e,t,o)=>{let i=o.optsWithGlobals(),r=await C(e,ye,i);await M({loading:"Rotating webhook signing secret...",sdkCall:n=>n.webhooks.rotateSigningSecret(r),onInteractive:n=>{console.log("Webhook signing secret rotated"),console.log(`ID: ${n.id}`),console.log(`Signing Secret: ${n.signing_secret}`)}},i)});var Su=new d("update").description("Update a webhook's endpoint URL, event subscriptions, or enabled status").argument("[id]","Webhook UUID").option("--endpoint <endpoint>","New HTTPS URL for this webhook").option("--events <events...>",'Replace the full event subscription list (comma or space-separated). Use "all" for all
|
|
945
|
+
After that, only the new secret does. Update your verification code within that window.`,output:' {"object":"webhook","id":"<uuid>","signing_secret":"<whsec_...>"}',errorCodes:["auth_error","create_error"],examples:["resend webhooks rotate-signing-secret 4dd369bc-aa82-4ff3-97de-514ae3000ee0","resend webhooks rotate-signing-secret 4dd369bc-aa82-4ff3-97de-514ae3000ee0 --json"]})).action(async(e,t,o)=>{let i=o.optsWithGlobals(),r=await C(e,ye,i);await M({loading:"Rotating webhook signing secret...",sdkCall:n=>n.webhooks.rotateSigningSecret(r),onInteractive:n=>{console.log("Webhook signing secret rotated"),console.log(`ID: ${n.id}`),console.log(`Signing Secret: ${n.signing_secret}`)}},i)});var Su=new d("update").description("Update a webhook's endpoint URL, event subscriptions, or enabled status").argument("[id]","Webhook UUID").option("--endpoint <endpoint>","New HTTPS URL for this webhook").option("--events <events...>",'Replace the full event subscription list (comma or space-separated). Use "all" for all 23 events.').addOption(new L("--status <status>","Enable or disable event delivery for this webhook").choices(["enabled","disabled"])).addHelpText("after",m({context:`At least one of --endpoint, --events, or --status must be provided.
|
|
944
946
|
|
|
945
947
|
--events replaces the entire event list (it is not additive).
|
|
946
|
-
Use "all" as a shorthand for all
|
|
948
|
+
Use "all" as a shorthand for all 23 event types.
|
|
947
949
|
|
|
948
950
|
--status controls whether events are delivered to this endpoint:
|
|
949
951
|
enabled Events are delivered (default on creation)
|
|
950
952
|
disabled Events are suppressed without deleting the webhook`,output:' {"object":"webhook","id":"<uuid>"}',errorCodes:["auth_error","no_changes","update_error"],examples:["resend webhooks update wh_abc123 --endpoint https://new-app.example.com/hooks/resend","resend webhooks update wh_abc123 --events email.sent email.bounced","resend webhooks update wh_abc123 --events all","resend webhooks update wh_abc123 --status disabled","resend webhooks update wh_abc123 --endpoint https://new-app.example.com/hooks/resend --events all --json"]})).action(async(e,t,o)=>{let i=o.optsWithGlobals(),r=await C(e,ye,i),n=t.events?.length?Zt(t.events):void 0,s=n!==void 0;!t.endpoint&&!s&&!t.status&&g({message:"Provide at least one option to update: --endpoint, --events, or --status.",code:"no_changes"},{json:i.json}),s&&!n.length&&g({message:"Missing --events values.",code:"no_changes"},{json:i.json});let a=n?.includes("all")?at:n?.length?n:void 0;await B({loading:"Updating webhook...",sdkCall:l=>l.webhooks.update(r,{...t.endpoint&&{endpoint:t.endpoint},...a?.length&&{events:a},...t.status&&{status:t.status}}),errorCode:"update_error",successMsg:`Webhook updated: ${r}`},i)});var vu=new d("webhooks").description("Manage webhook endpoints for real-time event notifications").addHelpText("after",m({context:`Webhooks let you receive real-time event notifications from Resend at an HTTPS endpoint.
|
|
951
953
|
Payloads are signed with Svix headers for verification.
|
|
952
954
|
|
|
953
|
-
Event categories (
|
|
955
|
+
Event categories (23 total):
|
|
954
956
|
Email: email.sent, email.delivered, email.delivery_delayed, email.bounced,
|
|
955
957
|
email.complained, email.opened, email.clicked, email.failed,
|
|
956
958
|
email.scheduled, email.suppressed, email.received
|
|
957
|
-
Contact: contact.created, contact.updated, contact.deleted
|
|
959
|
+
Contact: contact.created, contact.updated, contact.deleted,
|
|
960
|
+
contact.topics.updated
|
|
958
961
|
Domain: domain.created, domain.updated, domain.deleted
|
|
959
962
|
Suppression: suppression.added, suppression.removed
|
|
963
|
+
Topic: topic.created, topic.updated, topic.deleted
|
|
960
964
|
|
|
961
965
|
Signature verification (Svix):
|
|
962
966
|
Each delivery includes headers: svix-id, svix-timestamp, svix-signature
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
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.
|
|
49
|
+
"resend": "6.31.0"
|
|
50
50
|
},
|
|
51
51
|
"pkg": {
|
|
52
52
|
"scripts": [
|
|
@@ -13,7 +13,7 @@ metadata:
|
|
|
13
13
|
author: resend
|
|
14
14
|
# Skill version is independent from the CLI/package.json version —
|
|
15
15
|
# bump it on skill content changes, not CLI releases.
|
|
16
|
-
version: "2.
|
|
16
|
+
version: "2.15.0"
|
|
17
17
|
homepage: https://resend.com/docs/cli-agents
|
|
18
18
|
source: https://github.com/resend/resend-cli
|
|
19
19
|
openclaw:
|
|
@@ -21,11 +21,12 @@ Detailed flag specifications for `resend webhooks` commands.
|
|
|
21
21
|
| `--endpoint <url>` | string | Yes (non-interactive) | HTTPS webhook URL |
|
|
22
22
|
| `--events <events...>` | string[] | Yes (non-interactive) | Event types or `all` |
|
|
23
23
|
|
|
24
|
-
**All
|
|
24
|
+
**All 23 events:**
|
|
25
25
|
- Email: `email.sent`, `email.delivered`, `email.delivery_delayed`, `email.bounced`, `email.complained`, `email.opened`, `email.clicked`, `email.failed`, `email.scheduled`, `email.suppressed`, `email.received`
|
|
26
|
-
- Contact: `contact.created`, `contact.updated`, `contact.deleted`
|
|
26
|
+
- Contact: `contact.created`, `contact.updated`, `contact.deleted`, `contact.topics.updated`
|
|
27
27
|
- Domain: `domain.created`, `domain.updated`, `domain.deleted`
|
|
28
28
|
- Suppression: `suppression.added`, `suppression.removed`
|
|
29
|
+
- Topic: `topic.created`, `topic.updated`, `topic.deleted`
|
|
29
30
|
|
|
30
31
|
**Output includes `signing_secret`.** `webhooks get` returns it again.
|
|
31
32
|
|