ibm-cloud-sdk-core 5.4.22 → 5.6.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.
@@ -21,6 +21,12 @@ export interface Options extends BaseOptions {
21
21
  iamProfileCrn?: string;
22
22
  /** The ID of the linked trusted IAM profile to be used when obtaining the IAM access token */
23
23
  iamProfileId?: string;
24
+ /** The name of the linked trusted IAM profile to be used when obtaining the IAM access token */
25
+ iamProfileName?: string;
26
+ /** The version of the Instance Metadata Service to be used obtaining tokens */
27
+ serviceVersion?: string;
28
+ /** The lifetime of the Instance Identity Token */
29
+ tokenLifetime?: number;
24
30
  }
25
31
  /**
26
32
  * The VpcInstanceAuthenticator implements an authentication scheme in which it retrieves an "instance identity token"
@@ -36,6 +42,9 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
36
42
  protected tokenManager: VpcInstanceTokenManager;
37
43
  private iamProfileCrn;
38
44
  private iamProfileId;
45
+ private iamProfileName;
46
+ private serviceVersion;
47
+ private tokenLifetime;
39
48
  /**
40
49
  * Create a new VpcInstanceAuthenticator instance.
41
50
  *
@@ -44,9 +53,10 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
44
53
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
45
54
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
46
55
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
56
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
47
57
  *
48
58
  * @remarks
49
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
59
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
50
60
  * then the default IAM profile defined for the compute resource will be used.
51
61
  */
52
62
  constructor(options: Options);
@@ -60,6 +70,13 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
60
70
  * @param iamProfileId - the ID of the linked IAM trusted profile to use when obtaining an IAM access token
61
71
  */
62
72
  setIamProfileId(iamProfileId: string): void;
