1
1
import { BaseProvider } from '../BaseProvider' ;
2
- import { SecretsManagerClient , GetSecretValueCommand } from '@aws-sdk/client-secrets-manager' ;
2
+ import {
3
+ SecretsManagerClient ,
4
+ GetSecretValueCommand
5
+ } from '@aws-sdk/client-secrets-manager' ;
3
6
import type { GetSecretValueCommandInput } from '@aws-sdk/client-secrets-manager' ;
4
- import type { SecretsProviderOptions , SecretsGetOptionsInterface } from 'types/SecretsProvider' ;
7
+ import type {
8
+ SecretsProviderOptions ,
9
+ SecretsGetOptionsInterface
10
+ } from '../types/SecretsProvider' ;
5
11
6
12
class SecretsProvider extends BaseProvider {
7
13
public client : SecretsManagerClient ;
@@ -13,18 +19,21 @@ class SecretsProvider extends BaseProvider {
13
19
this . client = new SecretsManagerClient ( clientConfig ) ;
14
20
}
15
21
16
- public async get ( name : string , options ?: SecretsGetOptionsInterface ) : Promise < undefined | string | Uint8Array | Record < string , unknown > > {
22
+ public async get (
23
+ name : string ,
24
+ options ?: SecretsGetOptionsInterface
25
+ ) : Promise < undefined | string | Uint8Array | Record < string , unknown > > {
17
26
return super . get ( name , options ) ;
18
27
}
19
28
20
- protected async _get ( name : string , options ?: SecretsGetOptionsInterface ) : Promise < string | Uint8Array | undefined > {
29
+ protected async _get (
30
+ name : string ,
31
+ options ?: SecretsGetOptionsInterface
32
+ ) : Promise < string | Uint8Array | undefined > {
21
33
const sdkOptions : GetSecretValueCommandInput = {
34
+ ...( options ?. sdkOptions || { } ) ,
22
35
SecretId : name ,
23
36
} ;
24
- if ( options ?. sdkOptions ) {
25
- this . removeNonOverridableOptions ( options . sdkOptions as GetSecretValueCommandInput ) ;
26
- Object . assign ( sdkOptions , options . sdkOptions ) ;
27
- }
28
37
29
38
const result = await this . client . send ( new GetSecretValueCommand ( sdkOptions ) ) ;
30
39
@@ -36,20 +45,12 @@ class SecretsProvider extends BaseProvider {
36
45
/**
37
46
* Retrieving multiple parameter values is not supported with AWS Secrets Manager.
38
47
*/
39
- protected async _getMultiple ( _path : string , _options ?: unknown ) : Promise < Record < string , string | undefined > > {
48
+ protected async _getMultiple (
49
+ _path : string ,
50
+ _options ?: unknown
51
+ ) : Promise < Record < string , string | undefined > > {
40
52
throw new Error ( 'Method not implemented.' ) ;
41
- }
42
-
43
- /**
44
- * Explicit arguments passed to the constructor will take precedence over ones passed to the method.
45
- * For users who consume the library with TypeScript, this will be enforced by the type system. However,
46
- * for JavaScript users, we need to manually delete the properties that are not allowed to be overridden.
47
- */
48
- protected removeNonOverridableOptions ( options : GetSecretValueCommandInput ) : void {
49
- if ( options . hasOwnProperty ( 'SecretId' ) ) {
50
- delete options . SecretId ;
51
- }
52
- }
53
+ }
53
54
}
54
55
55
56
export {
0 commit comments