@aws-cdk/toolkit-lib 0.3.0 → 0.3.2

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.
@@ -1202,6 +1202,168 @@ export interface IIoHost {
1202
1202
  */
1203
1203
  requestResponse<T, U>(msg: IoRequest<T, U>): Promise<U>;
1204
1204
  }
1205
+ type ForReading = 0;
1206
+ type ForWriting = 1;
1207
+ interface CredentialProviderSource {
1208
+ name: string;
1209
+ /**
1210
+ * Whether the credential provider is even online
1211
+ *
1212
+ * Guaranteed to be called before any of the other functions are called.
1213
+ */
1214
+ isAvailable(): Promise<boolean>;
1215
+ /**
1216
+ * Whether the credential provider can provide credentials for the given account.
1217
+ */
1218
+ canProvideCredentials(accountId: string): Promise<boolean>;
1219
+ /**
1220
+ * Construct a credential provider for the given account and the given access mode
1221
+ *
1222
+ * Guaranteed to be called only if canProvideCredentials() returned true at some point.
1223
+ *
1224
+ * While it is possible for the plugin to return a static set of credentials, it is
1225
+ * recommended to return a provider.
1226
+ */
1227
+ getProvider(accountId: string, mode: ForReading | ForWriting, options?: PluginProviderOptions): Promise<PluginProviderResult>;
1228
+ }
1229
+ interface IPluginHost {
1230
+ /**
1231
+ * Registers a credential provider source. If, in the authentication process,
1232
+ * the CLI decides to try credentials from the plugins, it will go through the
1233
+ * sources registered in this way, in the same order as they were registered.
1234
+ */
1235
+ registerCredentialProviderSource(source: CredentialProviderSource): void;
1236
+ }
1237
+ interface PluginProviderOptions {
1238
+ /**
1239
+ * Whether or not this implementation of the CLI will recognize the `SDKv3CompatibleCredentialProvider` return variant
1240
+ *
1241
+ * Unless otherwise indicated, the CLI version will only support SDKv3
1242
+ * credentials, not SDKv3 providers. You should avoid returning types that the
1243
+ * consuming CLI will not understand, because it will most likely crash.
1244
+ *
1245
+ * @default false
1246
+ */
1247
+ readonly supportsV3Providers?: boolean;
1248
+ }
1249
+ type PluginProviderResult = SDKv2CompatibleCredentials | SDKv3CompatibleCredentialProvider | SDKv3CompatibleCredentials;
1250
+ interface SDKv2CompatibleCredentials {
1251
+ /**
1252
+ * AWS access key ID.
1253
+ */
1254
+ accessKeyId: string;
1255
+ /**
1256
+ * Time when credentials should be considered expired.
1257
+ * Used in conjunction with expired.
1258
+ */
1259
+ expireTime?: Date | null;
1260
+ /**
1261
+ * AWS secret access key.
1262
+ */
1263
+ secretAccessKey: string;
1264
+ /**
1265
+ * AWS session token.
1266
+ */
1267
+ sessionToken?: string;
1268
+ /**
1269
+ * Gets the existing credentials, refreshing them if necessary, and returns
1270
+ * a promise that will be fulfilled immediately (if no refresh is necessary)
1271
+ * or when the refresh has completed.
1272
+ */
1273
+ getPromise(): Promise<void>;
1274
+ }
1275
+ type SDKv3CompatibleCredentialProvider = (identityProperties?: Record<string, any>) => Promise<SDKv3CompatibleCredentials>;
1276
+ interface SDKv3CompatibleCredentials {
1277
+ /**
1278
+ * AWS access key ID
1279
+ */
1280
+ readonly accessKeyId: string;
1281
+ /**
1282
+ * AWS secret access key
1283
+ */
1284
+ readonly secretAccessKey: string;
1285
+ /**
1286
+ * A security or session token to use with these credentials. Usually
1287
+ * present for temporary credentials.
1288
+ */
1289
+ readonly sessionToken?: string;
1290
+ /**
1291
+ * A `Date` when the identity or credential will no longer be accepted.
1292
+ */
1293
+ readonly expiration?: Date;
1294
+ }
1295
+ interface ContextProviderPlugin {
1296
+ getValue(args: {
1297
+ [key: string]: any;
1298
+ }): Promise<any>;
1299
+ }
1300
+ /**
1301
+ * Class to manage a plugin collection
1302
+ *
1303
+ * It provides a `load()` function that loads a JavaScript
1304
+ * module from disk, and gives it access to the `IPluginHost` interface
1305
+ * to register itself.
1306
+ */
1307
+ export declare class PluginHost implements IPluginHost {
1308
+ /**
1309
+ * Access the currently registered CredentialProviderSources. New sources can
1310
+ * be registered using the +registerCredentialProviderSource+ method.
1311
+ */
1312
+ readonly credentialProviderSources: CredentialProviderSource[];
1313
+ readonly contextProviderPlugins: Record<string, ContextProviderPlugin>;
1314
+ ioHost?: IIoHost;
1315
+ private readonly alreadyLoaded;
1316
+ /**
1317
+ * Loads a plug-in into this PluginHost.
1318
+ *
1319
+ * Will use `require.resolve()` to get the most accurate representation of what
1320
+ * code will get loaded in error messages. As such, it will not work in
1321
+ * unit tests with Jest virtual modules becauase of <https://github.com/jestjs/jest/issues/9543>.
1322
+ *
1323
+ * @param moduleSpec the specification (path or name) of the plug-in module to be loaded.
1324
+ * @param ioHost the I/O host to use for printing progress information
1325
+ */
1326
+ load(moduleSpec: string, ioHost?: IIoHost): void;
1327
+ /**
1328
+ * Allows plug-ins to register new CredentialProviderSources.
1329
+ *
1330
+ * @param source a new CredentialProviderSource to register.
1331
+ */
1332
+ registerCredentialProviderSource(source: CredentialProviderSource): void;
1333
+ /**
1334
+ * (EXPERIMENTAL) Allow plugins to register context providers
1335
+ *
1336
+ * Context providers are objects with the following method:
1337
+ *
1338
+ * ```ts
1339
+ * getValue(args: {[key: string]: any}): Promise<any>;
1340
+ * ```
1341
+ *
1342
+ * Currently, they cannot reuse the CDK's authentication mechanisms, so they
1343
+ * must be prepared to either not make AWS calls or use their own source of
1344
+ * AWS credentials.
1345
+ *
1346
+ * This feature is experimental, and only intended to be used internally at Amazon
1347
+ * as a trial.
1348
+ *
1349
+ * After registering with 'my-plugin-name', the provider must be addressed as follows:
1350
+ *
1351
+ * ```ts
1352
+ * const value = ContextProvider.getValue(this, {
1353
+ * providerName: 'plugin',
1354
+ * props: {
1355
+ * pluginName: 'my-plugin-name',
1356
+ * myParameter1: 'xyz',
1357
+ * },
1358
+ * includeEnvironment: true | false,
1359
+ * dummyValue: 'what-to-return-on-the-first-pass',
1360
+ * })
1361
+ * ```
1362
+ *
1363
+ * @experimental
1364
+ */
1365
+ registerContextProviderAlpha(pluginProviderName: string, provider: ContextProviderPlugin): void;
1366
+ }
1205
1367
  export interface BootstrapEnvironmentProgress {
1206
1368
  /**
1207
1369
  * The total number of environments being deployed