@h4ad/serverless-adapter 3.0.0 → 3.1.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.
Files changed (436) hide show
  1. package/README.md +2 -2
  2. package/lib/@types/binary-settings.d.ts +41 -0
  3. package/lib/@types/binary-settings.d.ts.map +1 -0
  4. package/lib/@types/binary-settings.js +1 -1
  5. package/lib/@types/binary-settings.js.map +1 -1
  6. package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +37 -0
  7. package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +1 -0
  8. package/lib/@types/digital-ocean/digital-ocean-http-event.js +1 -1
  9. package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -1
  10. package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +22 -0
  11. package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +1 -0
  12. package/lib/@types/digital-ocean/digital-ocean-http-response.js +1 -1
  13. package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -1
  14. package/lib/@types/digital-ocean/index.d.ts +2 -0
  15. package/lib/@types/digital-ocean/index.d.ts.map +1 -0
  16. package/lib/@types/digital-ocean/index.js +1 -1
  17. package/lib/@types/digital-ocean/index.js.map +1 -1
  18. package/lib/@types/headers.d.ts +37 -0
  19. package/lib/@types/headers.d.ts.map +1 -0
  20. package/lib/@types/headers.js +1 -1
  21. package/lib/@types/headers.js.map +1 -1
  22. package/lib/@types/helpers.d.ts +10 -0
  23. package/lib/@types/helpers.d.ts.map +1 -0
  24. package/lib/@types/helpers.js +1 -1
  25. package/lib/@types/helpers.js.map +1 -1
  26. package/lib/@types/huawei/huawei-api-gateway-event.d.ts +81 -0
  27. package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +1 -0
  28. package/lib/@types/huawei/huawei-api-gateway-event.js +1 -1
  29. package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -1
  30. package/lib/@types/huawei/huawei-api-gateway-response.d.ts +27 -0
  31. package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +1 -0
  32. package/lib/@types/huawei/huawei-api-gateway-response.js +1 -1
  33. package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -1
  34. package/lib/@types/huawei/huawei-context.d.ts +188 -0
  35. package/lib/@types/huawei/huawei-context.d.ts.map +1 -0
  36. package/lib/@types/huawei/huawei-context.js +1 -1
  37. package/lib/@types/huawei/huawei-context.js.map +1 -1
  38. package/lib/@types/huawei/index.d.ts +4 -0
  39. package/lib/@types/huawei/index.d.ts.map +1 -0
  40. package/lib/@types/huawei/index.js +1 -1
  41. package/lib/@types/huawei/index.js.map +1 -1
  42. package/lib/@types/index.d.ts +4 -0
  43. package/lib/@types/index.d.ts.map +1 -0
  44. package/lib/@types/index.js +1 -1
  45. package/lib/@types/index.js.map +1 -1
  46. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +56 -0
  47. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts.map +1 -0
  48. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +1 -1
  49. package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -1
  50. package/lib/adapters/apollo-server/index.d.ts +2 -0
  51. package/lib/adapters/apollo-server/index.d.ts.map +1 -0
  52. package/lib/adapters/apollo-server/index.js +1 -1
  53. package/lib/adapters/apollo-server/index.js.map +1 -1
  54. package/lib/adapters/aws/alb.adapter.d.ts +71 -0
  55. package/lib/adapters/aws/alb.adapter.d.ts.map +1 -0
  56. package/lib/adapters/aws/alb.adapter.js +1 -1
  57. package/lib/adapters/aws/alb.adapter.js.map +1 -1
  58. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +76 -0
  59. package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +1 -0
  60. package/lib/adapters/aws/api-gateway-v1.adapter.js +1 -1
  61. package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -1
  62. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +75 -0
  63. package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +1 -0
  64. package/lib/adapters/aws/api-gateway-v2.adapter.js +1 -1
  65. package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -1
  66. package/lib/adapters/aws/base/aws-simple-adapter.d.ts +83 -0
  67. package/lib/adapters/aws/base/aws-simple-adapter.d.ts.map +1 -0
  68. package/lib/adapters/aws/base/aws-simple-adapter.js +1 -1
  69. package/lib/adapters/aws/base/aws-simple-adapter.js.map +1 -1
  70. package/lib/adapters/aws/base/index.d.ts +2 -0
  71. package/lib/adapters/aws/base/index.d.ts.map +1 -0
  72. package/lib/adapters/aws/base/index.js +1 -1
  73. package/lib/adapters/aws/base/index.js.map +1 -1
  74. package/lib/adapters/aws/dynamodb.adapter.d.ts +56 -0
  75. package/lib/adapters/aws/dynamodb.adapter.d.ts.map +1 -0
  76. package/lib/adapters/aws/dynamodb.adapter.js +1 -1
  77. package/lib/adapters/aws/dynamodb.adapter.js.map +1 -1
  78. package/lib/adapters/aws/event-bridge.adapter.d.ts +63 -0
  79. package/lib/adapters/aws/event-bridge.adapter.d.ts.map +1 -0
  80. package/lib/adapters/aws/event-bridge.adapter.js +1 -1
  81. package/lib/adapters/aws/event-bridge.adapter.js.map +1 -1
  82. package/lib/adapters/aws/index.d.ts +12 -0
  83. package/lib/adapters/aws/index.d.ts.map +1 -0
  84. package/lib/adapters/aws/index.js +1 -1
  85. package/lib/adapters/aws/index.js.map +1 -1
  86. package/lib/adapters/aws/lambda-edge.adapter.d.ts +209 -0
  87. package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +1 -0
  88. package/lib/adapters/aws/lambda-edge.adapter.js +1 -1
  89. package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -1
  90. package/lib/adapters/aws/request-lambda-edge.adapter.d.ts +131 -0
  91. package/lib/adapters/aws/request-lambda-edge.adapter.d.ts.map +1 -0
  92. package/lib/adapters/aws/request-lambda-edge.adapter.js +2 -0
  93. package/lib/adapters/aws/request-lambda-edge.adapter.js.map +1 -0
  94. package/lib/adapters/aws/s3.adapter.d.ts +56 -0
  95. package/lib/adapters/aws/s3.adapter.d.ts.map +1 -0
  96. package/lib/adapters/aws/s3.adapter.js +1 -1
  97. package/lib/adapters/aws/s3.adapter.js.map +1 -1
  98. package/lib/adapters/aws/sns.adapter.d.ts +56 -0
  99. package/lib/adapters/aws/sns.adapter.d.ts.map +1 -0
  100. package/lib/adapters/aws/sns.adapter.js +1 -1
  101. package/lib/adapters/aws/sns.adapter.js.map +1 -1
  102. package/lib/adapters/aws/sqs.adapter.d.ts +56 -0
  103. package/lib/adapters/aws/sqs.adapter.d.ts.map +1 -0
  104. package/lib/adapters/aws/sqs.adapter.js +1 -1
  105. package/lib/adapters/aws/sqs.adapter.js.map +1 -1
  106. package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +81 -0
  107. package/lib/adapters/azure/http-trigger-v4.adapter.d.ts.map +1 -0
  108. package/lib/adapters/azure/http-trigger-v4.adapter.js +1 -1
  109. package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
  110. package/lib/adapters/azure/index.d.ts +2 -0
  111. package/lib/adapters/azure/index.d.ts.map +1 -0
  112. package/lib/adapters/azure/index.js +1 -1
  113. package/lib/adapters/azure/index.js.map +1 -1
  114. package/lib/adapters/digital-ocean/http-function.adapter.d.ts +65 -0
  115. package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +1 -0
  116. package/lib/adapters/digital-ocean/http-function.adapter.js +1 -1
  117. package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -1
  118. package/lib/adapters/digital-ocean/index.d.ts +2 -0
  119. package/lib/adapters/digital-ocean/index.d.ts.map +1 -0
  120. package/lib/adapters/digital-ocean/index.js +1 -1
  121. package/lib/adapters/digital-ocean/index.js.map +1 -1
  122. package/lib/adapters/dummy/dummy.adapter.d.ts +31 -0
  123. package/lib/adapters/dummy/dummy.adapter.d.ts.map +1 -0
  124. package/lib/adapters/dummy/dummy.adapter.js +1 -1
  125. package/lib/adapters/dummy/dummy.adapter.js.map +1 -1
  126. package/lib/adapters/dummy/index.d.ts +2 -0
  127. package/lib/adapters/dummy/index.d.ts.map +1 -0
  128. package/lib/adapters/dummy/index.js +1 -1
  129. package/lib/adapters/dummy/index.js.map +1 -1
  130. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +66 -0
  131. package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +1 -0
  132. package/lib/adapters/huawei/huawei-api-gateway.adapter.js +1 -1
  133. package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -1
  134. package/lib/adapters/huawei/index.d.ts +2 -0
  135. package/lib/adapters/huawei/index.d.ts.map +1 -0
  136. package/lib/adapters/huawei/index.js +1 -1
  137. package/lib/adapters/huawei/index.js.map +1 -1
  138. package/lib/contracts/adapter.contract.d.ts +152 -0
  139. package/lib/contracts/adapter.contract.d.ts.map +1 -0
  140. package/lib/contracts/adapter.contract.js +1 -1
  141. package/lib/contracts/adapter.contract.js.map +1 -1
  142. package/lib/contracts/framework.contract.d.ts +19 -0
  143. package/lib/contracts/framework.contract.d.ts.map +1 -0
  144. package/lib/contracts/framework.contract.js +1 -1
  145. package/lib/contracts/framework.contract.js.map +1 -1
  146. package/lib/contracts/handler.contract.d.ts +25 -0
  147. package/lib/contracts/handler.contract.d.ts.map +1 -0
  148. package/lib/contracts/handler.contract.js +1 -1
  149. package/lib/contracts/handler.contract.js.map +1 -1
  150. package/lib/contracts/index.d.ts +5 -0
  151. package/lib/contracts/index.d.ts.map +1 -0
  152. package/lib/contracts/index.js +1 -1
  153. package/lib/contracts/index.js.map +1 -1
  154. package/lib/contracts/resolver.contract.d.ts +83 -0
  155. package/lib/contracts/resolver.contract.d.ts.map +1 -0
  156. package/lib/contracts/resolver.contract.js +1 -1
  157. package/lib/contracts/resolver.contract.js.map +1 -1
  158. package/lib/core/base-handler.d.ts +32 -0
  159. package/lib/core/base-handler.d.ts.map +1 -0
  160. package/lib/core/base-handler.js +1 -1
  161. package/lib/core/base-handler.js.map +1 -1
  162. package/lib/core/constants.d.ts +31 -0
  163. package/lib/core/constants.d.ts.map +1 -0
  164. package/lib/core/constants.js +1 -1
  165. package/lib/core/constants.js.map +1 -1
  166. package/lib/core/current-invoke.d.ts +48 -0
  167. package/lib/core/current-invoke.d.ts.map +1 -0
  168. package/lib/core/current-invoke.js +1 -1
  169. package/lib/core/current-invoke.js.map +1 -1
  170. package/lib/core/event-body.d.ts +22 -0
  171. package/lib/core/event-body.d.ts.map +1 -0
  172. package/lib/core/event-body.js +1 -1
  173. package/lib/core/event-body.js.map +1 -1
  174. package/lib/core/headers.d.ts +73 -0
  175. package/lib/core/headers.d.ts.map +1 -0
  176. package/lib/core/headers.js +2 -2
  177. package/lib/core/headers.js.map +1 -1
  178. package/lib/core/index.d.ts +12 -0
  179. package/lib/core/index.d.ts.map +1 -0
  180. package/lib/core/index.js +1 -1
  181. package/lib/core/index.js.map +1 -1
  182. package/lib/core/is-binary.d.ts +73 -0
  183. package/lib/core/is-binary.d.ts.map +1 -0
  184. package/lib/core/is-binary.js +1 -1
  185. package/lib/core/is-binary.js.map +1 -1
  186. package/lib/core/logger.d.ts +64 -0
  187. package/lib/core/logger.d.ts.map +1 -0
  188. package/lib/core/logger.js +1 -1
  189. package/lib/core/logger.js.map +1 -1
  190. package/lib/core/no-op.d.ts +8 -0
  191. package/lib/core/no-op.d.ts.map +1 -0
  192. package/lib/core/no-op.js +1 -1
  193. package/lib/core/no-op.js.map +1 -1
  194. package/lib/core/optional.d.ts +22 -0
  195. package/lib/core/optional.d.ts.map +1 -0
  196. package/lib/core/optional.js +1 -1
  197. package/lib/core/optional.js.map +1 -1
  198. package/lib/core/path.d.ts +53 -0
  199. package/lib/core/path.d.ts.map +1 -0
  200. package/lib/core/path.js +1 -1
  201. package/lib/core/path.js.map +1 -1
  202. package/lib/core/stream.d.ts +21 -0
  203. package/lib/core/stream.d.ts.map +1 -0
  204. package/lib/core/stream.js +1 -1
  205. package/lib/core/stream.js.map +1 -1
  206. package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +69 -0
  207. package/lib/frameworks/apollo-server/apollo-server.framework.d.ts.map +1 -0
  208. package/lib/frameworks/apollo-server/apollo-server.framework.js +1 -1
  209. package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -1
  210. package/lib/frameworks/apollo-server/index.d.ts +2 -0
  211. package/lib/frameworks/apollo-server/index.d.ts.map +1 -0
  212. package/lib/frameworks/apollo-server/index.js +1 -1
  213. package/lib/frameworks/apollo-server/index.js.map +1 -1
  214. package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +69 -0
  215. package/lib/frameworks/body-parser/base-body-parser.framework.d.ts.map +1 -0
  216. package/lib/frameworks/body-parser/base-body-parser.framework.js +1 -1
  217. package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -1
  218. package/lib/frameworks/body-parser/index.d.ts +6 -0
  219. package/lib/frameworks/body-parser/index.d.ts.map +1 -0
  220. package/lib/frameworks/body-parser/index.js +1 -1
  221. package/lib/frameworks/body-parser/index.js.map +1 -1
  222. package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +26 -0
  223. package/lib/frameworks/body-parser/json-body-parser.framework.d.ts.map +1 -0
  224. package/lib/frameworks/body-parser/json-body-parser.framework.js +1 -1
  225. package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -1
  226. package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +26 -0
  227. package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts.map +1 -0
  228. package/lib/frameworks/body-parser/raw-body-parser.framework.js +1 -1
  229. package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -1
  230. package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +26 -0
  231. package/lib/frameworks/body-parser/text-body-parser.framework.d.ts.map +1 -0
  232. package/lib/frameworks/body-parser/text-body-parser.framework.js +1 -1
  233. package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -1
  234. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +26 -0
  235. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts.map +1 -0
  236. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +1 -1
  237. package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -1
  238. package/lib/frameworks/cors/cors.framework.d.ts +78 -0
  239. package/lib/frameworks/cors/cors.framework.d.ts.map +1 -0
  240. package/lib/frameworks/cors/cors.framework.js +2 -2
  241. package/lib/frameworks/cors/cors.framework.js.map +1 -1
  242. package/lib/frameworks/cors/index.d.ts +2 -0
  243. package/lib/frameworks/cors/index.d.ts.map +1 -0
  244. package/lib/frameworks/cors/index.js +1 -1
  245. package/lib/frameworks/cors/index.js.map +1 -1
  246. package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +18 -0
  247. package/lib/frameworks/deepkit/http-deepkit.framework.d.ts.map +1 -0
  248. package/lib/frameworks/deepkit/http-deepkit.framework.js +1 -1
  249. package/lib/frameworks/deepkit/http-deepkit.framework.js.map +1 -1
  250. package/lib/frameworks/deepkit/index.d.ts +2 -0
  251. package/lib/frameworks/deepkit/index.d.ts.map +1 -0
  252. package/lib/frameworks/deepkit/index.js +1 -1
  253. package/lib/frameworks/deepkit/index.js.map +1 -1
  254. package/lib/frameworks/express/express.framework.d.ts +17 -0
  255. package/lib/frameworks/express/express.framework.d.ts.map +1 -0
  256. package/lib/frameworks/express/express.framework.js +1 -1
  257. package/lib/frameworks/express/express.framework.js.map +1 -1
  258. package/lib/frameworks/express/index.d.ts +2 -0
  259. package/lib/frameworks/express/index.d.ts.map +1 -0
  260. package/lib/frameworks/express/index.js +1 -1
  261. package/lib/frameworks/express/index.js.map +1 -1
  262. package/lib/frameworks/fastify/fastify.framework.d.ts +17 -0
  263. package/lib/frameworks/fastify/fastify.framework.d.ts.map +1 -0
  264. package/lib/frameworks/fastify/fastify.framework.js +1 -1
  265. package/lib/frameworks/fastify/fastify.framework.js.map +1 -1
  266. package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +14 -0
  267. package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts.map +1 -0
  268. package/lib/frameworks/fastify/helpers/no-op-content-parser.js +1 -1
  269. package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -1
  270. package/lib/frameworks/fastify/index.d.ts +2 -0
  271. package/lib/frameworks/fastify/index.d.ts.map +1 -0
  272. package/lib/frameworks/fastify/index.js +1 -1
  273. package/lib/frameworks/fastify/index.js.map +1 -1
  274. package/lib/frameworks/hapi/hapi.framework.d.ts +17 -0
  275. package/lib/frameworks/hapi/hapi.framework.d.ts.map +1 -0
  276. package/lib/frameworks/hapi/hapi.framework.js +1 -1
  277. package/lib/frameworks/hapi/hapi.framework.js.map +1 -1
  278. package/lib/frameworks/hapi/index.d.ts +2 -0
  279. package/lib/frameworks/hapi/index.d.ts.map +1 -0
  280. package/lib/frameworks/hapi/index.js +1 -1
  281. package/lib/frameworks/hapi/index.js.map +1 -1
  282. package/lib/frameworks/koa/index.d.ts +2 -0
  283. package/lib/frameworks/koa/index.d.ts.map +1 -0
  284. package/lib/frameworks/koa/index.js +1 -1
  285. package/lib/frameworks/koa/index.js.map +1 -1
  286. package/lib/frameworks/koa/koa.framework.d.ts +17 -0
  287. package/lib/frameworks/koa/koa.framework.d.ts.map +1 -0
  288. package/lib/frameworks/koa/koa.framework.js +1 -1
  289. package/lib/frameworks/koa/koa.framework.js.map +1 -1
  290. package/lib/frameworks/lazy/index.d.ts +2 -0
  291. package/lib/frameworks/lazy/index.d.ts.map +1 -0
  292. package/lib/frameworks/lazy/index.js +1 -1
  293. package/lib/frameworks/lazy/index.js.map +1 -1
  294. package/lib/frameworks/lazy/lazy.framework.d.ts +56 -0
  295. package/lib/frameworks/lazy/lazy.framework.d.ts.map +1 -0
  296. package/lib/frameworks/lazy/lazy.framework.js +1 -1
  297. package/lib/frameworks/lazy/lazy.framework.js.map +1 -1
  298. package/lib/frameworks/trpc/index.d.ts +2 -0
  299. package/lib/frameworks/trpc/index.d.ts.map +1 -0
  300. package/lib/frameworks/trpc/index.js +1 -1
  301. package/lib/frameworks/trpc/index.js.map +1 -1
  302. package/lib/frameworks/trpc/trpc.framework.d.ts +153 -0
  303. package/lib/frameworks/trpc/trpc.framework.d.ts.map +1 -0
  304. package/lib/frameworks/trpc/trpc.framework.js +1 -1
  305. package/lib/frameworks/trpc/trpc.framework.js.map +1 -1
  306. package/lib/handlers/aws/aws-stream.handler.d.ts +89 -0
  307. package/lib/handlers/aws/aws-stream.handler.d.ts.map +1 -0
  308. package/lib/handlers/aws/aws-stream.handler.js +1 -1
  309. package/lib/handlers/aws/aws-stream.handler.js.map +1 -1
  310. package/lib/handlers/aws/index.d.ts +2 -0
  311. package/lib/handlers/aws/index.d.ts.map +1 -0
  312. package/lib/handlers/aws/index.js +1 -1
  313. package/lib/handlers/aws/index.js.map +1 -1
  314. package/lib/handlers/azure/azure.handler.d.ts +45 -0
  315. package/lib/handlers/azure/azure.handler.d.ts.map +1 -0
  316. package/lib/handlers/azure/azure.handler.js +1 -1
  317. package/lib/handlers/azure/azure.handler.js.map +1 -1
  318. package/lib/handlers/azure/index.d.ts +2 -0
  319. package/lib/handlers/azure/index.d.ts.map +1 -0
  320. package/lib/handlers/azure/index.js +1 -1
  321. package/lib/handlers/azure/index.js.map +1 -1
  322. package/lib/handlers/base/index.d.ts +2 -0
  323. package/lib/handlers/base/index.d.ts.map +1 -0
  324. package/lib/handlers/base/index.js +1 -1
  325. package/lib/handlers/base/index.js.map +1 -1
  326. package/lib/handlers/base/raw-request.d.ts +31 -0
  327. package/lib/handlers/base/raw-request.d.ts.map +1 -0
  328. package/lib/handlers/base/raw-request.js +1 -1
  329. package/lib/handlers/base/raw-request.js.map +1 -1
  330. package/lib/handlers/default/default.handler.d.ts +88 -0
  331. package/lib/handlers/default/default.handler.d.ts.map +1 -0
  332. package/lib/handlers/default/default.handler.js +1 -1
  333. package/lib/handlers/default/default.handler.js.map +1 -1
  334. package/lib/handlers/default/index.d.ts +2 -0
  335. package/lib/handlers/default/index.d.ts.map +1 -0
  336. package/lib/handlers/default/index.js +1 -1
  337. package/lib/handlers/default/index.js.map +1 -1
  338. package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +17 -0
  339. package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +1 -0
  340. package/lib/handlers/digital-ocean/digital-ocean.handler.js +1 -1
  341. package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -1
  342. package/lib/handlers/digital-ocean/index.d.ts +2 -0
  343. package/lib/handlers/digital-ocean/index.d.ts.map +1 -0
  344. package/lib/handlers/digital-ocean/index.js +1 -1
  345. package/lib/handlers/digital-ocean/index.js.map +1 -1
  346. package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +27 -0
  347. package/lib/handlers/firebase/http-firebase-v2.handler.d.ts.map +1 -0
  348. package/lib/handlers/firebase/http-firebase-v2.handler.js +1 -1
  349. package/lib/handlers/firebase/http-firebase-v2.handler.js.map +1 -1
  350. package/lib/handlers/firebase/http-firebase.handler.d.ts +19 -0
  351. package/lib/handlers/firebase/http-firebase.handler.d.ts.map +1 -0
  352. package/lib/handlers/firebase/http-firebase.handler.js +1 -1
  353. package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
  354. package/lib/handlers/firebase/index.d.ts +3 -0
  355. package/lib/handlers/firebase/index.d.ts.map +1 -0
  356. package/lib/handlers/firebase/index.js +1 -1
  357. package/lib/handlers/firebase/index.js.map +1 -1
  358. package/lib/handlers/gcp/gcp.handler.d.ts +26 -0
  359. package/lib/handlers/gcp/gcp.handler.d.ts.map +1 -0
  360. package/lib/handlers/gcp/gcp.handler.js +1 -1
  361. package/lib/handlers/gcp/gcp.handler.js.map +1 -1
  362. package/lib/handlers/gcp/index.d.ts +2 -0
  363. package/lib/handlers/gcp/index.d.ts.map +1 -0
  364. package/lib/handlers/gcp/index.js +1 -1
  365. package/lib/handlers/gcp/index.js.map +1 -1
  366. package/lib/handlers/huawei/http-huawei.handler.d.ts +59 -0
  367. package/lib/handlers/huawei/http-huawei.handler.d.ts.map +1 -0
  368. package/lib/handlers/huawei/http-huawei.handler.js +1 -1
  369. package/lib/handlers/huawei/http-huawei.handler.js.map +1 -1
  370. package/lib/handlers/huawei/index.d.ts +2 -0
  371. package/lib/handlers/huawei/index.d.ts.map +1 -0
  372. package/lib/handlers/huawei/index.js +1 -1
  373. package/lib/handlers/huawei/index.js.map +1 -1
  374. package/lib/index.d.ts +6 -0
  375. package/lib/index.d.ts.map +1 -0
  376. package/lib/index.doc.js +1 -1
  377. package/lib/index.doc.js.map +1 -1
  378. package/lib/index.js +1 -1
  379. package/lib/index.js.map +1 -1
  380. package/lib/network/index.d.ts +5 -0
  381. package/lib/network/index.d.ts.map +1 -0
  382. package/lib/network/index.js +1 -1
  383. package/lib/network/index.js.map +1 -1
  384. package/lib/network/request.d.ts +44 -0
  385. package/lib/network/request.d.ts.map +1 -0
  386. package/lib/network/request.js +1 -1
  387. package/lib/network/request.js.map +1 -1
  388. package/lib/network/response-stream.d.ts +41 -0
  389. package/lib/network/response-stream.d.ts.map +1 -0
  390. package/lib/network/response-stream.js +4 -4
  391. package/lib/network/response-stream.js.map +1 -1
  392. package/lib/network/response.d.ts +48 -0
  393. package/lib/network/response.d.ts.map +1 -0
  394. package/lib/network/response.js +2 -2
  395. package/lib/network/response.js.map +1 -1
  396. package/lib/network/utils.d.ts +9 -0
  397. package/lib/network/utils.d.ts.map +1 -0
  398. package/lib/network/utils.js +1 -1
  399. package/lib/network/utils.js.map +1 -1
  400. package/lib/resolvers/aws-context/aws-context.resolver.d.ts +19 -0
  401. package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +1 -0
  402. package/lib/resolvers/aws-context/aws-context.resolver.js +1 -1
  403. package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -1
  404. package/lib/resolvers/aws-context/index.d.ts +2 -0
  405. package/lib/resolvers/aws-context/index.d.ts.map +1 -0
  406. package/lib/resolvers/aws-context/index.js +1 -1
  407. package/lib/resolvers/aws-context/index.js.map +1 -1
  408. package/lib/resolvers/callback/callback.resolver.d.ts +23 -0
  409. package/lib/resolvers/callback/callback.resolver.d.ts.map +1 -0
  410. package/lib/resolvers/callback/callback.resolver.js +1 -1
  411. package/lib/resolvers/callback/callback.resolver.js.map +1 -1
  412. package/lib/resolvers/callback/index.d.ts +2 -0
  413. package/lib/resolvers/callback/index.d.ts.map +1 -0
  414. package/lib/resolvers/callback/index.js +1 -1
  415. package/lib/resolvers/callback/index.js.map +1 -1
  416. package/lib/resolvers/dummy/dummy.resolver.d.ts +14 -0
  417. package/lib/resolvers/dummy/dummy.resolver.d.ts.map +1 -0
  418. package/lib/resolvers/dummy/dummy.resolver.js +1 -1
  419. package/lib/resolvers/dummy/dummy.resolver.js.map +1 -1
  420. package/lib/resolvers/dummy/index.d.ts +2 -0
  421. package/lib/resolvers/dummy/index.d.ts.map +1 -0
  422. package/lib/resolvers/dummy/index.js +1 -1
  423. package/lib/resolvers/dummy/index.js.map +1 -1
  424. package/lib/resolvers/promise/index.d.ts +2 -0
  425. package/lib/resolvers/promise/index.d.ts.map +1 -0
  426. package/lib/resolvers/promise/index.js +1 -1
  427. package/lib/resolvers/promise/index.js.map +1 -1
  428. package/lib/resolvers/promise/promise.resolver.d.ts +14 -0
  429. package/lib/resolvers/promise/promise.resolver.d.ts.map +1 -0
  430. package/lib/resolvers/promise/promise.resolver.js +1 -1
  431. package/lib/resolvers/promise/promise.resolver.js.map +1 -1
  432. package/lib/serverless-adapter.d.ts +119 -0
  433. package/lib/serverless-adapter.d.ts.map +1 -0
  434. package/lib/serverless-adapter.js +1 -1
  435. package/lib/serverless-adapter.js.map +1 -1
  436. package/package.json +2 -3
