@@ -5,7 +5,6 @@ import { stringifyError } from '@sofie-automation/shared-lib/dist/lib/stringifyE
55import { PeripheralDevice , PeripheralDeviceCategory } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice'
66import { Rundown , RundownSourceNrcs } from '@sofie-automation/corelib/dist/dataModel/Rundown'
77import { logger } from '../../logging'
8- import { MethodContext } from '../methodContext'
98import { profiler } from '../profiler'
109import { IngestJobFunc } from '@sofie-automation/corelib/dist/worker/ingest'
1110import { QueueIngestJob } from '../../worker/worker'
@@ -19,8 +18,6 @@ import {
1918} from '@sofie-automation/corelib/dist/dataModel/Ids'
2019import { PeripheralDevices } from '../../collections'
2120import { getStudioIdFromDevice } from '../studio/lib'
22- import { assertConnectionHasOneOfPermissions } from '../../security/auth'
23- import { SubscriptionContext } from '../../publications/lib'
2421
2522/**
2623 * Run an ingest operation via the worker.
@@ -64,43 +61,6 @@ export async function runIngestOperation<T extends keyof IngestJobFunc>(
6461 }
6562}
6663
67- /** Check Access and return PeripheralDevice, throws otherwise */
68- export async function checkAccessAndGetPeripheralDevice (
69- deviceId : PeripheralDeviceId ,
70- token : string | undefined ,
71- context : MethodContext | SubscriptionContext
72- ) : Promise < PeripheralDevice > {
73- const span = profiler . startSpan ( 'lib.checkAccessAndGetPeripheralDevice' )
74-
75- assertConnectionHasOneOfPermissions ( context . connection , 'gateway' )
76-
77- // If no token, we will never match
78- if ( ! token ) throw new Meteor . Error ( 401 , `Not allowed access to peripheralDevice` )
79-
80- const device = await PeripheralDevices . findOneAsync ( { _id : deviceId } )
81- if ( ! device ) throw new Meteor . Error ( 404 , `PeripheralDevice "${ deviceId } " not found` )
82-
83- // Check if the device has a token, and if it matches:
84- if ( device . token && device . token === token ) {
85- span ?. end ( )
86- return device
87- }
88-
89- // If the device has a parent, try that for access control:
90- const parentDevice = device . parentDeviceId ? await PeripheralDevices . findOneAsync ( device . parentDeviceId ) : device
91- if ( ! parentDevice ) throw new Meteor . Error ( 404 , `PeripheralDevice parentDevice "${ device . parentDeviceId } " not found` )
92-
93- // Check if the parent device has a token, and if it matches:
94- if ( parentDevice . token && parentDevice . token === token ) {
95- span ?. end ( )
96- return device
97- }
98-
99- // No match for token found
100- span ?. end ( )
101- throw new Meteor . Error ( 401 , `Not allowed access to peripheralDevice` )
102- }
103-
10464export function getRundownId ( studioId : StudioId , rundownExternalId : string ) : RundownId {
10565 if ( ! studioId ) throw new Meteor . Error ( 500 , 'getRundownId: studio not set!' )
10666 if ( ! rundownExternalId ) throw new Meteor . Error ( 401 , 'getRundownId: rundownExternalId must be set!' )
0 commit comments