* Verify if port is allowed to create controller * All web accessible resources should not be allowed to create a controller, * therefore only known IDs can be used to create such dialogs * @param {Object} port
(type, port)
| 105 | * @param {Object} port |
| 106 | */ |
| 107 | function verifyCreatePermission(type, port) { |
| 108 | if (!repo.has(type)) { |
| 109 | // view types not registered in repo are not allowed to create controller |
| 110 | throw new Error(`No controller found for view type: ${type}`); |
| 111 | } |
| 112 | if (!port) { |
| 113 | return; |
| 114 | } |
| 115 | if (type === 'editor') { |
| 116 | throw new Error('Editor view not allowed to directly create controller.'); |
| 117 | } |
| 118 | if (type === 'app') { |
| 119 | const sender = parseViewName(port.name); |
| 120 | if (sender.id !== APP_TOP_FRAME_ID) { |
| 121 | throw new Error('App view in embedded frame not allowed to directly create controller.'); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | export function verifyConnectPermission(type, sender) { |
| 127 | if (type === sender.type) { |
no test coverage detected