@@ -0,0 +1,63 @@
1
+ import type { EventBridgeEvent } from 'aws-lambda';
2
+ import { AwsSimpleAdapter } from './base/index';
3
+ /**
4
+ * The options to customize the {@link EventBridgeAdapter}
5
+ *
6
+ * @breadcrumb Adapters / AWS / EventBridgeAdapter
7
+ * @public
8
+ */
9
+ export interface EventBridgeOptions {
10
+ /**
11
+ * The path that will be used to create a request to be forwarded to the framework.
12
+ *
13
+ * @defaultValue /eventbridge
14
+ */
15
+ eventBridgeForwardPath?: string;
16
+ /**
17
+ * The http method that will be used to create a request to be forwarded to the framework.
18
+ *
19
+ * @defaultValue POST
20
+ */
21
+ eventBridgeForwardMethod?: string;
22
+ }
23
+ /**
24
+ * Just a type alias to ignore generic types in the event
25
+ *
26
+ * @breadcrumb Adapters / AWS / EventBridgeAdapter
27
+ * @public
28
+ */
29
+ export type EventBridgeEventAll = EventBridgeEvent<any, any>;
30
+ /**
31
+ * The adapter to handle requests from AWS EventBridge (Cloudwatch Events).
32
+ *
33
+ * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.
34
+ *
35
+ * {@link https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html | Event Reference}
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * const eventBridgeForwardPath = '/your/route/eventbridge'; // default /eventbridge
40
+ * const eventBridgeForwardMethod = 'POST'; // default POST
41
+ * const adapter = new EventBridgeAdapter({ eventBridgeForwardPath, eventBridgeForwardMethod });
42
+ * ```
43
+ *
44
+ * @breadcrumb Adapters / AWS / EventBridgeAdapter
45
+ * @public
46
+ */
47
+ export declare class EventBridgeAdapter extends AwsSimpleAdapter<EventBridgeEventAll> {
48
+ /**
49
+ * Default constructor
50
+ *
51
+ * @param options - The options to customize the {@link EventBridgeAdapter}
52
+ */
53
+ constructor(options?: EventBridgeOptions);
54
+ /**
55
+ * {@inheritDoc}
56
+ */
57
+ getAdapterName(): string;
58
+ /**
59
+ * {@inheritDoc}
60
+ */
61
+ canHandle(event: unknown): event is EventBridgeEventAll;
62
+ }
63
+ //# sourceMappingURL=event-bridge.adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-bridge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/event-bridge.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB,CAAC,mBAAmB,CAAC;IAG3E;;;;OAIG;gBACS,OAAO,CAAC,EAAE,kBAAkB;IAmBxC;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB;CAuB/D"}
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,v=Object.prototype.hasOwnProperty,_=(t,r)=>{for(var e in r)n(t,e,{get:r[e],enumerable:!0})},p=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of u(r))!v.call(t,a)&&a!==e&&n(t,a,{get:()=>r[a],enumerable:!(o=i(r,a))||o.enumerable});return t},g=t=>p(n({},"__esModule",{value:!0}),t),s={};_(s,{EventBridgeAdapter:()=>d});module.exports=g(s);var c=require("../../core"),l=require("./base/index");class d extends l.AwsSimpleAdapter{constructor(r){super({forwardPath:(0,c.getDefaultIfUndefined)(r==null?void 0:r.eventBridgeForwardPath,"/eventbridge"),forwardMethod:(0,c.getDefaultIfUndefined)(r==null?void 0:r.eventBridgeForwardMethod,"POST"),batch:!1,host:"events.amazonaws.com"})}getAdapterName(){return d.name}canHandle(r){const e=r;return!!(e&&e.version&&e.version==="0"&&e.id&&e["detail-type"]&&e.source&&e.account&&e.time&&e.region&&e.resources&&Array.isArray(e.resources)&&e.detail&&typeof e.detail=="object"&&!Array.isArray(e.detail))}}
1
+ "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),event_bridge_adapter_exports={};__export(event_bridge_adapter_exports,{EventBridgeAdapter:()=>EventBridgeAdapter});module.exports=__toCommonJS(event_bridge_adapter_exports);var import_core=require("../../core"),import_base=require("./base/index");class EventBridgeAdapter extends import_base.AwsSimpleAdapter{constructor(options){super({forwardPath:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.eventBridgeForwardPath,"/eventbridge"),forwardMethod:(0,import_core.getDefaultIfUndefined)(options==null?void 0:options.eventBridgeForwardMethod,"POST"),batch:!1,host:"events.amazonaws.com"})}getAdapterName(){return EventBridgeAdapter.name}canHandle(event){const eventBridgeEvent=event;return!!(eventBridgeEvent&&eventBridgeEvent.version&&eventBridgeEvent.version==="0"&&eventBridgeEvent.id&&eventBridgeEvent["detail-type"]&&eventBridgeEvent.source&&eventBridgeEvent.account&&eventBridgeEvent.time&&eventBridgeEvent.region&&eventBridgeEvent.resources&&Array.isArray(eventBridgeEvent.resources)&&eventBridgeEvent.detail&&typeof eventBridgeEvent.detail=="object"&&!Array.isArray(eventBridgeEvent.detail))}}
2
2
  //# sourceMappingURL=event-bridge.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-bridge.adapter.js","sources":["../../../src/adapters/aws/event-bridge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { EventBridgeEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link EventBridgeAdapter}\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport interface EventBridgeOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /eventbridge\n */\n eventBridgeForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n eventBridgeForwardMethod?: string;\n}\n\n/**\n * Just a type alias to ignore generic types in the event\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport type EventBridgeEventAll = EventBridgeEvent<any, any>;\n\n/**\n * The adapter to handle requests from AWS EventBridge (Cloudwatch Events).\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html | Event Reference}\n *\n * @example\n * ```typescript\n * const eventBridgeForwardPath = '/your/route/eventbridge'; // default /eventbridge\n * const eventBridgeForwardMethod = 'POST'; // default POST\n * const adapter = new EventBridgeAdapter({ eventBridgeForwardPath, eventBridgeForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport class EventBridgeAdapter extends AwsSimpleAdapter<EventBridgeEventAll> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link EventBridgeAdapter}\n */\n constructor(options?: EventBridgeOptions) {\n super({\n forwardPath: getDefaultIfUndefined(\n options?.eventBridgeForwardPath,\n '/eventbridge',\n ),\n forwardMethod: getDefaultIfUndefined(\n options?.eventBridgeForwardMethod,\n 'POST',\n ),\n batch: false,\n host: 'events.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return EventBridgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is EventBridgeEventAll {\n const eventBridgeEvent = event as Partial<EventBridgeEventAll>;\n\n // thanks to @cnuss in https://github.com/vendia/serverless-express/blob/b5da6070b8dd2fb674c1f7035dd7edfef1dc83a2/src/event-sources/utils.js#L87\n return !!(\n eventBridgeEvent &&\n eventBridgeEvent.version &&\n eventBridgeEvent.version === '0' &&\n eventBridgeEvent.id &&\n eventBridgeEvent['detail-type'] &&\n eventBridgeEvent.source &&\n eventBridgeEvent.account &&\n eventBridgeEvent.time &&\n eventBridgeEvent.region &&\n eventBridgeEvent.resources &&\n Array.isArray(eventBridgeEvent.resources) &&\n eventBridgeEvent.detail &&\n typeof eventBridgeEvent.detail === 'object' &&\n !Array.isArray(eventBridgeEvent.detail)\n );\n }\n\n //#endregion\n}\n"],"names":["event_bridge_adapter_exports","__export","EventBridgeAdapter","__toCommonJS","import_core","import_base","options","event","eventBridgeEvent"],"mappings":"qZAAAA,EAAA,CAAA,EAAAC,EAAAD,EAAA,CAAA,mBAAA,IAAAE,CAAA,CAAA,EAAA,OAAA,QAAAC,EAAAH,CAAA,EAGA,IAAsCI,EAAA,QAAA,YAAA,EACLC,EAAA,QAAA,cAAA,EAmD1B,MAAMH,UAA2BG,EAAsC,gBAAA,CAQ5E,YAAYC,EAA8B,CAClC,MAAA,CACJ,eAAaF,EAAA,uBACXE,GAAA,YAAAA,EAAS,uBACT,cACF,EACA,iBAAeF,EAAA,uBACbE,GAAA,YAAAA,EAAS,yBACT,MACF,EACA,MAAO,GACP,KAAM,sBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAOJ,EAAmB,IAC5B,CAKO,UAAUK,EAA8C,CAC7D,MAAMC,EAAmBD,EAGzB,MAAO,CAAC,EACNC,GACAA,EAAiB,SACjBA,EAAiB,UAAY,KAC7BA,EAAiB,IACjBA,EAAiB,aAAa,GAC9BA,EAAiB,QACjBA,EAAiB,SACjBA,EAAiB,MACjBA,EAAiB,QACjBA,EAAiB,WACjB,MAAM,QAAQA,EAAiB,SAAS,GACxCA,EAAiB,QACjB,OAAOA,EAAiB,QAAW,UACnC,CAAC,MAAM,QAAQA,EAAiB,MAAM,EAE1C,CAGF"}
