File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ [
2+ " https://nmrxiv.org" ,
3+ " http://nmrxiv.org" ,
4+ " http://localhost" ,
5+ " http://localhost:3000" ,
6+ " http://127.0.0.1:" ,
7+ " http://127.0.0.1:3000" ,
8+ " http://test.nmrxiv.org" ,
9+ " http://193.196.39.168" ,
10+ " http://193.196.39.168:3000" ,
11+ " https://nodejsdev.nmrxiv.org"
12+ ]
Original file line number Diff line number Diff line change 11import { EventType , EventData } from './types' ;
2-
3- const ALLOWED_ORIGINS : string [ ] = [
4- 'https://nmrxiv.org' ,
5- 'http://nmrxiv.org' ,
6- 'http://localhost' ,
7- 'http://localhost:3000' ,
8- 'http://127.0.0.1:' ,
9- 'http://127.0.0.1:3000' ,
10- 'http://test.nmrxiv.org' ,
11- 'http://193.196.39.168' ,
12- 'http://193.196.39.168:3000' ,
13- 'https://nodejsdev.nmrxiv.org' ,
14- ] ;
2+ import ALLOWED_ORIGINS from '../allowed-origins.json' ;
153
164const namespace = 'nmr-wrapper' ;
175
@@ -32,7 +20,10 @@ function on<T extends EventType>(
3220
3321 const url = new URL ( origin ) ;
3422
35- if ( ! ALLOWED_ORIGINS . includes ( url . origin ) ) {
23+ const skipOriginCheck =
24+ ALLOWED_ORIGINS . length === 0 || ALLOWED_ORIGINS . includes ( '*' ) ;
25+
26+ if ( ! skipOriginCheck && ! ALLOWED_ORIGINS . includes ( url . origin ) ) {
3627 throw new Error ( `Invalid Origin ${ origin } ` ) ;
3728 }
3829
You can’t perform that action at this time.
0 commit comments