AssumeRoleProvider.d.mts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /// <reference types="node" />
  2. import * as http from 'node:http';
  3. import { CredentialProvider } from "./CredentialProvider.mjs";
  4. import { Credentials } from "./Credentials.mjs";
  5. /**
  6. * @see https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html
  7. */
  8. type CredentialResponse = {
  9. ErrorResponse?: {
  10. Error?: {
  11. Code?: string;
  12. Message?: string;
  13. };
  14. };
  15. AssumeRoleResponse: {
  16. AssumeRoleResult: {
  17. Credentials: {
  18. AccessKeyId: string;
  19. SecretAccessKey: string;
  20. SessionToken: string;
  21. Expiration: string;
  22. };
  23. };
  24. };
  25. };
  26. export interface AssumeRoleProviderOptions {
  27. stsEndpoint: string;
  28. accessKey: string;
  29. secretKey: string;
  30. durationSeconds?: number;
  31. sessionToken?: string;
  32. policy?: string;
  33. region?: string;
  34. roleArn?: string;
  35. roleSessionName?: string;
  36. externalId?: string;
  37. token?: string;
  38. webIdentityToken?: string;
  39. action?: string;
  40. transportAgent?: http.Agent;
  41. }
  42. export declare class AssumeRoleProvider extends CredentialProvider {
  43. private readonly stsEndpoint;
  44. private readonly accessKey;
  45. private readonly secretKey;
  46. private readonly durationSeconds;
  47. private readonly policy?;
  48. private readonly region;
  49. private readonly roleArn?;
  50. private readonly roleSessionName?;
  51. private readonly externalId?;
  52. private readonly token?;
  53. private readonly webIdentityToken?;
  54. private readonly action;
  55. private _credentials;
  56. private readonly expirySeconds;
  57. private accessExpiresAt;
  58. private readonly transportAgent?;
  59. private readonly transport;
  60. constructor({
  61. stsEndpoint,
  62. accessKey,
  63. secretKey,
  64. durationSeconds,
  65. sessionToken,
  66. policy,
  67. region,
  68. roleArn,
  69. roleSessionName,
  70. externalId,
  71. token,
  72. webIdentityToken,
  73. action,
  74. transportAgent
  75. }: AssumeRoleProviderOptions);
  76. getRequestConfig(): {
  77. requestOptions: http.RequestOptions;
  78. requestData: string;
  79. };
  80. performRequest(): Promise<CredentialResponse>;
  81. parseCredentials(respObj: CredentialResponse): Credentials;
  82. refreshCredentials(): Promise<Credentials>;
  83. getCredentials(): Promise<Credentials>;
  84. isAboutToExpire(): boolean;
  85. }
  86. export default AssumeRoleProvider;