Skip to content

Commit

Permalink
Merge branch 'preview'
Browse files Browse the repository at this point in the history
  • Loading branch information
wictorwilen committed Nov 18, 2021
2 parents 753199d + 9b272a6 commit 3b27da9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [*1.9.0*] - <*2021-11-18*>

### Changes

* **BREAKING**: Added user state to classes marked with the `BotDeclaration` decorator. Class is instantiated with the following arguments: `(ConversationState, UserState, BotFrameworkAdapter)`
* Added `*.office.com` to CSP header for pages

## [*1.8.0*] - <*2021-10-22*>

### Added
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "express-msteams-host",
"version": "1.8.0",
"version": "1.9.0",
"description": "Express utility for Microsoft Teams solutions",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
7 changes: 5 additions & 2 deletions src/routers/MsTeamsApiRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IOutgoingWebhook } from "../interfaces/IOutgoingWebhook";
import { IConnector } from "../interfaces/IConnector";
import * as debug from "debug";
import { BotFrameworkAdapter } from "botbuilder";
import { ConversationState, ActivityHandler } from "botbuilder-core";
import { ConversationState, ActivityHandler, UserState } from "botbuilder-core";
import { MessagingExtensionMiddleware } from "botbuilder-teams-messagingextensions";
import "reflect-metadata";
import { IBotDeclarationSettings } from "../decorators/BotDeclaration";
Expand Down Expand Up @@ -38,6 +38,9 @@ export default (components: any): Router => {
// Create the conversation state
const conversationState: ConversationState = new ConversationState(botSettings.storage, botSettings.namespace);

// Create the user state
const userState: UserState = new UserState(botSettings.storage, botSettings.namespace);

// generic error handler
adapter.onTurnError = async (context, error) => {
log(`[onTurnError]: ${error}`);
Expand All @@ -46,7 +49,7 @@ export default (components: any): Router => {
};
// Create the Bot
// eslint-disable-next-line new-cap
const bot: ActivityHandler = new component(conversationState, adapter);
const bot: ActivityHandler = new component(conversationState, userState, adapter);

// add the Messaging Extension Middleware
for (const p in bot) {
Expand Down
4 changes: 2 additions & 2 deletions src/routers/MsTeamsPageRouter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ describe("MsTeamsPageRouter", () => {
expect(response.headers["Content-Security-Policy"]).toBeUndefined();
});

it("Shoudl return 200, with CSP", async () => {
it("Should return 200, with CSP", async () => {
const req = request(app);
const response = await req.get("/test.html");
expect(response).toBeDefined();
expect(response.statusCode).toEqual(200);
// console.log(JSON.stringify(response));
const host = (response as any).request.host;
expect(response.headers["content-security-policy"]).toEqual("frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.sharepoint.com outlook.office.com *.teams.microsoft.us local.teams.office.com " + host);
expect(response.headers["content-security-policy"]).toEqual("frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.sharepoint.com outlook.office.com *.teams.microsoft.us local.teams.office.com *.office.com " + host);
});

});
2 changes: 1 addition & 1 deletion src/routers/MsTeamsPageRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const MsTeamsPageRouter = (options: IMsTeamsPageRouterOptions): Router =>

// This is used to prevent your tabs from being embedded in other systems than Microsoft Teams
router.use((req: any, res: any, next: any) => {
res.setHeader("Content-Security-Policy", "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.sharepoint.com outlook.office.com *.teams.microsoft.us local.teams.office.com " + req.headers.host);
res.setHeader("Content-Security-Policy", "frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.sharepoint.com outlook.office.com *.teams.microsoft.us local.teams.office.com *.office.com " + req.headers.host);
res.setHeader("X-Frame-Options", "ALLOW-FROM https://teams.microsoft.com/."); // IE11
next();
});
Expand Down

0 comments on commit 3b27da9

Please sign in to comment.