Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@sentry/aws-serverless

Package Overview
Dependencies
Maintainers
1
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sentry/aws-serverless - npm Package Compare versions

Comparing version
10.51.0
to
10.52.0
+1
-1
build/lambda-extension/index.mjs
#!/usr/bin/env node
import*as n from"node:http";import{buffer as t}from"node:stream/consumers";const o=globalThis,e="10.51.0";const r={};function i(n){if(!("console"in o))return n();const t=o.console,e={},i=Object.keys(r);i.forEach(n=>{const o=r[n];e[n]=t[n],t[n]=o});try{return n()}finally{i.forEach(n=>{t[n]=e[n]})}}function s(){return c().enabled}function a(n,...t){s()&&i(()=>{o.console[n](`Sentry Logger [${n}]:`,...t)})}function c(){return function(n,t,r=o){const i=r.__SENTRY__=r.__SENTRY__||{},s=i[e]=i[e]||{};return s[n]||(s[n]=t())}("loggerSettings",()=>({enabled:!1}))}const p={enable:function(){c().enabled=!0},disable:function(){c().enabled=!1},isEnabled:s,log:function(...n){a("log",...n)},warn:function(...n){a("warn",...n)},error:function(...n){a("error",...n)}},l=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function d(n){return{protocol:n.protocol,publicKey:n.publicKey||"",pass:n.pass||"",host:n.host,port:n.port||"",path:n.path||"",projectId:n.projectId}}function u(n){const t="string"==typeof n?function(n){const t=l.exec(n);if(!t)return void i(()=>{console.error(`Invalid Sentry Dsn: ${n}`)});const[o,e,r="",s="",a="",c=""]=t.slice(1);let p="",u=c;const f=u.split("/");if(f.length>1&&(p=f.slice(0,-1).join("/"),u=f.pop()),u){const n=u.match(/^\d+/);n&&(u=n[0])}return d({host:s,pass:r,path:p,projectId:u,port:a,protocol:o,publicKey:e})}(n):d(n);if(t&&function(n){const{port:t,projectId:o,protocol:e}=n;return!(["protocol","publicKey","host","projectId"].find(t=>!n[t]&&(p.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(o.match(/^\d+$/)?function(n){return"http"===n||"https"===n}(e)?t&&isNaN(parseInt(t,10))&&(p.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(p.error(`Invalid Sentry Dsn: Invalid protocol ${e}`),1):(p.error(`Invalid Sentry Dsn: Invalid projectId ${o}`),1)))}(t))return t}function f(n,t,o){return`${function(n){return`${function(n){const t=n.protocol?`${n.protocol}:`:"",o=n.port?`:${n.port}`:"";return`${t}//${n.host}${o}${n.path?`/${n.path}`:""}/api/`}(n)}${n.projectId}/envelope/`}(n)}?${function(n){const t={sentry_version:"7"};return n.publicKey&&(t.sentry_key=n.publicKey),new URLSearchParams(t).toString()}(n)}`}class h{constructor(){this.t=`http://${process.env.AWS_LAMBDA_RUNTIME_API}/2020-01-01/extension`,this.o=null}async register(){const n=await fetch(`${this.t}/register`,{method:"POST",body:JSON.stringify({events:["INVOKE","SHUTDOWN"]}),headers:{"Content-Type":"application/json","Lambda-Extension-Name":"sentry-extension"}});if(!n.ok)throw new Error(`Failed to register with the extension API: ${await n.text()}`);this.o=n.headers.get("lambda-extension-identifier")}async next(){if(!this.o)throw new Error("Extension ID is not set");const n=await fetch(`${this.t}/event/next`,{headers:{"Lambda-Extension-Identifier":this.o,"Content-Type":"application/json"}});if(!n.ok)throw new Error(`Failed to advance to next event: ${await n.text()}`)}async error(n,t){if(!this.o)throw new Error("Extension ID is not set");const o=`Extension.${t.name||"UnknownError"}`,e=await fetch(`${this.t}/${n}/error`,{method:"POST",body:JSON.stringify({errorMessage:t.message||t.toString(),errorType:o,stackTrace:[t.stack]}),headers:{"Content-Type":"application/json","Lambda-Extension-Identifier":this.o,"Lambda-Extension-Function-Error":o}});throw e.ok||p.error(`Failed to report error: ${await e.text()}`),t}startSentryTunnel(){const o=function(){const n=process.env.SENTRY_DSN?.trim();return n?u(n):void 0}();o||i(()=>{console.warn("Sentry Lambda extension: SENTRY_DSN is not set or is invalid. The /envelope tunnel will forward any DSN in the envelope header without allowlist validation. Set SENTRY_DSN to the same DSN as your SDK to restrict outbound requests.")});const e=n.createServer(async(n,e)=>{if("POST"===n.method&&n.url?.startsWith("/envelope"))try{const r=await t(n),i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),s=(new TextDecoder).decode(i).split("\n")[0],a=JSON.parse(s||"{}").dsn;if(!a)return e.writeHead(400,{"Content-Type":"application/json"}),void e.end(JSON.stringify({error:"Invalid envelope: missing DSN"}));if(o&&function(n,t=!1){const{host:o,path:e,pass:r,port:i,projectId:s,protocol:a,publicKey:c}=n;return`${a}://${c}${t&&r?`:${r}`:""}@${o}${i?`:${i}`:""}/${e?`${e}/`:e}${s}`}(o)!==a)return p.warn(`Sentry Lambda extension tunnel: rejected request with unauthorized DSN (${a})`),e.writeHead(403,{"Content-Type":"application/json"}),void e.end(JSON.stringify({error:"DSN not allowed"}));const c=o||u(a);if(!c)return e.writeHead(403,{"Content-Type":"application/json"}),void e.end(JSON.stringify({error:"Invalid DSN"}));const l=f(c);fetch(l,{method:"POST",body:i}).catch(n=>{p.error("Error sending envelope to Sentry",n)}),e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({}))}catch(n){p.error("Error tunneling to Sentry",n),e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"Error tunneling to Sentry"}))}else e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"Not found"}))});e.listen(9e3,()=>{p.log("Sentry proxy listening on port 9000")}),e.on("error",n=>{p.error("Error starting Sentry proxy",n),process.exit(1)})}}(async function(){const n=new h;for(await n.register(),n.startSentryTunnel();;)await n.next()})().catch(n=>{p.error("Error in Lambda Extension",n)});
import*as n from"node:http";import{buffer as t}from"node:stream/consumers";const o=globalThis,e="10.52.0";const r={};function i(n){if(!("console"in o))return n();const t=o.console,e={},i=Object.keys(r);i.forEach(n=>{const o=r[n];e[n]=t[n],t[n]=o});try{return n()}finally{i.forEach(n=>{t[n]=e[n]})}}function s(){return c().enabled}function a(n,...t){s()&&i(()=>{o.console[n](`Sentry Logger [${n}]:`,...t)})}function c(){return function(n,t,r=o){const i=r.__SENTRY__=r.__SENTRY__||{},s=i[e]=i[e]||{};return s[n]||(s[n]=t())}("loggerSettings",()=>({enabled:!1}))}const p={enable:function(){c().enabled=!0},disable:function(){c().enabled=!1},isEnabled:s,log:function(...n){a("log",...n)},warn:function(...n){a("warn",...n)},error:function(...n){a("error",...n)}},l=/^(?:(\w+):)\/\/(?:(\w+)(?::(\w+)?)?@)((?:\[[:.%\w]+\]|[\w.-]+))(?::(\d+))?\/(.+)/;function d(n){return{protocol:n.protocol,publicKey:n.publicKey||"",pass:n.pass||"",host:n.host,port:n.port||"",path:n.path||"",projectId:n.projectId}}function u(n){const t="string"==typeof n?function(n){const t=l.exec(n);if(!t)return void i(()=>{console.error(`Invalid Sentry Dsn: ${n}`)});const[o,e,r="",s="",a="",c=""]=t.slice(1);let p="",u=c;const f=u.split("/");if(f.length>1&&(p=f.slice(0,-1).join("/"),u=f.pop()),u){const n=u.match(/^\d+/);n&&(u=n[0])}return d({host:s,pass:r,path:p,projectId:u,port:a,protocol:o,publicKey:e})}(n):d(n);if(t&&function(n){const{port:t,projectId:o,protocol:e}=n;return!(["protocol","publicKey","host","projectId"].find(t=>!n[t]&&(p.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(o.match(/^\d+$/)?function(n){return"http"===n||"https"===n}(e)?t&&isNaN(parseInt(t,10))&&(p.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(p.error(`Invalid Sentry Dsn: Invalid protocol ${e}`),1):(p.error(`Invalid Sentry Dsn: Invalid projectId ${o}`),1)))}(t))return t}function f(n,t,o){return`${function(n){return`${function(n){const t=n.protocol?`${n.protocol}:`:"",o=n.port?`:${n.port}`:"";return`${t}//${n.host}${o}${n.path?`/${n.path}`:""}/api/`}(n)}${n.projectId}/envelope/`}(n)}?${function(n){const t={sentry_version:"7"};return n.publicKey&&(t.sentry_key=n.publicKey),new URLSearchParams(t).toString()}(n)}`}class h{constructor(){this.t=`http://${process.env.AWS_LAMBDA_RUNTIME_API}/2020-01-01/extension`,this.o=null}async register(){const n=await fetch(`${this.t}/register`,{method:"POST",body:JSON.stringify({events:["INVOKE","SHUTDOWN"]}),headers:{"Content-Type":"application/json","Lambda-Extension-Name":"sentry-extension"}});if(!n.ok)throw new Error(`Failed to register with the extension API: ${await n.text()}`);this.o=n.headers.get("lambda-extension-identifier")}async next(){if(!this.o)throw new Error("Extension ID is not set");const n=await fetch(`${this.t}/event/next`,{headers:{"Lambda-Extension-Identifier":this.o,"Content-Type":"application/json"}});if(!n.ok)throw new Error(`Failed to advance to next event: ${await n.text()}`)}async error(n,t){if(!this.o)throw new Error("Extension ID is not set");const o=`Extension.${t.name||"UnknownError"}`,e=await fetch(`${this.t}/${n}/error`,{method:"POST",body:JSON.stringify({errorMessage:t.message||t.toString(),errorType:o,stackTrace:[t.stack]}),headers:{"Content-Type":"application/json","Lambda-Extension-Identifier":this.o,"Lambda-Extension-Function-Error":o}});throw e.ok||p.error(`Failed to report error: ${await e.text()}`),t}startSentryTunnel(){const o=function(){const n=process.env.SENTRY_DSN?.trim();return n?u(n):void 0}();o||i(()=>{console.warn("Sentry Lambda extension: SENTRY_DSN is not set or is invalid. The /envelope tunnel will forward any DSN in the envelope header without allowlist validation. Set SENTRY_DSN to the same DSN as your SDK to restrict outbound requests.")});const e=n.createServer(async(n,e)=>{if("POST"===n.method&&n.url?.startsWith("/envelope"))try{const r=await t(n),i=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),s=(new TextDecoder).decode(i).split("\n")[0],a=JSON.parse(s||"{}").dsn;if(!a)return e.writeHead(400,{"Content-Type":"application/json"}),void e.end(JSON.stringify({error:"Invalid envelope: missing DSN"}));if(o&&function(n,t=!1){const{host:o,path:e,pass:r,port:i,projectId:s,protocol:a,publicKey:c}=n;return`${a}://${c}${t&&r?`:${r}`:""}@${o}${i?`:${i}`:""}/${e?`${e}/`:e}${s}`}(o)!==a)return p.warn(`Sentry Lambda extension tunnel: rejected request with unauthorized DSN (${a})`),e.writeHead(403,{"Content-Type":"application/json"}),void e.end(JSON.stringify({error:"DSN not allowed"}));const c=o||u(a);if(!c)return e.writeHead(403,{"Content-Type":"application/json"}),void e.end(JSON.stringify({error:"Invalid DSN"}));const l=f(c);fetch(l,{method:"POST",body:i}).catch(n=>{p.error("Error sending envelope to Sentry",n)}),e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({}))}catch(n){p.error("Error tunneling to Sentry",n),e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"Error tunneling to Sentry"}))}else e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"Not found"}))});e.listen(9e3,()=>{p.log("Sentry proxy listening on port 9000")}),e.on("error",n=>{p.error("Error starting Sentry proxy",n),process.exit(1)})}}(async function(){const n=new h;for(await n.register(),n.startSentryTunnel();;)await n.next()})().catch(n=>{p.error("Error in Lambda Extension",n)});

@@ -1,1 +0,1 @@

{"type":"module","version":"10.51.0","sideEffects":false}
{"type":"module","version":"10.52.0","sideEffects":false}
{
"name": "@sentry/aws-serverless",
"version": "10.51.0",
"version": "10.52.0",
"description": "Official Sentry SDK for AWS Lambda and AWS Serverless Environments",

@@ -73,5 +73,5 @@ "repository": "git://github.com/getsentry/sentry-javascript.git",

"@opentelemetry/semantic-conventions": "^1.40.0",
"@sentry/core": "10.51.0",
"@sentry/node": "10.51.0",
"@sentry/node-core": "10.51.0",
"@sentry/core": "10.52.0",
"@sentry/node": "10.52.0",
"@sentry/node-core": "10.52.0",
"@types/aws-lambda": "^8.10.62"

@@ -78,0 +78,0 @@ },