@microsoft/agents-hosting 0.1.49

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 (394) hide show
  1. package/README.md +57 -0
  2. package/dist/src/activityHandler.d.ts +108 -0
  3. package/dist/src/activityHandler.js +395 -0
  4. package/dist/src/activityHandler.js.map +1 -0
  5. package/dist/src/agent-client/agentClient.d.ts +13 -0
  6. package/dist/src/agent-client/agentClient.js +75 -0
  7. package/dist/src/agent-client/agentClient.js.map +1 -0
  8. package/dist/src/agent-client/expressApi.d.ts +4 -0
  9. package/dist/src/agent-client/expressApi.js +50 -0
  10. package/dist/src/agent-client/expressApi.js.map +1 -0
  11. package/dist/src/agent-client/index.d.ts +2 -0
  12. package/dist/src/agent-client/index.js +19 -0
  13. package/dist/src/agent-client/index.js.map +1 -0
  14. package/dist/src/app/agentApplication.d.ts +47 -0
  15. package/dist/src/app/agentApplication.js +317 -0
  16. package/dist/src/app/agentApplication.js.map +1 -0
  17. package/dist/src/app/appRoute.d.ts +11 -0
  18. package/dist/src/app/appRoute.js +7 -0
  19. package/dist/src/app/appRoute.js.map +1 -0
  20. package/dist/src/app/applicationBuilder.d.ts +18 -0
  21. package/dist/src/app/applicationBuilder.js +37 -0
  22. package/dist/src/app/applicationBuilder.js.map +1 -0
  23. package/dist/src/app/applicationOptions.d.ts +19 -0
  24. package/dist/src/app/applicationOptions.js +7 -0
  25. package/dist/src/app/applicationOptions.js.map +1 -0
  26. package/dist/src/app/attachmentDownloader.d.ts +13 -0
  27. package/dist/src/app/attachmentDownloader.js +72 -0
  28. package/dist/src/app/attachmentDownloader.js.map +1 -0
  29. package/dist/src/app/conversationUpdateEvents.d.ts +5 -0
  30. package/dist/src/app/conversationUpdateEvents.js +7 -0
  31. package/dist/src/app/conversationUpdateEvents.js.map +1 -0
  32. package/dist/src/app/index.d.ts +10 -0
  33. package/dist/src/app/index.js +27 -0
  34. package/dist/src/app/index.js.map +1 -0
  35. package/dist/src/app/inputFileDownloader.d.ts +14 -0
  36. package/dist/src/app/inputFileDownloader.js +7 -0
  37. package/dist/src/app/inputFileDownloader.js.map +1 -0
  38. package/dist/src/app/memory.d.ts +10 -0
  39. package/dist/src/app/memory.js +7 -0
  40. package/dist/src/app/memory.js.map +1 -0
  41. package/dist/src/app/oauth/authenticationOptions.d.ts +7 -0
  42. package/dist/src/app/oauth/authenticationOptions.js +7 -0
  43. package/dist/src/app/oauth/authenticationOptions.js.map +1 -0
  44. package/dist/src/app/oauth/webChatOAuthFlowAppStyle.d.ts +11 -0
  45. package/dist/src/app/oauth/webChatOAuthFlowAppStyle.js +85 -0
  46. package/dist/src/app/oauth/webChatOAuthFlowAppStyle.js.map +1 -0
  47. package/dist/src/app/routeHandler.d.ts +7 -0
  48. package/dist/src/app/routeHandler.js +7 -0
  49. package/dist/src/app/routeHandler.js.map +1 -0
  50. package/dist/src/app/routeSelector.d.ts +7 -0
  51. package/dist/src/app/routeSelector.js +7 -0
  52. package/dist/src/app/routeSelector.js.map +1 -0
  53. package/dist/src/app/turnEvents.d.ts +5 -0
  54. package/dist/src/app/turnEvents.js +7 -0
  55. package/dist/src/app/turnEvents.js.map +1 -0
  56. package/dist/src/app/turnState.d.ts +85 -0
  57. package/dist/src/app/turnState.js +274 -0
  58. package/dist/src/app/turnState.js.map +1 -0
  59. package/dist/src/app/turnStateEntry.d.ts +17 -0
  60. package/dist/src/app/turnStateEntry.js +39 -0
  61. package/dist/src/app/turnStateEntry.js.map +1 -0
  62. package/dist/src/auth/authConfiguration.d.ts +29 -0
  63. package/dist/src/auth/authConfiguration.js +58 -0
  64. package/dist/src/auth/authConfiguration.js.map +1 -0
  65. package/dist/src/auth/authProvider.d.ts +17 -0
  66. package/dist/src/auth/authProvider.js +7 -0
  67. package/dist/src/auth/authProvider.js.map +1 -0
  68. package/dist/src/auth/index.d.ts +4 -0
  69. package/dist/src/auth/index.js +21 -0
  70. package/dist/src/auth/index.js.map +1 -0
  71. package/dist/src/auth/jwt-middleware.d.ts +13 -0
  72. package/dist/src/auth/jwt-middleware.js +97 -0
  73. package/dist/src/auth/jwt-middleware.js.map +1 -0
  74. package/dist/src/auth/msalTokenProvider.d.ts +53 -0
  75. package/dist/src/auth/msalTokenProvider.js +198 -0
  76. package/dist/src/auth/msalTokenProvider.js.map +1 -0
  77. package/dist/src/auth/request.d.ts +15 -0
  78. package/dist/src/auth/request.js +7 -0
  79. package/dist/src/auth/request.js.map +1 -0
  80. package/dist/src/baseAdapter.d.ts +88 -0
  81. package/dist/src/baseAdapter.js +94 -0
  82. package/dist/src/baseAdapter.js.map +1 -0
  83. package/dist/src/cards/animationCard.d.ts +36 -0
  84. package/dist/src/cards/animationCard.js +7 -0
  85. package/dist/src/cards/animationCard.js.map +1 -0
  86. package/dist/src/cards/audioCard.d.ts +36 -0
  87. package/dist/src/cards/audioCard.js +7 -0
  88. package/dist/src/cards/audioCard.js.map +1 -0
  89. package/dist/src/cards/cardFactory.d.ts +123 -0
  90. package/dist/src/cards/cardFactory.js +225 -0
  91. package/dist/src/cards/cardFactory.js.map +1 -0
  92. package/dist/src/cards/cardImage.d.ts +16 -0
  93. package/dist/src/cards/cardImage.js +7 -0
  94. package/dist/src/cards/cardImage.js.map +1 -0
  95. package/dist/src/cards/fact.d.ts +13 -0
  96. package/dist/src/cards/fact.js +7 -0
  97. package/dist/src/cards/fact.js.map +1 -0
  98. package/dist/src/cards/heroCard.d.ts +23 -0
  99. package/dist/src/cards/heroCard.js +7 -0
  100. package/dist/src/cards/heroCard.js.map +1 -0
  101. package/dist/src/cards/index.d.ts +17 -0
  102. package/dist/src/cards/index.js +34 -0
  103. package/dist/src/cards/index.js.map +1 -0
  104. package/dist/src/cards/mediaUrl.d.ts +17 -0
  105. package/dist/src/cards/mediaUrl.js +7 -0
  106. package/dist/src/cards/mediaUrl.js.map +1 -0
  107. package/dist/src/cards/o365ConnectorCard.d.ts +35 -0
  108. package/dist/src/cards/o365ConnectorCard.js +7 -0
  109. package/dist/src/cards/o365ConnectorCard.js.map +1 -0
  110. package/dist/src/cards/o365ConnectorCardActionBase.d.ts +22 -0
  111. package/dist/src/cards/o365ConnectorCardActionBase.js +7 -0
  112. package/dist/src/cards/o365ConnectorCardActionBase.js.map +1 -0
  113. package/dist/src/cards/o365ConnectorCardFact.d.ts +17 -0
  114. package/dist/src/cards/o365ConnectorCardFact.js +7 -0
  115. package/dist/src/cards/o365ConnectorCardFact.js.map +1 -0
  116. package/dist/src/cards/o365ConnectorCardImage.d.ts +17 -0
  117. package/dist/src/cards/o365ConnectorCardImage.js +7 -0
  118. package/dist/src/cards/o365ConnectorCardImage.js.map +1 -0
  119. package/dist/src/cards/o365ConnectorCardSection.d.ts +57 -0
  120. package/dist/src/cards/o365ConnectorCardSection.js +7 -0
  121. package/dist/src/cards/o365ConnectorCardSection.js.map +1 -0
  122. package/dist/src/cards/receiptCard.d.ts +44 -0
  123. package/dist/src/cards/receiptCard.js +7 -0
  124. package/dist/src/cards/receiptCard.js.map +1 -0
  125. package/dist/src/cards/receiptItem.d.ts +39 -0
  126. package/dist/src/cards/receiptItem.js +7 -0
  127. package/dist/src/cards/receiptItem.js.map +1 -0
  128. package/dist/src/cards/signinCard.d.ts +14 -0
  129. package/dist/src/cards/signinCard.js +5 -0
  130. package/dist/src/cards/signinCard.js.map +1 -0
  131. package/dist/src/cards/taskModuleAction.d.ts +43 -0
  132. package/dist/src/cards/taskModuleAction.js +30 -0
  133. package/dist/src/cards/taskModuleAction.js.map +1 -0
  134. package/dist/src/cards/thumbnailCard.d.ts +35 -0
  135. package/dist/src/cards/thumbnailCard.js +7 -0
  136. package/dist/src/cards/thumbnailCard.js.map +1 -0
  137. package/dist/src/cards/thumbnailUrl.d.ts +17 -0
  138. package/dist/src/cards/thumbnailUrl.js +7 -0
  139. package/dist/src/cards/thumbnailUrl.js.map +1 -0
  140. package/dist/src/cards/videoCard.d.ts +60 -0
  141. package/dist/src/cards/videoCard.js +7 -0
  142. package/dist/src/cards/videoCard.js.map +1 -0
  143. package/dist/src/claimsIdentity.d.ts +35 -0
  144. package/dist/src/claimsIdentity.js +43 -0
  145. package/dist/src/claimsIdentity.js.map +1 -0
  146. package/dist/src/cloudAdapter.d.ts +128 -0
  147. package/dist/src/cloudAdapter.js +376 -0
  148. package/dist/src/cloudAdapter.js.map +1 -0
  149. package/dist/src/connector-client/attachmentData.d.ts +25 -0
  150. package/dist/src/connector-client/attachmentData.js +7 -0
  151. package/dist/src/connector-client/attachmentData.js.map +1 -0
  152. package/dist/src/connector-client/attachmentInfo.d.ts +22 -0
  153. package/dist/src/connector-client/attachmentInfo.js +7 -0
  154. package/dist/src/connector-client/attachmentInfo.js.map +1 -0
  155. package/dist/src/connector-client/attachmentView.d.ts +17 -0
  156. package/dist/src/connector-client/attachmentView.js +7 -0
  157. package/dist/src/connector-client/attachmentView.js.map +1 -0
  158. package/dist/src/connector-client/connectorClient.d.ts +93 -0
  159. package/dist/src/connector-client/connectorClient.js +249 -0
  160. package/dist/src/connector-client/connectorClient.js.map +1 -0
  161. package/dist/src/connector-client/conversationMembers.d.ts +18 -0
  162. package/dist/src/connector-client/conversationMembers.js +7 -0
  163. package/dist/src/connector-client/conversationMembers.js.map +1 -0
  164. package/dist/src/connector-client/conversationParameters.d.ts +38 -0
  165. package/dist/src/connector-client/conversationParameters.js +7 -0
  166. package/dist/src/connector-client/conversationParameters.js.map +1 -0
  167. package/dist/src/connector-client/conversationResourceResponse.d.ts +21 -0
  168. package/dist/src/connector-client/conversationResourceResponse.js +7 -0
  169. package/dist/src/connector-client/conversationResourceResponse.js.map +1 -0
  170. package/dist/src/connector-client/conversationsResult.d.ts +18 -0
  171. package/dist/src/connector-client/conversationsResult.js +7 -0
  172. package/dist/src/connector-client/conversationsResult.js.map +1 -0
  173. package/dist/src/connector-client/index.d.ts +9 -0
  174. package/dist/src/connector-client/index.js +26 -0
  175. package/dist/src/connector-client/index.js.map +1 -0
  176. package/dist/src/connector-client/resourceResponse.d.ts +13 -0
  177. package/dist/src/connector-client/resourceResponse.js +7 -0
  178. package/dist/src/connector-client/resourceResponse.js.map +1 -0
  179. package/dist/src/index.d.ts +26 -0
  180. package/dist/src/index.js +45 -0
  181. package/dist/src/index.js.map +1 -0
  182. package/dist/src/invoke/adaptiveCardAuthentication.d.ts +10 -0
  183. package/dist/src/invoke/adaptiveCardAuthentication.js +7 -0
  184. package/dist/src/invoke/adaptiveCardAuthentication.js.map +1 -0
  185. package/dist/src/invoke/adaptiveCardInvokeResponse.d.ts +21 -0
  186. package/dist/src/invoke/adaptiveCardInvokeResponse.js +7 -0
  187. package/dist/src/invoke/adaptiveCardInvokeResponse.js.map +1 -0
  188. package/dist/src/invoke/adaptiveCardInvokeValue.d.ts +23 -0
  189. package/dist/src/invoke/adaptiveCardInvokeValue.js +7 -0
  190. package/dist/src/invoke/adaptiveCardInvokeValue.js.map +1 -0
  191. package/dist/src/invoke/index.d.ts +9 -0
  192. package/dist/src/invoke/index.js +26 -0
  193. package/dist/src/invoke/index.js.map +1 -0
  194. package/dist/src/invoke/invokeException.d.ts +24 -0
  195. package/dist/src/invoke/invokeException.js +35 -0
  196. package/dist/src/invoke/invokeException.js.map +1 -0
  197. package/dist/src/invoke/invokeResponse.d.ts +17 -0
  198. package/dist/src/invoke/invokeResponse.js +7 -0
  199. package/dist/src/invoke/invokeResponse.js.map +1 -0
  200. package/dist/src/invoke/searchInvokeOptions.d.ts +17 -0
  201. package/dist/src/invoke/searchInvokeOptions.js +7 -0
  202. package/dist/src/invoke/searchInvokeOptions.js.map +1 -0
  203. package/dist/src/invoke/searchInvokeResponse.d.ts +10 -0
  204. package/dist/src/invoke/searchInvokeResponse.js +7 -0
  205. package/dist/src/invoke/searchInvokeResponse.js.map +1 -0
  206. package/dist/src/invoke/searchInvokeValue.d.ts +26 -0
  207. package/dist/src/invoke/searchInvokeValue.js +7 -0
  208. package/dist/src/invoke/searchInvokeValue.js.map +1 -0
  209. package/dist/src/invoke/tokenExchangeInvokeRequest.d.ts +21 -0
  210. package/dist/src/invoke/tokenExchangeInvokeRequest.js +7 -0
  211. package/dist/src/invoke/tokenExchangeInvokeRequest.js.map +1 -0
  212. package/dist/src/logger.d.ts +12 -0
  213. package/dist/src/logger.js +42 -0
  214. package/dist/src/logger.js.map +1 -0
  215. package/dist/src/messageFactory.d.ts +62 -0
  216. package/dist/src/messageFactory.js +143 -0
  217. package/dist/src/messageFactory.js.map +1 -0
  218. package/dist/src/middlewareSet.d.ts +43 -0
  219. package/dist/src/middlewareSet.js +57 -0
  220. package/dist/src/middlewareSet.js.map +1 -0
  221. package/dist/src/oauth/index.d.ts +7 -0
  222. package/dist/src/oauth/index.js +24 -0
  223. package/dist/src/oauth/index.js.map +1 -0
  224. package/dist/src/oauth/oauthCard.d.ts +28 -0
  225. package/dist/src/oauth/oauthCard.js +5 -0
  226. package/dist/src/oauth/oauthCard.js.map +1 -0
  227. package/dist/src/oauth/signingResource.d.ts +19 -0
  228. package/dist/src/oauth/signingResource.js +5 -0
  229. package/dist/src/oauth/signingResource.js.map +1 -0
  230. package/dist/src/oauth/tokenExchangeRequest.d.ts +17 -0
  231. package/dist/src/oauth/tokenExchangeRequest.js +5 -0
  232. package/dist/src/oauth/tokenExchangeRequest.js.map +1 -0
  233. package/dist/src/oauth/tokenExchangeResource.d.ts +17 -0
  234. package/dist/src/oauth/tokenExchangeResource.js +5 -0
  235. package/dist/src/oauth/tokenExchangeResource.js.map +1 -0
  236. package/dist/src/oauth/tokenPostResource.d.ts +9 -0
  237. package/dist/src/oauth/tokenPostResource.js +5 -0
  238. package/dist/src/oauth/tokenPostResource.js.map +1 -0
  239. package/dist/src/oauth/userTokenClient.d.ts +49 -0
  240. package/dist/src/oauth/userTokenClient.js +117 -0
  241. package/dist/src/oauth/userTokenClient.js.map +1 -0
  242. package/dist/src/oauth/webChatOAuthFlow.d.ts +41 -0
  243. package/dist/src/oauth/webChatOAuthFlow.js +117 -0
  244. package/dist/src/oauth/webChatOAuthFlow.js.map +1 -0
  245. package/dist/src/state/agentState.d.ts +71 -0
  246. package/dist/src/state/agentState.js +122 -0
  247. package/dist/src/state/agentState.js.map +1 -0
  248. package/dist/src/state/agentStatePropertyAccesor.d.ts +39 -0
  249. package/dist/src/state/agentStatePropertyAccesor.js +60 -0
  250. package/dist/src/state/agentStatePropertyAccesor.js.map +1 -0
  251. package/dist/src/state/conversationState.d.ts +18 -0
  252. package/dist/src/state/conversationState.js +38 -0
  253. package/dist/src/state/conversationState.js.map +1 -0
  254. package/dist/src/state/index.d.ts +4 -0
  255. package/dist/src/state/index.js +21 -0
  256. package/dist/src/state/index.js.map +1 -0
  257. package/dist/src/state/userState.d.ts +18 -0
  258. package/dist/src/state/userState.js +38 -0
  259. package/dist/src/state/userState.js.map +1 -0
  260. package/dist/src/statusCodes.d.ts +19 -0
  261. package/dist/src/statusCodes.js +24 -0
  262. package/dist/src/statusCodes.js.map +1 -0
  263. package/dist/src/storage/index.d.ts +2 -0
  264. package/dist/src/storage/index.js +19 -0
  265. package/dist/src/storage/index.js.map +1 -0
  266. package/dist/src/storage/memoryStorage.d.ts +50 -0
  267. package/dist/src/storage/memoryStorage.js +100 -0
  268. package/dist/src/storage/memoryStorage.js.map +1 -0
  269. package/dist/src/storage/storage.d.ts +47 -0
  270. package/dist/src/storage/storage.js +7 -0
  271. package/dist/src/storage/storage.js.map +1 -0
  272. package/dist/src/tokenResponseEventName.d.ts +5 -0
  273. package/dist/src/tokenResponseEventName.js +9 -0
  274. package/dist/src/tokenResponseEventName.js.map +1 -0
  275. package/dist/src/transcript/consoleTranscriptLogger.d.ts +13 -0
  276. package/dist/src/transcript/consoleTranscriptLogger.js +21 -0
  277. package/dist/src/transcript/consoleTranscriptLogger.js.map +1 -0
  278. package/dist/src/transcript/index.d.ts +4 -0
  279. package/dist/src/transcript/index.js +21 -0
  280. package/dist/src/transcript/index.js.map +1 -0
  281. package/dist/src/transcript/transcriptLogger.d.ts +42 -0
  282. package/dist/src/transcript/transcriptLogger.js +3 -0
  283. package/dist/src/transcript/transcriptLogger.js.map +1 -0
  284. package/dist/src/transcript/transcriptLoggerMiddleware.d.ts +38 -0
  285. package/dist/src/transcript/transcriptLoggerMiddleware.js +126 -0
  286. package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -0
  287. package/dist/src/transcript/transcriptStore.d.ts +30 -0
  288. package/dist/src/transcript/transcriptStore.js +3 -0
  289. package/dist/src/transcript/transcriptStore.js.map +1 -0
  290. package/dist/src/turnContext.d.ts +160 -0
  291. package/dist/src/turnContext.js +286 -0
  292. package/dist/src/turnContext.js.map +1 -0
  293. package/dist/src/turnContextStateCollection.d.ts +29 -0
  294. package/dist/src/turnContextStateCollection.js +56 -0
  295. package/dist/src/turnContextStateCollection.js.map +1 -0
  296. package/package.json +48 -0
  297. package/src/activityHandler.ts +461 -0
  298. package/src/agent-client/agentClient.ts +84 -0
  299. package/src/agent-client/expressApi.ts +59 -0
  300. package/src/agent-client/index.ts +2 -0
  301. package/src/app/agentApplication.ts +401 -0
  302. package/src/app/appRoute.ts +13 -0
  303. package/src/app/applicationBuilder.ts +42 -0
  304. package/src/app/applicationOptions.ts +21 -0
  305. package/src/app/attachmentDownloader.ts +83 -0
  306. package/src/app/conversationUpdateEvents.ts +8 -0
  307. package/src/app/index.ts +10 -0
  308. package/src/app/inputFileDownloader.ts +17 -0
  309. package/src/app/memory.ts +14 -0
  310. package/src/app/oauth/authenticationOptions.ts +8 -0
  311. package/src/app/oauth/webChatOAuthFlowAppStyle.ts +90 -0
  312. package/src/app/routeHandler.ts +9 -0
  313. package/src/app/routeSelector.ts +10 -0
  314. package/src/app/turnEvents.ts +6 -0
  315. package/src/app/turnState.ts +338 -0
  316. package/src/app/turnStateEntry.ts +46 -0
  317. package/src/auth/authConfiguration.ts +68 -0
  318. package/src/auth/authProvider.ts +19 -0
  319. package/src/auth/index.ts +4 -0
  320. package/src/auth/jwt-middleware.ts +99 -0
  321. package/src/auth/msalTokenProvider.ts +202 -0
  322. package/src/auth/request.ts +20 -0
  323. package/src/baseAdapter.ts +174 -0
  324. package/src/cards/animationCard.ts +38 -0
  325. package/src/cards/audioCard.ts +38 -0
  326. package/src/cards/cardFactory.ts +276 -0
  327. package/src/cards/cardImage.ts +18 -0
  328. package/src/cards/fact.ts +14 -0
  329. package/src/cards/heroCard.ts +25 -0
  330. package/src/cards/index.ts +17 -0
  331. package/src/cards/mediaUrl.ts +18 -0
  332. package/src/cards/o365ConnectorCard.ts +37 -0
  333. package/src/cards/o365ConnectorCardActionBase.ts +24 -0
  334. package/src/cards/o365ConnectorCardFact.ts +18 -0
  335. package/src/cards/o365ConnectorCardImage.ts +18 -0
  336. package/src/cards/o365ConnectorCardSection.ts +60 -0
  337. package/src/cards/receiptCard.ts +46 -0
  338. package/src/cards/receiptItem.ts +41 -0
  339. package/src/cards/signinCard.ts +18 -0
  340. package/src/cards/taskModuleAction.ts +61 -0
  341. package/src/cards/thumbnailCard.ts +37 -0
  342. package/src/cards/thumbnailUrl.ts +18 -0
  343. package/src/cards/videoCard.ts +62 -0
  344. package/src/claimsIdentity.ts +47 -0
  345. package/src/cloudAdapter.ts +431 -0
  346. package/src/connector-client/attachmentData.ts +26 -0
  347. package/src/connector-client/attachmentInfo.ts +24 -0
  348. package/src/connector-client/attachmentView.ts +18 -0
  349. package/src/connector-client/connectorClient.ts +295 -0
  350. package/src/connector-client/conversationMembers.ts +20 -0
  351. package/src/connector-client/conversationParameters.ts +40 -0
  352. package/src/connector-client/conversationResourceResponse.ts +22 -0
  353. package/src/connector-client/conversationsResult.ts +20 -0
  354. package/src/connector-client/index.ts +9 -0
  355. package/src/connector-client/resourceResponse.ts +14 -0
  356. package/src/index.ts +31 -0
  357. package/src/invoke/adaptiveCardAuthentication.ts +13 -0
  358. package/src/invoke/adaptiveCardInvokeResponse.ts +22 -0
  359. package/src/invoke/adaptiveCardInvokeValue.ts +25 -0
  360. package/src/invoke/index.ts +9 -0
  361. package/src/invoke/invokeException.ts +33 -0
  362. package/src/invoke/invokeResponse.ts +18 -0
  363. package/src/invoke/searchInvokeOptions.ts +18 -0
  364. package/src/invoke/searchInvokeResponse.ts +11 -0
  365. package/src/invoke/searchInvokeValue.ts +28 -0
  366. package/src/invoke/tokenExchangeInvokeRequest.ts +22 -0
  367. package/src/logger.ts +43 -0
  368. package/src/messageFactory.ts +177 -0
  369. package/src/middlewareSet.ts +76 -0
  370. package/src/oauth/index.ts +7 -0
  371. package/src/oauth/oauthCard.ts +32 -0
  372. package/src/oauth/signingResource.ts +23 -0
  373. package/src/oauth/tokenExchangeRequest.ts +20 -0
  374. package/src/oauth/tokenExchangeResource.ts +20 -0
  375. package/src/oauth/tokenPostResource.ts +12 -0
  376. package/src/oauth/userTokenClient.ts +116 -0
  377. package/src/oauth/webChatOAuthFlow.ts +123 -0
  378. package/src/state/agentState.ts +142 -0
  379. package/src/state/agentStatePropertyAccesor.ts +61 -0
  380. package/src/state/conversationState.ts +42 -0
  381. package/src/state/index.ts +4 -0
  382. package/src/state/userState.ts +43 -0
  383. package/src/statusCodes.ts +20 -0
  384. package/src/storage/index.ts +2 -0
  385. package/src/storage/memoryStorage.ts +105 -0
  386. package/src/storage/storage.ts +52 -0
  387. package/src/tokenResponseEventName.ts +6 -0
  388. package/src/transcript/consoleTranscriptLogger.ts +20 -0
  389. package/src/transcript/index.ts +4 -0
  390. package/src/transcript/transcriptLogger.ts +45 -0
  391. package/src/transcript/transcriptLoggerMiddleware.ts +151 -0
  392. package/src/transcript/transcriptStore.ts +38 -0
  393. package/src/turnContext.ts +335 -0
  394. package/src/turnContextStateCollection.ts +69 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Storage, StorageKeyFactory } from '../storage/storage';
