function determineWebSocketScheme (config, protocolSupplier) {
  const encryptionOn = isEncryptionExplicitlyTurnedOn(config)
  const encryptionOff = isEncryptionExplicitlyTurnedOff(config)
  const trust = config.trust
  const secureProtocol = isProtocolSecure(protocolSupplier)
  verifyEncryptionSettings(encryptionOn, encryptionOff, secureProtocol)

  if (encryptionOff) {
    // encryption explicitly turned off in the config
    return { scheme: 'ws', error: null }
  }

  if (secureProtocol) {
    // driver is used in a secure https web page, use 'wss'
    return { scheme: 'wss', error: null }
  }

  if (encryptionOn) {
    // encryption explicitly requested in the config
    if (!trust || trust === 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES') {
      // trust strategy not specified or the only supported strategy is specified
      return { scheme: 'wss', error: null }
    } else {
      const error = newError(
        'The browser version of this driver only supports one trust ' +
          "strategy, 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'. " +
          trust +
          ' is not supported. Please ' +
          'either use TRUST_SYSTEM_CA_SIGNED_CERTIFICATES or disable encryption by setting ' +
          '`encrypted:"' +
          ENCRYPTION_OFF +
          '"` in the driver configuration.'
      )
      return { scheme: null, error }
    }
  }

  // default to unencrypted web socket
  return { scheme: 'ws', error: null }
}
@param {ChannelConfig} config - configuration for the channel.
@param {function(): string} protocolSupplier - function that detects protocol of the web page.
@return {{scheme: string|null, error: Neo4jError|null}} object containing either scheme or error.