Skip to content

Commit c113c2c

Browse files
authored
Removed message source check but kept origin validation in nested app auth standalone bridge (#2831)
* Remove message source check but keep origin validation * Create @microsoft-teams-js-8a2e274f-36a6-4e8e-a1aa-c56ae77741c6.json * Update @microsoft-teams-js-8a2e274f-36a6-4e8e-a1aa-c56ae77741c6.json
1 parent 2133410 commit c113c2c

File tree

3 files changed

+8
-30
lines changed

3 files changed

+8
-30
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Removed message source check but kept origin validation in nested app auth standalone bridge",
4+
"packageName": "@microsoft/teams-js",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/teams-js/src/private/nestedAppAuth/nestedAppAuthBridge.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { v4 as generateUUID } from 'uuid';
1919
* @internal
2020
* Limited to Microsoft-internal use
2121
*/
22-
export const version = '1.0.0';
22+
export const version = '1.0.1';
2323

2424
/**
2525
* Interface representing a request structure.
@@ -256,12 +256,6 @@ function processAuthBridgeMessage(evt: MessageEvent, onMessageReceived: (respons
256256
}
257257

258258
function shouldProcessIncomingMessage(messageSource: Window, messageOrigin: string): boolean {
259-
// Reject messages if they are not from the top window
260-
if (messageSource && messageSource !== window.top) {
261-
log('Should not process message because it is not coming from the top window');
262-
return false;
263-
}
264-
265259
// Check if messageOrigin matches topOriginForNAA
266260
if (messageOrigin === topOriginForNAA) {
267261
try {

packages/teams-js/test/private/nestedAppAuthBridge.spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -147,29 +147,6 @@ describe('NestedAppAuthBridge', () => {
147147
expect(mockWindow.removeEventListener).not.toBeCalled();
148148
});
149149

150-
it('should ignore message if source is not top window', () => {
151-
nestedAppAuthBridge.initialize(mockWindow as unknown as Window, mockOrigin);
152-
const bridge = mockWindow.nestedAppAuthBridge as NestedAppAuthBridge;
153-
154-
const callback = jest.fn();
155-
bridge.addEventListener('message', callback);
156-
157-
const handler = mockWindow.addEventListener.mock.calls[0][1] as (event: unknown) => void;
158-
159-
const fakeSource = {} as Window;
160-
161-
const msg = {
162-
origin: mockOrigin,
163-
source: fakeSource,
164-
data: {
165-
args: [null, JSON.stringify({ messageType: 'NestedAppAuthResponse' })],
166-
},
167-
};
168-
169-
handler(msg);
170-
expect(callback).not.toBeCalled();
171-
});
172-
173150
it('should ignore message without messageType', () => {
174151
nestedAppAuthBridge.initialize(mockWindow as unknown as Window, mockOrigin);
175152
const bridge = mockWindow.nestedAppAuthBridge as NestedAppAuthBridge;

0 commit comments

Comments
 (0)