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 | * string} secretAccessKey - The AWS secret access key.
{ |
14 | * 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 | * Gets the existing credentials, refreshing them if necessary, and returns
|
27 | * a promise that will be fulfilled immediately (if no refresh is necessary)
|
28 | * or when the refresh has completed.
|
29 | */
|
30 | getPromise(): Promise<void>;
|
31 | /**
|
32 | * Returns whether the credentials object should call refresh()
|
33 | */
|
34 | needsRefresh(): boolean;
|
35 | /**
|
36 | * Refreshes the credentials.
|
37 | * Users should call get() before attempting to forcibly refresh credentials.
|
38 | *
|
39 | * @param {function} callback - Called when the instance metadata service responds. When called with no error, the credentials information has been loaded into the object.
|
40 | */
|
41 | refresh(callback: (err: AWSError) => void): void;
|
42 | /**
|
43 | * Invokes a credential refresh and returns a promise that will be fulfilled
|
44 | * when the refresh has completed or rejected when the refresh has failed.
|
45 | * Users should call get() before attempting to forcibly refresh credentials.
|
46 | */
|
47 | refreshPromise(): Promise<void>;
|
48 | /**
|
49 | * AWS access key ID.
|
50 | */
|
51 | accessKeyId: string;
|
52 | /**
|
53 | * Whether the credentials have been expired and require a refresh.
|
54 | * Used in conjunction with expireTime.
|
55 | */
|
56 | expired: boolean;
|
57 | /**
|
58 | * Time when credentials should be considered expired.
|
59 | * Used in conjunction with expired.
|
60 | */
|
61 | expireTime: Date;
|
62 | static expiryWindow: number;
|
63 | /**
|
64 | * AWS secret access key.
|
65 | */
|
66 | secretAccessKey: string;
|
67 | /**
|
68 | * AWS session token.
|
69 | */
|
70 | sessionToken: string;
|
71 | }
|
72 |
|
73 | interface CredentialsOptions {
|
74 | /**
|
75 | * AWS access key ID.
|
76 | */
|
77 | accessKeyId: string
|
78 | /**
|
79 | * AWS secret access key.
|
80 | */
|
81 | secretAccessKey: string
|
82 | /**
|
83 | * AWS session token.
|
84 | */
|
85 | sessionToken?: string
|
86 | }
|