6
+ import { TurnContext } from '../turnContext';
7
+ import { AgentStatePropertyAccessor } from './agentStatePropertyAccesor';
8
+ export interface CachedAgentState {
9
+ state: {
10
+ [id: string]: any;
11
+ };
12
+ hash: string;
13
+ }
14
+ /**
15
+ * Manages the state of an Agent.
16
+ */
17
+ export declare class AgentState {
18
+ protected storage: Storage;
19
+ protected storageKey: StorageKeyFactory;
20
+ private readonly stateKey;
21
+ /**
22
+ * Creates a new instance of AgentState.
23
+ * @param storage The storage provider.
24
+ * @param storageKey The storage key factory.
25
+ */
26
+ constructor(storage: Storage, storageKey: StorageKeyFactory);
27
+ /**
28
+ * Creates a property accessor for the specified property.
29
+ * @param name The name of the property.
30
+ * @returns A property accessor for the specified property.
31
+ */
32
+ createProperty<T = any>(name: string): AgentStatePropertyAccessor<T>;
33
+ /**
34
+ * Loads the state from storage.
35
+ * @param context The turn context.
36
+ * @param force Whether to force loading the state.
37
+ * @returns A promise that resolves to the loaded state.
38
+ */
39
+ load(context: TurnContext, force?: boolean): Promise<any>;
40
+ /**
41
+ * Saves the state to storage.
42
+ * @param context The turn context.
43
+ * @param force Whether to force saving the state.
44
+ * @returns A promise that resolves when the save operation is complete.
45
+ */
46
+ saveChanges(context: TurnContext, force?: boolean): Promise<void>;
47
+ /**
48
+ * Clears the state from the turn context.
49
+ * @param context The turn context.
50
+ * @returns A promise that resolves when the clear operation is complete.
51
+ */
52
+ clear(context: TurnContext): Promise<void>;
53
+ /**
54
+ * Deletes the state from storage.
55
+ * @param context The turn context.
56
+ * @returns A promise that resolves when the delete operation is complete.
57
+ */
58
+ delete(context: TurnContext): Promise<void>;
59
+ /**
60
+ * Gets the state from the turn context.
61
+ * @param context The turn context.
62
+ * @returns The state, or undefined if the state is not found.
63
+ */
64
+ get(context: TurnContext): any | undefined;
65
+ /**
66
+ * Calculates the change hash for the specified item.
67
+ * @param item The item to calculate the hash for.
68
+ * @returns The calculated hash.
69
+ */
70
+ private readonly calculateChangeHash;
71
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.AgentState = void 0;
8
+ const node_crypto_1 = require("node:crypto");
9
+ const agentStatePropertyAccesor_1 = require("./agentStatePropertyAccesor");
10
+ const logger_1 = require("../logger");
11
+ const logger = (0, logger_1.debug)('agents:state');
12
+ /**
13
+ * Manages the state of an Agent.
14
+ */
15
+ class AgentState {
16
+ /**
17
+ * Creates a new instance of AgentState.
18
+ * @param storage The storage provider.
19
+ * @param storageKey The storage key factory.
20
+ */
21
+ constructor(storage, storageKey) {
22
+ this.storage = storage;
23
+ this.storageKey = storageKey;
24
+ this.stateKey = Symbol('state');
25
+ /**
26
+ * Calculates the change hash for the specified item.
27
+ * @param item The item to calculate the hash for.
28
+ * @returns The calculated hash.
29
+ */
30
+ this.calculateChangeHash = (item) => {
31
+ const { eTag, ...rest } = item;
32
+ // TODO review circular json structure
33
+ const result = JSON.stringify(rest);
34
+ const hash = (0, node_crypto_1.createHash)('sha256', { encoding: 'utf-8' });
35
+ const hashed = hash.update(result).digest('hex');
36
+ return hashed;
37
+ };
38
+ }
39
+ /**
40
+ * Creates a property accessor for the specified property.
41
+ * @param name The name of the property.
42
+ * @returns A property accessor for the specified property.
43
+ */
44
+ createProperty(name) {
45
+ const prop = new agentStatePropertyAccesor_1.AgentStatePropertyAccessor(this, name);
46
+ return prop;
47
+ }
48
+ /**
49
+ * Loads the state from storage.
50
+ * @param context The turn context.
51
+ * @param force Whether to force loading the state.
52
+ * @returns A promise that resolves to the loaded state.
53
+ */
54
+ async load(context, force = false) {
55
+ const cached = context.turnState.get(this.stateKey);
56
+ if (force || !cached || !cached.state) {
57
+ const key = await this.storageKey(context);
58
+ logger.info(`Reading storage with key ${key}`);
59
+ const storedItem = await this.storage.read([key]);
60
+ const state = storedItem[key] || {};
61
+ const hash = this.calculateChangeHash(state);
62
+ context.turnState.set(this.stateKey, { state, hash });
63
+ return state;
64
+ }
65
+ return cached.state;
66
+ }
67
+ /**
68
+ * Saves the state to storage.
69
+ * @param context The turn context.
70
+ * @param force Whether to force saving the state.
71
+ * @returns A promise that resolves when the save operation is complete.
72
+ */
73
+ async saveChanges(context, force = false) {
74
+ let cached = context.turnState.get(this.stateKey);
75
+ if (force || (cached && cached.hash !== this.calculateChangeHash(cached === null || cached === void 0 ? void 0 : cached.state))) {
76
+ if (!cached) {
77
+ cached = { state: {}, hash: '' };
78
+ }
79
+ cached.state.eTag = '*';
80
+ const changes = {};
81
+ const key = await this.storageKey(context);
82
+ changes[key] = cached.state;
83
+ logger.info(`Writing storage with key ${key}`);
84
+ await this.storage.write(changes);
85
+ cached.hash = this.calculateChangeHash(cached.state);
86
+ context.turnState.set(this.stateKey, cached);
87
+ }
88
+ }
89
+ /**
90
+ * Clears the state from the turn context.
91
+ * @param context The turn context.
92
+ * @returns A promise that resolves when the clear operation is complete.
93
+ */
94
+ async clear(context) {
95
+ const emptyObjectToForceSave = { state: {}, hash: '' };
96
+ context.turnState.set(this.stateKey, emptyObjectToForceSave);
97
+ }
98
+ /**
99
+ * Deletes the state from storage.
100
+ * @param context The turn context.
101
+ * @returns A promise that resolves when the delete operation is complete.
102
+ */
103
+ async delete(context) {
104
+ if (context.turnState.has(this.stateKey)) {
105
+ context.turnState.delete(this.stateKey);
106
+ }
107
+ const key = await this.storageKey(context);
108
+ logger.info(`Deleting storage with key ${key}`);
109
+ await this.storage.delete([key]);
110
+ }
111
+ /**
112
+ * Gets the state from the turn context.
113
+ * @param context The turn context.
114
+ * @returns The state, or undefined if the state is not found.
115
+ */
116
+ get(context) {
117
+ const cached = context.turnState.get(this.stateKey);
118
+ return typeof cached === 'object' && typeof cached.state === 'object' ? cached.state : undefined;
119
+ }
120
+ }
121
+ exports.AgentState = AgentState;
122
+ //# sourceMappingURL=agentState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentState.js","sourceRoot":"","sources":["../../../src/state/agentState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,6CAAwC;AACxC,2EAAwE;AACxE,sCAAiC;AAEjC,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,cAAc,CAAC,CAAA;AAOpC;;GAEG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4
+ */
5
+ import { TurnContext } from '../turnContext';
6
+ import { AgentState } from './agentState';
7
+ /**
8
+ * Provides access to an Agent state property.
9
+ */
10
+ export declare class AgentStatePropertyAccessor<T = any> {
11
+ protected readonly state: AgentState;
12
+ readonly name: string;
13
+ /**
14
+ * Creates a new instance of AgentStatePropertyAccessor.
15
+ * @param state The agent state.
16
+ * @param name The name of the property.
17
+ */
18
+ constructor(state: AgentState, name: string);
19
+ /**
20
+ * Deletes the property from the state.
21
+ * @param context The turn context.
22
+ * @returns A promise that resolves when the delete operation is complete.
23
+ */
24
+ delete(context: TurnContext): Promise<void>;
25
+ /**
26
+ * Gets the value of the property from the state.
27
+ * @param context The turn context.
28
+ * @param defaultValue The default value to return if the property is not found.
29
+ * @returns A promise that resolves to the value of the property.
30
+ */
31
+ get(context: TurnContext, defaultValue?: T): Promise<T>;
32
+ /**
33
+ * Sets the value of the property in the state.
34
+ * @param context The turn context.
35
+ * @param value The value to set.
36
+ * @returns A promise that resolves when the set operation is complete.
37
+ */
38
+ set(context: TurnContext, value: T): Promise<void>;
39
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.AgentStatePropertyAccessor = void 0;
8
+ /**
9
+ * Provides access to an Agent state property.
10
+ */
11
+ class AgentStatePropertyAccessor {
12
+ /**
13
+ * Creates a new instance of AgentStatePropertyAccessor.
14
+ * @param state The agent state.
15
+ * @param name The name of the property.
16
+ */
17
+ constructor(state, name) {
18
+ this.state = state;
19
+ this.name = name;
20
+ }
21
+ /**
22
+ * Deletes the property from the state.
23
+ * @param context The turn context.
24
+ * @returns A promise that resolves when the delete operation is complete.
25
+ */
26
+ async delete(context) {
27
+ const obj = await this.state.load(context);
28
+ if (Object.prototype.hasOwnProperty.call(obj, this.name)) {
29
+ delete obj[this.name];
30
+ }
31
+ }
32
+ /**
33
+ * Gets the value of the property from the state.
34
+ * @param context The turn context.
35
+ * @param defaultValue The default value to return if the property is not found.
36
+ * @returns A promise that resolves to the value of the property.
37
+ */
38
+ async get(context, defaultValue) {
39
+ const obj = await this.state.load(context);
40
+ if (!Object.prototype.hasOwnProperty.call(obj, this.name) && defaultValue !== undefined) {
41
+ const clone = typeof defaultValue === 'object' || Array.isArray(defaultValue)
42
+ ? JSON.parse(JSON.stringify(defaultValue))
43
+ : defaultValue;
44
+ obj[this.name] = clone;
45
+ }
46
+ return obj[this.name];
47
+ }
48
+ /**
49
+ * Sets the value of the property in the state.
50
+ * @param context The turn context.
51
+ * @param value The value to set.
52
+ * @returns A promise that resolves when the set operation is complete.
53
+ */
54
+ async set(context, value) {
55
+ const obj = await this.state.load(context);
56
+ obj[this.name] = value;
57
+ }
58
+ }
59
+ exports.AgentStatePropertyAccessor = AgentStatePropertyAccessor;
60
+ //# sourceMappingURL=agentStatePropertyAccesor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentStatePropertyAccesor.js","sourceRoot":"","sources":["../../../src/state/agentStatePropertyAccesor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH;;GAEG;AACH,MAAa,0BAA0B;IACrC;;;;OAIG;IACH,YAAgC,KAAiB,EAAkB,IAAY;QAA/C,UAAK,GAAL,KAAK,CAAY;QAAkB,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAEpF;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAE,OAAoB;QAChC,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACzD,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAE,OAAoB,EAAE,YAAgB;QAC/C,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YACxF,MAAM,KAAK,GACT,OAAO,YAAY,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC;gBAC7D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;gBAC1C,CAAC,CAAC,YAAY,CAAA;YAClB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;QACxB,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAE,OAAoB,EAAE,KAAQ;QACvC,MAAM,GAAG,GAAQ,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;IACxB,CAAC;CACF;AAjDD,gEAiDC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { AgentState } from './agentState';
6
+ import { Storage } from '../storage/storage';
7
+ /**
8
+ * Manages the state of a conversation.
9
+ */
10
+ export declare class ConversationState extends AgentState {
11
+ private readonly namespace;
12
+ /**
13
+ * Creates a new instance of ConversationState.
14
+ * @param storage The storage provider.
15
+ */
16
+ constructor(storage: Storage, namespace?: string);
17
+ private getStorageKey;
18
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.ConversationState = void 0;
8
+ const agentState_1 = require("./agentState");
9
+ /**
10
+ * Manages the state of a conversation.
11
+ */
12
+ class ConversationState extends agentState_1.AgentState {
13
+ /**
14
+ * Creates a new instance of ConversationState.
15
+ * @param storage The storage provider.
16
+ */
17
+ constructor(storage, namespace = '') {
18
+ super(storage, (context) => {
19
+ const key = this.getStorageKey(context);
20
+ return key !== null && key !== void 0 ? key : new Error('ConversationState: overridden getStorageKey method did not return a key.');
21
+ });
22
+ this.namespace = namespace;
23
+ }
24
+ getStorageKey(context) {
25
+ const activity = context.activity;
26
+ const channelId = activity.channelId;
27
+ const conversationId = activity && (activity.conversation != null) && activity.conversation.id ? activity.conversation.id : undefined;
28
+ if (!channelId) {
29
+ throw new Error('missing activity.channelId');
30
+ }
31
+ if (!conversationId) {
32
+ throw new Error('missing activity.conversation.id');
33
+ }
34
+ return `${channelId}/conversations/${conversationId}/${this.namespace}`;
35
+ }
36
+ }
37
+ exports.ConversationState = ConversationState;
38
+ //# sourceMappingURL=conversationState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversationState.js","sourceRoot":"","sources":["../../../src/state/conversationState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAyC;AAKzC;;GAEG;AACH,MAAa,iBAAkB,SAAQ,uBAAU;IAC/C;;;OAGG;IACH,YAAa,OAAgB,EAAmB,YAAoB,EAAE;QACpE,KAAK,CAAC,OAAO,EAAE,CAAC,OAAoB,EAAE,EAAE;YACtC,MAAM,GAAG,GAAW,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;YAE/C,OAAO,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAA;QACrG,CAAC,CAAC,CAAA;QAL4C,cAAS,GAAT,SAAS,CAAa;IAMtE,CAAC;IAEO,aAAa,CAAE,OAAoB;QACzC,MAAM,QAAQ,GAAa,OAAO,CAAC,QAAQ,CAAA;QAC3C,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;QACpC,MAAM,cAAc,GAAG,QAAQ,IAAI,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI,CAAC,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;QAErI,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC/C,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACrD,CAAC;QAED,OAAO,GAAG,SAAS,kBAAkB,cAAc,IAAI,IAAI,CAAC,SAAS,EAAE,CAAA;IACzE,CAAC;CACF;AA5BD,8CA4BC"}
@@ -0,0 +1,4 @@
1
+ export * from './userState';
2
+ export * from './conversationState';
3
+ export * from './agentStatePropertyAccesor';
4
+ export * from './agentState';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./userState"), exports);
18
+ __exportStar(require("./conversationState"), exports);
19
+ __exportStar(require("./agentStatePropertyAccesor"), exports);
20
+ __exportStar(require("./agentState"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/state/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,sDAAmC;AACnC,8DAA2C;AAC3C,+CAA4B"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { AgentState } from './agentState';
6
+ import { Storage } from '../storage/storage';
7
+ /**
8
+ * Manages the state of a user.
9
+ */
10
+ export declare class UserState extends AgentState {
11
+ private readonly namespace;
12
+ /**
13
+ * Creates a new instance of UserState.
14
+ * @param storage The storage provider.
15
+ */
16
+ constructor(storage: Storage, namespace?: string);
17
+ private getStorageKey;
18
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.UserState = void 0;
8
+ const agentState_1 = require("./agentState");
9
+ /**
10
+ * Manages the state of a user.
11
+ */
12
+ class UserState extends agentState_1.AgentState {
13
+ /**
14
+ * Creates a new instance of UserState.
15
+ * @param storage The storage provider.
16
+ */
17
+ constructor(storage, namespace = '') {
18
+ super(storage, (context) => {
19
+ const key = this.getStorageKey(context);
20
+ return key !== null && key !== void 0 ? key : new Error('UserState: overridden getStorageKey method did not return a key.');
21
+ });
22
+ this.namespace = namespace;
23
+ }
24
+ getStorageKey(context) {
25
+ const activity = context.activity;
26
+ const channelId = activity.channelId;
27
+ const userId = activity && (activity.from != null) && activity.from.id ? activity.from.id : undefined;
28
+ if (!channelId) {
29
+ throw new Error('missing activity.channelId');
30
+ }
31
+ if (!userId) {
32
+ throw new Error('missing activity.from.id');
33
+ }
34
+ return `${channelId}/users/${userId}/${this.namespace}`;
35
+ }
36
+ }
37
+ exports.UserState = UserState;
38
+ //# sourceMappingURL=userState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userState.js","sourceRoot":"","sources":["../../../src/state/userState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAyC;AAKzC;;GAEG;AACH,MAAa,SAAU,SAAQ,uBAAU;IACvC;;;QAGI;IACJ,YAAa,OAAgB,EAAmB,YAAoB,EAAE;QACpE,KAAK,CAAC,OAAO,EAAE,CAAC,OAAoB,EAAE,EAAE;YACtC,MAAM,GAAG,GAAW,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;YAE/C,OAAO,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAA;QAC7F,CAAC,CAAC,CAAA;QAL4C,cAAS,GAAT,SAAS,CAAa;IAMtE,CAAC;IAEO,aAAa,CAAE,OAAoB;QACzC,MAAM,QAAQ,GAAa,OAAO,CAAC,QAAQ,CAAA;QAE3C,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAA;QACpC,MAAM,MAAM,GAAG,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;QAErG,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAC/C,CAAC;QAED,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,GAAG,SAAS,UAAU,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAA;IACzD,CAAC;CACF;AA7BD,8BA6BC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export declare enum StatusCodes {
6
+ OK = 200,
7
+ CREATED = 201,
8
+ MULTIPLE_CHOICES = 300,
9
+ BAD_REQUEST = 400,
10
+ UNAUTHORIZED = 401,
11
+ NOT_FOUND = 404,
12
+ METHOD_NOT_ALLOWED = 405,
13
+ CONFLICT = 409,
14
+ PRECONDITION_FAILED = 412,
15
+ UPGRADE_REQUIRED = 426,
16
+ INTERNAL_SERVER_ERROR = 500,
17
+ NOT_IMPLEMENTED = 501,
18
+ BAD_GATEWAY = 502
19
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.StatusCodes = void 0;
8
+ var StatusCodes;
9
+ (function (StatusCodes) {
10
+ StatusCodes[StatusCodes["OK"] = 200] = "OK";
11
+ StatusCodes[StatusCodes["CREATED"] = 201] = "CREATED";
12
+ StatusCodes[StatusCodes["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
13
+ StatusCodes[StatusCodes["BAD_REQUEST"] = 400] = "BAD_REQUEST";
14
+ StatusCodes[StatusCodes["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
15
+ StatusCodes[StatusCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
16
+ StatusCodes[StatusCodes["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
17
+ StatusCodes[StatusCodes["CONFLICT"] = 409] = "CONFLICT";
18
+ StatusCodes[StatusCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
19
+ StatusCodes[StatusCodes["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
20
+ StatusCodes[StatusCodes["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
21
+ StatusCodes[StatusCodes["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
22
+ StatusCodes[StatusCodes["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
23
+ })(StatusCodes || (exports.StatusCodes = StatusCodes = {}));
24
+ //# sourceMappingURL=statusCodes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statusCodes.js","sourceRoot":"","sources":["../../src/statusCodes.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,IAAY,WAcX;AAdD,WAAY,WAAW;IACrB,2CAAQ,CAAA;IACR,qDAAa,CAAA;IACb,uEAAsB,CAAA;IACtB,6DAAiB,CAAA;IACjB,+DAAkB,CAAA;IAClB,yDAAe,CAAA;IACf,2EAAwB,CAAA;IACxB,uDAAc,CAAA;IACd,6EAAyB,CAAA;IACzB,uEAAsB,CAAA;IACtB,iFAA2B,CAAA;IAC3B,qEAAqB,CAAA;IACrB,6DAAiB,CAAA;AACnB,CAAC,EAdW,WAAW,2BAAX,WAAW,QActB"}
@@ -0,0 +1,2 @@
1
+ export * from './storage';
2
+ export * from './memoryStorage';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./storage"), exports);
18
+ __exportStar(require("./memoryStorage"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/storage/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,kDAA+B"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { Storage, StoreItem } from './storage';
6
+ /**
7
+ * A simple in-memory storage provider.
8
+ */
9
+ export declare class MemoryStorage implements Storage {
10
+ private memory;
11
+ private static instance;
12
+ private etag;
13
+ /**
14
+ * Creates a new instance of the MemoryStorage class.
15
+ * @param memory An optional initial memory store.
16
+ */
17
+ constructor(memory?: {
18
+ [k: string]: string;
19
+ });
20
+ /**
21
+ * Gets a single instance of the MemoryStorage class.
22
+ */
23
+ static getSingleInstance(): MemoryStorage;
24
+ /**
25
+ * Reads storage items from memory.
26
+ * @param keys The keys of the items to read.
27
+ * @returns A promise that resolves to the read items.
28
+ * @throws Will throw an error if keys are not provided.
29
+ */
30
+ read(keys: string[]): Promise<StoreItem>;
31
+ /**
32
+ * Writes storage items to memory.
33
+ * @param changes The items to write.
34
+ * @returns A promise that resolves when the write operation is complete.
35
+ * @throws Will throw an error if changes are not provided.
36
+ */
37
+ write(changes: StoreItem): Promise<void>;
38
+ /**
39
+ * Deletes storage items from memory.
40
+ * @param keys The keys of the items to delete.
41
+ * @returns A promise that resolves when the delete operation is complete.
42
+ */
43
+ delete(keys: string[]): Promise<void>;
44
+ /**
45
+ * Saves an item to memory.
46
+ * @param key The key of the item to save.
47
+ * @param item The item to save.
48
+ */
49
+ private saveItem;
50
+ }