Skip to content

Commit 31239a5

Browse files
author
Asyrafuddin Mohamad
committed
Rename AllowOrigins to AllowedOrigins and update references in PostMessageBridge
1 parent af52b8a commit 31239a5

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

packages/core/src/__tests__/post-message.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CoreError } from '../errors';
33
import type { HandshakeMessage } from '../types';
44
import { afterEach, beforeEach, describe, expect, test, vi, Mock } from 'vitest';
55
import { source } from './shared';
6-
import { AllowOrigins } from '../allow-origins';
6+
import { AllowedOrigins } from '../allowed-origins';
77

88
describe('PostMessageBridge', () => {
99
const mockTarget = {
@@ -134,7 +134,7 @@ describe('PostMessageBridge', () => {
134134
} as MessageEvent;
135135

136136
const mockAllowOrigins = ['https://allowed-origin.com'];
137-
vi.spyOn(AllowOrigins, 'some').mockImplementation((callback) => mockAllowOrigins.some(callback));
137+
vi.spyOn(AllowedOrigins, 'some').mockImplementation((callback) => mockAllowOrigins.some(callback));
138138

139139
const bridge = new PostMessageBridge({
140140
target: mockTarget,

packages/core/src/allow-origins.ts renamed to packages/core/src/allowed-origins.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const AllowOrigins = [
1+
export const AllowedOrigins = [
22
'sitecore-staging.cloud',
33
'sitecorecloud.app',
44
'sitecorecloud.io'

packages/core/src/post-message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
CoreSDKConfig,
1313
HandshakeConfig,
1414
} from './types';
15-
import { AllowOrigins } from './allow-origins';
15+
import { AllowedOrigins } from './allowed-origins';
1616

1717
const DEFAULT_TIMEOUT = 30000; // 30 seconds
1818

@@ -333,7 +333,7 @@ export class PostMessageBridge {
333333

334334
// For client SDK, we need to validate the origin during the handshake.
335335
if (this.sdkType === 'client' && message.type === 'handshake' && this.isNullOrEmpty(this.config.targetOrigin)) {
336-
isValidOrigin = AllowOrigins.some(origin => event.origin.includes(origin));
336+
isValidOrigin = AllowedOrigins.some(origin => event.origin.includes(origin));
337337
//Once origin is confirmed, targetOrigin will not be null
338338
if (isValidOrigin) {
339339
this.config.targetOrigin = event.origin;

0 commit comments

Comments
 (0)