73
+ /**
74
+ * Sets the "iamProfileName" value to be used when obtaining an IAM access token
75
+ * @param iamProfileName - the name of the linked IAM trusted profile to use when obtaining an IAM access token
76
+ */
77
+ setIamProfileName(iamProfileName: string): void;
78
+ setServiceVersion(serviceVersion: string): void;
79
+ setTokenLifetime(tokenLifetime: number): void;
63
80
  /**
64
81
  * Returns the authenticator's type ('vpc').
65
82
  *
@@ -54,9 +54,10 @@ var VpcInstanceAuthenticator = /** @class */ (function (_super) {
54
54
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
55
55
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
56
56
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
57
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
57
58
  *
58
59
  * @remarks
59
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
60
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
60
61
  * then the default IAM profile defined for the compute resource will be used.
61
62
  */
62
63
  function VpcInstanceAuthenticator(options) {
@@ -70,6 +71,15 @@ var VpcInstanceAuthenticator = /** @class */ (function (_super) {
70
71
  if (options.iamProfileId) {
71
72
  _this.iamProfileId = options.iamProfileId;
72
73
  }
74
+ if (options.iamProfileName) {
75
+ _this.iamProfileName = options.iamProfileName;
76
+ }
77
+ if (options.serviceVersion) {
78
+ _this.serviceVersion = options.serviceVersion;
79
+ }
80
+ if (options.tokenLifetime) {
81
+ _this.tokenLifetime = options.tokenLifetime;
82
+ }
73
83
  // the param names are shared between the authenticator and the token
74
84
  // manager so we can just pass along the options object.
75
85
  // also, the token manager will handle input validation
@@ -94,6 +104,23 @@ var VpcInstanceAuthenticator = /** @class */ (function (_super) {
94
104
  // update properties in token manager
95
105
  this.tokenManager.setIamProfileId(iamProfileId);
96
106
  };
107
+ /**
108
+ * Sets the "iamProfileName" value to be used when obtaining an IAM access token
109
+ * @param iamProfileName - the name of the linked IAM trusted profile to use when obtaining an IAM access token
110
+ */
111
+ VpcInstanceAuthenticator.prototype.setIamProfileName = function (iamProfileName) {
112
+ this.iamProfileName = iamProfileName;
113
+ // update properties in token manager
114
+ this.tokenManager.setIamProfileName(iamProfileName);
115
+ };
116
+ VpcInstanceAuthenticator.prototype.setServiceVersion = function (serviceVersion) {
117
+ this.serviceVersion = serviceVersion;
118
+ this.tokenManager.setServiceVersion(serviceVersion);
119
+ };
120
+ VpcInstanceAuthenticator.prototype.setTokenLifetime = function (tokenLifetime) {
121
+ this.tokenLifetime = tokenLifetime;
122
+ this.tokenManager.setTokenLifetime(tokenLifetime);
123
+ };
97
124
  /**
98
125
  * Returns the authenticator's type ('vpc').
99
126
  *
@@ -20,6 +20,12 @@ interface Options extends JwtTokenManagerOptions {
20
20
  iamProfileCrn?: string;
21
21
  /** The ID of the linked trusted IAM profile to be used when obtaining the IAM access token */
22
22
  iamProfileId?: string;
23
+ /** The name of the linked trusted IAM profile to be used when obtaining the IAM access token */
24
+ iamProfileName?: string;
25
+ /** The version of the Instance Metadata Service to be used obtaining tokens */
26
+ serviceVersion?: string;
27
+ /** The lifetime of the Instance Identity Token */
28
+ tokenLifetime?: number;
23
29
  }
24
30
  /**
25
31
  * Token Manager for VPC Instance Authentication.
@@ -27,6 +33,9 @@ interface Options extends JwtTokenManagerOptions {
27
33
  export declare class VpcInstanceTokenManager extends JwtTokenManager {
28
34
  private iamProfileCrn;
29
35
  private iamProfileId;
36
+ private iamProfileName;
37
+ private serviceVersion;
38
+ private tokenLifetime;
30
39
  /**
31
40
  * Create a new VpcInstanceTokenManager instance.
32
41
  *
@@ -35,9 +44,10 @@ export declare class VpcInstanceTokenManager extends JwtTokenManager {
35
44
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
36
45
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
37
46
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
47
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
38
48
  *
39
49
  * @remarks
40
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
50
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
41
51
  * then the default IAM profile defined for the compute resource will be used.
42
52
  */
43
53
  constructor(options: Options);
@@ -51,6 +61,15 @@ export declare class VpcInstanceTokenManager extends JwtTokenManager {
51
61
  * @param iamProfileId - the ID of the IAM trusted profile
52
62
  */
53
63
  setIamProfileId(iamProfileId: string): void;
64
+ /**
65
+ * Sets the name of the IAM trusted profile to use when fetching access token from the IAM token server.
66
+ * @param iamProfileName - the name of the IAM trusted profile
67
+ */
68
+ setIamProfileName(iamProfileName: string): void;
69
+ setServiceVersion(serviceVersion: string): void;
70
+ setTokenLifetime(tokenLifetime: number): void;
71
+ protected getAccessTokenPath(): string;
72
+ protected getIamTokenPath(): string;
54
73
  protected requestToken(): Promise<any>;
55
74
  private getInstanceIdentityToken;
56
75
  /**
@@ -76,7 +76,14 @@ var build_user_agent_1 = require("../../lib/build-user-agent");
76
76
  var jwt_token_manager_1 = require("./jwt-token-manager");
77
77
  var DEFAULT_IMS_ENDPOINT = 'http://169.254.169.254';
78
78
  var METADATA_SERVICE_VERSION = '2022-03-01';
79
+ var METADATA_SERVICE_VERSION2 = '2025-08-26';
79
80
  var IAM_EXPIRATION_WINDOW = 10;
81
+ var METADATA_TOKEN_LIFETIME = 300;
82
+ var DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN = '/instance_identity/v1/token';
83
+ var DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN = '/instance_identity/v1/iam_token';
84
+ var DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN2 = '/identity/v1/token';
85
+ var DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN2 = '/identity/v1/iam_tokens';
86
+ var metadataServiceSupportedVersions = [METADATA_SERVICE_VERSION, METADATA_SERVICE_VERSION2];
80
87
  /**
81
88
  * Token Manager for VPC Instance Authentication.
82
89
  */
@@ -90,9 +97,10 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
90
97
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
91
98
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
92
99
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
100
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
93
101
  *
94
102
  * @remarks
95
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
103
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
96
104
  * then the default IAM profile defined for the compute resource will be used.
97
105
  */
98
106
  function VpcInstanceTokenManager(options) {
@@ -100,16 +108,31 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
100
108
  // all parameters are optional
101
109
  options = options || {};
102
110
  _this = _super.call(this, options) || this;
103
- if (!(0, helpers_1.atMostOne)(options.iamProfileId, options.iamProfileCrn)) {
104
- throw new Error('At most one of `iamProfileId` or `iamProfileCrn` may be specified.');
111
+ if (!(0, helpers_1.atMostOne)(options.iamProfileId, options.iamProfileCrn, options.iamProfileName)) {
112
+ throw new Error('At most one of `iamProfileId`, `iamProfileCrn` or `iamProfileName` may be specified.');
105
113
  }
106
114
  _this.url = options.url || DEFAULT_IMS_ENDPOINT;
115
+ // Validate and set serviceVersion
116
+ var serviceVersion = options.serviceVersion || METADATA_SERVICE_VERSION;
117
+ if (!metadataServiceSupportedVersions.includes(serviceVersion)) {
118
+ throw new Error("Invalid serviceVersion. Must be one of: ".concat(metadataServiceSupportedVersions.join(', ')));
119
+ }
120
+ _this.serviceVersion = serviceVersion;
121
+ // Validate and set tokenLifetime
122
+ var tokenLifetime = options.tokenLifetime || METADATA_TOKEN_LIFETIME;
123
+ if (typeof tokenLifetime !== 'number' || tokenLifetime < 0) {
124
+ throw new Error('tokenLifetime must be a non-negative number');
125
+ }
126
+ _this.tokenLifetime = tokenLifetime;
107
127
  if (options.iamProfileCrn) {
108
128
  _this.iamProfileCrn = options.iamProfileCrn;
109
129
  }
110
130
  if (options.iamProfileId) {
111
131
  _this.iamProfileId = options.iamProfileId;
112
132
  }
133
+ if (options.iamProfileName) {
134
+ _this.iamProfileName = options.iamProfileName;
135
+ }
113
136
  _this.userAgent = (0, build_user_agent_1.buildUserAgent)('vpc-instance-authenticator');
114
137
  return _this;
115
138
  }
@@ -127,6 +150,37 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
127
150
  VpcInstanceTokenManager.prototype.setIamProfileId = function (iamProfileId) {
128
151
  this.iamProfileId = iamProfileId;
129
152
  };
153
+ /**
154
+ * Sets the name of the IAM trusted profile to use when fetching access token from the IAM token server.
155
+ * @param iamProfileName - the name of the IAM trusted profile
156
+ */
157
+ VpcInstanceTokenManager.prototype.setIamProfileName = function (iamProfileName) {
158
+ this.iamProfileName = iamProfileName;
159
+ };
160
+ VpcInstanceTokenManager.prototype.setServiceVersion = function (serviceVersion) {
161
+ if (!metadataServiceSupportedVersions.includes(serviceVersion)) {
162
+ throw new Error("Invalid serviceVersion. Must be one of: ".concat(metadataServiceSupportedVersions.join(', ')));
163
+ }
164
+ this.serviceVersion = serviceVersion;
165
+ };
166
+ VpcInstanceTokenManager.prototype.setTokenLifetime = function (tokenLifetime) {
167
+ if (typeof tokenLifetime !== 'number' || tokenLifetime < 0) {
168
+ throw new Error('tokenLifetime must be a non-negative number');
169
+ }
170
+ this.tokenLifetime = tokenLifetime;
171
+ };
172
+ VpcInstanceTokenManager.prototype.getAccessTokenPath = function () {
173
+ if (this.serviceVersion === METADATA_SERVICE_VERSION2) {
174
+ return DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN2;
175
+ }
176
+ return DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN;
177
+ };
178
+ VpcInstanceTokenManager.prototype.getIamTokenPath = function () {
179
+ if (this.serviceVersion === METADATA_SERVICE_VERSION2) {
180
+ return DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN2;
181
+ }
182
+ return DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN;
183
+ };
130
184
  VpcInstanceTokenManager.prototype.requestToken = function () {
131
185
  return __awaiter(this, void 0, void 0, function () {
132
186
  var instanceIdentityToken, body, parameters;
@@ -145,11 +199,16 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
145
199
  trusted_profile: { crn: this.iamProfileCrn },
146
200
  };
147
201
  }
202
+ else if (this.iamProfileName) {
203
+ body = {
204
+ trusted_profile: { name: this.iamProfileName },
205
+ };
206
+ }
148
207
  parameters = {
149
208
  options: {
150
- url: "".concat(this.url, "/instance_identity/v1/iam_token"),
209
+ url: "".concat(this.url).concat(this.getIamTokenPath()),
151
210
  qs: {
152
- version: METADATA_SERVICE_VERSION,
211
+ version: this.serviceVersion,
153
212
  },
154
213
  body: body,
155
214
  method: 'POST',
@@ -158,6 +217,7 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
158
217
  'User-Agent': this.userAgent,
159
218
  Accept: 'application/json',
160
219
  Authorization: "Bearer ".concat(instanceIdentityToken),
220
+ 'Metadata-Flavor': 'ibm',
161
221
  },
162
222
  },
163
223
  };
@@ -178,12 +238,12 @@ var VpcInstanceTokenManager = /** @class */ (function (_super) {
178
238
  case 0:
179
239
  parameters = {
180
240
  options: {
181
- url: "".concat(this.url, "/instance_identity/v1/token"),
241
+ url: "".concat(this.url).concat(this.getAccessTokenPath()),
182
242
  qs: {
183
- version: METADATA_SERVICE_VERSION,
243
+ version: this.serviceVersion,
184
244
  },
185
245
  body: {
186
- expires_in: 300,
246
+ expires_in: this.tokenLifetime,
187
247
  },
188
248
  method: 'PUT',
189
249
  headers: {
@@ -8521,7 +8521,7 @@
8521
8521
  {
8522
8522
  "kind": "Constructor",
8523
8523
  "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceAuthenticator:constructor(1)",
8524
- "docComment": "/**\n * Create a new VpcInstanceAuthenticator instance.\n *\n * @remarks\n *\n * At most one of \"iamProfileCrn\" or \"iamProfileId\" may be specified. If neither one is specified, then the default IAM profile defined for the compute resource will be used.\n *\n * @param options - Configuration options for VpcInstance authentication. This should be an object containing these fields: - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: \"http://169.254.169.254\") - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token\n */\n",
8524
+ "docComment": "/**\n * Create a new VpcInstanceAuthenticator instance.\n *\n * @remarks\n *\n * At most one of \"iamProfileCrn\", \"iamProfileId\" or \"iamProfileName\" may be specified. If neither one is specified, then the default IAM profile defined for the compute resource will be used.\n *\n * @param options - Configuration options for VpcInstance authentication. This should be an object containing these fields: - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: \"http://169.254.169.254\") - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token\n */\n",
8525
8525
  "excerptTokens": [
8526
8526
  {
8527
8527
  "kind": "Content",
@@ -8678,6 +8678,150 @@
8678
8678
  "isAbstract": false,
8679
8679
  "name": "setIamProfileId"
8680
8680
  },
8681
+ {
8682
+ "kind": "Method",
8683
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceAuthenticator#setIamProfileName:member(1)",
8684
+ "docComment": "/**\n * Sets the \"iamProfileName\" value to be used when obtaining an IAM access token\n *\n * @param iamProfileName - the name of the linked IAM trusted profile to use when obtaining an IAM access token\n */\n",
8685
+ "excerptTokens": [
8686
+ {
8687
+ "kind": "Content",
8688
+ "text": "setIamProfileName(iamProfileName: "
8689
+ },
8690
+ {
8691
+ "kind": "Content",
8692
+ "text": "string"
8693
+ },
8694
+ {
8695
+ "kind": "Content",
8696
+ "text": "): "
8697
+ },
8698
+ {
8699
+ "kind": "Content",
8700
+ "text": "void"
8701
+ },
8702
+ {
8703
+ "kind": "Content",
8704
+ "text": ";"
8705
+ }
8706
+ ],
8707
+ "isStatic": false,
8708
+ "returnTypeTokenRange": {
8709
+ "startIndex": 3,
8710
+ "endIndex": 4
8711
+ },
8712
+ "releaseTag": "Public",
8713
+ "isProtected": false,
8714
+ "overloadIndex": 1,
8715
+ "parameters": [
8716
+ {
8717
+ "parameterName": "iamProfileName",
8718
+ "parameterTypeTokenRange": {
8719
+ "startIndex": 1,
8720
+ "endIndex": 2
8721
+ },
8722
+ "isOptional": false
8723
+ }
8724
+ ],
8725
+ "isOptional": false,
8726
+ "isAbstract": false,
8727
+ "name": "setIamProfileName"
8728
+ },
8729
+ {
8730
+ "kind": "Method",
8731
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceAuthenticator#setServiceVersion:member(1)",
8732
+ "docComment": "",
8733
+ "excerptTokens": [
8734
+ {
8735
+ "kind": "Content",
8736
+ "text": "setServiceVersion(serviceVersion: "
8737
+ },
8738
+ {
8739
+ "kind": "Content",
8740
+ "text": "string"
8741
+ },
8742
+ {
8743
+ "kind": "Content",
8744
+ "text": "): "
8745
+ },
8746
+ {
8747
+ "kind": "Content",
8748
+ "text": "void"
8749
+ },
8750
+ {
8751
+ "kind": "Content",
8752
+ "text": ";"
8753
+ }
8754
+ ],
8755
+ "isStatic": false,
8756
+ "returnTypeTokenRange": {
8757
+ "startIndex": 3,
8758
+ "endIndex": 4
8759
+ },
8760
+ "releaseTag": "Public",
8761
+ "isProtected": false,
8762
+ "overloadIndex": 1,
8763
+ "parameters": [
8764
+ {
8765
+ "parameterName": "serviceVersion",
8766
+ "parameterTypeTokenRange": {
8767
+ "startIndex": 1,
8768
+ "endIndex": 2
8769
+ },
8770
+ "isOptional": false
8771
+ }
8772
+ ],
8773
+ "isOptional": false,
8774
+ "isAbstract": false,
8775
+ "name": "setServiceVersion"
8776
+ },
8777
+ {
8778
+ "kind": "Method",
8779
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceAuthenticator#setTokenLifetime:member(1)",
8780
+ "docComment": "",
8781
+ "excerptTokens": [
8782
+ {
8783
+ "kind": "Content",
8784
+ "text": "setTokenLifetime(tokenLifetime: "
8785
+ },
8786
+ {
8787
+ "kind": "Content",
8788
+ "text": "number"
8789
+ },
8790
+ {
8791
+ "kind": "Content",
8792
+ "text": "): "
8793
+ },
8794
+ {
8795
+ "kind": "Content",
8796
+ "text": "void"
8797
+ },
8798
+ {
8799
+ "kind": "Content",
8800
+ "text": ";"
8801
+ }
8802
+ ],
8803
+ "isStatic": false,
8804
+ "returnTypeTokenRange": {
8805
+ "startIndex": 3,
8806
+ "endIndex": 4
8807
+ },
8808
+ "releaseTag": "Public",
8809
+ "isProtected": false,
8810
+ "overloadIndex": 1,
8811
+ "parameters": [
8812
+ {
8813
+ "parameterName": "tokenLifetime",
8814
+ "parameterTypeTokenRange": {
8815
+ "startIndex": 1,
8816
+ "endIndex": 2
8817
+ },
8818
+ "isOptional": false
8819
+ }
8820
+ ],
8821
+ "isOptional": false,
8822
+ "isAbstract": false,
8823
+ "name": "setTokenLifetime"
8824
+ },
8681
8825
  {
8682
8826
  "kind": "Property",
8683
8827
  "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceAuthenticator#tokenManager:member",
@@ -8744,7 +8888,7 @@
8744
8888
  {
8745
8889
  "kind": "Constructor",
8746
8890
  "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager:constructor(1)",
8747
- "docComment": "/**\n * Create a new VpcInstanceTokenManager instance.\n *\n * @remarks\n *\n * At most one of \"iamProfileCrn\" or \"iamProfileId\" may be specified. If neither one is specified, then the default IAM profile defined for the compute resource will be used.\n *\n * @param options - Configuration options. This should be an object containing these fields: - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: \"http://169.254.169.254\") - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token\n */\n",
8891
+ "docComment": "/**\n * Create a new VpcInstanceTokenManager instance.\n *\n * @remarks\n *\n * At most one of \"iamProfileCrn\", \"iamProfileId\" or \"iamProfileName\" may be specified. If neither one is specified, then the default IAM profile defined for the compute resource will be used.\n *\n * @param options - Configuration options. This should be an object containing these fields: - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: \"http://169.254.169.254\") - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token\n */\n",
8748
8892
  "excerptTokens": [
8749
8893
  {
8750
8894
  "kind": "Content",
@@ -8774,6 +8918,68 @@
8774
8918
  }
8775
8919
  ]
8776
8920
  },
8921
+ {
8922
+ "kind": "Method",
8923
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager#getAccessTokenPath:member(1)",
8924
+ "docComment": "",
8925
+ "excerptTokens": [
8926
+ {
8927
+ "kind": "Content",
8928
+ "text": "protected getAccessTokenPath(): "
8929
+ },
8930
+ {
8931
+ "kind": "Content",
8932
+ "text": "string"
8933
+ },
8934
+ {
8935
+ "kind": "Content",
8936
+ "text": ";"
8937
+ }
8938
+ ],
8939
+ "isStatic": false,
8940
+ "returnTypeTokenRange": {
8941
+ "startIndex": 1,
8942
+ "endIndex": 2
8943
+ },
8944
+ "releaseTag": "Public",
8945
+ "isProtected": true,
8946
+ "overloadIndex": 1,
8947
+ "parameters": [],
8948
+ "isOptional": false,
8949
+ "isAbstract": false,
8950
+ "name": "getAccessTokenPath"
8951
+ },
8952
+ {
8953
+ "kind": "Method",
8954
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager#getIamTokenPath:member(1)",
8955
+ "docComment": "",
8956
+ "excerptTokens": [
8957
+ {
8958
+ "kind": "Content",
8959
+ "text": "protected getIamTokenPath(): "
8960
+ },
8961
+ {
8962
+ "kind": "Content",
8963
+ "text": "string"
8964
+ },
8965
+ {
8966
+ "kind": "Content",
8967
+ "text": ";"
8968
+ }
8969
+ ],
8970
+ "isStatic": false,
8971
+ "returnTypeTokenRange": {
8972
+ "startIndex": 1,
8973
+ "endIndex": 2
8974
+ },
8975
+ "releaseTag": "Public",
8976
+ "isProtected": true,
8977
+ "overloadIndex": 1,
8978
+ "parameters": [],
8979
+ "isOptional": false,
8980
+ "isAbstract": false,
8981
+ "name": "getIamTokenPath"
8982
+ },
8777
8983
  {
8778
8984
  "kind": "Method",
8779
8985
  "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager#isTokenExpired:member(1)",
@@ -8936,6 +9142,150 @@
8936
9142
  "isOptional": false,
8937
9143
  "isAbstract": false,
8938
9144
  "name": "setIamProfileId"
9145
+ },
9146
+ {
9147
+ "kind": "Method",
9148
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager#setIamProfileName:member(1)",
9149
+ "docComment": "/**\n * Sets the name of the IAM trusted profile to use when fetching access token from the IAM token server.\n *\n * @param iamProfileName - the name of the IAM trusted profile\n */\n",
9150
+ "excerptTokens": [
9151
+ {
9152
+ "kind": "Content",
9153
+ "text": "setIamProfileName(iamProfileName: "
9154
+ },
9155
+ {
9156
+ "kind": "Content",
9157
+ "text": "string"
9158
+ },
9159
+ {
9160
+ "kind": "Content",
9161
+ "text": "): "
9162
+ },
9163
+ {
9164
+ "kind": "Content",
9165
+ "text": "void"
9166
+ },
9167
+ {
9168
+ "kind": "Content",
9169
+ "text": ";"
9170
+ }
9171
+ ],
9172
+ "isStatic": false,
9173
+ "returnTypeTokenRange": {
9174
+ "startIndex": 3,
9175
+ "endIndex": 4
9176
+ },
9177
+ "releaseTag": "Public",
9178
+ "isProtected": false,
9179
+ "overloadIndex": 1,
9180
+ "parameters": [
9181
+ {
9182
+ "parameterName": "iamProfileName",
9183
+ "parameterTypeTokenRange": {
9184
+ "startIndex": 1,
9185
+ "endIndex": 2
9186
+ },
9187
+ "isOptional": false
9188
+ }
9189
+ ],
9190
+ "isOptional": false,
9191
+ "isAbstract": false,
9192
+ "name": "setIamProfileName"
9193
+ },
9194
+ {
9195
+ "kind": "Method",
9196
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager#setServiceVersion:member(1)",
9197
+ "docComment": "",
9198
+ "excerptTokens": [
9199
+ {
9200
+ "kind": "Content",
9201
+ "text": "setServiceVersion(serviceVersion: "
9202
+ },
9203
+ {
9204
+ "kind": "Content",
9205
+ "text": "string"
9206
+ },
9207
+ {
9208
+ "kind": "Content",
9209
+ "text": "): "
9210
+ },
9211
+ {
9212
+ "kind": "Content",
9213
+ "text": "void"
9214
+ },
9215
+ {
9216
+ "kind": "Content",
9217
+ "text": ";"
9218
+ }
9219
+ ],
9220
+ "isStatic": false,
9221
+ "returnTypeTokenRange": {
9222
+ "startIndex": 3,
9223
+ "endIndex": 4
9224
+ },
9225
+ "releaseTag": "Public",
9226
+ "isProtected": false,
9227
+ "overloadIndex": 1,
9228
+ "parameters": [
9229
+ {
9230
+ "parameterName": "serviceVersion",
9231
+ "parameterTypeTokenRange": {
9232
+ "startIndex": 1,
9233
+ "endIndex": 2
9234
+ },
9235
+ "isOptional": false
9236
+ }
9237
+ ],
9238
+ "isOptional": false,
9239
+ "isAbstract": false,
9240
+ "name": "setServiceVersion"
9241
+ },
9242
+ {
9243
+ "kind": "Method",
9244
+ "canonicalReference": "ibm-cloud-sdk-core!VpcInstanceTokenManager#setTokenLifetime:member(1)",
9245
+ "docComment": "",
9246
+ "excerptTokens": [
9247
+ {
9248
+ "kind": "Content",
9249
+ "text": "setTokenLifetime(tokenLifetime: "
9250
+ },
9251
+ {
9252
+ "kind": "Content",
9253
+ "text": "number"
9254
+ },
9255
+ {
9256
+ "kind": "Content",
9257
+ "text": "): "
9258
+ },
9259
+ {
9260
+ "kind": "Content",
9261
+ "text": "void"
9262
+ },
9263
+ {
9264
+ "kind": "Content",
9265
+ "text": ";"
9266
+ }
9267
+ ],
9268
+ "isStatic": false,
9269
+ "returnTypeTokenRange": {
9270
+ "startIndex": 3,
9271
+ "endIndex": 4
9272
+ },
9273
+ "releaseTag": "Public",
9274
+ "isProtected": false,
9275
+ "overloadIndex": 1,
9276
+ "parameters": [
9277
+ {
9278
+ "parameterName": "tokenLifetime",
9279
+ "parameterTypeTokenRange": {
9280
+ "startIndex": 1,
9281
+ "endIndex": 2
9282
+ },
9283
+ "isOptional": false
9284
+ }
9285
+ ],
9286
+ "isOptional": false,
9287
+ "isAbstract": false,
9288
+ "name": "setTokenLifetime"
8939
9289
  }
8940
9290
  ],
8941
9291
  "extendsTokenRange": {
@@ -21,6 +21,12 @@ export interface Options extends BaseOptions {
21
21
  iamProfileCrn?: string;
22
22
  /** The ID of the linked trusted IAM profile to be used when obtaining the IAM access token */
23
23
  iamProfileId?: string;
24
+ /** The name of the linked trusted IAM profile to be used when obtaining the IAM access token */
25
+ iamProfileName?: string;
26
+ /** The version of the Instance Metadata Service to be used obtaining tokens */
27
+ serviceVersion?: string;
28
+ /** The lifetime of the Instance Identity Token */
29
+ tokenLifetime?: number;
24
30
  }
25
31
  /**
26
32
  * The VpcInstanceAuthenticator implements an authentication scheme in which it retrieves an "instance identity token"
@@ -36,6 +42,9 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
36
42
  protected tokenManager: VpcInstanceTokenManager;
37
43
  private iamProfileCrn;
38
44
  private iamProfileId;
45
+ private iamProfileName;
46
+ private serviceVersion;
47
+ private tokenLifetime;
39
48
  /**
40
49
  * Create a new VpcInstanceAuthenticator instance.
41
50
  *
@@ -44,9 +53,10 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
44
53
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
45
54
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
46
55
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
56
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
47
57
  *
48
58
  * @remarks
49
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
59
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
50
60
  * then the default IAM profile defined for the compute resource will be used.
51
61
  */
52
62
  constructor(options: Options);
@@ -60,6 +70,13 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
60
70
  * @param iamProfileId - the ID of the linked IAM trusted profile to use when obtaining an IAM access token
61
71
  */
62
72
  setIamProfileId(iamProfileId: string): void;
73
+ /**
74
+ * Sets the "iamProfileName" value to be used when obtaining an IAM access token
75
+ * @param iamProfileName - the name of the linked IAM trusted profile to use when obtaining an IAM access token
76
+ */
77
+ setIamProfileName(iamProfileName: string): void;
78
+ setServiceVersion(serviceVersion: string): void;
79
+ setTokenLifetime(tokenLifetime: number): void;
63
80
  /**
64
81
  * Returns the authenticator's type ('vpc').
65
82
  *
@@ -35,9 +35,10 @@ export class VpcInstanceAuthenticator extends TokenRequestBasedAuthenticator {
35
35
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
36
36
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
37
37
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
38
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
38
39
  *
39
40
  * @remarks
40
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
41
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
41
42
  * then the default IAM profile defined for the compute resource will be used.
42
43
  */
43
44
  constructor(options) {
@@ -50,6 +51,15 @@ export class VpcInstanceAuthenticator extends TokenRequestBasedAuthenticator {
50
51
  if (options.iamProfileId) {
51
52
  this.iamProfileId = options.iamProfileId;
52
53
  }
54
+ if (options.iamProfileName) {
55
+ this.iamProfileName = options.iamProfileName;
56
+ }
57
+ if (options.serviceVersion) {
58
+ this.serviceVersion = options.serviceVersion;
59
+ }
60
+ if (options.tokenLifetime) {
61
+ this.tokenLifetime = options.tokenLifetime;
62
+ }
53
63
  // the param names are shared between the authenticator and the token
54
64
  // manager so we can just pass along the options object.
55
65
  // also, the token manager will handle input validation
@@ -73,6 +83,23 @@ export class VpcInstanceAuthenticator extends TokenRequestBasedAuthenticator {
73
83
  // update properties in token manager
74
84
  this.tokenManager.setIamProfileId(iamProfileId);
75
85
  }
86
+ /**
87
+ * Sets the "iamProfileName" value to be used when obtaining an IAM access token
88
+ * @param iamProfileName - the name of the linked IAM trusted profile to use when obtaining an IAM access token
89
+ */
90
+ setIamProfileName(iamProfileName) {
91
+ this.iamProfileName = iamProfileName;
92
+ // update properties in token manager
93
+ this.tokenManager.setIamProfileName(iamProfileName);
94
+ }
95
+ setServiceVersion(serviceVersion) {
96
+ this.serviceVersion = serviceVersion;
97
+ this.tokenManager.setServiceVersion(serviceVersion);
98
+ }
99
+ setTokenLifetime(tokenLifetime) {
100
+ this.tokenLifetime = tokenLifetime;
101
+ this.tokenManager.setTokenLifetime(tokenLifetime);
102
+ }
76
103
  /**
77
104
  * Returns the authenticator's type ('vpc').
78
105
  *
@@ -20,6 +20,12 @@ interface Options extends JwtTokenManagerOptions {
20
20
  iamProfileCrn?: string;
21
21
  /** The ID of the linked trusted IAM profile to be used when obtaining the IAM access token */
22
22
  iamProfileId?: string;
23
+ /** The name of the linked trusted IAM profile to be used when obtaining the IAM access token */
24
+ iamProfileName?: string;
25
+ /** The version of the Instance Metadata Service to be used obtaining tokens */
26
+ serviceVersion?: string;
27
+ /** The lifetime of the Instance Identity Token */
28
+ tokenLifetime?: number;
23
29
  }
24
30
  /**
25
31
  * Token Manager for VPC Instance Authentication.
@@ -27,6 +33,9 @@ interface Options extends JwtTokenManagerOptions {
27
33
  export declare class VpcInstanceTokenManager extends JwtTokenManager {
28
34
  private iamProfileCrn;
29
35
  private iamProfileId;
36
+ private iamProfileName;
37
+ private serviceVersion;
38
+ private tokenLifetime;
30
39
  /**
31
40
  * Create a new VpcInstanceTokenManager instance.
32
41
  *
@@ -35,9 +44,10 @@ export declare class VpcInstanceTokenManager extends JwtTokenManager {
35
44
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
36
45
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
37
46
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
47
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
38
48
  *
39
49
  * @remarks
40
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
50
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
41
51
  * then the default IAM profile defined for the compute resource will be used.
42
52
  */
43
53
  constructor(options: Options);
@@ -51,6 +61,15 @@ export declare class VpcInstanceTokenManager extends JwtTokenManager {
51
61
  * @param iamProfileId - the ID of the IAM trusted profile
52
62
  */
53
63
  setIamProfileId(iamProfileId: string): void;
64
+ /**
65
+ * Sets the name of the IAM trusted profile to use when fetching access token from the IAM token server.
66
+ * @param iamProfileName - the name of the IAM trusted profile
67
+ */
68
+ setIamProfileName(iamProfileName: string): void;
69
+ setServiceVersion(serviceVersion: string): void;
70
+ setTokenLifetime(tokenLifetime: number): void;
71
+ protected getAccessTokenPath(): string;
72
+ protected getIamTokenPath(): string;
54
73
  protected requestToken(): Promise<any>;
55
74
  private getInstanceIdentityToken;
56
75
  /**
@@ -28,7 +28,14 @@ import { buildUserAgent } from '../../lib/build-user-agent';
28
28
  import { JwtTokenManager } from './jwt-token-manager';
29
29
  const DEFAULT_IMS_ENDPOINT = 'http://169.254.169.254';
30
30
  const METADATA_SERVICE_VERSION = '2022-03-01';
31
+ const METADATA_SERVICE_VERSION2 = '2025-08-26';
31
32
  const IAM_EXPIRATION_WINDOW = 10;
33
+ const METADATA_TOKEN_LIFETIME = 300;
34
+ const DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN = '/instance_identity/v1/token';
35
+ const DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN = '/instance_identity/v1/iam_token';
36
+ const DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN2 = '/identity/v1/token';
37
+ const DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN2 = '/identity/v1/iam_tokens';
38
+ const metadataServiceSupportedVersions = [METADATA_SERVICE_VERSION, METADATA_SERVICE_VERSION2];
32
39
  /**
33
40
  * Token Manager for VPC Instance Authentication.
34
41
  */
@@ -41,25 +48,41 @@ export class VpcInstanceTokenManager extends JwtTokenManager {
41
48
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
42
49
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
43
50
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
51
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
44
52
  *
45
53
  * @remarks
46
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
54
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
47
55
  * then the default IAM profile defined for the compute resource will be used.
48
56
  */
49
57
  constructor(options) {
50
58
  // all parameters are optional
51
59
  options = options || {};
52
60
  super(options);
53
- if (!atMostOne(options.iamProfileId, options.iamProfileCrn)) {
54
- throw new Error('At most one of `iamProfileId` or `iamProfileCrn` may be specified.');
61
+ if (!atMostOne(options.iamProfileId, options.iamProfileCrn, options.iamProfileName)) {
62
+ throw new Error('At most one of `iamProfileId`, `iamProfileCrn` or `iamProfileName` may be specified.');
55
63
  }
56
64
  this.url = options.url || DEFAULT_IMS_ENDPOINT;
65
+ // Validate and set serviceVersion
66
+ const serviceVersion = options.serviceVersion || METADATA_SERVICE_VERSION;
67
+ if (!metadataServiceSupportedVersions.includes(serviceVersion)) {
68
+ throw new Error(`Invalid serviceVersion. Must be one of: ${metadataServiceSupportedVersions.join(', ')}`);
69
+ }
70
+ this.serviceVersion = serviceVersion;
71
+ // Validate and set tokenLifetime
72
+ const tokenLifetime = options.tokenLifetime || METADATA_TOKEN_LIFETIME;
73
+ if (typeof tokenLifetime !== 'number' || tokenLifetime < 0) {
74
+ throw new Error('tokenLifetime must be a non-negative number');
75
+ }
76
+ this.tokenLifetime = tokenLifetime;
57
77
  if (options.iamProfileCrn) {
58
78
  this.iamProfileCrn = options.iamProfileCrn;
59
79
  }
60
80
  if (options.iamProfileId) {
61
81
  this.iamProfileId = options.iamProfileId;
62
82
  }
83
+ if (options.iamProfileName) {
84
+ this.iamProfileName = options.iamProfileName;
85
+ }
63
86
  this.userAgent = buildUserAgent('vpc-instance-authenticator');
64
87
  }
65
88
  /**
@@ -76,6 +99,37 @@ export class VpcInstanceTokenManager extends JwtTokenManager {
76
99
  setIamProfileId(iamProfileId) {
77
100
  this.iamProfileId = iamProfileId;
78
101
  }
102
+ /**
103
+ * Sets the name of the IAM trusted profile to use when fetching access token from the IAM token server.
104
+ * @param iamProfileName - the name of the IAM trusted profile
105
+ */
106
+ setIamProfileName(iamProfileName) {
107
+ this.iamProfileName = iamProfileName;
108
+ }
109
+ setServiceVersion(serviceVersion) {
110
+ if (!metadataServiceSupportedVersions.includes(serviceVersion)) {
111
+ throw new Error(`Invalid serviceVersion. Must be one of: ${metadataServiceSupportedVersions.join(', ')}`);
112
+ }
113
+ this.serviceVersion = serviceVersion;
114
+ }
115
+ setTokenLifetime(tokenLifetime) {
116
+ if (typeof tokenLifetime !== 'number' || tokenLifetime < 0) {
117
+ throw new Error('tokenLifetime must be a non-negative number');
118
+ }
119
+ this.tokenLifetime = tokenLifetime;
120
+ }
121
+ getAccessTokenPath() {
122
+ if (this.serviceVersion === METADATA_SERVICE_VERSION2) {
123
+ return DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN2;
124
+ }
125
+ return DEFAULT_OPERATION_PATH_CREATE_ACCESS_TOKEN;
126
+ }
127
+ getIamTokenPath() {
128
+ if (this.serviceVersion === METADATA_SERVICE_VERSION2) {
129
+ return DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN2;
130
+ }
131
+ return DEFAULT_OPERATION_PATH_CREATE_IAM_TOKEN;
132
+ }
79
133
  requestToken() {
80
134
  return __awaiter(this, void 0, void 0, function* () {
81
135
  const instanceIdentityToken = yield this.getInstanceIdentityToken();
@@ -91,11 +145,16 @@ export class VpcInstanceTokenManager extends JwtTokenManager {
91
145
  trusted_profile: { crn: this.iamProfileCrn },
92
146
  };
93
147
  }
148
+ else if (this.iamProfileName) {
149
+ body = {
150
+ trusted_profile: { name: this.iamProfileName },
151
+ };
152
+ }
94
153
  const parameters = {
95
154
  options: {
96
- url: `${this.url}/instance_identity/v1/iam_token`,
155
+ url: `${this.url}${this.getIamTokenPath()}`,
97
156
  qs: {
98
- version: METADATA_SERVICE_VERSION,
157
+ version: this.serviceVersion,
99
158
  },
100
159
  body,
101
160
  method: 'POST',
@@ -104,6 +163,7 @@ export class VpcInstanceTokenManager extends JwtTokenManager {
104
163
  'User-Agent': this.userAgent,
105
164
  Accept: 'application/json',
106
165
  Authorization: `Bearer ${instanceIdentityToken}`,
166
+ 'Metadata-Flavor': 'ibm',
107
167
  },
108
168
  },
109
169
  };
@@ -118,12 +178,12 @@ export class VpcInstanceTokenManager extends JwtTokenManager {
118
178
  return __awaiter(this, void 0, void 0, function* () {
119
179
  const parameters = {
120
180
  options: {
121
- url: `${this.url}/instance_identity/v1/token`,
181
+ url: `${this.url}${this.getAccessTokenPath()}`,
122
182
  qs: {
123
- version: METADATA_SERVICE_VERSION,
183
+ version: this.serviceVersion,
124
184
  },
125
185
  body: {
126
- expires_in: 300,
186
+ expires_in: this.tokenLifetime,
127
187
  },
128
188
  method: 'PUT',
129
189
  headers: {
@@ -1319,6 +1319,12 @@ declare interface Options_10 extends BaseOptions {
1319
1319
  iamProfileCrn?: string;
1320
1320
  /** The ID of the linked trusted IAM profile to be used when obtaining the IAM access token */
1321
1321
  iamProfileId?: string;
1322
+ /** The name of the linked trusted IAM profile to be used when obtaining the IAM access token */
1323
+ iamProfileName?: string;
1324
+ /** The version of the Instance Metadata Service to be used obtaining tokens */
1325
+ serviceVersion?: string;
1326
+ /** The lifetime of the Instance Identity Token */
1327
+ tokenLifetime?: number;
1322
1328
  }
1323
1329
 
1324
1330
  /**
@@ -1522,6 +1528,12 @@ declare interface Options_9 extends JwtTokenManagerOptions {
1522
1528
  iamProfileCrn?: string;
1523
1529
  /** The ID of the linked trusted IAM profile to be used when obtaining the IAM access token */
1524
1530
  iamProfileId?: string;
1531
+ /** The name of the linked trusted IAM profile to be used when obtaining the IAM access token */
1532
+ iamProfileName?: string;
1533
+ /** The version of the Instance Metadata Service to be used obtaining tokens */
1534
+ serviceVersion?: string;
1535
+ /** The lifetime of the Instance Identity Token */
1536
+ tokenLifetime?: number;
1525
1537
  }
1526
1538
 
1527
1539
  /**
@@ -1936,6 +1948,9 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
1936
1948
  protected tokenManager: VpcInstanceTokenManager;
1937
1949
  private iamProfileCrn;
1938
1950
  private iamProfileId;
1951
+ private iamProfileName;
1952
+ private serviceVersion;
1953
+ private tokenLifetime;
1939
1954
  /**
1940
1955
  * Create a new VpcInstanceAuthenticator instance.
1941
1956
  *
@@ -1944,9 +1959,10 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
1944
1959
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
1945
1960
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
1946
1961
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
1962
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
1947
1963
  *
1948
1964
  * @remarks
1949
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
1965
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
1950
1966
  * then the default IAM profile defined for the compute resource will be used.
1951
1967
  */
1952
1968
  constructor(options: Options_10);
@@ -1960,6 +1976,13 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
1960
1976
  * @param iamProfileId - the ID of the linked IAM trusted profile to use when obtaining an IAM access token
1961
1977
  */
1962
1978
  setIamProfileId(iamProfileId: string): void;
1979
+ /**
1980
+ * Sets the "iamProfileName" value to be used when obtaining an IAM access token
1981
+ * @param iamProfileName - the name of the linked IAM trusted profile to use when obtaining an IAM access token
1982
+ */
1983
+ setIamProfileName(iamProfileName: string): void;
1984
+ setServiceVersion(serviceVersion: string): void;
1985
+ setTokenLifetime(tokenLifetime: number): void;
1963
1986
  /**
1964
1987
  * Returns the authenticator's type ('vpc').
1965
1988
  *
@@ -1974,6 +1997,9 @@ export declare class VpcInstanceAuthenticator extends TokenRequestBasedAuthentic
1974
1997
  export declare class VpcInstanceTokenManager extends JwtTokenManager {
1975
1998
  private iamProfileCrn;
1976
1999
  private iamProfileId;
2000
+ private iamProfileName;
2001
+ private serviceVersion;
2002
+ private tokenLifetime;
1977
2003
  /**
1978
2004
  * Create a new VpcInstanceTokenManager instance.
1979
2005
  *
@@ -1982,9 +2008,10 @@ export declare class VpcInstanceTokenManager extends JwtTokenManager {
1982
2008
  * - url: (optional) the endpoint URL for the VPC Instance Metadata Service (default value: "http://169.254.169.254")
1983
2009
  * - iamProfileCrn: (optional) the CRN of the linked IAM trusted profile to be used to obtain the IAM access token
1984
2010
  * - iamProfileId: (optional) the ID of the linked IAM trusted profile to be used to obtain the IAM access token
2011
+ * - iamProfileName: (optional) the name of the linked IAM trusted profile to be used to obtain the IAM access token
1985
2012
  *
1986
2013
  * @remarks
1987
- * At most one of "iamProfileCrn" or "iamProfileId" may be specified. If neither one is specified,
2014
+ * At most one of "iamProfileCrn", "iamProfileId" or "iamProfileName" may be specified. If neither one is specified,
1988
2015
  * then the default IAM profile defined for the compute resource will be used.
1989
2016
  */
1990
2017
  constructor(options: Options_9);
@@ -1998,6 +2025,15 @@ export declare class VpcInstanceTokenManager extends JwtTokenManager {
1998
2025
  * @param iamProfileId - the ID of the IAM trusted profile
1999
2026
  */
2000
2027
  setIamProfileId(iamProfileId: string): void;
2028
+ /**
2029
+ * Sets the name of the IAM trusted profile to use when fetching access token from the IAM token server.
2030
+ * @param iamProfileName - the name of the IAM trusted profile
2031
+ */
2032
+ setIamProfileName(iamProfileName: string): void;
2033
+ setServiceVersion(serviceVersion: string): void;
2034
+ setTokenLifetime(tokenLifetime: number): void;
2035
+ protected getAccessTokenPath(): string;
2036
+ protected getIamTokenPath(): string;
2001
2037
  protected requestToken(): Promise<any>;
2002
2038
  private getInstanceIdentityToken;
2003
2039
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ibm-cloud-sdk-core",
3
- "version": "5.4.22",
3
+ "version": "5.6.0",
4
4
  "description": "Core functionality to support SDKs generated with IBM's OpenAPI SDK Generator.",
5
5
  "main": "./index.js",
6
6
  "typings": "./es/index.d.ts",