@restatedev/restate-sdk 0.8.1 → 0.9.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 (374) hide show
  1. package/dist/{clients → src/clients}/workflow_client.d.ts +2 -2
  2. package/dist/src/clients/workflow_client.d.ts.map +1 -0
  3. package/dist/{clients → src/clients}/workflow_client.js +2 -2
  4. package/dist/src/clients/workflow_client.js.map +1 -0
  5. package/dist/{connection → src/connection}/buffered_connection.d.ts +1 -0
  6. package/dist/src/connection/buffered_connection.d.ts.map +1 -0
  7. package/dist/src/connection/buffered_connection.js.map +1 -0
  8. package/dist/src/connection/connection.d.ts.map +1 -0
  9. package/dist/src/connection/connection.js.map +1 -0
  10. package/dist/{connection → src/connection}/http_connection.d.ts +1 -1
  11. package/dist/src/connection/http_connection.d.ts.map +1 -0
  12. package/dist/{connection → src/connection}/http_connection.js +1 -1
  13. package/dist/src/connection/http_connection.js.map +1 -0
  14. package/dist/{connection → src/connection}/lambda_connection.d.ts +1 -0
  15. package/dist/src/connection/lambda_connection.d.ts.map +1 -0
  16. package/dist/{connection → src/connection}/lambda_connection.js +5 -4
  17. package/dist/src/connection/lambda_connection.js.map +1 -0
  18. package/dist/{context.d.ts → src/context.d.ts} +146 -224
  19. package/dist/src/context.d.ts.map +1 -0
  20. package/dist/{context.js → src/context.js} +6 -41
  21. package/dist/src/context.js.map +1 -0
  22. package/dist/src/context_impl.d.ts +62 -0
  23. package/dist/src/context_impl.d.ts.map +1 -0
  24. package/dist/{context_impl.js → src/context_impl.js} +201 -182
  25. package/dist/src/context_impl.js.map +1 -0
  26. package/dist/src/endpoint/endpoint_impl.d.ts +28 -0
  27. package/dist/src/endpoint/endpoint_impl.d.ts.map +1 -0
  28. package/dist/src/endpoint/endpoint_impl.js +164 -0
  29. package/dist/src/endpoint/endpoint_impl.js.map +1 -0
  30. package/dist/{endpoint → src/endpoint}/http2_handler.d.ts +1 -1
  31. package/dist/src/endpoint/http2_handler.d.ts.map +1 -0
  32. package/dist/src/endpoint/http2_handler.js +153 -0
  33. package/dist/src/endpoint/http2_handler.js.map +1 -0
  34. package/dist/{endpoint → src/endpoint}/lambda_handler.d.ts +2 -2
  35. package/dist/src/endpoint/lambda_handler.d.ts.map +1 -0
  36. package/dist/{endpoint → src/endpoint}/lambda_handler.js +66 -56
  37. package/dist/src/endpoint/lambda_handler.js.map +1 -0
  38. package/dist/src/endpoint/request_signing/basex.d.ts +10 -0
  39. package/dist/src/endpoint/request_signing/basex.d.ts.map +1 -0
  40. package/dist/src/endpoint/request_signing/basex.js +138 -0
  41. package/dist/src/endpoint/request_signing/basex.js.map +1 -0
  42. package/dist/src/endpoint/request_signing/ed25519.d.ts +17 -0
  43. package/dist/src/endpoint/request_signing/ed25519.d.ts.map +1 -0
  44. package/dist/src/endpoint/request_signing/ed25519.js +78 -0
  45. package/dist/src/endpoint/request_signing/ed25519.js.map +1 -0
  46. package/dist/src/endpoint/request_signing/v1.d.ts +9 -0
  47. package/dist/src/endpoint/request_signing/v1.d.ts.map +1 -0
  48. package/dist/src/endpoint/request_signing/v1.js +148 -0
  49. package/dist/src/endpoint/request_signing/v1.js.map +1 -0
  50. package/dist/src/endpoint/request_signing/validate.d.ts +18 -0
  51. package/dist/src/endpoint/request_signing/validate.d.ts.map +1 -0
  52. package/dist/src/endpoint/request_signing/validate.js +45 -0
  53. package/dist/src/endpoint/request_signing/validate.js.map +1 -0
  54. package/dist/src/endpoint.d.ts +102 -0
  55. package/dist/src/endpoint.d.ts.map +1 -0
  56. package/dist/{endpoint.js → src/endpoint.js} +1 -1
  57. package/dist/src/endpoint.js.map +1 -0
  58. package/dist/src/generated/proto/javascript_pb.d.ts +26 -0
  59. package/dist/src/generated/proto/javascript_pb.d.ts.map +1 -0
  60. package/dist/src/generated/proto/javascript_pb.js +52 -0
  61. package/dist/src/generated/proto/javascript_pb.js.map +1 -0
  62. package/dist/src/generated/proto/protocol_pb.d.ts +865 -0
  63. package/dist/src/generated/proto/protocol_pb.d.ts.map +1 -0
  64. package/dist/src/generated/proto/protocol_pb.js +1112 -0
  65. package/dist/src/generated/proto/protocol_pb.js.map +1 -0
  66. package/dist/src/generated/version.d.ts +2 -0
  67. package/dist/src/generated/version.d.ts.map +1 -0
  68. package/dist/src/generated/version.js +5 -0
  69. package/dist/src/generated/version.js.map +1 -0
  70. package/dist/{invocation.d.ts → src/invocation.d.ts} +14 -18
  71. package/dist/src/invocation.d.ts.map +1 -0
  72. package/dist/{invocation.js → src/invocation.js} +25 -24
  73. package/dist/src/invocation.js.map +1 -0
  74. package/dist/{io → src/io}/decoder.d.ts +3 -2
  75. package/dist/src/io/decoder.d.ts.map +1 -0
  76. package/dist/{io → src/io}/decoder.js +12 -10
  77. package/dist/src/io/decoder.js.map +1 -0
  78. package/dist/{io → src/io}/encoder.d.ts +1 -1
  79. package/dist/src/io/encoder.d.ts.map +1 -0
  80. package/dist/{io → src/io}/encoder.js +11 -21
  81. package/dist/src/io/encoder.js.map +1 -0
  82. package/dist/{journal.d.ts → src/journal.d.ts} +7 -7
  83. package/dist/src/journal.d.ts.map +1 -0
  84. package/dist/{journal.js → src/journal.js} +64 -46
  85. package/dist/src/journal.js.map +1 -0
  86. package/dist/{local_state_store.d.ts → src/local_state_store.d.ts} +2 -2
  87. package/dist/src/local_state_store.d.ts.map +1 -0
  88. package/dist/{local_state_store.js → src/local_state_store.js} +19 -17
  89. package/dist/src/local_state_store.js.map +1 -0
  90. package/dist/{logger.d.ts → src/logger.d.ts} +9 -1
  91. package/dist/src/logger.d.ts.map +1 -0
  92. package/dist/src/logger.js +158 -0
  93. package/dist/src/logger.js.map +1 -0
  94. package/dist/src/promise_combinator_tracker.d.ts.map +1 -0
  95. package/dist/src/promise_combinator_tracker.js.map +1 -0
  96. package/dist/src/public_api.d.ts +7 -0
  97. package/dist/src/public_api.d.ts.map +1 -0
  98. package/dist/{public_api.js → src/public_api.js} +4 -14
  99. package/dist/src/public_api.js.map +1 -0
  100. package/dist/{state_machine.d.ts → src/state_machine.d.ts} +7 -4
  101. package/dist/src/state_machine.d.ts.map +1 -0
  102. package/dist/{state_machine.js → src/state_machine.js} +32 -34
  103. package/dist/src/state_machine.js.map +1 -0
  104. package/dist/src/types/components.d.ts +65 -0
  105. package/dist/src/types/components.d.ts.map +1 -0
  106. package/dist/src/types/components.js +163 -0
  107. package/dist/src/types/components.js.map +1 -0
  108. package/dist/src/types/discovery.d.ts +40 -0
  109. package/dist/src/types/discovery.d.ts.map +1 -0
  110. package/dist/src/types/discovery.js +29 -0
  111. package/dist/src/types/discovery.js.map +1 -0
  112. package/dist/src/types/errors.d.ts +53 -0
  113. package/dist/src/types/errors.d.ts.map +1 -0
  114. package/dist/src/types/errors.js +129 -0
  115. package/dist/src/types/errors.js.map +1 -0
  116. package/dist/src/types/protocol.d.ts +33 -0
  117. package/dist/src/types/protocol.d.ts.map +1 -0
  118. package/dist/{types → src/types}/protocol.js +52 -52
  119. package/dist/src/types/protocol.js.map +1 -0
  120. package/dist/src/types/rpc.d.ts +50 -0
  121. package/dist/src/types/rpc.d.ts.map +1 -0
  122. package/dist/src/types/rpc.js +38 -0
  123. package/dist/src/types/rpc.js.map +1 -0
  124. package/dist/{types → src/types}/types.d.ts +0 -9
  125. package/dist/src/types/types.d.ts.map +1 -0
  126. package/dist/{types → src/types}/types.js +4 -21
  127. package/dist/src/types/types.js.map +1 -0
  128. package/dist/src/user_agent.d.ts +2 -0
  129. package/dist/src/user_agent.d.ts.map +1 -0
  130. package/dist/src/user_agent.js +16 -0
  131. package/dist/src/user_agent.js.map +1 -0
  132. package/dist/src/utils/message_logger.d.ts +7 -0
  133. package/dist/src/utils/message_logger.d.ts.map +1 -0
  134. package/dist/{utils → src/utils}/message_logger.js +17 -26
  135. package/dist/src/utils/message_logger.js.map +1 -0
  136. package/dist/src/utils/promises.d.ts.map +1 -0
  137. package/dist/src/utils/promises.js.map +1 -0
  138. package/dist/{utils → src/utils}/rand.d.ts +1 -0
  139. package/dist/src/utils/rand.d.ts.map +1 -0
  140. package/dist/{utils → src/utils}/rand.js +7 -6
  141. package/dist/src/utils/rand.js.map +1 -0
  142. package/dist/src/utils/serde.d.ts +3 -0
  143. package/dist/src/utils/serde.d.ts.map +1 -0
  144. package/dist/src/utils/serde.js +24 -0
  145. package/dist/src/utils/serde.js.map +1 -0
  146. package/dist/{utils → src/utils}/utils.d.ts +0 -1
  147. package/dist/src/utils/utils.d.ts.map +1 -0
  148. package/dist/{utils → src/utils}/utils.js +36 -43
  149. package/dist/src/utils/utils.js.map +1 -0
  150. package/dist/{workflows → src/workflows}/workflow.d.ts +6 -6
  151. package/dist/src/workflows/workflow.d.ts.map +1 -0
  152. package/dist/{workflows → src/workflows}/workflow.js +11 -7
  153. package/dist/src/workflows/workflow.js.map +1 -0
  154. package/dist/src/workflows/workflow_state_service.d.ts +35 -0
  155. package/dist/src/workflows/workflow_state_service.d.ts.map +1 -0
  156. package/dist/{workflows → src/workflows}/workflow_state_service.js +11 -11
  157. package/dist/src/workflows/workflow_state_service.js.map +1 -0
  158. package/dist/{workflows → src/workflows}/workflow_wrapper_service.d.ts +2 -2
  159. package/dist/src/workflows/workflow_wrapper_service.d.ts.map +1 -0
  160. package/dist/{workflows → src/workflows}/workflow_wrapper_service.js +66 -45
  161. package/dist/src/workflows/workflow_wrapper_service.js.map +1 -0
  162. package/dist/tsconfig.tsbuildinfo +1 -0
  163. package/package.json +13 -16
  164. package/LICENSE +0 -21
  165. package/README.md +0 -154
  166. package/dist/clients/workflow_client.d.ts.map +0 -1
  167. package/dist/clients/workflow_client.js.map +0 -1
  168. package/dist/connection/buffered_connection.d.ts.map +0 -1
  169. package/dist/connection/buffered_connection.js.map +0 -1
  170. package/dist/connection/connection.d.ts.map +0 -1
  171. package/dist/connection/connection.js.map +0 -1
  172. package/dist/connection/embedded_connection.d.ts +0 -20
  173. package/dist/connection/embedded_connection.d.ts.map +0 -1
  174. package/dist/connection/embedded_connection.js +0 -59
  175. package/dist/connection/embedded_connection.js.map +0 -1
  176. package/dist/connection/http_connection.d.ts.map +0 -1
  177. package/dist/connection/http_connection.js.map +0 -1
  178. package/dist/connection/lambda_connection.d.ts.map +0 -1
  179. package/dist/connection/lambda_connection.js.map +0 -1
  180. package/dist/context.d.ts.map +0 -1
  181. package/dist/context.js.map +0 -1
  182. package/dist/context_impl.d.ts +0 -65
  183. package/dist/context_impl.d.ts.map +0 -1
  184. package/dist/context_impl.js.map +0 -1
  185. package/dist/embedded/api.d.ts +0 -27
  186. package/dist/embedded/api.d.ts.map +0 -1
  187. package/dist/embedded/api.js +0 -35
  188. package/dist/embedded/api.js.map +0 -1
  189. package/dist/embedded/handler.d.ts +0 -4
  190. package/dist/embedded/handler.d.ts.map +0 -1
  191. package/dist/embedded/handler.js +0 -26
  192. package/dist/embedded/handler.js.map +0 -1
  193. package/dist/embedded/http2_remote.d.ts +0 -11
  194. package/dist/embedded/http2_remote.d.ts.map +0 -1
  195. package/dist/embedded/http2_remote.js +0 -91
  196. package/dist/embedded/http2_remote.js.map +0 -1
  197. package/dist/embedded/invocation.d.ts +0 -5
  198. package/dist/embedded/invocation.d.ts.map +0 -1
  199. package/dist/embedded/invocation.js +0 -94
  200. package/dist/embedded/invocation.js.map +0 -1
  201. package/dist/endpoint/endpoint_impl.d.ts +0 -35
  202. package/dist/endpoint/endpoint_impl.d.ts.map +0 -1
  203. package/dist/endpoint/endpoint_impl.js +0 -405
  204. package/dist/endpoint/endpoint_impl.js.map +0 -1
  205. package/dist/endpoint/http2_handler.d.ts.map +0 -1
  206. package/dist/endpoint/http2_handler.js +0 -119
  207. package/dist/endpoint/http2_handler.js.map +0 -1
  208. package/dist/endpoint/lambda_handler.d.ts.map +0 -1
  209. package/dist/endpoint/lambda_handler.js.map +0 -1
  210. package/dist/endpoint.d.ts +0 -161
  211. package/dist/endpoint.d.ts.map +0 -1
  212. package/dist/endpoint.js.map +0 -1
  213. package/dist/generated/dev/restate/events.d.ts +0 -96
  214. package/dist/generated/dev/restate/events.d.ts.map +0 -1
  215. package/dist/generated/dev/restate/events.js +0 -371
  216. package/dist/generated/dev/restate/events.js.map +0 -1
  217. package/dist/generated/dev/restate/ext.d.ts +0 -91
  218. package/dist/generated/dev/restate/ext.d.ts.map +0 -1
  219. package/dist/generated/dev/restate/ext.js +0 -215
  220. package/dist/generated/dev/restate/ext.js.map +0 -1
  221. package/dist/generated/google/protobuf/descriptor.d.ts +0 -1204
  222. package/dist/generated/google/protobuf/descriptor.d.ts.map +0 -1
  223. package/dist/generated/google/protobuf/descriptor.js +0 -6676
  224. package/dist/generated/google/protobuf/descriptor.js.map +0 -1
  225. package/dist/generated/google/protobuf/empty.d.ts +0 -86
  226. package/dist/generated/google/protobuf/empty.d.ts.map +0 -1
  227. package/dist/generated/google/protobuf/empty.js +0 -107
  228. package/dist/generated/google/protobuf/empty.js.map +0 -1
  229. package/dist/generated/google/protobuf/struct.d.ts +0 -175
  230. package/dist/generated/google/protobuf/struct.d.ts.map +0 -1
  231. package/dist/generated/google/protobuf/struct.js +0 -754
  232. package/dist/generated/google/protobuf/struct.js.map +0 -1
  233. package/dist/generated/proto/discovery.d.ts +0 -105
  234. package/dist/generated/proto/discovery.d.ts.map +0 -1
  235. package/dist/generated/proto/discovery.js +0 -364
  236. package/dist/generated/proto/discovery.js.map +0 -1
  237. package/dist/generated/proto/dynrpc.d.ts +0 -150
  238. package/dist/generated/proto/dynrpc.d.ts.map +0 -1
  239. package/dist/generated/proto/dynrpc.js +0 -668
  240. package/dist/generated/proto/dynrpc.js.map +0 -1
  241. package/dist/generated/proto/javascript.d.ts +0 -110
  242. package/dist/generated/proto/javascript.d.ts.map +0 -1
  243. package/dist/generated/proto/javascript.js +0 -416
  244. package/dist/generated/proto/javascript.js.map +0 -1
  245. package/dist/generated/proto/protocol.d.ts +0 -450
  246. package/dist/generated/proto/protocol.d.ts.map +0 -1
  247. package/dist/generated/proto/protocol.js +0 -2641
  248. package/dist/generated/proto/protocol.js.map +0 -1
  249. package/dist/generated/proto/services.d.ts +0 -307
  250. package/dist/generated/proto/services.d.ts.map +0 -1
  251. package/dist/generated/proto/services.js +0 -1535
  252. package/dist/generated/proto/services.js.map +0 -1
  253. package/dist/generated/proto/test.d.ts +0 -116
  254. package/dist/generated/proto/test.d.ts.map +0 -1
  255. package/dist/generated/proto/test.js +0 -321
  256. package/dist/generated/proto/test.js.map +0 -1
  257. package/dist/invocation.d.ts.map +0 -1
  258. package/dist/invocation.js.map +0 -1
  259. package/dist/io/decoder.d.ts.map +0 -1
  260. package/dist/io/decoder.js.map +0 -1
  261. package/dist/io/encoder.d.ts.map +0 -1
  262. package/dist/io/encoder.js.map +0 -1
  263. package/dist/journal.d.ts.map +0 -1
  264. package/dist/journal.js.map +0 -1
  265. package/dist/local_state_store.d.ts.map +0 -1
  266. package/dist/local_state_store.js.map +0 -1
  267. package/dist/logger.d.ts.map +0 -1
  268. package/dist/logger.js +0 -90
  269. package/dist/logger.js.map +0 -1
  270. package/dist/promise_combinator_tracker.d.ts.map +0 -1
  271. package/dist/promise_combinator_tracker.js.map +0 -1
  272. package/dist/public_api.d.ts +0 -10
  273. package/dist/public_api.d.ts.map +0 -1
  274. package/dist/public_api.js.map +0 -1
  275. package/dist/state_machine.d.ts.map +0 -1
  276. package/dist/state_machine.js.map +0 -1
  277. package/dist/types/errors.d.ts +0 -188
  278. package/dist/types/errors.d.ts.map +0 -1
  279. package/dist/types/errors.js +0 -273
  280. package/dist/types/errors.js.map +0 -1
  281. package/dist/types/grpc.d.ts +0 -90
  282. package/dist/types/grpc.d.ts.map +0 -1
  283. package/dist/types/grpc.js +0 -81
  284. package/dist/types/grpc.js.map +0 -1
  285. package/dist/types/protocol.d.ts +0 -30
  286. package/dist/types/protocol.d.ts.map +0 -1
  287. package/dist/types/protocol.js.map +0 -1
  288. package/dist/types/router.d.ts +0 -33
  289. package/dist/types/router.d.ts.map +0 -1
  290. package/dist/types/router.js +0 -36
  291. package/dist/types/router.js.map +0 -1
  292. package/dist/types/types.d.ts.map +0 -1
  293. package/dist/types/types.js.map +0 -1
  294. package/dist/utils/assumptions.d.ts +0 -8
  295. package/dist/utils/assumptions.d.ts.map +0 -1
  296. package/dist/utils/assumptions.js +0 -101
  297. package/dist/utils/assumptions.js.map +0 -1
  298. package/dist/utils/message_logger.d.ts +0 -28
  299. package/dist/utils/message_logger.d.ts.map +0 -1
  300. package/dist/utils/message_logger.js.map +0 -1
  301. package/dist/utils/promises.d.ts.map +0 -1
  302. package/dist/utils/promises.js.map +0 -1
  303. package/dist/utils/public_utils.d.ts +0 -58
  304. package/dist/utils/public_utils.d.ts.map +0 -1
  305. package/dist/utils/public_utils.js +0 -49
  306. package/dist/utils/public_utils.js.map +0 -1
  307. package/dist/utils/rand.d.ts.map +0 -1
  308. package/dist/utils/rand.js.map +0 -1
  309. package/dist/utils/utils.d.ts.map +0 -1
  310. package/dist/utils/utils.js.map +0 -1
  311. package/dist/workflows/workflow.d.ts.map +0 -1
  312. package/dist/workflows/workflow.js.map +0 -1
  313. package/dist/workflows/workflow_state_service.d.ts +0 -35
  314. package/dist/workflows/workflow_state_service.d.ts.map +0 -1
  315. package/dist/workflows/workflow_state_service.js.map +0 -1
  316. package/dist/workflows/workflow_wrapper_service.d.ts.map +0 -1
  317. package/dist/workflows/workflow_wrapper_service.js.map +0 -1
  318. package/src/clients/workflow_client.ts +0 -290
  319. package/src/connection/buffered_connection.ts +0 -47
  320. package/src/connection/connection.ts +0 -34
  321. package/src/connection/embedded_connection.ts +0 -62
  322. package/src/connection/http_connection.ts +0 -228
  323. package/src/connection/lambda_connection.ts +0 -69
  324. package/src/context.ts +0 -633
  325. package/src/context_impl.ts +0 -721
  326. package/src/embedded/api.ts +0 -57
  327. package/src/embedded/handler.ts +0 -36
  328. package/src/embedded/http2_remote.ts +0 -103
  329. package/src/embedded/invocation.ts +0 -126
  330. package/src/endpoint/endpoint_impl.ts +0 -623
  331. package/src/endpoint/http2_handler.ts +0 -151
  332. package/src/endpoint/lambda_handler.ts +0 -181
  333. package/src/endpoint.ts +0 -187
  334. package/src/generated/dev/restate/events.ts +0 -430
  335. package/src/generated/dev/restate/ext.ts +0 -238
  336. package/src/generated/google/protobuf/descriptor.ts +0 -7889
  337. package/src/generated/google/protobuf/empty.ts +0 -150
  338. package/src/generated/google/protobuf/struct.ts +0 -878
  339. package/src/generated/proto/discovery.ts +0 -423
  340. package/src/generated/proto/dynrpc.ts +0 -768
  341. package/src/generated/proto/javascript.ts +0 -488
  342. package/src/generated/proto/protocol.ts +0 -3091
  343. package/src/generated/proto/services.ts +0 -1834
  344. package/src/generated/proto/test.ts +0 -387
  345. package/src/invocation.ts +0 -212
  346. package/src/io/decoder.ts +0 -171
  347. package/src/io/encoder.ts +0 -72
  348. package/src/journal.ts +0 -537
  349. package/src/local_state_store.ts +0 -94
  350. package/src/logger.ts +0 -121
  351. package/src/promise_combinator_tracker.ts +0 -191
  352. package/src/public_api.ts +0 -53
  353. package/src/state_machine.ts +0 -635
  354. package/src/types/errors.ts +0 -297
  355. package/src/types/grpc.ts +0 -97
  356. package/src/types/protocol.ts +0 -201
  357. package/src/types/router.ts +0 -118
  358. package/src/types/types.ts +0 -160
  359. package/src/utils/assumptions.ts +0 -131
  360. package/src/utils/message_logger.ts +0 -112
  361. package/src/utils/promises.ts +0 -118
  362. package/src/utils/public_utils.ts +0 -91
  363. package/src/utils/rand.ts +0 -142
  364. package/src/utils/utils.ts +0 -178
  365. package/src/workflows/workflow.ts +0 -178
  366. package/src/workflows/workflow_state_service.ts +0 -299
  367. package/src/workflows/workflow_wrapper_service.ts +0 -314
  368. /package/dist/{connection → src/connection}/buffered_connection.js +0 -0
  369. /package/dist/{connection → src/connection}/connection.d.ts +0 -0
  370. /package/dist/{connection → src/connection}/connection.js +0 -0
  371. /package/dist/{promise_combinator_tracker.d.ts → src/promise_combinator_tracker.d.ts} +0 -0
  372. /package/dist/{promise_combinator_tracker.js → src/promise_combinator_tracker.js} +0 -0
  373. /package/dist/{utils → src/utils}/promises.d.ts +0 -0
  374. /package/dist/{utils → src/utils}/promises.js +0 -0
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ import { RestateEndpoint, ServiceBundle } from "../public_api";
3
+ import { ServiceDefinition, VirtualObjectDefinition } from "../types/rpc";
4
+ import { Http2ServerRequest, Http2ServerResponse } from "http2";
5
+ import { Component } from "../types/components";
6
+ import * as discovery from "../types/discovery";
7
+ import { KeySetV1 } from "./request_signing/v1";
8
+ export declare const endpointImpl: () => RestateEndpoint;
9
+ export declare class EndpointImpl implements RestateEndpoint {
10
+ private readonly services;
11
+ private _keySet?;
12
+ get keySet(): KeySetV1 | undefined;
13
+ componentByName(componentName: string): Component | undefined;
14
+ addComponent(component: Component): void;
15
+ bindBundle(services: ServiceBundle): RestateEndpoint;
16
+ bind<P extends string, M>(definition: ServiceDefinition<P, M> | VirtualObjectDefinition<P, M>): RestateEndpoint;
17
+ withIdentityV1(...keys: string[]): RestateEndpoint;
18
+ http2Handler(): (request: Http2ServerRequest, response: Http2ServerResponse) => void;
19
+ lambdaHandler(): (event: any, ctx: any) => Promise<any>;
20
+ listen(port?: number): Promise<number>;
21
+ computeDiscovery(protocolMode: discovery.ProtocolMode): discovery.Deployment;
22
+ private bindServiceComponent;
23
+ private bindVirtualObjectComponent;
24
+ }
25
+ export type RpcRouter = {
26
+ [key: string]: Function;
27
+ };
28
+ //# sourceMappingURL=endpoint_impl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint_impl.d.ts","sourceRoot":"","sources":["../../../src/endpoint/endpoint_impl.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAGvE,OAAO,EACL,SAAS,EAKV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,SAAS,MAAM,oBAAoB,C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* This file is part of the Restate SDK for Node.js/TypeScript,
6
+ * which is released under the MIT license.
7
+ *
8
+ * You can find a copy of the license in file LICENSE in the root
9
+ * directory of this repository or package, or at
10
+ * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.EndpointImpl = exports.endpointImpl = void 0;
17
+ const logger_1 = require("../logger");
18
+ const http2_1 = __importDefault(require("http2"));
19
+ const http2_handler_1 = require("./http2_handler");
20
+ const lambda_handler_1 = require("./lambda_handler");
21
+ const components_1 = require("../types/components");
22
+ const v1_1 = require("./request_signing/v1");
23
+ function isServiceDefinition(m) {
24
+ return m && m.service;
25
+ }
26
+ function isObjectDefinition(m) {
27
+ return m && m.object;
28
+ }
29
+ const endpointImpl = () => new EndpointImpl();
30
+ exports.endpointImpl = endpointImpl;
31
+ class EndpointImpl {
32
+ services = new Map();
33
+ _keySet;
34
+ get keySet() {
35
+ return this._keySet;
36
+ }
37
+ componentByName(componentName) {
38
+ return this.services.get(componentName);
39
+ }
40
+ addComponent(component) {
41
+ this.services.set(component.name(), component);
42
+ }
43
+ bindBundle(services) {
44
+ services.registerServices(this);
45
+ return this;
46
+ }
47
+ bind(definition) {
48
+ if (isServiceDefinition(definition)) {
49
+ const { name, service } = definition;
50
+ if (!service) {
51
+ throw new TypeError(`no service implemention found.`);
52
+ }
53
+ this.bindServiceComponent(name, service);
54
+ }
55
+ else if (isObjectDefinition(definition)) {
56
+ const { name, object } = definition;
57
+ if (!object) {
58
+ throw new TypeError(`no object implemention found.`);
59
+ }
60
+ this.bindVirtualObjectComponent(name, object);
61
+ }
62
+ else {
63
+ throw new TypeError("can only bind a service or a virtual object definition");
64
+ }
65
+ return this;
66
+ }
67
+ withIdentityV1(...keys) {
68
+ if (!this._keySet) {
69
+ this._keySet = (0, v1_1.parseKeySetV1)(keys);
70
+ return this;
71
+ }
72
+ (0, v1_1.parseKeySetV1)(keys).forEach((buffer, key) => this._keySet?.set(key, buffer));
73
+ return this;
74
+ }
75
+ http2Handler() {
76
+ if (!this._keySet) {
77
+ if (globalThis.process.env.NODE_ENV == "production") {
78
+ logger_1.rlog.warn(`Accepting HTTP requests without validating request signatures; endpoint access must be restricted`);
79
+ }
80
+ }
81
+ else {
82
+ logger_1.rlog.info(`Validating HTTP requests using signing keys [${Array.from(this._keySet.keys())}]`);
83
+ }
84
+ const handler = new http2_handler_1.Http2Handler(this);
85
+ return handler.acceptConnection.bind(handler);
86
+ }
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
+ lambdaHandler() {
89
+ if (!this._keySet) {
90
+ logger_1.rlog.warn(`Accepting Lambda requests without validating request signatures; Invoke permissions must be restricted`);
91
+ }
92
+ else {
93
+ logger_1.rlog.info(`Validating Lambda requests using signing keys [${Array.from(this._keySet.keys())}]`);
94
+ }
95
+ const handler = new lambda_handler_1.LambdaHandler(this);
96
+ return handler.handleRequest.bind(handler);
97
+ }
98
+ listen(port) {
99
+ const actualPort = port ?? parseInt(process.env.PORT ?? "9080");
100
+ logger_1.rlog.info(`Listening on ${actualPort}...`);
101
+ const server = http2_1.default.createServer(this.http2Handler());
102
+ return new Promise((resolve, reject) => {
103
+ let failed = false;
104
+ server.once("error", (e) => {
105
+ failed = true;
106
+ reject(e);
107
+ });
108
+ server.listen(actualPort, () => {
109
+ if (failed) {
110
+ return;
111
+ }
112
+ const address = server.address();
113
+ if (address === null || typeof address === "string") {
114
+ reject(new TypeError("endpoint.listen() currently supports only binding to a PORT"));
115
+ }
116
+ else {
117
+ resolve(address.port);
118
+ }
119
+ });
120
+ });
121
+ }
122
+ computeDiscovery(protocolMode) {
123
+ const services = [...this.services.values()].map((c) => c.discovery());
124
+ const deployment = {
125
+ protocolMode,
126
+ minProtocolVersion: 1,
127
+ maxProtocolVersion: 2,
128
+ services,
129
+ };
130
+ return deployment;
131
+ }
132
+ bindServiceComponent(name, router) {
133
+ if (name.indexOf("/") !== -1) {
134
+ throw new Error("service name must not contain any slash '/'");
135
+ }
136
+ const component = new components_1.ServiceComponent(name);
137
+ for (const [route, handler] of Object.entries(router)) {
138
+ /* eslint-disable @typescript-eslint/no-explicit-any */
139
+ const fn = handler;
140
+ component.add({
141
+ name: route,
142
+ fn: fn.bind(router),
143
+ });
144
+ }
145
+ this.addComponent(component);
146
+ }
147
+ bindVirtualObjectComponent(name, router) {
148
+ if (name.indexOf("/") !== -1) {
149
+ throw new Error("service name must not contain any slash '/'");
150
+ }
151
+ const component = new components_1.VritualObjectComponent(name);
152
+ for (const [route, handler] of Object.entries(router)) {
153
+ /* eslint-disable @typescript-eslint/no-explicit-any */
154
+ const fn = handler;
155
+ component.add({
156
+ name: route,
157
+ fn: fn.bind(router),
158
+ });
159
+ }
160
+ this.addComponent(component);
161
+ }
162
+ }
163
+ exports.EndpointImpl = EndpointImpl;
164
+ //# sourceMappingURL=endpoint_impl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint_impl.js","sourceRoot":"","sources":["../../../src/endpoint/endpoint_impl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;AAOH,sCAAiC;AACjC,kDAAuE;AACvE,mDAA+C;AAC/C,qDAAiD;AACjD,oDAM6B;AAG7B,6CAA+D;AAE/D,SAAS,mBAAmB,CAC1B,CAAM;IAEN,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC;AACxB,CAAC;AAED,SAAS,kBAAkB,CACzB,CAAM;IAEN,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACvB,CAAC;AAEM,MAAM,YAAY,GAAG,GAAoB,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC;AAAzD,QAAA,YAAY,gBAA6C;AAEtE,MAAa,YAAY;IACN,QAAQ,GAA2B,IAAI,GAAG,EAAE,CAAC;IACtD,OAAO,CAAY;IAE3B,IAAW,MAAM;QACf,OAAO,I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SAChE;QACD,MAAM,SAAS,GAAG,IAAI,6BAAgB,CAAC,IAAI,CAAC,CAAC;QAE7C,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrD,uDAAuD;YACvD,MAAM,EAAE,GAAG,OAA2C,CAAC;YACvD,SAAS,CAAC,GAAG,CAAC;gBACZ,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;IAEO,0BAA0B,CAAC,IAAY,EAAE,MAAiB;QAChE,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAChE;QACD,MAAM,SAAS,GAAG,IAAI,mCAAsB,CAAC,IAAI,CAAC,CAAC;QAEnD,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;YACrD,uDAAuD;YACvD,MAAM,EAAE,GAAG,OAAiD,CAAC;YAC7D,SAAS,CAAC,GAAG,CAAC;gBACZ,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;aACpB,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CACF;AA3KD,oCA2KC"}
@@ -3,9 +3,9 @@ import { Http2ServerRequest, Http2ServerResponse } from "http2";
3
3
  import { EndpointImpl } from "./endpoint_impl";
