@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.
- package/README.md +57 -0
- package/dist/src/activityHandler.d.ts +108 -0
- package/dist/src/activityHandler.js +395 -0
- package/dist/src/activityHandler.js.map +1 -0
- package/dist/src/agent-client/agentClient.d.ts +13 -0
- package/dist/src/agent-client/agentClient.js +75 -0
- package/dist/src/agent-client/agentClient.js.map +1 -0
- package/dist/src/agent-client/expressApi.d.ts +4 -0
- package/dist/src/agent-client/expressApi.js +50 -0
- package/dist/src/agent-client/expressApi.js.map +1 -0
- package/dist/src/agent-client/index.d.ts +2 -0
- package/dist/src/agent-client/index.js +19 -0
- package/dist/src/agent-client/index.js.map +1 -0
- package/dist/src/app/agentApplication.d.ts +47 -0
- package/dist/src/app/agentApplication.js +317 -0
- package/dist/src/app/agentApplication.js.map +1 -0
- package/dist/src/app/appRoute.d.ts +11 -0
- package/dist/src/app/appRoute.js +7 -0
- package/dist/src/app/appRoute.js.map +1 -0
- package/dist/src/app/applicationBuilder.d.ts +18 -0
- package/dist/src/app/applicationBuilder.js +37 -0
- package/dist/src/app/applicationBuilder.js.map +1 -0
- package/dist/src/app/applicationOptions.d.ts +19 -0
- package/dist/src/app/applicationOptions.js +7 -0
- package/dist/src/app/applicationOptions.js.map +1 -0
- package/dist/src/app/attachmentDownloader.d.ts +13 -0
- package/dist/src/app/attachmentDownloader.js +72 -0
- package/dist/src/app/attachmentDownloader.js.map +1 -0
- package/dist/src/app/conversationUpdateEvents.d.ts +5 -0
- package/dist/src/app/conversationUpdateEvents.js +7 -0
- package/dist/src/app/conversationUpdateEvents.js.map +1 -0
- package/dist/src/app/index.d.ts +10 -0
- package/dist/src/app/index.js +27 -0
- package/dist/src/app/index.js.map +1 -0
- package/dist/src/app/inputFileDownloader.d.ts +14 -0
- package/dist/src/app/inputFileDownloader.js +7 -0
- package/dist/src/app/inputFileDownloader.js.map +1 -0
- package/dist/src/app/memory.d.ts +10 -0
- package/dist/src/app/memory.js +7 -0
- package/dist/src/app/memory.js.map +1 -0
- package/dist/src/app/oauth/authenticationOptions.d.ts +7 -0
- package/dist/src/app/oauth/authenticationOptions.js +7 -0
- package/dist/src/app/oauth/authenticationOptions.js.map +1 -0
- package/dist/src/app/oauth/webChatOAuthFlowAppStyle.d.ts +11 -0
- package/dist/src/app/oauth/webChatOAuthFlowAppStyle.js +85 -0
- package/dist/src/app/oauth/webChatOAuthFlowAppStyle.js.map +1 -0
- package/dist/src/app/routeHandler.d.ts +7 -0
- package/dist/src/app/routeHandler.js +7 -0
- package/dist/src/app/routeHandler.js.map +1 -0
- package/dist/src/app/routeSelector.d.ts +7 -0
- package/dist/src/app/routeSelector.js +7 -0
- package/dist/src/app/routeSelector.js.map +1 -0
- package/dist/src/app/turnEvents.d.ts +5 -0
- package/dist/src/app/turnEvents.js +7 -0
- package/dist/src/app/turnEvents.js.map +1 -0
- package/dist/src/app/turnState.d.ts +85 -0
- package/dist/src/app/turnState.js +274 -0
- package/dist/src/app/turnState.js.map +1 -0
- package/dist/src/app/turnStateEntry.d.ts +17 -0
- package/dist/src/app/turnStateEntry.js +39 -0
- package/dist/src/app/turnStateEntry.js.map +1 -0
- package/dist/src/auth/authConfiguration.d.ts +29 -0
- package/dist/src/auth/authConfiguration.js +58 -0
- package/dist/src/auth/authConfiguration.js.map +1 -0
- package/dist/src/auth/authProvider.d.ts +17 -0
- package/dist/src/auth/authProvider.js +7 -0
- package/dist/src/auth/authProvider.js.map +1 -0
- package/dist/src/auth/index.d.ts +4 -0
- package/dist/src/auth/index.js +21 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/jwt-middleware.d.ts +13 -0
- package/dist/src/auth/jwt-middleware.js +97 -0
- package/dist/src/auth/jwt-middleware.js.map +1 -0
- package/dist/src/auth/msalTokenProvider.d.ts +53 -0
- package/dist/src/auth/msalTokenProvider.js +198 -0
- package/dist/src/auth/msalTokenProvider.js.map +1 -0
- package/dist/src/auth/request.d.ts +15 -0
- package/dist/src/auth/request.js +7 -0
- package/dist/src/auth/request.js.map +1 -0
- package/dist/src/baseAdapter.d.ts +88 -0
- package/dist/src/baseAdapter.js +94 -0
- package/dist/src/baseAdapter.js.map +1 -0
- package/dist/src/cards/animationCard.d.ts +36 -0
- package/dist/src/cards/animationCard.js +7 -0
- package/dist/src/cards/animationCard.js.map +1 -0
- package/dist/src/cards/audioCard.d.ts +36 -0
- package/dist/src/cards/audioCard.js +7 -0
- package/dist/src/cards/audioCard.js.map +1 -0
- package/dist/src/cards/cardFactory.d.ts +123 -0
- package/dist/src/cards/cardFactory.js +225 -0
- package/dist/src/cards/cardFactory.js.map +1 -0
- package/dist/src/cards/cardImage.d.ts +16 -0
- package/dist/src/cards/cardImage.js +7 -0
- package/dist/src/cards/cardImage.js.map +1 -0
- package/dist/src/cards/fact.d.ts +13 -0
- package/dist/src/cards/fact.js +7 -0
- package/dist/src/cards/fact.js.map +1 -0
- package/dist/src/cards/heroCard.d.ts +23 -0
- package/dist/src/cards/heroCard.js +7 -0
- package/dist/src/cards/heroCard.js.map +1 -0
- package/dist/src/cards/index.d.ts +17 -0
- package/dist/src/cards/index.js +34 -0
- package/dist/src/cards/index.js.map +1 -0
- package/dist/src/cards/mediaUrl.d.ts +17 -0
- package/dist/src/cards/mediaUrl.js +7 -0
- package/dist/src/cards/mediaUrl.js.map +1 -0
- package/dist/src/cards/o365ConnectorCard.d.ts +35 -0
- package/dist/src/cards/o365ConnectorCard.js +7 -0
- package/dist/src/cards/o365ConnectorCard.js.map +1 -0
- package/dist/src/cards/o365ConnectorCardActionBase.d.ts +22 -0
- package/dist/src/cards/o365ConnectorCardActionBase.js +7 -0
- package/dist/src/cards/o365ConnectorCardActionBase.js.map +1 -0
- package/dist/src/cards/o365ConnectorCardFact.d.ts +17 -0
- package/dist/src/cards/o365ConnectorCardFact.js +7 -0
- package/dist/src/cards/o365ConnectorCardFact.js.map +1 -0
- package/dist/src/cards/o365ConnectorCardImage.d.ts +17 -0
- package/dist/src/cards/o365ConnectorCardImage.js +7 -0
- package/dist/src/cards/o365ConnectorCardImage.js.map +1 -0
- package/dist/src/cards/o365ConnectorCardSection.d.ts +57 -0
- package/dist/src/cards/o365ConnectorCardSection.js +7 -0
- package/dist/src/cards/o365ConnectorCardSection.js.map +1 -0
- package/dist/src/cards/receiptCard.d.ts +44 -0
- package/dist/src/cards/receiptCard.js +7 -0
- package/dist/src/cards/receiptCard.js.map +1 -0
- package/dist/src/cards/receiptItem.d.ts +39 -0
- package/dist/src/cards/receiptItem.js +7 -0
- package/dist/src/cards/receiptItem.js.map +1 -0
- package/dist/src/cards/signinCard.d.ts +14 -0
- package/dist/src/cards/signinCard.js +5 -0
- package/dist/src/cards/signinCard.js.map +1 -0
- package/dist/src/cards/taskModuleAction.d.ts +43 -0
- package/dist/src/cards/taskModuleAction.js +30 -0
- package/dist/src/cards/taskModuleAction.js.map +1 -0
- package/dist/src/cards/thumbnailCard.d.ts +35 -0
- package/dist/src/cards/thumbnailCard.js +7 -0
- package/dist/src/cards/thumbnailCard.js.map +1 -0
- package/dist/src/cards/thumbnailUrl.d.ts +17 -0
- package/dist/src/cards/thumbnailUrl.js +7 -0
- package/dist/src/cards/thumbnailUrl.js.map +1 -0
- package/dist/src/cards/videoCard.d.ts +60 -0
- package/dist/src/cards/videoCard.js +7 -0
- package/dist/src/cards/videoCard.js.map +1 -0
- package/dist/src/claimsIdentity.d.ts +35 -0
- package/dist/src/claimsIdentity.js +43 -0
- package/dist/src/claimsIdentity.js.map +1 -0
- package/dist/src/cloudAdapter.d.ts +128 -0
- package/dist/src/cloudAdapter.js +376 -0
- package/dist/src/cloudAdapter.js.map +1 -0
- package/dist/src/connector-client/attachmentData.d.ts +25 -0
- package/dist/src/connector-client/attachmentData.js +7 -0
- package/dist/src/connector-client/attachmentData.js.map +1 -0
- package/dist/src/connector-client/attachmentInfo.d.ts +22 -0
- package/dist/src/connector-client/attachmentInfo.js +7 -0
- package/dist/src/connector-client/attachmentInfo.js.map +1 -0
- package/dist/src/connector-client/attachmentView.d.ts +17 -0
- package/dist/src/connector-client/attachmentView.js +7 -0
- package/dist/src/connector-client/attachmentView.js.map +1 -0
- package/dist/src/connector-client/connectorClient.d.ts +93 -0
- package/dist/src/connector-client/connectorClient.js +249 -0
- package/dist/src/connector-client/connectorClient.js.map +1 -0
- package/dist/src/connector-client/conversationMembers.d.ts +18 -0
- package/dist/src/connector-client/conversationMembers.js +7 -0
- package/dist/src/connector-client/conversationMembers.js.map +1 -0
- package/dist/src/connector-client/conversationParameters.d.ts +38 -0
- package/dist/src/connector-client/conversationParameters.js +7 -0
- package/dist/src/connector-client/conversationParameters.js.map +1 -0
- package/dist/src/connector-client/conversationResourceResponse.d.ts +21 -0
- package/dist/src/connector-client/conversationResourceResponse.js +7 -0
- package/dist/src/connector-client/conversationResourceResponse.js.map +1 -0
- package/dist/src/connector-client/conversationsResult.d.ts +18 -0
- package/dist/src/connector-client/conversationsResult.js +7 -0
- package/dist/src/connector-client/conversationsResult.js.map +1 -0
- package/dist/src/connector-client/index.d.ts +9 -0
- package/dist/src/connector-client/index.js +26 -0
- package/dist/src/connector-client/index.js.map +1 -0
- package/dist/src/connector-client/resourceResponse.d.ts +13 -0
- package/dist/src/connector-client/resourceResponse.js +7 -0
- package/dist/src/connector-client/resourceResponse.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.js +45 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/invoke/adaptiveCardAuthentication.d.ts +10 -0
- package/dist/src/invoke/adaptiveCardAuthentication.js +7 -0
- package/dist/src/invoke/adaptiveCardAuthentication.js.map +1 -0
- package/dist/src/invoke/adaptiveCardInvokeResponse.d.ts +21 -0
- package/dist/src/invoke/adaptiveCardInvokeResponse.js +7 -0
- package/dist/src/invoke/adaptiveCardInvokeResponse.js.map +1 -0
- package/dist/src/invoke/adaptiveCardInvokeValue.d.ts +23 -0
- package/dist/src/invoke/adaptiveCardInvokeValue.js +7 -0
- package/dist/src/invoke/adaptiveCardInvokeValue.js.map +1 -0
- package/dist/src/invoke/index.d.ts +9 -0
- package/dist/src/invoke/index.js +26 -0
- package/dist/src/invoke/index.js.map +1 -0
- package/dist/src/invoke/invokeException.d.ts +24 -0
- package/dist/src/invoke/invokeException.js +35 -0
- package/dist/src/invoke/invokeException.js.map +1 -0
- package/dist/src/invoke/invokeResponse.d.ts +17 -0
- package/dist/src/invoke/invokeResponse.js +7 -0
- package/dist/src/invoke/invokeResponse.js.map +1 -0
- package/dist/src/invoke/searchInvokeOptions.d.ts +17 -0
- package/dist/src/invoke/searchInvokeOptions.js +7 -0
- package/dist/src/invoke/searchInvokeOptions.js.map +1 -0
- package/dist/src/invoke/searchInvokeResponse.d.ts +10 -0
- package/dist/src/invoke/searchInvokeResponse.js +7 -0
- package/dist/src/invoke/searchInvokeResponse.js.map +1 -0
- package/dist/src/invoke/searchInvokeValue.d.ts +26 -0
- package/dist/src/invoke/searchInvokeValue.js +7 -0
- package/dist/src/invoke/searchInvokeValue.js.map +1 -0
- package/dist/src/invoke/tokenExchangeInvokeRequest.d.ts +21 -0
- package/dist/src/invoke/tokenExchangeInvokeRequest.js +7 -0
- package/dist/src/invoke/tokenExchangeInvokeRequest.js.map +1 -0
- package/dist/src/logger.d.ts +12 -0
- package/dist/src/logger.js +42 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/messageFactory.d.ts +62 -0
- package/dist/src/messageFactory.js +143 -0
- package/dist/src/messageFactory.js.map +1 -0
- package/dist/src/middlewareSet.d.ts +43 -0
- package/dist/src/middlewareSet.js +57 -0
- package/dist/src/middlewareSet.js.map +1 -0
- package/dist/src/oauth/index.d.ts +7 -0
- package/dist/src/oauth/index.js +24 -0
- package/dist/src/oauth/index.js.map +1 -0
- package/dist/src/oauth/oauthCard.d.ts +28 -0
- package/dist/src/oauth/oauthCard.js +5 -0
- package/dist/src/oauth/oauthCard.js.map +1 -0
- package/dist/src/oauth/signingResource.d.ts +19 -0
- package/dist/src/oauth/signingResource.js +5 -0
- package/dist/src/oauth/signingResource.js.map +1 -0
- package/dist/src/oauth/tokenExchangeRequest.d.ts +17 -0
- package/dist/src/oauth/tokenExchangeRequest.js +5 -0
- package/dist/src/oauth/tokenExchangeRequest.js.map +1 -0
- package/dist/src/oauth/tokenExchangeResource.d.ts +17 -0
- package/dist/src/oauth/tokenExchangeResource.js +5 -0
- package/dist/src/oauth/tokenExchangeResource.js.map +1 -0
- package/dist/src/oauth/tokenPostResource.d.ts +9 -0
- package/dist/src/oauth/tokenPostResource.js +5 -0
- package/dist/src/oauth/tokenPostResource.js.map +1 -0
- package/dist/src/oauth/userTokenClient.d.ts +49 -0
- package/dist/src/oauth/userTokenClient.js +117 -0
- package/dist/src/oauth/userTokenClient.js.map +1 -0
- package/dist/src/oauth/webChatOAuthFlow.d.ts +41 -0
- package/dist/src/oauth/webChatOAuthFlow.js +117 -0
- package/dist/src/oauth/webChatOAuthFlow.js.map +1 -0
- package/dist/src/state/agentState.d.ts +71 -0
- package/dist/src/state/agentState.js +122 -0
- package/dist/src/state/agentState.js.map +1 -0
- package/dist/src/state/agentStatePropertyAccesor.d.ts +39 -0
- package/dist/src/state/agentStatePropertyAccesor.js +60 -0
- package/dist/src/state/agentStatePropertyAccesor.js.map +1 -0
- package/dist/src/state/conversationState.d.ts +18 -0
- package/dist/src/state/conversationState.js +38 -0
- package/dist/src/state/conversationState.js.map +1 -0
- package/dist/src/state/index.d.ts +4 -0
- package/dist/src/state/index.js +21 -0
- package/dist/src/state/index.js.map +1 -0
- package/dist/src/state/userState.d.ts +18 -0
- package/dist/src/state/userState.js +38 -0
- package/dist/src/state/userState.js.map +1 -0
- package/dist/src/statusCodes.d.ts +19 -0
- package/dist/src/statusCodes.js +24 -0
- package/dist/src/statusCodes.js.map +1 -0
- package/dist/src/storage/index.d.ts +2 -0
- package/dist/src/storage/index.js +19 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/memoryStorage.d.ts +50 -0
- package/dist/src/storage/memoryStorage.js +100 -0
- package/dist/src/storage/memoryStorage.js.map +1 -0
- package/dist/src/storage/storage.d.ts +47 -0
- package/dist/src/storage/storage.js +7 -0
- package/dist/src/storage/storage.js.map +1 -0
- package/dist/src/tokenResponseEventName.d.ts +5 -0
- package/dist/src/tokenResponseEventName.js +9 -0
- package/dist/src/tokenResponseEventName.js.map +1 -0
- package/dist/src/transcript/consoleTranscriptLogger.d.ts +13 -0
- package/dist/src/transcript/consoleTranscriptLogger.js +21 -0
- package/dist/src/transcript/consoleTranscriptLogger.js.map +1 -0
- package/dist/src/transcript/index.d.ts +4 -0
- package/dist/src/transcript/index.js +21 -0
- package/dist/src/transcript/index.js.map +1 -0
- package/dist/src/transcript/transcriptLogger.d.ts +42 -0
- package/dist/src/transcript/transcriptLogger.js +3 -0
- package/dist/src/transcript/transcriptLogger.js.map +1 -0
- package/dist/src/transcript/transcriptLoggerMiddleware.d.ts +38 -0
- package/dist/src/transcript/transcriptLoggerMiddleware.js +126 -0
- package/dist/src/transcript/transcriptLoggerMiddleware.js.map +1 -0
- package/dist/src/transcript/transcriptStore.d.ts +30 -0
- package/dist/src/transcript/transcriptStore.js +3 -0
- package/dist/src/transcript/transcriptStore.js.map +1 -0
- package/dist/src/turnContext.d.ts +160 -0
- package/dist/src/turnContext.js +286 -0
- package/dist/src/turnContext.js.map +1 -0
- package/dist/src/turnContextStateCollection.d.ts +29 -0
- package/dist/src/turnContextStateCollection.js +56 -0
- package/dist/src/turnContextStateCollection.js.map +1 -0
- package/package.json +48 -0
- package/src/activityHandler.ts +461 -0
- package/src/agent-client/agentClient.ts +84 -0
- package/src/agent-client/expressApi.ts +59 -0
- package/src/agent-client/index.ts +2 -0
- package/src/app/agentApplication.ts +401 -0
- package/src/app/appRoute.ts +13 -0
- package/src/app/applicationBuilder.ts +42 -0
- package/src/app/applicationOptions.ts +21 -0
- package/src/app/attachmentDownloader.ts +83 -0
- package/src/app/conversationUpdateEvents.ts +8 -0
- package/src/app/index.ts +10 -0
- package/src/app/inputFileDownloader.ts +17 -0
- package/src/app/memory.ts +14 -0
- package/src/app/oauth/authenticationOptions.ts +8 -0
- package/src/app/oauth/webChatOAuthFlowAppStyle.ts +90 -0
- package/src/app/routeHandler.ts +9 -0
- package/src/app/routeSelector.ts +10 -0
- package/src/app/turnEvents.ts +6 -0
- package/src/app/turnState.ts +338 -0
- package/src/app/turnStateEntry.ts +46 -0
- package/src/auth/authConfiguration.ts +68 -0
- package/src/auth/authProvider.ts +19 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/jwt-middleware.ts +99 -0
- package/src/auth/msalTokenProvider.ts +202 -0
- package/src/auth/request.ts +20 -0
- package/src/baseAdapter.ts +174 -0
- package/src/cards/animationCard.ts +38 -0
- package/src/cards/audioCard.ts +38 -0
- package/src/cards/cardFactory.ts +276 -0
- package/src/cards/cardImage.ts +18 -0
- package/src/cards/fact.ts +14 -0
- package/src/cards/heroCard.ts +25 -0
- package/src/cards/index.ts +17 -0
- package/src/cards/mediaUrl.ts +18 -0
- package/src/cards/o365ConnectorCard.ts +37 -0
- package/src/cards/o365ConnectorCardActionBase.ts +24 -0
- package/src/cards/o365ConnectorCardFact.ts +18 -0
- package/src/cards/o365ConnectorCardImage.ts +18 -0
- package/src/cards/o365ConnectorCardSection.ts +60 -0
- package/src/cards/receiptCard.ts +46 -0
- package/src/cards/receiptItem.ts +41 -0
- package/src/cards/signinCard.ts +18 -0
- package/src/cards/taskModuleAction.ts +61 -0
- package/src/cards/thumbnailCard.ts +37 -0
- package/src/cards/thumbnailUrl.ts +18 -0
- package/src/cards/videoCard.ts +62 -0
- package/src/claimsIdentity.ts +47 -0
- package/src/cloudAdapter.ts +431 -0
- package/src/connector-client/attachmentData.ts +26 -0
- package/src/connector-client/attachmentInfo.ts +24 -0
- package/src/connector-client/attachmentView.ts +18 -0
- package/src/connector-client/connectorClient.ts +295 -0
- package/src/connector-client/conversationMembers.ts +20 -0
- package/src/connector-client/conversationParameters.ts +40 -0
- package/src/connector-client/conversationResourceResponse.ts +22 -0
- package/src/connector-client/conversationsResult.ts +20 -0
- package/src/connector-client/index.ts +9 -0
- package/src/connector-client/resourceResponse.ts +14 -0
- package/src/index.ts +31 -0
- package/src/invoke/adaptiveCardAuthentication.ts +13 -0
- package/src/invoke/adaptiveCardInvokeResponse.ts +22 -0
- package/src/invoke/adaptiveCardInvokeValue.ts +25 -0
- package/src/invoke/index.ts +9 -0
- package/src/invoke/invokeException.ts +33 -0
- package/src/invoke/invokeResponse.ts +18 -0
- package/src/invoke/searchInvokeOptions.ts +18 -0
- package/src/invoke/searchInvokeResponse.ts +11 -0
- package/src/invoke/searchInvokeValue.ts +28 -0
- package/src/invoke/tokenExchangeInvokeRequest.ts +22 -0
- package/src/logger.ts +43 -0
- package/src/messageFactory.ts +177 -0
- package/src/middlewareSet.ts +76 -0
- package/src/oauth/index.ts +7 -0
- package/src/oauth/oauthCard.ts +32 -0
- package/src/oauth/signingResource.ts +23 -0
- package/src/oauth/tokenExchangeRequest.ts +20 -0
- package/src/oauth/tokenExchangeResource.ts +20 -0
- package/src/oauth/tokenPostResource.ts +12 -0
- package/src/oauth/userTokenClient.ts +116 -0
- package/src/oauth/webChatOAuthFlow.ts +123 -0
- package/src/state/agentState.ts +142 -0
- package/src/state/agentStatePropertyAccesor.ts +61 -0
- package/src/state/conversationState.ts +42 -0
- package/src/state/index.ts +4 -0
- package/src/state/userState.ts +43 -0
- package/src/statusCodes.ts +20 -0
- package/src/storage/index.ts +2 -0
- package/src/storage/memoryStorage.ts +105 -0
- package/src/storage/storage.ts +52 -0
- package/src/tokenResponseEventName.ts +6 -0
- package/src/transcript/consoleTranscriptLogger.ts +20 -0
- package/src/transcript/index.ts +4 -0
- package/src/transcript/transcriptLogger.ts +45 -0
- package/src/transcript/transcriptLoggerMiddleware.ts +151 -0
- package/src/transcript/transcriptStore.ts +38 -0
- package/src/turnContext.ts +335 -0
- package/src/turnContextStateCollection.ts +69 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { AuthConfiguration } from './authConfiguration';
|
|
6
|
+
import { AuthProvider } from './authProvider';
|
|
7
|
+
/**
|
|
8
|
+
* Provides tokens using MSAL.
|
|
9
|
+
*/
|
|
10
|
+
export declare class MsalTokenProvider implements AuthProvider {
|
|
11
|
+
/**
|
|
12
|
+
* Gets an access token.
|
|
13
|
+
* @param authConfig The authentication configuration.
|
|
14
|
+
* @param scope The scope for the token.
|
|
15
|
+
* @returns A promise that resolves to the access token.
|
|
16
|
+
*/
|
|
17
|
+
getAccessToken(authConfig: AuthConfiguration, scope: string): Promise<string>;
|
|
18
|
+
private readonly sysOptions;
|
|
19
|
+
/**
|
|
20
|
+
* Acquires a token using a user-assigned identity.
|
|
21
|
+
* @param authConfig The authentication configuration.
|
|
22
|
+
* @param scope The scope for the token.
|
|
23
|
+
* @returns A promise that resolves to the access token.
|
|
24
|
+
*/
|
|
25
|
+
private acquireTokenWithUserAssignedIdentity;
|
|
26
|
+
/**
|
|
27
|
+
* Acquires a token using a certificate.
|
|
28
|
+
* @param authConfig The authentication configuration.
|
|
29
|
+
* @param scope The scope for the token.
|
|
30
|
+
* @returns A promise that resolves to the access token.
|
|
31
|
+
*/
|
|
32
|
+
private acquireTokenWithCertificate;
|
|
33
|
+
/**
|
|
34
|
+
* Acquires a token using a client secret.
|
|
35
|
+
* @param authConfig The authentication configuration.
|
|
36
|
+
* @param scope The scope for the token.
|
|
37
|
+
* @returns A promise that resolves to the access token.
|
|
38
|
+
*/
|
|
39
|
+
private acquireAccessTokenViaSecret;
|
|
40
|
+
/**
|
|
41
|
+
* Acquires a token using a FIC client assertion.
|
|
42
|
+
* @param authConfig The authentication configuration.
|
|
43
|
+
* @param scope The scope for the token.
|
|
44
|
+
* @returns A promise that resolves to the access token.
|
|
45
|
+
*/
|
|
46
|
+
private acquireAccessTokenViaFIC;
|
|
47
|
+
/**
|
|
48
|
+
* Fetches an external token.
|
|
49
|
+
* @param FICClientId The FIC client ID.
|
|
50
|
+
* @returns A promise that resolves to the external token.
|
|
51
|
+
*/
|
|
52
|
+
private fetchExternalToken;
|
|
53
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MsalTokenProvider = void 0;
|
|
11
|
+
const msal_node_1 = require("@azure/msal-node");
|
|
12
|
+
const logger_1 = require("../logger");
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
16
|
+
const audience = 'api://AzureADTokenExchange';
|
|
17
|
+
const logger = (0, logger_1.debug)('agents:msal-token-provider');
|
|
18
|
+
/**
|
|
19
|
+
* Provides tokens using MSAL.
|
|
20
|
+
*/
|
|
21
|
+
class MsalTokenProvider {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.sysOptions = {
|
|
24
|
+
loggerOptions: {
|
|
25
|
+
logLevel: msal_node_1.LogLevel.Trace,
|
|
26
|
+
loggerCallback: (level, message, containsPii) => {
|
|
27
|
+
if (containsPii) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
switch (level) {
|
|
31
|
+
case msal_node_1.LogLevel.Error:
|
|
32
|
+
logger.error(message);
|
|
33
|
+
return;
|
|
34
|
+
case msal_node_1.LogLevel.Info:
|
|
35
|
+
logger.info(message);
|
|
36
|
+
return;
|
|
37
|
+
case msal_node_1.LogLevel.Warning:
|
|
38
|
+
logger.warn(message);
|
|
39
|
+
return;
|
|
40
|
+
case msal_node_1.LogLevel.Verbose:
|
|
41
|
+
logger.debug(message);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
piiLoggingEnabled: false
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Gets an access token.
|
|
50
|
+
* @param authConfig The authentication configuration.
|
|
51
|
+
* @param scope The scope for the token.
|
|
52
|
+
* @returns A promise that resolves to the access token.
|
|
53
|
+
*/
|
|
54
|
+
async getAccessToken(authConfig, scope) {
|
|
55
|
+
if (!authConfig.clientId && process.env.NODE_ENV !== 'production') {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
let token;
|
|
59
|
+
if (authConfig.FICClientId !== undefined) {
|
|
60
|
+
token = await this.acquireAccessTokenViaFIC(authConfig, scope);
|
|
61
|
+
}
|
|
62
|
+
else if (authConfig.clientSecret !== undefined) {
|
|
63
|
+
token = await this.acquireAccessTokenViaSecret(authConfig, scope);
|
|
64
|
+
}
|
|
65
|
+
else if (authConfig.certPemFile !== undefined &&
|
|
66
|
+
authConfig.certKeyFile !== undefined) {
|
|
67
|
+
token = await this.acquireTokenWithCertificate(authConfig, scope);
|
|
68
|
+
}
|
|
69
|
+
else if (authConfig.clientSecret === undefined &&
|
|
70
|
+
authConfig.certPemFile === undefined &&
|
|
71
|
+
authConfig.certKeyFile === undefined) {
|
|
72
|
+
token = await this.acquireTokenWithUserAssignedIdentity(authConfig, scope);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
throw new Error('Invalid authConfig. ');
|
|
76
|
+
}
|
|
77
|
+
if (token === undefined) {
|
|
78
|
+
throw new Error('Failed to acquire token');
|
|
79
|
+
}
|
|
80
|
+
return token;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Acquires a token using a user-assigned identity.
|
|
84
|
+
* @param authConfig The authentication configuration.
|
|
85
|
+
* @param scope The scope for the token.
|
|
86
|
+
* @returns A promise that resolves to the access token.
|
|
87
|
+
*/
|
|
88
|
+
async acquireTokenWithUserAssignedIdentity(authConfig, scope) {
|
|
89
|
+
const mia = new msal_node_1.ManagedIdentityApplication({
|
|
90
|
+
managedIdentityIdParams: {
|
|
91
|
+
userAssignedClientId: authConfig.clientId || ''
|
|
92
|
+
},
|
|
93
|
+
system: this.sysOptions
|
|
94
|
+
});
|
|
95
|
+
const token = await mia.acquireToken({
|
|
96
|
+
resource: scope
|
|
97
|
+
});
|
|
98
|
+
return token === null || token === void 0 ? void 0 : token.accessToken;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Acquires a token using a certificate.
|
|
102
|
+
* @param authConfig The authentication configuration.
|
|
103
|
+
* @param scope The scope for the token.
|
|
104
|
+
* @returns A promise that resolves to the access token.
|
|
105
|
+
*/
|
|
106
|
+
async acquireTokenWithCertificate(authConfig, scope) {
|
|
107
|
+
const privateKeySource = fs_1.default.readFileSync(authConfig.certKeyFile);
|
|
108
|
+
const privateKeyObject = crypto_1.default.createPrivateKey({
|
|
109
|
+
key: privateKeySource,
|
|
110
|
+
format: 'pem'
|
|
111
|
+
});
|
|
112
|
+
const privateKey = privateKeyObject.export({
|
|
113
|
+
format: 'pem',
|
|
114
|
+
type: 'pkcs8'
|
|
115
|
+
});
|
|
116
|
+
const pubKeyObject = new crypto_1.default.X509Certificate(fs_1.default.readFileSync(authConfig.certPemFile));
|
|
117
|
+
const cca = new msal_node_1.ConfidentialClientApplication({
|
|
118
|
+
auth: {
|
|
119
|
+
clientId: authConfig.clientId || '',
|
|
120
|
+
authority: `https://login.microsoftonline.com/${authConfig.tenantId || 'botframework.com'}`,
|
|
121
|
+
clientCertificate: {
|
|
122
|
+
privateKey: privateKey,
|
|
123
|
+
thumbprint: pubKeyObject.fingerprint.replaceAll(':', ''),
|
|
124
|
+
x5c: Buffer.from(authConfig.certPemFile, 'base64').toString()
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
system: this.sysOptions
|
|
128
|
+
});
|
|
129
|
+
const token = await cca.acquireTokenByClientCredential({
|
|
130
|
+
scopes: [`${scope}/.default`],
|
|
131
|
+
correlationId: (0, uuid_1.v4)()
|
|
132
|
+
});
|
|
133
|
+
return token === null || token === void 0 ? void 0 : token.accessToken;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Acquires a token using a client secret.
|
|
137
|
+
* @param authConfig The authentication configuration.
|
|
138
|
+
* @param scope The scope for the token.
|
|
139
|
+
* @returns A promise that resolves to the access token.
|
|
140
|
+
*/
|
|
141
|
+
async acquireAccessTokenViaSecret(authConfig, scope) {
|
|
142
|
+
const cca = new msal_node_1.ConfidentialClientApplication({
|
|
143
|
+
auth: {
|
|
144
|
+
clientId: authConfig.clientId,
|
|
145
|
+
authority: `https://login.microsoftonline.com/${authConfig.tenantId || 'botframework.com'}`,
|
|
146
|
+
clientSecret: authConfig.clientSecret
|
|
147
|
+
},
|
|
148
|
+
system: this.sysOptions
|
|
149
|
+
});
|
|
150
|
+
const token = await cca.acquireTokenByClientCredential({
|
|
151
|
+
scopes: [`${scope}/.default`],
|
|
152
|
+
correlationId: (0, uuid_1.v4)()
|
|
153
|
+
});
|
|
154
|
+
return token === null || token === void 0 ? void 0 : token.accessToken;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Acquires a token using a FIC client assertion.
|
|
158
|
+
* @param authConfig The authentication configuration.
|
|
159
|
+
* @param scope The scope for the token.
|
|
160
|
+
* @returns A promise that resolves to the access token.
|
|
161
|
+
*/
|
|
162
|
+
async acquireAccessTokenViaFIC(authConfig, scope) {
|
|
163
|
+
const scopes = [`${scope}/.default`];
|
|
164
|
+
const clientAssertion = await this.fetchExternalToken(authConfig.FICClientId);
|
|
165
|
+
const cca = new msal_node_1.ConfidentialClientApplication({
|
|
166
|
+
auth: {
|
|
167
|
+
clientId: authConfig.clientId,
|
|
168
|
+
authority: `https://login.microsoftonline.com/${authConfig.tenantId}`,
|
|
169
|
+
clientAssertion
|
|
170
|
+
},
|
|
171
|
+
system: this.sysOptions
|
|
172
|
+
});
|
|
173
|
+
const token = await cca.acquireTokenByClientCredential({ scopes });
|
|
174
|
+
logger.info('got token using FIC client assertion');
|
|
175
|
+
return token === null || token === void 0 ? void 0 : token.accessToken;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Fetches an external token.
|
|
179
|
+
* @param FICClientId The FIC client ID.
|
|
180
|
+
* @returns A promise that resolves to the external token.
|
|
181
|
+
*/
|
|
182
|
+
async fetchExternalToken(FICClientId) {
|
|
183
|
+
const managedIdentityClientAssertion = new msal_node_1.ManagedIdentityApplication({
|
|
184
|
+
managedIdentityIdParams: {
|
|
185
|
+
userAssignedClientId: FICClientId
|
|
186
|
+
},
|
|
187
|
+
system: this.sysOptions
|
|
188
|
+
});
|
|
189
|
+
const response = await managedIdentityClientAssertion.acquireToken({
|
|
190
|
+
resource: audience,
|
|
191
|
+
forceRefresh: true
|
|
192
|
+
});
|
|
193
|
+
logger.info('got token for FIC');
|
|
194
|
+
return response.accessToken;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.MsalTokenProvider = MsalTokenProvider;
|
|
198
|
+
//# sourceMappingURL=msalTokenProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msalTokenProvider.js","sourceRoot":"","sources":["../../../src/auth/msalTokenProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,gDAAyH;AAGzH,sCAAiC;AACjC,+BAAyB;AAEzB,4CAAmB;AACnB,oDAA2B;AAE3B,MAAM,QAAQ,GAAG,4BAA4B,CAAA;AAC7C,MAAM,MAAM,GAAG,IAAA,cAAK,EAAC,4BAA4B,CAAC,CAAA;AAElD;;GAEG;AACH,MAAa,iBAAiB;IAA9B;QAiCmB,eAAU,GAAsB;YAC/C,aAAa,EAAE;gBACb,QAAQ,EAAE,oBAAQ,CAAC,KAAK;gBACxB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AAI,CAAC,mBAAmB,CAAC,CAAA;QAChC,OAAO,QAAQ,CAAC,WAAW,CAAA;IAC7B,CAAC;CACF;AArLD,8CAqLC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { JwtPayload } from 'jsonwebtoken';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a Node.js HTTP Request, including the minimal set of use properties.
|
|
8
|
+
* Compatible with Restify, Express, and Node.js core http.
|
|
9
|
+
*/
|
|
10
|
+
export interface Request<Body extends Record<string, unknown> = Record<string, unknown>, Headers extends Record<string, string[] | string | undefined> = Record<string, string[] | string | undefined>> {
|
|
11
|
+
body?: Body;
|
|
12
|
+
headers: Headers;
|
|
13
|
+
method?: string;
|
|
14
|
+
user?: JwtPayload;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/auth/request.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { AuthConfiguration } from './auth/authConfiguration';
|
|
6
|
+
import { AuthProvider } from './auth/authProvider';
|
|
7
|
+
import { Middleware, MiddlewareHandler, MiddlewareSet } from './middlewareSet';
|
|
8
|
+
import { TurnContext } from './turnContext';
|
|
9
|
+
import { Activity, ConversationReference } from '@microsoft/agents-activity';
|
|
10
|
+
import { ResourceResponse } from './connector-client/resourceResponse';
|
|
11
|
+
import { AttachmentData } from './connector-client/attachmentData';
|
|
12
|
+
import { AttachmentInfo } from './connector-client/attachmentInfo';
|
|
13
|
+
/**
|
|
14
|
+
* Base class for all adapters, providing middleware and error handling capabilities.
|
|
15
|
+
*/
|
|
16
|
+
export declare abstract class BaseAdapter {
|
|
17
|
+
protected middleware: MiddlewareSet;
|
|
18
|
+
private turnError;
|
|
19
|
+
readonly AgentIdentityKey: symbol;
|
|
20
|
+
readonly ConnectorClientKey: symbol;
|
|
21
|
+
readonly OAuthScopeKey: symbol;
|
|
22
|
+
authProvider: AuthProvider;
|
|
23
|
+
authConfig: AuthConfiguration;
|
|
24
|
+
/**
|
|
25
|
+
* Sends a set of activities to the conversation.
|
|
26
|
+
* @param context - The TurnContext for the current turn.
|
|
27
|
+
* @param activities - The activities to send.
|
|
28
|
+
* @returns A promise representing the array of ResourceResponses for the sent activities.
|
|
29
|
+
*/
|
|
30
|
+
abstract sendActivities(context: TurnContext, activities: Activity[]): Promise<ResourceResponse[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Updates an existing activity.
|
|
33
|
+
* @param context - The TurnContext for the current turn.
|
|
34
|
+
* @param activity - The activity to update.
|
|
35
|
+
* @returns A promise representing the ResourceResponse for the updated activity.
|
|
36
|
+
*/
|
|
37
|
+
abstract updateActivity(context: TurnContext, activity: Activity): Promise<ResourceResponse | void>;
|
|
38
|
+
/**
|
|
39
|
+
* Deletes an existing activity.
|
|
40
|
+
* @param context - The TurnContext for the current turn.
|
|
41
|
+
* @param reference - The conversation reference of the activity to delete.
|
|
42
|
+
* @returns A promise representing the completion of the delete operation.
|
|
43
|
+
*/
|
|
44
|
+
abstract deleteActivity(context: TurnContext, reference: Partial<ConversationReference>): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Continues a conversation.
|
|
47
|
+
* @param reference - The conversation reference to continue.
|
|
48
|
+
* @param logic - The logic to execute.
|
|
49
|
+
* @returns A promise representing the completion of the continue operation.
|
|
50
|
+
*/
|
|
51
|
+
abstract continueConversation(reference: Partial<ConversationReference>, logic: (revocableContext: TurnContext) => Promise<void>): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Uploads an attachment.
|
|
54
|
+
* @param conversationId - The conversation ID.
|
|
55
|
+
* @param attachmentData - The attachment data.
|
|
56
|
+
* @returns A promise representing the ResourceResponse for the uploaded attachment.
|
|
57
|
+
*/
|
|
58
|
+
abstract uploadAttachment(conversationId: string, attachmentData: AttachmentData): Promise<ResourceResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Gets attachment information.
|
|
61
|
+
* @param attachmentId - The attachment ID.
|
|
62
|
+
* @returns A promise representing the AttachmentInfo for the requested attachment.
|
|
63
|
+
*/
|
|
64
|
+
abstract getAttachmentInfo(attachmentId: string): Promise<AttachmentInfo>;
|
|
65
|
+
/**
|
|
66
|
+
* Gets an attachment.
|
|
67
|
+
* @param attachmentId - The attachment ID.
|
|
68
|
+
* @param viewId - The view ID.
|
|
69
|
+
* @returns A promise representing the NodeJS.ReadableStream for the requested attachment.
|
|
70
|
+
*/
|
|
71
|
+
abstract getAttachment(attachmentId: string, viewId: string): Promise<NodeJS.ReadableStream>;
|
|
72
|
+
get onTurnError(): (context: TurnContext, error: Error) => Promise<void>;
|
|
73
|
+
set onTurnError(value: (context: TurnContext, error: Error) => Promise<void>);
|
|
74
|
+
/**
|
|
75
|
+
* Adds middleware to the adapter's middleware pipeline.
|
|
76
|
+
* @param middlewares - The middleware to add.
|
|
77
|
+
* @returns The adapter instance.
|
|
78
|
+
*/
|
|
79
|
+
use(...middlewares: Array<MiddlewareHandler | Middleware>): this;
|
|
80
|
+
private makeRevocable;
|
|
81
|
+
/**
|
|
82
|
+
* Runs the middleware pipeline in sequence.
|
|
83
|
+
* @param context - The TurnContext for the current turn.
|
|
84
|
+
* @param next - The next function to call in the pipeline.
|
|
85
|
+
* @returns A promise representing the completion of the middleware pipeline.
|
|
86
|
+
*/
|
|
87
|
+
protected runMiddleware(context: TurnContext, next: (revocableContext: TurnContext) => Promise<void>): Promise<void>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
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.BaseAdapter = void 0;
|
|
8
|
+
const msalTokenProvider_1 = require("./auth/msalTokenProvider");
|
|
9
|
+
const middlewareSet_1 = require("./middlewareSet");
|
|
10
|
+
const logger_1 = require("./logger");
|
|
11
|
+
const logger = (0, logger_1.debug)('agents:base-adapter');
|
|
12
|
+
/**
|
|
13
|
+
* Base class for all adapters, providing middleware and error handling capabilities.
|
|
14
|
+
*/
|
|
15
|
+
class BaseAdapter {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.middleware = new middlewareSet_1.MiddlewareSet();
|
|
18
|
+
this.turnError = async (context, error) => {
|
|
19
|
+
logger.error(`\n [onTurnError] unhandled error: ${error}`);
|
|
20
|
+
// Send a trace activity, which will be displayed in Bot Framework Emulator
|
|
21
|
+
await context.sendTraceActivity('OnTurnError Trace', `${error}`, 'https://www.botframework.com/schemas/error', 'TurnError');
|
|
22
|
+
// Send a message to the user
|
|
23
|
+
await context.sendActivity('The agent encountered an error or bug.');
|
|
24
|
+
await context.sendActivity('To continue to run this agent, please fix the source code.');
|
|
25
|
+
};
|
|
26
|
+
this.AgentIdentityKey = Symbol('AgentIdentity');
|
|
27
|
+
this.ConnectorClientKey = Symbol('ConnectorClient');
|
|
28
|
+
this.OAuthScopeKey = Symbol('OAuthScope');
|
|
29
|
+
this.authProvider = new msalTokenProvider_1.MsalTokenProvider();
|
|
30
|
+
this.authConfig = { issuers: [] };
|
|
31
|
+
}
|
|
32
|
+
get onTurnError() {
|
|
33
|
+
return this.turnError;
|
|
34
|
+
}
|
|
35
|
+
set onTurnError(value) {
|
|
36
|
+
this.turnError = value;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Adds middleware to the adapter's middleware pipeline.
|
|
40
|
+
* @param middlewares - The middleware to add.
|
|
41
|
+
* @returns The adapter instance.
|
|
42
|
+
*/
|
|
43
|
+
use(...middlewares) {
|
|
44
|
+
this.middleware.use(...middlewares);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
makeRevocable(target, handler) {
|
|
48
|
+
// Ensure proxy supported (some browsers don't)
|
|
49
|
+
if (typeof Proxy !== 'undefined' && Proxy.revocable) {
|
|
50
|
+
return Proxy.revocable(target, (handler != null) ? handler : {});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return {
|
|
54
|
+
proxy: target,
|
|
55
|
+
revoke: () => {
|
|
56
|
+
// noop
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Runs the middleware pipeline in sequence.
|
|
63
|
+
* @param context - The TurnContext for the current turn.
|
|
64
|
+
* @param next - The next function to call in the pipeline.
|
|
65
|
+
* @returns A promise representing the completion of the middleware pipeline.
|
|
66
|
+
*/
|
|
67
|
+
async runMiddleware(context, next) {
|
|
68
|
+
if (context && context.activity && context.activity.locale) {
|
|
69
|
+
context.locale = context.activity.locale;
|
|
70
|
+
}
|
|
71
|
+
const pContext = this.makeRevocable(context);
|
|
72
|
+
try {
|
|
73
|
+
await this.middleware.run(pContext.proxy, async () => await next(pContext.proxy));
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
if (this.onTurnError) {
|
|
77
|
+
if (err instanceof Error) {
|
|
78
|
+
await this.onTurnError(pContext.proxy, err);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
throw new Error('Unknown error type');
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
pContext.revoke();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.BaseAdapter = BaseAdapter;
|
|
94
|
+
//# sourceMappingURL=baseAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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;gBACN,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,QAAQ,CAAC,MAAM,EAAE,CAAA;QACnB,CAAC;IACH,CAAC;CACF;AAxJD,kCAwJC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright(c) Microsoft Corporation.All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { CardAction } from '@microsoft/agents-activity';
|
|
6
|
+
import { MediaUrl } from './mediaUrl';
|
|
7
|
+
import { ThumbnailUrl } from './thumbnailUrl';
|
|
8
|
+
/**
|
|
9
|
+
* Interface representing an Animation Card.
|
|
10
|
+
*/
|
|
11
|
+
export interface AnimationCard {
|
|
12
|
+
/** The title of the card. */
|
|
13
|
+
title: string;
|
|
14
|
+
/** The subtitle of the card. */
|
|
15
|
+
subtitle: string;
|
|
16
|
+
/** The text content of the card. */
|
|
17
|
+
text: string;
|
|
18
|
+
/** The image to be displayed on the card. */
|
|
19
|
+
image: ThumbnailUrl;
|
|
20
|
+
/** The media URLs or objects. */
|
|
21
|
+
media: MediaUrl[];
|
|
22
|
+
/** The buttons to be displayed on the card. */
|
|
23
|
+
buttons: CardAction[];
|
|
24
|
+
/** Indicates whether the card is shareable. */
|
|
25
|
+
shareable: boolean;
|
|
26
|
+
/** Indicates whether the card should auto-loop. */
|
|
27
|
+
autoloop: boolean;
|
|
28
|
+
/** Indicates whether the card should auto-start. */
|
|
29
|
+
autostart: boolean;
|
|
30
|
+
/** The aspect ratio of the card. */
|
|
31
|
+
aspect: string;
|
|
32
|
+
/** The duration of the animation. */
|
|
33
|
+
duration: string;
|
|
34
|
+
/** Additional value for the card. */
|
|
35
|
+
value: any;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animationCard.js","sourceRoot":"","sources":["../../../src/cards/animationCard.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright(c) Microsoft Corporation.All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { CardAction } from '@microsoft/agents-activity';
|
|
6
|
+
import { MediaUrl } from './mediaUrl';
|
|
7
|
+
import { ThumbnailUrl } from './thumbnailUrl';
|
|
8
|
+
/**
|
|
9
|
+
* Interface representing an Audio Card.
|
|
10
|
+
*/
|
|
11
|
+
export interface AudioCard {
|
|
12
|
+
/** The title of the card. */
|
|
13
|
+
title: string;
|
|
14
|
+
/** The subtitle of the card. */
|
|
15
|
+
subtitle: string;
|
|
16
|
+
/** The text content of the card. */
|
|
17
|
+
text: string;
|
|
18
|
+
/** The image to be displayed on the card. */
|
|
19
|
+
image: ThumbnailUrl;
|
|
20
|
+
/** The media URLs or objects. */
|
|
21
|
+
media: MediaUrl[];
|
|
22
|
+
/** The buttons to be displayed on the card. */
|
|
23
|
+
buttons: CardAction[];
|
|
24
|
+
/** Indicates whether the card is shareable. */
|
|
25
|
+
shareable: boolean;
|
|
26
|
+
/** Indicates whether the card should auto-loop. */
|
|
27
|
+
autoloop: boolean;
|
|
28
|
+
/** Indicates whether the card should auto-start. */
|
|
29
|
+
autostart: boolean;
|
|
30
|
+
/** The aspect ratio of the card. */
|
|
31
|
+
aspect: string;
|
|
32
|
+
/** The duration of the audio. */
|
|
33
|
+
duration: string;
|
|
34
|
+
/** Additional value for the card. */
|
|
35
|
+
value: any;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioCard.js","sourceRoot":"","sources":["../../../src/cards/audioCard.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
|