msiTokenCredentials.d.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { WebResource, HttpClient } from "@azure/ms-rest-js";
  2. import { TokenClientCredentials, TokenResponse } from "./tokenClientCredentials";
  3. /**
  4. * @interface MSIOptions Defines the optional parameters for authentication with MSI.
  5. */
  6. export interface MSIOptions {
  7. /**
  8. * @prop {string} [resource] - The resource uri or token audience for which the token is needed.
  9. * For e.g. it can be:
  10. * - resourcemanagement endpoint "https://management.azure.com/" (default)
  11. * - management endpoint "https://management.core.windows.net/"
  12. */
  13. resource?: string;
  14. /**
  15. * @property {HttpClient} [httpClient] - The client responsible for sending HTTP requests.
  16. * By default it is Axios-based {@link DefaultHttpClient}.
  17. */
  18. httpClient?: HttpClient;
  19. }
  20. /**
  21. * @interface MSITokenResponse - Describes the MSITokenResponse.
  22. */
  23. export interface MSITokenResponse extends TokenResponse {
  24. /**
  25. * @property {any} any - Placeholder for unknown properties.
  26. */
  27. readonly [x: string]: any;
  28. }
  29. /**
  30. * @class MSITokenCredentials - Provides information about managed service identity token credentials.
  31. * This object can only be used to acquire token on a virtual machine provisioned in Azure with managed service identity.
  32. */
  33. export declare abstract class MSITokenCredentials implements TokenClientCredentials {
  34. resource: string;
  35. protected _httpClient: HttpClient;
  36. /**
  37. * Creates an instance of MSITokenCredentials.
  38. * @param {object} [options] - Optional parameters
  39. * @param {string} [options.resource] - The resource uri or token audience for which the token is needed.
  40. * For e.g. it can be:
  41. * - resource management endpoint "https://management.azure.com/"(default)
  42. * - management endpoint "https://management.core.windows.net/"
  43. */
  44. constructor(options: MSIOptions);
  45. /**
  46. * Parses a tokenResponse json string into a object, and converts properties on the first level to camelCase.
  47. * This method tries to standardize the tokenResponse
  48. * @param {string} body A json string
  49. * @return {object} [tokenResponse] The tokenResponse (tokenType and accessToken are the two important properties).
  50. */
  51. parseTokenResponse(body: string): TokenResponse;
  52. /**
  53. * Prepares and sends a POST request to a service endpoint hosted on the Azure VM, which responds with the access token.
  54. * @param {function} callback The callback in the form (err, result)
  55. * @return {Promise<MSITokenResponse>} Promise with the token response.
  56. */
  57. abstract getToken(): Promise<MSITokenResponse>;
  58. protected abstract prepareRequestOptions(): WebResource;
  59. /**
  60. * Signs a request with the Authentication header.
  61. *
  62. * @param {webResource} The WebResource to be signed.
  63. * @return {Promise<WebResource>} Promise with signed WebResource.
  64. */
  65. signRequest(webResource: WebResource): Promise<WebResource>;
  66. }
  67. //# sourceMappingURL=msiTokenCredentials.d.ts.map