( inputValidator: TType<T>, input: mixed, source: string, )
| 88 | } |
| 89 | |
| 90 | function checkInputValidator<T>( |
| 91 | inputValidator: TType<T>, |
| 92 | input: mixed, |
| 93 | source: string, |
| 94 | ): T { |
| 95 | if (inputValidator.is(input)) { |
| 96 | return assertWithValidator(input, inputValidator); |
| 97 | } |
| 98 | const error = new ServerError('invalid_parameters'); |
| 99 | try { |
| 100 | error.sanitizedInput = input ? sanitizeInput(inputValidator, input) : null; |
| 101 | } catch { |
| 102 | error.sanitizedInput = null; |
| 103 | } |
| 104 | console.log(`failed input validation on ${source}`); |
| 105 | throw error; |
| 106 | } |
| 107 | |
| 108 | async function checkClientSupported<T>( |
| 109 | viewer: Viewer, |
no test coverage detected