@@ -9,6 +9,7 @@ const utils = require('./utils');
9
9
const MINIMUM_TOKEN_REFRESH_IN_MILLISECONDS = 6000 ;
10
10
11
11
/**
12
+ * @class
12
13
* @ignore
13
14
*/
14
15
class AzureCredentialCache {
@@ -36,35 +37,45 @@ class AzureCredentialCache {
36
37
}
37
38
38
39
/**
39
- * @ignore
40
40
* exposed for testing
41
+ * @ignore
41
42
*/
42
43
resetCache ( ) {
43
44
this . cachedToken = null ;
44
45
}
45
46
46
47
/**
47
- * @ignore
48
48
* exposed for testing
49
+ * @ignore
49
50
*/
50
51
_getToken ( ) {
51
52
return fetchAzureKMSToken ( ) ;
52
53
}
53
54
}
54
55
/**
55
- * @type {AzureCredentialCache }
56
+ * @type { AzureCredentialCache }
57
+ * @ignore
56
58
*/
57
59
let tokenCache = new AzureCredentialCache ( ) ;
58
60
61
+ /**
62
+ * @typedef {object } KmsRequestResponsePayload
63
+ * @property {string | undefined } access_token
64
+ * @property {string | undefined } expires_in
65
+ *
66
+ * @ignore
67
+ */
68
+
59
69
/**
60
70
* @param { {body: string, status: number } } response
61
71
* @returns { Promise<{ accessToken: string, expiresOnTimestamp: number } > }
72
+ * @ignore
62
73
*/
63
74
async function parseResponse ( response ) {
64
75
const { status, body : rawBody } = response ;
65
76
66
77
/**
67
- * @type { { access_token?: string, expires_in?: string} }
78
+ * @type { KmsRequestResponsePayload }
68
79
*/
69
80
const body = ( ( ) => {
70
81
try {
@@ -107,6 +118,8 @@ async function parseResponse(response) {
107
118
* @param {object } options
108
119
* @param {object | undefined } [options.headers]
109
120
* @param {URL | undefined } [options.url]
121
+ *
122
+ * @ignore
110
123
*/
111
124
function prepareRequest ( options ) {
112
125
const url =
@@ -122,13 +135,26 @@ function prepareRequest(options) {
122
135
}
123
136
124
137
/**
138
+ * @typedef {object } AzureKMSRequestOptions
139
+ * @property {object | undefined } headers
140
+ * @property {URL | undefined } url
125
141
* @ignore
142
+ */
143
+
144
+ /**
145
+ * @typedef {object } AzureKMSRequestResponse
146
+ * @property {string } accessToken
147
+ * @property {number } expiresOnTimestamp
148
+ * @ignore
149
+ */
150
+
151
+ /**
126
152
* exported only for testing purposes in the driver
127
153
*
128
- * @param {object } options
129
- * @param { object | undefined } [options.headers]
130
- * @param { URL | undefined } [options.url]
131
- * @returns { Promise<{ accessToken: string, expiresOnTimestamp: number }> }
154
+ * @param {AzureKMSRequestOptions } options
155
+ * @returns { Promise<AzureKMSRequestResponse> }
156
+ *
157
+ * @ignore
132
158
*/
133
159
async function fetchAzureKMSToken ( options = { } ) {
134
160
const { headers, url } = prepareRequest ( options ) ;
@@ -142,7 +168,6 @@ async function fetchAzureKMSToken(options = {}) {
142
168
}
143
169
144
170
/**
145
- * @param {import('../../index').KMSProviders } kmsProviders
146
171
* @ignore
147
172
*/
148
173
async function loadAzureCredentials ( kmsProviders ) {
0 commit comments