4
4
  export declare class Http2Handler {
5
5
  private readonly endpoint;
6
- private readonly discoveryResponse;
7
6
  constructor(endpoint: EndpointImpl);
8
7
  acceptConnection(request: Http2ServerRequest, _response: Http2ServerResponse): void;
8
+ private validateConnectionSignature;
9
9
  private handleConnection;
10
10
  }
11
11
  //# sourceMappingURL=http2_handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http2_handler.d.ts","sourceRoot":"","sources":["../../../src/endpoint/http2_handler.ts"],"names":[],"mappings":";AAaA,OAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAiB/C,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAEnD,gBAAgB,CACd,OAAO,EAAE,kBAAkB,EAE3B,SAAS,EAAE,mBAAmB;YAuBlB,2BAA2B;IAmCzC,OAAO,CAAC,gBAAgB;CAkCzB"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2023-2024 - Restate Software, Inc., Restate GmbH
4
+ *
5
+ * This file is part of the Restate SDK for Node.js/TypeScript,
6
+ * which is released under the MIT license.
7
+ *
8
+ * You can find a copy of the license in file LICENSE in the root
9
+ * directory of this repository or package, or at
10
+ * https://github.com/restatedev/sdk-typescript/blob/main/LICENSE
11
+ */
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Http2Handler = void 0;
17
+ const node_stream_1 = __importDefault(require("node:stream"));
18
+ const promises_1 = require("node:stream/promises");
19
+ const http_connection_1 = require("../connection/http_connection");
20
+ const errors_1 = require("../types/errors");
21
+ const invocation_1 = require("../invocation");
22
+ const state_machine_1 = require("../state_machine");
23
+ const logger_1 = require("../logger");
24
+ const components_1 = require("../types/components");
25
+ const discovery_1 = require("../types/discovery");
26
+ const validate_1 = require("./request_signing/validate");
27
+ const user_agent_1 = require("../user_agent");
28
+ class Http2Handler {
29
+ endpoint;
30
+ constructor(endpoint) {
31
+ this.endpoint = endpoint;
32
+ }
33
+ acceptConnection(request,
34
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
+ _response) {
36
+ const stream = request.stream;
37
+ const url = new URL(request.url ?? "/", "https://restate.dev"); // use a dummy base; we only care about path
38
+ this.validateConnectionSignature(request, url, stream)
39
+ .then((result) => {
40
+ if (!result) {
41
+ return;
42
+ }
43
+ else {
44
+ return this.handleConnection(url, stream);
45
+ }
46
+ })
47
+ .catch((e) => {
48
+ const error = (0, errors_1.ensureError)(e);
49
+ logger_1.rlog.error("Error while handling connection: " + (error.stack ?? error.message));
50
+ stream.end();
51
+ stream.destroy();
52
+ });
53
+ }
54
+ async validateConnectionSignature(request, url, stream) {
55
+ if (!this.endpoint.keySet) {
56
+ // not validating
57
+ return true;
58
+ }
59
+ const keySet = this.endpoint.keySet;
60
+ const validateResponse = await (0, validate_1.validateRequestSignature)(keySet, url.pathname ?? "/", request.headers);
61
+ if (!validateResponse.valid) {
62
+ logger_1.rlog.error(`Rejecting request as its JWT did not validate: ${validateResponse.error}`);
63
+ stream.respond({
64
+ "content-type": "application/restate",
65
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
66
+ ":status": 401,
67
+ });
68
+ stream.end();
69
+ stream.destroy();
70
+ return false;
71
+ }
72
+ else {
73
+ return true;
74
+ }
75
+ }
76
+ handleConnection(url, stream) {
77
+ const route = (0, components_1.parseUrlComponents)(url.pathname ?? undefined);
78
+ if (!route) {
79
+ return respondNotFound(stream);
80
+ }
81
+ if (route === "discovery") {
82
+ const discovery = this.endpoint.computeDiscovery(discovery_1.ProtocolMode.BIDI_STREAM);
83
+ return respondDiscovery(discovery, stream);
84
+ }
85
+ const urlComponents = route;
86
+ const component = this.endpoint.componentByName(urlComponents.componentName);
87
+ if (!component) {
88
+ return respondNotFound(stream);
89
+ }
90
+ const handler = component.handlerMatching(urlComponents);
91
+ if (!handler) {
92
+ return respondNotFound(stream);
93
+ }
94
+ // valid connection, let's dispatch the invocation
95
+ stream.respond({
96
+ "content-type": "application/restate",
97
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
98
+ ":status": 200,
99
+ });
100
+ const restateStream = http_connection_1.RestateHttp2Connection.from(stream);
101
+ return handleInvocation(handler, restateStream);
102
+ }
103
+ }
104
+ exports.Http2Handler = Http2Handler;
105
+ function respondDiscovery(response, http2Stream) {
106
+ const responseData = JSON.stringify(response);
107
+ http2Stream.respond({
108
+ ":status": 200,
109
+ "content-type": "application/json",
110
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
111
+ });
112
+ return (0, promises_1.pipeline)(node_stream_1.default.Readable.from(responseData), http2Stream, {
113
+ end: true,
114
+ });
115
+ }
116
+ function respondNotFound(stream) {
117
+ stream.respond({
118
+ "content-type": "application/json",
119
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
120
+ ":status": 404,
121
+ });
122
+ stream.end();
123
+ return (0, promises_1.finished)(stream);
124
+ }
125
+ async function handleInvocation(handler, connection) {
126
+ // step 1: collect all journal events
127
+ const journalBuilder = new invocation_1.InvocationBuilder(handler);
128
+ connection.pipeToConsumer(journalBuilder);
129
+ try {
130
+ await journalBuilder.completion();
131
+ }
132
+ finally {
133
+ // ensure GC friendliness, also in case of errors
134
+ connection.removeCurrentConsumer();
135
+ }
136
+ // step 2: create the state machine
137
+ const invocation = journalBuilder.build();
138
+ const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.BIDI_STREAM, handler instanceof components_1.VirtualObjectHandler, invocation.inferLoggerContext());
139
+ connection.pipeToConsumer(stateMachine);
140
+ // step 3: invoke the function
141
+ // This call would propagate errors in the state machine logic, but not errors
142
+ // in the application function code. Ending a function with an error as well
143
+ // as failign an invocation and being retried are perfectly valid actions from the
144
+ // SDK's perspective.
145
+ try {
146
+ await stateMachine.invoke();
147
+ }
148
+ finally {
149
+ // ensure GC friendliness, also in case of errors
150
+ connection.removeCurrentConsumer();
151
+ }
152
+ }
153
+ //# sourceMappingURL=http2_handler.js.map
@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AM,cAAc,GAAG,IAAI,8BAAiB,CAAC,OAAO,CAAC,CAAC;IACtD,UAAU,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IAC1C,IAAI;QACF,MAAM,cAAc,CAAC,UAAU,EAAE,CAAC;KACnC;YAAS;QACR,iDAAiD;QACjD,UAAU,CAAC,qBAAqB,EAAE,CAAC;KACpC;IAED,mCAAmC;IACnC,MAAM,UAAU,GAAG,cAAc,CAAC,KAAK,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAG,IAAI,4BAAY,CACnC,UAAU,EACV,UAAU,EACV,wBAAY,CAAC,WAAW,EACxB,OAAO,YAAY,iCAAoB,EACvC,UAAU,CAAC,kBAAkB,EAAE,CAChC,CAAC;IACF,UAAU,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IAExC,8BAA8B;IAE9B,8EAA8E;IAC9E,4EAA4E;IAC5E,kFAAkF;IAClF,qBAAqB;IACrB,IAAI;QACF,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC;KAC7B;YAAS;QACR,iDAAiD;QACjD,UAAU,CAAC,qBAAqB,EAAE,CAAC;KACpC;AACH,CAAC"}
@@ -1,13 +1,13 @@
1
- import { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2, Context } from "aws-lambda";
1
+ import type { APIGatewayProxyEvent, APIGatewayProxyEventV2, APIGatewayProxyResult, APIGatewayProxyResultV2, Context } from "aws-lambda";
2
2
  import { EndpointImpl } from "./endpoint_impl";
