ibm-cloud-sdk-core 5.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.secrets.baseline +128 -24
- package/Authentication.md +146 -21
- package/CHANGELOG.md +14 -0
- package/README.md +3 -2
- package/auth/authenticators/authenticator.d.ts +1 -0
- package/auth/authenticators/authenticator.js +1 -0
- package/auth/authenticators/basic-authenticator.d.ts +1 -1
- package/auth/authenticators/basic-authenticator.js +3 -1
- package/auth/authenticators/bearer-token-authenticator.js +2 -0
- package/auth/authenticators/container-authenticator.d.ts +6 -0
- package/auth/authenticators/container-authenticator.js +8 -0
- package/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/auth/authenticators/iam-assume-authenticator.js +92 -0
- package/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/auth/authenticators/iam-authenticator.js +8 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/auth/authenticators/iam-request-based-authenticator-immutable.js +74 -0
- package/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/auth/authenticators/iam-request-based-authenticator.js +28 -36
- package/auth/authenticators/index.d.ts +4 -1
- package/auth/authenticators/index.js +3 -1
- package/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/auth/authenticators/token-request-based-authenticator-immutable.js +91 -0
- package/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/auth/authenticators/token-request-based-authenticator.js +5 -40
- package/auth/token-managers/container-token-manager.d.ts +6 -0
- package/auth/token-managers/container-token-manager.js +18 -50
- package/auth/token-managers/cp4d-token-manager.js +6 -1
- package/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/auth/token-managers/iam-assume-token-manager.js +220 -0
- package/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/auth/token-managers/iam-request-based-token-manager.js +5 -9
- package/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/auth/token-managers/iam-token-manager.js +10 -2
- package/auth/token-managers/index.d.ts +4 -2
- package/auth/token-managers/index.js +6 -3
- package/auth/token-managers/mcsp-token-manager.js +6 -1
- package/auth/token-managers/token-manager.js +7 -3
- package/auth/token-managers/vpc-instance-token-manager.js +4 -1
- package/auth/utils/get-authenticator-from-environment.js +3 -0
- package/auth/utils/helpers.d.ts +18 -23
- package/auth/utils/helpers.js +50 -30
- package/auth/utils/read-external-sources.js +2 -0
- package/docs/ibm-cloud-sdk-core.api.json +787 -404
- package/es/auth/authenticators/authenticator.d.ts +1 -0
- package/es/auth/authenticators/authenticator.js +1 -0
- package/es/auth/authenticators/basic-authenticator.d.ts +1 -1
- package/es/auth/authenticators/basic-authenticator.js +3 -1
- package/es/auth/authenticators/bearer-token-authenticator.js +2 -0
- package/es/auth/authenticators/container-authenticator.d.ts +6 -0
- package/es/auth/authenticators/container-authenticator.js +8 -0
- package/es/auth/authenticators/iam-assume-authenticator.d.ts +82 -0
- package/es/auth/authenticators/iam-assume-authenticator.js +70 -0
- package/es/auth/authenticators/iam-authenticator.d.ts +6 -0
- package/es/auth/authenticators/iam-authenticator.js +8 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.d.ts +64 -0
- package/es/auth/authenticators/iam-request-based-authenticator-immutable.js +51 -0
- package/es/auth/authenticators/iam-request-based-authenticator.d.ts +19 -47
- package/es/auth/authenticators/iam-request-based-authenticator.js +26 -35
- package/es/auth/authenticators/index.d.ts +4 -1
- package/es/auth/authenticators/index.js +1 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.d.ts +71 -0
- package/es/auth/authenticators/token-request-based-authenticator-immutable.js +65 -0
- package/es/auth/authenticators/token-request-based-authenticator.d.ts +4 -42
- package/es/auth/authenticators/token-request-based-authenticator.js +3 -37
- package/es/auth/token-managers/container-token-manager.d.ts +6 -0
- package/es/auth/token-managers/container-token-manager.js +18 -24
- package/es/auth/token-managers/cp4d-token-manager.js +6 -1
- package/es/auth/token-managers/iam-assume-token-manager.d.ts +101 -0
- package/es/auth/token-managers/iam-assume-token-manager.js +164 -0
- package/es/auth/token-managers/iam-request-based-token-manager.d.ts +3 -9
- package/es/auth/token-managers/iam-request-based-token-manager.js +5 -9
- package/es/auth/token-managers/iam-token-manager.d.ts +8 -2
- package/es/auth/token-managers/iam-token-manager.js +10 -2
- package/es/auth/token-managers/index.d.ts +4 -2
- package/es/auth/token-managers/index.js +4 -2
- package/es/auth/token-managers/mcsp-token-manager.js +6 -1
- package/es/auth/token-managers/token-manager.js +7 -3
- package/es/auth/token-managers/vpc-instance-token-manager.js +4 -1
- package/es/auth/utils/get-authenticator-from-environment.js +4 -1
- package/es/auth/utils/helpers.d.ts +18 -23
- package/es/auth/utils/helpers.js +35 -27
- package/es/auth/utils/read-external-sources.js +2 -0
- package/es/lib/base-service.js +2 -0
- package/es/lib/private-helpers.d.ts +22 -0
- package/es/lib/private-helpers.js +58 -0
- package/es/lib/request-wrapper.d.ts +43 -1
- package/es/lib/request-wrapper.js +113 -14
- package/etc/ibm-cloud-sdk-core.api.md +46 -28
- package/ibm-cloud-sdk-core.d.ts +306 -68
- package/lib/base-service.js +2 -0
- package/lib/private-helpers.d.ts +22 -0
- package/lib/private-helpers.js +62 -0
- package/lib/request-wrapper.d.ts +43 -1
- package/lib/request-wrapper.js +113 -14
- package/package.json +5 -4
- package/sdk-test-utilities/package-lock.json +8 -5
- package/sdk-test-utilities/package.json +3 -0
package/ibm-cloud-sdk-core.d.ts
CHANGED
|
@@ -7,24 +7,21 @@ import { OutgoingHttpHeaders } from 'http';
|
|
|
7
7
|
import { Stream } from 'stream';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Checks for at least one of
|
|
10
|
+
* Checks for at least one of the given elements being defined.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @
|
|
14
|
-
* @returns true if a or b is defined; false if both are undefined
|
|
12
|
+
* @param args - The spread of arguments to check
|
|
13
|
+
* @returns true if one or more are defined; false if all are undefined
|
|
15
14
|
*/
|
|
16
|
-
export declare function atLeastOne(
|
|
15
|
+
export declare function atLeastOne(...args: any): boolean;
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
* Verifies that
|
|
18
|
+
* Verifies that no more than one of the given elements are defined.
|
|
19
|
+
* Returns true if one or none are defined, and false otherwise.
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
*
|
|
24
|
-
* @returns false if a and b are both defined, true otherwise
|
|
25
|
-
|
|
21
|
+
* @param args - The spread of arguments to check
|
|
22
|
+
* @returns false if more than one elements are defined, true otherwise
|
|
26
23
|
*/
|
|
27
|
-
export declare function atMostOne(
|
|
24
|
+
export declare function atMostOne(...args: any): boolean;
|
|
28
25
|
|
|
29
26
|
/**
|
|
30
27
|
* The request object containing the headers property that
|
|
@@ -49,6 +46,7 @@ export declare class Authenticator implements AuthenticatorInterface {
|
|
|
49
46
|
static AUTHTYPE_BASIC: string;
|
|
50
47
|
static AUTHTYPE_BEARERTOKEN: string;
|
|
51
48
|
static AUTHTYPE_IAM: string;
|
|
49
|
+
static AUTHTYPE_IAM_ASSUME: string;
|
|
52
50
|
static AUTHTYPE_CONTAINER: string;
|
|
53
51
|
static AUTHTYPE_CP4D: string;
|
|
54
52
|
static AUTHTYPE_NOAUTH: string;
|
|
@@ -384,7 +382,7 @@ export declare class CloudPakForDataAuthenticator extends TokenRequestBasedAuthe
|
|
|
384
382
|
}
|
|
385
383
|
|
|
386
384
|
/**
|
|
387
|
-
* (C) Copyright IBM Corp. 2019,
|
|
385
|
+
* (C) Copyright IBM Corp. 2019, 2024.
|
|
388
386
|
*
|
|
389
387
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
390
388
|
* you may not use this file except in compliance with the License.
|
|
@@ -478,6 +476,12 @@ export declare class ContainerAuthenticator extends IamRequestBasedAuthenticator
|
|
|
478
476
|
* @returns a string that indicates the authenticator's type
|
|
479
477
|
*/
|
|
480
478
|
authenticationType(): string;
|
|
479
|
+
/**
|
|
480
|
+
* Return the most recently stored refresh token.
|
|
481
|
+
*
|
|
482
|
+
* @returns the refresh token string
|
|
483
|
+
*/
|
|
484
|
+
getRefreshToken(): string;
|
|
481
485
|
}
|
|
482
486
|
|
|
483
487
|
/**
|
|
@@ -525,6 +529,12 @@ export declare class ContainerTokenManager extends IamRequestBasedTokenManager {
|
|
|
525
529
|
* @param iamProfileId - the ID of the IAM trusted profile
|
|
526
530
|
*/
|
|
527
531
|
setIamProfileId(iamProfileId: string): void;
|
|
532
|
+
/**
|
|
533
|
+
* Returns the most recently stored refresh token.
|
|
534
|
+
*
|
|
535
|
+
* @returns the refresh token
|
|
536
|
+
*/
|
|
537
|
+
getRefreshToken(): string;
|
|
528
538
|
/**
|
|
529
539
|
* Request an IAM token using a compute resource token.
|
|
530
540
|
*/
|
|
@@ -687,6 +697,126 @@ export declare function getNewLogger(moduleName: string): SDKLogger;
|
|
|
687
697
|
*/
|
|
688
698
|
export declare function getQueryParam(urlStr: string, param: string): string;
|
|
689
699
|
|
|
700
|
+
/**
|
|
701
|
+
* The IamAssumeAuthenticator obtains an IAM access token using the IAM "get-token"
|
|
702
|
+
* operation's "assume" grant type. The authenticator obtains an initial IAM access
|
|
703
|
+
* token from a user-supplied apikey, then exchanges this initial IAM access token
|
|
704
|
+
* for another IAM access token that has "assumed the identity" of the specified
|
|
705
|
+
* trusted profile.
|
|
706
|
+
*
|
|
707
|
+
* The bearer token will be sent as an Authorization header in the form:
|
|
708
|
+
*
|
|
709
|
+
* Authorization: Bearer \<bearer-token\>
|
|
710
|
+
*/
|
|
711
|
+
export declare class IamAssumeAuthenticator extends IamRequestBasedAuthenticatorImmutable {
|
|
712
|
+
protected tokenManager: IamAssumeTokenManager;
|
|
713
|
+
/**
|
|
714
|
+
*
|
|
715
|
+
* Create a new IamAssumeAuthenticator instance.
|
|
716
|
+
*
|
|
717
|
+
* @param options - Configuration options for IAM authentication.
|
|
718
|
+
* This should be an object containing these fields:
|
|
719
|
+
* - apikey: (required) the IAM api key for initial token request
|
|
720
|
+
* - iamProfileId: (optional) the ID of the trusted profile to use
|
|
721
|
+
* - iamProfileCrn: (optional) the CRN of the trusted profile to use
|
|
722
|
+
* - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
|
|
723
|
+
* - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
|
|
724
|
+
* - url: (optional) the endpoint URL for the token service
|
|
725
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
726
|
+
* should be disabled or not
|
|
727
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
728
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
729
|
+
* Authorization header to be included in each request to the token service
|
|
730
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
731
|
+
* Authorization header to be included in each request to the token service
|
|
732
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
733
|
+
*
|
|
734
|
+
* @throws Error: the configuration options are not valid.
|
|
735
|
+
*/
|
|
736
|
+
constructor(options: Options_14);
|
|
737
|
+
/**
|
|
738
|
+
* Returns the authenticator's type ('iamAssume').
|
|
739
|
+
*
|
|
740
|
+
* @returns a string that indicates the authenticator's type
|
|
741
|
+
*/
|
|
742
|
+
authenticationType(): string;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* The IamAssumeTokenManager takes an api key, along with trusted profile information, and performs
|
|
747
|
+
* the necessary interactions with the IAM token service to obtain and store a suitable bearer token
|
|
748
|
+
* that "assumes" the identify of the trusted profile.
|
|
749
|
+
*/
|
|
750
|
+
export declare class IamAssumeTokenManager extends IamRequestBasedTokenManager {
|
|
751
|
+
protected requiredOptions: string[];
|
|
752
|
+
private iamProfileId;
|
|
753
|
+
private iamProfileCrn;
|
|
754
|
+
private iamProfileName;
|
|
755
|
+
private iamAccountId;
|
|
756
|
+
private iamDelegate;
|
|
757
|
+
/**
|
|
758
|
+
*
|
|
759
|
+
* Create a new IamAssumeTokenManager instance.
|
|
760
|
+
*
|
|
761
|
+
* @param options - Configuration options.
|
|
762
|
+
* This should be an object containing these fields:
|
|
763
|
+
* - apikey: (required) the IAM api key
|
|
764
|
+
* - iamProfileId: (optional) the ID of the trusted profile to use
|
|
765
|
+
* - iamProfileCrn: (optional) the CRN of the trusted profile to use
|
|
766
|
+
* - iamProfileName: (optional) the name of the trusted profile to use (must be specified with iamAccountId)
|
|
767
|
+
* - iamAccountId: (optional) the ID of the account the trusted profile is in (must be specified with iamProfileName)
|
|
768
|
+
* - url: (optional) the endpoint URL for the IAM token service (default value: "https://iam.cloud.ibm.com")
|
|
769
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
770
|
+
* should be disabled or not
|
|
771
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
772
|
+
* - clientId: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
773
|
+
* Authorization header to be included in each request to the token service
|
|
774
|
+
* - clientSecret: (optional) the "clientId" and "clientSecret" fields are used to form a Basic
|
|
775
|
+
* Authorization header to be included in each request to the token service
|
|
776
|
+
* - scope: (optional) the "scope" parameter to use when fetching the bearer token from the token service
|
|
777
|
+
*
|
|
778
|
+
* @throws Error: the configuration options are not valid.
|
|
779
|
+
*/
|
|
780
|
+
constructor(options: Options_13);
|
|
781
|
+
/**
|
|
782
|
+
* Request an IAM token using a standard access token and a trusted profile.
|
|
783
|
+
*/
|
|
784
|
+
protected requestToken(): Promise<any>;
|
|
785
|
+
/**
|
|
786
|
+
* Extend this method from the parent class to erase the refresh token from
|
|
787
|
+
* the class - we do not want to expose it for IAM Assume authentication.
|
|
788
|
+
*
|
|
789
|
+
* @param tokenResponse - the response object from JWT service request
|
|
790
|
+
*/
|
|
791
|
+
protected saveTokenInfo(tokenResponse: any): void;
|
|
792
|
+
/**
|
|
793
|
+
* Sets the IAM "scope" value.
|
|
794
|
+
* This value is sent as the "scope" form parameter in the IAM delegate request.
|
|
795
|
+
*
|
|
796
|
+
* @param scope - a space-separated string that contains one or more scope names
|
|
797
|
+
*/
|
|
798
|
+
setScope(scope: string): void;
|
|
799
|
+
/**
|
|
800
|
+
* Sets the IAM "clientId" and "clientSecret" values for the IAM delegate.
|
|
801
|
+
*
|
|
802
|
+
* @param clientId - the client id.
|
|
803
|
+
* @param clientSecret - the client secret.
|
|
804
|
+
*/
|
|
805
|
+
setClientIdAndSecret(clientId: string, clientSecret: string): void;
|
|
806
|
+
/**
|
|
807
|
+
* Sets the "disableSslVerification" property for the IAM delegate.
|
|
808
|
+
*
|
|
809
|
+
* @param value - the new value for the disableSslVerification property
|
|
810
|
+
*/
|
|
811
|
+
setDisableSslVerification(value: boolean): void;
|
|
812
|
+
/**
|
|
813
|
+
* Sets the headers to be included in the IAM delegate's requests.
|
|
814
|
+
*
|
|
815
|
+
* @param headers - the set of headers to send with each request to the token server
|
|
816
|
+
*/
|
|
817
|
+
setHeaders(headers: OutgoingHttpHeaders): void;
|
|
818
|
+
}
|
|
819
|
+
|
|
690
820
|
/**
|
|
691
821
|
* The IamAuthenticator will use the user-supplied `apikey`
|
|
692
822
|
* value to obtain a bearer token from a token server. When the bearer token
|
|
@@ -728,6 +858,12 @@ export declare class IamAuthenticator extends IamRequestBasedAuthenticator {
|
|
|
728
858
|
* @returns a string that indicates the authenticator's type
|
|
729
859
|
*/
|
|
730
860
|
authenticationType(): string;
|
|
861
|
+
/**
|
|
862
|
+
* Return the most recently stored refresh token.
|
|
863
|
+
*
|
|
864
|
+
* @returns the refresh token string
|
|
865
|
+
*/
|
|
866
|
+
getRefreshToken(): string;
|
|
731
867
|
}
|
|
732
868
|
|
|
733
869
|
/**
|
|
@@ -735,14 +871,49 @@ export declare class IamAuthenticator extends IamRequestBasedAuthenticator {
|
|
|
735
871
|
* for authenticators that interact with the IAM token service. This authenticator
|
|
736
872
|
* is not meant for use on its own.
|
|
737
873
|
*/
|
|
738
|
-
export declare class IamRequestBasedAuthenticator extends
|
|
874
|
+
export declare class IamRequestBasedAuthenticator extends IamRequestBasedAuthenticatorImmutable {
|
|
875
|
+
/**
|
|
876
|
+
* Setter for the mutually inclusive "clientId" and the "clientSecret" fields.
|
|
877
|
+
* @param clientId - the "clientId" value used to form a Basic Authorization header for IAM token requests
|
|
878
|
+
* @param clientSecret - the "clientSecret" value used to form a Basic Authorization header for IAM token requests
|
|
879
|
+
*/
|
|
880
|
+
setClientIdAndSecret(clientId: string, clientSecret: string): void;
|
|
881
|
+
/**
|
|
882
|
+
* Setter for the "scope" parameter to use when fetching the bearer token from the IAM token server.
|
|
883
|
+
* @param scope - (optional) a space-separated string that specifies one or more scopes to be
|
|
884
|
+
* associated with IAM token requests
|
|
885
|
+
*/
|
|
886
|
+
setScope(scope: string): void;
|
|
887
|
+
/**
|
|
888
|
+
* Set the flag that indicates whether verification of the server's SSL
|
|
889
|
+
* certificate should be disabled or not.
|
|
890
|
+
*
|
|
891
|
+
* @param value - a flag that indicates whether verification of the
|
|
892
|
+
* token server's SSL certificate should be disabled or not.
|
|
893
|
+
*/
|
|
894
|
+
setDisableSslVerification(value: boolean): void;
|
|
895
|
+
/**
|
|
896
|
+
* Set headers.
|
|
897
|
+
*
|
|
898
|
+
* @param headers - a set of HTTP headers to be sent with each outbound token server request.
|
|
899
|
+
* Overwrites previous default headers.
|
|
900
|
+
*/
|
|
901
|
+
setHeaders(headers: OutgoingHttpHeaders): void;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* The IamRequestBasedAuthenticatorImmutable provides shared configuration and functionality
|
|
906
|
+
* for authenticators that interact with the IAM token service. This authenticator
|
|
907
|
+
* is not meant for use on its own.
|
|
908
|
+
*/
|
|
909
|
+
declare class IamRequestBasedAuthenticatorImmutable extends TokenRequestBasedAuthenticatorImmutable {
|
|
739
910
|
protected tokenManager: IamRequestBasedTokenManager;
|
|
740
911
|
protected clientId: string;
|
|
741
912
|
protected clientSecret: string;
|
|
742
913
|
protected scope: string;
|
|
743
914
|
/**
|
|
744
915
|
*
|
|
745
|
-
* Create a new
|
|
916
|
+
* Create a new IamRequestBasedAuthenticatorImmutable instance.
|
|
746
917
|
*
|
|
747
918
|
* @param options - Configuration options for IAM authentication.
|
|
748
919
|
* This should be an object containing these fields:
|
|
@@ -759,24 +930,6 @@ export declare class IamRequestBasedAuthenticator extends TokenRequestBasedAuthe
|
|
|
759
930
|
* @throws Error: the configuration options are not valid.
|
|
760
931
|
*/
|
|
761
932
|
constructor(options: IamRequestOptions_2);
|
|
762
|
-
/**
|
|
763
|
-
* Setter for the mutually inclusive "clientId" and the "clientSecret" fields.
|
|
764
|
-
* @param clientId - the "clientId" value used to form a Basic Authorization header for IAM token requests
|
|
765
|
-
* @param clientSecret - the "clientSecret" value used to form a Basic Authorization header for IAM token requests
|
|
766
|
-
*/
|
|
767
|
-
setClientIdAndSecret(clientId: string, clientSecret: string): void;
|
|
768
|
-
/**
|
|
769
|
-
* Setter for the "scope" parameter to use when fetching the bearer token from the IAM token server.
|
|
770
|
-
* @param scope - (optional) a space-separated string that specifies one or more scopes to be
|
|
771
|
-
* associated with IAM token requests
|
|
772
|
-
*/
|
|
773
|
-
setScope(scope: string): void;
|
|
774
|
-
/**
|
|
775
|
-
* Return the most recently stored refresh token.
|
|
776
|
-
*
|
|
777
|
-
* @returns the refresh token string
|
|
778
|
-
*/
|
|
779
|
-
getRefreshToken(): string;
|
|
780
933
|
}
|
|
781
934
|
|
|
782
935
|
/**
|
|
@@ -787,9 +940,9 @@ export declare class IamRequestBasedAuthenticator extends TokenRequestBasedAuthe
|
|
|
787
940
|
* class be extended with specific implementations.
|
|
788
941
|
*/
|
|
789
942
|
export declare class IamRequestBasedTokenManager extends JwtTokenManager {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
943
|
+
protected clientId: string;
|
|
944
|
+
protected clientSecret: string;
|
|
945
|
+
protected scope: string;
|
|
793
946
|
protected refreshToken: string;
|
|
794
947
|
protected formData: any;
|
|
795
948
|
/**
|
|
@@ -829,12 +982,6 @@ export declare class IamRequestBasedTokenManager extends JwtTokenManager {
|
|
|
829
982
|
* @param clientSecret - the client secret.
|
|
830
983
|
*/
|
|
831
984
|
setClientIdAndSecret(clientId: string, clientSecret: string): void;
|
|
832
|
-
/**
|
|
833
|
-
* Returns the most recently stored refresh token.
|
|
834
|
-
*
|
|
835
|
-
* @returns the refresh token
|
|
836
|
-
*/
|
|
837
|
-
getRefreshToken(): string;
|
|
838
985
|
/**
|
|
839
986
|
* Extend this method from the parent class to extract the refresh token from
|
|
840
987
|
* the request and save it.
|
|
@@ -886,8 +1033,8 @@ declare interface IamRequestOptions_2 extends BaseOptions {
|
|
|
886
1033
|
}
|
|
887
1034
|
|
|
888
1035
|
/**
|
|
889
|
-
* The
|
|
890
|
-
* the IAM token service to obtain and store a suitable bearer token. Additionally, the
|
|
1036
|
+
* The IamTokenManager takes an api key and performs the necessary interactions with
|
|
1037
|
+
* the IAM token service to obtain and store a suitable bearer token. Additionally, the IamTokenManager
|
|
891
1038
|
* will retrieve bearer tokens via basic auth using a supplied "clientId" and "clientSecret" pair.
|
|
892
1039
|
*/
|
|
893
1040
|
export declare class IamTokenManager extends IamRequestBasedTokenManager {
|
|
@@ -913,6 +1060,12 @@ export declare class IamTokenManager extends IamRequestBasedTokenManager {
|
|
|
913
1060
|
* @throws Error: the configuration options are not valid.
|
|
914
1061
|
*/
|
|
915
1062
|
constructor(options: Options_5);
|
|
1063
|
+
/**
|
|
1064
|
+
* Returns the most recently stored refresh token.
|
|
1065
|
+
*
|
|
1066
|
+
* @returns the refresh token
|
|
1067
|
+
*/
|
|
1068
|
+
getRefreshToken(): string;
|
|
916
1069
|
}
|
|
917
1070
|
|
|
918
1071
|
export declare function isEmptyObject(obj: any): boolean;
|
|
@@ -1049,16 +1202,14 @@ export declare class NoAuthAuthenticator extends Authenticator {
|
|
|
1049
1202
|
}
|
|
1050
1203
|
|
|
1051
1204
|
/**
|
|
1052
|
-
* Checks
|
|
1053
|
-
* Returns true if
|
|
1054
|
-
*
|
|
1055
|
-
* or both are undefined.
|
|
1205
|
+
* Checks that exactly one of the arguments provided is defined.
|
|
1206
|
+
* Returns true if one argument is defined. Returns false if no
|
|
1207
|
+
* argument are defined or if 2 or more are defined.
|
|
1056
1208
|
*
|
|
1057
|
-
* @param
|
|
1058
|
-
* @
|
|
1059
|
-
* @returns true if and only if exactly one of a or b is defined
|
|
1209
|
+
* @param args - The spread of arguments to check
|
|
1210
|
+
* @returns true if and only if exactly one argument is defined
|
|
1060
1211
|
*/
|
|
1061
|
-
export declare function onlyOne(
|
|
1212
|
+
export declare function onlyOne(...args: any): boolean;
|
|
1062
1213
|
|
|
1063
1214
|
/** Configuration options for basic authentication. */
|
|
1064
1215
|
declare type Options = {
|
|
@@ -1094,6 +1245,37 @@ declare interface Options_12 extends BaseOptions {
|
|
|
1094
1245
|
url: string;
|
|
1095
1246
|
}
|
|
1096
1247
|
|
|
1248
|
+
/** Configuration options for IAM Assume token retrieval. */
|
|
1249
|
+
declare interface Options_13 extends IamRequestOptions {
|
|
1250
|
+
apikey: string;
|
|
1251
|
+
iamProfileId?: string;
|
|
1252
|
+
iamProfileCrn?: string;
|
|
1253
|
+
iamProfileName?: string;
|
|
1254
|
+
iamAccountId?: string;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/** Configuration options for IAM Assume authentication. */
|
|
1258
|
+
declare interface Options_14 extends IamRequestOptions_2 {
|
|
1259
|
+
/** The IAM api key */
|
|
1260
|
+
apikey: string;
|
|
1261
|
+
/**
|
|
1262
|
+
* Specify exactly one of [iamProfileId, iamProfileCrn, or iamProfileName] to
|
|
1263
|
+
* identify the trusted profile whose identity should be used. If iamProfileId
|
|
1264
|
+
* or iamProfileCrn is used, the trusted profile must exist in the same account.
|
|
1265
|
+
* If and only if iamProfileName is used, then iamAccountId must also be
|
|
1266
|
+
* specified to indicate the account that contains the trusted profile.
|
|
1267
|
+
*/
|
|
1268
|
+
iamProfileId?: string;
|
|
1269
|
+
iamProfileCrn?: string;
|
|
1270
|
+
iamProfileName?: string;
|
|
1271
|
+
/**
|
|
1272
|
+
* If and only if iamProfileName is used to specify the trusted profile, then
|
|
1273
|
+
* iamAccountId must also be specified to indicate the account that contains
|
|
1274
|
+
* the trusted profile.
|
|
1275
|
+
*/
|
|
1276
|
+
iamAccountId?: string;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1097
1279
|
/** Configuration options for bearer authentication. */
|
|
1098
1280
|
declare type Options_2 = {
|
|
1099
1281
|
/** The bearer token to be added to requests. */
|
|
@@ -1230,6 +1412,42 @@ declare class RequestWrapper {
|
|
|
1230
1412
|
private retryInterceptorId;
|
|
1231
1413
|
private raxConfig;
|
|
1232
1414
|
constructor(axiosOptions?: any);
|
|
1415
|
+
/**
|
|
1416
|
+
* Formats the specified Axios request for debug logging.
|
|
1417
|
+
* @param request - the request to be logged
|
|
1418
|
+
* @returns the string representation of the request
|
|
1419
|
+
*/
|
|
1420
|
+
private formatAxiosRequest;
|
|
1421
|
+
/**
|
|
1422
|
+
* Formats the specified Axios response for debug logging.
|
|
1423
|
+
* @param response - the response to be logged
|
|
1424
|
+
* @returns the string representation of the response
|
|
1425
|
+
*/
|
|
1426
|
+
private formatAxiosResponse;
|
|
1427
|
+
/**
|
|
1428
|
+
* Formats the specified Axios error for debug logging.
|
|
1429
|
+
* @param error - the error to be logged
|
|
1430
|
+
* @returns the string representation of the error
|
|
1431
|
+
*/
|
|
1432
|
+
private formatAxiosError;
|
|
1433
|
+
/**
|
|
1434
|
+
* Formats 'headers' to be included in the debug output
|
|
1435
|
+
* like this:
|
|
1436
|
+
* Accept: application/json
|
|
1437
|
+
* Content-Type: application/json
|
|
1438
|
+
* My-Header: my-value
|
|
1439
|
+
* ...
|
|
1440
|
+
* @param headers - the headers associated with an Axios request or response
|
|
1441
|
+
* @returns the formatted output to be included in the HTTP message traces
|
|
1442
|
+
*/
|
|
1443
|
+
private formatAxiosHeaders;
|
|
1444
|
+
/**
|
|
1445
|
+
* Formats 'body' (either a string or object/array) to be included in the debug output
|
|
1446
|
+
*
|
|
1447
|
+
* @param body - a string, object or array that contains the request or response body
|
|
1448
|
+
* @returns the formatted output to be included in the HTTP message traces
|
|
1449
|
+
*/
|
|
1450
|
+
private formatAxiosBody;
|
|
1233
1451
|
setCompressRequestData(setting: boolean): void;
|
|
1234
1452
|
/**
|
|
1235
1453
|
* Creates the request.
|
|
@@ -1251,6 +1469,12 @@ declare class RequestWrapper {
|
|
|
1251
1469
|
private static getRaxConfig;
|
|
1252
1470
|
enableRetries(retryOptions?: RetryOptions): void;
|
|
1253
1471
|
disableRetries(): void;
|
|
1472
|
+
/**
|
|
1473
|
+
* Returns true iff the previously-failed request contained in "error" should be retried.
|
|
1474
|
+
* @param error - an AxiosError instance that contains a previously-failed request
|
|
1475
|
+
* @returns true iff the request should be retried
|
|
1476
|
+
*/
|
|
1477
|
+
private static retryPolicy;
|
|
1254
1478
|
private gzipRequestBody;
|
|
1255
1479
|
}
|
|
1256
1480
|
|
|
@@ -1404,22 +1628,7 @@ export declare type TokenManagerOptions = {
|
|
|
1404
1628
|
*
|
|
1405
1629
|
* Authorization: Bearer \<bearer-token\>
|
|
1406
1630
|
*/
|
|
1407
|
-
export declare class TokenRequestBasedAuthenticator extends
|
|
1408
|
-
protected tokenManager: JwtTokenManager;
|
|
1409
|
-
protected url: string;
|
|
1410
|
-
protected headers: OutgoingHttpHeaders;
|
|
1411
|
-
protected disableSslVerification: boolean;
|
|
1412
|
-
/**
|
|
1413
|
-
* Create a new TokenRequestBasedAuthenticator instance with an internal JwtTokenManager.
|
|
1414
|
-
*
|
|
1415
|
-
* @param options - Configuration options.
|
|
1416
|
-
* This should be an object containing these fields:
|
|
1417
|
-
* - url: (optional) the endpoint URL for the token service
|
|
1418
|
-
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
1419
|
-
* should be disabled or not
|
|
1420
|
-
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
1421
|
-
*/
|
|
1422
|
-
constructor(options: BaseOptions);
|
|
1631
|
+
export declare class TokenRequestBasedAuthenticator extends TokenRequestBasedAuthenticatorImmutable {
|
|
1423
1632
|
/**
|
|
1424
1633
|
* Set the flag that indicates whether verification of the server's SSL
|
|
1425
1634
|
* certificate should be disabled or not.
|
|
@@ -1435,6 +1644,35 @@ export declare class TokenRequestBasedAuthenticator extends Authenticator {
|
|
|
1435
1644
|
* Overwrites previous default headers.
|
|
1436
1645
|
*/
|
|
1437
1646
|
setHeaders(headers: OutgoingHttpHeaders): void;
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
/**
|
|
1650
|
+
* Class for common functionality shared by token-request authenticators.
|
|
1651
|
+
* Token-request authenticators use token managers to retrieve, store,
|
|
1652
|
+
* and refresh tokens. Not intended to be used as stand-alone authenticator,
|
|
1653
|
+
* but as base class to authenticators that have their own token manager
|
|
1654
|
+
* implementations.
|
|
1655
|
+
*
|
|
1656
|
+
* The token will be added as an Authorization header in the form:
|
|
1657
|
+
*
|
|
1658
|
+
* Authorization: Bearer \<bearer-token\>
|
|
1659
|
+
*/
|
|
1660
|
+
declare class TokenRequestBasedAuthenticatorImmutable extends Authenticator {
|
|
1661
|
+
protected tokenManager: JwtTokenManager;
|
|
1662
|
+
protected url: string;
|
|
1663
|
+
protected headers: OutgoingHttpHeaders;
|
|
1664
|
+
protected disableSslVerification: boolean;
|
|
1665
|
+
/**
|
|
1666
|
+
* Create a new TokenRequestBasedAuthenticatorImmutable instance with an internal JwtTokenManager.
|
|
1667
|
+
*
|
|
1668
|
+
* @param options - Configuration options.
|
|
1669
|
+
* This should be an object containing these fields:
|
|
1670
|
+
* - url: (optional) the endpoint URL for the token service
|
|
1671
|
+
* - disableSslVerification: (optional) a flag that indicates whether verification of the token server's SSL certificate
|
|
1672
|
+
* should be disabled or not
|
|
1673
|
+
* - headers: (optional) a set of HTTP headers to be sent with each request to the token service
|
|
1674
|
+
*/
|
|
1675
|
+
constructor(options: BaseOptions);
|
|
1438
1676
|
/**
|
|
1439
1677
|
* Adds bearer token information to "requestOptions". The bearer token information
|
|
1440
1678
|
* will be set in the Authorization property of "requestOptions.headers" in the form:
|
package/lib/base-service.js
CHANGED
|
@@ -107,6 +107,7 @@ var BaseService = /** @class */ (function () {
|
|
|
107
107
|
BaseService.prototype.setServiceUrl = function (url) {
|
|
108
108
|
if (url) {
|
|
109
109
|
this.baseOptions.serviceUrl = (0, helper_1.stripTrailingSlash)(url);
|
|
110
|
+
logger_1.default.debug("Set service URL: ".concat(this.baseOptions.serviceUrl));
|
|
110
111
|
}
|
|
111
112
|
};
|
|
112
113
|
/**
|
|
@@ -181,6 +182,7 @@ var BaseService = /** @class */ (function () {
|
|
|
181
182
|
* configuration.
|
|
182
183
|
*/
|
|
183
184
|
BaseService.prototype.configureService = function (serviceName) {
|
|
185
|
+
logger_1.default.debug("Configuring BaseService instance with service name: ".concat(serviceName));
|
|
184
186
|
if (!serviceName) {
|
|
185
187
|
var err = 'Error configuring service. Service name is required.';
|
|
186
188
|
logger_1.default.error(err);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (C) Copyright IBM Corp. 2024.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Redacts secrets found in "input" so that the resulting string
|
|
18
|
+
* is suitable for debug logging.
|
|
19
|
+
* @param input - the string that potentially contains secrets
|
|
20
|
+
* @returns the input string with secrets replaced with "[redacted]"
|
|
21
|
+
*/
|
|
22
|
+
export declare function redactSecrets(input: string): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* (C) Copyright IBM Corp. 2024.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.redactSecrets = void 0;
|
|
19
|
+
// Keywords that should be redacted.
|
|
20
|
+
var redactedKeywords = [
|
|
21
|
+
'apikey',
|
|
22
|
+
'api_key',
|
|
23
|
+
'passcode',
|
|
24
|
+
'password',
|
|
25
|
+
'token',
|
|
26
|
+
'aadClientId',
|
|
27
|
+
'aadClientSecret',
|
|
28
|
+
'auth',
|
|
29
|
+
'auth_provider_x509_cert_url',
|
|
30
|
+
'auth_uri',
|
|
31
|
+
'client_email',
|
|
32
|
+
'client_id',
|
|
33
|
+
'client_x509_cert_url',
|
|
34
|
+
'key',
|
|
35
|
+
'project_id',
|
|
36
|
+
'secret',
|
|
37
|
+
'subscriptionId',
|
|
38
|
+
'tenantId',
|
|
39
|
+
'thumbprint',
|
|
40
|
+
'token_uri',
|
|
41
|
+
];
|
|
42
|
+
var redactedTokens = redactedKeywords.join('|');
|
|
43
|
+
// Pre-compiled regular expressions used by redactSecrets().
|
|
44
|
+
var reAuthHeader = new RegExp("^(Authorization|X-Auth\\S*): .*$", 'gim');
|
|
45
|
+
var rePropertySetting = new RegExp("(".concat(redactedTokens, ")=[^&]*(&|$)"), 'gi');
|
|
46
|
+
var reJsonField = new RegExp("\"([^\"]*(".concat(redactedTokens, ")[^\"_]*)\":\\s*\"[^\\,]*\""), 'gi');
|
|
47
|
+
// RedactSecrets() returns the input string with secrets redacted.
|
|
48
|
+
/**
|
|
49
|
+
* Redacts secrets found in "input" so that the resulting string
|
|
50
|
+
* is suitable for debug logging.
|
|
51
|
+
* @param input - the string that potentially contains secrets
|
|
52
|
+
* @returns the input string with secrets replaced with "[redacted]"
|
|
53
|
+
*/
|
|
54
|
+
function redactSecrets(input) {
|
|
55
|
+
var redacted = '[redacted]';
|
|
56
|
+
var redactedString = input;
|
|
57
|
+
redactedString = redactedString.replace(reAuthHeader, "$1: ".concat(redacted));
|
|
58
|
+
redactedString = redactedString.replace(rePropertySetting, "$1=".concat(redacted, "$2"));
|
|
59
|
+
redactedString = redactedString.replace(reJsonField, "\"$1\":\"".concat(redacted, "\""));
|
|
60
|
+
return redactedString;
|
|
61
|
+
}
|
|
62
|
+
exports.redactSecrets = redactSecrets;
|
package/lib/request-wrapper.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* (C) Copyright IBM Corp. 2014,
|
|
2
|
+
* (C) Copyright IBM Corp. 2014, 2024.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -33,6 +33,42 @@ export declare class RequestWrapper {
|
|
|
33
33
|
private retryInterceptorId;
|
|
34
34
|
private raxConfig;
|
|
35
35
|
constructor(axiosOptions?: any);
|
|
36
|
+
/**
|
|
37
|
+
* Formats the specified Axios request for debug logging.
|
|
38
|
+
* @param request - the request to be logged
|
|
39
|
+
* @returns the string representation of the request
|
|
40
|
+
*/
|
|
41
|
+
private formatAxiosRequest;
|
|
42
|
+
/**
|
|
43
|
+
* Formats the specified Axios response for debug logging.
|
|
44
|
+
* @param response - the response to be logged
|
|
45
|
+
* @returns the string representation of the response
|
|
46
|
+
*/
|
|
47
|
+
private formatAxiosResponse;
|
|
48
|
+
/**
|
|
49
|
+
* Formats the specified Axios error for debug logging.
|
|
50
|
+
* @param error - the error to be logged
|
|
51
|
+
* @returns the string representation of the error
|
|
52
|
+
*/
|
|
53
|
+
private formatAxiosError;
|
|
54
|
+
/**
|
|
55
|
+
* Formats 'headers' to be included in the debug output
|
|
56
|
+
* like this:
|
|
57
|
+
* Accept: application/json
|
|
58
|
+
* Content-Type: application/json
|
|
59
|
+
* My-Header: my-value
|
|
60
|
+
* ...
|
|
61
|
+
* @param headers - the headers associated with an Axios request or response
|
|
62
|
+
* @returns the formatted output to be included in the HTTP message traces
|
|
63
|
+
*/
|
|
64
|
+
private formatAxiosHeaders;
|
|
65
|
+
/**
|
|
66
|
+
* Formats 'body' (either a string or object/array) to be included in the debug output
|
|
67
|
+
*
|
|
68
|
+
* @param body - a string, object or array that contains the request or response body
|
|
69
|
+
* @returns the formatted output to be included in the HTTP message traces
|
|
70
|
+
*/
|
|
71
|
+
private formatAxiosBody;
|
|
36
72
|
setCompressRequestData(setting: boolean): void;
|
|
37
73
|
/**
|
|
38
74
|
* Creates the request.
|
|
@@ -54,5 +90,11 @@ export declare class RequestWrapper {
|
|
|
54
90
|
private static getRaxConfig;
|
|
55
91
|
enableRetries(retryOptions?: RetryOptions): void;
|
|
56
92
|
disableRetries(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Returns true iff the previously-failed request contained in "error" should be retried.
|
|
95
|
+
* @param error - an AxiosError instance that contains a previously-failed request
|
|
96
|
+
* @returns true iff the request should be retried
|
|
97
|
+
*/
|
|
98
|
+
private static retryPolicy;
|
|
57
99
|
private gzipRequestBody;
|
|
58
100
|
}
|