1
+ {"version":3,"file":"event-bridge.adapter.js","sources":["../../../src/adapters/aws/event-bridge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { EventBridgeEvent } from 'aws-lambda';\nimport { getDefaultIfUndefined } from '../../core';\nimport { AwsSimpleAdapter } from './base/index';\n\n//#endregion\n\n/**\n * The options to customize the {@link EventBridgeAdapter}\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport interface EventBridgeOptions {\n /**\n * The path that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue /eventbridge\n */\n eventBridgeForwardPath?: string;\n\n /**\n * The http method that will be used to create a request to be forwarded to the framework.\n *\n * @defaultValue POST\n */\n eventBridgeForwardMethod?: string;\n}\n\n/**\n * Just a type alias to ignore generic types in the event\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport type EventBridgeEventAll = EventBridgeEvent<any, any>;\n\n/**\n * The adapter to handle requests from AWS EventBridge (Cloudwatch Events).\n *\n * The option of `responseWithErrors` is ignored by this adapter and we always call `resolver.fail` with the error.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/services-cloudwatchevents.html | Event Reference}\n *\n * @example\n * ```typescript\n * const eventBridgeForwardPath = '/your/route/eventbridge'; // default /eventbridge\n * const eventBridgeForwardMethod = 'POST'; // default POST\n * const adapter = new EventBridgeAdapter({ eventBridgeForwardPath, eventBridgeForwardMethod });\n * ```\n *\n * @breadcrumb Adapters / AWS / EventBridgeAdapter\n * @public\n */\nexport class EventBridgeAdapter extends AwsSimpleAdapter<EventBridgeEventAll> {\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link EventBridgeAdapter}\n */\n constructor(options?: EventBridgeOptions) {\n super({\n forwardPath: getDefaultIfUndefined(\n options?.eventBridgeForwardPath,\n '/eventbridge',\n ),\n forwardMethod: getDefaultIfUndefined(\n options?.eventBridgeForwardMethod,\n 'POST',\n ),\n batch: false,\n host: 'events.amazonaws.com',\n });\n }\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return EventBridgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is EventBridgeEventAll {\n const eventBridgeEvent = event as Partial<EventBridgeEventAll>;\n\n // thanks to @cnuss in https://github.com/vendia/serverless-express/blob/b5da6070b8dd2fb674c1f7035dd7edfef1dc83a2/src/event-sources/utils.js#L87\n return !!(\n eventBridgeEvent &&\n eventBridgeEvent.version &&\n eventBridgeEvent.version === '0' &&\n eventBridgeEvent.id &&\n eventBridgeEvent['detail-type'] &&\n eventBridgeEvent.source &&\n eventBridgeEvent.account &&\n eventBridgeEvent.time &&\n eventBridgeEvent.region &&\n eventBridgeEvent.resources &&\n Array.isArray(eventBridgeEvent.resources) &&\n eventBridgeEvent.detail &&\n typeof eventBridgeEvent.detail === 'object' &&\n !Array.isArray(eventBridgeEvent.detail)\n );\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"ooBAAA,6BAAA,CAAA,EAAA,SAAA,6BAAA,CAAA,mBAAA,IAAA,kBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,4BAAA,EAGA,IAAsC,YAAA,QAAA,YAAA,EACL,YAAA,QAAA,cAAA,EAmD1B,MAAM,2BAA2B,YAAsC,gBAAA,CAQ5E,YAAY,QAA8B,CAClC,MAAA,CACJ,eAAa,YAAA,uBACX,6BAAS,uBACT,cACF,EACA,iBAAe,YAAA,uBACb,6BAAS,yBACT,MACF,EACA,MAAO,GACP,KAAM,sBAAA,CACP,CACH,CASO,gBAAyB,CAC9B,OAAO,mBAAmB,IAC5B,CAKO,UAAU,MAA8C,CAC7D,MAAM,iBAAmB,MAGzB,MAAO,CAAC,EACN,kBACA,iBAAiB,SACjB,iBAAiB,UAAY,KAC7B,iBAAiB,IACjB,iBAAiB,aAAa,GAC9B,iBAAiB,QACjB,iBAAiB,SACjB,iBAAiB,MACjB,iBAAiB,QACjB,iBAAiB,WACjB,MAAM,QAAQ,iBAAiB,SAAS,GACxC,iBAAiB,QACjB,OAAO,iBAAiB,QAAW,UACnC,CAAC,MAAM,QAAQ,iBAAiB,MAAM,EAE1C,CAGF"}
@@ -0,0 +1,12 @@
1
+ export * from './alb.adapter';
2
+ export * from './api-gateway-v1.adapter';
3
+ export * from './api-gateway-v2.adapter';
4
+ export * from './dynamodb.adapter';
5
+ export * from './event-bridge.adapter';
6
+ export * from './lambda-edge.adapter';
7
+ export * from './s3.adapter';
8
+ export * from './sns.adapter';
9
+ export * from './sqs.adapter';
10
+ export * from './base';
11
+ export * from './request-lambda-edge.adapter';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,+BAA+B,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";var _=Object.defineProperty,i=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,u=(p,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of x(t))!n.call(p,o)&&o!==s&&_(p,o,{get:()=>t[o],enumerable:!(a=i(t,o))||a.enumerable});return p},r=(p,t,s)=>(u(p,t,"default"),s&&u(s,t,"default")),q=p=>u(_({},"__esModule",{value:!0}),p),e={};module.exports=q(e);r(e,require("./alb.adapter"),module.exports);r(e,require("./api-gateway-v1.adapter"),module.exports);r(e,require("./api-gateway-v2.adapter"),module.exports);r(e,require("./dynamodb.adapter"),module.exports);r(e,require("./event-bridge.adapter"),module.exports);r(e,require("./lambda-edge.adapter"),module.exports);r(e,require("./s3.adapter"),module.exports);r(e,require("./sns.adapter"),module.exports);r(e,require("./sqs.adapter"),module.exports);r(e,require("./base"),module.exports);
1
+ "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),aws_exports={};module.exports=__toCommonJS(aws_exports);__reExport(aws_exports,require("./alb.adapter"),module.exports);__reExport(aws_exports,require("./api-gateway-v1.adapter"),module.exports);__reExport(aws_exports,require("./api-gateway-v2.adapter"),module.exports);__reExport(aws_exports,require("./dynamodb.adapter"),module.exports);__reExport(aws_exports,require("./event-bridge.adapter"),module.exports);__reExport(aws_exports,require("./lambda-edge.adapter"),module.exports);__reExport(aws_exports,require("./s3.adapter"),module.exports);__reExport(aws_exports,require("./sns.adapter"),module.exports);__reExport(aws_exports,require("./sqs.adapter"),module.exports);__reExport(aws_exports,require("./base"),module.exports);__reExport(aws_exports,require("./request-lambda-edge.adapter"),module.exports);
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/adapters/aws/index.ts"],"sourcesContent":["export * from './alb.adapter';\nexport * from './api-gateway-v1.adapter';\nexport * from './api-gateway-v2.adapter';\nexport * from './dynamodb.adapter';\nexport * from './event-bridge.adapter';\nexport * from './lambda-edge.adapter';\nexport * from './s3.adapter';\nexport * from './sns.adapter';\nexport * from './sqs.adapter';\nexport * from './base';\n"],"names":["aws_exports","__toCommonJS","__reExport"],"mappings":"6YAAAA,EAAA,CAAA,EAAA,OAAA,QAAAC,EAAAD,CAAA,EAAAE,EAAAF,EAAc,QAAd,eAAA,EAAA,OAAA,OAAA,EACAE,EAAAF,EAAc,QADd,0BAAA,EAAA,OAAA,OAAA,EAEAE,EAAAF,EAAc,QAFd,0BAAA,EAAA,OAAA,OAAA,EAGAE,EAAAF,EAAc,QAHd,oBAAA,EAAA,OAAA,OAAA,EAIAE,EAAAF,EAAc,QAJd,wBAAA,EAAA,OAAA,OAAA,EAKAE,EAAAF,EAAc,QALd,uBAAA,EAAA,OAAA,OAAA,EAMAE,EAAAF,EAAc,QANd,cAAA,EAAA,OAAA,OAAA,EAOAE,EAAAF,EAAc,QAPd,eAAA,EAAA,OAAA,OAAA,EAQAE,EAAAF,EAAc,QARd,eAAA,EAAA,OAAA,OAAA,EASAE,EAAAF,EAAc,QATd,QAAA,EAAA,OAAA,OAAA"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/adapters/aws/index.ts"],"sourcesContent":["export * from './alb.adapter';\nexport * from './api-gateway-v1.adapter';\nexport * from './api-gateway-v2.adapter';\nexport * from './dynamodb.adapter';\nexport * from './event-bridge.adapter';\nexport * from './lambda-edge.adapter';\nexport * from './s3.adapter';\nexport * from './sns.adapter';\nexport * from './sqs.adapter';\nexport * from './base';\nexport * from './request-lambda-edge.adapter';\n"],"names":[],"mappings":"kqBAAA,YAAA,CAAA,EAAA,OAAA,QAAA,aAAA,WAAA,EAAA,WAAA,YAAc,QAAd,eAAA,EAAA,OAAA,OAAA,EACA,WAAA,YAAc,QADd,0BAAA,EAAA,OAAA,OAAA,EAEA,WAAA,YAAc,QAFd,0BAAA,EAAA,OAAA,OAAA,EAGA,WAAA,YAAc,QAHd,oBAAA,EAAA,OAAA,OAAA,EAIA,WAAA,YAAc,QAJd,wBAAA,EAAA,OAAA,OAAA,EAKA,WAAA,YAAc,QALd,uBAAA,EAAA,OAAA,OAAA,EAMA,WAAA,YAAc,QANd,cAAA,EAAA,OAAA,OAAA,EAOA,WAAA,YAAc,QAPd,eAAA,EAAA,OAAA,OAAA,EAQA,WAAA,YAAc,QARd,eAAA,EAAA,OAAA,OAAA,EASA,WAAA,YAAc,QATd,QAAA,EAAA,OAAA,OAAA,EAUA,WAAA,YAAc,QAVd,+BAAA,EAAA,OAAA,OAAA"}
@@ -0,0 +1,209 @@
1
+ import type { CloudFrontRequest, Context } from 'aws-lambda';
2
+ import type { CloudFrontEvent, CloudFrontHeaders } from 'aws-lambda/common/cloudfront';
3
+ import type { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda/trigger/cloudfront-request';
4
+ import { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';
5
+ import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
6
+ /**
7
+ * The type alias to indicate where we get the default value of query string to create the request.
8
+ *
9
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
10
+ * @public
11
+ */
12
+ export type DefaultQueryString = CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];
13
+ /**
14
+ * The type alias to indicate where we get the default value of path to create the request.
15
+ *
16
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
17
+ * @public
18
+ */
19
+ export type DefaultForwardPath = CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];
20
+ /**
21
+ * Represents the body of the new version of Lambda\@edge, which uses the `body` property inside `request` as the body (library) of the request.
22
+ *
23
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
24
+ * @public
25
+ */
26
+ export type NewLambdaEdgeBody = CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];
27
+ /**
28
+ * Represents the body of the old version of Lambda\@edge supported by \@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.
29
+ *
30
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
31
+ * @public
32
+ */
33
+ export type OldLambdaEdgeBody = Concrete<CloudFrontRequestEvent['Records'][number]['cf']['request']>['body']['data'];
34
+ /**
35
+ * The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the "Disallowed Headers" section.
36
+ *
37
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
38
+ * @public
39
+ */
40
+ export declare const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[];
41
+ /**
42
+ * The default max response size in bytes of viewer request and viewer response.
43
+ *
44
+ * @defaultValue 1024 * 40 = 40960 = 40KB
45
+ *
46
+ * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
47
+ *
48
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
49
+ * @public
50
+ */
51
+ export declare const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES: number;
52
+ /**
53
+ * The default max response size in bytes of origin request and origin response.
54
+ *
55
+ * @defaultValue 1024 * 1024 = 1048576 = 1MB
56
+ *
57
+ * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
58
+ *
59
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants
60
+ * @public
61
+ */
62
+ export declare const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES: number;
63
+ /**
64
+ * The options to customize the {@link LambdaEdgeAdapter}.
65
+ *
66
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
67
+ * @public
68
+ */
69
+ export interface LambdaEdgeAdapterOptions {
70
+ /**
71
+ * The max response size in bytes of viewer request and viewer response.
72
+ *
73
+ * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
74
+ *
75
+ * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}
76
+ */
77
+ viewerMaxResponseSizeInBytes?: number;
78
+ /**
79
+ * The max response size in bytes of origin request and origin response.
80
+ *
81
+ * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}
82
+ *
83
+ * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}
84
+ */
85
+ originMaxResponseSizeInBytes?: number;
86
+ /**
87
+ * The function called when the response size exceed the max limits of the Lambda\@edge
88
+ *
89
+ * @param response - The response from framework that exceed the limit of Lambda\@edge
90
+ * @defaultValue undefined
91
+ */
92
+ onResponseSizeExceedLimit?: (response: CloudFrontRequestResult) => CloudFrontRequestResult;
93
+ /**
94
+ * Return the path to be used to create a request to the framework
95
+ *
96
+ * @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.
97
+ *
98
+ * @param event - The event sent by the serverless
99
+ * @defaultValue The value from {@link DefaultForwardPath}
100
+ */
101
+ getPathFromEvent?: (event: CloudFrontRequestEvent['Records'][number]) => string;
102
+ /**
103
+ * The headers that will be stripped from the headers object because Lambda\@edge will fail if these headers are passed in the response.
104
+ *
105
+ * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)
106
+ *
107
+ * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.
108
+ */
109
+ disallowedHeaders?: (string | RegExp)[];
110
+ /**
111
+ * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.
112
+ *
113
+ * @param header - The header of the response
114
+ * @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.
115
+ */
116
+ shouldStripHeader?: (header: string) => boolean;
117
+ /**
118
+ * By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.
119
+ * So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.
120
+ * Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.
121
+ *
122
+ * @defaultValue false
123
+ */
124
+ shouldUseHeadersFromFramework?: boolean;
125
+ }
126
+ /**
127
+ * The adapter to handle requests from AWS Lambda\@Edge.
128
+ *
129
+ * This adapter is not fully compatible with Lambda\@edge supported by \@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.
130
+ * Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.
131
+ * And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.
132
+ *
133
+ * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}
134
+ * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}
135
+ *
136
+ * @example
137
+ * ```typescript
138
+ * const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint
139
+ * const adapter = new LambdaEdgeAdapter({ getPathFromEvent });
140
+ * ```
141
+ *
142
+ * @breadcrumb Adapters / AWS / LambdaEdgeAdapter
143
+ * @public
144
+ */
145
+ export declare class LambdaEdgeAdapter implements AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult> {
146
+ protected readonly options?: LambdaEdgeAdapterOptions | undefined;
147
+ /**
148
+ * Default constructor
149
+ *
150
+ * @param options - The options to customize the {@link LambdaEdgeAdapter}
151
+ */
152
+ constructor(options?: LambdaEdgeAdapterOptions | undefined);
153
+ /**
154
+ * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.
155
+ */
156
+ protected readonly cachedDisallowedHeaders: RegExp[];
157
+ /**
158
+ * {@inheritDoc}
159
+ */
160
+ getAdapterName(): string;
161
+ /**
162
+ * {@inheritDoc}
163
+ */
164
+ canHandle(event: unknown): event is CloudFrontRequestEvent;
165
+ /**
166
+ * {@inheritDoc}
167
+ */
168
+ getRequest(event: CloudFrontRequestEvent): AdapterRequest;
169
+ /**
170
+ * {@inheritDoc}
171
+ */
172
+ getResponse(props: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult;
173
+ /**
174
+ * {@inheritDoc}
175
+ */
176
+ onErrorWhileForwarding({ error, delegatedResolver, }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void;
177
+ /**
178
+ * Returns the headers with the flattened (non-list) values of the cloudfront request headers
179
+ *
180
+ * @param cloudFrontRequest - The cloudfront request
181
+ */
182
+ protected getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest: CloudFrontRequest): SingleValueHeaders;
183
+ /**
184
+ * Returns the framework response in the format required by the Lambda\@edge.
185
+ *
186
+ * @param body - The body of the response
187
+ * @param frameworkHeaders - The headers from the framework
188
+ */
189
+ protected getResponseToLambdaEdge({ body, headers: frameworkHeaders, }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult;
190
+ /**
191
+ * Returns headers in Cloudfront Response format.
192
+ *
193
+ * @param originalHeaders - The original version of the request sent by the framework
194
+ */
195
+ protected getHeadersForCloudfrontResponse(originalHeaders: BothValueHeaders): CloudFrontHeaders;
196
+ /**
197
+ * Returns the information if we should remove the response header
198
+ *
199
+ * @param headerKey - The header that will be tested
200
+ */
201
+ protected shouldStripHeader(headerKey: string): boolean;
202
+ /**
203
+ * Determines whether the event is from origin or is from viewer.
204
+ *
205
+ * @param content - The event sent by AWS or the response sent by the framework
206
+ */
207
+ protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean;
208
+ }
209
+ //# sourceMappingURL=lambda-edge.adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-edge.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"names":[],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty,m=Object.getOwnPropertyDescriptor,v=Object.getOwnPropertyNames,O=Object.prototype.hasOwnProperty,D=(a,r)=>{for(var e in r)c(a,e,{get:r[e],enumerable:!0})},I=(a,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of v(r))!O.call(a,s)&&s!==e&&c(a,s,{get:()=>r[s],enumerable:!(t=m(r,s))||t.enumerable});return a},P=a=>I(c({},"__esModule",{value:!0}),a),h={};D(h,{DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS:()=>_,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES:()=>S,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES:()=>A,LambdaEdgeAdapter:()=>f});module.exports=P(h);var d=require("../../core");const _=["Connection","Expect","Keep-Alive","Proxy-Authenticate","Proxy-Authorization","Proxy-Connection","Trailer","Upgrade","X-Accel-Buffering","X-Accel-Charset","X-Accel-Limit-Rate","X-Accel-Redirect",/(X-Amz-Cf-)(.*)/gim,"X-Cache",/(X-Edge-)(.*)/gim,"X-Forwarded-Proto","X-Real-IP"],A=1024*40,S=1024*1024;class f{constructor(r){var t;this.options=r;const e=(0,d.getDefaultIfUndefined)((t=this.options)==null?void 0:t.disallowedHeaders,_);this.cachedDisallowedHeaders=e.map(s=>s instanceof RegExp?s:new RegExp(`(${s})`,"gim"))}getAdapterName(){return f.name}canHandle(r){var o,n,i;const e=r;if(!Array.isArray(e==null?void 0:e.Records))return!1;const t=(i=(n=(o=e.Records[0])==null?void 0:o.cf)==null?void 0:n.config)==null?void 0:i.eventType;return["origin-response","origin-request","viewer-response","viewer-request"].includes(t)}getRequest(r){var g;const e=r.Records[0],t=e.cf.request,s=t.method,o=(g=this.options)!=null&&g.getPathFromEvent?this.options.getPathFromEvent(e):void 0,n=(0,d.getPathWithQueryStringParams)(t.uri,t.querystring),i=(0,d.getDefaultIfUndefined)(o,n),u=t.clientIp,p=this.getFlattenedHeadersFromCloudfrontRequest(t);let E;if(t.body){const[R,y]=(0,d.getEventBodyAsBuffer)(JSON.stringify(t.body),!1);E=R,p["content-length"]=y.toString()}const{host:l}=p;return{method:s,path:i,headers:p,body:E,remoteAddress:u,host:l,hostname:l}}getResponse(r){var n,i,u;const e=this.getResponseToLambdaEdge(r),t=new TextEncoder().encode(JSON.stringify(e)).length,o=this.isEventTypeOrigin(r.event.Records[0].cf.config)?(0,d.getDefaultIfUndefined)((n=this.options)==null?void 0:n.originMaxResponseSizeInBytes,S):(0,d.getDefaultIfUndefined)((i=this.options)==null?void 0:i.viewerMaxResponseSizeInBytes,A);return t<=o||((u=this.options)!=null&&u.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(e):r.log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${t} of the max of ${o}.`)),e}onErrorWhileForwarding({error:r,delegatedResolver:e}){e.fail(r)}getFlattenedHeadersFromCloudfrontRequest(r){return Object.keys(r.headers).reduce((e,t)=>{const s=r.headers[t];return e[t]=s.map(o=>o.value).join(","),e},{})}getResponseToLambdaEdge({body:r,headers:e}){var o;const t=(0,d.getDefaultIfUndefined)((o=this.options)==null?void 0:o.shouldUseHeadersFromFramework,!1),s=JSON.parse(r);return s.headers&&(s.headers=Object.keys(s.headers).reduce((n,i)=>(this.shouldStripHeader(i)||(n[i]=s.headers[i]),n),{})),t&&(s.headers=this.getHeadersForCloudfrontResponse(e)),s}getHeadersForCloudfrontResponse(r){return Object.keys(r).reduce((e,t)=>{if(this.shouldStripHeader(t))return e;e[t]||(e[t]=[]);const s=r[t];if(!Array.isArray(s))return e[t].push({key:t,value:s||""}),e;const o=s.map(n=>({key:t,value:n}));return e[t].push(...o),e},{})}shouldStripHeader(r){var t;if((t=this.options)!=null&&t.shouldStripHeader)return this.options.shouldStripHeader(r);const e=r.toLowerCase();for(const s of this.cachedDisallowedHeaders)if(s.test(e))return!0;return!1}isEventTypeOrigin(r){return r.eventType.includes("origin")}}
1
+ "use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),lambda_edge_adapter_exports={};__export(lambda_edge_adapter_exports,{DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS:()=>DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES:()=>DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES:()=>DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,LambdaEdgeAdapter:()=>LambdaEdgeAdapter});module.exports=__toCommonJS(lambda_edge_adapter_exports);var import_core=require("../../core");const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS=["Connection","Expect","Keep-Alive","Proxy-Authenticate","Proxy-Authorization","Proxy-Connection","Trailer","Upgrade","X-Accel-Buffering","X-Accel-Charset","X-Accel-Limit-Rate","X-Accel-Redirect",/(X-Amz-Cf-)(.*)/gim,"X-Cache",/(X-Edge-)(.*)/gim,"X-Forwarded-Proto","X-Real-IP"],DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES=1024*40,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES=1024*1024;class LambdaEdgeAdapter{constructor(options){var _a;this.options=options;const disallowedHeaders=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.disallowedHeaders,DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS);this.cachedDisallowedHeaders=disallowedHeaders.map(disallowedHeader=>disallowedHeader instanceof RegExp?disallowedHeader:new RegExp(`(${disallowedHeader})`,"gim"))}getAdapterName(){return LambdaEdgeAdapter.name}canHandle(event){var _a,_b,_c;const lambdaEdgeEvent=event;if(!Array.isArray(lambdaEdgeEvent==null?void 0:lambdaEdgeEvent.Records))return!1;const eventType=(_c=(_b=(_a=lambdaEdgeEvent.Records[0])==null?void 0:_a.cf)==null?void 0:_b.config)==null?void 0:_c.eventType;return["origin-response","origin-request","viewer-response","viewer-request"].includes(eventType)}getRequest(event){var _a;const request=event.Records[0],cloudFrontRequest=request.cf.request,method=cloudFrontRequest.method,pathFromOptions=(_a=this.options)!=null&&_a.getPathFromEvent?this.options.getPathFromEvent(request):void 0,defaultPath=(0,import_core.getPathWithQueryStringParams)(cloudFrontRequest.uri,cloudFrontRequest.querystring),path=(0,import_core.getDefaultIfUndefined)(pathFromOptions,defaultPath),remoteAddress=cloudFrontRequest.clientIp,headers=this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);let body;if(cloudFrontRequest.body){const[buffer,contentLength]=(0,import_core.getEventBodyAsBuffer)(JSON.stringify(cloudFrontRequest.body),!1);body=buffer,headers["content-length"]=contentLength.toString()}const{host}=headers;return{method,path,headers,body,remoteAddress,host,hostname:host}}getResponse(props){var _a,_b,_c;const response=this.getResponseToLambdaEdge(props),responseToServiceBytes=new TextEncoder().encode(JSON.stringify(response)).length,maxSizeInBytes=this.isEventTypeOrigin(props.event.Records[0].cf.config)?(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.originMaxResponseSizeInBytes,DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES):(0,import_core.getDefaultIfUndefined)((_b=this.options)==null?void 0:_b.viewerMaxResponseSizeInBytes,DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES);return responseToServiceBytes<=maxSizeInBytes||((_c=this.options)!=null&&_c.onResponseSizeExceedLimit?this.options.onResponseSizeExceedLimit(response):props.log.error(`SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`)),response}onErrorWhileForwarding({error,delegatedResolver}){delegatedResolver.fail(error)}getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest){return Object.keys(cloudFrontRequest.headers).reduce((acc,headerKey)=>{const headerValue=cloudFrontRequest.headers[headerKey];return acc[headerKey]=headerValue.map(header=>header.value).join(","),acc},{})}getResponseToLambdaEdge({body,headers:frameworkHeaders}){var _a;const shouldUseHeadersFromFramework=(0,import_core.getDefaultIfUndefined)((_a=this.options)==null?void 0:_a.shouldUseHeadersFromFramework,!1),parsedBody=JSON.parse(body);return parsedBody.headers&&(parsedBody.headers=Object.keys(parsedBody.headers).reduce((acc,header)=>(this.shouldStripHeader(header)||(acc[header]=parsedBody.headers[header]),acc),{})),shouldUseHeadersFromFramework&&(parsedBody.headers=this.getHeadersForCloudfrontResponse(frameworkHeaders)),parsedBody}getHeadersForCloudfrontResponse(originalHeaders){return Object.keys(originalHeaders).reduce((acc,headerKey)=>{if(this.shouldStripHeader(headerKey))return acc;acc[headerKey]||(acc[headerKey]=[]);const headerValue=originalHeaders[headerKey];if(!Array.isArray(headerValue))return acc[headerKey].push({key:headerKey,value:headerValue||""}),acc;const headersArray=headerValue.map(value=>({key:headerKey,value}));return acc[headerKey].push(...headersArray),acc},{})}shouldStripHeader(headerKey){var _a;if((_a=this.options)!=null&&_a.shouldStripHeader)return this.options.shouldStripHeader(headerKey);const headerKeyLowerCase=headerKey.toLowerCase();for(const stripHeaderIf of this.cachedDisallowedHeaders)if(stripHeaderIf.test(headerKeyLowerCase))return!0;return!1}isEventTypeOrigin(content){return content.eventType.includes("origin")}}
2
2
  //# sourceMappingURL=lambda-edge.adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lambda-edge.adapter.js","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontEvent,\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\n\n//#endregion\n\n/**\n * The type alias to indicate where we get the default value of query string to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultQueryString =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];\n\n/**\n * The type alias to indicate where we get the default value of path to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultForwardPath =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];\n\n/**\n * Represents the body of the new version of Lambda\\@edge, which uses the `body` property inside `request` as the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type NewLambdaEdgeBody =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];\n\n/**\n * Represents the body of the old version of Lambda\\@edge supported by \\@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type OldLambdaEdgeBody = Concrete<\n CloudFrontRequestEvent['Records'][number]['cf']['request']\n>['body']['data'];\n\n/**\n * The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the \"Disallowed Headers\" section.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[] = [\n 'Connection',\n 'Expect',\n 'Keep-Alive',\n 'Proxy-Authenticate',\n 'Proxy-Authorization',\n 'Proxy-Connection',\n 'Trailer',\n 'Upgrade',\n 'X-Accel-Buffering',\n 'X-Accel-Charset',\n 'X-Accel-Limit-Rate',\n 'X-Accel-Redirect',\n /(X-Amz-Cf-)(.*)/gim,\n 'X-Cache',\n /(X-Edge-)(.*)/gim,\n 'X-Forwarded-Proto',\n 'X-Real-IP',\n];\n\n/**\n * The default max response size in bytes of viewer request and viewer response.\n *\n * @defaultValue 1024 * 40 = 40960 = 40KB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 40;\n\n/**\n * The default max response size in bytes of origin request and origin response.\n *\n * @defaultValue 1024 * 1024 = 1048576 = 1MB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 1024;\n\n/**\n * The options to customize the {@link LambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport interface LambdaEdgeAdapterOptions {\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * Return the path to be used to create a request to the framework\n *\n * @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.\n *\n * @param event - The event sent by the serverless\n * @defaultValue The value from {@link DefaultForwardPath}\n */\n getPathFromEvent?: (\n event: CloudFrontRequestEvent['Records'][number],\n ) => string;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n\n /**\n * By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.\n * So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.\n * Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.\n *\n * @defaultValue false\n */\n shouldUseHeadersFromFramework?: boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge.\n *\n * This adapter is not fully compatible with Lambda\\@edge supported by \\@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.\n * Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.\n * And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint\n * const adapter = new LambdaEdgeAdapter({ getPathFromEvent });\n * ```\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport class LambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link LambdaEdgeAdapter}\n */\n constructor(protected readonly options?: LambdaEdgeAdapterOptions) {\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return LambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n const validEventTypes: CloudFrontEvent['config']['eventType'][] = [\n 'origin-response',\n 'origin-request',\n 'viewer-response',\n 'viewer-request',\n ];\n\n return validEventTypes.includes(eventType);\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const pathFromOptions = this.options?.getPathFromEvent\n ? this.options.getPathFromEvent(request)\n : undefined;\n const defaultPath = getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n );\n const path = getDefaultIfUndefined(pathFromOptions, defaultPath);\n\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n JSON.stringify(cloudFrontRequest.body),\n false,\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse(\n props: GetResponseAdapterProps<CloudFrontRequestEvent>,\n ): CloudFrontRequestResult {\n const response = this.getResponseToLambdaEdge(props);\n const responseToServiceBytes = new TextEncoder().encode(\n JSON.stringify(response),\n ).length;\n\n const isOriginRequestOrResponse = this.isEventTypeOrigin(\n props.event.Records[0].cf.config,\n );\n const maxSizeInBytes = isOriginRequestOrResponse\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n if (responseToServiceBytes <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n props.log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n delegatedResolver.fail(error);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns the framework response in the format required by the Lambda\\@edge.\n *\n * @param body - The body of the response\n * @param frameworkHeaders - The headers from the framework\n */\n protected getResponseToLambdaEdge({\n body,\n headers: frameworkHeaders,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult {\n const shouldUseHeadersFromFramework = getDefaultIfUndefined(\n this.options?.shouldUseHeadersFromFramework,\n false,\n );\n\n const parsedBody: CloudFrontResultResponse | CloudFrontRequest =\n JSON.parse(body);\n\n if (parsedBody.headers) {\n parsedBody.headers = Object.keys(parsedBody.headers).reduce(\n (acc, header) => {\n if (this.shouldStripHeader(header)) return acc;\n\n acc[header] = parsedBody.headers![header];\n\n return acc;\n },\n {} as CloudFrontHeaders,\n );\n }\n\n if (!shouldUseHeadersFromFramework) return parsedBody;\n\n parsedBody.headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n return parsedBody;\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n if (!acc[headerKey]) acc[headerKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[headerKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[headerKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Determines whether the event is from origin or is from viewer.\n *\n * @param content - The event sent by AWS or the response sent by the framework\n */\n protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean {\n return content.eventType.includes('origin');\n }\n\n //#endregion\n}\n"],"names":["lambda_edge_adapter_exports","__export","DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS","DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES","DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES","LambdaEdgeAdapter","__toCommonJS","import_core","options","disallowedHeaders","_a","disallowedHeader","event","lambdaEdgeEvent","eventType","_c","_b","request","cloudFrontRequest","method","pathFromOptions","defaultPath","path","remoteAddress","headers","body","buffer","contentLength","host","props","response","responseToServiceBytes","maxSizeInBytes","error","delegatedResolver","acc","headerKey","headerValue","header","frameworkHeaders","shouldUseHeadersFromFramework","parsedBody","originalHeaders","headersArray","value","headerKeyLowerCase","stripHeaderIf","content"],"mappings":"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"}
1
+ {"version":3,"file":"lambda-edge.adapter.js","sources":["../../../src/adapters/aws/lambda-edge.adapter.ts"],"sourcesContent":["//#region Imports\n\nimport type { CloudFrontRequest, Context } from 'aws-lambda';\nimport type {\n CloudFrontEvent,\n CloudFrontHeaders,\n CloudFrontResultResponse,\n} from 'aws-lambda/common/cloudfront';\nimport type {\n CloudFrontRequestEvent,\n CloudFrontRequestResult,\n} from 'aws-lambda/trigger/cloudfront-request';\nimport { BothValueHeaders, Concrete, SingleValueHeaders } from '../../@types';\nimport {\n AdapterContract,\n AdapterRequest,\n GetResponseAdapterProps,\n OnErrorProps,\n} from '../../contracts';\nimport {\n getDefaultIfUndefined,\n getEventBodyAsBuffer,\n getPathWithQueryStringParams,\n} from '../../core';\n\n//#endregion\n\n/**\n * The type alias to indicate where we get the default value of query string to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultQueryString =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['querystring'];\n\n/**\n * The type alias to indicate where we get the default value of path to create the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type DefaultForwardPath =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['uri'];\n\n/**\n * Represents the body of the new version of Lambda\\@edge, which uses the `body` property inside `request` as the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type NewLambdaEdgeBody =\n CloudFrontRequestEvent['Records'][number]['cf']['request']['body'];\n\n/**\n * Represents the body of the old version of Lambda\\@edge supported by \\@vendia/serverless-express which returns the `data` property within `body` for the body (library) of the request.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport type OldLambdaEdgeBody = Concrete<\n CloudFrontRequestEvent['Records'][number]['cf']['request']\n>['body']['data'];\n\n/**\n * The list was created based on {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html | these docs} in the \"Disallowed Headers\" section.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS: (string | RegExp)[] = [\n 'Connection',\n 'Expect',\n 'Keep-Alive',\n 'Proxy-Authenticate',\n 'Proxy-Authorization',\n 'Proxy-Connection',\n 'Trailer',\n 'Upgrade',\n 'X-Accel-Buffering',\n 'X-Accel-Charset',\n 'X-Accel-Limit-Rate',\n 'X-Accel-Redirect',\n /(X-Amz-Cf-)(.*)/gim,\n 'X-Cache',\n /(X-Edge-)(.*)/gim,\n 'X-Forwarded-Proto',\n 'X-Real-IP',\n];\n\n/**\n * The default max response size in bytes of viewer request and viewer response.\n *\n * @defaultValue 1024 * 40 = 40960 = 40KB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 40;\n\n/**\n * The default max response size in bytes of origin request and origin response.\n *\n * @defaultValue 1024 * 1024 = 1048576 = 1MB\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter / Constants\n * @public\n */\nexport const DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES = 1024 * 1024;\n\n/**\n * The options to customize the {@link LambdaEdgeAdapter}.\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport interface LambdaEdgeAdapterOptions {\n /**\n * The max response size in bytes of viewer request and viewer response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n viewerMaxResponseSizeInBytes?: number;\n\n /**\n * The max response size in bytes of origin request and origin response.\n *\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html | Reference}\n *\n * @defaultValue {@link DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES}\n */\n originMaxResponseSizeInBytes?: number;\n\n /**\n * The function called when the response size exceed the max limits of the Lambda\\@edge\n *\n * @param response - The response from framework that exceed the limit of Lambda\\@edge\n * @defaultValue undefined\n */\n onResponseSizeExceedLimit?: (\n response: CloudFrontRequestResult,\n ) => CloudFrontRequestResult;\n\n /**\n * Return the path to be used to create a request to the framework\n *\n * @remarks You MUST append the query params from {@link DefaultQueryString}, you can use the helper {@link getPathWithQueryStringParams}.\n *\n * @param event - The event sent by the serverless\n * @defaultValue The value from {@link DefaultForwardPath}\n */\n getPathFromEvent?: (\n event: CloudFrontRequestEvent['Records'][number],\n ) => string;\n\n /**\n * The headers that will be stripped from the headers object because Lambda\\@edge will fail if these headers are passed in the response.\n *\n * @remarks All headers will be compared with other headers using toLowerCase, but for the RegExp, if you modify this list, you must put the flag `/gmi` at the end of the RegExp (ex: `/(X-Amz-Cf-)(.*)/gim`)\n *\n * @defaultValue To get the full list, see {@link DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS}.\n */\n disallowedHeaders?: (string | RegExp)[];\n\n /**\n * If you want to change how we check against the header if it should be stripped, you can pass a function to this property.\n *\n * @param header - The header of the response\n * @defaultValue The default method is implemented to test the header against the list {@link LambdaEdgeAdapterOptions.disallowedHeaders}.\n */\n shouldStripHeader?: (header: string) => boolean;\n\n /**\n * By default, the {@link aws-lambda#CloudFrontRequestResult} has the `headers` property, but we also have the headers sent by the framework too.\n * So this setting tells us how to handle this case, if you pass `true` to this property, we will use the framework headers.\n * Otherwise, we will forward the body back to cloudfront without modifying or trying to set the `headers` property inside {@link aws-lambda#CloudFrontRequestResult}.\n *\n * @defaultValue false\n */\n shouldUseHeadersFromFramework?: boolean;\n}\n\n/**\n * The adapter to handle requests from AWS Lambda\\@Edge.\n *\n * This adapter is not fully compatible with Lambda\\@edge supported by \\@vendia/serverless-express, the request body was modified to return {@link NewLambdaEdgeBody} instead {@link OldLambdaEdgeBody}.\n * Also, the response has been modified to return entire body sent by the framework, in this form you MUST return the body from the framework in the format of {@link aws-lambda#CloudFrontRequestResult}.\n * And when we get an error during the forwarding to the framework, we call `resolver.fail` instead of trying to return status 500 like the old implementation was.\n *\n * {@link https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html | Lambda edge docs}\n * {@link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html | Event Reference}\n *\n * @example\n * ```typescript\n * const getPathFromEvent = () => '/lambda/edge'; // will forward all requests to the same endpoint\n * const adapter = new LambdaEdgeAdapter({ getPathFromEvent });\n * ```\n *\n * @breadcrumb Adapters / AWS / LambdaEdgeAdapter\n * @public\n */\nexport class LambdaEdgeAdapter\n implements\n AdapterContract<CloudFrontRequestEvent, Context, CloudFrontRequestResult>\n{\n //#region Constructor\n\n /**\n * Default constructor\n *\n * @param options - The options to customize the {@link LambdaEdgeAdapter}\n */\n constructor(protected readonly options?: LambdaEdgeAdapterOptions) {\n const disallowedHeaders = getDefaultIfUndefined(\n this.options?.disallowedHeaders,\n DEFAULT_LAMBDA_EDGE_DISALLOWED_HEADERS,\n );\n\n this.cachedDisallowedHeaders = disallowedHeaders.map(disallowedHeader => {\n if (disallowedHeader instanceof RegExp) return disallowedHeader;\n\n return new RegExp(`(${disallowedHeader})`, 'gim');\n });\n }\n\n //#endregion\n\n //#region Protected Properties\n\n /**\n * This property is used to cache the disallowed headers in `RegExp` version, even if you provide a string in `disallowedHeader`, we will cache it in an instance of `RegExp`.\n */\n protected readonly cachedDisallowedHeaders: RegExp[];\n\n //#endregion\n\n //#region Public Methods\n\n /**\n * {@inheritDoc}\n */\n public getAdapterName(): string {\n return LambdaEdgeAdapter.name;\n }\n\n /**\n * {@inheritDoc}\n */\n public canHandle(event: unknown): event is CloudFrontRequestEvent {\n const lambdaEdgeEvent = event as Partial<CloudFrontRequestEvent>;\n\n if (!Array.isArray(lambdaEdgeEvent?.Records)) return false;\n\n const eventType = lambdaEdgeEvent.Records[0]?.cf?.config?.eventType;\n const validEventTypes: CloudFrontEvent['config']['eventType'][] = [\n 'origin-response',\n 'origin-request',\n 'viewer-response',\n 'viewer-request',\n ];\n\n return validEventTypes.includes(eventType);\n }\n\n /**\n * {@inheritDoc}\n */\n public getRequest(event: CloudFrontRequestEvent): AdapterRequest {\n const request = event.Records[0];\n const cloudFrontRequest = request.cf.request;\n\n const method = cloudFrontRequest.method;\n\n const pathFromOptions = this.options?.getPathFromEvent\n ? this.options.getPathFromEvent(request)\n : undefined;\n const defaultPath = getPathWithQueryStringParams(\n cloudFrontRequest.uri,\n cloudFrontRequest.querystring,\n );\n const path = getDefaultIfUndefined(pathFromOptions, defaultPath);\n\n const remoteAddress = cloudFrontRequest.clientIp;\n\n const headers =\n this.getFlattenedHeadersFromCloudfrontRequest(cloudFrontRequest);\n\n let body: Buffer | undefined;\n\n if (cloudFrontRequest.body) {\n const [buffer, contentLength] = getEventBodyAsBuffer(\n JSON.stringify(cloudFrontRequest.body),\n false,\n );\n\n body = buffer;\n headers['content-length'] = contentLength.toString();\n }\n\n const { host } = headers;\n\n return {\n method,\n path,\n headers,\n body,\n remoteAddress,\n host,\n hostname: host,\n };\n }\n\n /**\n * {@inheritDoc}\n */\n public getResponse(\n props: GetResponseAdapterProps<CloudFrontRequestEvent>,\n ): CloudFrontRequestResult {\n const response = this.getResponseToLambdaEdge(props);\n const responseToServiceBytes = new TextEncoder().encode(\n JSON.stringify(response),\n ).length;\n\n const isOriginRequestOrResponse = this.isEventTypeOrigin(\n props.event.Records[0].cf.config,\n );\n const maxSizeInBytes = isOriginRequestOrResponse\n ? getDefaultIfUndefined(\n this.options?.originMaxResponseSizeInBytes,\n DEFAULT_ORIGIN_MAX_RESPONSE_SIZE_IN_BYTES,\n )\n : getDefaultIfUndefined(\n this.options?.viewerMaxResponseSizeInBytes,\n DEFAULT_VIEWER_MAX_RESPONSE_SIZE_IN_BYTES,\n );\n\n if (responseToServiceBytes <= maxSizeInBytes) return response;\n\n if (this.options?.onResponseSizeExceedLimit)\n this.options.onResponseSizeExceedLimit(response);\n else {\n props.log.error(\n `SERVERLESS_ADAPTER:LAMBDA_EDGE_ADAPTER: Max response size exceeded: ${responseToServiceBytes} of the max of ${maxSizeInBytes}.`,\n );\n }\n\n return response;\n }\n\n /**\n * {@inheritDoc}\n */\n public onErrorWhileForwarding({\n error,\n delegatedResolver,\n }: OnErrorProps<CloudFrontRequestEvent, CloudFrontRequestResult>): void {\n delegatedResolver.fail(error);\n }\n\n //#endregion\n\n //#region Protected Methods\n\n /**\n * Returns the headers with the flattened (non-list) values of the cloudfront request headers\n *\n * @param cloudFrontRequest - The cloudfront request\n */\n protected getFlattenedHeadersFromCloudfrontRequest(\n cloudFrontRequest: CloudFrontRequest,\n ): SingleValueHeaders {\n return Object.keys(cloudFrontRequest.headers).reduce((acc, headerKey) => {\n const headerValue = cloudFrontRequest.headers[headerKey];\n\n acc[headerKey] = headerValue.map(header => header.value).join(',');\n\n return acc;\n }, {} as SingleValueHeaders);\n }\n\n /**\n * Returns the framework response in the format required by the Lambda\\@edge.\n *\n * @param body - The body of the response\n * @param frameworkHeaders - The headers from the framework\n */\n protected getResponseToLambdaEdge({\n body,\n headers: frameworkHeaders,\n }: GetResponseAdapterProps<CloudFrontRequestEvent>): CloudFrontRequestResult {\n const shouldUseHeadersFromFramework = getDefaultIfUndefined(\n this.options?.shouldUseHeadersFromFramework,\n false,\n );\n\n const parsedBody: CloudFrontResultResponse | CloudFrontRequest =\n JSON.parse(body);\n\n if (parsedBody.headers) {\n parsedBody.headers = Object.keys(parsedBody.headers).reduce(\n (acc, header) => {\n if (this.shouldStripHeader(header)) return acc;\n\n acc[header] = parsedBody.headers![header];\n\n return acc;\n },\n {} as CloudFrontHeaders,\n );\n }\n\n if (!shouldUseHeadersFromFramework) return parsedBody;\n\n parsedBody.headers = this.getHeadersForCloudfrontResponse(frameworkHeaders);\n\n return parsedBody;\n }\n\n /**\n * Returns headers in Cloudfront Response format.\n *\n * @param originalHeaders - The original version of the request sent by the framework\n */\n protected getHeadersForCloudfrontResponse(\n originalHeaders: BothValueHeaders,\n ): CloudFrontHeaders {\n return Object.keys(originalHeaders).reduce((acc, headerKey) => {\n if (this.shouldStripHeader(headerKey)) return acc;\n\n if (!acc[headerKey]) acc[headerKey] = [];\n\n const headerValue = originalHeaders[headerKey];\n\n if (!Array.isArray(headerValue)) {\n acc[headerKey].push({\n key: headerKey,\n value: headerValue || '',\n });\n\n return acc;\n }\n\n const headersArray = headerValue.map(value => ({\n key: headerKey,\n value: value,\n }));\n\n acc[headerKey].push(...headersArray);\n\n return acc;\n }, {} as CloudFrontHeaders);\n }\n\n /**\n * Returns the information if we should remove the response header\n *\n * @param headerKey - The header that will be tested\n */\n protected shouldStripHeader(headerKey: string): boolean {\n if (this.options?.shouldStripHeader)\n return this.options.shouldStripHeader(headerKey);\n\n const headerKeyLowerCase = headerKey.toLowerCase();\n\n for (const stripHeaderIf of this.cachedDisallowedHeaders) {\n if (!stripHeaderIf.test(headerKeyLowerCase)) continue;\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Determines whether the event is from origin or is from viewer.\n *\n * @param content - The event sent by AWS or the response sent by the framework\n */\n protected isEventTypeOrigin(content: CloudFrontEvent['config']): boolean {\n return content.eventType.includes('origin');\n }\n\n //#endregion\n}\n"],"names":[],"mappings":"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"}