3
3
  export declare class LambdaHandler {
4
4
  private readonly endpoint;
5
- private readonly discoveryResponse;
6
5
  constructor(endpoint: EndpointImpl);
7
6
  /**
8
7
  * This is the main request handling method, effectively a typed variant of `create()`.
9
8
  */
10
9
  handleRequest(event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: Context): Promise<APIGatewayProxyResult | APIGatewayProxyResultV2>;
10
+ private validateConnectionSignature;
11
11
  private handleInvoke;
12
12
  private handleDiscovery;
13
13
  private toErrorResponse;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda_handler.d.ts","sourceRoot":"","sources":["../../../src/endpoint/lambda_handler.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,OAAO,EACR,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAmB/C,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,YAAY;IAInD;;OAEG;IACG,aAAa,CACjB,KAAK,EAAE,oBAAoB,GAAG,sBAAsB,EACpD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,qBAAqB,GAAG,uBAAuB,CAAC;YAoC7C,2BAA2B;YAkC3B,YAAY;IAgD1B,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,eAAe;CAWxB"}
@@ -12,86 +12,93 @@
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.LambdaHandler = void 0;
14
14
  const logger_1 = require("../logger");
15
- const discovery_1 = require("../generated/proto/discovery");
16
15
  const lambda_connection_1 = require("../connection/lambda_connection");
17
16
  const invocation_1 = require("../invocation");
18
17
  const decoder_1 = require("../io/decoder");
19
18
  const state_machine_1 = require("../state_machine");
20
19
  const errors_1 = require("../types/errors");
21
20
  const protocol_1 = require("../types/protocol");
21
+ const discovery_1 = require("../types/discovery");
22
+ const components_1 = require("../types/components");
23
+ const validate_1 = require("./request_signing/validate");
24
+ const user_agent_1 = require("../user_agent");
25
+ const node_buffer_1 = require("node:buffer");
22
26
  class LambdaHandler {
23
27
  endpoint;
24
- discoveryResponse;
25
28
  constructor(endpoint) {
26
29
  this.endpoint = endpoint;
27
- this.discoveryResponse = discovery_1.ServiceDiscoveryResponse.fromPartial({
28
- ...this.endpoint.discovery,
29
- protocolMode: discovery_1.ProtocolMode.REQUEST_RESPONSE,
30
- });
31
30
  }
32
31
  // --------------------------------------------------------------------------
33
32
  /**
34
33
  * This is the main request handling method, effectively a typed variant of `create()`.
35
34
  */
36
35
  async handleRequest(event, context) {
37
- let path;
38
- if ("path" in event) {
39
- // V1
40
- path = event.path;
36
+ const path = "path" in event ? event.path : event.rawPath;
37
+ const error = await this.validateConnectionSignature(path, event.headers);
38
+ if (error !== null) {
39
+ return error;
41
40
  }
42
- else {
43
- // V2
44
- path = event.rawPath;
45
- }
46
- const pathSegments = path.split("/");
47
- // API Gateway can add a prefix to the path based on the name of the Lambda function and deployment stage
48
- // (e.g. /default)
49
- // So we only check the ending of the path on correctness.
50
- // Logic:
51
- // 1. Check whether there are at least three segments in the path and whether the third-last one is "invoke".
52
- // If that is the case, treat it as an invocation.
53
- // 2. See if the last one is "discover", answer with discovery.
54
- // 3. Else report "invalid path".
55
- if (pathSegments.length >= 3 &&
56
- pathSegments[pathSegments.length - 3] === "invoke") {
57
- const url = "/" + pathSegments.slice(-3).join("/");
58
- return await this.handleInvoke(url, event, context);
41
+ const parsed = (0, components_1.parseUrlComponents)(path);
42
+ if (!parsed) {
43
+ const msg = `Invalid path: path doesn't end in /invoke/SvcName/handlerName and also not in /discover: ${path}`;
44
+ logger_1.rlog.trace(msg);
45
+ return this.toErrorResponse(404, msg);
59
46
  }
60
- else if (pathSegments[pathSegments.length - 1] === "discover") {
47
+ if (parsed === "discovery") {
61
48
  return this.handleDiscovery();
62
49
  }
63
- else {
64
- const msg = `Invalid path: path doesn't end in /invoke/SvcName/MethodName and also not in /discover: ${path}`;
65
- logger_1.rlog.trace(msg);
66
- return this.toErrorResponse(500, msg);
50
+ const parsedUrl = parsed;
51
+ const method = this.endpoint.componentByName(parsedUrl.componentName);
52
+ if (!method) {
53
+ const msg = `No service found for URL: ${parsedUrl}`;
54
+ logger_1.rlog.error(msg);
55
+ return this.toErrorResponse(404, msg);
67
56
  }
57
+ const handler = method?.handlerMatching(parsedUrl);
58
+ if (!handler) {
59
+ const msg = `No service found for URL: ${parsedUrl}`;
60
+ logger_1.rlog.error(msg);
61
+ return this.toErrorResponse(404, msg);
62
+ }
63
+ if (!event.body) {
64
+ throw new Error("The incoming message body was null");
65
+ }
66
+ return this.handleInvoke(handler, event.body, context);
68
67
  }
69
- async handleInvoke(url, event, context) {
68
+ async validateConnectionSignature(path, headers) {
69
+ if (!this.endpoint.keySet) {
70
+ // not validating
71
+ return null;
72
+ }
70
73
  try {
71
- const method = this.endpoint.methodByUrl(url);
72
- if (event.body == null) {
73
- throw new Error("The incoming message body was null");
74
+ const validateResponse = await (0, validate_1.validateRequestSignature)(this.endpoint.keySet, path, headers);
75
+ if (!validateResponse.valid) {
76
+ logger_1.rlog.error(`Rejecting request as its JWT did not validate: ${validateResponse.error}`);
77
+ return this.toErrorResponse(401, "Unauthorized");
74
78
  }
75
- if (method === undefined) {
76
- if (url.includes("?")) {
77
- throw new Error(`Invalid path: path URL seems to include query parameters: ${url}`);
78
- }
79
- else {
80
- const msg = `No service found for URL: ${url}`;
81
- logger_1.rlog.error(msg);
82
- return this.toErrorResponse(404, msg);
83
- }
79
+ else {
80
+ return null;
84
81
  }
82
+ }
83
+ catch (e) {
84
+ const error = (0, errors_1.ensureError)(e);
85
+ logger_1.rlog.error("Error while attempting to validate request signature:" + error.stack ??
86
+ error.message);
87
+ return this.toErrorResponse(401, "Unauthorized");
88
+ }
89
+ }
90
+ async handleInvoke(handler, body, context) {
91
+ try {
85
92
  // build the previous journal from the events
86
- let decodedEntries = (0, decoder_1.decodeLambdaBody)(event.body);
87
- const journalBuilder = new invocation_1.InvocationBuilder(method);
93
+ let decodedEntries = (0, decoder_1.decodeLambdaBody)(body);
94
+ const journalBuilder = new invocation_1.InvocationBuilder(handler);
88
95
  decodedEntries.forEach((e) => journalBuilder.handleMessage(e));
89
- const alreadyCompleted = decodedEntries.find((e) => e.messageType === protocol_1.OUTPUT_STREAM_ENTRY_MESSAGE_TYPE) !== undefined;
96
+ const alreadyCompleted = decodedEntries.find((e) => e.messageType === protocol_1.OUTPUT_ENTRY_MESSAGE_TYPE) !== undefined;
90
97
  decodedEntries = null;
91
98
  // set up and invoke the state machine
92
99
  const connection = new lambda_connection_1.LambdaConnection(alreadyCompleted);
93
100
  const invocation = journalBuilder.build();
94
- const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.REQUEST_RESPONSE, method.method.keyedContext, invocation.inferLoggerContext({
101
+ const stateMachine = new state_machine_1.StateMachine(connection, invocation, discovery_1.ProtocolMode.REQUEST_RESPONSE, handler instanceof components_1.VirtualObjectHandler, invocation.inferLoggerContext({
95
102
  AWSRequestId: context.awsRequestId,
96
103
  }));
97
104
  await stateMachine.invoke();
@@ -99,6 +106,7 @@ class LambdaHandler {
99
106
  return {
100
107
  headers: {
101
108
  "content-type": "application/restate",
109
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
102
110
  },
103
111
  statusCode: 200,
104
112
  isBase64Encoded: true,
@@ -113,32 +121,34 @@ class LambdaHandler {
113
121
  }
114
122
  }
115
123
  handleDiscovery() {
116
- // return discovery information
117
- logger_1.rlog.info("Answering discovery request. Announcing services: " +
118
- JSON.stringify(this.discoveryResponse.services));
124
+ const disocvery = this.endpoint.computeDiscovery(discovery_1.ProtocolMode.REQUEST_RESPONSE);
125
+ const discoveryJson = JSON.stringify(disocvery);
126
+ const body = node_buffer_1.Buffer.from(discoveryJson).toString("base64");
119
127
  return {
120
128
  headers: {
121
- "content-type": "application/proto",
129
+ "content-type": "application/json",
130
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
122
131
  },
123
132
  statusCode: 200,
124
133
  isBase64Encoded: true,
125
- body: encodeResponse(discovery_1.ServiceDiscoveryResponse.encode(this.discoveryResponse).finish()),
134
+ body,
126
135
  };
127
136
  }
128
137
  toErrorResponse(code, message) {
129
138
  return {
130
139
  headers: {
131
140
  "content-type": "application/restate",
141
+ "x-restate-server": user_agent_1.X_RESTATE_SERVER,
132
142
  },
133
143
  statusCode: code,
134
144
  isBase64Encoded: true,
135
- body: encodeResponse(Buffer.from(JSON.stringify({ message }))),
145
+ body: encodeResponse(node_buffer_1.Buffer.from(JSON.stringify({ message }))),
136
146
  };
137
147
  }
138
148
  }
139
149
  exports.LambdaHandler = LambdaHandler;
140
150
  function encodeResponse(data) {
141
- const buffer = data instanceof Buffer ? data : Buffer.from(data);
151
+ const buffer = data instanceof node_buffer_1.Buffer ? data : node_buffer_1.Buffer.from(data);
142
152
  return buffer.toString("base64");
143
153
  }
144
154
  //# sourceMappingURL=lambda_handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda_handler.js","sourceRoot":"","sources":["../../../src/endpoint/lambda_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAEH,sCAAiC;AASjC,uEAAmE;AACnE,8CAAkD;AAClD,2CAAiD;AAEjD,oDAAgD;AAChD,4CAA8C;AAC9C,gDAA8D;AAC9D,kDAAkD;AAClD,oDAK6B;AAC7B,yDAAsE;AACtE,8CAAiD;AACjD,6CAAqC;AAErC,MAAa,aAAa;IACK;IAA7B,YAA6B,QAAsB;QAAtB,aAAQ,GAAR,QAAQ,CAAc;IAAG,CAAC;IAEvD,6EAA6E;IAE7E;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,KAAoD,EACpD,OAAgB;QAEhB,MAAM,IAAI,GAAG,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QAE1D,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,2BAA2B,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,OAAO,KAAK,CAAC;SACd;QAED,MAAM,MAAM,GAAG,IAAA,+BAAkB,EAAC,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,GAAG,4FAA4F,IAAI,EAAE,CAAC;YAC/G,aAAI,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,OAAe;QACnD,OAAO;YACL,OAAO,EAAE;gBACP,cAAc,EAAE,qBAAqB;gBACrC,kBAAkB,EAAE,6BAAgB;aACrC;YACD,UAAU,EAAE,IAAI;YAChB,eAAe,EAAE,IAAI;YACrB,IAAI,EAAE,cAAc,CAAC,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;SAC/D,CAAC;IACJ,CAAC;CACF;AA9JD,sCA8JC;AAED,SAAS,cAAc,CAAC,IAAgB;IACtC,MAAM,MAAM,GAAG,IAAI,YAAY,oBAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,10 @@
1
+ declare function base(ALPHABET: string): base.BaseConverter;
2
+ export default base;
3
+ declare namespace base {
4
+ interface BaseConverter {
5
+ encode(buffer: Uint8Array | number[]): string;
6
+ decodeUnsafe(string: string): Uint8Array | undefined;
7
+ decode(string: string): Uint8Array;
8
+ }
9
+ }
10
+ //# sourceMappingURL=basex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basex.d.ts","sourceRoot":"","sources":["../../../../src/endpoint/request_signing/basex.ts"],"names":[],"mappings":"AAUA,iBAAS,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC,aAAa,CA2JlD;AAED,eAAe,IAAI,CAAC;AAEpB,OAAO,WAAW,IAAI,CAAC;IACrB,UAAU,aAAa;QACrB,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC;QAE9C,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;QAErD,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;KACpC;CACF"}