credentials.d.ts (2504B)
1 import {AWSError} from './error'; 2 export class Credentials { 3 /** 4 * Creates a Credentials object with a given set of credential information as an options hash. 5 * 6 * @param {object} options - An option hash containing a set of credential information. 7 */ 8 constructor(options: CredentialsOptions); 9 /** 10 * Creates a Credentials object with a given set of credential information as positional arguments. 11 * * 12 * @param {string} accessKeyId - The AWS access key ID. 13 * @param {string} secretAccessKey - The AWS secret access key. 14 * @param {string} sessionToken - The optional AWS session token. 15 */ 16 constructor(accessKeyId: string, secretAccessKey: string, sessionToken?: string); 17 /** 18 * Gets the existing credentials, refreshing them if they are not yet loaded or have expired. 19 * Users should call this method before using refresh(), as this will not attempt to reload 20 * credentials when they are already loaded into the object. 21 * 22 * @param {get} callback - Called when the instance metadata service responds. When called with no error, the credentials information has been loaded into the object. 23 */ 24 get(callback: (err: AWSError) => void): void; 25 /** 26 * Returns whether the credentials object should call refresh() 27 */ 28 needsRefresh(): boolean; 29 /** 30 * Refreshes the credentials. 31 * Users should call get() before attempting to forcibly refresh credentials. 32 * 33 * @param {function} callback - Called when the instance metadata service responds. When called with no error, the credentials information has been loaded into the object. 34 */ 35 refresh(callback: (err: AWSError) => void): void; 36 /** 37 * AWS access key ID. 38 */ 39 accessKeyId: string 40 /** 41 * Whether the credentials have been expired and require a refresh. 42 * Used in conjunction with expireTime. 43 */ 44 expired: boolean 45 /** 46 * Time when credentials should be considered expired. 47 * Used in conjunction with expired. 48 */ 49 expireTime: Date 50 static expiryWindow: number 51 /** 52 * AWS secret access key. 53 */ 54 secretAccessKey: string 55 /** 56 * AWS session token. 57 */ 58 sessionToken: string 59 } 60 61 interface CredentialsOptions { 62 /** 63 * AWS access key ID. 64 */ 65 accessKeyId: string 66 /** 67 * AWS secret access key. 68 */ 69 secretAccessKey: string 70 /** 71 * AWS session token. 72 */ 73 sessionToken?: string 74 }