![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/ts.corals.io/frontend/node_modules/pusher-js/src/runtimes/worker/auth/ |
import AbstractRuntime from 'runtimes/interface'; import { AuthTransport } from 'core/auth/auth_transports'; import { AuthRequestType, AuthTransportCallback, InternalAuthOptions } from 'core/auth/options'; import { HTTPAuthError } from 'core/errors'; var fetchAuth: AuthTransport = function( context: AbstractRuntime, query: string, authOptions: InternalAuthOptions, authRequestType: AuthRequestType, callback: AuthTransportCallback ) { var headers = new Headers(); headers.set('Content-Type', 'application/x-www-form-urlencoded'); for (var headerName in authOptions.headers) { headers.set(headerName, authOptions.headers[headerName]); } if (authOptions.headersProvider != null) { const dynamicHeaders = authOptions.headersProvider(); for (var headerName in dynamicHeaders) { headers.set(headerName, dynamicHeaders[headerName]); } } var body = query; var request = new Request(authOptions.endpoint, { headers, body, credentials: 'same-origin', method: 'POST' }); return fetch(request) .then(response => { let { status } = response; if (status === 200) { // manually parse the json so we can provide a more helpful error in // failure case return response.text(); } throw new HTTPAuthError( 200, `Could not get ${authRequestType.toString()} info from your auth endpoint, status: ${status}` ); }) .then(data => { let parsedData; try { parsedData = JSON.parse(data); } catch (e) { throw new HTTPAuthError( 200, `JSON returned from ${authRequestType.toString()} endpoint was invalid, yet status code was 200. Data was: ${data}` ); } callback(null, parsedData); }) .catch(err => { callback(err, null); }); }; export default fetchAuth;