MCPcopy Index your code
hub / github.com/mailvelope/mailvelope / verifyCreatePermission

Function verifyCreatePermission

src/controller/factory.js:107–124  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

105 * @param {Object} port
106 */
107function 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
126export function verifyConnectPermission(type, sender) {
127 if (type === sender.type) {

Callers 1

createControllerFunction · 0.85

Calls 2

parseViewNameFunction · 0.90
hasMethod · 0.45

Tested by

no test coverage detected