File tree Expand file tree Collapse file tree 6 files changed +19
-17
lines changed Expand file tree Collapse file tree 6 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,8 @@ export class MongoCryptError extends Error {
23
23
* An error indicating that `ClientEncryption.createEncryptedCollection()` failed to create data keys
24
24
*/
25
25
export class MongoCryptCreateDataKeyError extends MongoCryptError {
26
- // TODO: type encrypted fields
27
26
encryptedFields : Document ;
28
- constructor ( { encryptedFields, cause } ) {
27
+ constructor ( { encryptedFields , cause } : { encryptedFields : Document , cause : Error } ) {
29
28
super ( `Unable to complete creating data keys: ${ cause . message } ` , { cause } ) ;
30
29
this . encryptedFields = encryptedFields ;
31
30
}
@@ -40,9 +39,8 @@ export class MongoCryptCreateDataKeyError extends MongoCryptError {
40
39
* An error indicating that `ClientEncryption.createEncryptedCollection()` failed to create a collection
41
40
*/
42
41
export class MongoCryptCreateEncryptedCollectionError extends MongoCryptError {
43
- // TODO: type encrypted fields
44
42
encryptedFields : Document ;
45
- constructor ( { encryptedFields, cause } ) {
43
+ constructor ( { encryptedFields , cause } : { encryptedFields : Document , cause : Error } ) {
46
44
super ( `Unable to create collection: ${ cause . message } ` , { cause } ) ;
47
45
this . encryptedFields = encryptedFields ;
48
46
}
Original file line number Diff line number Diff line change @@ -16,6 +16,5 @@ export async function loadAWSCredentials(kmsProviders: KMSProviders): Promise<KM
16
16
// The state machine is the only place calling this so it will
17
17
// catch if there is a rejection here.
18
18
const aws = await provider ( ) ;
19
- // TODO - figure out the type mismatch here
20
19
return { ...kmsProviders , aws } ;
21
20
}
Original file line number Diff line number Diff line change @@ -117,8 +117,10 @@ export function prepareRequest(options: AzureKMSRequestOptions): {
117
117
const url =
118
118
options . url == null
119
119
? new URL ( 'http://169.254.169.254/metadata/identity/oauth2/token' )
120
- : // TODO - figure out why typings are messed up.
121
- // @ts -expect-error the URL constructor supports a url parameter, but the types say it doesn't
120
+ : // The Node URL constructor technically supports "any object that converts to a valid URL string",
121
+ // but Node types doesn't support this. See the Node docs for new URL().
122
+ // https://nodejs.org/api/url.html#new-urlinput-base
123
+ // @ts -ignore
122
124
new URL ( options . url ) ;
123
125
124
126
url . searchParams . append ( 'api-version' , '2018-02-01' ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export async function loadGCPCredentials(kmsProviders: KMSProviders): Promise<KM
9
9
return kmsProviders ;
10
10
}
11
11
12
- const { access_token : accessToken } = await gcpMetadata . instance ( {
12
+ const { access_token : accessToken } = await gcpMetadata . instance < { access_token : string } > ( {
13
13
property : 'service-accounts/default/token'
14
14
} ) ;
15
15
return { ...kmsProviders , gcp : { accessToken } } ;
Original file line number Diff line number Diff line change @@ -157,14 +157,6 @@ interface AWSTempCredentials {
157
157
Expiration ?: Date ;
158
158
}
159
159
160
- /* @internal */
161
- export interface AWSCredentials {
162
- accessKeyId ?: string ;
163
- secretAccessKey ?: string ;
164
- sessionToken ?: string ;
165
- expiration ?: Date ;
166
- }
167
-
168
160
async function makeTempCredentials ( credentials : MongoCredentials ) : Promise < MongoCredentials > {
169
161
function makeMongoCredentialsFromAWSTemp ( creds : AWSTempCredentials ) {
170
162
if ( ! creds . AccessKeyId || ! creds . SecretAccessKey || ! creds . Token ) {
Original file line number Diff line number Diff line change 1
1
/* eslint-disable @typescript-eslint/no-var-requires */
2
2
import type { Document } from './bson' ;
3
- import type { AWSCredentials } from './cmap/auth/mongodb_aws' ;
4
3
import type { ProxyOptions } from './cmap/connection' ;
5
4
import { MongoMissingDependencyError } from './error' ;
6
5
import type { MongoClient } from './mongo_client' ;
@@ -76,6 +75,18 @@ export function getZstdLibrary(): typeof ZStandard | { kModuleError: MongoMissin
76
75
}
77
76
}
78
77
78
+ /**
79
+ * @internal
80
+ * Copy of the AwsCredentialIdentityProvider interface from [`@smithy/types`](https://socket.dev/npm/package/@smithy/types/files/1.1.1/dist-types/identity/awsCredentialIdentity.d.ts),
81
+ * the return type of the aws-sdk's `fromNodeProviderChain().provider()`.
82
+ */
83
+ export interface AWSCredentials {
84
+ accessKeyId : string ;
85
+ secretAccessKey : string ;
86
+ sessionToken : string ;
87
+ expiration ?: Date ;
88
+ }
89
+
79
90
type CredentialProvider = {
80
91
fromNodeProviderChain ( this : void ) : ( ) => Promise < AWSCredentials > ;
81
92
} ;
You can’t perform that action at this time.
0 commit comments