IHttpConnectionOptions.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. import { HttpClient } from "./HttpClient";
  4. import { ILogger, LogLevel } from "./ILogger";
  5. import { HttpTransportType, ITransport } from "./ITransport";
  6. import { EventSourceConstructor, WebSocketConstructor } from "./Polyfills";
  7. /** Options provided to the 'withUrl' method on {@link @aspnet/signalr.HubConnectionBuilder} to configure options for the HTTP-based transports. */
  8. export interface IHttpConnectionOptions {
  9. /** An {@link @aspnet/signalr.HttpClient} that will be used to make HTTP requests. */
  10. httpClient?: HttpClient;
  11. /** An {@link @aspnet/signalr.HttpTransportType} value specifying the transport to use for the connection. */
  12. transport?: HttpTransportType | ITransport;
  13. /** Configures the logger used for logging.
  14. *
  15. * Provide an {@link @aspnet/signalr.ILogger} instance, and log messages will be logged via that instance. Alternatively, provide a value from
  16. * the {@link @aspnet/signalr.LogLevel} enumeration and a default logger which logs to the Console will be configured to log messages of the specified
  17. * level (or higher).
  18. */
  19. logger?: ILogger | LogLevel;
  20. /** A function that provides an access token required for HTTP Bearer authentication.
  21. *
  22. * @returns {string | Promise<string>} A string containing the access token, or a Promise that resolves to a string containing the access token.
  23. */
  24. accessTokenFactory?(): string | Promise<string>;
  25. /** A boolean indicating if message content should be logged.
  26. *
  27. * Message content can contain sensitive user data, so this is disabled by default.
  28. */
  29. logMessageContent?: boolean;
  30. /** A boolean indicating if negotiation should be skipped.
  31. *
  32. * Negotiation can only be skipped when the {@link @aspnet/signalr.IHttpConnectionOptions.transport} property is set to 'HttpTransportType.WebSockets'.
  33. */
  34. skipNegotiation?: boolean;
  35. // Used for unit testing and code spelunkers
  36. /** A constructor that can be used to create a WebSocket.
  37. *
  38. * @internal
  39. */
  40. WebSocket?: WebSocketConstructor;
  41. // Used for unit testing and code spelunkers
  42. /** A constructor that can be used to create an EventSource.
  43. *
  44. * @internal
  45. */
  46. EventSource?: EventSourceConstructor;
  47. }